schummar-table 0.43.1 → 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
@@ -3704,7 +3831,7 @@ var Row = memo2(function Row2({
3704
3831
  indent: item2 ? getAncestors(state.activeItemsById, item2).size : 0,
3705
3832
  hasChildren: !!(item2 == null ? void 0 : item2.children.length),
3706
3833
  hasDeferredChildren: item2 && ((_b = (_a2 = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a2, item2.value)),
3707
- columnIds: state.activeColumns.map((column) => column.id),
3834
+ columnIds: state.visibleColumns.map((column) => column.id),
3708
3835
  enableSelection: state.props.enableSelection,
3709
3836
  rowAction: state.props.rowAction instanceof Function ? item2 ? state.props.rowAction(item2.value, rowIndex) : null : state.props.rowAction,
3710
3837
  hasDetails: state.props.rowDetails instanceof Function ? item2 ? !!state.props.rowDetails(item2.value, rowIndex) : null : !!state.props.rowDetails
@@ -3784,7 +3911,7 @@ var Row = memo2(function Row2({
3784
3911
  });
3785
3912
 
3786
3913
  // src/components/virtualized.tsx
3787
- 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";
3788
3915
  import { jsx as jsx32, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3789
3916
  var findScrollRoot = (x) => {
3790
3917
  const parent = x.parentElement;
@@ -3824,8 +3951,9 @@ function Virtualized(_a) {
3824
3951
  var _a3;
3825
3952
  const itemIds2 = state.activeItems.map((item) => item.id);
3826
3953
  const root = probeRef.current && findScrollRoot(probeRef.current);
3954
+ if (!probeRef.current || !root || !document.contains(root) || state.displaySizePx === void 0)
3955
+ return {};
3827
3956
  if (!state.props.virtual) return { itemIds: itemIds2 };
3828
- if (!probeRef.current || !root || !document.contains(root)) return {};
3829
3957
  const {
3830
3958
  rowHeight,
3831
3959
  initalRowHeight,
@@ -3864,7 +3992,24 @@ function Virtualized(_a) {
3864
3992
  );
3865
3993
  const throttleScroll = (_b2 = (_a2 = typeof virtual === "boolean" ? void 0 : virtual) == null ? void 0 : _a2.throttleScroll) != null ? _b2 : 16;
3866
3994
  const update = useMemo10(() => throttle(() => setId({}), throttleScroll), [throttleScroll]);
3867
- 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(() => {
3868
4013
  if (!virtual || !probeRef.current) return;
3869
4014
  window.addEventListener("scroll", update, true);
3870
4015
  window.addEventListener("resize", update, true);
@@ -3873,7 +4018,7 @@ function Virtualized(_a) {
3873
4018
  window.removeEventListener("resize", update, true);
3874
4019
  };
3875
4020
  }, [update, virtual]);
3876
- useEffect13(() => update.cancel, [update]);
4021
+ useEffect14(() => update.cancel, [update]);
3877
4022
  useLayoutEffect5(
3878
4023
  () => {
3879
4024
  var _a3, _b3;
@@ -3909,7 +4054,7 @@ function Table(props) {
3909
4054
  function TableLoadingState({ isHydrated }) {
3910
4055
  const loadingText = useTheme((t) => t.text.loading);
3911
4056
  const [showLoading, setShowLoading] = useState14(false);
3912
- useEffect14(() => {
4057
+ useEffect15(() => {
3913
4058
  const handle = setTimeout(() => setShowLoading(true), 500);
3914
4059
  return () => clearTimeout(handle);
3915
4060
  });
@@ -3921,12 +4066,13 @@ function TableLoadingState({ isHydrated }) {
3921
4066
  var TableInner = memo3(function TableInner2({ hidden }) {
3922
4067
  const table = useTableContext();
3923
4068
  const fullWidth = table.useState((state) => state.props.fullWidth);
3924
- const activeColumns = table.useState(
3925
- (state) => state.activeColumns.map((column) => ({
4069
+ const visibleColumns = table.useState(
4070
+ (state) => state.visibleColumns.map((column) => ({
3926
4071
  id: column.id,
3927
4072
  width: column.width,
3928
4073
  classes: column.classes,
3929
- styles: column.styles
4074
+ styles: column.styles,
4075
+ footer: column.footer
3930
4076
  }))
3931
4077
  );
3932
4078
  const hasActiveFilters = table.useState((state) => {
@@ -3943,8 +4089,12 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3943
4089
  const stickyHeader = table.useState((state) => state.props.stickyHeader);
3944
4090
  const stickyFooter = table.useState((state) => state.props.stickyFooter);
3945
4091
  const enableSelection = table.useState((state) => state.props.enableSelection);
3946
- const enableColumnSelection = table.useState((state) => state.props.enableColumnSelection);
3947
- 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
+ );
3948
4098
  const cssVariables = useCssVariables();
3949
4099
  const enableClearFiltersButton = table.useState((state) => state.props.enableClearFiltersButton);
3950
4100
  useLayoutEffect6(() => {
@@ -3961,7 +4111,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3961
4111
  //
3962
4112
  fullWidth === "right" || fullWidth === true ? "auto" : "0",
3963
4113
  "max-content",
3964
- ...activeColumns.map(
4114
+ ...visibleColumns.map(
3965
4115
  (column) => {
3966
4116
  var _a, _b;
3967
4117
  return (_b = (_a = columnWidths.get(column.id)) != null ? _a : column.width) != null ? _b : "max-content";
@@ -3976,6 +4126,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3976
4126
  {
3977
4127
  className: classes == null ? void 0 : classes.headerCell,
3978
4128
  css: [
4129
+ { gridColumn: 1 },
3979
4130
  defaultClasses.headerFill,
3980
4131
  stickyHeader && defaultClasses.sticky,
3981
4132
  stickyHeader instanceof Object && stickyHeader,
@@ -3988,6 +4139,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
3988
4139
  {
3989
4140
  className: classes == null ? void 0 : classes.headerCell,
3990
4141
  css: [
4142
+ { gridColumn: 2 },
3991
4143
  defaultClasses.headerCell,
3992
4144
  stickyHeader && defaultClasses.sticky,
3993
4145
  stickyHeader instanceof Object && stickyHeader,
@@ -4004,7 +4156,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
4004
4156
  ]
4005
4157
  }
4006
4158
  ),
4007
- /* @__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)) }),
4008
4160
  /* @__PURE__ */ jsx33(
4009
4161
  "div",
4010
4162
  {
@@ -4026,6 +4178,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
4026
4178
  {
4027
4179
  className: classes == null ? void 0 : classes.footerCell,
4028
4180
  css: [
4181
+ { gridColumn: 1 },
4029
4182
  defaultClasses.footerFill,
4030
4183
  stickyFooter && defaultClasses.stickyBottom,
4031
4184
  stickyFooter instanceof Object && stickyFooter,
@@ -4045,7 +4198,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
4045
4198
  ]
4046
4199
  }
4047
4200
  ),
4048
- 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)),
4049
4202
  /* @__PURE__ */ jsx33(
4050
4203
  "div",
4051
4204
  {