schummar-table 0.41.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';
@@ -40,6 +40,7 @@ type DatePickerProps = {
40
40
  defaultDateInView?: Date;
41
41
  /** Show buttons to quickly select suggested dates or date ranges */
42
42
  quickOptions?: DatePickerQuickOption[];
43
+ noReset?: boolean;
43
44
  /** Minimum selectable date */
44
45
  /** Date ranges that are visually marked as blocked */
45
46
  blockedRanges?: DateRange[];
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';
@@ -40,6 +40,7 @@ type DatePickerProps = {
40
40
  defaultDateInView?: Date;
41
41
  /** Show buttons to quickly select suggested dates or date ranges */
42
42
  quickOptions?: DatePickerQuickOption[];
43
+ noReset?: boolean;
43
44
  /** Minimum selectable date */
44
45
  /** Date ranges that are visually marked as blocked */
45
46
  blockedRanges?: DateRange[];
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
  }),
@@ -1290,6 +1294,7 @@ function DatePicker(props) {
1290
1294
  firstDayOfWeek = 1,
1291
1295
  defaultDateInView,
1292
1296
  quickOptions = ["today", "thisWeek"],
1297
+ noReset,
1293
1298
  minDate,
1294
1299
  maxDate,
1295
1300
  showCalendarWeek,
@@ -1373,37 +1378,38 @@ function DatePicker(props) {
1373
1378
  }
1374
1379
  const min = dirty ? dirty.min : value instanceof Date ? value : value == null ? void 0 : value.min;
1375
1380
  const max = dirty ? dirty.max : value instanceof Date ? value : value == null ? void 0 : value.max;
1376
- const resolvedQuickOptions = [...quickOptions, { label: /* @__PURE__ */ jsx13(Text, { id: "reset" }), value: null }].map(
1377
- (option, index) => {
1378
- if (option instanceof Function) {
1379
- return option((value3) => {
1381
+ const resolvedQuickOptions = [
1382
+ ...quickOptions,
1383
+ ...noReset ? [] : [{ label: /* @__PURE__ */ jsx13(Text, { id: "reset" }), value: null }]
1384
+ ].map((option, index) => {
1385
+ if (option instanceof Function) {
1386
+ return option((value3) => {
1387
+ setDirty(void 0);
1388
+ onChange(value3, "quickOption");
1389
+ });
1390
+ }
1391
+ const { label, value: value2 } = typeof option === "string" ? commonQuickOptions[option] : option;
1392
+ return /* @__PURE__ */ jsx13(
1393
+ Button2,
1394
+ {
1395
+ variant: "text",
1396
+ type: "button",
1397
+ css: {
1398
+ color: "inherit"
1399
+ },
1400
+ onClick: () => {
1380
1401
  setDirty(void 0);
1381
- onChange(value3, "quickOption");
1382
- });
1383
- }
1384
- const { label, value: value2 } = typeof option === "string" ? commonQuickOptions[option] : option;
1385
- return /* @__PURE__ */ jsx13(
1386
- Button2,
1387
- {
1388
- variant: "text",
1389
- type: "button",
1390
- css: {
1391
- color: "inherit"
1392
- },
1393
- onClick: () => {
1394
- setDirty(void 0);
1395
- if (value2 instanceof Function) {
1396
- onChange(value2(props), "quickOption");
1397
- } else {
1398
- onChange(value2, "quickOption");
1399
- }
1400
- },
1401
- children: label
1402
+ if (value2 instanceof Function) {
1403
+ onChange(value2(props), "quickOption");
1404
+ } else {
1405
+ onChange(value2, "quickOption");
1406
+ }
1402
1407
  },
1403
- index
1404
- );
1405
- }
1406
- );
1408
+ children: label
1409
+ },
1410
+ index
1411
+ );
1412
+ });
1407
1413
  const { calendars, getBackProps, getForwardProps, getDateProps } = useDayzed({
1408
1414
  onDateSelected: () => void 0,
1409
1415
  firstDayOfWeek,
@@ -2203,7 +2209,7 @@ function SelectFilter(_a) {
2203
2209
  }
2204
2210
 
2205
2211
  // src/components/table.tsx
2206
- 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";
2207
2213
 
2208
2214
  // src/internalState/tableStateStorage.ts
2209
2215
  import { useEffect as useEffect5, useState as useState9 } from "react";
@@ -2623,6 +2629,7 @@ function calcProps(props) {
2623
2629
  };
2624
2630
  };
2625
2631
  const columns = inputColumns.map(mapColumn);
2632
+ const wrapRow = props.wrapRow && cache("wrapRow", props.wrapRow);
2626
2633
  const wrapCell = props.wrapCell && cache("wrapCell", props.wrapCell);
2627
2634
  const rowAction = props.rowAction instanceof Function || Array.isArray(props.rowAction) ? cache("rowAction", props.rowAction) : props.rowAction;
2628
2635
  const rowDetails = props.rowDetails instanceof Function || Array.isArray(props.rowDetails) ? cache("rowDetails", props.rowDetails) : props.rowDetails;
@@ -2631,6 +2638,7 @@ function calcProps(props) {
2631
2638
  parentId,
2632
2639
  columns,
2633
2640
  columnProps,
2641
+ wrapRow,
2634
2642
  wrapCell,
2635
2643
  rowAction,
2636
2644
  rowDetails,
@@ -3660,18 +3668,27 @@ function SelectComponent({ itemId }) {
3660
3668
  }
3661
3669
 
3662
3670
  // src/components/row.tsx
3663
- 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
+ };
3664
3675
  var Row = memo2(function Row2({
3665
3676
  itemId,
3666
3677
  rowIndex
3667
3678
  }) {
3679
+ var _a;
3668
3680
  const table = useTableContext();
3669
3681
  const divRef = useRef5(null);
3670
3682
  const detailsDivRef = useRef5(null);
3671
3683
  const classes = useTheme((t) => t.classes);
3672
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);
3673
3690
  const {
3674
- className: className2,
3691
+ cellClassName,
3675
3692
  css_,
3676
3693
  indent,
3677
3694
  hasChildren,
@@ -3681,18 +3698,18 @@ var Row = memo2(function Row2({
3681
3698
  rowAction,
3682
3699
  hasDetails
3683
3700
  } = table.useState((state) => {
3684
- var _a, _b;
3685
- const item = state.activeItemsById.get(itemId);
3701
+ var _a2, _b;
3702
+ const item2 = state.activeItemsById.get(itemId);
3686
3703
  return {
3687
- className: cx(...calcClassNames(classes, item == null ? void 0 : item.value, rowIndex)),
3688
- css_: calcCss(styles, item == null ? void 0 : item.value, rowIndex),
3689
- indent: item ? getAncestors(state.activeItemsById, item).size : 0,
3690
- hasChildren: !!(item == null ? void 0 : item.children.length),
3691
- 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)),
3692
3709
  columnIds: state.activeColumns.map((column) => column.id),
3693
3710
  enableSelection: state.props.enableSelection,
3694
- rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item.value, rowIndex) : null : state.props.rowAction,
3695
- 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
3696
3713
  };
3697
3714
  });
3698
3715
  useLayoutEffect4(() => {
@@ -3717,25 +3734,56 @@ var Row = memo2(function Row2({
3717
3734
  };
3718
3735
  }, [table, itemId, divRef.current, detailsDivRef.current]);
3719
3736
  useLayoutEffect4(() => {
3720
- var _a, _b;
3721
- 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);
3722
3739
  });
3723
- return /* @__PURE__ */ jsxs17("div", { css: { display: "contents" }, children: [
3724
- /* @__PURE__ */ jsx31("div", { className: className2, css: [defaultClasses.cellFill, css_], ref: divRef }),
3725
- /* @__PURE__ */ jsxs17("div", { className: className2, css: [defaultClasses.cell, defaultClasses.firstCell, css_], children: [
3726
- indent > 0 && /* @__PURE__ */ jsx31("div", { css: { width: indent * 20 } }),
3727
- enableSelection && /* @__PURE__ */ jsx31(SelectComponent, { itemId }),
3728
- (hasChildren || hasDeferredChildren || hasDetails) && /* @__PURE__ */ jsx31(ExpandControl, { itemId, hasDeferredChildren }),
3729
- rowAction
3730
- ] }),
3731
- columnIds.map((columnId) => /* @__PURE__ */ jsx31(ColumnContext.Provider, { value: columnId, children: /* @__PURE__ */ jsx31(Cell, { itemId, rowIndex }) }, columnId)),
3732
- /* @__PURE__ */ jsx31("div", { className: className2, css: [defaultClasses.cellFill, css_] }),
3733
- /* @__PURE__ */ jsx31(Details, { ref: detailsDivRef, itemId, rowIndex })
3734
- ] });
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
+ );
3735
3783
  });
3736
3784
 
3737
3785
  // src/components/virtualized.tsx
3738
- 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";
3739
3787
  import { jsx as jsx32, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3740
3788
  var findScrollRoot = (x) => {
3741
3789
  const parent = x.parentElement;
@@ -3815,7 +3863,7 @@ function Virtualized(_a) {
3815
3863
  );
3816
3864
  const throttleScroll = (_b2 = (_a2 = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a2.throttleScroll) != null ? _b2 : 16;
3817
3865
  const update = useMemo10(() => throttle(() => setId({}), throttleScroll), [throttleScroll]);
3818
- useEffect14(() => {
3866
+ useEffect13(() => {
3819
3867
  if (!virtual || !probeRef.current) return;
3820
3868
  window.addEventListener("scroll", update, true);
3821
3869
  window.addEventListener("resize", update, true);
@@ -3824,7 +3872,7 @@ function Virtualized(_a) {
3824
3872
  window.removeEventListener("resize", update, true);
3825
3873
  };
3826
3874
  }, [update, virtual]);
3827
- useEffect14(() => update.cancel, [update]);
3875
+ useEffect13(() => update.cancel, [update]);
3828
3876
  useLayoutEffect5(
3829
3877
  () => {
3830
3878
  var _a3, _b3;
@@ -3841,7 +3889,7 @@ function Virtualized(_a) {
3841
3889
  }
3842
3890
 
3843
3891
  // src/components/table.tsx
3844
- 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";
3845
3893
  function Table(props) {
3846
3894
  const [table, resetState] = useTableState(props);
3847
3895
  const [isHydrated, clearStorage] = useTableStateStorage(table);
@@ -3860,11 +3908,11 @@ function Table(props) {
3860
3908
  function TableLoadingState({ isHydrated }) {
3861
3909
  const loadingText = useTheme((t) => t.text.loading);
3862
3910
  const [showLoading, setShowLoading] = useState14(false);
3863
- useEffect15(() => {
3911
+ useEffect14(() => {
3864
3912
  const handle = setTimeout(() => setShowLoading(true), 500);
3865
3913
  return () => clearTimeout(handle);
3866
3914
  });
3867
- return /* @__PURE__ */ jsxs19(Fragment7, { children: [
3915
+ return /* @__PURE__ */ jsxs19(Fragment8, { children: [
3868
3916
  !isHydrated && showLoading && /* @__PURE__ */ jsx33("div", { children: loadingText }),
3869
3917
  /* @__PURE__ */ jsx33(TableInner, { hidden: !isHydrated })
3870
3918
  ] });
@@ -3921,7 +3969,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3921
3969
  fullWidth === "left" || fullWidth === true ? "auto" : "0"
3922
3970
  ].join(" ")
3923
3971
  },
3924
- header: /* @__PURE__ */ jsxs19(Fragment7, { children: [
3972
+ header: /* @__PURE__ */ jsxs19(Fragment8, { children: [
3925
3973
  /* @__PURE__ */ jsx33(
3926
3974
  "div",
3927
3975
  {
@@ -3948,7 +3996,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3948
3996
  enableSelection && /* @__PURE__ */ jsx33(SelectComponent, {}),
3949
3997
  enableColumnSelection && /* @__PURE__ */ jsx33(ColumnSelection, {}),
3950
3998
  enableExport && /* @__PURE__ */ jsx33(Export2, {}),
3951
- (enableSelection || enableColumnSelection || enableExport) && /* @__PURE__ */ jsxs19(Fragment7, { children: [
3999
+ (enableSelection || enableColumnSelection || enableExport) && /* @__PURE__ */ jsxs19(Fragment8, { children: [
3952
4000
  /* @__PURE__ */ jsx33("div", { css: { flex: 1 } }),
3953
4001
  /* @__PURE__ */ jsx33(ResizeHandleView, {})
3954
4002
  ] })
@@ -3969,9 +4017,9 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3969
4017
  }
3970
4018
  )
3971
4019
  ] }),
3972
- footer: /* @__PURE__ */ jsxs19(Fragment7, { children: [
4020
+ footer: /* @__PURE__ */ jsxs19(Fragment8, { children: [
3973
4021
  enableClearFiltersButton && hasActiveFilters && /* @__PURE__ */ jsx33(ClearFiltersButton, {}),
3974
- hasFooter && /* @__PURE__ */ jsxs19(Fragment7, { children: [
4022
+ hasFooter && /* @__PURE__ */ jsxs19(Fragment8, { children: [
3975
4023
  /* @__PURE__ */ jsx33(
3976
4024
  "div",
3977
4025
  {