Use Math.min to simplify ternary clamping expressions (S7766)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 07:37:46 +08:00
parent 731649ed0a
commit 75adbd9c6b
2 changed files with 7 additions and 19 deletions

View File

@@ -68,7 +68,7 @@
dataKey="id" dataKey="id"
breakpoint="0" breakpoint="0"
:tableClass="tableClass" :tableClass="tableClass"
@row-select="onRowSelect" @row-select="onRowSelectionChange"
> >
<ColumnGroup type="header"> <ColumnGroup type="header">
<Row> <Row>
@@ -140,8 +140,8 @@
dataKey="id" dataKey="id"
breakpoint="0" breakpoint="0"
tableClass="w-full !border-separate !border-spacing-x-2 !table-auto text-sm" tableClass="w-full !border-separate !border-spacing-x-2 !table-auto text-sm"
@row-select="onRowSelect" @row-select="onRowSelectionChange"
@row-unselect="onRowUnselect" @row-unselect="onRowSelectionChange"
@row-select-all="onRowSelectAll($event)" @row-select-all="onRowSelectAll($event)"
@row-unselect-all="onRowUnelectAll" @row-unselect-all="onRowUnelectAll"
> >
@@ -526,21 +526,9 @@ const labelsData = computed(() => {
}); });
/** /**
* Selects an option in the categorical table. * Emits the current attribute selection when a row is selected or deselected.
*/ */
function onRowSelect() { function onRowSelectionChange() {
const type = selectedAttName.value.type;
const data = {
type: type,
data: selectedAttRange.value,
};
emit("select-attribute", data);
}
/**
* Deselects an option in the categorical table.
*/
function onRowUnselect() {
const type = selectedAttName.value.type; const type = selectedAttName.value.type;
const data = { const data = {
type: type, type: type,
@@ -915,7 +903,7 @@ function sliderValueRange(e, direction) {
(sliderData[sliderData.length - 1] - sliderData[0])) * (sliderData[sliderData.length - 1] - sliderData[0])) *
sliderData.length; sliderData.length;
let result = Math.round(Math.abs(closestIndex)); let result = Math.round(Math.abs(closestIndex));
result = result > selectRange.value ? selectRange.value : result; result = Math.min(result, selectRange.value);
return result; return result;
}); });
// Update the slider // Update the slider

View File

@@ -381,7 +381,7 @@ function sliderTimeRange(e, direction) {
(sliderDataVal[sliderDataVal.length - 1] - sliderDataVal[0])) * (sliderDataVal[sliderDataVal.length - 1] - sliderDataVal[0])) *
sliderDataVal.length; sliderDataVal.length;
let result = Math.round(Math.abs(closestIndex)); let result = Math.round(Math.abs(closestIndex));
result = result > selectRange.value ? selectRange.value : result; result = Math.min(result, selectRange.value);
return result; return result;
}); });