schummar-table 0.43.0 → 0.44.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.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  defaultClasses,
9
9
  globalTableTheme,
10
10
  mergeThemes
11
- } from "./chunk-FTCKJOPQ.js";
11
+ } from "./chunk-NTYYITKA.js";
12
12
  import "./chunk-WFCJ3D3G.js";
13
13
  import {
14
14
  __async,
@@ -791,13 +791,13 @@ var FilterControlContext = createContext3({
791
791
  isActive: false,
792
792
  close: () => void 0
793
793
  });
794
- function FilterControl() {
794
+ function FilterControl({
795
+ component: Component = DefaultButton,
796
+ onClose
797
+ }) {
795
798
  const table = useTableContext();
796
799
  const columnId = useColumnContext();
797
- const IconButton2 = useTheme((t) => t.components.IconButton);
798
800
  const Popover2 = useTheme((t) => t.components.Popover);
799
- const FilterList2 = useTheme((t) => t.icons.FilterList);
800
- const ArrowDropDown2 = useTheme((t) => t.icons.ArrowDropDown);
801
801
  const classes = useTheme((t) => t.classes);
802
802
  const cssVariables = useCssVariables();
803
803
  const [anchor, setAnchor] = useState2(null);
@@ -817,14 +817,14 @@ function FilterControl() {
817
817
  }
818
818
  );
819
819
  function reset() {
820
- table.update((state) => {
821
- var _a;
822
- const impl = state.filters.get(columnId);
823
- (_a = impl == null ? void 0 : impl.onChange) == null ? void 0 : _a.call(impl, void 0);
824
- if ((impl == null ? void 0 : impl.value) === void 0) {
820
+ var _a;
821
+ const impl = table.getState().filters.get(columnId);
822
+ (_a = impl == null ? void 0 : impl.onChange) == null ? void 0 : _a.call(impl, void 0);
823
+ if ((impl == null ? void 0 : impl.value) === void 0) {
824
+ table.update((state) => {
825
825
  state.filterValues.delete(columnId);
826
- }
827
- });
826
+ });
827
+ }
828
828
  }
829
829
  const context = useMemo2(
830
830
  () => ({
@@ -836,7 +836,7 @@ function FilterControl() {
836
836
  if (!filter) return null;
837
837
  return /* @__PURE__ */ jsxs7(FilterControlContext.Provider, { value: context, children: [
838
838
  /* @__PURE__ */ jsx9(
839
- "div",
839
+ Component,
840
840
  {
841
841
  onClick: (event) => setAnchor(event.currentTarget),
842
842
  onContextMenu: (event) => {
@@ -844,18 +844,7 @@ function FilterControl() {
844
844
  event.preventDefault();
845
845
  return false;
846
846
  },
847
- children: /* @__PURE__ */ jsx9(
848
- IconButton2,
849
- {
850
- css: [
851
- { color: "#b0bac9" },
852
- isActive && {
853
- color: "var(--primaryMain) !important"
854
- }
855
- ],
856
- children: isActive ? /* @__PURE__ */ jsx9(FilterList2, {}) : /* @__PURE__ */ jsx9(ArrowDropDown2, {})
857
- }
858
- )
847
+ isActive
859
848
  }
860
849
  ),
861
850
  /* @__PURE__ */ jsx9(
@@ -872,7 +861,10 @@ function FilterControl() {
872
861
  {
873
862
  open: true,
874
863
  hidden: !anchor,
875
- onClose: () => setAnchor(null),
864
+ onClose: () => {
865
+ setAnchor(null);
866
+ onClose == null ? void 0 : onClose();
867
+ },
876
868
  anchorEl: anchor != null ? anchor : document.body,
877
869
  css: cssVariables,
878
870
  className: cx(classes == null ? void 0 : classes.popover, filterClassNames == null ? void 0 : filterClassNames.popover),
@@ -884,6 +876,24 @@ function FilterControl() {
884
876
  )
885
877
  ] });
886
878
  }
879
+ function DefaultButton(_a) {
880
+ var _b = _a, { isActive } = _b, props = __objRest(_b, ["isActive"]);
881
+ const IconButton2 = useTheme((t) => t.components.IconButton);
882
+ const FilterList2 = useTheme((t) => t.icons.FilterList);
883
+ const ArrowDropDown2 = useTheme((t) => t.icons.ArrowDropDown);
884
+ return /* @__PURE__ */ jsx9(
885
+ IconButton2,
886
+ __spreadProps(__spreadValues({}, props), {
887
+ css: [
888
+ { color: "#b0bac9" },
889
+ isActive && {
890
+ color: "var(--primaryMain) !important"
891
+ }
892
+ ],
893
+ children: isActive ? /* @__PURE__ */ jsx9(FilterList2, {}) : /* @__PURE__ */ jsx9(ArrowDropDown2, {})
894
+ })
895
+ );
896
+ }
887
897
 
888
898
  // src/components/autoFocusTextField.tsx
889
899
  import { jsx as jsx10 } from "@emotion/react/jsx-runtime";
@@ -2151,6 +2161,7 @@ function SelectFilter(_a) {
2151
2161
  css: {
2152
2162
  padding: "calc(var(--spacing) * 2)",
2153
2163
  display: "grid",
2164
+ gridTemplateColumns: "minmax(0, 1fr)",
2154
2165
  gap: "var(--spacing)"
2155
2166
  },
2156
2167
  children: [
@@ -2184,7 +2195,11 @@ function SelectFilter(_a) {
2184
2195
  items: ordered,
2185
2196
  css: {
2186
2197
  width: "20em",
2187
- maxHeight: "20em"
2198
+ maxWidth: "100%",
2199
+ maxHeight: "min(20em, 50vh)",
2200
+ overflow: "hidden auto",
2201
+ display: "grid",
2202
+ gridTemplateColumns: "minmax(0, 1fr)"
2188
2203
  },
2189
2204
  children: (option, index) => /* @__PURE__ */ jsx19(
2190
2205
  FormControlLabel,
@@ -2209,7 +2224,7 @@ function SelectFilter(_a) {
2209
2224
  }
2210
2225
 
2211
2226
  // src/components/table.tsx
2212
- import { memo as memo3, useEffect as useEffect14, useLayoutEffect as useLayoutEffect6, useState as useState14 } from "react";
2227
+ import { memo as memo3, useEffect as useEffect15, useLayoutEffect as useLayoutEffect6, useState as useState14 } from "react";
2213
2228
 
2214
2229
  // src/internalState/tableStateStorage.ts
2215
2230
  import { useEffect as useEffect5, useState as useState9 } from "react";
@@ -2418,8 +2433,8 @@ function useTableStateStorage(table) {
2418
2433
  }
2419
2434
 
2420
2435
  // src/internalState/useTableState.ts
2421
- import { castDraft as castDraft3 } from "immer";
2422
- import { useEffect as useEffect11, useMemo as useMemo9, useState as useState10 } from "react";
2436
+ import { castDraft as castDraft4 } from "immer";
2437
+ import { useEffect as useEffect12, useMemo as useMemo9, useState as useState10 } from "react";
2423
2438
 
2424
2439
  // src/internalState/calcItems.ts
2425
2440
  import { castDraft as castDraft2 } from "immer";
@@ -2555,104 +2570,149 @@ function defaultSerializer(x) {
2555
2570
  return (_a = JSON.stringify(x)) != null ? _a : "";
2556
2571
  }
2557
2572
 
2573
+ // src/misc/overrides.ts
2574
+ function overrides(first, ...overrides2) {
2575
+ return overrides2.reduce(
2576
+ (result, source) => {
2577
+ for (const [key, value] of Object.entries(source != null ? source : {})) {
2578
+ if (value !== void 0) {
2579
+ result[key] = value;
2580
+ }
2581
+ }
2582
+ return result;
2583
+ },
2584
+ __spreadValues({}, first)
2585
+ );
2586
+ }
2587
+
2558
2588
  // src/internalState/calcProps.ts
2559
- var noopParentId = () => void 0;
2589
+ var defaultProps = {
2590
+ id: () => "",
2591
+ columns: [],
2592
+ enableSelection: true,
2593
+ selectSyncChildren: true,
2594
+ stickyHeader: true,
2595
+ stickyFooter: true,
2596
+ enableColumnSelection: true,
2597
+ enableColumnResize: true,
2598
+ enableColumnReorder: true,
2599
+ displaySizeOverrides: {
2600
+ mobile: {
2601
+ enableSelection: false,
2602
+ enableColumnSelection: false,
2603
+ enableExport: false,
2604
+ enableColumnResize: false,
2605
+ enableColumnReorder: false
2606
+ }
2607
+ }
2608
+ };
2560
2609
  function calcProps(props) {
2561
2610
  const cache = useTableMemo();
2562
- return useMemo8(() => {
2563
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2564
- let id;
2565
- if (props.id instanceof Function || Array.isArray(props.id)) {
2566
- id = cache("id", props.id);
2567
- } else {
2568
- id = cache("id", [(item) => item[props.id], props.id]);
2569
- }
2570
- let parentId;
2571
- if (props.parentId instanceof Function || Array.isArray(props.parentId)) {
2572
- parentId = cache("parentId", props.parentId);
2573
- } else if (props.parentId !== void 0) {
2574
- parentId = cache("parentId", [
2575
- (item) => item[props.parentId],
2576
- props.parentId
2577
- ]);
2578
- } else {
2579
- parentId = noopParentId;
2580
- }
2581
- const columnProps = props.columnProps && cache("columnProps", props.columnProps);
2582
- let inputColumns;
2583
- if (props.columns instanceof Function) {
2584
- inputColumns = props.columns((value, column) => __spreadProps(__spreadValues({}, column), { value }));
2585
- } else {
2586
- inputColumns = props.columns.map((column) => __spreadProps(__spreadValues({}, column), { dependecies: void 0 }));
2587
- }
2588
- const globalDefaults = props.defaultColumnProps;
2589
- const mapColumn = ({
2590
- id: _id,
2591
- header,
2592
- exportHeader,
2593
- footer,
2594
- value,
2595
- renderCell,
2596
- exportCell,
2597
- sortBy,
2611
+ return useMemo8(
2612
+ () => overrides(defaultProps, calc(props, cache)),
2613
+ [props]
2614
+ );
2615
+ }
2616
+ function calc(props, cache) {
2617
+ var _a;
2618
+ let id;
2619
+ if (props.id instanceof Function || Array.isArray(props.id)) {
2620
+ id = cache("id", props.id);
2621
+ } else if (props.id !== void 0) {
2622
+ id = cache("id", [(item) => item[props.id], props.id]);
2623
+ }
2624
+ let parentId;
2625
+ if (props.parentId instanceof Function || Array.isArray(props.parentId)) {
2626
+ parentId = cache("parentId", props.parentId);
2627
+ } else if (props.parentId !== void 0) {
2628
+ parentId = cache("parentId", [
2629
+ (item) => item[props.parentId],
2630
+ props.parentId
2631
+ ]);
2632
+ }
2633
+ const columnProps = props.columnProps && cache("columnProps", props.columnProps);
2634
+ let inputColumns;
2635
+ if (props.columns instanceof Function) {
2636
+ inputColumns = props.columns((value, column) => __spreadProps(__spreadValues({}, column), { value }));
2637
+ } else if (props.columns !== void 0) {
2638
+ inputColumns = props.columns.map((column) => __spreadProps(__spreadValues({}, column), { dependecies: void 0 }));
2639
+ }
2640
+ const globalDefaults = props.defaultColumnProps;
2641
+ const mapColumn = ({
2642
+ id: _id,
2643
+ header,
2644
+ exportHeader,
2645
+ footer,
2646
+ value,
2647
+ renderCell,
2648
+ exportCell,
2649
+ sortBy,
2650
+ disableSort,
2651
+ hidden,
2652
+ classes,
2653
+ styles,
2654
+ filter,
2655
+ width,
2656
+ displaySize
2657
+ }, index) => {
2658
+ var _a2, _b, _c, _d, _e, _f;
2659
+ const id2 = _id != null ? _id : index;
2660
+ const cacheKey = typeof id2 === "string" ? `s${id2}` : `n${id2}`;
2661
+ const defaults2 = __spreadValues(__spreadValues({}, globalDefaults), columnProps == null ? void 0 : columnProps(id2));
2662
+ return {
2663
+ id: id2,
2664
+ header: (_a2 = header != null ? header : defaults2 == null ? void 0 : defaults2.header) != null ? _a2 : null,
2665
+ exportHeader: (_b = exportHeader != null ? exportHeader : defaults2 == null ? void 0 : defaults2.exportHeader) != null ? _b : id2,
2666
+ footer: (_c = footer != null ? footer : defaults2 == null ? void 0 : defaults2.footer) != null ? _c : null,
2667
+ value: cache(`columns.${cacheKey}.value`, value),
2668
+ renderCell: cache(
2669
+ `columns.${cacheKey}.renderCell`,
2670
+ (_d = renderCell != null ? renderCell : defaults2 == null ? void 0 : defaults2.renderCell) != null ? _d : asString
2671
+ ),
2672
+ exportCell: (_e = exportCell != null ? exportCell : defaults2 == null ? void 0 : defaults2.exportCell) != null ? _e : defaultSerializer,
2673
+ sortBy: ((_f = sortBy != null ? sortBy : defaults2 == null ? void 0 : defaults2.sortBy) != null ? _f : [
2674
+ (v) => typeof v === "number" || v instanceof Date ? v : v === null || v === void 0 ? "" : String(v)
2675
+ ]).map((function_, i) => cache(`columns.${cacheKey}.sortBy.${i}`, function_)),
2598
2676
  disableSort,
2599
- hidden,
2600
- classes,
2601
- styles,
2602
- filter,
2603
- width
2604
- }, index) => {
2605
- var _a2, _b2, _c2, _d2, _e2, _f2;
2606
- const id2 = _id != null ? _id : index;
2607
- const cacheKey = typeof id2 === "string" ? `s${id2}` : `n${id2}`;
2608
- const defaults2 = __spreadValues(__spreadValues({}, globalDefaults), columnProps == null ? void 0 : columnProps(id2));
2609
- return {
2610
- id: id2,
2611
- header: (_a2 = header != null ? header : defaults2 == null ? void 0 : defaults2.header) != null ? _a2 : null,
2612
- exportHeader: (_b2 = exportHeader != null ? exportHeader : defaults2 == null ? void 0 : defaults2.exportHeader) != null ? _b2 : id2,
2613
- footer: (_c2 = footer != null ? footer : defaults2 == null ? void 0 : defaults2.footer) != null ? _c2 : null,
2614
- value: cache(`columns.${cacheKey}.value`, value),
2615
- renderCell: cache(
2616
- `columns.${cacheKey}.renderCell`,
2617
- (_d2 = renderCell != null ? renderCell : defaults2 == null ? void 0 : defaults2.renderCell) != null ? _d2 : asString
2618
- ),
2619
- exportCell: (_e2 = exportCell != null ? exportCell : defaults2 == null ? void 0 : defaults2.exportCell) != null ? _e2 : defaultSerializer,
2620
- sortBy: ((_f2 = sortBy != null ? sortBy : defaults2 == null ? void 0 : defaults2.sortBy) != null ? _f2 : [
2621
- (v) => typeof v === "number" || v instanceof Date ? v : v === null || v === void 0 ? "" : String(v)
2622
- ]).map((function_, i) => cache(`columns.${cacheKey}.sortBy.${i}`, function_)),
2623
- disableSort,
2624
- hidden: hidden != null ? hidden : defaults2 == null ? void 0 : defaults2.hidden,
2625
- classes: classes != null ? classes : defaults2 == null ? void 0 : defaults2.classes,
2626
- styles: styles != null ? styles : defaults2 == null ? void 0 : defaults2.styles,
2627
- filter: filter != null ? filter : defaults2 == null ? void 0 : defaults2.filter,
2628
- width: width != null ? width : defaults2 == null ? void 0 : defaults2.width
2629
- };
2677
+ hidden: hidden != null ? hidden : defaults2 == null ? void 0 : defaults2.hidden,
2678
+ classes: classes != null ? classes : defaults2 == null ? void 0 : defaults2.classes,
2679
+ styles: styles != null ? styles : defaults2 == null ? void 0 : defaults2.styles,
2680
+ filter: filter != null ? filter : defaults2 == null ? void 0 : defaults2.filter,
2681
+ width: width != null ? width : defaults2 == null ? void 0 : defaults2.width,
2682
+ displaySize: Array.isArray(displaySize) ? displaySize : displaySize ? [displaySize] : void 0
2630
2683
  };
2631
- const columns = inputColumns.map(mapColumn);
2632
- const wrapRow = props.wrapRow && cache("wrapRow", props.wrapRow);
2633
- const wrapCell = props.wrapCell && cache("wrapCell", props.wrapCell);
2634
- const rowAction = props.rowAction instanceof Function || Array.isArray(props.rowAction) ? cache("rowAction", props.rowAction) : props.rowAction;
2635
- const rowDetails = props.rowDetails instanceof Function || Array.isArray(props.rowDetails) ? cache("rowDetails", props.rowDetails) : props.rowDetails;
2636
- return __spreadProps(__spreadValues({}, props), {
2637
- id,
2638
- parentId,
2639
- columns,
2640
- columnProps,
2641
- wrapRow,
2642
- wrapCell,
2643
- rowAction,
2644
- rowDetails,
2645
- enableSelection: (_a = props.enableSelection) != null ? _a : true,
2646
- selectSyncChildren: (_b = props.selectSyncChildren) != null ? _b : true,
2647
- stickyHeader: (_c = props.stickyHeader) != null ? _c : true,
2648
- stickyFooter: (_d = props.stickyFooter) != null ? _d : true,
2649
- enableExport: (_e = props.enableExport) != null ? _e : false,
2650
- enableColumnSelection: (_f = props.enableColumnSelection) != null ? _f : true,
2651
- enableClearFiltersButton: (_g = props.enableClearFiltersButton) != null ? _g : false,
2652
- enableColumnResize: (_h = props.enableColumnResize) != null ? _h : true,
2653
- enableColumnReorder: (_i = props.enableColumnReorder) != null ? _i : true
2654
- });
2655
- }, [props]);
2684
+ };
2685
+ const columns = inputColumns == null ? void 0 : inputColumns.map(mapColumn);
2686
+ const wrapRow = props.wrapRow && cache("wrapRow", props.wrapRow);
2687
+ const wrapCell = props.wrapCell && cache("wrapCell", props.wrapCell);
2688
+ const rowAction = props.rowAction instanceof Function || Array.isArray(props.rowAction) ? cache("rowAction", props.rowAction) : props.rowAction;
2689
+ const rowDetails = props.rowDetails instanceof Function || Array.isArray(props.rowDetails) ? cache("rowDetails", props.rowDetails) : props.rowDetails;
2690
+ const displaySizeOverrides = props.displaySizeOverrides && Object.fromEntries(
2691
+ Object.entries((_a = props.displaySizeOverrides) != null ? _a : {}).map(([size, overrides2]) => [
2692
+ size,
2693
+ overrides2 && calc(overrides2, cache)
2694
+ ])
2695
+ );
2696
+ return __spreadProps(__spreadValues({}, props), {
2697
+ id,
2698
+ parentId,
2699
+ columns,
2700
+ columnProps,
2701
+ wrapRow,
2702
+ wrapCell,
2703
+ rowAction,
2704
+ rowDetails,
2705
+ enableSelection: props.enableSelection,
2706
+ selectSyncChildren: props.selectSyncChildren,
2707
+ stickyHeader: props.stickyHeader,
2708
+ stickyFooter: props.stickyFooter,
2709
+ enableColumnSelection: props.enableColumnSelection,
2710
+ enableExport: props.enableExport,
2711
+ enableClearFiltersButton: props.enableClearFiltersButton,
2712
+ enableColumnResize: props.enableColumnResize,
2713
+ enableColumnReorder: props.enableColumnReorder,
2714
+ displaySizeOverrides
2715
+ });
2656
2716
  }
2657
2717
 
2658
2718
  // src/internalState/cleanupState.ts
@@ -2722,8 +2782,14 @@ import { useEffect as useEffect8 } from "react";
2722
2782
  function filterColumns(state) {
2723
2783
  useEffect8(
2724
2784
  () => state.addReaction(
2725
- (state2) => [state2.props.columns, state2.hiddenColumns, state2.columnOrder],
2726
- ([columns, hiddenColumns, columnOrder], draft) => {
2785
+ (state2) => [
2786
+ state2.props.columns,
2787
+ state2.hiddenColumns,
2788
+ state2.columnOrder,
2789
+ state2.displaySize,
2790
+ state2.displaySizePx
2791
+ ],
2792
+ ([columns, hiddenColumns, columnOrder, displaySize], draft) => {
2727
2793
  draft.activeColumns = orderBy(
2728
2794
  columns.filter((column) => {
2729
2795
  var _a;
@@ -2731,6 +2797,9 @@ function filterColumns(state) {
2731
2797
  }),
2732
2798
  [(column) => columnOrder.indexOf(column.id)]
2733
2799
  );
2800
+ draft.visibleColumns = draft.activeColumns.filter(
2801
+ (column) => displaySize === void 0 || column.displaySize === void 0 || column.displaySize.includes(displaySize)
2802
+ );
2734
2803
  },
2735
2804
  { runNow: true }
2736
2805
  ),
@@ -2812,6 +2881,53 @@ function syncSelections(table) {
2812
2881
  );
2813
2882
  }
2814
2883
 
2884
+ // src/internalState/watchDisplaySize.ts
2885
+ import { castDraft as castDraft3 } from "immer";
2886
+ import { useEffect as useEffect11 } from "react";
2887
+ var DEFAULT_DISPLAY_SIZES = {
2888
+ mobile: 400,
2889
+ desktop: Infinity
2890
+ };
2891
+ function watchDisplaySize(state) {
2892
+ useEffect11(
2893
+ () => state.addReaction(
2894
+ (state2) => ({
2895
+ displaySizePx: state2.displaySizePx,
2896
+ displaySize: state2.props.displaySize
2897
+ }),
2898
+ ({ displaySizePx, displaySize = DEFAULT_DISPLAY_SIZES }, draft) => {
2899
+ if (displaySizePx === void 0) {
2900
+ return;
2901
+ }
2902
+ if (typeof displaySize === "object") {
2903
+ const entry = Object.entries(displaySize).find(
2904
+ ([, maxWidth]) => maxWidth >= displaySizePx
2905
+ );
2906
+ draft.displaySize = entry == null ? void 0 : entry[0];
2907
+ } else {
2908
+ draft.displaySize = displaySize;
2909
+ }
2910
+ }
2911
+ ),
2912
+ [state]
2913
+ );
2914
+ useEffect11(
2915
+ () => state.addReaction(
2916
+ (state2) => ({
2917
+ props: state2.normalizedProps,
2918
+ displaySize: state2.displaySize
2919
+ }),
2920
+ ({ props, displaySize }, draft) => {
2921
+ var _a;
2922
+ draft.props = castDraft3(
2923
+ overrides(props, displaySize ? (_a = props.displaySizeOverrides) == null ? void 0 : _a[displaySize] : void 0)
2924
+ );
2925
+ }
2926
+ ),
2927
+ [state]
2928
+ );
2929
+ }
2930
+
2815
2931
  // src/internalState/useTableState.ts
2816
2932
  function useTableState(_props) {
2817
2933
  const [key, setKey] = useState10({});
@@ -2837,6 +2953,7 @@ function useTableState(_props) {
2837
2953
  () => {
2838
2954
  var _a, _b, _c, _d;
2839
2955
  return new Store({
2956
+ normalizedProps: props,
2840
2957
  props,
2841
2958
  key,
2842
2959
  sort: (_a = props.defaultSort) != null ? _a : [],
@@ -2850,11 +2967,14 @@ function useTableState(_props) {
2850
2967
  columnOrder: props.columns.map((column) => column.id),
2851
2968
  columnStyleOverride: /* @__PURE__ */ new Map(),
2852
2969
  activeColumns: [],
2970
+ visibleColumns: [],
2853
2971
  items: [],
2854
2972
  itemsById: /* @__PURE__ */ new Map(),
2855
2973
  activeItems: [],
2856
2974
  activeItemsById: /* @__PURE__ */ new Map(),
2857
- lastSelectedId: void 0
2975
+ lastSelectedId: void 0,
2976
+ displaySizePx: void 0,
2977
+ displaySize: void 0
2858
2978
  });
2859
2979
  },
2860
2980
  [key]
@@ -2864,9 +2984,10 @@ function useTableState(_props) {
2864
2984
  normalizeExpanded(state);
2865
2985
  syncSelections(state);
2866
2986
  cleanupState(state);
2867
- useEffect11(() => {
2987
+ watchDisplaySize(state);
2988
+ useEffect12(() => {
2868
2989
  state.update((state2) => {
2869
- state2.props = castDraft3(props);
2990
+ state2.normalizedProps = castDraft4(props);
2870
2991
  if (props.sort) state2.sort = props.sort;
2871
2992
  if (props.selection) state2.selection = props.selection;
2872
2993
  if (props.expanded) state2.expanded = props.expanded;
@@ -2957,8 +3078,8 @@ function ColumnFooter() {
2957
3078
  }
2958
3079
 
2959
3080
  // src/components/columnHeader.tsx
2960
- import { castDraft as castDraft4 } from "immer";
2961
- import { useEffect as useEffect12, useRef as useRef4 } from "react";
3081
+ import { castDraft as castDraft5 } from "immer";
3082
+ import { useEffect as useEffect13, useRef as useRef4 } from "react";
2962
3083
 
2963
3084
  // src/components/resizeHandle.tsx
2964
3085
  import { jsx as jsx22 } from "@emotion/react/jsx-runtime";
@@ -2995,6 +3116,9 @@ function ResizeHandle() {
2995
3116
  }
2996
3117
  });
2997
3118
  }
3119
+ if (!enabled) {
3120
+ return null;
3121
+ }
2998
3122
  return /* @__PURE__ */ jsx22(
2999
3123
  ResizeHandleView,
3000
3124
  {
@@ -3028,7 +3152,7 @@ function ResizeHandleView(_a) {
3028
3152
  {
3029
3153
  alignSelf: "stretch",
3030
3154
  padding: "0 5px",
3031
- cursor: enabled ? "col-resize" : "initial",
3155
+ cursor: enabled === true ? "col-resize" : "initial",
3032
3156
  display: "flex",
3033
3157
  alignItems: "center",
3034
3158
  "&:after": {
@@ -3037,6 +3161,9 @@ function ResizeHandleView(_a) {
3037
3161
  height: "1.5em",
3038
3162
  background: "#c9cfda",
3039
3163
  transition: "transform 300ms"
3164
+ },
3165
+ "@media (pointer: coarse)": {
3166
+ pointerEvents: "none"
3040
3167
  }
3041
3168
  },
3042
3169
  styles
@@ -3154,11 +3281,11 @@ function ColumnHeader() {
3154
3281
  const store = ColumnHeaderContext.useStore();
3155
3282
  const draggingStart = useRef4();
3156
3283
  const clone = useRef4();
3157
- useEffect12(() => {
3284
+ useEffect13(() => {
3158
3285
  const div = ref.current;
3159
3286
  if (!div) return;
3160
3287
  store.update((state) => {
3161
- state.items.set(columnId, castDraft4(div));
3288
+ state.items.set(columnId, castDraft5(div));
3162
3289
  });
3163
3290
  return () => {
3164
3291
  store.update((state) => {
@@ -3391,7 +3518,7 @@ function Export2() {
3391
3518
  const classes = useTheme((t) => t.classes);
3392
3519
  const cssVariables = useCssVariables();
3393
3520
  const { all, exporters } = table.useState((state) => {
3394
- if (typeof state.props.enableExport === "boolean") {
3521
+ if (typeof state.props.enableExport === "boolean" || state.props.enableExport === void 0) {
3395
3522
  return {
3396
3523
  all: false,
3397
3524
  exporters: contextExporters
@@ -3469,6 +3596,7 @@ function Export2() {
3469
3596
  }
3470
3597
 
3471
3598
  // src/components/row.tsx
3599
+ import { ClassNames as ClassNames2 } from "@emotion/react";
3472
3600
  import { memo as memo2, useLayoutEffect as useLayoutEffect4, useRef as useRef5 } from "react";
3473
3601
 
3474
3602
  // src/misc/calcClassNames.ts
@@ -3669,9 +3797,6 @@ function SelectComponent({ itemId }) {
3669
3797
 
3670
3798
  // src/components/row.tsx
3671
3799
  import { Fragment as Fragment7, jsx as jsx31, jsxs as jsxs17 } from "@emotion/react/jsx-runtime";
3672
- var defaultWrapRow = (content) => {
3673
- return content;
3674
- };
3675
3800
  var Row = memo2(function Row2({
3676
3801
  itemId,
3677
3802
  rowIndex
@@ -3683,7 +3808,7 @@ var Row = memo2(function Row2({
3683
3808
  const classes = useTheme((t) => t.classes);
3684
3809
  const styles = useTheme((t) => t.styles);
3685
3810
  const item = table.useState((state) => state.activeItemsById.get(itemId));
3686
- const wrapRow = (_a = table.useState((state) => state.props.wrapRow)) != null ? _a : defaultWrapRow;
3811
+ const wrapRow = (_a = table.useState((state) => state.props.wrapRow)) != null ? _a : (props) => /* @__PURE__ */ jsx31("div", __spreadValues({}, props));
3687
3812
  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
3813
  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
3814
  const subgrid = table.useState((state) => state.props.subgrid);
@@ -3706,7 +3831,7 @@ var Row = memo2(function Row2({
3706
3831
  indent: item2 ? getAncestors(state.activeItemsById, item2).size : 0,
3707
3832
  hasChildren: !!(item2 == null ? void 0 : item2.children.length),
3708
3833
  hasDeferredChildren: item2 && ((_b = (_a2 = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a2, item2.value)),
3709
- columnIds: state.activeColumns.map((column) => column.id),
3834
+ columnIds: state.visibleColumns.map((column) => column.id),
3710
3835
  enableSelection: state.props.enableSelection,
3711
3836
  rowAction: state.props.rowAction instanceof Function ? item2 ? state.props.rowAction(item2.value, rowIndex) : null : state.props.rowAction,
3712
3837
  hasDetails: state.props.rowDetails instanceof Function ? item2 ? !!state.props.rowDetails(item2.value, rowIndex) : null : !!state.props.rowDetails
@@ -3740,50 +3865,53 @@ var Row = memo2(function Row2({
3740
3865
  if (!item) {
3741
3866
  return null;
3742
3867
  }
3743
- return /* @__PURE__ */ jsx31(
3744
- "div",
3868
+ return /* @__PURE__ */ jsx31(ClassNames2, { children: ({ css: css3 }) => /* @__PURE__ */ jsx31(Fragment7, { children: wrapRow(
3745
3869
  {
3746
- css: [
3747
- {
3748
- display: "contents"
3749
- },
3750
- subgrid && {
3751
- gridColumn: "1 / -1",
3870
+ className: css3([
3871
+ subgrid ? {
3872
+ gridColumn: `1 / -1`,
3752
3873
  display: "grid",
3753
3874
  gridTemplateColumns: "subgrid"
3875
+ } : {
3876
+ display: "contents"
3754
3877
  },
3878
+ rowClassName,
3755
3879
  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
- );
3880
+ ]),
3881
+ children: /* @__PURE__ */ jsxs17(Fragment7, { children: [
3882
+ /* @__PURE__ */ jsx31(
3883
+ "div",
3884
+ {
3885
+ className: cellClassName,
3886
+ css: [defaultClasses.cellFill, css_],
3887
+ ref: divRef
3888
+ }
3889
+ ),
3890
+ /* @__PURE__ */ jsxs17(
3891
+ "div",
3892
+ {
3893
+ className: cellClassName,
3894
+ css: [defaultClasses.cell, defaultClasses.firstCell, css_],
3895
+ children: [
3896
+ indent > 0 && /* @__PURE__ */ jsx31("div", { css: { width: indent * 20 } }),
3897
+ enableSelection && /* @__PURE__ */ jsx31(SelectComponent, { itemId }),
3898
+ (hasChildren || hasDeferredChildren || hasDetails) && /* @__PURE__ */ jsx31(ExpandControl, { itemId, hasDeferredChildren }),
3899
+ rowAction
3900
+ ]
3901
+ }
3902
+ ),
3903
+ columnIds.map((columnId) => /* @__PURE__ */ jsx31(ColumnContext.Provider, { value: columnId, children: /* @__PURE__ */ jsx31(Cell, { itemId, rowIndex }) }, columnId)),
3904
+ /* @__PURE__ */ jsx31("div", { className: cellClassName, css: [defaultClasses.cellFill, css_] }),
3905
+ /* @__PURE__ */ jsx31(Details, { ref: detailsDivRef, itemId, rowIndex })
3906
+ ] })
3907
+ },
3908
+ item.value,
3909
+ rowIndex
3910
+ ) }) });
3783
3911
  });
3784
3912
 
3785
3913
  // src/components/virtualized.tsx
3786
- import { useEffect as useEffect13, useLayoutEffect as useLayoutEffect5, useMemo as useMemo10, useRef as useRef6, useState as useState13 } from "react";
3914
+ import { useEffect as useEffect14, useLayoutEffect as useLayoutEffect5, useMemo as useMemo10, useRef as useRef6, useState as useState13 } from "react";
3787
3915
  import { jsx as jsx32, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3788
3916
  var findScrollRoot = (x) => {
3789
3917
  const parent = x.parentElement;
@@ -3823,8 +3951,9 @@ function Virtualized(_a) {
3823
3951
  var _a3;
3824
3952
  const itemIds2 = state.activeItems.map((item) => item.id);
3825
3953
  const root = probeRef.current && findScrollRoot(probeRef.current);
3954
+ if (!probeRef.current || !root || !document.contains(root) || state.displaySizePx === void 0)
3955
+ return {};
3826
3956
  if (!state.props.virtual) return { itemIds: itemIds2 };
3827
- if (!probeRef.current || !root || !document.contains(root)) return {};
3828
3957
  const {
3829
3958
  rowHeight,
3830
3959
  initalRowHeight,
@@ -3863,7 +3992,24 @@ function Virtualized(_a) {
3863
3992
  );
3864
3993
  const throttleScroll = (_b2 = (_a2 = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a2.throttleScroll) != null ? _b2 : 16;
3865
3994
  const update = useMemo10(() => throttle(() => setId({}), throttleScroll), [throttleScroll]);
3866
- useEffect13(() => {
3995
+ useEffect14(() => {
3996
+ var _a3;
3997
+ const tableElem = (_a3 = probeRef.current) == null ? void 0 : _a3.parentElement;
3998
+ if (!tableElem) return;
3999
+ const update2 = () => {
4000
+ table.update((state) => {
4001
+ state.displaySizePx = tableElem.clientWidth;
4002
+ });
4003
+ };
4004
+ const ro = new ResizeObserver(update2);
4005
+ ro.observe(tableElem);
4006
+ window.addEventListener("resize", update2, true);
4007
+ return () => {
4008
+ ro.disconnect();
4009
+ window.removeEventListener("resize", update2, true);
4010
+ };
4011
+ }, [table, probeRef.current]);
4012
+ useEffect14(() => {
3867
4013
  if (!virtual || !probeRef.current) return;
3868
4014
  window.addEventListener("scroll", update, true);
3869
4015
  window.addEventListener("resize", update, true);
@@ -3872,7 +4018,7 @@ function Virtualized(_a) {
3872
4018
  window.removeEventListener("resize", update, true);
3873
4019
  };
3874
4020
  }, [update, virtual]);
3875
- useEffect13(() => update.cancel, [update]);
4021
+ useEffect14(() => update.cancel, [update]);
3876
4022
  useLayoutEffect5(
3877
4023
  () => {
3878
4024
  var _a3, _b3;
@@ -3908,7 +4054,7 @@ function Table(props) {
3908
4054
  function TableLoadingState({ isHydrated }) {
3909
4055
  const loadingText = useTheme((t) => t.text.loading);
3910
4056
  const [showLoading, setShowLoading] = useState14(false);
3911
- useEffect14(() => {
4057
+ useEffect15(() => {
3912
4058
  const handle = setTimeout(() => setShowLoading(true), 500);
3913
4059
  return () => clearTimeout(handle);
3914
4060
  });
@@ -3920,12 +4066,13 @@ function TableLoadingState({ isHydrated }) {
3920
4066
  var TableInner = memo3(function TableInner2({ hidden }) {
3921
4067
  const table = useTableContext();
3922
4068
  const fullWidth = table.useState((state) => state.props.fullWidth);
3923
- const activeColumns = table.useState(
3924
- (state) => state.activeColumns.map((column) => ({
4069
+ const visibleColumns = table.useState(
4070
+ (state) => state.visibleColumns.map((column) => ({
3925
4071
  id: column.id,
3926
4072
  width: column.width,
3927
4073
  classes: column.classes,
3928
- styles: column.styles
4074
+ styles: column.styles,
4075
+ footer: column.footer
3929
4076
  }))
3930
4077
  );
3931
4078
  const hasActiveFilters = table.useState((state) => {
@@ -3942,8 +4089,12 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3942
4089
  const stickyHeader = table.useState((state) => state.props.stickyHeader);
3943
4090
  const stickyFooter = table.useState((state) => state.props.stickyFooter);
3944
4091
  const enableSelection = table.useState((state) => state.props.enableSelection);
3945
- const enableColumnSelection = table.useState((state) => state.props.enableColumnSelection);
3946
- const enableExport = table.useState((state) => !!state.props.enableExport);
4092
+ const enableColumnSelection = table.useState(
4093
+ (state) => Array.isArray(state.props.enableColumnSelection) ? !state.displaySize || state.props.enableColumnSelection.includes(state.displaySize) : state.props.enableColumnSelection
4094
+ );
4095
+ const enableExport = table.useState(
4096
+ (state) => typeof state.props.enableExport === "object" && !("exporters" in state.props.enableExport) ? !state.displaySize || !!state.props.enableExport[state.displaySize] : !!state.props.enableExport
4097
+ );
3947
4098
  const cssVariables = useCssVariables();
3948
4099
  const enableClearFiltersButton = table.useState((state) => state.props.enableClearFiltersButton);
3949
4100
  useLayoutEffect6(() => {
@@ -3960,7 +4111,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3960
4111
  //
3961
4112
  fullWidth === "right" || fullWidth === true ? "auto" : "0",
3962
4113
  "max-content",
3963
- ...activeColumns.map(
4114
+ ...visibleColumns.map(
3964
4115
  (column) => {
3965
4116
  var _a, _b;
3966
4117
  return (_b = (_a = columnWidths.get(column.id)) != null ? _a : column.width) != null ? _b : "max-content";
@@ -3975,6 +4126,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3975
4126
  {
3976
4127
  className: classes == null ? void 0 : classes.headerCell,
3977
4128
  css: [
4129
+ { gridColumn: 1 },
3978
4130
  defaultClasses.headerFill,
3979
4131
  stickyHeader && defaultClasses.sticky,
3980
4132
  stickyHeader instanceof Object && stickyHeader,
@@ -3987,6 +4139,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3987
4139
  {
3988
4140
  className: classes == null ? void 0 : classes.headerCell,
3989
4141
  css: [
4142
+ { gridColumn: 2 },
3990
4143
  defaultClasses.headerCell,
3991
4144
  stickyHeader && defaultClasses.sticky,
3992
4145
  stickyHeader instanceof Object && stickyHeader,
@@ -4003,7 +4156,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
4003
4156
  ]
4004
4157
  }
4005
4158
  ),
4006
- /* @__PURE__ */ jsx33(ColumnHeaderContext.Provider, { children: activeColumns.map((column) => /* @__PURE__ */ jsx33(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ jsx33(ColumnHeader, {}) }, column.id)) }),
4159
+ /* @__PURE__ */ jsx33(ColumnHeaderContext.Provider, { children: visibleColumns.map((column) => /* @__PURE__ */ jsx33(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ jsx33(ColumnHeader, {}) }, column.id)) }),
4007
4160
  /* @__PURE__ */ jsx33(
4008
4161
  "div",
4009
4162
  {
@@ -4025,6 +4178,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
4025
4178
  {
4026
4179
  className: classes == null ? void 0 : classes.footerCell,
4027
4180
  css: [
4181
+ { gridColumn: 1 },
4028
4182
  defaultClasses.footerFill,
4029
4183
  stickyFooter && defaultClasses.stickyBottom,
4030
4184
  stickyFooter instanceof Object && stickyFooter,
@@ -4044,7 +4198,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
4044
4198
  ]
4045
4199
  }
4046
4200
  ),
4047
- activeColumns.map((column) => /* @__PURE__ */ jsx33(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ jsx33(ColumnFooter, {}) }, column.id)),
4201
+ visibleColumns.map((column) => /* @__PURE__ */ jsx33(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ jsx33(ColumnFooter, {}) }, column.id)),
4048
4202
  /* @__PURE__ */ jsx33(
4049
4203
  "div",
4050
4204
  {