schummar-table 0.7.0 → 0.7.1

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/es/index.js CHANGED
@@ -308,10 +308,11 @@ function calcItems(state) {
308
308
  state2.activeColumns,
309
309
  state2.expanded
310
310
  ], ([items = [], id, parentId, revealFiltered, sort, filters, filterValues, activeColumns], draft) => {
311
- const tableItems = items.map((item) => __spreadProps(__spreadValues({}, item), {
311
+ const tableItems = items.map((item) => ({
312
312
  id: id(item),
313
313
  parentId: parentId == null ? void 0 : parentId(item),
314
- children: []
314
+ children: [],
315
+ value: item
315
316
  }));
316
317
  let sorted;
317
318
  if (sort.length === 0) {
@@ -326,7 +327,7 @@ function calcItems(state) {
326
327
  direction: sort2.direction
327
328
  }));
328
329
  }).filter(Boolean);
329
- sorted = orderBy(tableItems, selectors.map((x) => x.selector), selectors.map((x) => x.direction));
330
+ sorted = orderBy(tableItems, selectors.map((x) => (item) => x.selector(item.value)), selectors.map((x) => x.direction));
330
331
  }
331
332
  const lookup = /* @__PURE__ */ new Map();
332
333
  for (const item of sorted) {
@@ -360,7 +361,7 @@ function calcItems(state) {
360
361
  if (filterValue === void 0 || !filter.isActive(filterValue))
361
362
  return true;
362
363
  const filterBy = (_a = filter.filterBy) != null ? _a : (x) => x;
363
- const value = filterBy(column.value(item), item);
364
+ const value = filterBy(column.value(item.value), item.value);
364
365
  return castArray(value).some((value2) => filter.test(filterValue, value2));
365
366
  }));
366
367
  if (isActive && item.parentId !== void 0) {
@@ -868,7 +869,7 @@ function Export$1() {
868
869
  activeColumns,
869
870
  activeItems
870
871
  } = table.getState();
871
- const data = [activeColumns.map((column) => String(column.id)), ...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item), item)))];
872
+ const data = [activeColumns.map((column) => String(column.id)), ...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)))];
872
873
  return csvExport(data, options);
873
874
  };
874
875
  const copy = () => {
@@ -1088,11 +1089,11 @@ const Cell = memo(function Cell2({
1088
1089
  const className2 = useTheme((t) => cx(...calcClassNames(t.classes, item, rowIndex)));
1089
1090
  if (!column || !item)
1090
1091
  return null;
1091
- const content = column.renderCell(column.value(item), item);
1092
+ const content = column.renderCell(column.value(item.value), item.value);
1092
1093
  return jsx("div", {
1093
1094
  className: className2,
1094
1095
  css: [defaultClasses.cell, columnStyleOverride],
1095
- children: wrapCell(content, column.value(item), item, rowIndex)
1096
+ children: wrapCell(content, column.value(item.value), item.value, rowIndex)
1096
1097
  });
1097
1098
  });
1098
1099
  function ExpandControl({
@@ -1246,10 +1247,10 @@ const Row = memo(function Row2({
1246
1247
  className: cx(...calcClassNames(classes, item, rowIndex)),
1247
1248
  indent: item ? getAncestors(state.activeItemsById, item).size : 0,
1248
1249
  hasChildren: !!(item == null ? void 0 : item.children.length),
1249
- hasDeferredChildren: item && ((_b = (_a = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a, item)),
1250
+ hasDeferredChildren: item && ((_b = (_a = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a, item.value)),
1250
1251
  columnIds: state.activeColumns.map((column) => column.id),
1251
1252
  enableSelection: state.props.enableSelection,
1252
- rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item, rowIndex) : null : state.props.rowAction
1253
+ rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item.value, rowIndex) : null : state.props.rowAction
1253
1254
  };
1254
1255
  });
1255
1256
  useEffect(() => {
@@ -2627,7 +2628,7 @@ function SelectFilter(_m) {
2627
2628
  const column = state.activeColumns.find((column2) => column2.id === columnId);
2628
2629
  if (!column)
2629
2630
  return [];
2630
- return uniq(flatMap(state.items, (item) => castArray(filterBy(column.value(item), item))));
2631
+ return uniq(flatMap(state.items, (item) => castArray(filterBy(column.value(item.value), item.value))));
2631
2632
  });
2632
2633
  const [query, setQuery] = useState("");
2633
2634
  const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));