schummar-table 1.0.0-beta.6 → 1.0.0-beta.7
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 +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/mantineTheme.d.cts +1 -1
- package/dist/mantineTheme.d.ts +1 -1
- package/dist/mui4Theme.d.cts +1 -1
- package/dist/mui4Theme.d.ts +1 -1
- package/dist/mui5Theme.d.cts +1 -1
- package/dist/mui5Theme.d.ts +1 -1
- package/dist/{types--I5JSyno.d.cts → types-CWF6E2Xg.d.cts} +3 -2
- package/dist/{types-BFFYueFE.d.ts → types-Dlq59yQq.d.ts} +3 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -269,6 +269,7 @@ function useColumns(props, displaySize) {
|
|
|
269
269
|
//#region src/state/useExpanded.ts
|
|
270
270
|
function useExpanded(props, itemsById, matching) {
|
|
271
271
|
const [value, setExpanded, setExpandedInternal] = useControllableState(props.expanded, () => props.defaultExpanded ?? /* @__PURE__ */ new Set(), props.onExpandedChange);
|
|
272
|
+
const expandOnlyOne = props.expandOnlyOne && !(props.revealFiltered && matching);
|
|
272
273
|
const expanded = useNormalized(value, (0, react.useMemo)(() => {
|
|
273
274
|
let result = value;
|
|
274
275
|
const add = (id) => {
|
|
@@ -276,7 +277,7 @@ function useExpanded(props, itemsById, matching) {
|
|
|
276
277
|
if (result === value) result = new Set(value);
|
|
277
278
|
result.add(id);
|
|
278
279
|
};
|
|
279
|
-
if (
|
|
280
|
+
if (expandOnlyOne && value.size > 1) {
|
|
280
281
|
const deepest = [...value].map((id) => itemsById.get(id)).filter((item) => item !== void 0).sort((a, b) => b.depth - a.depth)[0];
|
|
281
282
|
const branch = deepest ? require_useTheme.getAncestors(itemsById, deepest).add(deepest.id) : /* @__PURE__ */ new Set();
|
|
282
283
|
if ([...value].some((id) => !branch.has(id))) return branch;
|
|
@@ -296,7 +297,7 @@ function useExpanded(props, itemsById, matching) {
|
|
|
296
297
|
value,
|
|
297
298
|
itemsById,
|
|
298
299
|
props.items,
|
|
299
|
-
|
|
300
|
+
expandOnlyOne
|
|
300
301
|
]), setExpanded);
|
|
301
302
|
const latest = (0, react.useRef)({
|
|
302
303
|
expanded,
|
|
@@ -324,6 +325,7 @@ function useExpanded(props, itemsById, matching) {
|
|
|
324
325
|
]);
|
|
325
326
|
return {
|
|
326
327
|
expanded,
|
|
328
|
+
expandOnlyOne,
|
|
327
329
|
setExpanded,
|
|
328
330
|
setExpandedInternal
|
|
329
331
|
};
|
|
@@ -917,11 +919,11 @@ function useTable(raw, onReset, isReset = false) {
|
|
|
917
919
|
setExpanded: (value) => get().expanded.setExpanded(value),
|
|
918
920
|
toggleExpanded(itemId) {
|
|
919
921
|
const { state, expanded } = get();
|
|
920
|
-
const { activeItemsById
|
|
922
|
+
const { activeItemsById } = state;
|
|
921
923
|
const item = activeItemsById.get(itemId);
|
|
922
924
|
const isExpanded = state.expanded.has(itemId);
|
|
923
925
|
const next = new Set(state.expanded);
|
|
924
|
-
if (
|
|
926
|
+
if (expanded.expandOnlyOne) {
|
|
925
927
|
next.clear();
|
|
926
928
|
for (const id of item ? require_useTheme.getAncestors(activeItemsById, item) : []) next.add(id);
|
|
927
929
|
}
|