schummar-table 0.6.0 → 0.8.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/es/index.js CHANGED
@@ -29,15 +29,43 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { useState, useEffect, useMemo, useRef, createContext, useCallback, memo, useContext, cloneElement, useLayoutEffect, Fragment as Fragment$1 } from "react";
32
+ import { createContext, useContext, useMemo, useState, useEffect, useCallback, useRef, memo, useLayoutEffect, cloneElement, Fragment as Fragment$1 } from "react";
33
33
  import { Store, StoreScope } from "schummar-state/react";
34
- import { d as defaultClasses, a as darkGray, l as lightGray, P as Popover, m as mergeThemes, g as globalTableTheme, T as TableThemeContext, b as PopoverContext, c as gray } from "./tableTheme.js";
34
+ import { d as defaultClasses, a as darkGray, l as lightGray, P as Popover, T as TableThemeContext, m as mergeThemes, g as globalTableTheme, b as PopoverContext, c as gray } from "./tableTheme.js";
35
35
  export { T as TableThemeContext, f as TableThemeProvider, e as configureTableTheme, m as mergeThemes } from "./tableTheme.js";
36
36
  import { jsx, jsxs, Fragment } from "@emotion/react/jsx-runtime";
37
37
  import { useDayzed } from "dayzed";
38
38
  import { castDraft } from "immer";
39
39
  import { css, ClassNames } from "@emotion/react";
40
40
  import "react-dom";
41
+ const TableMemoContext = createContext(/* @__PURE__ */ new Map());
42
+ function TableMemoContextProvider({
43
+ children
44
+ }) {
45
+ return /* @__PURE__ */ jsx(TableMemoContext.Provider, {
46
+ value: useMemo(() => /* @__PURE__ */ new Map(), []),
47
+ children
48
+ });
49
+ }
50
+ function useTableMemo() {
51
+ const memoCache = useContext(TableMemoContext);
52
+ return (key, fn) => {
53
+ let deps;
54
+ if (Array.isArray(fn)) {
55
+ deps = fn.slice(1);
56
+ fn = fn[0];
57
+ } else {
58
+ deps = [fn.toString()];
59
+ }
60
+ let cachedValue = memoCache.get(key);
61
+ const hit = cachedValue && cachedValue[1].length === deps.length && cachedValue[1].every((x, i) => x === deps[i]);
62
+ if (!cachedValue || !hit) {
63
+ cachedValue = [fn, deps];
64
+ memoCache.set(key, cachedValue);
65
+ }
66
+ return cachedValue[0];
67
+ };
68
+ }
41
69
  class Queue {
42
70
  constructor() {
43
71
  this.q = new Array();
@@ -280,10 +308,11 @@ function calcItems(state) {
280
308
  state2.activeColumns,
281
309
  state2.expanded
282
310
  ], ([items = [], id, parentId, revealFiltered, sort, filters, filterValues, activeColumns], draft) => {
283
- const tableItems = items.map((item) => __spreadProps(__spreadValues({}, item), {
311
+ const tableItems = items.map((item) => ({
284
312
  id: id(item),
285
313
  parentId: parentId == null ? void 0 : parentId(item),
286
- children: []
314
+ children: [],
315
+ value: item
287
316
  }));
288
317
  let sorted;
289
318
  if (sort.length === 0) {
@@ -293,10 +322,12 @@ function calcItems(state) {
293
322
  const column = activeColumns.find((column2) => column2.id === sort2.columnId);
294
323
  if (!column)
295
324
  return [];
296
- const sortBy = column.sortBy instanceof Array ? column.sortBy : [column.sortBy];
297
- return sortBy.map((sortBy2) => ({ selector: (item) => sortBy2(column.value(item), item), direction: sort2.direction }));
325
+ return column.sortBy.map((sortBy) => ({
326
+ selector: (item) => sortBy(column.value(item), item),
327
+ direction: sort2.direction
328
+ }));
298
329
  }).filter(Boolean);
299
- sorted = orderBy(tableItems, selectors.map((x) => x.selector), selectors.map((x) => x.direction));
330
+ sorted = orderBy(tableItems, selectors.map((x) => (item) => x.selector(item.value)), selectors.map((x) => x.direction));
300
331
  }
301
332
  const lookup = /* @__PURE__ */ new Map();
302
333
  for (const item of sorted) {
@@ -330,7 +361,7 @@ function calcItems(state) {
330
361
  if (filterValue === void 0 || !filter.isActive(filterValue))
331
362
  return true;
332
363
  const filterBy = (_a = filter.filterBy) != null ? _a : (x) => x;
333
- const value = filterBy(column.value(item), item);
364
+ const value = filterBy(column.value(item.value), item.value);
334
365
  return castArray(value).some((value2) => filter.test(filterValue, value2));
335
366
  }));
336
367
  if (isActive && item.parentId !== void 0) {
@@ -366,20 +397,20 @@ function calcItems(state) {
366
397
  }
367
398
  const noopParentId = () => void 0;
368
399
  function calcProps(props) {
369
- const columnCache = useRef(/* @__PURE__ */ new Map());
400
+ const cache = useTableMemo();
370
401
  return useMemo(() => {
371
- var _c, _d, _e, _f, _g, _h;
402
+ var _f, _g, _h, _i, _j, _k, _l;
372
403
  let id;
373
- if (props.id instanceof Function) {
374
- id = props.id;
404
+ if (props.id instanceof Function || Array.isArray(props.id)) {
405
+ id = cache("id", props.id);
375
406
  } else {
376
- id = (item) => item[props.id];
407
+ id = cache("id", [(item) => item[props.id], props.id]);
377
408
  }
378
409
  let parentId;
379
- if (props.parentId instanceof Function) {
380
- parentId = props.parentId;
381
- } else if (typeof props.parentId === "string") {
382
- parentId = (item) => item[props.parentId];
410
+ if (props.parentId instanceof Function || Array.isArray(props.parentId)) {
411
+ parentId = cache("parentId", props.parentId);
412
+ } else if (props.parentId !== void 0) {
413
+ parentId = cache("parentId", [(item) => item[props.parentId], props.parentId]);
383
414
  } else {
384
415
  parentId = noopParentId;
385
416
  }
@@ -389,42 +420,39 @@ function calcProps(props) {
389
420
  } else {
390
421
  inputColumns = props.columns.map((column) => __spreadProps(__spreadValues({}, column), { dependecies: void 0 }));
391
422
  }
392
- const newColumnCache = /* @__PURE__ */ new Map();
393
- const columns = inputColumns.map(function(_a, index) {
394
- var _b = _a, {
423
+ const defCol = props.defaultColumnProps;
424
+ const mapColumn = ({
425
+ id: _id,
426
+ header = ((_a) => (_a = defCol == null ? void 0 : defCol.header) != null ? _a : null)(),
427
+ footer = ((_b) => (_b = defCol == null ? void 0 : defCol.footer) != null ? _b : null)(),
428
+ value,
429
+ renderCell = ((_c) => (_c = defCol == null ? void 0 : defCol.renderCell) != null ? _c : asString)(),
430
+ exportCell = ((_d) => (_d = defCol == null ? void 0 : defCol.exportCell) != null ? _d : asString)(),
431
+ sortBy = ((_e) => (_e = defCol == null ? void 0 : defCol.sortBy) != null ? _e : [(v) => typeof v === "number" || v instanceof Date ? v : String(v)])(),
432
+ cannotHide = defCol == null ? void 0 : defCol.cannotHide,
433
+ classes = defCol == null ? void 0 : defCol.classes,
434
+ filter = defCol == null ? void 0 : defCol.filter,
435
+ width = defCol == null ? void 0 : defCol.width
436
+ }, index) => {
437
+ const id2 = _id != null ? _id : index;
438
+ const cacheKey = typeof id2 === "string" ? `s${id2}` : `n${id2}`;
439
+ return {
395
440
  id: id2,
396
- header = null,
397
- renderCell = asString,
398
- exportCell = asString,
399
- sortBy = (v) => typeof v === "number" || v instanceof Date ? v : String(v),
400
- dependencies = []
401
- } = _b, props2 = __objRest(_b, [
402
- "id",
403
- "header",
404
- "renderCell",
405
- "exportCell",
406
- "sortBy",
407
- "dependencies"
408
- ]);
409
- var _a2;
410
- const [depsInCache, columnInCache] = (_a2 = columnCache.current.get(id2 != null ? id2 : index)) != null ? _a2 : [];
411
- let column;
412
- if (depsInCache && columnInCache && depsInCache.length === dependencies.length && depsInCache.every((x, i) => dependencies[i] === x)) {
413
- column = columnInCache;
414
- } else {
415
- column = __spreadValues({
416
- id: id2 != null ? id2 : index,
417
- header,
418
- renderCell,
419
- exportCell,
420
- sortBy,
421
- dependencies
422
- }, props2);
423
- }
424
- newColumnCache.set(id2 != null ? id2 : index, [dependencies, column]);
425
- return column;
426
- });
427
- columnCache.current = newColumnCache;
441
+ header: header instanceof Function ? cache(`columns.${cacheKey}.header`, header) : header,
442
+ footer: footer instanceof Function ? cache(`columns.${cacheKey}.footer`, footer) : footer,
443
+ value: cache(`columns.${cacheKey}.value`, value),
444
+ renderCell: cache(`columns.${cacheKey}.renderCell`, renderCell),
445
+ exportCell,
446
+ sortBy: sortBy.map((fn, i) => cache(`columns.${cacheKey}.sortBy.${i}`, fn)),
447
+ cannotHide,
448
+ classes,
449
+ filter,
450
+ width
451
+ };
452
+ };
453
+ const columns = inputColumns.map(mapColumn);
454
+ const wrapCell = props.wrapCell && cache("wrapCell", props.wrapCell);
455
+ const rowAction = props.rowAction instanceof Function || Array.isArray(props.rowAction) ? cache("rowAction", props.rowAction) : props.rowAction;
428
456
  let copy;
429
457
  if (props.enableExport === true || props.enableExport instanceof Object && props.enableExport.copy === true) {
430
458
  copy = { separator: " " };
@@ -442,13 +470,16 @@ function calcProps(props) {
442
470
  id,
443
471
  parentId,
444
472
  columns,
445
- enableSelection: (_c = props.enableSelection) != null ? _c : true,
446
- selectSyncChildren: (_d = props.selectSyncChildren) != null ? _d : true,
447
- stickyHeader: (_e = props.stickyHeader) != null ? _e : true,
473
+ wrapCell,
474
+ rowAction,
475
+ enableSelection: (_f = props.enableSelection) != null ? _f : true,
476
+ selectSyncChildren: (_g = props.selectSyncChildren) != null ? _g : true,
477
+ stickyHeader: (_h = props.stickyHeader) != null ? _h : true,
478
+ stickyFooter: (_i = props.stickyFooter) != null ? _i : true,
448
479
  enableExport,
449
- enableColumnSelection: (_f = props.enableColumnSelection) != null ? _f : true,
450
- enableColumnResize: (_g = props.enableColumnResize) != null ? _g : true,
451
- enableColumnReorder: (_h = props.enableColumnReorder) != null ? _h : true
480
+ enableColumnSelection: (_j = props.enableColumnSelection) != null ? _j : true,
481
+ enableColumnResize: (_k = props.enableColumnResize) != null ? _k : true,
482
+ enableColumnReorder: (_l = props.enableColumnReorder) != null ? _l : true
452
483
  });
453
484
  }, [props]);
454
485
  }
@@ -578,25 +609,269 @@ function useTableState(_props) {
578
609
  return state;
579
610
  }
580
611
  function useCssVariables() {
581
- const theme = useTheme();
582
- return {
583
- "--spacing": theme.spacing,
584
- "--primaryMain": theme.colors.primary.main,
585
- "--primaryLight": theme.colors.primary.light,
586
- "--primaryContrastText": theme.colors.primary.contrastText,
587
- "--secondaryMain": theme.colors.secondary.main,
588
- "--secondaryLight": theme.colors.secondary.light,
589
- "--secondaryContrastText": theme.colors.secondary.contrastText
590
- };
612
+ return useTheme(({ spacing, colors }) => ({
613
+ "--spacing": spacing,
614
+ "--primaryMain": colors.primary.main,
615
+ "--primaryLight": colors.primary.light,
616
+ "--primaryContrastText": colors.primary.contrastText,
617
+ "--secondaryMain": colors.secondary.main,
618
+ "--secondaryLight": colors.secondary.light,
619
+ "--secondaryContrastText": colors.secondary.contrastText
620
+ }));
621
+ }
622
+ function ColumnFooter() {
623
+ const table = useTableContext();
624
+ const columnId = useColumnContext();
625
+ const stickyFooter = table.useState("props.stickyFooter");
626
+ const columnStyleOverride = table.useState((state) => state.columnStyleOverride.get(columnId), {
627
+ throttle: 16
628
+ });
629
+ const columnClasses = table.useState((state) => {
630
+ var _a;
631
+ return (_a = state.activeColumns.find((column) => column.id === columnId)) == null ? void 0 : _a.classes;
632
+ });
633
+ const classes = useTheme((theme) => theme.classes);
634
+ const content = table.useState((state) => {
635
+ const column = state.activeColumns.find((column2) => column2.id === columnId);
636
+ if ((column == null ? void 0 : column.footer) instanceof Function) {
637
+ const items = state.activeItems;
638
+ const values = items.map((item) => column == null ? void 0 : column.value(item));
639
+ return column == null ? void 0 : column.footer(values, items);
640
+ }
641
+ return column == null ? void 0 : column.footer;
642
+ });
643
+ return /* @__PURE__ */ jsx("div", {
644
+ className: cx(classes == null ? void 0 : classes.footerCell, columnClasses == null ? void 0 : columnClasses.footerCell),
645
+ css: [defaultClasses.footerCell, columnStyleOverride, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter],
646
+ children: content
647
+ });
648
+ }
649
+ const FilterControlContext = createContext(() => void 0);
650
+ function FilterControl() {
651
+ const table = useTableContext();
652
+ const columnId = useColumnContext();
653
+ const IconButton2 = useTheme((t) => t.components.IconButton);
654
+ const Popover2 = useTheme((t) => t.components.Popover);
655
+ const FilterList2 = useTheme((t) => t.icons.FilterList);
656
+ const ArrowDropDown2 = useTheme((t) => t.icons.ArrowDropDown);
657
+ const cssVariables = useCssVariables();
658
+ const [anchor, setAnchor] = useState(null);
659
+ const isActive = table.useState((state) => {
660
+ const filter2 = state.filters.get(columnId);
661
+ const filterValue = state.filterValues.get(columnId);
662
+ return filter2 !== void 0 && filterValue !== void 0 && filter2.isActive(filterValue);
663
+ });
664
+ const filter = table.useState((state) => {
665
+ var _a;
666
+ return (_a = state.activeColumns.find((column) => column.id === columnId)) == null ? void 0 : _a.filter;
667
+ });
668
+ function reset() {
669
+ table.update((state) => {
670
+ state.filterValues.delete(columnId);
671
+ });
672
+ }
673
+ const close = useCallback(function() {
674
+ setAnchor(null);
675
+ }, []);
676
+ if (!filter)
677
+ return null;
678
+ return /* @__PURE__ */ jsxs(FilterControlContext.Provider, {
679
+ value: close,
680
+ children: [/* @__PURE__ */ jsx("div", {
681
+ onClick: (e2) => setAnchor(e2.currentTarget),
682
+ onContextMenu: (e2) => {
683
+ reset();
684
+ e2.preventDefault();
685
+ return false;
686
+ },
687
+ children: /* @__PURE__ */ jsx(IconButton2, {
688
+ css: [{
689
+ color: "#b0bac9"
690
+ }, isActive && {
691
+ color: "var(--primaryMain) !important"
692
+ }],
693
+ children: isActive ? /* @__PURE__ */ jsx(FilterList2, {}) : /* @__PURE__ */ jsx(ArrowDropDown2, {})
694
+ })
695
+ }), /* @__PURE__ */ jsx("div", {
696
+ onPointerDown: (e2) => {
697
+ e2.stopPropagation();
698
+ },
699
+ onPointerMove: (e2) => {
700
+ e2.stopPropagation();
701
+ },
702
+ children: /* @__PURE__ */ jsx(Popover2, {
703
+ open: true,
704
+ hidden: !anchor,
705
+ onClose: () => setAnchor(null),
706
+ anchorEl: anchor != null ? anchor : document.body,
707
+ css: cssVariables,
708
+ children: filter
709
+ })
710
+ })]
711
+ });
712
+ }
713
+ function ResizeHandle() {
714
+ const table = useTableContext();
715
+ const columnId = useColumnContext();
716
+ const enabled = table.useState("props.enableColumnResize");
717
+ function onPointerDown(e2) {
718
+ e2.stopPropagation();
719
+ const div = e2.target;
720
+ div.setPointerCapture(e2.pointerId);
721
+ }
722
+ function onPointerMove(e2) {
723
+ e2.stopPropagation();
724
+ const div = e2.target;
725
+ if (!div.hasPointerCapture(e2.pointerId))
726
+ return;
727
+ const parent = div.parentElement;
728
+ const width = Math.max(e2.clientX - parent.getBoundingClientRect().left + 5, 50);
729
+ table.update((state) => {
730
+ state.columnWidths.set(columnId, `${width}px`);
731
+ });
732
+ }
733
+ function onPointerUp(e2) {
734
+ e2.stopPropagation();
735
+ const div = e2.target;
736
+ div.releasePointerCapture(e2.pointerId);
737
+ }
738
+ function onDoubleClick(e2) {
739
+ table.update((state) => {
740
+ if (e2.getModifierState("Control")) {
741
+ state.columnWidths.delete(columnId);
742
+ } else {
743
+ state.columnWidths.set(columnId, "max-content");
744
+ }
745
+ });
746
+ }
747
+ return /* @__PURE__ */ jsx(ResizeHandleView, {
748
+ enabled,
749
+ onPointerDown: enabled ? onPointerDown : void 0,
750
+ onPointerMove: enabled ? onPointerMove : void 0,
751
+ onPointerUp: enabled ? onPointerUp : void 0,
752
+ onDoubleClick: enabled ? onDoubleClick : void 0
753
+ });
754
+ }
755
+ function ResizeHandleView(_a) {
756
+ var _b = _a, {
757
+ enabled
758
+ } = _b, props = __objRest(_b, [
759
+ "enabled"
760
+ ]);
761
+ return /* @__PURE__ */ jsx("div", __spreadValues({
762
+ css: {
763
+ alignSelf: "stretch",
764
+ padding: "0 5px",
765
+ cursor: enabled ? "col-resize" : "initial",
766
+ display: "flex",
767
+ alignItems: "center",
768
+ "&:after": {
769
+ content: '""',
770
+ width: 1,
771
+ height: "1.5em",
772
+ background: "#c9cfda",
773
+ transition: "transform 300ms"
774
+ }
775
+ }
776
+ }, props));
777
+ }
778
+ function SortComponent({
779
+ children
780
+ }) {
781
+ const table = useTableContext();
782
+ const columnId = useColumnContext();
783
+ const Badge2 = useTheme((t) => t.components.Badge);
784
+ const ArrowUpward2 = useTheme((t) => t.icons.ArrowUpward);
785
+ const {
786
+ direction,
787
+ index
788
+ } = table.useState((state) => {
789
+ var _a, _b;
790
+ const index2 = (_a = state.sort.findIndex((s) => s.columnId === columnId)) != null ? _a : -1;
791
+ return {
792
+ direction: (_b = state.sort[index2]) == null ? void 0 : _b.direction,
793
+ index: index2 >= 0 && state.sort.length > 1 ? index2 + 1 : void 0
794
+ };
795
+ });
796
+ function toggle2(e2, off) {
797
+ const {
798
+ props: {
799
+ sort: controlledSort,
800
+ onSortChange
801
+ }
802
+ } = table.getState();
803
+ const newDirection = direction === "asc" ? "desc" : "asc";
804
+ const newSort = e2.getModifierState("Control") || off ? table.getState().sort.filter((s) => s.columnId !== columnId) : [];
805
+ if (!off) {
806
+ newSort.push({
807
+ columnId,
808
+ direction: newDirection
809
+ });
810
+ }
811
+ onSortChange == null ? void 0 : onSortChange(newSort);
812
+ if (!controlledSort) {
813
+ table.update((state) => {
814
+ state.sort = newSort;
815
+ });
816
+ }
817
+ e2.preventDefault();
818
+ return false;
819
+ }
820
+ return /* @__PURE__ */ jsxs("div", {
821
+ css: {
822
+ userSelect: "none",
823
+ display: "grid",
824
+ gridTemplateColumns: "minmax(0, 1fr) max-content",
825
+ alignItems: "center",
826
+ cursor: "pointer",
827
+ "& > div": {
828
+ overflow: "hidden",
829
+ textOverflow: "ellipsis"
830
+ }
831
+ },
832
+ onClick: (e2) => toggle2(e2),
833
+ onContextMenu: (e2) => toggle2(e2, true),
834
+ children: [/* @__PURE__ */ jsx("div", {
835
+ children
836
+ }), /* @__PURE__ */ jsx(Badge2, {
837
+ badgeContent: index,
838
+ children: /* @__PURE__ */ jsx("span", {
839
+ css: [{
840
+ transition: "all 300ms",
841
+ fontSize: "0.8em"
842
+ }, !direction && {
843
+ opacity: 0
844
+ }, direction === "desc" && {
845
+ transform: "rotate3d(0, 0, 1, 180deg)"
846
+ }],
847
+ children: /* @__PURE__ */ jsx(ArrowUpward2, {})
848
+ })
849
+ })]
850
+ });
591
851
  }
592
852
  const ColumnHeaderContext = new StoreScope({
593
853
  items: /* @__PURE__ */ new Map()
594
854
  });
595
- function ColumnHeader(props) {
855
+ function ColumnHeader() {
596
856
  const ref = useRef(null);
597
857
  const columnId = useColumnContext();
598
858
  const table = useTableContext();
599
859
  const enabled = table.useState("props.enableColumnReorder");
860
+ const columnStyleOverride = table.useState((state) => state.columnStyleOverride.get(columnId), {
861
+ throttle: 16
862
+ });
863
+ const stickyHeader = table.useState("props.stickyHeader");
864
+ const classes = useTheme((theme) => theme.classes);
865
+ const {
866
+ header,
867
+ columnClasses
868
+ } = table.useState((state) => {
869
+ const column = state.activeColumns.find((column2) => column2.id === columnId);
870
+ return {
871
+ header: column == null ? void 0 : column.header,
872
+ columnClasses: column == null ? void 0 : column.classes
873
+ };
874
+ });
600
875
  const store = ColumnHeaderContext.useStore();
601
876
  const draggingStart = useRef();
602
877
  const clone = useRef();
@@ -715,24 +990,31 @@ function ColumnHeader(props) {
715
990
  clone.current = void 0;
716
991
  });
717
992
  }
718
- return jsx("div", __spreadProps(__spreadValues({}, props), {
719
- css: {
993
+ return /* @__PURE__ */ jsxs("div", {
994
+ ref,
995
+ className: cx(classes == null ? void 0 : classes.headerCell, columnClasses == null ? void 0 : columnClasses.headerCell),
996
+ css: [{
720
997
  position: "relative",
721
998
  userSelect: "none"
722
- },
723
- ref,
999
+ }, defaultClasses.headerCell, columnStyleOverride, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
724
1000
  onPointerDown: enabled ? onPointerDown : void 0,
725
1001
  onPointerMove: enabled ? onPointerMove : void 0,
726
1002
  onPointerUp: enabled ? onPointerUp : void 0,
727
- children: props.children
728
- }));
1003
+ children: [/* @__PURE__ */ jsx(SortComponent, {
1004
+ children: header
1005
+ }), /* @__PURE__ */ jsx("div", {
1006
+ css: {
1007
+ flex: 1
1008
+ }
1009
+ }), /* @__PURE__ */ jsx(FilterControl, {}), /* @__PURE__ */ jsx(ResizeHandle, {})]
1010
+ });
729
1011
  }
730
1012
  function FormControlLabel({
731
1013
  control,
732
1014
  label,
733
1015
  disabled
734
1016
  }) {
735
- return jsxs("label", {
1017
+ return /* @__PURE__ */ jsxs("label", {
736
1018
  css: [{
737
1019
  display: "flex",
738
1020
  alignItems: "center",
@@ -744,7 +1026,7 @@ function FormControlLabel({
744
1026
  }, disabled && {
745
1027
  color: "rgba(0, 0, 0, 0.26)"
746
1028
  }],
747
- children: [control, jsx("span", {
1029
+ children: [control, /* @__PURE__ */ jsx("span", {
748
1030
  css: {
749
1031
  marginLeft: "var(--spacing)"
750
1032
  },
@@ -753,17 +1035,11 @@ function FormControlLabel({
753
1035
  });
754
1036
  }
755
1037
  function ColumnSelection() {
756
- const {
757
- components: {
758
- IconButton: IconButton2,
759
- Popover: Popover2,
760
- Checkbox: Checkbox2
761
- },
762
- icons: {
763
- Settings: Settings2
764
- },
765
- text
766
- } = useTheme();
1038
+ const IconButton2 = useTheme((t) => t.components.IconButton);
1039
+ const Popover2 = useTheme((t) => t.components.Popover);
1040
+ const Checkbox2 = useTheme((t) => t.components.Checkbox);
1041
+ const Settings2 = useTheme((t) => t.icons.Settings);
1042
+ const selectColumns = useTheme((t) => t.text.selectColumns);
767
1043
  const cssVariables = useCssVariables();
768
1044
  const table = useTableContext();
769
1045
  const columns = table.useState("props.columns");
@@ -788,27 +1064,27 @@ function ColumnSelection() {
788
1064
  }
789
1065
  onHiddenColumnsChange == null ? void 0 : onHiddenColumnsChange(newValue);
790
1066
  };
791
- return jsxs(Fragment, {
792
- children: [jsx(IconButton2, {
1067
+ return /* @__PURE__ */ jsxs(Fragment, {
1068
+ children: [/* @__PURE__ */ jsx(IconButton2, {
793
1069
  onClick: (e2) => setAnchorEl(anchorEl ? null : e2.currentTarget),
794
- children: jsx(Settings2, {})
795
- }), jsx(Popover2, {
1070
+ children: /* @__PURE__ */ jsx(Settings2, {})
1071
+ }), /* @__PURE__ */ jsx(Popover2, {
796
1072
  anchorEl,
797
1073
  open: !!anchorEl,
798
1074
  onClose: () => setAnchorEl(null),
799
1075
  css: cssVariables,
800
- children: jsxs("div", {
1076
+ children: /* @__PURE__ */ jsxs("div", {
801
1077
  css: {
802
1078
  padding: `calc(var(--spacing) * 2)`,
803
1079
  display: "grid"
804
1080
  },
805
- children: [jsx("div", {
1081
+ children: [/* @__PURE__ */ jsx("div", {
806
1082
  css: {
807
1083
  marginBottom: "var(--spacing)"
808
1084
  },
809
- children: text.selectColumns
810
- }), columns.map((column) => jsx(FormControlLabel, {
811
- control: jsx(Checkbox2, {
1085
+ children: selectColumns
1086
+ }), columns.map((column) => /* @__PURE__ */ jsx(FormControlLabel, {
1087
+ control: /* @__PURE__ */ jsx(Checkbox2, {
812
1088
  checked: !hiddenColumns.has(column.id),
813
1089
  onChange: () => toggle2(column),
814
1090
  disabled: column.cannotHide
@@ -833,18 +1109,14 @@ function csvExport(data, { sepPrefix, separator = ",", quote = '"', eol = "\n" }
833
1109
  }
834
1110
  function Export$1() {
835
1111
  const table = useTableContext();
836
- const {
837
- components: {
838
- Button: Button2,
839
- IconButton: IconButton2,
840
- Popover: Popover2
841
- },
842
- icons: {
843
- Export: Export2,
844
- Clipboard: Clipboard2
845
- },
846
- text
847
- } = useTheme();
1112
+ const Button2 = useTheme((t) => t.components.Button);
1113
+ const IconButton2 = useTheme((t) => t.components.IconButton);
1114
+ const Popover2 = useTheme((t) => t.components.Popover);
1115
+ const Export2 = useTheme((t) => t.icons.Export);
1116
+ const Clipboard2 = useTheme((t) => t.icons.Clipboard);
1117
+ const exportTitle = useTheme((t) => t.text.exportTitle);
1118
+ const exportCopy = useTheme((t) => t.text.exportCopy);
1119
+ const exportDownload = useTheme((t) => t.text.exportDownload);
848
1120
  const cssVariables = useCssVariables();
849
1121
  const [anchor, setAnchor] = useState(null);
850
1122
  const generate = (options) => {
@@ -852,7 +1124,7 @@ function Export$1() {
852
1124
  activeColumns,
853
1125
  activeItems
854
1126
  } = table.getState();
855
- const data = [activeColumns.map((column) => String(column.id)), ...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item), item)))];
1127
+ const data = [activeColumns.map((column) => String(column.id)), ...activeItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)))];
856
1128
  return csvExport(data, options);
857
1129
  };
858
1130
  const copy = () => {
@@ -866,225 +1138,97 @@ function Export$1() {
866
1138
  a.click();
867
1139
  document.body.removeChild(a);
868
1140
  };
869
- return jsxs(Fragment, {
870
- children: [jsx(IconButton2, {
1141
+ return /* @__PURE__ */ jsxs(Fragment, {
1142
+ children: [/* @__PURE__ */ jsx(IconButton2, {
871
1143
  onClick: (e2) => setAnchor(anchor ? null : e2.currentTarget),
872
- children: jsx(Export2, {
1144
+ children: /* @__PURE__ */ jsx(Export2, {
873
1145
  css: !!anchor && {
874
1146
  color: "var(--primaryMain)"
875
1147
  }
876
1148
  })
877
- }), jsx(Popover2, {
878
- open: !!anchor,
879
- onClose: () => setAnchor(null),
880
- anchorEl: anchor,
881
- css: cssVariables,
882
- children: jsxs("div", {
883
- css: {
884
- padding: `calc(var(--spacing) * 2)`,
885
- display: "grid",
886
- justifyItems: "stretch",
887
- gap: "var(--spacing)",
888
- "& > *": {
889
- justifyContent: "start"
890
- }
891
- },
892
- children: [jsx("div", {
893
- css: {
894
- marginBottom: "var(--spacing)"
895
- },
896
- children: text.exportTitle
897
- }), jsx(Button2, {
898
- startIcon: jsx(Clipboard2, {}),
899
- onClick: copy,
900
- children: text.exportCopy
901
- }), jsx(Button2, {
902
- startIcon: jsx(Export2, {}),
903
- onClick: download,
904
- children: text.exportDownload
905
- })]
906
- })
907
- })]
908
- });
909
- }
910
- const FilterControlContext = createContext(() => void 0);
911
- function FilterControl() {
912
- const table = useTableContext();
913
- const columnId = useColumnContext();
914
- const {
915
- components: {
916
- IconButton: IconButton2,
917
- Popover: Popover2
918
- },
919
- icons: {
920
- FilterList: FilterList2,
921
- ArrowDropDown: ArrowDropDown2
922
- }
923
- } = useTheme();
924
- const cssVariables = useCssVariables();
925
- const [anchor, setAnchor] = useState(null);
926
- const isActive = table.useState((state) => {
927
- const filter2 = state.filters.get(columnId);
928
- const filterValue = state.filterValues.get(columnId);
929
- return filter2 !== void 0 && filterValue !== void 0 && filter2.isActive(filterValue);
930
- });
931
- const filter = table.useState((state) => {
932
- var _a;
933
- return (_a = state.activeColumns.find((column) => column.id === columnId)) == null ? void 0 : _a.filter;
934
- });
935
- function reset() {
936
- table.update((state) => {
937
- state.filterValues.delete(columnId);
938
- });
939
- }
940
- const close = useCallback(function() {
941
- setAnchor(null);
942
- }, []);
943
- if (!filter)
944
- return null;
945
- return jsxs(FilterControlContext.Provider, {
946
- value: close,
947
- children: [jsx("div", {
948
- onClick: (e2) => setAnchor(e2.currentTarget),
949
- onContextMenu: (e2) => {
950
- reset();
951
- e2.preventDefault();
952
- return false;
953
- },
954
- children: jsx(IconButton2, {
955
- css: [{
956
- color: "#b0bac9"
957
- }, isActive && {
958
- color: "var(--primaryMain) !important"
959
- }],
960
- children: isActive ? jsx(FilterList2, {}) : jsx(ArrowDropDown2, {})
961
- })
962
- }), jsx("div", {
963
- onPointerDown: (e2) => {
964
- e2.stopPropagation();
965
- },
966
- onPointerMove: (e2) => {
967
- e2.stopPropagation();
968
- },
969
- children: jsx(Popover2, {
970
- open: true,
971
- hidden: !anchor,
972
- onClose: () => setAnchor(null),
973
- anchorEl: anchor != null ? anchor : document.body,
974
- css: cssVariables,
975
- children: filter
1149
+ }), /* @__PURE__ */ jsx(Popover2, {
1150
+ open: !!anchor,
1151
+ onClose: () => setAnchor(null),
1152
+ anchorEl: anchor,
1153
+ css: cssVariables,
1154
+ children: /* @__PURE__ */ jsxs("div", {
1155
+ css: {
1156
+ padding: `calc(var(--spacing) * 2)`,
1157
+ display: "grid",
1158
+ justifyItems: "stretch",
1159
+ gap: "var(--spacing)",
1160
+ "& > *": {
1161
+ justifyContent: "start"
1162
+ }
1163
+ },
1164
+ children: [/* @__PURE__ */ jsx("div", {
1165
+ css: {
1166
+ marginBottom: "var(--spacing)"
1167
+ },
1168
+ children: exportTitle
1169
+ }), /* @__PURE__ */ jsx(Button2, {
1170
+ startIcon: /* @__PURE__ */ jsx(Clipboard2, {}),
1171
+ onClick: copy,
1172
+ children: exportCopy
1173
+ }), /* @__PURE__ */ jsx(Button2, {
1174
+ startIcon: /* @__PURE__ */ jsx(Export2, {}),
1175
+ onClick: download,
1176
+ children: exportDownload
1177
+ })]
976
1178
  })
977
1179
  })]
978
1180
  });
979
1181
  }
980
- function ResizeHandle() {
981
- const table = useTableContext();
982
- const columnId = useColumnContext();
983
- const enabled = table.useState("props.enableColumnResize");
984
- function onPointerDown(e2) {
985
- e2.stopPropagation();
986
- const div = e2.target;
987
- div.setPointerCapture(e2.pointerId);
988
- }
989
- function onPointerMove(e2) {
990
- e2.stopPropagation();
991
- const div = e2.target;
992
- if (!div.hasPointerCapture(e2.pointerId))
993
- return;
994
- const parent = div.parentElement;
995
- const width = Math.max(e2.clientX - parent.getBoundingClientRect().left + 5, 50);
996
- table.update((state) => {
997
- state.columnWidths.set(columnId, `${width}px`);
998
- });
999
- }
1000
- function onPointerUp(e2) {
1001
- e2.stopPropagation();
1002
- const div = e2.target;
1003
- div.releasePointerCapture(e2.pointerId);
1004
- }
1005
- function onDoubleClick(e2) {
1006
- table.update((state) => {
1007
- if (e2.getModifierState("Control")) {
1008
- state.columnWidths.delete(columnId);
1009
- } else {
1010
- state.columnWidths.set(columnId, "max-content");
1011
- }
1182
+ const defaultWrapCell = (content) => {
1183
+ if (typeof content === "string") {
1184
+ return /* @__PURE__ */ jsx("span", {
1185
+ css: defaultClasses.text,
1186
+ title: content,
1187
+ children: content
1012
1188
  });
1013
1189
  }
1014
- return jsx(ResizeHandleView, {
1015
- enabled,
1016
- onPointerDown: enabled ? onPointerDown : void 0,
1017
- onPointerMove: enabled ? onPointerMove : void 0,
1018
- onPointerUp: enabled ? onPointerUp : void 0,
1019
- onDoubleClick: enabled ? onDoubleClick : void 0
1020
- });
1021
- }
1022
- function ResizeHandleView(_a) {
1023
- var _b = _a, {
1024
- enabled
1025
- } = _b, props = __objRest(_b, [
1026
- "enabled"
1027
- ]);
1028
- return jsx("div", __spreadValues({
1029
- css: {
1030
- alignSelf: "stretch",
1031
- padding: "0 5px",
1032
- cursor: enabled ? "col-resize" : "initial",
1033
- display: "flex",
1034
- alignItems: "center",
1035
- "&:after": {
1036
- content: '""',
1037
- width: 1,
1038
- height: "1.5em",
1039
- background: "#c9cfda",
1040
- transition: "transform 300ms"
1041
- }
1042
- }
1043
- }, props));
1044
- }
1190
+ return content;
1191
+ };
1045
1192
  const Cell = memo(function Cell2({
1046
1193
  itemId,
1047
1194
  rowIndex
1048
1195
  }) {
1049
- var _a, _b;
1196
+ var _a;
1050
1197
  const table = useTableContext();
1051
1198
  const columnId = useColumnContext();
1052
- const {
1053
- classes
1054
- } = useTheme();
1055
- const column = table.useState((state) => state.activeColumns.find((column2) => column2.id === columnId));
1199
+ const column = table.useState((state) => {
1200
+ const col = state.activeColumns.find((column2) => column2.id === columnId);
1201
+ return col && {
1202
+ value: col.value,
1203
+ renderCell: col.renderCell
1204
+ };
1205
+ });
1206
+ const wrapCell = (_a = table.useState((state) => state.props.wrapCell)) != null ? _a : defaultWrapCell;
1056
1207
  const item = table.useState((state) => state.activeItemsById.get(itemId));
1057
1208
  const columnStyleOverride = table.useState((state) => state.columnStyleOverride.get(columnId), {
1058
1209
  throttle: 16
1059
1210
  });
1211
+ useLayoutEffect(() => {
1212
+ var _a2, _b;
1213
+ return (_b = (_a2 = table.getState().props).debugRender) == null ? void 0 : _b.call(_a2, "render cell", itemId, columnId);
1214
+ });
1215
+ const className2 = useTheme((t) => cx(...calcClassNames(t.classes, item, rowIndex)));
1060
1216
  if (!column || !item)
1061
1217
  return null;
1062
- (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render cell", itemId, columnId);
1063
- const classNames = [...calcClassNames(classes, item, rowIndex), ...calcClassNames(column == null ? void 0 : column.classes, item, rowIndex)];
1064
- const content = column.renderCell(column.value(item), item);
1065
- return jsx("div", {
1066
- className: cx(...classNames),
1067
- css: [defaultClasses.cell, classNames, columnStyleOverride],
1068
- children: typeof content === "string" ? jsx("span", {
1069
- css: defaultClasses.text,
1070
- title: content,
1071
- children: content
1072
- }) : content
1218
+ const content = column.renderCell(column.value(item.value), item.value);
1219
+ return /* @__PURE__ */ jsx("div", {
1220
+ className: className2,
1221
+ css: [defaultClasses.cell, columnStyleOverride],
1222
+ children: wrapCell(content, column.value(item.value), item.value, rowIndex)
1073
1223
  });
1074
1224
  });
1075
1225
  function ExpandControl({
1076
1226
  itemId,
1077
1227
  hasDeferredChildren
1078
1228
  }) {
1079
- const {
1080
- components: {
1081
- IconButton: IconButton2,
1082
- Spinner: Spinner2
1083
- },
1084
- icons: {
1085
- ChevronRight: ChevronRight2
1086
- }
1087
- } = useTheme();
1229
+ const IconButton2 = useTheme((t) => t.components.IconButton);
1230
+ const Spinner2 = useTheme((t) => t.components.Spinner);
1231
+ const ChevronRight2 = useTheme((t) => t.icons.ChevronRight);
1088
1232
  const table = useTableContext();
1089
1233
  const isExpanded = table.useState((state) => state.expanded.has(itemId));
1090
1234
  const hasChildren = table.useState((state) => {
@@ -1121,21 +1265,21 @@ function ExpandControl({
1121
1265
  }
1122
1266
  }
1123
1267
  if (isExpanded && hasDeferredChildren && !hasChildren) {
1124
- return jsx(Spinner2, {
1268
+ return /* @__PURE__ */ jsx(Spinner2, {
1125
1269
  css: {
1126
1270
  margin: "0 var(--spacing)"
1127
1271
  }
1128
1272
  });
1129
1273
  }
1130
- return jsx(IconButton2, {
1274
+ return /* @__PURE__ */ jsx(IconButton2, {
1131
1275
  onClick: toggle2,
1132
- children: jsx("span", {
1276
+ children: /* @__PURE__ */ jsx("span", {
1133
1277
  css: {
1134
1278
  display: "inline-flex",
1135
1279
  transition: "all 300ms",
1136
1280
  transform: isExpanded ? "rotate3d(0, 0, 1, 90deg)" : "rotate3d(0, 0, 1, 0deg)"
1137
1281
  },
1138
- children: jsx(ChevronRight2, {})
1282
+ children: /* @__PURE__ */ jsx(ChevronRight2, {})
1139
1283
  })
1140
1284
  });
1141
1285
  }
@@ -1143,11 +1287,7 @@ function SelectComponent({
1143
1287
  itemId
1144
1288
  }) {
1145
1289
  const table = useTableContext();
1146
- const {
1147
- components: {
1148
- Checkbox: Checkbox2
1149
- }
1150
- } = useTheme();
1290
+ const Checkbox2 = useTheme((t) => t.components.Checkbox);
1151
1291
  const isSelected = table.useState((state) => {
1152
1292
  const itemIds = itemId ? [itemId] : Array.from(state.activeItemsById.keys());
1153
1293
  return state.activeItemsById.size > 0 && itemIds.every((itemId2) => state.selection.has(itemId2));
@@ -1199,7 +1339,7 @@ function SelectComponent({
1199
1339
  state.lastSelectedId = itemId;
1200
1340
  });
1201
1341
  }
1202
- return jsx(Checkbox2, {
1342
+ return /* @__PURE__ */ jsx(Checkbox2, {
1203
1343
  css: {
1204
1344
  justifySelf: "start",
1205
1345
  color: "#c9cfda"
@@ -1215,9 +1355,9 @@ const Row = memo(function Row2({
1215
1355
  itemId,
1216
1356
  rowIndex
1217
1357
  }) {
1218
- var _a, _b;
1219
1358
  const table = useTableContext();
1220
1359
  const divRef = useRef(null);
1360
+ const classes = useTheme((t) => t.classes);
1221
1361
  const {
1222
1362
  className: className2,
1223
1363
  indent,
@@ -1227,17 +1367,16 @@ const Row = memo(function Row2({
1227
1367
  enableSelection,
1228
1368
  rowAction
1229
1369
  } = table.useState((state) => {
1230
- var _a2, _b2;
1370
+ var _a, _b;
1231
1371
  const item = state.activeItemsById.get(itemId);
1232
- const index = !item ? -1 : state.activeItems.indexOf(item);
1233
1372
  return {
1234
- className: cx(...calcClassNames(state.props.classes, item, index)),
1373
+ className: cx(...calcClassNames(classes, item, rowIndex)),
1235
1374
  indent: item ? getAncestors(state.activeItemsById, item).size : 0,
1236
1375
  hasChildren: !!(item == null ? void 0 : item.children.length),
1237
- hasDeferredChildren: item && ((_b2 = (_a2 = state.props).hasDeferredChildren) == null ? void 0 : _b2.call(_a2, item)),
1376
+ hasDeferredChildren: item && ((_b = (_a = state.props).hasDeferredChildren) == null ? void 0 : _b.call(_a, item.value)),
1238
1377
  columnIds: state.activeColumns.map((column) => column.id),
1239
1378
  enableSelection: state.props.enableSelection,
1240
- rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item, index) : null : state.props.rowAction
1379
+ rowAction: state.props.rowAction instanceof Function ? item ? state.props.rowAction(item.value, rowIndex) : null : state.props.rowAction
1241
1380
  };
1242
1381
  });
1243
1382
  useEffect(() => {
@@ -1254,117 +1393,40 @@ const Row = memo(function Row2({
1254
1393
  o.observe(div);
1255
1394
  return () => o.disconnect();
1256
1395
  }, [divRef.current]);
1257
- (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render row", itemId);
1258
- return jsxs(Fragment, {
1259
- children: [jsx("div", {
1396
+ useLayoutEffect(() => {
1397
+ var _a, _b;
1398
+ return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render row", itemId);
1399
+ });
1400
+ return /* @__PURE__ */ jsxs(Fragment, {
1401
+ children: [/* @__PURE__ */ jsx("div", {
1260
1402
  className: className2,
1261
1403
  css: [defaultClasses.cellFill],
1262
1404
  ref: divRef
1263
- }), jsxs("div", {
1405
+ }), /* @__PURE__ */ jsxs("div", {
1264
1406
  className: className2,
1265
1407
  css: [defaultClasses.cell, defaultClasses.firstCell],
1266
- children: [jsx("div", {
1408
+ children: [/* @__PURE__ */ jsx("div", {
1267
1409
  css: {
1268
1410
  width: indent * 20
1269
1411
  }
1270
- }), enableSelection && jsx(SelectComponent, {
1412
+ }), enableSelection && /* @__PURE__ */ jsx(SelectComponent, {
1271
1413
  itemId
1272
- }), (hasChildren || hasDeferredChildren) && jsx(ExpandControl, {
1414
+ }), (hasChildren || hasDeferredChildren) && /* @__PURE__ */ jsx(ExpandControl, {
1273
1415
  itemId,
1274
1416
  hasDeferredChildren
1275
1417
  }), rowAction]
1276
- }), columnIds.map((columnId) => jsx(ColumnContext.Provider, {
1418
+ }), columnIds.map((columnId) => /* @__PURE__ */ jsx(ColumnContext.Provider, {
1277
1419
  value: columnId,
1278
- children: jsx(Cell, {
1420
+ children: /* @__PURE__ */ jsx(Cell, {
1279
1421
  itemId,
1280
1422
  rowIndex
1281
1423
  })
1282
- }, columnId)), jsx("div", {
1424
+ }, columnId)), /* @__PURE__ */ jsx("div", {
1283
1425
  className: className2,
1284
1426
  css: [defaultClasses.cellFill]
1285
1427
  })]
1286
1428
  });
1287
1429
  });
1288
- function SortComponent({
1289
- children
1290
- }) {
1291
- const table = useTableContext();
1292
- const columnId = useColumnContext();
1293
- const {
1294
- components: {
1295
- Badge: Badge2
1296
- },
1297
- icons: {
1298
- ArrowUpward: ArrowUpward2
1299
- }
1300
- } = useTheme();
1301
- const {
1302
- direction,
1303
- index
1304
- } = table.useState((state) => {
1305
- var _a, _b;
1306
- const index2 = (_a = state.sort.findIndex((s) => s.columnId === columnId)) != null ? _a : -1;
1307
- return {
1308
- direction: (_b = state.sort[index2]) == null ? void 0 : _b.direction,
1309
- index: index2 >= 0 && state.sort.length > 1 ? index2 + 1 : void 0
1310
- };
1311
- });
1312
- function toggle2(e2, off) {
1313
- const {
1314
- props: {
1315
- sort: controlledSort,
1316
- onSortChange
1317
- }
1318
- } = table.getState();
1319
- const newDirection = direction === "asc" ? "desc" : "asc";
1320
- const newSort = e2.getModifierState("Control") || off ? table.getState().sort.filter((s) => s.columnId !== columnId) : [];
1321
- if (!off) {
1322
- newSort.push({
1323
- columnId,
1324
- direction: newDirection
1325
- });
1326
- }
1327
- onSortChange == null ? void 0 : onSortChange(newSort);
1328
- if (!controlledSort) {
1329
- table.update((state) => {
1330
- state.sort = newSort;
1331
- });
1332
- }
1333
- e2.preventDefault();
1334
- return false;
1335
- }
1336
- return jsxs("div", {
1337
- css: {
1338
- userSelect: "none",
1339
- display: "grid",
1340
- gridTemplateColumns: "minmax(0, 1fr) max-content",
1341
- alignItems: "center",
1342
- cursor: "pointer",
1343
- "& > div": {
1344
- overflow: "hidden",
1345
- textOverflow: "ellipsis"
1346
- }
1347
- },
1348
- onClick: (e2) => toggle2(e2),
1349
- onContextMenu: (e2) => toggle2(e2, true),
1350
- children: [jsx("div", {
1351
- children
1352
- }), jsx(Badge2, {
1353
- badgeContent: index,
1354
- children: jsx("span", {
1355
- css: [{
1356
- transition: "all 300ms",
1357
- fontSize: "0.8em"
1358
- }, !direction && {
1359
- opacity: 0
1360
- }, direction === "desc" && {
1361
- transform: "rotate3d(0, 0, 1, 180deg)"
1362
- }],
1363
- children: jsx(ArrowUpward2, {})
1364
- })
1365
- })]
1366
- });
1367
- }
1368
1430
  function throttle(fn, ms) {
1369
1431
  let last = 0;
1370
1432
  let lastArgs;
@@ -1391,6 +1453,11 @@ function throttle(fn, ms) {
1391
1453
  if (lastArgs) {
1392
1454
  run();
1393
1455
  }
1456
+ },
1457
+ cancel() {
1458
+ if (timeout) {
1459
+ clearTimeout(timeout);
1460
+ }
1394
1461
  }
1395
1462
  });
1396
1463
  }
@@ -1412,12 +1479,14 @@ const relativeOffset = (x, y) => {
1412
1479
  function Virtualized(_c) {
1413
1480
  var _d = _c, {
1414
1481
  header,
1482
+ footer,
1415
1483
  children
1416
1484
  } = _d, props = __objRest(_d, [
1417
1485
  "header",
1486
+ "footer",
1418
1487
  "children"
1419
1488
  ]);
1420
- var _a, _b, _c2, _d2;
1489
+ var _a, _b;
1421
1490
  const table = useTableContext();
1422
1491
  const virtual = table.useState("props.virtual");
1423
1492
  const probeRef = useRef(null);
@@ -1491,20 +1560,24 @@ function Virtualized(_c) {
1491
1560
  window.removeEventListener("resize", incCounter, true);
1492
1561
  };
1493
1562
  }, [probeRef.current, incCounter]);
1494
- (_d2 = (_c2 = table.getState().props).debugRender) == null ? void 0 : _d2.call(_c2, `Virtualalized render ${from} to ${to}`);
1495
- return jsxs("div", __spreadProps(__spreadValues({}, props), {
1496
- children: [header, virtual && jsx("div", {
1563
+ useEffect(() => incCounter.cancel, [incCounter]);
1564
+ useLayoutEffect(() => {
1565
+ var _a2, _b2;
1566
+ return (_b2 = (_a2 = table.getState().props).debugRender) == null ? void 0 : _b2.call(_a2, `Virtualalized render ${from} to ${to}`);
1567
+ });
1568
+ return /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({}, props), {
1569
+ children: [header, virtual && /* @__PURE__ */ jsx("div", {
1497
1570
  style: {
1498
1571
  gridColumn: "1 / -1",
1499
1572
  height: before
1500
1573
  },
1501
1574
  ref: probeRef
1502
- }), children(itemIds, from), virtual && jsx("div", {
1575
+ }), children(itemIds, from), virtual && /* @__PURE__ */ jsx("div", {
1503
1576
  style: {
1504
1577
  gridColumn: "1 / -1",
1505
1578
  height: after
1506
1579
  }
1507
- })]
1580
+ }), footer]
1508
1581
  }));
1509
1582
  }
1510
1583
  const TableContext = createContext(null);
@@ -1522,28 +1595,30 @@ function useColumnContext() {
1522
1595
  return value;
1523
1596
  }
1524
1597
  function Table(props) {
1525
- var _a, _b;
1526
1598
  const table = useTableState(props);
1527
- (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table");
1528
- return jsx(TableContext.Provider, {
1599
+ useLayoutEffect(() => {
1600
+ var _a, _b;
1601
+ return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table");
1602
+ });
1603
+ return /* @__PURE__ */ jsx(TableContext.Provider, {
1529
1604
  value: table,
1530
- children: jsx(TableLoadingState, {})
1605
+ children: /* @__PURE__ */ jsx(TableMemoContextProvider, {
1606
+ children: /* @__PURE__ */ jsx(TableLoadingState, {})
1607
+ })
1531
1608
  });
1532
1609
  }
1533
1610
  function TableLoadingState() {
1534
- const {
1535
- text
1536
- } = useTheme();
1611
+ const loadingText = useTheme((t) => t.text.loading);
1537
1612
  const isHydrated = useTableStateStorage();
1538
1613
  const [showLoading, setShowLoading] = useState(false);
1539
1614
  useEffect(() => {
1540
1615
  const handle = setTimeout(() => setShowLoading(true), 500);
1541
1616
  return () => clearTimeout(handle);
1542
1617
  });
1543
- return jsxs(Fragment, {
1544
- children: [!isHydrated && showLoading && jsx("div", {
1545
- children: text.loading
1546
- }), jsx(TableInner, {
1618
+ return /* @__PURE__ */ jsxs(Fragment, {
1619
+ children: [!isHydrated && showLoading && /* @__PURE__ */ jsx("div", {
1620
+ children: loadingText
1621
+ }), /* @__PURE__ */ jsx(TableInner, {
1547
1622
  hidden: !isHydrated
1548
1623
  })]
1549
1624
  });
@@ -1551,76 +1626,77 @@ function TableLoadingState() {
1551
1626
  const TableInner = memo(function TableInner2({
1552
1627
  hidden
1553
1628
  }) {
1554
- var _a, _b;
1555
1629
  const table = useTableContext();
1556
1630
  const fullWidth = table.useState("props.fullWidth");
1557
1631
  const activeColumns = table.useState((state) => state.activeColumns.map((column) => ({
1558
1632
  id: column.id,
1559
1633
  width: column.width,
1560
- classes: column.classes,
1561
- header: column.header
1634
+ classes: column.classes
1562
1635
  })));
1563
1636
  const columnWidths = table.useState("columnWidths", {
1564
1637
  throttle: 16
1565
1638
  });
1566
- const columnStyleOverride = table.useState("columnStyleOverride", {
1567
- throttle: 16
1568
- });
1569
- const defaultWidth = table.useState("props.defaultWidth");
1570
- const classes = table.useState("props.classes");
1639
+ const hasFooter = table.useState((state) => state.activeColumns.some((column) => column.footer));
1640
+ const classes = useTheme((theme) => theme.classes);
1571
1641
  const stickyHeader = table.useState("props.stickyHeader");
1642
+ const stickyFooter = table.useState("props.stickyFooter");
1572
1643
  const enableSelection = table.useState("props.enableSelection");
1573
1644
  const enableColumnSelection = table.useState("props.enableColumnSelection");
1574
1645
  const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
1575
1646
  const cssVariables = useCssVariables();
1576
- (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
1577
- return jsx(Virtualized, {
1647
+ useLayoutEffect(() => {
1648
+ var _a, _b;
1649
+ return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
1650
+ });
1651
+ return /* @__PURE__ */ jsx(Virtualized, {
1578
1652
  className: classes == null ? void 0 : classes.table,
1579
1653
  css: [cssVariables, defaultClasses.table, {
1580
1654
  gridTemplateColumns: [
1581
1655
  fullWidth === "right" || fullWidth === true ? "auto" : "0",
1582
1656
  "max-content",
1583
1657
  ...activeColumns.map((column) => {
1584
- var _a2, _b2, _c;
1585
- return (_c = (_b2 = (_a2 = columnWidths.get(column.id)) != null ? _a2 : column.width) != null ? _b2 : defaultWidth) != null ? _c : "max-content";
1658
+ var _a, _b;
1659
+ return (_b = (_a = columnWidths.get(column.id)) != null ? _a : column.width) != null ? _b : "max-content";
1586
1660
  }),
1587
1661
  fullWidth === "left" || fullWidth === true ? "auto" : "0"
1588
1662
  ].join(" ")
1589
1663
  }, hidden && {
1590
1664
  visibility: "hidden"
1591
1665
  }],
1592
- header: jsxs(Fragment, {
1593
- children: [jsx("div", {
1666
+ header: /* @__PURE__ */ jsxs(Fragment, {
1667
+ children: [/* @__PURE__ */ jsx("div", {
1594
1668
  className: classes == null ? void 0 : classes.headerCell,
1595
1669
  css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
1596
- }), jsxs("div", {
1670
+ }), /* @__PURE__ */ jsxs("div", {
1597
1671
  className: classes == null ? void 0 : classes.headerCell,
1598
1672
  css: [defaultClasses.headerCell, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
1599
- children: [enableSelection && jsx(SelectComponent, {}), enableColumnSelection && jsx(ColumnSelection, {}), enableExport && jsx(Export$1, {}), jsx(ResizeHandleView, {})]
1600
- }), jsx(ColumnHeaderContext.Provider, {
1601
- children: activeColumns.map((column) => {
1602
- var _a2;
1603
- return jsx(ColumnContext.Provider, {
1604
- value: column.id,
1605
- children: jsxs(ColumnHeader, {
1606
- className: cx(classes == null ? void 0 : classes.headerCell, (_a2 = column.classes) == null ? void 0 : _a2.headerCell),
1607
- css: [defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
1608
- children: [jsx(SortComponent, {
1609
- children: column.header
1610
- }), jsx("div", {
1611
- css: {
1612
- flex: 1
1613
- }
1614
- }), jsx(FilterControl, {}), jsx(ResizeHandle, {})]
1615
- }, column.id)
1616
- }, column.id);
1617
- })
1618
- }), jsx("div", {
1673
+ children: [enableSelection && /* @__PURE__ */ jsx(SelectComponent, {}), enableColumnSelection && /* @__PURE__ */ jsx(ColumnSelection, {}), enableExport && /* @__PURE__ */ jsx(Export$1, {}), /* @__PURE__ */ jsx(ResizeHandleView, {})]
1674
+ }), /* @__PURE__ */ jsx(ColumnHeaderContext.Provider, {
1675
+ children: activeColumns.map((column) => /* @__PURE__ */ jsx(ColumnContext.Provider, {
1676
+ value: column.id,
1677
+ children: /* @__PURE__ */ jsx(ColumnHeader, {})
1678
+ }, column.id))
1679
+ }), /* @__PURE__ */ jsx("div", {
1619
1680
  className: classes == null ? void 0 : classes.headerCell,
1620
1681
  css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
1621
1682
  })]
1622
1683
  }),
1623
- children: (itemIds, startIndex) => itemIds.map((itemId, index) => jsx(Row, {
1684
+ footer: hasFooter && /* @__PURE__ */ jsxs(Fragment, {
1685
+ children: [/* @__PURE__ */ jsx("div", {
1686
+ className: classes == null ? void 0 : classes.footerCell,
1687
+ css: [defaultClasses.footerFill, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
1688
+ }), /* @__PURE__ */ jsx("div", {
1689
+ className: classes == null ? void 0 : classes.footerCell,
1690
+ css: [defaultClasses.footerFill, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
1691
+ }), activeColumns.map((column) => /* @__PURE__ */ jsx(ColumnContext.Provider, {
1692
+ value: column.id,
1693
+ children: /* @__PURE__ */ jsx(ColumnFooter, {})
1694
+ }, column.id)), /* @__PURE__ */ jsx("div", {
1695
+ className: classes == null ? void 0 : classes.footerCell,
1696
+ css: [defaultClasses.footerFill, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
1697
+ })]
1698
+ }),
1699
+ children: (itemIds, startIndex) => itemIds.map((itemId, index) => /* @__PURE__ */ jsx(Row, {
1624
1700
  itemId,
1625
1701
  rowIndex: startIndex + index
1626
1702
  }, itemId))
@@ -1633,7 +1709,7 @@ const defaultColors = {
1633
1709
  function Spinner({
1634
1710
  className: className2
1635
1711
  }) {
1636
- return jsxs("div", {
1712
+ return /* @__PURE__ */ jsxs("div", {
1637
1713
  className: className2,
1638
1714
  css: css`
1639
1715
  display: inline-block;
@@ -1671,7 +1747,7 @@ function Spinner({
1671
1747
  }
1672
1748
  }
1673
1749
  `,
1674
- children: [jsx("div", {}), jsx("div", {}), jsx("div", {})]
1750
+ children: [/* @__PURE__ */ jsx("div", {}), /* @__PURE__ */ jsx("div", {}), /* @__PURE__ */ jsx("div", {})]
1675
1751
  });
1676
1752
  }
1677
1753
  const Badge = ({
@@ -1680,14 +1756,14 @@ const Badge = ({
1680
1756
  }) => {
1681
1757
  if (!open)
1682
1758
  return null;
1683
- return jsxs("span", {
1759
+ return /* @__PURE__ */ jsxs("span", {
1684
1760
  css: {
1685
1761
  display: "inline-flex",
1686
1762
  position: "relative",
1687
1763
  flexShrink: 0,
1688
1764
  verticalAlign: "middle"
1689
1765
  },
1690
- children: [children, jsx("span", {
1766
+ children: [children, /* @__PURE__ */ jsx("span", {
1691
1767
  css: [{
1692
1768
  top: 0,
1693
1769
  right: 0,
@@ -1725,7 +1801,7 @@ const Button = (_e) => {
1725
1801
  "children",
1726
1802
  "variant"
1727
1803
  ]);
1728
- return jsxs("button", __spreadProps(__spreadValues({
1804
+ return /* @__PURE__ */ jsxs("button", __spreadProps(__spreadValues({
1729
1805
  css: [{
1730
1806
  padding: `var(--spacing) calc(var(--spacing) * 2)`,
1731
1807
  display: "inline-flex",
@@ -1760,12 +1836,12 @@ const Button = (_e) => {
1760
1836
  }
1761
1837
  }]
1762
1838
  }, props), {
1763
- children: [startIcon && jsx("span", {
1839
+ children: [startIcon && /* @__PURE__ */ jsx("span", {
1764
1840
  css: {
1765
1841
  marginRight: `calc(var(--spacing) * 2)`
1766
1842
  },
1767
1843
  children: startIcon
1768
- }), jsx("span", {
1844
+ }), /* @__PURE__ */ jsx("span", {
1769
1845
  children
1770
1846
  })]
1771
1847
  }));
@@ -1776,7 +1852,7 @@ const Checkbox = (_g) => {
1776
1852
  } = _h, props = __objRest(_h, [
1777
1853
  "className"
1778
1854
  ]);
1779
- return jsxs("label", {
1855
+ return /* @__PURE__ */ jsxs("label", {
1780
1856
  css: [{
1781
1857
  padding: "calc(var(--spacing) * 1.8)",
1782
1858
  display: "flex",
@@ -1790,9 +1866,9 @@ const Checkbox = (_g) => {
1790
1866
  color: "rgba(0, 0, 0, 0.26)"
1791
1867
  }],
1792
1868
  className: className2,
1793
- children: [jsx("input", __spreadValues({
1869
+ children: [/* @__PURE__ */ jsx("input", __spreadValues({
1794
1870
  type: "checkbox"
1795
- }, props)), props.checked ? jsx("svg", {
1871
+ }, props)), props.checked ? /* @__PURE__ */ jsx("svg", {
1796
1872
  css: {
1797
1873
  fontSize: "1.25rem",
1798
1874
  width: "1em",
@@ -1802,10 +1878,10 @@ const Checkbox = (_g) => {
1802
1878
  focusable: "false",
1803
1879
  viewBox: "0 0 24 24",
1804
1880
  "aria-hidden": "true",
1805
- children: jsx("path", {
1881
+ children: /* @__PURE__ */ jsx("path", {
1806
1882
  d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
1807
1883
  })
1808
- }) : jsx("svg", {
1884
+ }) : /* @__PURE__ */ jsx("svg", {
1809
1885
  css: {
1810
1886
  fontSize: "1.25rem",
1811
1887
  width: "1em",
@@ -1815,14 +1891,14 @@ const Checkbox = (_g) => {
1815
1891
  focusable: "false",
1816
1892
  viewBox: "0 0 24 24",
1817
1893
  "aria-hidden": "true",
1818
- children: jsx("path", {
1894
+ children: /* @__PURE__ */ jsx("path", {
1819
1895
  d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
1820
1896
  })
1821
1897
  })]
1822
1898
  });
1823
1899
  };
1824
1900
  const IconButton = (props) => {
1825
- return jsx("button", __spreadValues({
1901
+ return /* @__PURE__ */ jsx("button", __spreadValues({
1826
1902
  css: {
1827
1903
  padding: "var(--spacing)",
1828
1904
  borderRadius: "50%",
@@ -1855,12 +1931,12 @@ const TextField = (_i) => {
1855
1931
  ]);
1856
1932
  var _a;
1857
1933
  const [focus, setFocus] = useState(false);
1858
- return jsx("div", {
1934
+ return /* @__PURE__ */ jsx("div", {
1859
1935
  className: className2,
1860
1936
  css: {
1861
1937
  display: "flex"
1862
1938
  },
1863
- children: jsxs("span", {
1939
+ children: /* @__PURE__ */ jsxs("span", {
1864
1940
  css: [{
1865
1941
  flex: 1,
1866
1942
  display: "flex",
@@ -1871,7 +1947,7 @@ const TextField = (_i) => {
1871
1947
  border: "2px solid var(--primaryMain)",
1872
1948
  margin: -1
1873
1949
  }],
1874
- children: [jsx("input", __spreadProps(__spreadValues({
1950
+ children: [/* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({
1875
1951
  ref: inputRef
1876
1952
  }, props), {
1877
1953
  value: (_a = props.value) != null ? _a : "",
@@ -1905,7 +1981,7 @@ const IconDefaultStyle = css({
1905
1981
  color: "inherit"
1906
1982
  });
1907
1983
  function Icon(svg) {
1908
- return (props) => jsx(ClassNames, {
1984
+ return (props) => /* @__PURE__ */ jsx(ClassNames, {
1909
1985
  children: ({
1910
1986
  css: css2
1911
1987
  }) => cloneElement(svg, __spreadProps(__spreadValues({}, props), {
@@ -1913,120 +1989,120 @@ function Icon(svg) {
1913
1989
  }))
1914
1990
  });
1915
1991
  }
1916
- const Settings = Icon(jsxs("svg", {
1992
+ const Settings = Icon(/* @__PURE__ */ jsxs("svg", {
1917
1993
  xmlns: "http://www.w3.org/2000/svg",
1918
1994
  height: "24px",
1919
1995
  viewBox: "0 0 24 24",
1920
1996
  width: "24px",
1921
1997
  fill: "currentColor",
1922
- children: [jsx("path", {
1998
+ children: [/* @__PURE__ */ jsx("path", {
1923
1999
  d: "M0 0h24v24H0V0z",
1924
2000
  fill: "none"
1925
- }), jsx("path", {
2001
+ }), /* @__PURE__ */ jsx("path", {
1926
2002
  d: "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"
1927
2003
  })]
1928
2004
  }));
1929
- const Export = Icon(jsxs("svg", {
2005
+ const Export = Icon(/* @__PURE__ */ jsxs("svg", {
1930
2006
  xmlns: "http://www.w3.org/2000/svg",
1931
2007
  enableBackground: "new 0 0 24 24",
1932
2008
  height: "24px",
1933
2009
  viewBox: "0 0 24 24",
1934
2010
  width: "24px",
1935
2011
  fill: "currentColor",
1936
- children: [jsx("g", {
1937
- children: jsx("rect", {
2012
+ children: [/* @__PURE__ */ jsx("g", {
2013
+ children: /* @__PURE__ */ jsx("rect", {
1938
2014
  fill: "none",
1939
2015
  height: "24",
1940
2016
  width: "24"
1941
2017
  })
1942
- }), jsx("g", {
1943
- children: jsx("path", {
2018
+ }), /* @__PURE__ */ jsx("g", {
2019
+ children: /* @__PURE__ */ jsx("path", {
1944
2020
  d: "M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"
1945
2021
  })
1946
2022
  })]
1947
2023
  }));
1948
- const Clipboard = Icon(jsxs("svg", {
2024
+ const Clipboard = Icon(/* @__PURE__ */ jsxs("svg", {
1949
2025
  xmlns: "http://www.w3.org/2000/svg",
1950
2026
  height: "24px",
1951
2027
  viewBox: "0 0 24 24",
1952
2028
  width: "24px",
1953
2029
  fill: "currentColor",
1954
- children: [jsx("path", {
2030
+ children: [/* @__PURE__ */ jsx("path", {
1955
2031
  d: "M0 0h24v24H0V0z",
1956
2032
  fill: "none"
1957
- }), jsx("path", {
2033
+ }), /* @__PURE__ */ jsx("path", {
1958
2034
  d: "M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"
1959
2035
  })]
1960
2036
  }));
1961
- const ChevronRight = Icon(jsxs("svg", {
2037
+ const ChevronRight = Icon(/* @__PURE__ */ jsxs("svg", {
1962
2038
  xmlns: "http://www.w3.org/2000/svg",
1963
2039
  height: "24px",
1964
2040
  viewBox: "0 0 24 24",
1965
2041
  width: "24px",
1966
2042
  fill: "currentColor",
1967
- children: [jsx("path", {
2043
+ children: [/* @__PURE__ */ jsx("path", {
1968
2044
  d: "M0 0h24v24H0V0z",
1969
2045
  fill: "none"
1970
- }), jsx("path", {
2046
+ }), /* @__PURE__ */ jsx("path", {
1971
2047
  d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"
1972
2048
  })]
1973
2049
  }));
1974
- const Search = Icon(jsxs("svg", {
2050
+ const Search = Icon(/* @__PURE__ */ jsxs("svg", {
1975
2051
  xmlns: "http://www.w3.org/2000/svg",
1976
2052
  height: "24px",
1977
2053
  viewBox: "0 0 24 24",
1978
2054
  width: "24px",
1979
2055
  fill: "currentColor",
1980
- children: [jsx("path", {
2056
+ children: [/* @__PURE__ */ jsx("path", {
1981
2057
  d: "M0 0h24v24H0V0z",
1982
2058
  fill: "none"
1983
- }), jsx("path", {
2059
+ }), /* @__PURE__ */ jsx("path", {
1984
2060
  d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
1985
2061
  })]
1986
2062
  }));
1987
- const Clear = Icon(jsxs("svg", {
2063
+ const Clear = Icon(/* @__PURE__ */ jsxs("svg", {
1988
2064
  xmlns: "http://www.w3.org/2000/svg",
1989
2065
  height: "24px",
1990
2066
  viewBox: "0 0 24 24",
1991
2067
  width: "24px",
1992
2068
  fill: "currentColor",
1993
- children: [jsx("path", {
2069
+ children: [/* @__PURE__ */ jsx("path", {
1994
2070
  d: "M0 0h24v24H0V0z",
1995
2071
  fill: "none"
1996
- }), jsx("path", {
2072
+ }), /* @__PURE__ */ jsx("path", {
1997
2073
  d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
1998
2074
  })]
1999
2075
  }));
2000
- const ArrowDropDown = Icon(jsxs("svg", {
2076
+ const ArrowDropDown = Icon(/* @__PURE__ */ jsxs("svg", {
2001
2077
  xmlns: "http://www.w3.org/2000/svg",
2002
2078
  height: "24px",
2003
2079
  viewBox: "0 0 24 24",
2004
2080
  width: "24px",
2005
2081
  fill: "currentColor",
2006
- children: [jsx("path", {
2082
+ children: [/* @__PURE__ */ jsx("path", {
2007
2083
  d: "M0 0h24v24H0V0z",
2008
2084
  fill: "none"
2009
- }), jsx("path", {
2085
+ }), /* @__PURE__ */ jsx("path", {
2010
2086
  d: "M7 10l5 5 5-5H7z"
2011
2087
  })]
2012
2088
  }));
2013
- const FilterList = Icon(jsx("svg", {
2089
+ const FilterList = Icon(/* @__PURE__ */ jsx("svg", {
2014
2090
  viewBox: "0 0 24 24",
2015
- children: jsx("path", {
2091
+ children: /* @__PURE__ */ jsx("path", {
2016
2092
  fill: "currentColor",
2017
2093
  d: "M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z"
2018
2094
  })
2019
2095
  }));
2020
- const ArrowUpward = Icon(jsxs("svg", {
2096
+ const ArrowUpward = Icon(/* @__PURE__ */ jsxs("svg", {
2021
2097
  xmlns: "http://www.w3.org/2000/svg",
2022
2098
  height: "24px",
2023
2099
  viewBox: "0 0 24 24",
2024
2100
  width: "24px",
2025
2101
  fill: "currentColor",
2026
- children: [jsx("path", {
2102
+ children: [/* @__PURE__ */ jsx("path", {
2027
2103
  d: "M0 0h24v24H0V0z",
2028
2104
  fill: "none"
2029
- }), jsx("path", {
2105
+ }), /* @__PURE__ */ jsx("path", {
2030
2106
  d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"
2031
2107
  })]
2032
2108
  }));
@@ -2061,26 +2137,45 @@ const defaultTableTheme = {
2061
2137
  spacing: "5px"
2062
2138
  };
2063
2139
  const emptyStore = new Store(void 0);
2064
- function useTheme() {
2140
+ function useTheme(selector) {
2065
2141
  var _a, _b;
2066
- const table = useContext(TableContext);
2067
- const localTheme = (_b = (_a = table == null ? void 0 : table.useState((state) => ({
2068
- text: state.props.text,
2069
- classes: state.props.classes,
2070
- components: state.props.components,
2071
- icons: state.props.icons,
2072
- colors: state.props.colors,
2073
- spacing: state.props.spacing
2074
- }))) != null ? _a : emptyStore.useState()) != null ? _b : {};
2075
2142
  const contextTableTheme = useContext(TableThemeContext);
2076
- return mergeThemes(defaultTableTheme, globalTableTheme, contextTableTheme, localTheme);
2143
+ const table = useContext(TableContext);
2144
+ const columnId = useContext(ColumnContext);
2145
+ const memo2 = useTableMemo();
2146
+ const process = (t) => {
2147
+ var _a2;
2148
+ const cell = (_a2 = t.classes) == null ? void 0 : _a2.cell;
2149
+ const selected = t.text.selected;
2150
+ return __spreadProps(__spreadValues({}, t), {
2151
+ classes: __spreadProps(__spreadValues({}, t.classes), {
2152
+ cell: cell instanceof Function || Array.isArray(cell) ? memo2("theme.classes.cell", cell) : cell
2153
+ }),
2154
+ text: __spreadProps(__spreadValues({}, t.text), {
2155
+ selected: selected instanceof Function || Array.isArray(selected) ? memo2("theme.text.selected", selected) : selected
2156
+ })
2157
+ });
2158
+ };
2159
+ const theme = (_b = (_a = table == null ? void 0 : table.useState((state) => {
2160
+ const localTheme = {
2161
+ text: state.props.text,
2162
+ classes: state.props.classes,
2163
+ components: state.props.components,
2164
+ icons: state.props.icons,
2165
+ colors: state.props.colors,
2166
+ spacing: state.props.spacing
2167
+ };
2168
+ const column = state.activeColumns.find((column2) => column2.id === columnId);
2169
+ const columnsTheme = {
2170
+ classes: column == null ? void 0 : column.classes
2171
+ };
2172
+ const theme2 = mergeThemes(defaultTableTheme, globalTableTheme, contextTableTheme, localTheme, columnsTheme);
2173
+ return selector(process(theme2));
2174
+ })) != null ? _a : emptyStore.useState()) != null ? _b : selector(process(mergeThemes(defaultTableTheme, globalTableTheme, contextTableTheme)));
2175
+ return theme;
2077
2176
  }
2078
2177
  function AutoFocusTextField(props) {
2079
- const {
2080
- components: {
2081
- TextField: TextField2
2082
- }
2083
- } = useTheme();
2178
+ const TextField2 = useTheme((t) => t.components.TextField);
2084
2179
  const ref = useRef(null);
2085
2180
  const {
2086
2181
  visible
@@ -2090,7 +2185,7 @@ function AutoFocusTextField(props) {
2090
2185
  ref.current.focus();
2091
2186
  }
2092
2187
  }, [visible]);
2093
- return jsx(TextField2, __spreadProps(__spreadValues({}, props), {
2188
+ return /* @__PURE__ */ jsx(TextField2, __spreadProps(__spreadValues({}, props), {
2094
2189
  inputRef: ref
2095
2190
  }));
2096
2191
  }
@@ -2148,7 +2243,7 @@ function DateInput({
2148
2243
  }), [locale]);
2149
2244
  const parts = format.formatToParts(value != null ? value : defaultDate);
2150
2245
  const isEmpty = !value;
2151
- return jsx("div", {
2246
+ return /* @__PURE__ */ jsx("div", {
2152
2247
  css: {
2153
2248
  display: "flex",
2154
2249
  alignItems: "baseline"
@@ -2156,8 +2251,8 @@ function DateInput({
2156
2251
  children: parts.map(({
2157
2252
  type,
2158
2253
  value: value2
2159
- }, index) => jsx(Fragment$1, {
2160
- children: isIncludedType(type) ? jsx("input", {
2254
+ }, index) => /* @__PURE__ */ jsx(Fragment$1, {
2255
+ children: isIncludedType(type) ? /* @__PURE__ */ jsx("input", {
2161
2256
  className,
2162
2257
  css: {
2163
2258
  width: `${length(type, value2)}ch`,
@@ -2184,7 +2279,7 @@ function DateInput({
2184
2279
  },
2185
2280
  onFocus: (e2) => e2.target.select(),
2186
2281
  onBlur: commit
2187
- }) : type === "literal" ? jsx("span", {
2282
+ }) : type === "literal" ? /* @__PURE__ */ jsx("span", {
2188
2283
  children: value2
2189
2284
  }) : null
2190
2285
  }, index))
@@ -2240,16 +2335,12 @@ function DatePicker({
2240
2335
  locale,
2241
2336
  firstDayOfWeek = 0
2242
2337
  }) {
2243
- const {
2244
- components: {
2245
- Button: Button2,
2246
- IconButton: IconButton2
2247
- },
2248
- icons: {
2249
- ChevronRight: ChevronRight2
2250
- },
2251
- text
2252
- } = useTheme();
2338
+ const Button2 = useTheme((t) => t.components.Button);
2339
+ const IconButton2 = useTheme((t) => t.components.IconButton);
2340
+ const ChevronRight2 = useTheme((t) => t.icons.ChevronRight);
2341
+ const textToday = useTheme((t) => t.text.today);
2342
+ const textThisWeek = useTheme((t) => t.text.thisWeek);
2343
+ const textReset = useTheme((t) => t.text.reset);
2253
2344
  const [baseDate] = useState(new Date());
2254
2345
  const [dateInView, setDateInView] = useState(baseDate);
2255
2346
  const [dirty, setDirty] = useState();
@@ -2326,8 +2417,8 @@ function DatePicker({
2326
2417
  });
2327
2418
  return (year) => format(new Date(year, 0, 1));
2328
2419
  }, [locale]);
2329
- return jsxs("div", {
2330
- children: [jsxs("div", {
2420
+ return /* @__PURE__ */ jsxs("div", {
2421
+ children: [/* @__PURE__ */ jsxs("div", {
2331
2422
  css: {
2332
2423
  display: "grid",
2333
2424
  gridAutoFlow: "column",
@@ -2335,12 +2426,12 @@ function DatePicker({
2335
2426
  alignItems: "baseline",
2336
2427
  gap: "var(--spacing)"
2337
2428
  },
2338
- children: [jsx(DateInput, {
2429
+ children: [/* @__PURE__ */ jsx(DateInput, {
2339
2430
  value: min != null ? min : null,
2340
2431
  onChange: (date) => set(date != null ? date : void 0, max, "min"),
2341
2432
  locale
2342
- }), rangeSelect && jsxs(Fragment, {
2343
- children: [" - ", jsx(DateInput, {
2433
+ }), rangeSelect && /* @__PURE__ */ jsxs(Fragment, {
2434
+ children: [" - ", /* @__PURE__ */ jsx(DateInput, {
2344
2435
  value: max != null ? max : null,
2345
2436
  onChange: (date) => set(min, date != null ? date : void 0, "max"),
2346
2437
  locale
@@ -2350,11 +2441,11 @@ function DatePicker({
2350
2441
  month,
2351
2442
  year,
2352
2443
  weeks
2353
- }) => jsxs("div", {
2444
+ }) => /* @__PURE__ */ jsxs("div", {
2354
2445
  css: {
2355
2446
  display: "grid"
2356
2447
  },
2357
- children: [jsxs("div", {
2448
+ children: [/* @__PURE__ */ jsxs("div", {
2358
2449
  css: {
2359
2450
  margin: "calc(var(--spacing) * 4) 0",
2360
2451
  display: "grid",
@@ -2362,32 +2453,32 @@ function DatePicker({
2362
2453
  justifyContent: "space-between",
2363
2454
  alignItems: "center"
2364
2455
  },
2365
- children: [jsx(IconButton2, __spreadProps(__spreadValues({}, getBackProps({
2456
+ children: [/* @__PURE__ */ jsx(IconButton2, __spreadProps(__spreadValues({}, getBackProps({
2366
2457
  calendars
2367
2458
  })), {
2368
- children: jsx(ChevronRight2, {
2459
+ children: /* @__PURE__ */ jsx(ChevronRight2, {
2369
2460
  css: {
2370
2461
  transform: "rotate3d(0, 0, 1, 180deg)"
2371
2462
  }
2372
2463
  })
2373
- })), jsxs("div", {
2464
+ })), /* @__PURE__ */ jsxs("div", {
2374
2465
  css: {
2375
2466
  display: "flex"
2376
2467
  },
2377
2468
  children: [formatMonth(month), " ", formatYear(year)]
2378
- }), jsx(IconButton2, __spreadProps(__spreadValues({}, getForwardProps({
2469
+ }), /* @__PURE__ */ jsx(IconButton2, __spreadProps(__spreadValues({}, getForwardProps({
2379
2470
  calendars
2380
2471
  })), {
2381
- children: jsx(ChevronRight2, {})
2472
+ children: /* @__PURE__ */ jsx(ChevronRight2, {})
2382
2473
  }))]
2383
- }), jsxs("div", {
2474
+ }), /* @__PURE__ */ jsxs("div", {
2384
2475
  css: {
2385
2476
  justifySelf: "center",
2386
2477
  display: "grid",
2387
2478
  gridTemplateColumns: "repeat(7, max-content)",
2388
2479
  fontWeight: "bold"
2389
2480
  },
2390
- children: [weekDays.map((_v, weekDay) => jsx("div", {
2481
+ children: [weekDays.map((_v, weekDay) => /* @__PURE__ */ jsx("div", {
2391
2482
  css: {
2392
2483
  justifySelf: "center",
2393
2484
  marginBottom: "var(--spacing)"
@@ -2395,7 +2486,7 @@ function DatePicker({
2395
2486
  children: formatWeekday(weekDay)
2396
2487
  }, weekDay)), weeks.map((week, index) => week.map((dateObj, dayIndex) => {
2397
2488
  if (!dateObj) {
2398
- return jsx("div", {});
2489
+ return /* @__PURE__ */ jsx("div", {});
2399
2490
  }
2400
2491
  const {
2401
2492
  prevMonth,
@@ -2414,7 +2505,7 @@ function DatePicker({
2414
2505
  min: hovered,
2415
2506
  max: min
2416
2507
  }));
2417
- return jsx("button", __spreadProps(__spreadValues({
2508
+ return /* @__PURE__ */ jsx("button", __spreadProps(__spreadValues({
2418
2509
  css: [{
2419
2510
  padding: 10,
2420
2511
  border: "1px solid transparent",
@@ -2450,34 +2541,34 @@ function DatePicker({
2450
2541
  }), `${index}-${dayIndex}`);
2451
2542
  }))]
2452
2543
  })]
2453
- }, `${month}${year}`)), jsxs("div", {
2544
+ }, `${month}${year}`)), /* @__PURE__ */ jsxs("div", {
2454
2545
  css: {
2455
2546
  marginTop: "var(--spacing)",
2456
2547
  display: "grid",
2457
2548
  gridAutoFlow: "column",
2458
2549
  justifyContent: "center"
2459
2550
  },
2460
- children: [jsx(Button2, {
2551
+ children: [/* @__PURE__ */ jsx(Button2, {
2461
2552
  variant: "text",
2462
2553
  onClick: () => {
2463
2554
  setDirty(void 0);
2464
2555
  onChange(today());
2465
2556
  },
2466
- children: text.today
2467
- }), jsx(Button2, {
2557
+ children: textToday
2558
+ }), /* @__PURE__ */ jsx(Button2, {
2468
2559
  variant: "text",
2469
2560
  onClick: () => {
2470
2561
  setDirty(void 0);
2471
2562
  onChange(thisWeek(firstDayOfWeek));
2472
2563
  },
2473
- children: text.thisWeek
2474
- }), jsx(Button2, {
2564
+ children: textThisWeek
2565
+ }), /* @__PURE__ */ jsx(Button2, {
2475
2566
  variant: "text",
2476
2567
  onClick: () => {
2477
2568
  setDirty(void 0);
2478
2569
  onChange(null);
2479
2570
  },
2480
- children: text.reset
2571
+ children: textReset
2481
2572
  })]
2482
2573
  })]
2483
2574
  });
@@ -2529,12 +2620,12 @@ function DateFilter(_k) {
2529
2620
  return dateIntersect(filterValue, value2);
2530
2621
  }
2531
2622
  }));
2532
- return jsx("div", {
2623
+ return /* @__PURE__ */ jsx("div", {
2533
2624
  css: {
2534
2625
  padding: "calc(var(--spacing) * 2)",
2535
2626
  display: "grid"
2536
2627
  },
2537
- children: jsx(DatePicker, {
2628
+ children: /* @__PURE__ */ jsx(DatePicker, {
2538
2629
  rangeSelect: !singleSelect,
2539
2630
  value,
2540
2631
  onChange,
@@ -2564,34 +2655,18 @@ function SelectFilter(_m) {
2564
2655
  "render",
2565
2656
  "singleSelect"
2566
2657
  ]);
2567
- const {
2568
- components: {
2569
- IconButton: IconButton2,
2570
- Checkbox: Checkbox2
2571
- },
2572
- icons: {
2573
- Search: Search2,
2574
- Clear: Clear2
2575
- },
2576
- text
2577
- } = useTheme();
2658
+ const IconButton2 = useTheme((t) => t.components.IconButton);
2659
+ const Checkbox2 = useTheme((t) => t.components.Checkbox);
2660
+ const Search2 = useTheme((t) => t.icons.Search);
2661
+ const Clear2 = useTheme((t) => t.icons.Clear);
2662
+ const selected = useTheme((t) => t.text.selected);
2663
+ const noResults = useTheme((t) => t.text.noResults);
2578
2664
  const table = useTableContext();
2579
2665
  const columnId = useColumnContext();
2580
- const options = table.useState((state) => {
2581
- var _a;
2582
- if (providedOptions)
2583
- return uniq(providedOptions);
2584
- const column = state.activeColumns.find((column2) => column2.id === columnId);
2585
- if (!column)
2586
- return [];
2587
- const filterBy = (_a = props.filterBy) != null ? _a : (x) => x;
2588
- return uniq(flatMap(state.items, (item) => castArray(filterBy(column.value(item), item))));
2589
- });
2590
- const [query, setQuery] = useState("");
2591
- const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));
2592
2666
  const {
2593
2667
  value = /* @__PURE__ */ new Set(),
2594
- onChange
2668
+ onChange,
2669
+ filterBy
2595
2670
  } = useFilter(__spreadProps(__spreadValues({}, props), {
2596
2671
  id: "selectFilter",
2597
2672
  isActive(filterValue) {
@@ -2601,49 +2676,59 @@ function SelectFilter(_m) {
2601
2676
  return filterValue.has(value2);
2602
2677
  }
2603
2678
  }));
2604
- return jsxs("div", {
2679
+ const options = table.useState((state) => {
2680
+ if (providedOptions)
2681
+ return uniq(providedOptions);
2682
+ const column = state.activeColumns.find((column2) => column2.id === columnId);
2683
+ if (!column)
2684
+ return [];
2685
+ return uniq(flatMap(state.items, (item) => castArray(filterBy(column.value(item.value), item.value))));
2686
+ });
2687
+ const [query, setQuery] = useState("");
2688
+ const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));
2689
+ return /* @__PURE__ */ jsxs("div", {
2605
2690
  css: {
2606
2691
  padding: "calc(var(--spacing) * 2)",
2607
2692
  display: "grid",
2608
2693
  gap: "var(--spacing)"
2609
2694
  },
2610
- children: [jsx(AutoFocusTextField, {
2695
+ children: [/* @__PURE__ */ jsx(AutoFocusTextField, {
2611
2696
  value: query,
2612
2697
  onChange: (e2) => setQuery(e2.target.value),
2613
- endIcon: jsx(IconButton2, {
2698
+ endIcon: /* @__PURE__ */ jsx(IconButton2, {
2614
2699
  onClick: () => setQuery(""),
2615
- children: !query ? jsx(Search2, {}) : jsx(Clear2, {})
2700
+ children: !query ? /* @__PURE__ */ jsx(Search2, {}) : /* @__PURE__ */ jsx(Clear2, {})
2616
2701
  }),
2617
2702
  css: {
2618
2703
  marginBottom: "var(--spacing)"
2619
2704
  }
2620
- }), jsxs("div", {
2705
+ }), /* @__PURE__ */ jsxs("div", {
2621
2706
  css: {
2622
2707
  maxHeight: "20em",
2623
2708
  overflowY: "auto"
2624
2709
  },
2625
- children: [jsx(FormControlLabel, {
2710
+ children: [/* @__PURE__ */ jsx(FormControlLabel, {
2626
2711
  disabled: value.size === 0,
2627
- control: jsx(Checkbox2, {
2712
+ control: /* @__PURE__ */ jsx(Checkbox2, {
2628
2713
  disabled: value.size === 0,
2629
2714
  checked: value.size > 0,
2630
2715
  onChange: () => onChange(/* @__PURE__ */ new Set())
2631
2716
  }),
2632
- label: jsxs(Fragment, {
2633
- children: ["<", text.selected(value.size), ">"]
2717
+ label: /* @__PURE__ */ jsxs(Fragment, {
2718
+ children: ["<", selected(value.size), ">"]
2634
2719
  })
2635
- }), filtered.map((option, index) => jsx(FormControlLabel, {
2636
- control: jsx(Checkbox2, {
2720
+ }), filtered.map((option, index) => /* @__PURE__ */ jsx(FormControlLabel, {
2721
+ control: /* @__PURE__ */ jsx(Checkbox2, {
2637
2722
  checked: value.has(option),
2638
2723
  onChange: () => onChange(toggle(value, option, singleSelect))
2639
2724
  }),
2640
2725
  label: render(option)
2641
2726
  }, index))]
2642
- }), filtered.length === 0 && jsx("span", {
2727
+ }), filtered.length === 0 && /* @__PURE__ */ jsx("span", {
2643
2728
  css: {
2644
2729
  textAlign: "center"
2645
2730
  },
2646
- children: text.noResults
2731
+ children: noResults
2647
2732
  })]
2648
2733
  });
2649
2734
  }
@@ -2674,6 +2759,8 @@ function debounce(fn, ms) {
2674
2759
  function useFilter(impl) {
2675
2760
  const table = useTableContext();
2676
2761
  const columnId = useColumnContext();
2762
+ const cache = useTableMemo();
2763
+ const filterBy = impl.filterBy && cache("", impl.filterBy);
2677
2764
  useEffect(() => {
2678
2765
  table.update((state) => {
2679
2766
  if (impl.defaultValue !== void 0) {
@@ -2683,7 +2770,7 @@ function useFilter(impl) {
2683
2770
  }, []);
2684
2771
  useEffect(() => {
2685
2772
  table.update((state) => {
2686
- state.filters.set(columnId, castDraft(impl));
2773
+ state.filters.set(columnId, castDraft(__spreadProps(__spreadValues({}, impl), { filterBy })));
2687
2774
  if (impl.value !== void 0) {
2688
2775
  state.filterValues.set(columnId, impl.value);
2689
2776
  }
@@ -2718,7 +2805,8 @@ function useFilter(impl) {
2718
2805
  return {
2719
2806
  value: dirtyValue != null ? dirtyValue : value,
2720
2807
  onChange,
2721
- close: useContext(FilterControlContext)
2808
+ close: useContext(FilterControlContext),
2809
+ filterBy: filterBy != null ? filterBy : (x) => x
2722
2810
  };
2723
2811
  }
2724
2812
  const textMatch = (text, query) => {
@@ -2748,15 +2836,9 @@ function TextFilter(_o) {
2748
2836
  "compare",
2749
2837
  "filterBy"
2750
2838
  ]);
2751
- const {
2752
- components: {
2753
- IconButton: IconButton2
2754
- },
2755
- icons: {
2756
- Search: Search2,
2757
- Clear: Clear2
2758
- }
2759
- } = useTheme();
2839
+ const IconButton2 = useTheme((t) => t.components.IconButton);
2840
+ const Search2 = useTheme((t) => t.icons.Search);
2841
+ const Clear2 = useTheme((t) => t.icons.Clear);
2760
2842
  const {
2761
2843
  value = "",
2762
2844
  onChange
@@ -2770,17 +2852,17 @@ function TextFilter(_o) {
2770
2852
  return compare(value2, filterValue);
2771
2853
  }
2772
2854
  }));
2773
- return jsx("div", {
2855
+ return /* @__PURE__ */ jsx("div", {
2774
2856
  css: {
2775
2857
  padding: `calc(var(--spacing) * 2)`,
2776
2858
  display: "grid"
2777
2859
  },
2778
- children: jsx(AutoFocusTextField, {
2860
+ children: /* @__PURE__ */ jsx(AutoFocusTextField, {
2779
2861
  value,
2780
2862
  onChange: (e2) => onChange(e2.target.value),
2781
- endIcon: jsx(IconButton2, {
2863
+ endIcon: /* @__PURE__ */ jsx(IconButton2, {
2782
2864
  onClick: () => onChange(""),
2783
- children: !value ? jsx(Search2, {}) : jsx(Clear2, {})
2865
+ children: !value ? /* @__PURE__ */ jsx(Search2, {}) : /* @__PURE__ */ jsx(Clear2, {})
2784
2866
  })
2785
2867
  })
2786
2868
  });