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