schummar-table 1.0.0-beta.6 → 1.0.0-beta.8

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 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 (props.expandOnlyOne && value.size > 1) {
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
- props.expandOnlyOne
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, props } = state;
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 (props.expandOnlyOne) {
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
  }
@@ -1604,19 +1606,22 @@ function SortComponent({ children }) {
1604
1606
  display: "grid",
1605
1607
  gridTemplateColumns: "minmax(0, 1fr) max-content",
1606
1608
  alignItems: "center",
1607
- cursor: "pointer",
1608
- "& > div": {
1609
- overflow: "hidden",
1610
- textOverflow: "ellipsis"
1611
- }
1609
+ cursor: "pointer"
1612
1610
  },
1613
1611
  onClick: (event) => toggle(event),
1614
1612
  onContextMenu: (event) => toggle(event, true),
1615
- children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", { children }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Badge, {
1613
+ children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
1614
+ css: {
1615
+ overflow: "hidden",
1616
+ textOverflow: "ellipsis"
1617
+ },
1618
+ children
1619
+ }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(Badge, {
1616
1620
  badgeContent: sortDisabled ? 0 : index,
1617
1621
  children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
1618
1622
  css: [
1619
1623
  {
1624
+ display: "inline-flex",
1620
1625
  transition: "all 300ms",
1621
1626
  fontSize: "0.8em"
1622
1627
  },