@iris-ui-kit/vue 0.2.8 → 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.js CHANGED
@@ -5538,10 +5538,29 @@ var IrisTable = defineComponent({
5538
5538
  walk(sortedRows.value);
5539
5539
  return nodes;
5540
5540
  });
5541
+ const compactTreeSelectionSeed = (keys) => {
5542
+ const selected = new Set(keys);
5543
+ const parentByKey = new Map(
5544
+ treeSelectionNodes.value.map((node) => [node.key, node.parentKey])
5545
+ );
5546
+ return keys.filter((key) => {
5547
+ const visited = /* @__PURE__ */ new Set();
5548
+ let parent = parentByKey.get(key);
5549
+ while (parent !== void 0 && !visited.has(parent)) {
5550
+ if (selected.has(parent)) return false;
5551
+ visited.add(parent);
5552
+ parent = parentByKey.get(parent);
5553
+ }
5554
+ return true;
5555
+ });
5556
+ };
5541
5557
  const resolvedTreeSelection = computed(
5542
5558
  () => cascadingTreeSelection.value ? createTreeSelection({
5543
5559
  nodes: treeSelectionNodes.value,
5544
- defaultChecked: displaySelection.value
5560
+ // Canonical payloads contain fully-selected branches and their
5561
+ // leaves. Seed only the highest selected ancestors so rebuilding a
5562
+ // large fully-selected tree does not cascade once per descendant.
5563
+ defaultChecked: compactTreeSelectionSeed(displaySelection.value)
5545
5564
  }) : null
5546
5565
  );
5547
5566
  const isSelected = (id) => resolvedTreeSelection.value?.isChecked(id) ?? displaySelection.value.includes(id);
@@ -5560,8 +5579,11 @@ var IrisTable = defineComponent({
5560
5579
  if (props.selectable === "single") {
5561
5580
  selectionModel.set(selectionModel.isSelected(id) ? [] : [id]);
5562
5581
  } else if (props.selectable === "multi") {
5563
- const treeSelection = resolvedTreeSelection.value;
5564
- if (treeSelection) {
5582
+ if (cascadingTreeSelection.value) {
5583
+ const treeSelection = createTreeSelection({
5584
+ nodes: treeSelectionNodes.value,
5585
+ defaultChecked: compactTreeSelectionSeed(displaySelection.value)
5586
+ });
5565
5587
  treeSelection.toggle(id);
5566
5588
  selectionModel.set(treeSelection.getChecked());
5567
5589
  } else {