vueless 0.0.533 → 0.0.534
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/ui.data-table/UTable.vue
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
ref,
|
|
4
4
|
computed,
|
|
5
5
|
watch,
|
|
6
|
-
toValue,
|
|
7
6
|
useSlots,
|
|
8
7
|
nextTick,
|
|
9
8
|
onMounted,
|
|
@@ -39,6 +38,7 @@ import { useLocale } from "../composables/useLocale.ts";
|
|
|
39
38
|
|
|
40
39
|
import type { Cell, Row, RowId, UTableProps, UTableRowAttrs } from "./types.ts";
|
|
41
40
|
import type { Ref, RendererElement, ComputedRef } from "vue";
|
|
41
|
+
import { isEqual } from "lodash-es";
|
|
42
42
|
|
|
43
43
|
defineOptions({ inheritAttrs: false });
|
|
44
44
|
|
|
@@ -254,7 +254,15 @@ const tableRowAttrs = computed(() => ({
|
|
|
254
254
|
|
|
255
255
|
watch(selectAll, onChangeSelectAll, { deep: true });
|
|
256
256
|
watch(selectedRows, onChangeSelectedRows, { deep: true });
|
|
257
|
-
watch(
|
|
257
|
+
watch(
|
|
258
|
+
tableRows,
|
|
259
|
+
() => {
|
|
260
|
+
if (!isEqual(tableRows.value, props.rows)) {
|
|
261
|
+
emit("update:rows", tableRows.value);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{ deep: true },
|
|
265
|
+
);
|
|
258
266
|
watch(() => tableRows.value.length, updateSelectedRows);
|
|
259
267
|
watch(() => props.rows, synchronizeTableItemsWithProps, { deep: true });
|
|
260
268
|
watch(isHeaderSticky, setHeaderCellWidth);
|
|
@@ -337,7 +345,9 @@ function synchronizeTableItemsWithProps() {
|
|
|
337
345
|
selectedRows.value = [];
|
|
338
346
|
}
|
|
339
347
|
|
|
340
|
-
tableRows.value
|
|
348
|
+
if (!isEqual(tableRows.value, props.rows)) {
|
|
349
|
+
tableRows.value = props.rows;
|
|
350
|
+
}
|
|
341
351
|
}
|
|
342
352
|
|
|
343
353
|
function updateSelectedRows() {
|
|
@@ -379,11 +389,11 @@ function onChangeSelectAll(selectAll: boolean) {
|
|
|
379
389
|
if (selectAll && canSelectAll.value) {
|
|
380
390
|
selectedRows.value = getFlatRows(tableRows.value).map((row) => row.id);
|
|
381
391
|
|
|
382
|
-
tableRows.value.
|
|
392
|
+
tableRows.value = tableRows.value.map((row) => switchRowCheck({ ...row }, true));
|
|
383
393
|
} else if (!selectAll) {
|
|
384
394
|
selectedRows.value = [];
|
|
385
395
|
|
|
386
|
-
tableRows.value.
|
|
396
|
+
tableRows.value = tableRows.value.map((row) => switchRowCheck({ ...row }, false));
|
|
387
397
|
}
|
|
388
398
|
|
|
389
399
|
canSelectAll.value = true;
|
|
@@ -406,8 +416,7 @@ function clearSelectedItems() {
|
|
|
406
416
|
}
|
|
407
417
|
|
|
408
418
|
function onToggleRowVisibility(rowId: string | number) {
|
|
409
|
-
|
|
410
|
-
tableRows.value.forEach((row) => toggleRowVisibility(row, rowId));
|
|
419
|
+
tableRows.value = tableRows.value.map((row) => toggleRowVisibility({ ...row }, rowId));
|
|
411
420
|
}
|
|
412
421
|
|
|
413
422
|
defineExpose({
|
|
@@ -50,7 +50,7 @@ export function toggleRowVisibility(row: Row, targetRowId: string | number) {
|
|
|
50
50
|
row.nestedData.isHidden = !row.nestedData.isHidden;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
return;
|
|
53
|
+
return row;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (row.row && !Array.isArray(row.row)) {
|
|
@@ -64,6 +64,8 @@ export function toggleRowVisibility(row: Row, targetRowId: string | number) {
|
|
|
64
64
|
if (row.nestedData) {
|
|
65
65
|
toggleRowVisibility(row.nestedData, targetRowId);
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
return row;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
export function switchRowCheck(row: Row, isChecked: boolean) {
|
|
@@ -76,6 +78,8 @@ export function switchRowCheck(row: Row, isChecked: boolean) {
|
|
|
76
78
|
if (row.row && Array.isArray(row.row)) {
|
|
77
79
|
row.row.map((currentRow) => switchRowCheck(currentRow, isChecked));
|
|
78
80
|
}
|
|
81
|
+
|
|
82
|
+
return row;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
export function getFlatRows(tableRows: Row[]) {
|