@iris-ui-kit/vue 0.2.7 → 0.2.9
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 +87 -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 +88 -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,97 @@ 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 compactTreeSelectionSeed = (keys) => {
|
|
9467
|
+
const selected = new Set(keys);
|
|
9468
|
+
const parentByKey = new Map(
|
|
9469
|
+
treeSelectionNodes.value.map((node) => [node.key, node.parentKey])
|
|
9470
|
+
);
|
|
9471
|
+
return keys.filter((key) => {
|
|
9472
|
+
const visited = /* @__PURE__ */ new Set();
|
|
9473
|
+
let parent = parentByKey.get(key);
|
|
9474
|
+
while (parent !== void 0 && !visited.has(parent)) {
|
|
9475
|
+
if (selected.has(parent)) return false;
|
|
9476
|
+
visited.add(parent);
|
|
9477
|
+
parent = parentByKey.get(parent);
|
|
9478
|
+
}
|
|
9479
|
+
return true;
|
|
9480
|
+
});
|
|
9481
|
+
};
|
|
9482
|
+
const resolvedTreeSelection = vue.computed(
|
|
9483
|
+
() => cascadingTreeSelection.value ? core.createTreeSelection({
|
|
9484
|
+
nodes: treeSelectionNodes.value,
|
|
9485
|
+
// Canonical payloads contain fully-selected branches and their
|
|
9486
|
+
// leaves. Seed only the highest selected ancestors so rebuilding a
|
|
9487
|
+
// large fully-selected tree does not cascade once per descendant.
|
|
9488
|
+
defaultChecked: compactTreeSelectionSeed(displaySelection.value)
|
|
9489
|
+
}) : null
|
|
9490
|
+
);
|
|
9491
|
+
const isSelected = (id) => resolvedTreeSelection.value?.isChecked(id) ?? displaySelection.value.includes(id);
|
|
9492
|
+
const isSelectionIndeterminate = (id) => resolvedTreeSelection.value?.isIndeterminate(id) ?? false;
|
|
9493
|
+
const allRowIds = vue.computed(
|
|
9494
|
+
() => cascadingTreeSelection.value ? treeSelectionNodes.value.map((node) => node.key) : bodyData.value.map((row, index) => rowId(row, index))
|
|
9495
|
+
);
|
|
9438
9496
|
const allSelected = vue.computed(() => {
|
|
9439
|
-
|
|
9440
|
-
return allRowIds.value.length > 0 && allRowIds.value.every((id) => sel.includes(id));
|
|
9497
|
+
return allRowIds.value.length > 0 && allRowIds.value.every((id) => isSelected(id));
|
|
9441
9498
|
});
|
|
9442
9499
|
const someSelected = vue.computed(() => {
|
|
9443
|
-
|
|
9444
|
-
return !allSelected.value && allRowIds.value.some((id) => sel.includes(id));
|
|
9500
|
+
return !allSelected.value && allRowIds.value.some((id) => isSelected(id) || isSelectionIndeterminate(id));
|
|
9445
9501
|
});
|
|
9446
9502
|
const toggleRow = (id) => {
|
|
9447
9503
|
rebaseToProp();
|
|
9448
9504
|
if (props.selectable === "single") {
|
|
9449
9505
|
selectionModel.set(selectionModel.isSelected(id) ? [] : [id]);
|
|
9450
9506
|
} else if (props.selectable === "multi") {
|
|
9451
|
-
|
|
9507
|
+
if (cascadingTreeSelection.value) {
|
|
9508
|
+
const treeSelection = core.createTreeSelection({
|
|
9509
|
+
nodes: treeSelectionNodes.value,
|
|
9510
|
+
defaultChecked: compactTreeSelectionSeed(displaySelection.value)
|
|
9511
|
+
});
|
|
9512
|
+
treeSelection.toggle(id);
|
|
9513
|
+
selectionModel.set(treeSelection.getChecked());
|
|
9514
|
+
} else {
|
|
9515
|
+
selectionModel.toggle(id);
|
|
9516
|
+
}
|
|
9452
9517
|
}
|
|
9453
9518
|
};
|
|
9454
9519
|
const toggleAll = () => {
|
|
9455
9520
|
rebaseToProp();
|
|
9456
|
-
|
|
9521
|
+
if (allSelected.value) {
|
|
9522
|
+
selectionModel.set([]);
|
|
9523
|
+
return;
|
|
9524
|
+
}
|
|
9525
|
+
if (cascadingTreeSelection.value) {
|
|
9526
|
+
const treeSelection = core.createTreeSelection({
|
|
9527
|
+
nodes: treeSelectionNodes.value,
|
|
9528
|
+
defaultChecked: allRowIds.value
|
|
9529
|
+
});
|
|
9530
|
+
selectionModel.set(treeSelection.getChecked());
|
|
9531
|
+
return;
|
|
9532
|
+
}
|
|
9533
|
+
selectionModel.set([...allRowIds.value]);
|
|
9457
9534
|
};
|
|
9458
9535
|
const editingCellId = vue.ref(null);
|
|
9459
9536
|
const editingDraft = vue.ref("");
|
|
@@ -10015,7 +10092,7 @@ var IrisTable = vue.defineComponent({
|
|
|
10015
10092
|
},
|
|
10016
10093
|
[
|
|
10017
10094
|
vue.h(IrisCheckbox, {
|
|
10018
|
-
modelValue: selected,
|
|
10095
|
+
modelValue: isSelectionIndeterminate(id) ? "indeterminate" : selected,
|
|
10019
10096
|
size: "sm",
|
|
10020
10097
|
ariaLabel: t("table.selectRow", { key: id }),
|
|
10021
10098
|
"onUpdate:modelValue": () => toggleRow(id),
|