vueless 0.0.465 → 0.0.466
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
|
@@ -297,7 +297,7 @@ import {
|
|
|
297
297
|
toggleRowVisibility,
|
|
298
298
|
switchRowCheck,
|
|
299
299
|
getFlatRows,
|
|
300
|
-
|
|
300
|
+
addRowId,
|
|
301
301
|
} from "./utilTable.js";
|
|
302
302
|
|
|
303
303
|
import { PX_IN_REM } from "../constants.js";
|
|
@@ -565,20 +565,13 @@ watch(isFooterSticky, (newValue) =>
|
|
|
565
565
|
newValue ? nextTick(setFooterCellWidth) : setFooterCellWidth(null),
|
|
566
566
|
);
|
|
567
567
|
watch(
|
|
568
|
-
() => selectedRows.value
|
|
568
|
+
() => selectedRows.value,
|
|
569
569
|
() => {
|
|
570
|
-
tableRows.value = tableRows.value
|
|
570
|
+
tableRows.value = tableRows.value
|
|
571
|
+
.map(addRowId)
|
|
572
|
+
.map((row) => syncRowCheck(row, selectedRows.value));
|
|
571
573
|
},
|
|
572
|
-
|
|
573
|
-
watch(
|
|
574
|
-
() => props.rows,
|
|
575
|
-
() => {
|
|
576
|
-
if (!rowsHasId(props.rows)) {
|
|
577
|
-
// eslint-disable-next-line no-console
|
|
578
|
-
console.warn("[Vueless][UTable]: Each table row must have unique id.");
|
|
579
|
-
}
|
|
580
|
-
},
|
|
581
|
-
{ deep: true, immediate: true },
|
|
574
|
+
{ deep: true },
|
|
582
575
|
);
|
|
583
576
|
|
|
584
577
|
onMounted(() => {
|
|
@@ -405,7 +405,6 @@ CellSlots.args = {
|
|
|
405
405
|
{ key: "tags", label: "tags" },
|
|
406
406
|
],
|
|
407
407
|
row: {
|
|
408
|
-
id: getRandomId(),
|
|
409
408
|
link: "some link",
|
|
410
409
|
money: {
|
|
411
410
|
sum: 10,
|
|
@@ -418,7 +417,6 @@ CellSlots.args = {
|
|
|
418
417
|
},
|
|
419
418
|
row: [
|
|
420
419
|
{
|
|
421
|
-
id: getRandomId(),
|
|
422
420
|
isHidden: false,
|
|
423
421
|
link: "some link",
|
|
424
422
|
money: {
|
|
@@ -432,7 +430,6 @@ CellSlots.args = {
|
|
|
432
430
|
},
|
|
433
431
|
},
|
|
434
432
|
{
|
|
435
|
-
id: getRandomId(),
|
|
436
433
|
isHidden: false,
|
|
437
434
|
link: "some link",
|
|
438
435
|
money: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getRandomId } from "../utils/utilUI";
|
|
2
|
+
|
|
1
3
|
export function normalizeColumns(columns) {
|
|
2
4
|
return columns.map((column) => (typeof column === "string" ? { label: column } : column));
|
|
3
5
|
}
|
|
@@ -15,13 +17,29 @@ export function getFilteredRow(row, columns) {
|
|
|
15
17
|
export function syncRowCheck(row, selectedRows) {
|
|
16
18
|
row.isChecked = selectedRows.includes(row.id);
|
|
17
19
|
|
|
18
|
-
if (row.row) {
|
|
20
|
+
if (row.row && !Array.isArray(row.row)) {
|
|
19
21
|
row.row = syncRowCheck(row.row, selectedRows);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
return row;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
export function addRowId(row) {
|
|
28
|
+
const hasRowId = typeof row.id !== "undefined" && row.id !== null && row.id !== "";
|
|
29
|
+
|
|
30
|
+
row.id = hasRowId ? row.id : getRandomId();
|
|
31
|
+
|
|
32
|
+
if (row.row && !Array.isArray(row.row)) {
|
|
33
|
+
row.row = addRowId(row.row);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (row.row && Array.isArray(row.row)) {
|
|
37
|
+
row.row = row.row.map((nestedRow) => addRowId(nestedRow));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return row;
|
|
41
|
+
}
|
|
42
|
+
|
|
25
43
|
export function toggleRowVisibility(row, targetRowId) {
|
|
26
44
|
if (row.id === targetRowId) {
|
|
27
45
|
if (Object.hasOwn(row, "isHidden")) {
|
|
@@ -73,28 +91,3 @@ export function getFlatRows(tableRows) {
|
|
|
73
91
|
|
|
74
92
|
return rows;
|
|
75
93
|
}
|
|
76
|
-
|
|
77
|
-
export function rowsHasId(rows) {
|
|
78
|
-
const ids = new Set();
|
|
79
|
-
let totalRows = 0;
|
|
80
|
-
|
|
81
|
-
function addId(row) {
|
|
82
|
-
totalRows++;
|
|
83
|
-
|
|
84
|
-
if (typeof row.id !== "undefined") {
|
|
85
|
-
ids.add(row.id);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (row.row && !Array.isArray(row.row)) {
|
|
89
|
-
addId(row.row);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (row.row && Array.isArray(row.row)) {
|
|
93
|
-
row.row.forEach(addId);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
rows.forEach((row) => addId(row));
|
|
98
|
-
|
|
99
|
-
return ids.size === totalRows;
|
|
100
|
-
}
|