material-react-table 2.0.0-beta.6 → 2.0.0-beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. package/dist/cjs/index.js +524 -529
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/material-react-table.esm.js +525 -530
  4. package/dist/esm/material-react-table.esm.js.map +1 -1
  5. package/dist/index.d.ts +15 -14
  6. package/locales/ar/index.d.ts +1 -1
  7. package/locales/ar/index.esm.d.ts +1 -1
  8. package/locales/ar/package.json +9 -1
  9. package/locales/az/index.d.ts +1 -1
  10. package/locales/az/index.esm.d.ts +1 -1
  11. package/locales/az/package.json +9 -1
  12. package/locales/bg/index.d.ts +1 -1
  13. package/locales/bg/index.esm.d.ts +1 -1
  14. package/locales/bg/package.json +9 -1
  15. package/locales/cs/index.d.ts +1 -1
  16. package/locales/cs/index.esm.d.ts +1 -1
  17. package/locales/cs/package.json +9 -1
  18. package/locales/da/index.d.ts +1 -1
  19. package/locales/da/index.esm.d.ts +1 -1
  20. package/locales/da/package.json +9 -1
  21. package/locales/de/index.d.ts +1 -1
  22. package/locales/de/index.esm.d.ts +1 -1
  23. package/locales/de/package.json +9 -1
  24. package/locales/en/index.d.ts +1 -1
  25. package/locales/en/index.esm.d.ts +1 -1
  26. package/locales/en/package.json +9 -1
  27. package/locales/es/index.d.ts +1 -1
  28. package/locales/es/index.esm.d.ts +1 -1
  29. package/locales/es/package.json +9 -1
  30. package/locales/et/index.d.ts +1 -1
  31. package/locales/et/index.esm.d.ts +1 -1
  32. package/locales/et/package.json +9 -1
  33. package/locales/fa/index.d.ts +1 -1
  34. package/locales/fa/index.esm.d.ts +1 -1
  35. package/locales/fa/package.json +9 -1
  36. package/locales/fi/index.d.ts +1 -1
  37. package/locales/fi/index.esm.d.ts +1 -1
  38. package/locales/fi/package.json +9 -1
  39. package/locales/fr/index.d.ts +1 -1
  40. package/locales/fr/index.esm.d.ts +1 -1
  41. package/locales/fr/package.json +9 -1
  42. package/locales/hu/index.d.ts +1 -1
  43. package/locales/hu/index.esm.d.ts +1 -1
  44. package/locales/hu/package.json +9 -1
  45. package/locales/hy/index.d.ts +1 -1
  46. package/locales/hy/index.esm.d.ts +1 -1
  47. package/locales/hy/package.json +9 -1
  48. package/locales/id/index.d.ts +1 -1
  49. package/locales/id/index.esm.d.ts +1 -1
  50. package/locales/id/package.json +9 -1
  51. package/locales/it/index.d.ts +1 -1
  52. package/locales/it/index.esm.d.ts +1 -1
  53. package/locales/it/package.json +9 -1
  54. package/locales/ja/index.d.ts +1 -1
  55. package/locales/ja/index.esm.d.ts +1 -1
  56. package/locales/ja/package.json +9 -1
  57. package/locales/ko/index.d.ts +1 -1
  58. package/locales/ko/index.esm.d.ts +1 -1
  59. package/locales/ko/package.json +9 -1
  60. package/locales/nl/index.d.ts +1 -1
  61. package/locales/nl/index.esm.d.ts +1 -1
  62. package/locales/nl/package.json +9 -1
  63. package/locales/no/index.d.ts +1 -1
  64. package/locales/no/index.esm.d.ts +1 -1
  65. package/locales/no/package.json +9 -1
  66. package/locales/np/index.d.ts +1 -1
  67. package/locales/np/index.esm.d.ts +1 -1
  68. package/locales/np/package.json +9 -1
  69. package/locales/pl/index.d.ts +1 -1
  70. package/locales/pl/index.esm.d.ts +1 -1
  71. package/locales/pl/package.json +9 -1
  72. package/locales/pt/index.d.ts +1 -1
  73. package/locales/pt/index.esm.d.ts +1 -1
  74. package/locales/pt/package.json +9 -1
  75. package/locales/pt-BR/index.d.ts +1 -1
  76. package/locales/pt-BR/index.esm.d.ts +1 -1
  77. package/locales/pt-BR/package.json +9 -1
  78. package/locales/ro/index.d.ts +1 -1
  79. package/locales/ro/index.esm.d.ts +1 -1
  80. package/locales/ro/package.json +9 -1
  81. package/locales/ru/index.d.ts +1 -1
  82. package/locales/ru/index.esm.d.ts +1 -1
  83. package/locales/ru/package.json +9 -1
  84. package/locales/sk/index.d.ts +1 -1
  85. package/locales/sk/index.esm.d.ts +1 -1
  86. package/locales/sk/package.json +9 -1
  87. package/locales/sr-Cyrl-RS/index.d.ts +1 -1
  88. package/locales/sr-Cyrl-RS/index.esm.d.ts +1 -1
  89. package/locales/sr-Cyrl-RS/package.json +9 -1
  90. package/locales/sr-Latn-RS/index.d.ts +1 -1
  91. package/locales/sr-Latn-RS/index.esm.d.ts +1 -1
  92. package/locales/sr-Latn-RS/package.json +9 -1
  93. package/locales/sv/index.d.ts +1 -1
  94. package/locales/sv/index.esm.d.ts +1 -1
  95. package/locales/sv/package.json +9 -1
  96. package/locales/tr/index.d.ts +1 -1
  97. package/locales/tr/index.esm.d.ts +1 -1
  98. package/locales/tr/package.json +9 -1
  99. package/locales/uk/index.d.ts +1 -1
  100. package/locales/uk/index.esm.d.ts +1 -1
  101. package/locales/uk/package.json +9 -1
  102. package/locales/vi/index.d.ts +1 -1
  103. package/locales/vi/index.esm.d.ts +1 -1
  104. package/locales/vi/package.json +9 -1
  105. package/locales/zh-Hans/index.d.ts +1 -1
  106. package/locales/zh-Hans/index.esm.d.ts +1 -1
  107. package/locales/zh-Hans/package.json +9 -1
  108. package/locales/zh-Hant/index.d.ts +1 -1
  109. package/locales/zh-Hant/index.esm.d.ts +1 -1
  110. package/locales/zh-Hant/package.json +9 -1
  111. package/package.json +1 -1
  112. package/src/body/MRT_TableBodyRow.tsx +2 -0
  113. package/src/column.utils.ts +4 -4
  114. package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
  115. package/src/hooks/useMRT_DisplayColumns.tsx +9 -7
  116. package/src/hooks/useMRT_TableOptions.ts +2 -2
  117. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -0
  118. package/src/style.utils.ts +1 -1
  119. package/src/table/MRT_TablePaper.tsx +2 -0
  120. package/src/types.ts +14 -10
@@ -11,7 +11,7 @@ import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
11
11
  import Skeleton from '@mui/material/Skeleton';
12
12
  import TableCell from '@mui/material/TableCell';
13
13
  import Box from '@mui/material/Box';
14
- import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, aggregationFns, filterFns } from '@tanstack/react-table';
14
+ import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, aggregationFns, filterFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
15
15
  import highlightWords from 'highlight-words';
16
16
  import IconButton from '@mui/material/IconButton';
17
17
  import Tooltip from '@mui/material/Tooltip';
@@ -291,15 +291,15 @@ const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', o
291
291
  [getColumnId(col)]: '',
292
292
  }))), -1, 0);
293
293
  const extraIndexRangeExtractor = (range, draggingIndex) => {
294
- const newIndexs = defaultRangeExtractor(range);
294
+ const newIndexes = defaultRangeExtractor(range);
295
295
  if (draggingIndex >= 0 &&
296
296
  draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
297
- newIndexs.unshift(draggingIndex);
297
+ newIndexes.unshift(draggingIndex);
298
298
  }
299
299
  if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
300
- newIndexs.push(draggingIndex);
300
+ newIndexes.push(draggingIndex);
301
301
  }
302
- return newIndexs;
302
+ return newIndexes;
303
303
  };
304
304
  function createMRTColumnHelper() {
305
305
  return {
@@ -318,7 +318,7 @@ const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: them
318
318
  ? lighten(theme.palette.background.default, 0.05)
319
319
  : theme.palette.background.default, draggingBorderColor: theme.palette.primary.main, matchHighlightColor: theme.palette.mode === 'dark'
320
320
  ? darken(theme.palette.warning.dark, 0.25)
321
- : lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, table.options.mrtTheme));
321
+ : lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
322
322
  const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
323
323
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
324
324
  const { options: { layoutMode }, } = table;
@@ -824,7 +824,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
824
824
  };
825
825
  const rowRef = useRef(null);
826
826
  const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
827
- return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter, ref: (node) => {
827
+ return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
828
828
  if (node) {
829
829
  rowRef.current = node;
830
830
  measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
@@ -1932,7 +1932,7 @@ const MRT_TableHeadCellResizeHandle = (_a) => {
1932
1932
  : '-28px',
1933
1933
  position: 'absolute',
1934
1934
  px: '4px',
1935
- right: '0',
1935
+ right: column.columnDef.columnDefType === 'display' ? '4px' : '0',
1936
1936
  }), children: jsx(Divider, { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transition: column.getIsResizing()
1937
1937
  ? undefined
1938
1938
  : 'all 150ms ease-in-out', userSelect: 'none', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) }) }));
@@ -2421,6 +2421,8 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
2421
2421
  setHoveredColumn(column);
2422
2422
  }
2423
2423
  };
2424
+ if (!columnDef.header)
2425
+ return null;
2424
2426
  return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
2425
2427
  ? `2px dashed ${theme.palette.grey[500]}`
2426
2428
  : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
@@ -2860,7 +2862,7 @@ const MRT_TablePaper = (_a) => {
2860
2862
  width: '100vw',
2861
2863
  zIndex: 999,
2862
2864
  }
2863
- : {})), tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), sx: (theme) => (Object.assign({ overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx, theme))), children: [enableTopToolbar &&
2865
+ : {})), tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx, theme))), children: [enableTopToolbar &&
2864
2866
  ((_b = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
2865
2867
  ((_c = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _c !== void 0 ? _c : (jsx(MRT_BottomToolbar, { table: table })))] })));
2866
2868
  };
@@ -2986,533 +2988,225 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
2986
2988
  ['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { arrow: true, placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : renderRowActionMenuItems ? (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) }), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
2987
2989
  };
2988
2990
 
2989
- const blankColProps = {
2990
- children: null,
2991
- sx: {
2992
- flex: '1 0 auto',
2993
- minWidth: 0,
2994
- p: 0,
2995
- width: 0,
2996
- },
2997
- };
2998
- const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOptions, }) => {
2999
- var _a, _b;
3000
- return useMemo(() => {
3001
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
3002
- return [
3003
- ((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-pin') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), header: tableOptions.localization.pin, size: 60 }, tableOptions.defaultDisplayColumn), (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-pin']), { id: 'mrt-row-pin' }),
3004
- ((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, tableOptions.defaultDisplayColumn), (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-drag']), { id: 'mrt-row-drag' }),
3005
- (((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-actions') ||
3006
- (creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, tableOptions.defaultDisplayColumn), (_j = tableOptions.displayColumnDefOptions) === null || _j === void 0 ? void 0 : _j['mrt-row-actions']), { id: 'mrt-row-actions' }),
3007
- ((_l = (_k = tableOptions.state) === null || _k === void 0 ? void 0 : _k.columnOrder) !== null && _l !== void 0 ? _l : columnOrder).includes('mrt-row-expand') &&
3008
- showExpandColumn(tableOptions, (_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.grouping) !== null && _o !== void 0 ? _o : grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
3009
- ? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
3010
- : null, header: tableOptions.localization.expand, size: 60 }, tableOptions.defaultDisplayColumn), (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-expand']), { id: 'mrt-row-expand' }),
3011
- ((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
3012
- tableOptions.enableMultiRowSelection
3013
- ? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
3014
- : null, header: tableOptions.localization.select, size: 60 }, tableOptions.defaultDisplayColumn), (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-select']), { id: 'mrt-row-select' }),
3015
- ((_u = (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnOrder) !== null && _u !== void 0 ? _u : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, tableOptions.defaultDisplayColumn), (_v = tableOptions.displayColumnDefOptions) === null || _v === void 0 ? void 0 : _v['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
3016
- ((_x = (_w = tableOptions.state) === null || _w === void 0 ? void 0 : _w.columnOrder) !== null && _x !== void 0 ? _x : columnOrder).includes('mrt-row-spacer') && {
3017
- columnDefType: 'display',
3018
- header: '',
3019
- id: 'mrt-row-spacer',
3020
- muiTableBodyCellProps: blankColProps,
3021
- muiTableFooterCellProps: blankColProps,
3022
- muiTableHeadCellProps: blankColProps,
3023
- },
3024
- ].filter(Boolean);
3025
- }, [
3026
- columnOrder,
3027
- grouping,
3028
- tableOptions.displayColumnDefOptions,
3029
- tableOptions.editDisplayMode,
3030
- tableOptions.enableColumnDragging,
3031
- tableOptions.enableColumnFilterModes,
3032
- tableOptions.enableColumnOrdering,
3033
- tableOptions.enableEditing,
3034
- tableOptions.enableExpandAll,
3035
- tableOptions.enableExpanding,
3036
- tableOptions.enableGrouping,
3037
- tableOptions.enableRowActions,
3038
- tableOptions.enableRowDragging,
3039
- tableOptions.enableRowNumbers,
3040
- tableOptions.enableRowOrdering,
3041
- tableOptions.enableRowSelection,
3042
- tableOptions.enableSelectAll,
3043
- tableOptions.localization,
3044
- tableOptions.positionActionsColumn,
3045
- tableOptions.renderDetailPanel,
3046
- tableOptions.renderRowActionMenuItems,
3047
- tableOptions.renderRowActions,
3048
- (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
3049
- (_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
3050
- ]);
2991
+ const MRT_AggregationFns = Object.assign({}, aggregationFns);
2992
+
2993
+ const fuzzy = (row, columnId, filterValue, addMeta) => {
2994
+ const itemRank = rankItem(row.getValue(columnId), filterValue, {
2995
+ threshold: rankings.MATCHES,
2996
+ });
2997
+ addMeta(itemRank);
2998
+ return itemRank.passed;
3051
2999
  };
3000
+ fuzzy.autoRemove = (val) => !val;
3001
+ const contains = (row, id, filterValue) => row
3002
+ .getValue(id)
3003
+ .toString()
3004
+ .toLowerCase()
3005
+ .trim()
3006
+ .includes(filterValue.toString().toLowerCase().trim());
3007
+ contains.autoRemove = (val) => !val;
3008
+ const startsWith = (row, id, filterValue) => row
3009
+ .getValue(id)
3010
+ .toString()
3011
+ .toLowerCase()
3012
+ .trim()
3013
+ .startsWith(filterValue.toString().toLowerCase().trim());
3014
+ startsWith.autoRemove = (val) => !val;
3015
+ const endsWith = (row, id, filterValue) => row
3016
+ .getValue(id)
3017
+ .toString()
3018
+ .toLowerCase()
3019
+ .trim()
3020
+ .endsWith(filterValue.toString().toLowerCase().trim());
3021
+ endsWith.autoRemove = (val) => !val;
3022
+ const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
3023
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
3024
+ equals.autoRemove = (val) => !val;
3025
+ const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
3026
+ filterValue.toString().toLowerCase().trim();
3027
+ notEquals.autoRemove = (val) => !val;
3028
+ const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
3029
+ ? +row.getValue(id) > +filterValue
3030
+ : row.getValue(id).toString().toLowerCase().trim() >
3031
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
3032
+ greaterThan.autoRemove = (val) => !val;
3033
+ const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
3034
+ greaterThanOrEqualTo.autoRemove = (val) => !val;
3035
+ const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
3036
+ ? +row.getValue(id) < +filterValue
3037
+ : row.getValue(id).toString().toLowerCase().trim() <
3038
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
3039
+ lessThan.autoRemove = (val) => !val;
3040
+ const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
3041
+ lessThanOrEqualTo.autoRemove = (val) => !val;
3042
+ const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
3043
+ greaterThan(row, id, filterValues[0])) &&
3044
+ ((!isNaN(+filterValues[0]) &&
3045
+ !isNaN(+filterValues[1]) &&
3046
+ +filterValues[0] > +filterValues[1]) ||
3047
+ ['', undefined].includes(filterValues[1]) ||
3048
+ lessThan(row, id, filterValues[1]));
3049
+ between.autoRemove = (val) => !val;
3050
+ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
3051
+ greaterThanOrEqualTo(row, id, filterValues[0])) &&
3052
+ ((!isNaN(+filterValues[0]) &&
3053
+ !isNaN(+filterValues[1]) &&
3054
+ +filterValues[0] > +filterValues[1]) ||
3055
+ ['', undefined].includes(filterValues[1]) ||
3056
+ lessThanOrEqualTo(row, id, filterValues[1]));
3057
+ betweenInclusive.autoRemove = (val) => !val;
3058
+ const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
3059
+ empty.autoRemove = (val) => !val;
3060
+ const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
3061
+ notEmpty.autoRemove = (val) => !val;
3062
+ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
3063
+ betweenInclusive,
3064
+ contains,
3065
+ empty,
3066
+ endsWith,
3067
+ equals,
3068
+ fuzzy,
3069
+ greaterThan,
3070
+ greaterThanOrEqualTo,
3071
+ lessThan,
3072
+ lessThanOrEqualTo,
3073
+ notEmpty,
3074
+ notEquals,
3075
+ startsWith });
3052
3076
 
3053
- const useMRT_Effects = (table) => {
3054
- const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
3055
- const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
3056
- const rerender = useReducer(() => ({}), {})[1];
3057
- const isMounted = useRef(false);
3058
- const initialBodyHeight = useRef();
3059
- const previousTop = useRef();
3060
- useEffect(() => {
3061
- if (typeof window !== 'undefined') {
3062
- initialBodyHeight.current = document.body.style.height;
3063
- }
3064
- }, []);
3065
- useEffect(() => {
3066
- if (isMounted && typeof window !== 'undefined') {
3067
- if (isFullScreen) {
3068
- previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
3069
- document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
3070
- }
3071
- else {
3072
- document.body.style.height = initialBodyHeight.current;
3073
- if (!previousTop.current)
3074
- return;
3075
- //restore scroll position
3076
- window.scrollTo({
3077
- behavior: 'instant',
3078
- top: -1 * previousTop.current,
3079
- });
3080
- }
3081
- }
3082
- isMounted.current = true;
3083
- }, [isFullScreen]);
3084
- //if page index is out of bounds, set it to the last page
3085
- useEffect(() => {
3086
- if (!enablePagination || isLoading || showSkeletons)
3087
- return;
3088
- const { pageIndex, pageSize } = pagination;
3089
- const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
3090
- const firstVisibleRowIndex = pageIndex * pageSize;
3091
- if (firstVisibleRowIndex > totalRowCount) {
3092
- table.setPageIndex(Math.floor(totalRowCount / pageSize));
3093
- }
3094
- }, [rowCount, table.getPrePaginationRowModel().rows.length]);
3095
- //turn off sort when global filter is looking for ranked results
3096
- const appliedSort = useRef(sorting);
3097
- useEffect(() => {
3098
- if (sorting.length) {
3099
- appliedSort.current = sorting;
3100
- }
3101
- }, [sorting]);
3102
- useEffect(() => {
3103
- if (!getCanRankRows(table))
3104
- return;
3105
- if (globalFilter) {
3106
- table.setSorting([]);
3107
- }
3108
- else {
3109
- table.setSorting(() => appliedSort.current || []);
3110
- }
3111
- }, [globalFilter]);
3112
- useEffect(() => {
3113
- if (enableRowPinning && getIsSomeRowsPinned()) {
3114
- setTimeout(() => {
3115
- rerender();
3116
- }, 150);
3117
- }
3118
- }, [density]);
3077
+ const MRT_Default_Icons = {
3078
+ ArrowDownwardIcon,
3079
+ ArrowRightIcon,
3080
+ CancelIcon,
3081
+ ChevronLeftIcon,
3082
+ ChevronRightIcon,
3083
+ ClearAllIcon,
3084
+ CloseIcon,
3085
+ DensityLargeIcon,
3086
+ DensityMediumIcon,
3087
+ DensitySmallIcon,
3088
+ DragHandleIcon,
3089
+ DynamicFeedIcon,
3090
+ EditIcon,
3091
+ ExpandMoreIcon,
3092
+ FilterAltIcon,
3093
+ FilterListIcon,
3094
+ FilterListOffIcon,
3095
+ FirstPageIcon,
3096
+ FullscreenExitIcon,
3097
+ FullscreenIcon,
3098
+ KeyboardDoubleArrowDownIcon,
3099
+ LastPageIcon,
3100
+ MoreHorizIcon,
3101
+ MoreVertIcon,
3102
+ PushPinIcon,
3103
+ RestartAltIcon,
3104
+ SaveIcon,
3105
+ SearchIcon,
3106
+ SearchOffIcon,
3107
+ SortIcon,
3108
+ SyncAltIcon,
3109
+ ViewColumnIcon,
3110
+ VisibilityOffIcon,
3119
3111
  };
3120
3112
 
3121
- const useMRT_TableInstance = (tableOptions) => {
3122
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
3123
- const bottomToolbarRef = useRef(null);
3124
- const editInputRefs = useRef({});
3125
- const filterInputRefs = useRef({});
3126
- const searchInputRef = useRef(null);
3127
- const tableContainerRef = useRef(null);
3128
- const tableHeadCellRefs = useRef({});
3129
- const tablePaperRef = useRef(null);
3130
- const topToolbarRef = useRef(null);
3131
- const tableHeadRef = useRef(null);
3132
- const tableFooterRef = useRef(null);
3133
- const initialState = useMemo(() => {
3134
- var _a, _b, _c;
3135
- const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
3136
- initState.columnOrder =
3137
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
3138
- initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
3139
- return initState;
3140
- }, []);
3141
- const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
3142
- const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
3143
- var _a, _b, _c, _d;
3144
- return ({
3145
- [getColumnId(col)]: col.filterFn instanceof Function
3146
- ? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
3147
- : (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
3148
- });
3149
- })));
3150
- const [columnOrder, setColumnOrder] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
3151
- const [density, setDensity] = useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
3152
- const [draggingColumn, setDraggingColumn] = useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
3153
- const [draggingRow, setDraggingRow] = useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
3154
- const [editingCell, setEditingCell] = useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
3155
- const [editingRow, setEditingRow] = useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
3156
- const [globalFilterFn, setGlobalFilterFn] = useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
3157
- const [grouping, setGrouping] = useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
3158
- const [hoveredColumn, setHoveredColumn] = useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
3159
- const [hoveredRow, setHoveredRow] = useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
3160
- const [isFullScreen, setIsFullScreen] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
3161
- const [showAlertBanner, setShowAlertBanner] = useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
3162
- const [showColumnFilters, setShowColumnFilters] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
3163
- const [showGlobalFilter, setShowGlobalFilter] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
3164
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
3165
- const displayColumns = useMRT_DisplayColumns({
3166
- columnOrder,
3167
- creatingRow,
3168
- grouping,
3169
- tableOptions,
3170
- });
3171
- const columnDefs = useMemo(() => {
3172
- var _a, _b, _c;
3173
- return prepareColumns({
3174
- aggregationFns: tableOptions.aggregationFns,
3175
- columnDefs: [...displayColumns, ...tableOptions.columns],
3176
- columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
3177
- defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
3178
- filterFns: tableOptions.filterFns,
3179
- sortingFns: tableOptions.sortingFns,
3180
- });
3181
- }, [
3182
- columnFilterFns,
3183
- displayColumns,
3184
- tableOptions.columns,
3185
- (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
3186
- ]);
3187
- const data = useMemo(() => {
3188
- var _a, _b, _c, _d, _e;
3189
- return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
3190
- !tableOptions.data.length
3191
- ? [
3192
- ...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
3193
- ((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
3194
- 10).fill(null),
3195
- ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
3196
- [getColumnId(col)]: null,
3197
- }))))
3198
- : tableOptions.data;
3199
- }, [
3200
- tableOptions.data,
3201
- (_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
3202
- (_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
3203
- ]);
3204
- //@ts-ignore
3205
- const table = useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
3206
- ? getExpandedRowModel()
3207
- : undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
3208
- ? getFacetedMinMaxValues()
3209
- : undefined, getFacetedRowModel: tableOptions.enableFacetedValues
3210
- ? getFacetedRowModel()
3211
- : undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
3212
- ? getFacetedUniqueValues()
3213
- : undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
3214
- tableOptions.enableGlobalFilter ||
3215
- tableOptions.enableFilters
3216
- ? getFilteredRowModel()
3217
- : undefined, getGroupedRowModel: tableOptions.enableGrouping
3218
- ? getGroupedRowModel()
3219
- : undefined, getPaginationRowModel: tableOptions.enablePagination
3220
- ? getPaginationRowModel()
3221
- : undefined, getSortedRowModel: tableOptions.enableSorting
3222
- ? getSortedRowModel()
3223
- : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping }, tableOptions), {
3224
- //@ts-ignore
3225
- columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ columnFilterFns,
3226
- columnOrder,
3227
- creatingRow,
3228
- density,
3229
- draggingColumn,
3230
- draggingRow,
3231
- editingCell,
3232
- editingRow,
3233
- globalFilterFn,
3234
- grouping,
3235
- hoveredColumn,
3236
- hoveredRow,
3237
- isFullScreen,
3238
- showAlertBanner,
3239
- showColumnFilters,
3240
- showGlobalFilter,
3241
- showToolbarDropZone }, tableOptions.state) }));
3242
- // @ts-ignore
3243
- table.refs = {
3244
- // @ts-ignore
3245
- bottomToolbarRef,
3246
- editInputRefs,
3247
- filterInputRefs,
3248
- // @ts-ignore
3249
- searchInputRef,
3250
- // @ts-ignore
3251
- tableContainerRef,
3252
- // @ts-ignore
3253
- tableFooterRef,
3254
- tableHeadCellRefs,
3255
- // @ts-ignore
3256
- tableHeadRef,
3257
- // @ts-ignore
3258
- tablePaperRef,
3259
- // @ts-ignore
3260
- topToolbarRef,
3261
- };
3262
- const setCreatingRow = (row) => {
3263
- var _a, _b;
3264
- let _row = row;
3265
- if (row === true) {
3266
- _row = createRow(table);
3267
- }
3268
- (_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
3269
- };
3270
- table.setCreatingRow = setCreatingRow;
3271
- table.setColumnFilterFns =
3272
- (_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
3273
- table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
3274
- table.setDraggingColumn =
3275
- (_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
3276
- table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
3277
- table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
3278
- table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
3279
- table.setGlobalFilterFn =
3280
- (_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
3281
- table.setHoveredColumn =
3282
- (_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
3283
- table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
3284
- table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
3285
- table.setShowAlertBanner =
3286
- (_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
3287
- table.setShowColumnFilters =
3288
- (_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
3289
- table.setShowGlobalFilter =
3290
- (_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
3291
- table.setShowToolbarDropZone =
3292
- (_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
3293
- useMRT_Effects(table);
3294
- return table;
3113
+ const MRT_Localization_EN = {
3114
+ actions: 'Actions',
3115
+ and: 'and',
3116
+ cancel: 'Cancel',
3117
+ changeFilterMode: 'Change filter mode',
3118
+ changeSearchMode: 'Change search mode',
3119
+ clearFilter: 'Clear filter',
3120
+ clearSearch: 'Clear search',
3121
+ clearSort: 'Clear sort',
3122
+ clickToCopy: 'Click to copy',
3123
+ collapse: 'Collapse',
3124
+ collapseAll: 'Collapse all',
3125
+ columnActions: 'Column Actions',
3126
+ copiedToClipboard: 'Copied to clipboard',
3127
+ dropToGroupBy: 'Drop to group by {column}',
3128
+ edit: 'Edit',
3129
+ expand: 'Expand',
3130
+ expandAll: 'Expand all',
3131
+ filterArrIncludes: 'Includes',
3132
+ filterArrIncludesAll: 'Includes all',
3133
+ filterArrIncludesSome: 'Includes',
3134
+ filterBetween: 'Between',
3135
+ filterBetweenInclusive: 'Between Inclusive',
3136
+ filterByColumn: 'Filter by {column}',
3137
+ filterContains: 'Contains',
3138
+ filterEmpty: 'Empty',
3139
+ filterEndsWith: 'Ends With',
3140
+ filterEquals: 'Equals',
3141
+ filterEqualsString: 'Equals',
3142
+ filterFuzzy: 'Fuzzy',
3143
+ filterGreaterThan: 'Greater Than',
3144
+ filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
3145
+ filterInNumberRange: 'Between',
3146
+ filterIncludesString: 'Contains',
3147
+ filterIncludesStringSensitive: 'Contains',
3148
+ filterLessThan: 'Less Than',
3149
+ filterLessThanOrEqualTo: 'Less Than Or Equal To',
3150
+ filterMode: 'Filter Mode: {filterType}',
3151
+ filterNotEmpty: 'Not Empty',
3152
+ filterNotEquals: 'Not Equals',
3153
+ filterStartsWith: 'Starts With',
3154
+ filterWeakEquals: 'Equals',
3155
+ filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
3156
+ goToFirstPage: 'Go to first page',
3157
+ goToLastPage: 'Go to last page',
3158
+ goToNextPage: 'Go to next page',
3159
+ goToPreviousPage: 'Go to previous page',
3160
+ grab: 'Grab',
3161
+ groupByColumn: 'Group by {column}',
3162
+ groupedBy: 'Grouped by ',
3163
+ hideAll: 'Hide all',
3164
+ hideColumn: 'Hide {column} column',
3165
+ max: 'Max',
3166
+ min: 'Min',
3167
+ move: 'Move',
3168
+ noRecordsToDisplay: 'No records to display',
3169
+ noResultsFound: 'No results found',
3170
+ of: 'of',
3171
+ or: 'or',
3172
+ pin: 'Pin',
3173
+ pinToLeft: 'Pin to left',
3174
+ pinToRight: 'Pin to right',
3175
+ resetColumnSize: 'Reset column size',
3176
+ resetOrder: 'Reset order',
3177
+ rowActions: 'Row Actions',
3178
+ rowNumber: '#',
3179
+ rowNumbers: 'Row Numbers',
3180
+ rowsPerPage: 'Rows per page',
3181
+ save: 'Save',
3182
+ search: 'Search',
3183
+ selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
3184
+ select: 'Select',
3185
+ showAll: 'Show all',
3186
+ showAllColumns: 'Show all columns',
3187
+ showHideColumns: 'Show/Hide columns',
3188
+ showHideFilters: 'Show/Hide filters',
3189
+ showHideSearch: 'Show/Hide search',
3190
+ sortByColumnAsc: 'Sort by {column} ascending',
3191
+ sortByColumnDesc: 'Sort by {column} descending',
3192
+ sortedByColumnAsc: 'Sorted by {column} ascending',
3193
+ sortedByColumnDesc: 'Sorted by {column} descending',
3194
+ thenBy: ', then by ',
3195
+ toggleDensity: 'Toggle density',
3196
+ toggleFullScreen: 'Toggle full screen',
3197
+ toggleSelectAll: 'Toggle select all',
3198
+ toggleSelectRow: 'Toggle select row',
3199
+ toggleVisibility: 'Toggle visibility',
3200
+ ungroupByColumn: 'Ungroup by {column}',
3201
+ unpin: 'Unpin',
3202
+ unpinAll: 'Unpin all',
3295
3203
  };
3296
3204
 
3297
- const MRT_AggregationFns = Object.assign({}, aggregationFns);
3298
-
3299
- const fuzzy = (row, columnId, filterValue, addMeta) => {
3300
- const itemRank = rankItem(row.getValue(columnId), filterValue, {
3301
- threshold: rankings.MATCHES,
3302
- });
3303
- addMeta(itemRank);
3304
- return itemRank.passed;
3305
- };
3306
- fuzzy.autoRemove = (val) => !val;
3307
- const contains = (row, id, filterValue) => row
3308
- .getValue(id)
3309
- .toString()
3310
- .toLowerCase()
3311
- .trim()
3312
- .includes(filterValue.toString().toLowerCase().trim());
3313
- contains.autoRemove = (val) => !val;
3314
- const startsWith = (row, id, filterValue) => row
3315
- .getValue(id)
3316
- .toString()
3317
- .toLowerCase()
3318
- .trim()
3319
- .startsWith(filterValue.toString().toLowerCase().trim());
3320
- startsWith.autoRemove = (val) => !val;
3321
- const endsWith = (row, id, filterValue) => row
3322
- .getValue(id)
3323
- .toString()
3324
- .toLowerCase()
3325
- .trim()
3326
- .endsWith(filterValue.toString().toLowerCase().trim());
3327
- endsWith.autoRemove = (val) => !val;
3328
- const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
3329
- (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
3330
- equals.autoRemove = (val) => !val;
3331
- const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
3332
- filterValue.toString().toLowerCase().trim();
3333
- notEquals.autoRemove = (val) => !val;
3334
- const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
3335
- ? +row.getValue(id) > +filterValue
3336
- : row.getValue(id).toString().toLowerCase().trim() >
3337
- (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
3338
- greaterThan.autoRemove = (val) => !val;
3339
- const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
3340
- greaterThanOrEqualTo.autoRemove = (val) => !val;
3341
- const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
3342
- ? +row.getValue(id) < +filterValue
3343
- : row.getValue(id).toString().toLowerCase().trim() <
3344
- (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
3345
- lessThan.autoRemove = (val) => !val;
3346
- const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
3347
- lessThanOrEqualTo.autoRemove = (val) => !val;
3348
- const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
3349
- greaterThan(row, id, filterValues[0])) &&
3350
- ((!isNaN(+filterValues[0]) &&
3351
- !isNaN(+filterValues[1]) &&
3352
- +filterValues[0] > +filterValues[1]) ||
3353
- ['', undefined].includes(filterValues[1]) ||
3354
- lessThan(row, id, filterValues[1]));
3355
- between.autoRemove = (val) => !val;
3356
- const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
3357
- greaterThanOrEqualTo(row, id, filterValues[0])) &&
3358
- ((!isNaN(+filterValues[0]) &&
3359
- !isNaN(+filterValues[1]) &&
3360
- +filterValues[0] > +filterValues[1]) ||
3361
- ['', undefined].includes(filterValues[1]) ||
3362
- lessThanOrEqualTo(row, id, filterValues[1]));
3363
- betweenInclusive.autoRemove = (val) => !val;
3364
- const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
3365
- empty.autoRemove = (val) => !val;
3366
- const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
3367
- notEmpty.autoRemove = (val) => !val;
3368
- const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
3369
- betweenInclusive,
3370
- contains,
3371
- empty,
3372
- endsWith,
3373
- equals,
3374
- fuzzy,
3375
- greaterThan,
3376
- greaterThanOrEqualTo,
3377
- lessThan,
3378
- lessThanOrEqualTo,
3379
- notEmpty,
3380
- notEquals,
3381
- startsWith });
3382
-
3383
- const MRT_Default_Icons = {
3384
- ArrowDownwardIcon,
3385
- ArrowRightIcon,
3386
- CancelIcon,
3387
- ChevronLeftIcon,
3388
- ChevronRightIcon,
3389
- ClearAllIcon,
3390
- CloseIcon,
3391
- DensityLargeIcon,
3392
- DensityMediumIcon,
3393
- DensitySmallIcon,
3394
- DragHandleIcon,
3395
- DynamicFeedIcon,
3396
- EditIcon,
3397
- ExpandMoreIcon,
3398
- FilterAltIcon,
3399
- FilterListIcon,
3400
- FilterListOffIcon,
3401
- FirstPageIcon,
3402
- FullscreenExitIcon,
3403
- FullscreenIcon,
3404
- KeyboardDoubleArrowDownIcon,
3405
- LastPageIcon,
3406
- MoreHorizIcon,
3407
- MoreVertIcon,
3408
- PushPinIcon,
3409
- RestartAltIcon,
3410
- SaveIcon,
3411
- SearchIcon,
3412
- SearchOffIcon,
3413
- SortIcon,
3414
- SyncAltIcon,
3415
- ViewColumnIcon,
3416
- VisibilityOffIcon,
3417
- };
3418
-
3419
- const MRT_Localization_EN = {
3420
- actions: 'Actions',
3421
- and: 'and',
3422
- cancel: 'Cancel',
3423
- changeFilterMode: 'Change filter mode',
3424
- changeSearchMode: 'Change search mode',
3425
- clearFilter: 'Clear filter',
3426
- clearSearch: 'Clear search',
3427
- clearSort: 'Clear sort',
3428
- clickToCopy: 'Click to copy',
3429
- collapse: 'Collapse',
3430
- collapseAll: 'Collapse all',
3431
- columnActions: 'Column Actions',
3432
- copiedToClipboard: 'Copied to clipboard',
3433
- dropToGroupBy: 'Drop to group by {column}',
3434
- edit: 'Edit',
3435
- expand: 'Expand',
3436
- expandAll: 'Expand all',
3437
- filterArrIncludes: 'Includes',
3438
- filterArrIncludesAll: 'Includes all',
3439
- filterArrIncludesSome: 'Includes',
3440
- filterBetween: 'Between',
3441
- filterBetweenInclusive: 'Between Inclusive',
3442
- filterByColumn: 'Filter by {column}',
3443
- filterContains: 'Contains',
3444
- filterEmpty: 'Empty',
3445
- filterEndsWith: 'Ends With',
3446
- filterEquals: 'Equals',
3447
- filterEqualsString: 'Equals',
3448
- filterFuzzy: 'Fuzzy',
3449
- filterGreaterThan: 'Greater Than',
3450
- filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
3451
- filterInNumberRange: 'Between',
3452
- filterIncludesString: 'Contains',
3453
- filterIncludesStringSensitive: 'Contains',
3454
- filterLessThan: 'Less Than',
3455
- filterLessThanOrEqualTo: 'Less Than Or Equal To',
3456
- filterMode: 'Filter Mode: {filterType}',
3457
- filterNotEmpty: 'Not Empty',
3458
- filterNotEquals: 'Not Equals',
3459
- filterStartsWith: 'Starts With',
3460
- filterWeakEquals: 'Equals',
3461
- filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
3462
- goToFirstPage: 'Go to first page',
3463
- goToLastPage: 'Go to last page',
3464
- goToNextPage: 'Go to next page',
3465
- goToPreviousPage: 'Go to previous page',
3466
- grab: 'Grab',
3467
- groupByColumn: 'Group by {column}',
3468
- groupedBy: 'Grouped by ',
3469
- hideAll: 'Hide all',
3470
- hideColumn: 'Hide {column} column',
3471
- max: 'Max',
3472
- min: 'Min',
3473
- move: 'Move',
3474
- noRecordsToDisplay: 'No records to display',
3475
- noResultsFound: 'No results found',
3476
- of: 'of',
3477
- or: 'or',
3478
- pin: 'Pin',
3479
- pinToLeft: 'Pin to left',
3480
- pinToRight: 'Pin to right',
3481
- resetColumnSize: 'Reset column size',
3482
- resetOrder: 'Reset order',
3483
- rowActions: 'Row Actions',
3484
- rowNumber: '#',
3485
- rowNumbers: 'Row Numbers',
3486
- rowsPerPage: 'Rows per page',
3487
- save: 'Save',
3488
- search: 'Search',
3489
- selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
3490
- select: 'Select',
3491
- showAll: 'Show all',
3492
- showAllColumns: 'Show all columns',
3493
- showHideColumns: 'Show/Hide columns',
3494
- showHideFilters: 'Show/Hide filters',
3495
- showHideSearch: 'Show/Hide search',
3496
- sortByColumnAsc: 'Sort by {column} ascending',
3497
- sortByColumnDesc: 'Sort by {column} descending',
3498
- sortedByColumnAsc: 'Sorted by {column} ascending',
3499
- sortedByColumnDesc: 'Sorted by {column} descending',
3500
- thenBy: ', then by ',
3501
- toggleDensity: 'Toggle density',
3502
- toggleFullScreen: 'Toggle full screen',
3503
- toggleSelectAll: 'Toggle select all',
3504
- toggleSelectRow: 'Toggle select row',
3505
- toggleVisibility: 'Toggle visibility',
3506
- ungroupByColumn: 'Ungroup by {column}',
3507
- unpin: 'Unpin',
3508
- unpinAll: 'Unpin all',
3509
- };
3510
-
3511
- const MRT_DefaultColumn = {
3512
- filterVariant: 'text',
3513
- maxSize: 1000,
3514
- minSize: 40,
3515
- size: 180,
3205
+ const MRT_DefaultColumn = {
3206
+ filterVariant: 'text',
3207
+ maxSize: 1000,
3208
+ minSize: 40,
3209
+ size: 180,
3516
3210
  };
3517
3211
  const MRT_DefaultDisplayColumn = {
3518
3212
  columnDefType: 'display',
@@ -3605,6 +3299,307 @@ const useMRT_TableOptions = (_a) => {
3605
3299
  selectAllMode, sortingFns: _sortingFns }, rest);
3606
3300
  };
3607
3301
 
3302
+ const blankColProps = {
3303
+ children: null,
3304
+ sx: {
3305
+ flex: '1 0 auto',
3306
+ minWidth: 0,
3307
+ p: 0,
3308
+ width: 0,
3309
+ },
3310
+ };
3311
+ const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOptions, }) => {
3312
+ var _a, _b;
3313
+ return useMemo(() => {
3314
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
3315
+ return [
3316
+ ((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-pin') && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), header: tableOptions.localization.pin, size: 60 }, (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-pin']), { columnDefType: 'display', id: 'mrt-row-pin' }),
3317
+ ((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-drag']), { columnDefType: 'display', id: 'mrt-row-drag' }),
3318
+ (((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-actions') ||
3319
+ (creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, (_j = tableOptions.displayColumnDefOptions) === null || _j === void 0 ? void 0 : _j['mrt-row-actions']), { columnDefType: 'display', id: 'mrt-row-actions' }),
3320
+ ((_l = (_k = tableOptions.state) === null || _k === void 0 ? void 0 : _k.columnOrder) !== null && _l !== void 0 ? _l : columnOrder).includes('mrt-row-expand') &&
3321
+ showExpandColumn(tableOptions, (_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.grouping) !== null && _o !== void 0 ? _o : grouping) && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
3322
+ ? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
3323
+ : null, header: tableOptions.localization.expand, size: 60 }, (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-expand']), { columnDefType: 'display', id: 'mrt-row-expand' }),
3324
+ ((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
3325
+ tableOptions.enableMultiRowSelection
3326
+ ? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
3327
+ : null, header: tableOptions.localization.select, size: 60 }, (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-select']), { columnDefType: 'display', id: 'mrt-row-select' }),
3328
+ ((_u = (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnOrder) !== null && _u !== void 0 ? _u : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, (_v = tableOptions.displayColumnDefOptions) === null || _v === void 0 ? void 0 : _v['mrt-row-numbers']), { columnDefType: 'display', id: 'mrt-row-numbers' }),
3329
+ ((_x = (_w = tableOptions.state) === null || _w === void 0 ? void 0 : _w.columnOrder) !== null && _x !== void 0 ? _x : columnOrder).includes('mrt-row-spacer') && Object.assign(Object.assign(Object.assign({}, (_y = tableOptions.displayColumnDefOptions) === null || _y === void 0 ? void 0 : _y['mrt-row-spacer']), MRT_DefaultDisplayColumn), { columnDefType: 'display', header: '', id: 'mrt-row-spacer', muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps }),
3330
+ ].filter(Boolean);
3331
+ }, [
3332
+ columnOrder,
3333
+ grouping,
3334
+ tableOptions.displayColumnDefOptions,
3335
+ tableOptions.editDisplayMode,
3336
+ tableOptions.enableColumnDragging,
3337
+ tableOptions.enableColumnFilterModes,
3338
+ tableOptions.enableColumnOrdering,
3339
+ tableOptions.enableEditing,
3340
+ tableOptions.enableExpandAll,
3341
+ tableOptions.enableExpanding,
3342
+ tableOptions.enableGrouping,
3343
+ tableOptions.enableRowActions,
3344
+ tableOptions.enableRowDragging,
3345
+ tableOptions.enableRowNumbers,
3346
+ tableOptions.enableRowOrdering,
3347
+ tableOptions.enableRowSelection,
3348
+ tableOptions.enableSelectAll,
3349
+ tableOptions.localization,
3350
+ tableOptions.positionActionsColumn,
3351
+ tableOptions.renderDetailPanel,
3352
+ tableOptions.renderRowActionMenuItems,
3353
+ tableOptions.renderRowActions,
3354
+ (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
3355
+ (_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
3356
+ ]);
3357
+ };
3358
+
3359
+ const useMRT_Effects = (table) => {
3360
+ const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
3361
+ const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
3362
+ const rerender = useReducer(() => ({}), {})[1];
3363
+ const isMounted = useRef(false);
3364
+ const initialBodyHeight = useRef();
3365
+ const previousTop = useRef();
3366
+ useEffect(() => {
3367
+ if (typeof window !== 'undefined') {
3368
+ initialBodyHeight.current = document.body.style.height;
3369
+ }
3370
+ }, []);
3371
+ useEffect(() => {
3372
+ if (isMounted && typeof window !== 'undefined') {
3373
+ if (isFullScreen) {
3374
+ previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
3375
+ document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
3376
+ }
3377
+ else {
3378
+ document.body.style.height = initialBodyHeight.current;
3379
+ if (!previousTop.current)
3380
+ return;
3381
+ //restore scroll position
3382
+ window.scrollTo({
3383
+ behavior: 'instant',
3384
+ top: -1 * previousTop.current,
3385
+ });
3386
+ }
3387
+ }
3388
+ isMounted.current = true;
3389
+ }, [isFullScreen]);
3390
+ //if page index is out of bounds, set it to the last page
3391
+ useEffect(() => {
3392
+ if (!enablePagination || isLoading || showSkeletons)
3393
+ return;
3394
+ const { pageIndex, pageSize } = pagination;
3395
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
3396
+ const firstVisibleRowIndex = pageIndex * pageSize;
3397
+ if (firstVisibleRowIndex > totalRowCount) {
3398
+ table.setPageIndex(Math.floor(totalRowCount / pageSize));
3399
+ }
3400
+ }, [rowCount, table.getPrePaginationRowModel().rows.length]);
3401
+ //turn off sort when global filter is looking for ranked results
3402
+ const appliedSort = useRef(sorting);
3403
+ useEffect(() => {
3404
+ if (sorting.length) {
3405
+ appliedSort.current = sorting;
3406
+ }
3407
+ }, [sorting]);
3408
+ useEffect(() => {
3409
+ if (!getCanRankRows(table))
3410
+ return;
3411
+ if (globalFilter) {
3412
+ table.setSorting([]);
3413
+ }
3414
+ else {
3415
+ table.setSorting(() => appliedSort.current || []);
3416
+ }
3417
+ }, [globalFilter]);
3418
+ useEffect(() => {
3419
+ if (enableRowPinning && getIsSomeRowsPinned()) {
3420
+ setTimeout(() => {
3421
+ rerender();
3422
+ }, 150);
3423
+ }
3424
+ }, [density]);
3425
+ };
3426
+
3427
+ const useMRT_TableInstance = (tableOptions) => {
3428
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
3429
+ const bottomToolbarRef = useRef(null);
3430
+ const editInputRefs = useRef({});
3431
+ const filterInputRefs = useRef({});
3432
+ const searchInputRef = useRef(null);
3433
+ const tableContainerRef = useRef(null);
3434
+ const tableHeadCellRefs = useRef({});
3435
+ const tablePaperRef = useRef(null);
3436
+ const topToolbarRef = useRef(null);
3437
+ const tableHeadRef = useRef(null);
3438
+ const tableFooterRef = useRef(null);
3439
+ const initialState = useMemo(() => {
3440
+ var _a, _b, _c;
3441
+ const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
3442
+ initState.columnOrder =
3443
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
3444
+ initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
3445
+ return initState;
3446
+ }, []);
3447
+ const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
3448
+ const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
3449
+ var _a, _b, _c, _d;
3450
+ return ({
3451
+ [getColumnId(col)]: col.filterFn instanceof Function
3452
+ ? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
3453
+ : (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
3454
+ });
3455
+ })));
3456
+ const [columnOrder, setColumnOrder] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
3457
+ const [density, setDensity] = useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
3458
+ const [draggingColumn, setDraggingColumn] = useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
3459
+ const [draggingRow, setDraggingRow] = useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
3460
+ const [editingCell, setEditingCell] = useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
3461
+ const [editingRow, setEditingRow] = useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
3462
+ const [globalFilterFn, setGlobalFilterFn] = useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
3463
+ const [grouping, setGrouping] = useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
3464
+ const [hoveredColumn, setHoveredColumn] = useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
3465
+ const [hoveredRow, setHoveredRow] = useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
3466
+ const [isFullScreen, setIsFullScreen] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
3467
+ const [showAlertBanner, setShowAlertBanner] = useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
3468
+ const [showColumnFilters, setShowColumnFilters] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
3469
+ const [showGlobalFilter, setShowGlobalFilter] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
3470
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
3471
+ const displayColumns = useMRT_DisplayColumns({
3472
+ columnOrder,
3473
+ creatingRow,
3474
+ grouping,
3475
+ tableOptions,
3476
+ });
3477
+ const columnDefs = useMemo(() => {
3478
+ var _a, _b, _c;
3479
+ return prepareColumns({
3480
+ aggregationFns: tableOptions.aggregationFns,
3481
+ columnDefs: [...displayColumns, ...tableOptions.columns],
3482
+ columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
3483
+ defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
3484
+ filterFns: tableOptions.filterFns,
3485
+ sortingFns: tableOptions.sortingFns,
3486
+ });
3487
+ }, [
3488
+ columnFilterFns,
3489
+ displayColumns,
3490
+ tableOptions.columns,
3491
+ (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
3492
+ ]);
3493
+ const data = useMemo(() => {
3494
+ var _a, _b, _c, _d, _e;
3495
+ return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
3496
+ !tableOptions.data.length
3497
+ ? [
3498
+ ...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
3499
+ ((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
3500
+ 10).fill(null),
3501
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
3502
+ [getColumnId(col)]: null,
3503
+ }))))
3504
+ : tableOptions.data;
3505
+ }, [
3506
+ tableOptions.data,
3507
+ (_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
3508
+ (_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
3509
+ ]);
3510
+ //@ts-ignore
3511
+ const table = useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
3512
+ ? getExpandedRowModel()
3513
+ : undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
3514
+ ? getFacetedMinMaxValues()
3515
+ : undefined, getFacetedRowModel: tableOptions.enableFacetedValues
3516
+ ? getFacetedRowModel()
3517
+ : undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
3518
+ ? getFacetedUniqueValues()
3519
+ : undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
3520
+ tableOptions.enableGlobalFilter ||
3521
+ tableOptions.enableFilters
3522
+ ? getFilteredRowModel()
3523
+ : undefined, getGroupedRowModel: tableOptions.enableGrouping
3524
+ ? getGroupedRowModel()
3525
+ : undefined, getPaginationRowModel: tableOptions.enablePagination
3526
+ ? getPaginationRowModel()
3527
+ : undefined, getSortedRowModel: tableOptions.enableSorting
3528
+ ? getSortedRowModel()
3529
+ : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping }, tableOptions), {
3530
+ //@ts-ignore
3531
+ columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ columnFilterFns,
3532
+ columnOrder,
3533
+ creatingRow,
3534
+ density,
3535
+ draggingColumn,
3536
+ draggingRow,
3537
+ editingCell,
3538
+ editingRow,
3539
+ globalFilterFn,
3540
+ grouping,
3541
+ hoveredColumn,
3542
+ hoveredRow,
3543
+ isFullScreen,
3544
+ showAlertBanner,
3545
+ showColumnFilters,
3546
+ showGlobalFilter,
3547
+ showToolbarDropZone }, tableOptions.state) }));
3548
+ // @ts-ignore
3549
+ table.refs = {
3550
+ // @ts-ignore
3551
+ bottomToolbarRef,
3552
+ editInputRefs,
3553
+ filterInputRefs,
3554
+ // @ts-ignore
3555
+ searchInputRef,
3556
+ // @ts-ignore
3557
+ tableContainerRef,
3558
+ // @ts-ignore
3559
+ tableFooterRef,
3560
+ tableHeadCellRefs,
3561
+ // @ts-ignore
3562
+ tableHeadRef,
3563
+ // @ts-ignore
3564
+ tablePaperRef,
3565
+ // @ts-ignore
3566
+ topToolbarRef,
3567
+ };
3568
+ const setCreatingRow = (row) => {
3569
+ var _a, _b;
3570
+ let _row = row;
3571
+ if (row === true) {
3572
+ _row = createRow(table);
3573
+ }
3574
+ (_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
3575
+ };
3576
+ table.setCreatingRow = setCreatingRow;
3577
+ table.setColumnFilterFns =
3578
+ (_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
3579
+ table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
3580
+ table.setDraggingColumn =
3581
+ (_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
3582
+ table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
3583
+ table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
3584
+ table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
3585
+ table.setGlobalFilterFn =
3586
+ (_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
3587
+ table.setHoveredColumn =
3588
+ (_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
3589
+ table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
3590
+ table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
3591
+ table.setShowAlertBanner =
3592
+ (_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
3593
+ table.setShowColumnFilters =
3594
+ (_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
3595
+ table.setShowGlobalFilter =
3596
+ (_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
3597
+ table.setShowToolbarDropZone =
3598
+ (_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
3599
+ useMRT_Effects(table);
3600
+ return table;
3601
+ };
3602
+
3608
3603
  const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
3609
3604
 
3610
3605
  const isTableInstanceProp = (props) => props.table !== undefined;