schummar-table 0.10.4 → 0.10.5
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/cjs/index.js +22 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +22 -18
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -545,30 +545,34 @@ function filterColumns(state) {
|
|
|
545
545
|
}
|
|
546
546
|
function normalizeExpanded(table) {
|
|
547
547
|
react.useEffect(() => table.addReaction((state) => [state.props.expandOnlyOne, state.expanded, state.itemsById], ([expandOnlyOne, , itemsById], state) => {
|
|
548
|
-
var _a, _b;
|
|
548
|
+
var _a, _b, _c, _d, _e;
|
|
549
549
|
let expanded = state.expanded;
|
|
550
|
-
let last, lastItem;
|
|
551
550
|
let hasChanged = false;
|
|
552
|
-
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
551
|
+
const allAncestors = [...expanded].map((id) => {
|
|
552
|
+
const item = itemsById.get(id);
|
|
553
|
+
return {
|
|
554
|
+
id,
|
|
555
|
+
ancestors: item ? getAncestors(itemsById, item) : /* @__PURE__ */ new Set()
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
if (expandOnlyOne) {
|
|
559
|
+
const withMostAncestors = orderBy(allAncestors, [(x) => x.ancestors.size], ["desc"])[0];
|
|
560
|
+
if ([...expanded].some((id) => id !== (withMostAncestors == null ? void 0 : withMostAncestors.id) && !(withMostAncestors == null ? void 0 : withMostAncestors.ancestors.has(id)))) {
|
|
561
|
+
expanded = state.expanded = (_a = withMostAncestors == null ? void 0 : withMostAncestors.ancestors) != null ? _a : /* @__PURE__ */ new Set();
|
|
562
|
+
(_c = (_b = state.props).onExpandedChange) == null ? void 0 : _c.call(_b, expanded);
|
|
563
|
+
return;
|
|
557
564
|
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
expanded.add(ancestor);
|
|
565
|
-
hasChanged = true;
|
|
566
|
-
}
|
|
565
|
+
}
|
|
566
|
+
for (const { ancestors } of allAncestors) {
|
|
567
|
+
for (const ancestor of ancestors != null ? ancestors : []) {
|
|
568
|
+
if (!expanded.has(ancestor)) {
|
|
569
|
+
expanded.add(ancestor);
|
|
570
|
+
hasChanged = true;
|
|
567
571
|
}
|
|
568
572
|
}
|
|
569
573
|
}
|
|
570
574
|
if (hasChanged) {
|
|
571
|
-
(
|
|
575
|
+
(_e = (_d = state.props).onExpandedChange) == null ? void 0 : _e.call(_d, new Set(expanded));
|
|
572
576
|
}
|
|
573
577
|
}, { runNow: true }), [table]);
|
|
574
578
|
}
|
|
@@ -616,8 +620,8 @@ function useTableState(_props) {
|
|
|
616
620
|
});
|
|
617
621
|
}, []);
|
|
618
622
|
filterColumns(state);
|
|
619
|
-
normalizeExpanded(state);
|
|
620
623
|
calcItems(state);
|
|
624
|
+
normalizeExpanded(state);
|
|
621
625
|
syncSelections(state);
|
|
622
626
|
cleanupState(state);
|
|
623
627
|
react.useEffect(() => {
|