schummar-table 0.42.0 → 0.43.0

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.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ComponentType, ReactNode, HTMLProps } from 'react';
4
- import { T as TableTheme, C as CommonFilterProps, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-xTAreHv_.cjs';
5
- export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-xTAreHv_.cjs';
4
+ import { T as TableTheme, C as CommonFilterProps, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-B8KLTUz2.cjs';
5
+ export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-B8KLTUz2.cjs';
6
6
  import { Store } from 'schummar-state/react';
7
7
  import { E as ExporterEntry } from './exporter-u6SatTo6.cjs';
8
8
  import '@emotion/react';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ComponentType, ReactNode, HTMLProps } from 'react';
4
- import { T as TableTheme, C as CommonFilterProps, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-DcnzwYBU.js';
5
- export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-DcnzwYBU.js';
4
+ import { T as TableTheme, C as CommonFilterProps, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-C_rX6bDQ.js';
5
+ export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-C_rX6bDQ.js';
6
6
  import { Store } from 'schummar-state/react';
7
7
  import { E as ExporterEntry } from './exporter-u6SatTo6.js';
8
8
  import '@emotion/react';
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  defaultClasses,
9
9
  globalTableTheme,
10
10
  mergeThemes
11
- } from "./chunk-E2DUBLYQ.js";
11
+ } from "./chunk-FTCKJOPQ.js";
12
12
  import "./chunk-WFCJ3D3G.js";
13
13
  import {
14
14
  __async,
@@ -606,17 +606,21 @@ function useTheme(selector) {
606
606
  const memo4 = useTableMemo();
607
607
  const _globalTableTheme = globalTableTheme.useState();
608
608
  const process = (t) => {
609
- var _a2, _b2, _c, _d;
610
- const cellClass = (_a2 = t.classes) == null ? void 0 : _a2.cell;
611
- const cellStyles = (_b2 = t.styles) == null ? void 0 : _b2.cell;
612
- const detailsClass = (_c = t.classes) == null ? void 0 : _c.details;
613
- const detailsStyles = (_d = t.styles) == null ? void 0 : _d.details;
609
+ var _a2, _b2, _c, _d, _e, _f;
610
+ const rowClass = (_a2 = t.classes) == null ? void 0 : _a2.row;
611
+ const rowStyles = (_b2 = t.styles) == null ? void 0 : _b2.row;
612
+ const cellClass = (_c = t.classes) == null ? void 0 : _c.cell;
613
+ const cellStyles = (_d = t.styles) == null ? void 0 : _d.cell;
614
+ const detailsClass = (_e = t.classes) == null ? void 0 : _e.details;
615
+ const detailsStyles = (_f = t.styles) == null ? void 0 : _f.details;
614
616
  return __spreadProps(__spreadValues({}, t), {
615
617
  classes: __spreadProps(__spreadValues({}, t.classes), {
618
+ row: rowClass instanceof Function || Array.isArray(rowClass) ? memo4("theme.classes.row", rowClass) : rowClass,
616
619
  cell: cellClass instanceof Function || Array.isArray(cellClass) ? memo4("theme.classes.cell", cellClass) : cellClass,
617
620
  details: detailsClass instanceof Function || Array.isArray(detailsClass) ? memo4("theme.classes.details", detailsClass) : detailsClass
618
621
  }),
619
622
  styles: __spreadProps(__spreadValues({}, t.styles), {
623
+ row: rowStyles instanceof Function || Array.isArray(rowStyles) ? memo4("theme.styles.row", rowStyles) : rowStyles,
620
624
  cell: cellStyles instanceof Function || Array.isArray(cellStyles) ? memo4("theme.styles.cell", cellStyles) : cellStyles,
621
625
  details: detailsStyles instanceof Function || Array.isArray(detailsStyles) ? memo4("theme.styles.details", detailsStyles) : detailsStyles
622
626
  }),
@@ -2205,7 +2209,7 @@ function SelectFilter(_a) {
2205
2209
  }
2206
2210
 
2207
2211
  // src/components/table.tsx
2208
- import { memo as memo3, useEffect as useEffect15, useLayoutEffect as useLayoutEffect6, useState as useState14 } from "react";
2212
+ import { memo as memo3, useEffect as useEffect14, useLayoutEffect as useLayoutEffect6, useState as useState14 } from "react";
2209
2213
 
2210
2214
  // src/internalState/tableStateStorage.ts
2211
2215
  import { useEffect as useEffect5, useState as useState9 } from "react";
@@ -2625,6 +2629,7 @@ function calcProps(props) {
2625
2629
  };
2626
2630
  };
2627
2631
  const columns = inputColumns.map(mapColumn);
2632
+ const wrapRow = props.wrapRow && cache("wrapRow", props.wrapRow);
2628
2633
  const wrapCell = props.wrapCell && cache("wrapCell", props.wrapCell);
2629
2634
  const rowAction = props.rowAction instanceof Function || Array.isArray(props.rowAction) ? cache("rowAction", props.rowAction) : props.rowAction;
2630
2635
  const rowDetails = props.rowDetails instanceof Function || Array.isArray(props.rowDetails) ? cache("rowDetails", props.rowDetails) : props.rowDetails;
@@ -2633,6 +2638,7 @@ function calcProps(props) {
2633
2638
  parentId,
2634
2639
  columns,
2635
2640
  columnProps,
2641
+ wrapRow,
2636
2642
  wrapCell,
2637
2643
  rowAction,
2638
2644
  rowDetails,
@@ -3662,18 +3668,27 @@ function SelectComponent({ itemId }) {
3662
3668
  }
3663
3669
 
3664
3670
  // src/components/row.tsx
3665
- import { jsx as jsx31, jsxs as jsxs17 } from "@emotion/react/jsx-runtime";
3671
+ import { Fragment as Fragment7, jsx as jsx31, jsxs as jsxs17 } from "@emotion/react/jsx-runtime";
3672
+ var defaultWrapRow = (content) => {
3673
+ return content;
3674
+ };
3666
3675
  var Row = memo2(function Row2({
3667
3676
  itemId,
3668
3677
  rowIndex
3669
3678
  }) {
3679
+ var _a;
3670
3680
  const table = useTableContext();
3671
3681
  const divRef = useRef5(null);
3672
3682
  const detailsDivRef = useRef5(null);
3673
3683
  const classes = useTheme((t) => t.classes);
3674
3684
  const styles = useTheme((t) => t.styles);
3685
+ const item = table.useState((state) => state.activeItemsById.get(itemId));
3686
+ const wrapRow = (_a = table.useState((state) => state.props.wrapRow)) != null ? _a : defaultWrapRow;
3687
+ const rowClassName = (classes == null ? void 0 : classes.row) instanceof Function ? classes.row(item == null ? void 0 : item.value, rowIndex) : classes == null ? void 0 : classes.row;
3688
+ const rowStyles = (styles == null ? void 0 : styles.row) instanceof Function ? styles.row(item == null ? void 0 : item.value, rowIndex) : styles == null ? void 0 : styles.row;
3689
+ const subgrid = table.useState((state) => state.props.subgrid);
3675
3690
  const {
3676
- className: className2,
3691
+ cellClassName,
3677
3692
  css_,
3678
3693
  indent,
3679
3694
  hasChildren,
@@ -3683,18 +3698,18 @@ var Row = memo2(function Row2({
3683
3698
  rowAction,
3684
3699
  hasDetails
3685
3700
  } = table.useState((state) => {
3686
- var _a, _b;
3687
- const item = state.activeItemsById.get(itemId);
3701
+ var _a2, _b;
3702
+ const item2 = state.activeItemsById.get(itemId);
3688
3703
  return {
3689
- className: cx(...calcClassNames(classes, item == null ? void 0 : item.value, rowIndex)),
3690
- css_: calcCss(styles, item == null ? void 0 : item.value, rowIndex),
3691
- indent: item ? getAncestors(state.activeItemsById, item).size : 0,
3692
- hasChildren: !!(item == null ? void 0 : item.children.length),
3693
- hasDeferredChildren: item && ((_b = (_a = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a, item.value)),
3704
+ cellClassName: cx(...calcClassNames(classes, item2 == null ? void 0 : item2.value, rowIndex)),
3705
+ css_: calcCss(styles, item2 == null ? void 0 : item2.value, rowIndex),
3706
+ indent: item2 ? getAncestors(state.activeItemsById, item2).size : 0,
3707
+ hasChildren: !!(item2 == null ? void 0 : item2.children.length),
3708
+ hasDeferredChildren: item2 && ((_b = (_a2 = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a2, item2.value)),
3694
3709
  columnIds: state.activeColumns.map((column) => column.id),
3695
3710
  enableSelection: state.props.enableSelection,
3696
- rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item.value, rowIndex) : null : state.props.rowAction,
3697
- hasDetails: state.props.rowDetails instanceof Function ? item ? !!state.props.rowDetails(item.value, rowIndex) : null : !!state.props.rowDetails
3711
+ rowAction: state.props.rowAction instanceof Function ? item2 ? state.props.rowAction(item2.value, rowIndex) : null : state.props.rowAction,
3712
+ hasDetails: state.props.rowDetails instanceof Function ? item2 ? !!state.props.rowDetails(item2.value, rowIndex) : null : !!state.props.rowDetails
3698
3713
  };
3699
3714
  });
3700
3715
  useLayoutEffect4(() => {
@@ -3719,25 +3734,56 @@ var Row = memo2(function Row2({
3719
3734
  };
3720
3735
  }, [table, itemId, divRef.current, detailsDivRef.current]);
3721
3736
  useLayoutEffect4(() => {
3722
- var _a, _b;
3723
- return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render row", itemId);
3737
+ var _a2, _b;
3738
+ return (_b = (_a2 = table.getState().props).debugRender) == null ? void 0 : _b.call(_a2, "render row", itemId);
3724
3739
  });
3725
- return /* @__PURE__ */ jsxs17("div", { css: { display: "contents" }, children: [
3726
- /* @__PURE__ */ jsx31("div", { className: className2, css: [defaultClasses.cellFill, css_], ref: divRef }),
3727
- /* @__PURE__ */ jsxs17("div", { className: className2, css: [defaultClasses.cell, defaultClasses.firstCell, css_], children: [
3728
- indent > 0 && /* @__PURE__ */ jsx31("div", { css: { width: indent * 20 } }),
3729
- enableSelection && /* @__PURE__ */ jsx31(SelectComponent, { itemId }),
3730
- (hasChildren || hasDeferredChildren || hasDetails) && /* @__PURE__ */ jsx31(ExpandControl, { itemId, hasDeferredChildren }),
3731
- rowAction
3732
- ] }),
3733
- columnIds.map((columnId) => /* @__PURE__ */ jsx31(ColumnContext.Provider, { value: columnId, children: /* @__PURE__ */ jsx31(Cell, { itemId, rowIndex }) }, columnId)),
3734
- /* @__PURE__ */ jsx31("div", { className: className2, css: [defaultClasses.cellFill, css_] }),
3735
- /* @__PURE__ */ jsx31(Details, { ref: detailsDivRef, itemId, rowIndex })
3736
- ] });
3740
+ if (!item) {
3741
+ return null;
3742
+ }
3743
+ return /* @__PURE__ */ jsx31(
3744
+ "div",
3745
+ {
3746
+ css: [
3747
+ {
3748
+ display: "contents"
3749
+ },
3750
+ subgrid && {
3751
+ gridColumn: "1 / -1",
3752
+ display: "grid",
3753
+ gridTemplateColumns: "subgrid"
3754
+ },
3755
+ rowStyles
3756
+ ],
3757
+ className: rowClassName,
3758
+ children: wrapRow(
3759
+ /* @__PURE__ */ jsxs17(Fragment7, { children: [
3760
+ /* @__PURE__ */ jsx31("div", { className: cellClassName, css: [defaultClasses.cellFill, css_], ref: divRef }),
3761
+ /* @__PURE__ */ jsxs17(
3762
+ "div",
3763
+ {
3764
+ className: cellClassName,
3765
+ css: [defaultClasses.cell, defaultClasses.firstCell, css_],
3766
+ children: [
3767
+ indent > 0 && /* @__PURE__ */ jsx31("div", { css: { width: indent * 20 } }),
3768
+ enableSelection && /* @__PURE__ */ jsx31(SelectComponent, { itemId }),
3769
+ (hasChildren || hasDeferredChildren || hasDetails) && /* @__PURE__ */ jsx31(ExpandControl, { itemId, hasDeferredChildren }),
3770
+ rowAction
3771
+ ]
3772
+ }
3773
+ ),
3774
+ columnIds.map((columnId) => /* @__PURE__ */ jsx31(ColumnContext.Provider, { value: columnId, children: /* @__PURE__ */ jsx31(Cell, { itemId, rowIndex }) }, columnId)),
3775
+ /* @__PURE__ */ jsx31("div", { className: cellClassName, css: [defaultClasses.cellFill, css_] }),
3776
+ /* @__PURE__ */ jsx31(Details, { ref: detailsDivRef, itemId, rowIndex })
3777
+ ] }),
3778
+ item.value,
3779
+ rowIndex
3780
+ )
3781
+ }
3782
+ );
3737
3783
  });
3738
3784
 
3739
3785
  // src/components/virtualized.tsx
3740
- import { useEffect as useEffect14, useLayoutEffect as useLayoutEffect5, useMemo as useMemo10, useRef as useRef6, useState as useState13 } from "react";
3786
+ import { useEffect as useEffect13, useLayoutEffect as useLayoutEffect5, useMemo as useMemo10, useRef as useRef6, useState as useState13 } from "react";
3741
3787
  import { jsx as jsx32, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3742
3788
  var findScrollRoot = (x) => {
3743
3789
  const parent = x.parentElement;
@@ -3817,7 +3863,7 @@ function Virtualized(_a) {
3817
3863
  );
3818
3864
  const throttleScroll = (_b2 = (_a2 = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a2.throttleScroll) != null ? _b2 : 16;
3819
3865
  const update = useMemo10(() => throttle(() => setId({}), throttleScroll), [throttleScroll]);
3820
- useEffect14(() => {
3866
+ useEffect13(() => {
3821
3867
  if (!virtual || !probeRef.current) return;
3822
3868
  window.addEventListener("scroll", update, true);
3823
3869
  window.addEventListener("resize", update, true);
@@ -3826,7 +3872,7 @@ function Virtualized(_a) {
3826
3872
  window.removeEventListener("resize", update, true);
3827
3873
  };
3828
3874
  }, [update, virtual]);
3829
- useEffect14(() => update.cancel, [update]);
3875
+ useEffect13(() => update.cancel, [update]);
3830
3876
  useLayoutEffect5(
3831
3877
  () => {
3832
3878
  var _a3, _b3;
@@ -3843,7 +3889,7 @@ function Virtualized(_a) {
3843
3889
  }
3844
3890
 
3845
3891
  // src/components/table.tsx
3846
- import { Fragment as Fragment7, jsx as jsx33, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
3892
+ import { Fragment as Fragment8, jsx as jsx33, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
3847
3893
  function Table(props) {
3848
3894
  const [table, resetState] = useTableState(props);
3849
3895
  const [isHydrated, clearStorage] = useTableStateStorage(table);
@@ -3862,11 +3908,11 @@ function Table(props) {
3862
3908
  function TableLoadingState({ isHydrated }) {
3863
3909
  const loadingText = useTheme((t) => t.text.loading);
3864
3910
  const [showLoading, setShowLoading] = useState14(false);
3865
- useEffect15(() => {
3911
+ useEffect14(() => {
3866
3912
  const handle = setTimeout(() => setShowLoading(true), 500);
3867
3913
  return () => clearTimeout(handle);
3868
3914
  });
3869
- return /* @__PURE__ */ jsxs19(Fragment7, { children: [
3915
+ return /* @__PURE__ */ jsxs19(Fragment8, { children: [
3870
3916
  !isHydrated && showLoading && /* @__PURE__ */ jsx33("div", { children: loadingText }),
3871
3917
  /* @__PURE__ */ jsx33(TableInner, { hidden: !isHydrated })
3872
3918
  ] });
@@ -3923,7 +3969,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3923
3969
  fullWidth === "left" || fullWidth === true ? "auto" : "0"
3924
3970
  ].join(" ")
3925
3971
  },
3926
- header: /* @__PURE__ */ jsxs19(Fragment7, { children: [
3972
+ header: /* @__PURE__ */ jsxs19(Fragment8, { children: [
3927
3973
  /* @__PURE__ */ jsx33(
3928
3974
  "div",
3929
3975
  {
@@ -3950,7 +3996,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3950
3996
  enableSelection && /* @__PURE__ */ jsx33(SelectComponent, {}),
3951
3997
  enableColumnSelection && /* @__PURE__ */ jsx33(ColumnSelection, {}),
3952
3998
  enableExport && /* @__PURE__ */ jsx33(Export2, {}),
3953
- (enableSelection || enableColumnSelection || enableExport) && /* @__PURE__ */ jsxs19(Fragment7, { children: [
3999
+ (enableSelection || enableColumnSelection || enableExport) && /* @__PURE__ */ jsxs19(Fragment8, { children: [
3954
4000
  /* @__PURE__ */ jsx33("div", { css: { flex: 1 } }),
3955
4001
  /* @__PURE__ */ jsx33(ResizeHandleView, {})
3956
4002
  ] })
@@ -3971,9 +4017,9 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3971
4017
  }
3972
4018
  )
3973
4019
  ] }),
3974
- footer: /* @__PURE__ */ jsxs19(Fragment7, { children: [
4020
+ footer: /* @__PURE__ */ jsxs19(Fragment8, { children: [
3975
4021
  enableClearFiltersButton && hasActiveFilters && /* @__PURE__ */ jsx33(ClearFiltersButton, {}),
3976
- hasFooter && /* @__PURE__ */ jsxs19(Fragment7, { children: [
4022
+ hasFooter && /* @__PURE__ */ jsxs19(Fragment8, { children: [
3977
4023
  /* @__PURE__ */ jsx33(
3978
4024
  "div",
3979
4025
  {