@dooherceg/material-react-table 3.2.2-alpha.9 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -13
- package/dist/index.esm.js +156 -97
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +155 -96
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -712,10 +712,7 @@ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
|
|
712
712
|
const flexRender = reactTable.flexRender;
|
|
713
713
|
function createMRTColumnHelper() {
|
|
714
714
|
return {
|
|
715
|
-
accessor: (accessor, column) => {
|
|
716
|
-
return typeof accessor === 'function'
|
|
717
|
-
? Object.assign(Object.assign({}, column), { accessorFn: accessor }) : Object.assign(Object.assign({}, column), { accessorKey: accessor });
|
|
718
|
-
},
|
|
715
|
+
accessor: (accessor, column) => (Object.assign(Object.assign({}, column), { accessorKey: accessor })),
|
|
719
716
|
display: (column) => column,
|
|
720
717
|
group: (column) => column,
|
|
721
718
|
};
|
|
@@ -1951,7 +1948,7 @@ const MRT_DefaultDisplayColumn = {
|
|
|
1951
1948
|
};
|
|
1952
1949
|
const useMRT_TableOptions = (_a) => {
|
|
1953
1950
|
var _b;
|
|
1954
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = true, enableColumnPinning = true, enableColumnResizing = true, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, maxDepth, enableExpanding, enableRowReordering, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = false, enableAdvancedFilters = true, enableGlobalFilter = false, enableGlobalFilterRankedResults = true, enableGrouping = true, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = true, enableRowSelection = true, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = true, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = react.useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "maxDepth", "enableExpanding", "enableRowReordering", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableAdvancedFilters", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
|
1951
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = true, enableColumnPinning = true, enableColumnResizing = true, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, maxDepth, enableExpanding, enableRowReordering, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = false, enableAdvancedFilters = true, enableGlobalFilter = false, enableGlobalFilterRankedResults = true, enableGrouping = true, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = true, enableRowSelection = true, enableRowVirtualization = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = true, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = react.useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "maxDepth", "enableExpanding", "enableRowReordering", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableAdvancedFilters", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
|
1955
1952
|
const theme = styles.useTheme();
|
|
1956
1953
|
icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
|
1957
1954
|
localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
|
@@ -2237,7 +2234,7 @@ const handleRemoveRow = ({ getRowId, setRowsState, }) => {
|
|
|
2237
2234
|
* @returns the MRT table instance
|
|
2238
2235
|
*/
|
|
2239
2236
|
const useMRT_TableInstance = (definedTableOptions) => {
|
|
2240
|
-
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, _11, _12, _13, _14, _15, _16, _17, _18
|
|
2237
|
+
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, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
2241
2238
|
const lastSelectedRowId = react.useRef(null);
|
|
2242
2239
|
const allSelectableRowIdsRef = react.useRef([]);
|
|
2243
2240
|
const actionCellRef = react.useRef(null);
|
|
@@ -2299,17 +2296,16 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2299
2296
|
const [showAlertBanner, setShowAlertBanner] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
|
|
2300
2297
|
const [showColumnFilters, setShowColumnFilters] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
|
|
2301
2298
|
const [showGlobalFilter, setShowGlobalFilter] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
|
|
2302
|
-
const
|
|
2303
|
-
|
|
2304
|
-
const [
|
|
2305
|
-
const [
|
|
2306
|
-
const [showProgressBars, setShowProgressBars] = react.useState((_x = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _x !== void 0 ? _x : false);
|
|
2299
|
+
const showAdvancedFiltersSetterRef = react.useRef(null);
|
|
2300
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
|
|
2301
|
+
const [newEntryModal, setNewEntryModal] = react.useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _v !== void 0 ? _v : { open: false });
|
|
2302
|
+
const [showProgressBars, setShowProgressBars] = react.useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _w !== void 0 ? _w : false);
|
|
2307
2303
|
// Saved filter presets — initialised from the dedicated option so the consumer
|
|
2308
2304
|
// can hydrate them from the server response before rendering.
|
|
2309
|
-
const [savedFilters, setSavedFilters] = react.useState((
|
|
2305
|
+
const [savedFilters, setSavedFilters] = react.useState((_x = definedTableOptions.initialSavedFilters) !== null && _x !== void 0 ? _x : {});
|
|
2310
2306
|
// Row reordering selection state
|
|
2311
|
-
const [rowReorderingSelection, setRowReorderingSelection] = react.useState((
|
|
2312
|
-
const [rows, setRowsState] = react.useState((
|
|
2307
|
+
const [rowReorderingSelection, setRowReorderingSelection] = react.useState((_y = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _y !== void 0 ? _y : {});
|
|
2308
|
+
const [rows, setRowsState] = react.useState((_z = definedTableOptions.data) !== null && _z !== void 0 ? _z : []);
|
|
2313
2309
|
definedTableOptions.state = Object.assign({ actionCell,
|
|
2314
2310
|
columnFilterFns,
|
|
2315
2311
|
columnOrder,
|
|
@@ -2331,7 +2327,6 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2331
2327
|
showAlertBanner,
|
|
2332
2328
|
showColumnFilters,
|
|
2333
2329
|
showGlobalFilter,
|
|
2334
|
-
showAdvancedFilters,
|
|
2335
2330
|
showProgressBars,
|
|
2336
2331
|
showToolbarDropZone,
|
|
2337
2332
|
newEntryModal }, definedTableOptions.state);
|
|
@@ -2344,39 +2339,67 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2344
2339
|
}
|
|
2345
2340
|
//The table options now include all state needed to help determine column visibility and order logic
|
|
2346
2341
|
const statefulTableOptions = definedTableOptions;
|
|
2347
|
-
const resolveRowId = (
|
|
2348
|
-
//
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2342
|
+
const resolveRowId = (_0 = statefulTableOptions.getRowId) !== null && _0 !== void 0 ? _0 : ((_originalRow, index, _parentRow) => String(index));
|
|
2343
|
+
//keep the prepared column tree referentially stable so TanStack's
|
|
2344
|
+
//getAllColumns/getAllLeafColumns/row.getAllCells memo chain doesn't
|
|
2345
|
+
//recompute (and recreate every cell of every row) on unrelated renders
|
|
2346
|
+
//like hover, menu open/close, or density toggle
|
|
2347
|
+
const rawColumns = statefulTableOptions.columns;
|
|
2348
|
+
const { aggregationFns, createDisplayMode, defaultDisplayColumn, displayColumnDefOptions, editDisplayMode, enableEditing, enableExpanding, enableGrouping, enableRowActions, enableRowDragging, enableRowNumbers, enableRowOrdering, enableRowPinning, enableRowSelection, filterFns, layoutMode, localization, renderDetailPanel, rowNumberDisplayMode, rowPinningDisplayMode, sortingFns, } = statefulTableOptions;
|
|
2349
|
+
//read from the final merged state (consumers/MaterialReactServerTableInstance
|
|
2350
|
+
//may control these via the `state` option, which overrides the internal
|
|
2351
|
+
//useState values above)
|
|
2352
|
+
const { columnFilterFns: stateColumnFilterFns, creatingRow: stateCreatingRow, grouping: stateGrouping, } = statefulTableOptions.state;
|
|
2353
|
+
statefulTableOptions.columns = react.useMemo(() => prepareColumns({
|
|
2354
|
+
columnDefs: [
|
|
2355
|
+
...[
|
|
2356
|
+
showRowPinningColumn(statefulTableOptions) &&
|
|
2357
|
+
getMRT_RowPinningColumnDef(statefulTableOptions),
|
|
2358
|
+
showRowDragColumn(statefulTableOptions) &&
|
|
2359
|
+
getMRT_RowDragColumnDef(statefulTableOptions),
|
|
2360
|
+
showRowActionsColumn(statefulTableOptions) &&
|
|
2361
|
+
getMRT_RowActionsColumnDef(statefulTableOptions),
|
|
2362
|
+
showRowExpandColumn(statefulTableOptions) &&
|
|
2363
|
+
getMRT_RowExpandColumnDef(statefulTableOptions),
|
|
2364
|
+
showRowSelectionColumn(statefulTableOptions) &&
|
|
2365
|
+
getMRT_RowSelectColumnDef(statefulTableOptions),
|
|
2366
|
+
showRowNumbersColumn(statefulTableOptions) &&
|
|
2367
|
+
getMRT_RowNumbersColumnDef(statefulTableOptions),
|
|
2368
|
+
].filter(Boolean),
|
|
2369
|
+
...rawColumns,
|
|
2370
|
+
...[
|
|
2371
|
+
showRowSpacerColumn(statefulTableOptions) &&
|
|
2372
|
+
getMRT_RowSpacerColumnDef(statefulTableOptions),
|
|
2373
|
+
].filter(Boolean),
|
|
2374
|
+
],
|
|
2375
|
+
tableOptions: statefulTableOptions,
|
|
2376
|
+
}), [
|
|
2377
|
+
rawColumns,
|
|
2378
|
+
aggregationFns,
|
|
2379
|
+
createDisplayMode,
|
|
2380
|
+
defaultDisplayColumn,
|
|
2381
|
+
displayColumnDefOptions,
|
|
2382
|
+
editDisplayMode,
|
|
2383
|
+
enableEditing,
|
|
2384
|
+
enableExpanding,
|
|
2385
|
+
enableGrouping,
|
|
2386
|
+
enableRowActions,
|
|
2387
|
+
enableRowDragging,
|
|
2388
|
+
enableRowNumbers,
|
|
2389
|
+
enableRowOrdering,
|
|
2390
|
+
enableRowPinning,
|
|
2391
|
+
enableRowSelection,
|
|
2392
|
+
filterFns,
|
|
2393
|
+
layoutMode,
|
|
2394
|
+
localization,
|
|
2395
|
+
renderDetailPanel,
|
|
2396
|
+
rowNumberDisplayMode,
|
|
2397
|
+
rowPinningDisplayMode,
|
|
2398
|
+
sortingFns,
|
|
2399
|
+
stateColumnFilterFns,
|
|
2400
|
+
stateCreatingRow,
|
|
2401
|
+
stateGrouping,
|
|
2402
|
+
]);
|
|
2380
2403
|
//if loading, generate blank rows to show skeleton loaders
|
|
2381
2404
|
statefulTableOptions.data = react.useMemo(() => (statefulTableOptions.state.isLoading ||
|
|
2382
2405
|
statefulTableOptions.state.showSkeletons) &&
|
|
@@ -2395,7 +2418,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2395
2418
|
const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
|
2396
2419
|
onColumnSizingInfoChange,
|
|
2397
2420
|
onGroupingChange,
|
|
2398
|
-
onPaginationChange }, statefulTableOptions), { globalFilterFn: (
|
|
2421
|
+
onPaginationChange }, statefulTableOptions), { globalFilterFn: (_1 = statefulTableOptions.filterFns) === null || _1 === void 0 ? void 0 : _1[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
|
|
2399
2422
|
table.refs = {
|
|
2400
2423
|
actionCellRef,
|
|
2401
2424
|
allSelectableRowIdsRef,
|
|
@@ -2412,7 +2435,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2412
2435
|
topToolbarRef,
|
|
2413
2436
|
};
|
|
2414
2437
|
table.setActionCell =
|
|
2415
|
-
(
|
|
2438
|
+
(_2 = statefulTableOptions.onActionCellChange) !== null && _2 !== void 0 ? _2 : setActionCell;
|
|
2416
2439
|
table.setCreatingRow = (row) => {
|
|
2417
2440
|
var _a, _b;
|
|
2418
2441
|
let _row = row;
|
|
@@ -2422,38 +2445,39 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2422
2445
|
(_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
|
|
2423
2446
|
};
|
|
2424
2447
|
table.setColumnFilterFns =
|
|
2425
|
-
(
|
|
2426
|
-
table.setDensity = (
|
|
2448
|
+
(_3 = statefulTableOptions.onColumnFilterFnsChange) !== null && _3 !== void 0 ? _3 : setColumnFilterFns;
|
|
2449
|
+
table.setDensity = (_4 = statefulTableOptions.onDensityChange) !== null && _4 !== void 0 ? _4 : setDensity;
|
|
2427
2450
|
table.setDraggingColumn =
|
|
2428
|
-
(
|
|
2451
|
+
(_5 = statefulTableOptions.onDraggingColumnChange) !== null && _5 !== void 0 ? _5 : setDraggingColumn;
|
|
2429
2452
|
table.setDraggingRow =
|
|
2430
|
-
(
|
|
2453
|
+
(_6 = statefulTableOptions.onDraggingRowChange) !== null && _6 !== void 0 ? _6 : setDraggingRow;
|
|
2431
2454
|
table.setEditingCell =
|
|
2432
|
-
(
|
|
2455
|
+
(_7 = statefulTableOptions.onEditingCellChange) !== null && _7 !== void 0 ? _7 : setEditingCell;
|
|
2433
2456
|
table.setEditingRow =
|
|
2434
|
-
(
|
|
2435
|
-
table.setFilters = (
|
|
2457
|
+
(_8 = statefulTableOptions.onEditingRowChange) !== null && _8 !== void 0 ? _8 : setEditingRow;
|
|
2458
|
+
table.setFilters = (_9 = statefulTableOptions.onFiltersChange) !== null && _9 !== void 0 ? _9 : setFilters;
|
|
2436
2459
|
table.setGlobalFilterFn =
|
|
2437
|
-
(
|
|
2460
|
+
(_10 = statefulTableOptions.onGlobalFilterFnChange) !== null && _10 !== void 0 ? _10 : setGlobalFilterFn;
|
|
2438
2461
|
table.setHoveredColumn =
|
|
2439
|
-
(
|
|
2462
|
+
(_11 = statefulTableOptions.onHoveredColumnChange) !== null && _11 !== void 0 ? _11 : setHoveredColumn;
|
|
2440
2463
|
table.setHoveredRow =
|
|
2441
|
-
(
|
|
2464
|
+
(_12 = statefulTableOptions.onHoveredRowChange) !== null && _12 !== void 0 ? _12 : setHoveredRow;
|
|
2442
2465
|
table.setSavedFilters = setSavedFilters;
|
|
2443
2466
|
table.setShowAlertBanner =
|
|
2444
|
-
(
|
|
2467
|
+
(_13 = statefulTableOptions.onShowAlertBannerChange) !== null && _13 !== void 0 ? _13 : setShowAlertBanner;
|
|
2468
|
+
table._showAdvancedFiltersSetterRef = showAdvancedFiltersSetterRef;
|
|
2445
2469
|
table.setShowAdvancedFilters =
|
|
2446
|
-
(
|
|
2470
|
+
(_14 = statefulTableOptions.onShowAdvancedFiltersChange) !== null && _14 !== void 0 ? _14 : ((updater) => { var _a; return (_a = showAdvancedFiltersSetterRef.current) === null || _a === void 0 ? void 0 : _a.call(showAdvancedFiltersSetterRef, updater); });
|
|
2447
2471
|
table.setShowColumnFilters =
|
|
2448
|
-
(
|
|
2472
|
+
(_15 = statefulTableOptions.onShowColumnFiltersChange) !== null && _15 !== void 0 ? _15 : setShowColumnFilters;
|
|
2449
2473
|
table.setShowGlobalFilter =
|
|
2450
|
-
(
|
|
2474
|
+
(_16 = statefulTableOptions.onShowGlobalFilterChange) !== null && _16 !== void 0 ? _16 : setShowGlobalFilter;
|
|
2451
2475
|
table.setShowProgressBars = setShowProgressBars;
|
|
2452
2476
|
table.setShowToolbarDropZone =
|
|
2453
|
-
(
|
|
2477
|
+
(_17 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _17 !== void 0 ? _17 : setShowToolbarDropZone;
|
|
2454
2478
|
table.setNewEntryModal = setNewEntryModal;
|
|
2455
2479
|
table.setRowReorderingSelection =
|
|
2456
|
-
(
|
|
2480
|
+
(_18 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _18 !== void 0 ? _18 : setRowReorderingSelection;
|
|
2457
2481
|
table.addRow = handleAddRow({
|
|
2458
2482
|
setRowsState,
|
|
2459
2483
|
getRowId: resolveRowId,
|
|
@@ -2594,7 +2618,10 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
|
2594
2618
|
? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
|
|
2595
2619
|
: undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
|
|
2596
2620
|
const rowCount = realRows.length;
|
|
2597
|
-
|
|
2621
|
+
//matches the defaultRowHeight assumption in MRT_TableBodyRow so the
|
|
2622
|
+
//initial estimate (before measureElement corrects it for dynamic content)
|
|
2623
|
+
//doesn't cause scroll-position drift
|
|
2624
|
+
const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
|
|
2598
2625
|
const rowVirtualizer = reactVirtual.useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
|
|
2599
2626
|
? expanded === true
|
|
2600
2627
|
? 100
|
|
@@ -2614,6 +2641,20 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
|
2614
2641
|
return rowVirtualizer;
|
|
2615
2642
|
};
|
|
2616
2643
|
|
|
2644
|
+
const MRT_AdvancedFiltersContext = react.createContext(null);
|
|
2645
|
+
const useMRT_AdvancedFiltersContext = () => {
|
|
2646
|
+
const ctx = react.useContext(MRT_AdvancedFiltersContext);
|
|
2647
|
+
if (!ctx)
|
|
2648
|
+
throw new Error('useMRT_AdvancedFiltersContext must be used within MRT_AdvancedFiltersProvider');
|
|
2649
|
+
return ctx;
|
|
2650
|
+
};
|
|
2651
|
+
const MRT_AdvancedFiltersProvider = ({ children, initialOpen = false, setterRef, }) => {
|
|
2652
|
+
const [showAdvancedFilters, setShowAdvancedFilters] = react.useState(initialOpen);
|
|
2653
|
+
// Always keep ref in sync so table.setShowAdvancedFilters works externally
|
|
2654
|
+
setterRef.current = setShowAdvancedFilters;
|
|
2655
|
+
return (jsxRuntime.jsx(MRT_AdvancedFiltersContext.Provider, { value: { showAdvancedFilters, setShowAdvancedFilters }, children: children }));
|
|
2656
|
+
};
|
|
2657
|
+
|
|
2617
2658
|
// Internal Select option value strings — converted to/from actual boolean in RHF state.
|
|
2618
2659
|
const BOOLEAN_OPTION_TRUE = 'true';
|
|
2619
2660
|
const BOOLEAN_OPTION_FALSE = 'false';
|
|
@@ -4375,7 +4416,7 @@ const MRT_AdvancedFiltersRuleRow = ({ filterableColumns, isFirst, isPinned, logi
|
|
|
4375
4416
|
xs: 'auto minmax(0, 1fr) minmax(0, 0.7fr) minmax(0, 1.5fr) auto auto',
|
|
4376
4417
|
},
|
|
4377
4418
|
width: '100%',
|
|
4378
|
-
}, children: [jsxRuntime.jsxs(TextField, { disabled: !isFirst, fullWidth: true, onChange: (event) => onUpdateLogicOperator(event.target.value), select: true, size: "small", value: logicOperator, variant: "outlined", children: [jsxRuntime.jsx(MenuItem, { value: "and", children: localization.and }), jsxRuntime.jsx(MenuItem, { value: "or", children: localization.or })] }), jsxRuntime.jsx(TextField, { fullWidth: true, label: localization.columns, onChange: (event) => handleColumnChange(event.target.value), select: true, size: "small", value: selectedColumn.id, variant: "outlined", children: filterableColumns.map((column) => (jsxRuntime.jsx(MenuItem, { value: column.id, children: column.columnDef.header || localization[column.id] || column.id }, column.id))) }), jsxRuntime.jsx(TextField, { fullWidth: true, label: localization.filterOperator, onChange: (event) => handleOperatorChange(event.target.value), select: true, size: "small", value: selectedOperator.id, variant: "outlined", children: availableOperators.map((operator) => (jsxRuntime.jsx(MenuItem, { value: operator.id, children: getLocalizedFilterOperatorLabel(localization, operator.id, operator.label) }, operator.id))) }), jsxRuntime.jsx(Box, { "data-testid": FILTER_RULE_VALUE_TEST_ID, onKeyDown: (event) => {
|
|
4419
|
+
}, children: [jsxRuntime.jsxs(TextField, { disabled: !isFirst, fullWidth: true, onChange: (event) => onUpdateLogicOperator(event.target.value), select: true, size: "small", value: logicOperator, variant: "outlined", "data-testid": "logic-operator", children: [jsxRuntime.jsx(MenuItem, { value: "and", children: localization.and }), jsxRuntime.jsx(MenuItem, { value: "or", children: localization.or })] }), jsxRuntime.jsx(TextField, { fullWidth: true, label: localization.columns, onChange: (event) => handleColumnChange(event.target.value), select: true, size: "small", value: selectedColumn.id, variant: "outlined", children: filterableColumns.map((column) => (jsxRuntime.jsx(MenuItem, { value: column.id, children: column.columnDef.header || localization[column.id] || column.id }, column.id))) }), jsxRuntime.jsx(TextField, { fullWidth: true, label: localization.filterOperator, onChange: (event) => handleOperatorChange(event.target.value), select: true, size: "small", value: selectedOperator.id, variant: "outlined", children: availableOperators.map((operator) => (jsxRuntime.jsx(MenuItem, { value: operator.id, children: getLocalizedFilterOperatorLabel(localization, operator.id, operator.label) }, operator.id))) }), jsxRuntime.jsx(Box, { "data-testid": FILTER_RULE_VALUE_TEST_ID, onKeyDown: (event) => {
|
|
4379
4420
|
const shouldApplyOnEnter = selectedOperator.valueShape !== 'multi';
|
|
4380
4421
|
if (event.key === 'Enter' && onApply && shouldApplyOnEnter) {
|
|
4381
4422
|
// Prevent the Enter from bubbling to MUI Drawer/Modal infrastructure
|
|
@@ -4601,8 +4642,8 @@ const useMRT_AdvancedFiltersDraft = (table) => {
|
|
|
4601
4642
|
* Extracted so that hooks are never called conditionally in the parent guard.
|
|
4602
4643
|
*/
|
|
4603
4644
|
const MRT_AdvancedFiltersContent = ({ table, }) => {
|
|
4604
|
-
const {
|
|
4605
|
-
const { showAdvancedFilters } =
|
|
4645
|
+
const { options: { icons: { CloseIcon }, localization, }, setFilters, } = table;
|
|
4646
|
+
const { showAdvancedFilters, setShowAdvancedFilters } = useMRT_AdvancedFiltersContext();
|
|
4606
4647
|
// All draft editing logic lives in this hook
|
|
4607
4648
|
const { addRule, clearRules, discardChanges, draftFilters, filterableColumns, hasInvalidRules, hasUnappliedChanges, markApplied, pinRule, removeRule, unpinRule, updateLogicOperator, updateRule, } = useMRT_AdvancedFiltersDraft(table);
|
|
4608
4649
|
// Close the drawer without applying changes
|
|
@@ -5378,7 +5419,7 @@ const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
|
|
|
5378
5419
|
justifyContent: 'space-between',
|
|
5379
5420
|
gap: 1,
|
|
5380
5421
|
minWidth: 180,
|
|
5381
|
-
}, children: [jsxRuntime.jsx(ListItemText, { onClick: () => handleSelectFilter(savedFilter), primary: savedFilter.name, sx: { cursor: 'pointer', flexGrow: 1 } }), onDeleteSavedFilter && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Divider, { flexItem: true, orientation: "vertical" }), jsxRuntime.jsx(DeleteForeverIcon, { color: "error", fontSize: "small", onClick: (event) => {
|
|
5422
|
+
}, children: [jsxRuntime.jsx(ListItemText, { onClick: () => handleSelectFilter(savedFilter), primary: savedFilter.name, sx: { cursor: 'pointer', flexGrow: 1 }, "data-testid": "saved-filter-item" }), onDeleteSavedFilter && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Divider, { flexItem: true, orientation: "vertical" }), jsxRuntime.jsx(DeleteForeverIcon, { color: "error", fontSize: "small", onClick: (event) => {
|
|
5382
5423
|
event.stopPropagation();
|
|
5383
5424
|
handleDeleteFilter(savedFilter.name);
|
|
5384
5425
|
}, sx: { cursor: 'pointer', flexShrink: 0 } })] }))] }, savedFilter.name)))] })] }));
|
|
@@ -5539,21 +5580,24 @@ const MRT_ShowHideColumnsButton = (_a) => {
|
|
|
5539
5580
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns, children: jsxRuntime.jsx(Button, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick, size: "small", startIcon: jsxRuntime.jsx(ViewColumnIcon, { fontSize: "small" }), variant: "text" }, rest, { title: undefined, children: localization.showHideColumns })) }), anchorEl && (jsxRuntime.jsx(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))] }));
|
|
5540
5581
|
};
|
|
5541
5582
|
|
|
5542
|
-
const
|
|
5583
|
+
const MRT_ToggleAdvancedFiltersButtonInner = (_a) => {
|
|
5543
5584
|
var _b;
|
|
5544
5585
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
5545
|
-
const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, manualFiltering, },
|
|
5546
|
-
const { filters
|
|
5586
|
+
const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, manualFiltering, }, } = table;
|
|
5587
|
+
const { filters } = getState();
|
|
5588
|
+
const { showAdvancedFilters, setShowAdvancedFilters } = useMRT_AdvancedFiltersContext();
|
|
5547
5589
|
if (!manualFiltering) {
|
|
5548
5590
|
return null;
|
|
5549
5591
|
}
|
|
5550
|
-
// Count applied filter rules to display on the badge
|
|
5551
5592
|
const activeFilterCount = filters.rules.length;
|
|
5552
|
-
const handleToggleShowAdvancedFilters = () => {
|
|
5553
|
-
setShowAdvancedFilters((prev) => !prev);
|
|
5554
|
-
};
|
|
5555
5593
|
const FilterIcon = showAdvancedFilters ? FilterListOffIcon : FilterListIcon;
|
|
5556
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showAdvancedFilters, children: jsxRuntime.jsx(Badge, { badgeContent: activeFilterCount, color: "primary", invisible: activeFilterCount === 0, children: jsxRuntime.jsx(Button, Object.assign({ "aria-label": localization.showAdvancedFilters, onClick:
|
|
5594
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showAdvancedFilters, children: jsxRuntime.jsx(Badge, { badgeContent: activeFilterCount, color: "primary", invisible: activeFilterCount === 0, children: jsxRuntime.jsx(Button, Object.assign({ "aria-label": localization.showAdvancedFilters, onClick: () => setShowAdvancedFilters((prev) => !prev), size: "small", startIcon: jsxRuntime.jsx(FilterIcon, {}), variant: "text" }, rest, { title: undefined, children: localization.filters })) }) }), jsxRuntime.jsx(MRT_AdvancedFilters, { table: table })] }));
|
|
5595
|
+
};
|
|
5596
|
+
const MRT_ToggleAdvancedFiltersButton = (_a) => {
|
|
5597
|
+
var _b, _c;
|
|
5598
|
+
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
5599
|
+
const initialOpen = (_c = (_b = table.options.initialState) === null || _b === void 0 ? void 0 : _b.showAdvancedFilters) !== null && _c !== void 0 ? _c : Boolean(table.options.enableAdvancedFilters && table.options.manualFiltering);
|
|
5600
|
+
return (jsxRuntime.jsx(MRT_AdvancedFiltersProvider, { initialOpen: initialOpen, setterRef: table._showAdvancedFiltersSetterRef, children: jsxRuntime.jsx(MRT_ToggleAdvancedFiltersButtonInner, Object.assign({ table: table }, rest)) }));
|
|
5557
5601
|
};
|
|
5558
5602
|
|
|
5559
5603
|
const MRT_ToggleDensePaddingButton = (_a) => {
|
|
@@ -6440,8 +6484,7 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowInde
|
|
|
6440
6484
|
|
|
6441
6485
|
const MRT_TableBodyCell = (_a) => {
|
|
6442
6486
|
var _b, _c, _d, _e;
|
|
6443
|
-
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
|
|
6444
|
-
const theme = styles.useTheme();
|
|
6487
|
+
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table", "theme"]);
|
|
6445
6488
|
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
|
6446
6489
|
const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
|
6447
6490
|
const { column, row } = cell;
|
|
@@ -6640,8 +6683,7 @@ const MRT_TableDetailPanel = (_a) => {
|
|
|
6640
6683
|
|
|
6641
6684
|
const MRT_TableBodyRow = (_a) => {
|
|
6642
6685
|
var _b, _c, _d, _f;
|
|
6643
|
-
var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
|
|
6644
|
-
const theme = styles.useTheme();
|
|
6686
|
+
var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, theme, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "theme", "virtualRow"]);
|
|
6645
6687
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
|
6646
6688
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, rowPinning, } = getState();
|
|
6647
6689
|
const visibleCells = row.getVisibleCells();
|
|
@@ -6706,7 +6748,11 @@ const MRT_TableBodyRow = (_a) => {
|
|
|
6706
6748
|
? Object.assign({ backgroundColor: styles.alpha(cellHighlightColorHover, 0.3) }, commonCellBeforeAfterStyles) : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
|
|
6707
6749
|
? `${bottomPinnedIndex * rowHeight +
|
|
6708
6750
|
(enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
|
|
6709
|
-
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1,
|
|
6751
|
+
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1,
|
|
6752
|
+
//prevents the browser from "anchoring" scroll position to this
|
|
6753
|
+
//row as virtualized rows are recycled in and out — see
|
|
6754
|
+
//tanstack/virtual#860
|
|
6755
|
+
overflowAnchor: virtualRow ? 'none' : undefined, position: virtualRow
|
|
6710
6756
|
? 'absolute'
|
|
6711
6757
|
: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
|
|
6712
6758
|
? 'sticky'
|
|
@@ -6729,6 +6775,7 @@ const MRT_TableBodyRow = (_a) => {
|
|
|
6729
6775
|
staticColumnIndex,
|
|
6730
6776
|
staticRowIndex,
|
|
6731
6777
|
table,
|
|
6778
|
+
theme,
|
|
6732
6779
|
};
|
|
6733
6780
|
const key = `${cell.id}-${staticRowIndex}`;
|
|
6734
6781
|
return cell ? (memoMode === 'cells' &&
|
|
@@ -6746,6 +6793,10 @@ const MRT_TableBody = (_a) => {
|
|
|
6746
6793
|
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
|
6747
6794
|
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
|
6748
6795
|
const { columnFilters, globalFilter, rowPinning } = getState();
|
|
6796
|
+
//read once per body render instead of once per row/cell, since every
|
|
6797
|
+
//subscriber otherwise pays its own useContext lookup on every mount
|
|
6798
|
+
//(noticeable when a burst of new rows mounts on a fast scroll jump)
|
|
6799
|
+
const theme = styles.useTheme();
|
|
6749
6800
|
const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
|
|
6750
6801
|
const tableHeadHeight = (enableStickyHeader && ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
|
|
6751
6802
|
const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
|
|
@@ -6764,6 +6815,7 @@ const MRT_TableBody = (_a) => {
|
|
|
6764
6815
|
columnVirtualizer,
|
|
6765
6816
|
numRows: rows.length,
|
|
6766
6817
|
table,
|
|
6818
|
+
theme,
|
|
6767
6819
|
};
|
|
6768
6820
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
|
6769
6821
|
getIsSomeRowsPinned('top') && (jsxRuntime.jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, staticRowIndex) => {
|
|
@@ -7480,7 +7532,7 @@ const MRT_Table = (_a) => {
|
|
|
7480
7532
|
columnVirtualizer,
|
|
7481
7533
|
table,
|
|
7482
7534
|
};
|
|
7483
|
-
return (jsxRuntime.jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
|
|
7535
|
+
return (jsxRuntime.jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsxRuntime.jsx("caption", { children: Caption }), enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
|
|
7484
7536
|
};
|
|
7485
7537
|
|
|
7486
7538
|
const MRT_TableLoadingOverlay = (_a) => {
|
|
@@ -7506,7 +7558,7 @@ const MRT_TableLoadingOverlay = (_a) => {
|
|
|
7506
7558
|
|
|
7507
7559
|
const MRT_TableContainer = (_a) => {
|
|
7508
7560
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
7509
|
-
const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
|
|
7561
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
|
|
7510
7562
|
const { actionCell, creatingRow, editingRow, isLoading, showLoadingOverlay, newEntryModal, } = getState();
|
|
7511
7563
|
const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
|
|
7512
7564
|
const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
|
|
@@ -7522,7 +7574,9 @@ const MRT_TableContainer = (_a) => {
|
|
|
7522
7574
|
tableContainerProps.ref.current = node;
|
|
7523
7575
|
}
|
|
7524
7576
|
}
|
|
7525
|
-
}, style: Object.assign({}, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ flex: '1 1 auto', height: '100%', display: 'flex', flexDirection: 'column', maxWidth: '100%', overflow: 'auto', position: 'relative' },
|
|
7577
|
+
}, style: Object.assign({}, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign(Object.assign({ flex: '1 1 auto', height: '100%', display: 'flex', flexDirection: 'column', maxWidth: '100%', overflow: 'auto', position: 'relative' }, (enableRowVirtualization
|
|
7578
|
+
? { contain: 'paint', willChange: 'transform' }
|
|
7579
|
+
: null)), parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsxRuntime.jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table })), newEntryModal.open && jsxRuntime.jsx(MRT_NewEntryModal, { table: table }), enableCellActions && actionCell && jsxRuntime.jsx(MRT_CellActionMenu, { table: table })] })));
|
|
7526
7580
|
};
|
|
7527
7581
|
|
|
7528
7582
|
const MRT_TablePaper = (_a) => {
|
|
@@ -7823,8 +7877,14 @@ function createColumnDef(column) {
|
|
|
7823
7877
|
}
|
|
7824
7878
|
return resolver.createColumnDef(column);
|
|
7825
7879
|
}
|
|
7826
|
-
function createColumnDefs(columns) {
|
|
7827
|
-
return columns.map((column) =>
|
|
7880
|
+
function createColumnDefs(columns, extendColumns) {
|
|
7881
|
+
return columns.map((column) => {
|
|
7882
|
+
const resolved = createColumnDef(column);
|
|
7883
|
+
const extension = extendColumns === null || extendColumns === void 0 ? void 0 : extendColumns.find((ext) => ext.accessorKey === column.accessorKey);
|
|
7884
|
+
if (extension)
|
|
7885
|
+
return Object.assign(Object.assign({}, resolved), extension);
|
|
7886
|
+
return resolved;
|
|
7887
|
+
});
|
|
7828
7888
|
}
|
|
7829
7889
|
|
|
7830
7890
|
/** Builds the initial MRT_ActiveExportsState from availableExports.
|
|
@@ -7838,7 +7898,7 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
|
|
|
7838
7898
|
return {
|
|
7839
7899
|
selectedFormat: uniqueFormats[0],
|
|
7840
7900
|
selectedExports: exportEntries.length > 0 ? [exportEntries[0].name] : [],
|
|
7841
|
-
grouped: false,
|
|
7901
|
+
grouped: savedActiveExports ? savedActiveExports.grouped : false,
|
|
7842
7902
|
};
|
|
7843
7903
|
}
|
|
7844
7904
|
return (savedActiveExports !== null && savedActiveExports !== void 0 ? savedActiveExports : {
|
|
@@ -7848,10 +7908,10 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
|
|
|
7848
7908
|
});
|
|
7849
7909
|
};
|
|
7850
7910
|
const MaterialReactServerTableInstance = (_a) => {
|
|
7851
|
-
var _b;
|
|
7852
|
-
var { config, loadData, saveState, getAllSelectableRowIds, getTotalRows, onSaveFilters, onDeleteSavedFilter, initialSavedFilters, loadExport, exportPermissions, enableNewEntryButton, actions, deleteRowsFn, editRowFn, enableResetState, resetState } = _a,
|
|
7911
|
+
var _b, _c;
|
|
7912
|
+
var { config, loadData, saveState, getAllSelectableRowIds, getTotalRows, onSaveFilters, onDeleteSavedFilter, initialSavedFilters, loadExport, exportPermissions, enableNewEntryButton, actions, deleteRowsFn, editRowFn, enableResetState, resetState, extendColumns } = _a,
|
|
7853
7913
|
// Extra MRT_TableOptions props (e.g. formConfig) passed directly through to useMaterialReactTable
|
|
7854
|
-
tableOptionsOverrides = __rest(_a, ["config", "loadData", "saveState", "getAllSelectableRowIds", "getTotalRows", "onSaveFilters", "onDeleteSavedFilter", "initialSavedFilters", "loadExport", "exportPermissions", "enableNewEntryButton", "actions", "deleteRowsFn", "editRowFn", "enableResetState", "resetState"]);
|
|
7914
|
+
tableOptionsOverrides = __rest(_a, ["config", "loadData", "saveState", "getAllSelectableRowIds", "getTotalRows", "onSaveFilters", "onDeleteSavedFilter", "initialSavedFilters", "loadExport", "exportPermissions", "enableNewEntryButton", "actions", "deleteRowsFn", "editRowFn", "enableResetState", "resetState", "extendColumns"]);
|
|
7855
7915
|
const [pageCount, setPageCount] = react.useState(undefined);
|
|
7856
7916
|
const [rowCount, setRowCount] = react.useState(0);
|
|
7857
7917
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
@@ -7879,7 +7939,7 @@ const MaterialReactServerTableInstance = (_a) => {
|
|
|
7879
7939
|
initialState: Object.assign(Object.assign({}, config.initialState), { activeExports: buildInitialExportState(allowedExports, (_b = config.initialState) === null || _b === void 0 ? void 0 : _b.activeExports) }),
|
|
7880
7940
|
saveState,
|
|
7881
7941
|
});
|
|
7882
|
-
const columns = react.useMemo(() => createColumnDefs(config.columns), [config.columns]);
|
|
7942
|
+
const columns = react.useMemo(() => createColumnDefs(config.columns, extendColumns), [config.columns, extendColumns]);
|
|
7883
7943
|
const wrappedGetTotalRows = react.useMemo(() => getTotalRows
|
|
7884
7944
|
? (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7885
7945
|
const count = yield getTotalRows(props);
|
|
@@ -7894,8 +7954,7 @@ const MaterialReactServerTableInstance = (_a) => {
|
|
|
7894
7954
|
resetState, enableRowActions: true, renderRowActions: RowActionsCell, positionActionsColumn: 'last', actions: actions, getAllSelectableRowIds, getTotalRows: wrappedGetTotalRows, deleteRowsFn,
|
|
7895
7955
|
editRowFn,
|
|
7896
7956
|
onSaveFilters,
|
|
7897
|
-
onDeleteSavedFilter,
|
|
7898
|
-
initialSavedFilters, availableExports: hasAvailableExports ? allowedExports : undefined, loadExport: hasAvailableExports ? loadExport : undefined, enableNewEntryButton }, tableOptionsOverrides), handlers));
|
|
7957
|
+
onDeleteSavedFilter, initialSavedFilters: initialSavedFilters !== null && initialSavedFilters !== void 0 ? initialSavedFilters : (_c = config.initialState) === null || _c === void 0 ? void 0 : _c.savedFilters, availableExports: hasAvailableExports ? allowedExports : undefined, loadExport: hasAvailableExports ? loadExport : undefined, enableNewEntryButton }, tableOptionsOverrides), handlers));
|
|
7899
7958
|
const fetchData = react.useCallback((tableInstance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7900
7959
|
setIsLoading(true);
|
|
7901
7960
|
try {
|