@iris-ui-kit/vue 0.2.7 → 0.2.8
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/dist/index.cjs +65 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +66 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -9347,7 +9347,14 @@ var IrisTable = vue.defineComponent({
|
|
|
9347
9347
|
getSubRows: {
|
|
9348
9348
|
type: Function,
|
|
9349
9349
|
default: void 0
|
|
9350
|
-
}
|
|
9350
|
+
},
|
|
9351
|
+
/**
|
|
9352
|
+
* Cascade multi-row selection through the complete tree supplied by
|
|
9353
|
+
* `getSubRows`. Selecting a branch selects every descendant (including
|
|
9354
|
+
* collapsed rows); partially selected branches render indeterminate.
|
|
9355
|
+
* Ignored outside tree mode and for non-multi selection.
|
|
9356
|
+
*/
|
|
9357
|
+
treeSelectionCascade: { type: Boolean, default: false }
|
|
9351
9358
|
},
|
|
9352
9359
|
emits: {
|
|
9353
9360
|
"update:selection": (_value) => true,
|
|
@@ -9433,27 +9440,75 @@ var IrisTable = vue.defineComponent({
|
|
|
9433
9440
|
const bodyData = vue.computed(
|
|
9434
9441
|
() => flatTree.value ? flatTree.value.map((t2) => t2.row) : sortedRows.value
|
|
9435
9442
|
);
|
|
9436
|
-
const
|
|
9437
|
-
|
|
9443
|
+
const cascadingTreeSelection = vue.computed(
|
|
9444
|
+
() => props.treeSelectionCascade && props.selectable === "multi" && treeMode.value
|
|
9445
|
+
);
|
|
9446
|
+
const treeSelectionNodes = vue.computed(() => {
|
|
9447
|
+
const getChildren = props.getSubRows;
|
|
9448
|
+
if (!cascadingTreeSelection.value || !getChildren) return [];
|
|
9449
|
+
const nodes = [];
|
|
9450
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9451
|
+
let rowIndex = 0;
|
|
9452
|
+
const walk = (rows, parentKey) => {
|
|
9453
|
+
for (const row of rows) {
|
|
9454
|
+
const key = rowId(row, rowIndex);
|
|
9455
|
+
rowIndex += 1;
|
|
9456
|
+
if (seen.has(key)) continue;
|
|
9457
|
+
seen.add(key);
|
|
9458
|
+
nodes.push({ key, parentKey });
|
|
9459
|
+
const children = getChildren(row);
|
|
9460
|
+
if (children && children.length > 0) walk(children, key);
|
|
9461
|
+
}
|
|
9462
|
+
};
|
|
9463
|
+
walk(sortedRows.value);
|
|
9464
|
+
return nodes;
|
|
9465
|
+
});
|
|
9466
|
+
const resolvedTreeSelection = vue.computed(
|
|
9467
|
+
() => cascadingTreeSelection.value ? core.createTreeSelection({
|
|
9468
|
+
nodes: treeSelectionNodes.value,
|
|
9469
|
+
defaultChecked: displaySelection.value
|
|
9470
|
+
}) : null
|
|
9471
|
+
);
|
|
9472
|
+
const isSelected = (id) => resolvedTreeSelection.value?.isChecked(id) ?? displaySelection.value.includes(id);
|
|
9473
|
+
const isSelectionIndeterminate = (id) => resolvedTreeSelection.value?.isIndeterminate(id) ?? false;
|
|
9474
|
+
const allRowIds = vue.computed(
|
|
9475
|
+
() => cascadingTreeSelection.value ? treeSelectionNodes.value.map((node) => node.key) : bodyData.value.map((row, index) => rowId(row, index))
|
|
9476
|
+
);
|
|
9438
9477
|
const allSelected = vue.computed(() => {
|
|
9439
|
-
|
|
9440
|
-
return allRowIds.value.length > 0 && allRowIds.value.every((id) => sel.includes(id));
|
|
9478
|
+
return allRowIds.value.length > 0 && allRowIds.value.every((id) => isSelected(id));
|
|
9441
9479
|
});
|
|
9442
9480
|
const someSelected = vue.computed(() => {
|
|
9443
|
-
|
|
9444
|
-
return !allSelected.value && allRowIds.value.some((id) => sel.includes(id));
|
|
9481
|
+
return !allSelected.value && allRowIds.value.some((id) => isSelected(id) || isSelectionIndeterminate(id));
|
|
9445
9482
|
});
|
|
9446
9483
|
const toggleRow = (id) => {
|
|
9447
9484
|
rebaseToProp();
|
|
9448
9485
|
if (props.selectable === "single") {
|
|
9449
9486
|
selectionModel.set(selectionModel.isSelected(id) ? [] : [id]);
|
|
9450
9487
|
} else if (props.selectable === "multi") {
|
|
9451
|
-
|
|
9488
|
+
const treeSelection = resolvedTreeSelection.value;
|
|
9489
|
+
if (treeSelection) {
|
|
9490
|
+
treeSelection.toggle(id);
|
|
9491
|
+
selectionModel.set(treeSelection.getChecked());
|
|
9492
|
+
} else {
|
|
9493
|
+
selectionModel.toggle(id);
|
|
9494
|
+
}
|
|
9452
9495
|
}
|
|
9453
9496
|
};
|
|
9454
9497
|
const toggleAll = () => {
|
|
9455
9498
|
rebaseToProp();
|
|
9456
|
-
|
|
9499
|
+
if (allSelected.value) {
|
|
9500
|
+
selectionModel.set([]);
|
|
9501
|
+
return;
|
|
9502
|
+
}
|
|
9503
|
+
if (cascadingTreeSelection.value) {
|
|
9504
|
+
const treeSelection = core.createTreeSelection({
|
|
9505
|
+
nodes: treeSelectionNodes.value,
|
|
9506
|
+
defaultChecked: allRowIds.value
|
|
9507
|
+
});
|
|
9508
|
+
selectionModel.set(treeSelection.getChecked());
|
|
9509
|
+
return;
|
|
9510
|
+
}
|
|
9511
|
+
selectionModel.set([...allRowIds.value]);
|
|
9457
9512
|
};
|
|
9458
9513
|
const editingCellId = vue.ref(null);
|
|
9459
9514
|
const editingDraft = vue.ref("");
|
|
@@ -10015,7 +10070,7 @@ var IrisTable = vue.defineComponent({
|
|
|
10015
10070
|
},
|
|
10016
10071
|
[
|
|
10017
10072
|
vue.h(IrisCheckbox, {
|
|
10018
|
-
modelValue: selected,
|
|
10073
|
+
modelValue: isSelectionIndeterminate(id) ? "indeterminate" : selected,
|
|
10019
10074
|
size: "sm",
|
|
10020
10075
|
ariaLabel: t("table.selectRow", { key: id }),
|
|
10021
10076
|
"onUpdate:modelValue": () => toggleRow(id),
|