@dooherceg/material-react-table 4.1.7 → 4.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,36 +1,36 @@
1
1
  'use strict';
2
2
 
3
- var reactTable = require('@tanstack/react-table');
4
3
  var react = require('react');
4
+ var compilerRuntime = require('react/compiler-runtime');
5
+ var IconButton = require('@mui/material/IconButton');
6
+ var Tooltip = require('@mui/material/Tooltip');
7
+ var reactStore = require('@tanstack/react-store');
8
+ var Menu = require('@mui/material/Menu');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ var styles = require('@mui/material/styles');
11
+ var reactTable = require('@tanstack/react-table');
12
+ var Checkbox = require('@mui/material/Checkbox');
13
+ var Radio = require('@mui/material/Radio');
5
14
  var CancelIcon = require('@mui/icons-material/Cancel');
6
15
  var Button = require('@mui/material/Button');
7
16
  var Dialog = require('@mui/material/Dialog');
8
17
  var DialogActions = require('@mui/material/DialogActions');
9
18
  var DialogContent = require('@mui/material/DialogContent');
10
19
  var DialogTitle = require('@mui/material/DialogTitle');
11
- var IconButton = require('@mui/material/IconButton');
12
20
  var Stack = require('@mui/material/Stack');
13
- var compilerRuntime = require('react/compiler-runtime');
14
21
  var DeleteOutlineIcon = require('@mui/icons-material/DeleteOutline');
15
- var Tooltip = require('@mui/material/Tooltip');
16
- var styles = require('@mui/material/styles');
17
- var jsxRuntime = require('react/jsx-runtime');
18
22
  var EditNoteIcon = require('@mui/icons-material/EditNote');
19
23
  var FileDownloadIcon = require('@mui/icons-material/FileDownload');
20
24
  var PrintIcon = require('@mui/icons-material/Print');
21
- var Checkbox = require('@mui/material/Checkbox');
22
25
  var CircularProgress = require('@mui/material/CircularProgress');
23
26
  var Divider = require('@mui/material/Divider');
24
27
  var FormControl = require('@mui/material/FormControl');
25
28
  var FormControlLabel = require('@mui/material/FormControlLabel');
26
- var Menu = require('@mui/material/Menu');
27
29
  var MenuItem = require('@mui/material/MenuItem');
28
- var Radio = require('@mui/material/Radio');
29
30
  var RadioGroup = require('@mui/material/RadioGroup');
30
31
  var Typography = require('@mui/material/Typography');
31
32
  var printJS = require('print-js');
32
33
  var notistack = require('notistack');
33
- var reactStore = require('@tanstack/react-store');
34
34
  var SubdirectoryArrowLeftIcon = require('@mui/icons-material/SubdirectoryArrowLeft');
35
35
  var VerticalAlignTopIcon = require('@mui/icons-material/VerticalAlignTop');
36
36
  var Box = require('@mui/material/Box');
@@ -128,163 +128,133 @@ var AccordionSummary = require('@mui/material/AccordionSummary');
128
128
  var Modal = require('@mui/material/Modal');
129
129
  var AlertTitle = require('@mui/material/AlertTitle');
130
130
 
131
- const MRT_SortingFns = {
132
- ...reactTable.sortFns
133
- };
134
-
135
- const getColumnId = columnDef => columnDef.id ?? columnDef.accessorKey?.toString?.() ?? columnDef.header;
136
- const getAllLeafColumnDefs = columns => {
137
- const allLeafColumnDefs = [];
138
- const getLeafColumns = cols => {
139
- cols.forEach(col => {
140
- if (col.columns) {
141
- getLeafColumns(col.columns);
142
- } else {
143
- allLeafColumnDefs.push(col);
144
- }
145
- });
146
- };
147
- getLeafColumns(columns);
148
- return allLeafColumnDefs;
149
- };
150
-
151
- // Must run on the raw, user-authored column array — by the time TanStack
152
- // resolves column.columnDef.size (via constructColumn's `{...defaultColumn,
153
- // ...columnDef}` merge), a column the consumer never gave a size backfills
154
- // MRT_DefaultColumn.size (180) directly into columnDef.size, indistinguishable
155
- // from a column that explicitly asked for 180. Checking `size === undefined`
156
- // here, before that merge happens, is the only point where the distinction
157
- // still exists.
158
- const getAutoSizeCandidateColumnIds = columnDefs => new Set(getAllLeafColumnDefs(columnDefs).filter(columnDef => columnDef.size === undefined).map(columnDef => getColumnId(columnDef)));
159
- const prepareColumns = ({
160
- columnDefs,
161
- tableOptions
131
+ const MRT_RowActionMenu = ({
132
+ anchorEl,
133
+ row,
134
+ setAnchorEl,
135
+ staticRowIndex,
136
+ table,
137
+ ...rest
162
138
  }) => {
163
139
  const {
164
- defaultDisplayColumn
165
- } = tableOptions;
166
- return columnDefs.map(columnDef => {
167
- //assign columnId
168
- if (!columnDef.id) columnDef.id = getColumnId(columnDef);
169
- //assign columnDefType
170
- if (!columnDef.columnDefType) columnDef.columnDefType = 'data';
171
- if (columnDef.columns?.length) {
172
- columnDef.columnDefType = 'group';
173
- //recursively prepare columns if this is a group column
174
- columnDef.columns = prepareColumns({
175
- columnDefs: columnDef.columns,
176
- tableOptions
177
- });
178
- } else if (columnDef.columnDefType === 'data') {
179
- // Multi-aggregation arrays (e.g. aggregationFn: ['count', 'mean']) are
180
- // handled natively by v9's rowAggregationFeature — it resolves each
181
- // registered name and returns a keyed result object, so no manual
182
- // mapping is needed here anymore (v8 required it).
183
-
184
- //assign sortFns
185
- if (Object.keys(MRT_SortingFns).includes(columnDef.sortFn)) {
186
- // @ts-expect-error - resolving the registered string name to its function
187
- columnDef.sortFn = MRT_SortingFns[columnDef.sortFn];
188
- }
189
- } else if (columnDef.columnDefType === 'display') {
190
- columnDef = {
191
- ...defaultDisplayColumn,
192
- ...columnDef,
193
- onClickIconTypeColumn: undefined
194
- };
140
+ options: {
141
+ mrtTheme: {
142
+ menuBackgroundColor
143
+ },
144
+ renderRowActionMenuItems
195
145
  }
196
- return columnDef;
146
+ } = table;
147
+ const density = reactStore.useSelector(table.store, state => state.density);
148
+ const menuItems = react.useMemo(() => {
149
+ const items = [];
150
+ const rowActionMenuItems = renderRowActionMenuItems?.({
151
+ closeMenu: () => setAnchorEl(null),
152
+ row,
153
+ staticRowIndex,
154
+ table
155
+ });
156
+ if (rowActionMenuItems?.length) items.push(...rowActionMenuItems);
157
+ return items;
158
+ }, [renderRowActionMenuItems, row, staticRowIndex, table]);
159
+ if (!menuItems.length) return null;
160
+ return /*#__PURE__*/jsxRuntime.jsx(Menu, {
161
+ MenuListProps: {
162
+ dense: density === 'compact',
163
+ sx: {
164
+ backgroundColor: menuBackgroundColor
165
+ }
166
+ },
167
+ anchorEl: anchorEl,
168
+ disableScrollLock: true,
169
+ onClick: event => event.stopPropagation(),
170
+ onClose: () => setAnchorEl(null),
171
+ open: !!anchorEl,
172
+ ...rest,
173
+ children: menuItems
197
174
  });
198
175
  };
199
- const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
200
- if (draggedColumn.getCanPin()) {
201
- draggedColumn.pin(targetColumn.getIsPinned());
202
- }
203
- const newColumnOrder = [...columnOrder];
204
- newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
205
- return newColumnOrder;
206
- };
207
176
 
208
- function defaultDisplayColumnProps({
209
- columnSpecificDefaults,
210
- header,
211
- id,
212
- size,
213
- tableOptions
214
- }) {
215
- const {
216
- defaultDisplayColumn,
217
- displayColumnDefOptions,
218
- localization
219
- } = tableOptions;
177
+ /** Resolved column limits shared by measurement, resizing, and cell layout. */
178
+ const getColumnSizeBounds = ({
179
+ minSize = 40,
180
+ maxSize = 1000
181
+ }) => {
182
+ const min = Number.isFinite(minSize) ? Math.max(0, minSize) : 40;
183
+ const max = Number.isNaN(maxSize) ? 1000 : Math.max(min, maxSize);
220
184
  return {
221
- ...defaultDisplayColumn,
222
- header: header ? localization[header] : '',
223
- size,
224
- ...columnSpecificDefaults,
225
- ...displayColumnDefOptions?.[id],
226
- id
185
+ minSize: min,
186
+ maxSize: max
227
187
  };
228
- }
229
- const showRowPinningColumn = tableOptions => {
230
- const {
231
- enableRowPinning,
232
- rowPinningDisplayMode
233
- } = tableOptions;
234
- return !!(enableRowPinning && !rowPinningDisplayMode?.startsWith('select'));
235
- };
236
- const showRowExpandColumn = tableOptions => {
237
- const {
238
- enableExpanding,
239
- enableGrouping,
240
- renderDetailPanel,
241
- state: {
242
- grouping
243
- }
244
- } = tableOptions;
245
- return !!(enableExpanding || enableGrouping && grouping?.length || renderDetailPanel);
246
188
  };
247
- const showRowActionsColumn = tableOptions => {
189
+
190
+ // `el` normally has an explicit width/min-width/flex-basis (driven by the
191
+ // column's size CSS var), so nothing overflows and `getBoundingClientRect`
192
+ // just reports that forced size back — and `min-width` alone would otherwise
193
+ // stop it from ever shrinking below the current (large) column size.
194
+ // Temporarily switching to `max-content` with min-width/grow/shrink zeroed
195
+ // out lets the browser lay it out at its natural content size instead — then
196
+ // the inline style is restored before this task yields, so there's no
197
+ // visible flash.
198
+ const measureIntrinsicWidth = el => {
248
199
  const {
249
- enableEditing,
250
- enableRowActions
251
- } = tableOptions;
252
- return !!(enableRowActions || enableEditing);
200
+ width,
201
+ minWidth,
202
+ maxWidth,
203
+ flexBasis,
204
+ flexGrow,
205
+ flexShrink
206
+ } = el.style;
207
+ el.style.width = 'max-content';
208
+ el.style.minWidth = '0';
209
+ el.style.maxWidth = 'none';
210
+ el.style.flexBasis = 'auto';
211
+ el.style.flexGrow = '0';
212
+ el.style.flexShrink = '0';
213
+ const measured = Math.ceil(el.getBoundingClientRect().width);
214
+ el.style.width = width;
215
+ el.style.minWidth = minWidth;
216
+ el.style.maxWidth = maxWidth;
217
+ el.style.flexBasis = flexBasis;
218
+ el.style.flexGrow = flexGrow;
219
+ el.style.flexShrink = flexShrink;
220
+ return measured;
253
221
  };
254
- const showRowSelectionColumn = tableOptions => !!tableOptions.enableRowSelection;
255
- const showRowNumbersColumn = tableOptions => !!tableOptions.enableRowNumbers;
256
- const showRowSpacerColumn = tableOptions => tableOptions.layoutMode === 'grid-no-grow';
257
- const getLeadingDisplayColumnIds = tableOptions => [showRowPinningColumn(tableOptions) && 'mrt-row-pin', tableOptions.positionActionsColumn === 'first' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'first' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', showRowSelectionColumn(tableOptions) && '__check__', showRowNumbersColumn(tableOptions) && 'mrt-row-numbers'].filter(Boolean);
258
- const getTrailingDisplayColumnIds = tableOptions => [tableOptions.positionActionsColumn === 'last' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'last' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', showRowSpacerColumn(tableOptions) && 'mrt-row-spacer'].filter(Boolean);
259
-
260
- /** The internal ID used by TanStack Table for the row-selection checkbox column */
261
- const CHECKBOX_DISPLAY_COLUMN_ID = '__check__';
262
222
 
263
223
  /**
264
- * Forces mrt-row-expand to a fixed slot in columnOrder: right after the
265
- * checkbox column when row selection is enabled, otherwise the very first
266
- * column. This slot is independent of column pinning.
224
+ * The single measurement this library uses anywhere it decides "what's the
225
+ * right width for this column's current content" — shared by the resize
226
+ * handle's double-click autosize and the initial autosize effect
227
+ * (MRT_AutoSizeColumnsEffect), so both agree on the exact same answer.
228
+ *
229
+ * Driven purely by body cell content: the header title never contributes,
230
+ * so a long header simply ellipsizes when its values are narrower.
231
+ *
232
+ * Only the currently rendered (visible, due to row virtualization) body
233
+ * cells can be measured — a full-dataset autosize would require rendering
234
+ * every row off-screen, which defeats the point of virtualization.
267
235
  */
268
- const normalizeRowExpandColumnOrder = (tableOptions, columnOrder) => {
269
- if (!showRowExpandColumn(tableOptions)) {
270
- return columnOrder;
236
+ // Absorbs the sub-pixel rounding gap between measurement time (forced
237
+ // `max-content`, read via `Math.ceil`) and final render time (the actual
238
+ // `calc(var(--col-x-size) * 1px)` width) — without it, a column can land
239
+ // exactly 1px short of its own measured content and still clip/ellipsize.
240
+ const MEASUREMENT_SAFETY_MARGIN_PX = 2;
241
+ const computeAutoSizedColumnWidth = ({
242
+ bodyCellEls,
243
+ maxSize,
244
+ minSize
245
+ }) => {
246
+ let contentWidth = 0;
247
+ for (const cellEl of bodyCellEls ?? []) {
248
+ contentWidth = Math.max(contentWidth, measureIntrinsicWidth(cellEl));
271
249
  }
272
- const withoutExpand = columnOrder.filter(id => id !== 'mrt-row-expand');
273
- const expandIndex = showRowSelectionColumn(tableOptions) ? 1 : 0;
274
- return [...withoutExpand.slice(0, expandIndex), 'mrt-row-expand', ...withoutExpand.slice(expandIndex)];
275
- };
276
- const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
277
- const {
278
- state: {
279
- columnOrder: currentColumnOrderIds = []
280
- }
281
- } = tableOptions;
282
- const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
283
- const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
284
- const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map(columnDef => getColumnId(columnDef));
285
- let allLeafColumnDefIds = reset ? defaultColumnDefIds : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
286
- allLeafColumnDefIds = allLeafColumnDefIds.filter(colId => !leadingDisplayColIds.includes(colId) && !trailingDisplayColIds.includes(colId));
287
- return [...leadingDisplayColIds, ...allLeafColumnDefIds, ...trailingDisplayColIds];
250
+ if (contentWidth > 0) {
251
+ contentWidth = Math.ceil(contentWidth) + MEASUREMENT_SAFETY_MARGIN_PX;
252
+ }
253
+ const bounds = getColumnSizeBounds({
254
+ minSize,
255
+ maxSize
256
+ });
257
+ return Math.min(Math.max(contentWidth, bounds.minSize), bounds.maxSize);
288
258
  };
289
259
 
290
260
  const parseFromValuesOrFunc = (fn, arg) => fn instanceof Function ? fn(arg) : fn;
@@ -306,114 +276,399 @@ const getValueAndLabel = option => {
306
276
  };
307
277
  };
308
278
 
309
- const getMRT_Rows = (table, all) => {
310
- const {
311
- getCenterRows,
312
- getPrePaginatedRowModel,
313
- getRowModel,
314
- getTopRows,
315
- options: {
316
- enableRowPinning,
317
- rowPinningDisplayMode
318
- }
319
- } = table;
320
- let rows = !enableRowPinning || rowPinningDisplayMode?.includes('sticky') ? all ? getPrePaginatedRowModel().rows : getRowModel().rows : getCenterRows();
321
- // row pinning adjustments
322
- if (enableRowPinning && rowPinningDisplayMode?.includes('sticky')) {
323
- const centerPinnedRowIds = rows.filter(row => row.getIsPinned()).map(r => r.id);
324
- rows = [...getTopRows().filter(row => !centerPinnedRowIds.includes(row.id)), ...rows];
325
- }
326
- return rows;
279
+ // Loading indicators fade in after a short delay
280
+ // (`animation: ${mrtDelayedFadeIn}`), so fast responses don't flash them.
281
+ const mrtDelayedFadeIn = `${styles.keyframes`
282
+ from { opacity: 0; }
283
+ to { opacity: 1; }
284
+ `} 150ms ease-out 200ms both`;
285
+ const parseCSSVarId = id => id.replace(/[^a-zA-Z0-9]/g, '_');
286
+ const getMRTTheme = (mrtTheme, muiTheme) => {
287
+ const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
288
+ const baseBackgroundColor = muiTheme.palette.background.default;
289
+ return {
290
+ baseBackgroundColor,
291
+ cellNavigationOutlineColor: muiTheme.palette.primary.main,
292
+ draggingBorderColor: muiTheme.palette.primary.main,
293
+ matchHighlightColor: muiTheme.palette.mode === 'dark' ? styles.darken(muiTheme.palette.warning.dark, 0.25) : styles.lighten(muiTheme.palette.warning.light, 0.5),
294
+ menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07),
295
+ pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1),
296
+ selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2),
297
+ ...mrtThemeOverrides
298
+ };
327
299
  };
328
- const getIsRowSelected = ({
329
- row,
330
- table
300
+ const commonCellBeforeAfterStyles = {
301
+ content: '""',
302
+ height: '100%',
303
+ left: 0,
304
+ position: 'absolute',
305
+ top: 0,
306
+ width: '100%',
307
+ zIndex: -1
308
+ };
309
+ const getCommonPinnedCellStyles = ({
310
+ column,
311
+ table,
312
+ theme
331
313
  }) => {
332
314
  const {
333
- options: {
334
- enableRowSelection
315
+ baseBackgroundColor
316
+ } = table.options.mrtTheme;
317
+ return {
318
+ '&[data-pinned="true"]': {
319
+ '&:before': {
320
+ backgroundColor: baseBackgroundColor,
321
+ // Draw only the edge facing the center region, including when other
322
+ // pinned columns are hidden. Logical borders also handle RTL layouts.
323
+ borderInlineEnd: column?.getIsPinned() === 'start' && column.getIsLastColumn('start') ? `1px solid ${theme.palette.divider}` : undefined,
324
+ borderInlineStart: column?.getIsPinned() === 'end' && column.getIsFirstColumn('end') ? `1px solid ${theme.palette.divider}` : undefined,
325
+ boxSizing: 'border-box',
326
+ ...commonCellBeforeAfterStyles
327
+ }
335
328
  }
336
- } = table;
337
- return row.getIsSelected() || parseFromValuesOrFunc(enableRowSelection, row) && row.getCanSelectSubRows() && row.getIsAllSubRowsSelected();
329
+ };
338
330
  };
339
- const getMRT_RowSelectionHandler = ({
340
- row,
341
- staticRowIndex = 0,
342
- table
343
- }) => (event, value) => {
331
+
332
+ // Shared by cell styles and the imperative sizing subscription: resizing must
333
+ // update growth even when memoized cells do not render again.
334
+ const getColumnGrowWeight = (column, table) => {
335
+ const {
336
+ columnDef
337
+ } = column;
338
+ const sizing = table.getState().columnSizing[column.id];
339
+ const hasUserSize = sizing !== undefined && sizing !== table.refs.autoSizedColumnWidthsRef.current[column.id];
340
+ if (column.getIsPinned() || !table.refs.autoSizeColumnIdsRef.current.has(column.id) || hasUserSize) return 0;
341
+ if (typeof columnDef.grow === 'number') return Math.max(0, columnDef.grow);
342
+ return columnDef.grow === false ? 0 : 1;
343
+ };
344
+ const getCommonMRTCellStyles = ({
345
+ column,
346
+ header,
347
+ isDraggingColumn,
348
+ isHoveredColumn,
349
+ table,
350
+ tableCellProps,
351
+ theme
352
+ }) => {
344
353
  const {
345
- getState,
346
354
  options: {
347
- enableBatchRowSelection,
348
- enableMultiRowSelection,
349
- enableRowPinning,
350
- manualPagination,
351
- rowPinningDisplayMode
352
- },
353
- refs: {
354
- allSelectableRowIdsRef,
355
- lastSelectedRowId
355
+ enableColumnVirtualization,
356
+ layoutMode
356
357
  }
357
358
  } = table;
358
359
  const {
359
- pagination: {
360
- pageIndex,
361
- pageSize
362
- }
363
- } = getState();
364
- const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
365
- const wasCurrentRowChecked = getIsRowSelected({
366
- row,
367
- table
368
- });
369
-
370
- // ── Special case: deselecting a row while "select all pages" is active ────
371
- // Per spec: deselecting any single row while in global-select-all mode must
372
- // reset the selection to only the current page rows, minus the clicked row.
373
- if (allSelectableRowIdsRef.current.length > 0 && wasCurrentRowChecked) {
374
- allSelectableRowIdsRef.current = [];
375
- const newSelection = {};
376
- table.getPaginatedRowModel().rows.forEach(pageRow => {
377
- if (pageRow.id !== row.id && pageRow.getCanSelect()) {
378
- newSelection[pageRow.id] = true;
379
- }
380
- });
381
- table.setRowSelection(newSelection);
382
- lastSelectedRowId.current = row.id;
383
- return;
360
+ columnDef
361
+ } = column;
362
+ const {
363
+ columnDefType
364
+ } = columnDef;
365
+ const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
366
+ const {
367
+ minSize,
368
+ maxSize
369
+ } = getColumnSizeBounds(columnDef);
370
+ const sizeVar = `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`;
371
+ const boundedSize = Number.isFinite(maxSize) ? `clamp(${minSize}px, ${sizeVar}, ${maxSize}px)` : `max(${minSize}px, ${sizeVar})`;
372
+ const widthStyles = {
373
+ // Group headers span already-bounded child columns; the default leaf
374
+ // maximum must not truncate the sum of their widths.
375
+ maxWidth: columnDefType === 'group' ? sizeVar : Number.isFinite(maxSize) ? `${maxSize}px` : 'none',
376
+ minWidth: columnDefType === 'group' ? sizeVar : boundedSize,
377
+ width: columnDefType === 'group' ? sizeVar : boundedSize
378
+ };
379
+ if (layoutMode === 'grid' || layoutMode === 'grid-no-grow') {
380
+ const weight = getColumnGrowWeight(column, table);
381
+ const growVar = `var(--col-${parseCSSVarId(column.id)}-grow, ${weight})`;
382
+ widthStyles.flex = `${growVar} 0 auto`;
384
383
  }
385
-
386
- // toggle selection of this row (normal path)
387
- row.toggleSelected(value ?? !wasCurrentRowChecked);
388
- const changedRowIds = new Set([row.id]);
389
-
390
- // if shift key is pressed, select all rows between last selected and this one
391
- if (enableBatchRowSelection && enableMultiRowSelection && event.nativeEvent.shiftKey && lastSelectedRowId.current !== null) {
392
- const rows = getMRT_Rows(table, true);
393
- const lastIndex = rows.findIndex(r => r.id === lastSelectedRowId.current);
394
- if (lastIndex !== -1) {
395
- const isLastIndexChecked = getIsRowSelected({
396
- row: rows?.[lastIndex],
397
- table
398
- });
399
- const currentIndex = staticRowIndex + paginationOffset;
400
- const [start, end] = lastIndex < currentIndex ? [lastIndex, currentIndex] : [currentIndex, lastIndex];
401
-
402
- // toggle selection of all rows between last selected and this one
403
- // but only if the last selected row is not the same as the current one
404
- if (wasCurrentRowChecked !== isLastIndexChecked) {
405
- for (let i = start; i <= end; i++) {
406
- rows[i].toggleSelected(!wasCurrentRowChecked);
407
- changedRowIds.add(rows[i].id);
408
- }
409
- }
410
- }
384
+ const pinnedStyles = isColumnPinned ? {
385
+ ...getCommonPinnedCellStyles({
386
+ column,
387
+ table,
388
+ theme
389
+ }),
390
+ // Logical CSS insets (not left/right) so pinning stays correct in RTL
391
+ // without branching on theme.direction here.
392
+ insetInlineStart: isColumnPinned === 'start' ? `${column.getStart('start')}px` : undefined,
393
+ position: 'sticky',
394
+ insetInlineEnd: isColumnPinned === 'end' ? `${column.getAfter('end')}px` : undefined
395
+ } : {};
396
+ return {
397
+ backgroundColor: 'inherit',
398
+ backgroundImage: 'inherit',
399
+ display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
400
+ justifyContent: columnDefType === 'group' ? 'center' : layoutMode?.startsWith('grid') ? tableCellProps.align : undefined,
401
+ opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1,
402
+ position: 'relative',
403
+ transition: enableColumnVirtualization ? 'none' : `padding 150ms ease-in-out`,
404
+ zIndex: column.getIsResizing() || isDraggingColumn ? 2 : columnDefType !== 'group' && isColumnPinned ? 1 : 0,
405
+ '&:focus-visible': {
406
+ outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
407
+ outlineOffset: '-2px'
408
+ },
409
+ ...pinnedStyles,
410
+ ...widthStyles,
411
+ ...parseFromValuesOrFunc(tableCellProps?.sx, theme)
412
+ };
413
+ };
414
+ const getCommonToolbarStyles = ({
415
+ table
416
+ }) => ({
417
+ alignItems: 'flex-start',
418
+ backgroundColor: table.options.mrtTheme.baseBackgroundColor,
419
+ display: 'grid',
420
+ flexWrap: 'wrap-reverse',
421
+ position: 'relative',
422
+ transition: 'all 150ms ease-in-out',
423
+ zIndex: 1
424
+ });
425
+ const flipIconStyles = theme => theme.direction === 'rtl' ? {
426
+ style: {
427
+ transform: 'scaleX(-1)'
411
428
  }
429
+ } : undefined;
430
+ const getCommonTooltipProps = placement => ({
431
+ disableInteractive: true,
432
+ enterDelay: 1000,
433
+ enterNextDelay: 1000,
434
+ placement
435
+ });
412
436
 
413
- // record the last selected row id
414
- lastSelectedRowId.current = row.id;
437
+ // Stable, row-scoped hook for e2e/unit tests to target a specific default
438
+ // row action (e.g. edit, delete) without relying on DOM order or icon markup.
439
+ const getRowActionTestId = (rowId, actionName) => `mrt-row-${rowId}-${actionName}-action`;
415
440
 
416
- // if all sub rows were selected, unselect them
441
+ const commonIconButtonStyles = {
442
+ '&:hover': {
443
+ opacity: 1
444
+ },
445
+ height: '2rem',
446
+ ml: '10px',
447
+ opacity: 0.5,
448
+ transition: 'opacity 150ms',
449
+ width: '2rem'
450
+ };
451
+ const MRT_ToggleRowActionMenuButton = t0 => {
452
+ const $ = compilerRuntime.c(20);
453
+ let cell;
454
+ let rest;
455
+ let row;
456
+ let staticRowIndex;
457
+ let table;
458
+ if ($[0] !== t0) {
459
+ ({
460
+ cell,
461
+ row,
462
+ staticRowIndex,
463
+ table,
464
+ ...rest
465
+ } = t0);
466
+ $[0] = t0;
467
+ $[1] = cell;
468
+ $[2] = rest;
469
+ $[3] = row;
470
+ $[4] = staticRowIndex;
471
+ $[5] = table;
472
+ } else {
473
+ cell = $[1];
474
+ rest = $[2];
475
+ row = $[3];
476
+ staticRowIndex = $[4];
477
+ table = $[5];
478
+ }
479
+ const {
480
+ options: t1
481
+ } = table;
482
+ const {
483
+ icons: t2,
484
+ localization,
485
+ renderRowActionMenuItems,
486
+ renderRowActions
487
+ } = t1;
488
+ const {
489
+ MoreHorizIcon
490
+ } = t2;
491
+ const [anchorEl, setAnchorEl] = react.useState(null);
492
+ let t3;
493
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
494
+ t3 = event => {
495
+ event.stopPropagation();
496
+ event.preventDefault();
497
+ setAnchorEl(event.currentTarget);
498
+ };
499
+ $[6] = t3;
500
+ } else {
501
+ t3 = $[6];
502
+ }
503
+ const handleOpenRowActionMenu = t3;
504
+ let t4;
505
+ if ($[7] !== MoreHorizIcon || $[8] !== anchorEl || $[9] !== cell || $[10] !== localization || $[11] !== renderRowActionMenuItems || $[12] !== renderRowActions || $[13] !== rest || $[14] !== row || $[15] !== staticRowIndex || $[16] !== table) {
506
+ t4 = renderRowActions ? renderRowActions({
507
+ cell,
508
+ row,
509
+ staticRowIndex,
510
+ table
511
+ }) : renderRowActionMenuItems?.({
512
+ closeMenu: _temp$B,
513
+ row,
514
+ staticRowIndex,
515
+ table
516
+ })?.length ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
517
+ children: [/*#__PURE__*/jsxRuntime.jsx(Tooltip, {
518
+ ...getCommonTooltipProps(),
519
+ title: localization.rowActions,
520
+ children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
521
+ "aria-label": localization.rowActions,
522
+ onClick: handleOpenRowActionMenu,
523
+ size: "small",
524
+ sx: commonIconButtonStyles,
525
+ ...rest,
526
+ children: /*#__PURE__*/jsxRuntime.jsx(MoreHorizIcon, {})
527
+ })
528
+ }), /*#__PURE__*/jsxRuntime.jsx(MRT_RowActionMenu, {
529
+ anchorEl: anchorEl,
530
+ row: row,
531
+ setAnchorEl: setAnchorEl,
532
+ staticRowIndex: staticRowIndex,
533
+ table: table
534
+ })]
535
+ }) : null;
536
+ $[7] = MoreHorizIcon;
537
+ $[8] = anchorEl;
538
+ $[9] = cell;
539
+ $[10] = localization;
540
+ $[11] = renderRowActionMenuItems;
541
+ $[12] = renderRowActions;
542
+ $[13] = rest;
543
+ $[14] = row;
544
+ $[15] = staticRowIndex;
545
+ $[16] = table;
546
+ $[17] = t4;
547
+ } else {
548
+ t4 = $[17];
549
+ }
550
+ let t5;
551
+ if ($[18] !== t4) {
552
+ t5 = /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
553
+ children: t4
554
+ });
555
+ $[18] = t4;
556
+ $[19] = t5;
557
+ } else {
558
+ t5 = $[19];
559
+ }
560
+ return t5;
561
+ };
562
+ function _temp$B() {}
563
+
564
+ const getMRT_Rows = (table, all) => {
565
+ const {
566
+ getCenterRows,
567
+ getPrePaginatedRowModel,
568
+ getRowModel,
569
+ getTopRows,
570
+ options: {
571
+ enableRowPinning,
572
+ rowPinningDisplayMode
573
+ }
574
+ } = table;
575
+ let rows = !enableRowPinning || rowPinningDisplayMode?.includes('sticky') ? all ? getPrePaginatedRowModel().rows : getRowModel().rows : getCenterRows();
576
+ // row pinning adjustments
577
+ if (enableRowPinning && rowPinningDisplayMode?.includes('sticky')) {
578
+ const centerPinnedRowIds = rows.filter(row => row.getIsPinned()).map(r => r.id);
579
+ rows = [...getTopRows().filter(row => !centerPinnedRowIds.includes(row.id)), ...rows];
580
+ }
581
+ return rows;
582
+ };
583
+ const getIsRowSelected = ({
584
+ row,
585
+ table
586
+ }) => {
587
+ const {
588
+ options: {
589
+ enableRowSelection
590
+ }
591
+ } = table;
592
+ return row.getIsSelected() || parseFromValuesOrFunc(enableRowSelection, row) && row.getCanSelectSubRows() && row.getIsAllSubRowsSelected();
593
+ };
594
+ const getMRT_RowSelectionHandler = ({
595
+ row,
596
+ staticRowIndex = 0,
597
+ table
598
+ }) => (event, value) => {
599
+ const {
600
+ getState,
601
+ options: {
602
+ enableBatchRowSelection,
603
+ enableMultiRowSelection,
604
+ enableRowPinning,
605
+ manualPagination,
606
+ rowPinningDisplayMode
607
+ },
608
+ refs: {
609
+ allSelectableRowIdsRef,
610
+ lastSelectedRowId
611
+ }
612
+ } = table;
613
+ const {
614
+ pagination: {
615
+ pageIndex,
616
+ pageSize
617
+ }
618
+ } = getState();
619
+ const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
620
+ const wasCurrentRowChecked = getIsRowSelected({
621
+ row,
622
+ table
623
+ });
624
+
625
+ // ── Special case: deselecting a row while "select all pages" is active ────
626
+ // Per spec: deselecting any single row while in global-select-all mode must
627
+ // reset the selection to only the current page rows, minus the clicked row.
628
+ if (allSelectableRowIdsRef.current.length > 0 && wasCurrentRowChecked) {
629
+ allSelectableRowIdsRef.current = [];
630
+ const newSelection = {};
631
+ table.getPaginatedRowModel().rows.forEach(pageRow => {
632
+ if (pageRow.id !== row.id && pageRow.getCanSelect()) {
633
+ newSelection[pageRow.id] = true;
634
+ }
635
+ });
636
+ table.setRowSelection(newSelection);
637
+ lastSelectedRowId.current = row.id;
638
+ return;
639
+ }
640
+
641
+ // toggle selection of this row (normal path)
642
+ row.toggleSelected(value ?? !wasCurrentRowChecked);
643
+ const changedRowIds = new Set([row.id]);
644
+
645
+ // if shift key is pressed, select all rows between last selected and this one
646
+ if (enableBatchRowSelection && enableMultiRowSelection && event.nativeEvent.shiftKey && lastSelectedRowId.current !== null) {
647
+ const rows = getMRT_Rows(table, true);
648
+ const lastIndex = rows.findIndex(r => r.id === lastSelectedRowId.current);
649
+ if (lastIndex !== -1) {
650
+ const isLastIndexChecked = getIsRowSelected({
651
+ row: rows?.[lastIndex],
652
+ table
653
+ });
654
+ const currentIndex = staticRowIndex + paginationOffset;
655
+ const [start, end] = lastIndex < currentIndex ? [lastIndex, currentIndex] : [currentIndex, lastIndex];
656
+
657
+ // toggle selection of all rows between last selected and this one
658
+ // but only if the last selected row is not the same as the current one
659
+ if (wasCurrentRowChecked !== isLastIndexChecked) {
660
+ for (let i = start; i <= end; i++) {
661
+ rows[i].toggleSelected(!wasCurrentRowChecked);
662
+ changedRowIds.add(rows[i].id);
663
+ }
664
+ }
665
+ }
666
+ }
667
+
668
+ // record the last selected row id
669
+ lastSelectedRowId.current = row.id;
670
+
671
+ // if all sub rows were selected, unselect them
417
672
  if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
418
673
  row.subRows?.forEach(r => r.toggleSelected(false));
419
674
  }
@@ -470,265 +725,465 @@ const getIsAllPagesSelectionActive = (table, rowSelection) => {
470
725
  return table.getIsAllRowsSelected();
471
726
  };
472
727
 
473
- const flexRender = reactTable.flexRender;
474
- function createMRTColumnHelper() {
475
- return {
476
- accessor: (accessor, column) => ({
477
- ...column,
478
- accessorKey: accessor
479
- }),
480
- display: column => column,
481
- group: column => column
482
- };
483
- }
484
- const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => reactTable.constructRow(table, 'mrt-row-create', originalRow ?? Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map(col => ({
485
- [getColumnId(col)]: ''
486
- }))), rowIndex, depth, subRows, parentId);
487
-
488
- /** Resolved column limits shared by measurement, resizing, and cell layout. */
489
- const getColumnSizeBounds = ({
490
- minSize = 40,
491
- maxSize = 1000
492
- }) => {
493
- const min = Number.isFinite(minSize) ? Math.max(0, minSize) : 40;
494
- const max = Number.isNaN(maxSize) ? 1000 : Math.max(min, maxSize);
495
- return {
496
- minSize: min,
497
- maxSize: max
498
- };
499
- };
500
-
501
- // `el` normally has an explicit width/min-width/flex-basis (driven by the
502
- // column's size CSS var), so nothing overflows and `getBoundingClientRect`
503
- // just reports that forced size back — and `min-width` alone would otherwise
504
- // stop it from ever shrinking below the current (large) column size.
505
- // Temporarily switching to `max-content` with min-width/grow/shrink zeroed
506
- // out lets the browser lay it out at its natural content size instead — then
507
- // the inline style is restored before this task yields, so there's no
508
- // visible flash.
509
- const measureIntrinsicWidth = el => {
728
+ const MRT_SelectCheckbox = t0 => {
729
+ const $ = compilerRuntime.c(32);
730
+ let rest;
731
+ let row;
732
+ let staticRowIndex;
733
+ let table;
734
+ if ($[0] !== t0) {
735
+ ({
736
+ row,
737
+ staticRowIndex,
738
+ table,
739
+ ...rest
740
+ } = t0);
741
+ $[0] = t0;
742
+ $[1] = rest;
743
+ $[2] = row;
744
+ $[3] = staticRowIndex;
745
+ $[4] = table;
746
+ } else {
747
+ rest = $[1];
748
+ row = $[2];
749
+ staticRowIndex = $[3];
750
+ table = $[4];
751
+ }
510
752
  const {
511
- width,
512
- minWidth,
513
- maxWidth,
514
- flexBasis,
515
- flexGrow,
516
- flexShrink
517
- } = el.style;
518
- el.style.width = 'max-content';
519
- el.style.minWidth = '0';
520
- el.style.maxWidth = 'none';
521
- el.style.flexBasis = 'auto';
522
- el.style.flexGrow = '0';
523
- el.style.flexShrink = '0';
524
- const measured = Math.ceil(el.getBoundingClientRect().width);
525
- el.style.width = width;
526
- el.style.minWidth = minWidth;
527
- el.style.maxWidth = maxWidth;
528
- el.style.flexBasis = flexBasis;
529
- el.style.flexGrow = flexGrow;
530
- el.style.flexShrink = flexShrink;
531
- return measured;
532
- };
533
-
534
- /**
535
- * The single measurement this library uses anywhere it decides "what's the
536
- * right width for this column's current content" — shared by the resize
537
- * handle's double-click autosize and the initial autosize effect
538
- * (MRT_AutoSizeColumnsEffect), so both agree on the exact same answer.
539
- *
540
- * Driven purely by body cell content: the header title never contributes,
541
- * so a long header simply ellipsizes when its values are narrower.
542
- *
543
- * Only the currently rendered (visible, due to row virtualization) body
544
- * cells can be measured — a full-dataset autosize would require rendering
545
- * every row off-screen, which defeats the point of virtualization.
546
- */
547
- // Absorbs the sub-pixel rounding gap between measurement time (forced
548
- // `max-content`, read via `Math.ceil`) and final render time (the actual
549
- // `calc(var(--col-x-size) * 1px)` width) — without it, a column can land
550
- // exactly 1px short of its own measured content and still clip/ellipsize.
551
- const MEASUREMENT_SAFETY_MARGIN_PX = 2;
552
- const computeAutoSizedColumnWidth = ({
553
- bodyCellEls,
554
- maxSize,
555
- minSize
556
- }) => {
557
- let contentWidth = 0;
558
- for (const cellEl of bodyCellEls ?? []) {
559
- contentWidth = Math.max(contentWidth, measureIntrinsicWidth(cellEl));
753
+ getState,
754
+ options: t1
755
+ } = table;
756
+ const {
757
+ enableMultiRowSelection,
758
+ localization,
759
+ muiSelectAllCheckboxProps,
760
+ muiSelectCheckboxProps,
761
+ selectAllMode
762
+ } = t1;
763
+ let t2;
764
+ if ($[5] !== getState) {
765
+ t2 = getState();
766
+ $[5] = getState;
767
+ $[6] = t2;
768
+ } else {
769
+ t2 = $[6];
560
770
  }
561
- if (contentWidth > 0) {
562
- contentWidth = Math.ceil(contentWidth) + MEASUREMENT_SAFETY_MARGIN_PX;
771
+ const {
772
+ isLoading
773
+ } = t2;
774
+ const density = reactStore.useSelector(table.store, _temp$A);
775
+ const selectAll = !row;
776
+ let t3;
777
+ if ($[7] !== row || $[8] !== staticRowIndex || $[9] !== table) {
778
+ t3 = row ? getMRT_RowSelectionHandler({
779
+ row,
780
+ staticRowIndex,
781
+ table
782
+ }) : undefined;
783
+ $[7] = row;
784
+ $[8] = staticRowIndex;
785
+ $[9] = table;
786
+ $[10] = t3;
787
+ } else {
788
+ t3 = $[10];
563
789
  }
564
- const bounds = getColumnSizeBounds({
565
- minSize,
566
- maxSize
567
- });
568
- return Math.min(Math.max(contentWidth, bounds.minSize), bounds.maxSize);
790
+ const onSelectionChange = t3;
791
+ let t4;
792
+ if ($[11] !== table) {
793
+ t4 = getMRT_SelectAllHandler({
794
+ table
795
+ });
796
+ $[11] = table;
797
+ $[12] = t4;
798
+ } else {
799
+ t4 = $[12];
800
+ }
801
+ const onSelectAllChange = t4;
802
+ let t5;
803
+ if ($[13] !== density || $[14] !== enableMultiRowSelection || $[15] !== isLoading || $[16] !== localization.toggleSelectAll || $[17] !== localization.toggleSelectRow || $[18] !== muiSelectAllCheckboxProps || $[19] !== muiSelectCheckboxProps || $[20] !== onSelectAllChange || $[21] !== onSelectionChange || $[22] !== rest || $[23] !== row || $[24] !== selectAll || $[25] !== selectAllMode || $[26] !== staticRowIndex || $[27] !== table) {
804
+ t5 = () => {
805
+ const allRowsSelected = selectAll ? selectAllMode === "page" ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected() : undefined;
806
+ const isChecked = selectAll ? allRowsSelected : getIsRowSelected({
807
+ row,
808
+ table
809
+ });
810
+ const checkboxProps = {
811
+ ...(selectAll ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, {
812
+ table
813
+ }) : parseFromValuesOrFunc(muiSelectCheckboxProps, {
814
+ row,
815
+ staticRowIndex,
816
+ table
817
+ })),
818
+ ...rest
819
+ };
820
+ const commonProps = {
821
+ "aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow,
822
+ checked: isChecked,
823
+ disabled: isLoading || row && !row.getCanSelect() || row?.id === "mrt-row-create",
824
+ inputProps: {
825
+ "aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
826
+ },
827
+ onChange: event => {
828
+ event.stopPropagation();
829
+ selectAll ? onSelectAllChange(event) : onSelectionChange(event);
830
+ },
831
+ size: density === "compact" ? "small" : "medium",
832
+ ...checkboxProps,
833
+ onClick: e => {
834
+ e.stopPropagation();
835
+ checkboxProps?.onClick?.(e);
836
+ },
837
+ sx: theme => ({
838
+ height: density === "compact" ? "1.75rem" : "2.5rem",
839
+ m: density !== "compact" ? "-0.4rem" : undefined,
840
+ width: density === "compact" ? "1.75rem" : "2.5rem",
841
+ zIndex: 0,
842
+ ...parseFromValuesOrFunc(checkboxProps?.sx, theme)
843
+ }),
844
+ title: undefined
845
+ };
846
+ return /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
847
+ ...getCommonTooltipProps(),
848
+ title: checkboxProps?.title ?? (selectAll ? localization.toggleSelectAll : localization.toggleSelectRow),
849
+ children: enableMultiRowSelection === false ? /*#__PURE__*/jsxRuntime.jsx(Radio, {
850
+ ...commonProps
851
+ }) : /*#__PURE__*/jsxRuntime.jsx(Checkbox, {
852
+ disableRipple: true,
853
+ indeterminate: !isChecked && selectAll ? table.getIsSomeRowsSelected() : row?.getIsSomeSelected() && row.getCanSelectSubRows(),
854
+ ...commonProps
855
+ })
856
+ });
857
+ };
858
+ $[13] = density;
859
+ $[14] = enableMultiRowSelection;
860
+ $[15] = isLoading;
861
+ $[16] = localization.toggleSelectAll;
862
+ $[17] = localization.toggleSelectRow;
863
+ $[18] = muiSelectAllCheckboxProps;
864
+ $[19] = muiSelectCheckboxProps;
865
+ $[20] = onSelectAllChange;
866
+ $[21] = onSelectionChange;
867
+ $[22] = rest;
868
+ $[23] = row;
869
+ $[24] = selectAll;
870
+ $[25] = selectAllMode;
871
+ $[26] = staticRowIndex;
872
+ $[27] = table;
873
+ $[28] = t5;
874
+ } else {
875
+ t5 = $[28];
876
+ }
877
+ let t6;
878
+ if ($[29] !== t5 || $[30] !== table.store) {
879
+ t6 = /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
880
+ selector: _temp2$d,
881
+ source: table.store,
882
+ children: t5
883
+ });
884
+ $[29] = t5;
885
+ $[30] = table.store;
886
+ $[31] = t6;
887
+ } else {
888
+ t6 = $[31];
889
+ }
890
+ return t6;
569
891
  };
570
-
571
- // Loading indicators fade in after a short delay
572
- // (`animation: ${mrtDelayedFadeIn}`), so fast responses don't flash them.
573
- const mrtDelayedFadeIn = `${styles.keyframes`
574
- from { opacity: 0; }
575
- to { opacity: 1; }
576
- `} 150ms ease-out 200ms both`;
577
- const parseCSSVarId = id => id.replace(/[^a-zA-Z0-9]/g, '_');
578
- const getMRTTheme = (mrtTheme, muiTheme) => {
579
- const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
580
- const baseBackgroundColor = muiTheme.palette.background.default;
892
+ function _temp$A(state) {
893
+ return state.density;
894
+ }
895
+ function _temp2$d(state_0) {
581
896
  return {
582
- baseBackgroundColor,
583
- cellNavigationOutlineColor: muiTheme.palette.primary.main,
584
- draggingBorderColor: muiTheme.palette.primary.main,
585
- matchHighlightColor: muiTheme.palette.mode === 'dark' ? styles.darken(muiTheme.palette.warning.dark, 0.25) : styles.lighten(muiTheme.palette.warning.light, 0.5),
586
- menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07),
587
- pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1),
588
- selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2),
589
- ...mrtThemeOverrides
897
+ pagination: state_0.pagination,
898
+ rowSelection: state_0.rowSelection
590
899
  };
591
- };
592
- const commonCellBeforeAfterStyles = {
593
- content: '""',
594
- height: '100%',
595
- left: 0,
596
- position: 'absolute',
597
- top: 0,
598
- width: '100%',
599
- zIndex: -1
600
- };
601
- const getCommonPinnedCellStyles = ({
602
- column,
603
- table,
604
- theme
605
- }) => {
900
+ }
901
+
902
+ function defaultDisplayColumnProps({
903
+ columnSpecificDefaults,
904
+ header,
905
+ id,
906
+ size,
907
+ tableOptions
908
+ }) {
606
909
  const {
607
- baseBackgroundColor
608
- } = table.options.mrtTheme;
910
+ defaultDisplayColumn,
911
+ displayColumnDefOptions,
912
+ localization
913
+ } = tableOptions;
609
914
  return {
610
- '&[data-pinned="true"]': {
611
- '&:before': {
612
- backgroundColor: baseBackgroundColor,
613
- // Draw only the edge facing the center region, including when other
614
- // pinned columns are hidden. Logical borders also handle RTL layouts.
615
- borderInlineEnd: column?.getIsPinned() === 'start' && column.getIsLastColumn('start') ? `1px solid ${theme.palette.divider}` : undefined,
616
- borderInlineStart: column?.getIsPinned() === 'end' && column.getIsFirstColumn('end') ? `1px solid ${theme.palette.divider}` : undefined,
617
- boxSizing: 'border-box',
618
- ...commonCellBeforeAfterStyles
619
- }
620
- }
915
+ ...defaultDisplayColumn,
916
+ header: header ? localization[header] : '',
917
+ size,
918
+ ...columnSpecificDefaults,
919
+ ...displayColumnDefOptions?.[id],
920
+ id
621
921
  };
622
- };
623
-
624
- // Shared by cell styles and the imperative sizing subscription: resizing must
625
- // update growth even when memoized cells do not render again.
626
- const getColumnGrowWeight = (column, table) => {
922
+ }
923
+ const showRowPinningColumn = tableOptions => {
627
924
  const {
628
- columnDef
629
- } = column;
630
- const sizing = table.getState().columnSizing[column.id];
631
- const hasUserSize = sizing !== undefined && sizing !== table.refs.autoSizedColumnWidthsRef.current[column.id];
632
- if (column.getIsPinned() || !table.refs.autoSizeColumnIdsRef.current.has(column.id) || hasUserSize) return 0;
633
- if (typeof columnDef.grow === 'number') return Math.max(0, columnDef.grow);
634
- return columnDef.grow === false ? 0 : 1;
925
+ enableRowPinning,
926
+ rowPinningDisplayMode
927
+ } = tableOptions;
928
+ return !!(enableRowPinning && !rowPinningDisplayMode?.startsWith('select'));
635
929
  };
636
- const getCommonMRTCellStyles = ({
637
- column,
638
- header,
639
- isDraggingColumn,
640
- isHoveredColumn,
641
- table,
642
- tableCellProps,
643
- theme
644
- }) => {
930
+ const showRowExpandColumn = tableOptions => {
645
931
  const {
646
- options: {
647
- enableColumnVirtualization,
648
- layoutMode
932
+ enableExpanding,
933
+ enableGrouping,
934
+ renderDetailPanel,
935
+ state: {
936
+ grouping
649
937
  }
650
- } = table;
651
- const {
652
- columnDef
653
- } = column;
938
+ } = tableOptions;
939
+ return !!(enableExpanding || enableGrouping && grouping?.length || renderDetailPanel);
940
+ };
941
+ const showRowActionsColumn = tableOptions => {
654
942
  const {
655
- columnDefType
656
- } = columnDef;
657
- const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
943
+ enableEditing,
944
+ enableRowActions
945
+ } = tableOptions;
946
+ return !!(enableRowActions || enableEditing) && !columnsIncludeRowActions(tableOptions.columns);
947
+ };
948
+ const showRowNumbersColumn = tableOptions => !!tableOptions.enableRowNumbers;
949
+ const showRowSpacerColumn = tableOptions => tableOptions.layoutMode === 'grid-no-grow';
950
+ const getLeadingDisplayColumnIds = tableOptions => [showRowPinningColumn(tableOptions) && 'mrt-row-pin', tableOptions.positionActionsColumn === 'first' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'first' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', columnsIncludeCheckboxSelection(tableOptions.columns) && '__check__', showRowNumbersColumn(tableOptions) && 'mrt-row-numbers'].filter(Boolean);
951
+ const getTrailingDisplayColumnIds = tableOptions => [tableOptions.positionActionsColumn === 'last' && showRowActionsColumn(tableOptions) && 'mrt-row-actions', tableOptions.positionExpandColumn === 'last' && showRowExpandColumn(tableOptions) && 'mrt-row-expand', showRowSpacerColumn(tableOptions) && 'mrt-row-spacer'].filter(Boolean);
952
+
953
+ /** The internal ID used by TanStack Table for the row-selection checkbox column */
954
+ const CHECKBOX_DISPLAY_COLUMN_ID = '__check__';
955
+ const getColumnMenuLabel = (column, localization) => column.id === CHECKBOX_DISPLAY_COLUMN_ID ? localization.selection : column.columnDef.header;
956
+ const ACTIONS_DISPLAY_COLUMN_ID = 'actions';
957
+ const getRowActionsCell = () => ({
958
+ Cell: ({
959
+ cell,
960
+ row,
961
+ staticRowIndex,
962
+ table
963
+ }) => /*#__PURE__*/react.createElement(MRT_ToggleRowActionMenuButton, {
964
+ cell,
965
+ row,
966
+ staticRowIndex,
967
+ table
968
+ })
969
+ });
970
+
971
+ /** Render row actions in the supplied column, preserving its layout and metadata. */
972
+ const decorateRowActionsColumn = (columnDef, tableOptions) => ({
973
+ ...columnDef,
974
+ enableColumnDragging: columnDef.enableColumnDragging ?? true,
975
+ enableColumnOrdering: columnDef.enableColumnOrdering ?? true,
976
+ enableColumnActions: columnDef.enableColumnActions ?? true,
977
+ enablePinning: columnDef.enablePinning ?? true,
978
+ enableResizing: columnDef.enableResizing ?? true,
979
+ id: ACTIONS_DISPLAY_COLUMN_ID,
980
+ columnDefType: 'display',
981
+ onClickIconTypeColumn: undefined,
982
+ ...getRowActionsCell(),
983
+ ...tableOptions.displayColumnDefOptions?.[ACTIONS_DISPLAY_COLUMN_ID]
984
+ });
985
+ const columnsIncludeRowActions = columnDefs => getAllLeafColumnDefs(columnDefs).some(columnDef => getColumnId(columnDef) === ACTIONS_DISPLAY_COLUMN_ID);
986
+
987
+ /**
988
+ * The Cell/Header pair every `__check__` column renders — shared by the
989
+ * auto-injected row-select column (getMRT_RowSelectColumnDef) and any column
990
+ * a consumer supplies directly under this reserved id (see
991
+ * decorateCheckboxSelectionColumn below), so both stay visually and
992
+ * behaviorally identical.
993
+ */
994
+ const getCheckboxSelectionCellAndHeader = tableOptions => {
658
995
  const {
659
- minSize,
660
- maxSize
661
- } = getColumnSizeBounds(columnDef);
662
- const sizeVar = `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`;
663
- const boundedSize = Number.isFinite(maxSize) ? `clamp(${minSize}px, ${sizeVar}, ${maxSize}px)` : `max(${minSize}px, ${sizeVar})`;
664
- const widthStyles = {
665
- // Group headers span already-bounded child columns; the default leaf
666
- // maximum must not truncate the sum of their widths.
667
- maxWidth: columnDefType === 'group' ? sizeVar : Number.isFinite(maxSize) ? `${maxSize}px` : 'none',
668
- minWidth: columnDefType === 'group' ? sizeVar : boundedSize,
669
- width: columnDefType === 'group' ? sizeVar : boundedSize
996
+ enableMultiRowSelection,
997
+ enableSelectAll
998
+ } = tableOptions;
999
+ return {
1000
+ Cell: ({
1001
+ row,
1002
+ staticRowIndex,
1003
+ table
1004
+ }) => /*#__PURE__*/react.createElement(MRT_SelectCheckbox, {
1005
+ row,
1006
+ staticRowIndex,
1007
+ table
1008
+ }),
1009
+ Header: enableSelectAll && enableMultiRowSelection ? ({
1010
+ table
1011
+ }) => /*#__PURE__*/react.createElement(MRT_SelectCheckbox, {
1012
+ table
1013
+ }) : undefined
670
1014
  };
671
- if (layoutMode === 'grid' || layoutMode === 'grid-no-grow') {
672
- const weight = getColumnGrowWeight(column, table);
673
- const growVar = `var(--col-${parseCSSVarId(column.id)}-grow, ${weight})`;
674
- widthStyles.flex = `${growVar} 0 auto`;
1015
+ };
1016
+
1017
+ /**
1018
+ * `__check__` is reserved: MRT always knows how to render a column by this
1019
+ * id as the row-selection checkbox — supplied directly in the consumer's
1020
+ * own columns array, e.g. a column converted 1:1, size/minSize/sortable and
1021
+ * all, from an external data source that happens to use this id for its own
1022
+ * selection column. `enableColumnActions`/`enablePinning` default to true
1023
+ * (matching every other display column's own baseline) unless the
1024
+ * consumer's own column def says otherwise; Cell/Header/columnDefType are
1025
+ * always forced, to route through the same display-column render path.
1026
+ * `displayColumnDefOptions['__check__']`, same as every other display
1027
+ * column, always has the final say, able to override any of it.
1028
+ */
1029
+ const decorateCheckboxSelectionColumn = (columnDef, tableOptions) => ({
1030
+ ...columnDef,
1031
+ enableColumnActions: columnDef.enableColumnActions ?? true,
1032
+ enablePinning: columnDef.enablePinning ?? true,
1033
+ enableResizing: columnDef.enableResizing ?? true,
1034
+ // Breathing room between the select-all checkbox/column-actions button
1035
+ // and whatever sits to their right (next column's border, or the
1036
+ // resize handle) — logical property so it's the correct side in RTL too.
1037
+ muiTableHeadCellProps: columnDef.muiTableHeadCellProps ?? {
1038
+ sx: {
1039
+ paddingInlineEnd: '1rem'
1040
+ }
1041
+ },
1042
+ id: CHECKBOX_DISPLAY_COLUMN_ID,
1043
+ accessorKey: CHECKBOX_DISPLAY_COLUMN_ID,
1044
+ columnDefType: 'display',
1045
+ // Matches prepareColumns' own display-column merge below — without this,
1046
+ // the spread above leaves TS unable to tell this apart from the
1047
+ // icon-column variant of MRT_ColumnDef (which requires this field).
1048
+ onClickIconTypeColumn: undefined,
1049
+ ...getCheckboxSelectionCellAndHeader(tableOptions),
1050
+ ...tableOptions.displayColumnDefOptions?.[CHECKBOX_DISPLAY_COLUMN_ID]
1051
+ });
1052
+
1053
+ /**
1054
+ * Whether the consumer's own columns already include a `__check__` column —
1055
+ * when true, MRT must not also auto-inject its own (enableRowSelection would
1056
+ * otherwise create a second column under the same reserved id).
1057
+ */
1058
+ const columnsIncludeCheckboxSelection = columnDefs => getAllLeafColumnDefs(columnDefs).some(columnDef => getColumnId(columnDef) === CHECKBOX_DISPLAY_COLUMN_ID);
1059
+
1060
+ /**
1061
+ * Forces mrt-row-expand to a fixed slot in columnOrder: right after the
1062
+ * checkbox column when row selection is enabled, otherwise the very first
1063
+ * column. This slot is independent of column pinning.
1064
+ */
1065
+ const normalizeRowExpandColumnOrder = (tableOptions, columnOrder) => {
1066
+ if (!showRowExpandColumn(tableOptions)) {
1067
+ return columnOrder;
675
1068
  }
676
- const pinnedStyles = isColumnPinned ? {
677
- ...getCommonPinnedCellStyles({
678
- column,
679
- table,
680
- theme
681
- }),
682
- // Logical CSS insets (not left/right) so pinning stays correct in RTL
683
- // without branching on theme.direction here.
684
- insetInlineStart: isColumnPinned === 'start' ? `${column.getStart('start')}px` : undefined,
685
- position: 'sticky',
686
- insetInlineEnd: isColumnPinned === 'end' ? `${column.getAfter('end')}px` : undefined
687
- } : {};
688
- return {
689
- backgroundColor: 'inherit',
690
- backgroundImage: 'inherit',
691
- display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
692
- justifyContent: columnDefType === 'group' ? 'center' : layoutMode?.startsWith('grid') ? tableCellProps.align : undefined,
693
- opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1,
694
- position: 'relative',
695
- transition: enableColumnVirtualization ? 'none' : `padding 150ms ease-in-out`,
696
- zIndex: column.getIsResizing() || isDraggingColumn ? 2 : columnDefType !== 'group' && isColumnPinned ? 1 : 0,
697
- '&:focus-visible': {
698
- outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
699
- outlineOffset: '-2px'
700
- },
701
- ...pinnedStyles,
702
- ...widthStyles,
703
- ...parseFromValuesOrFunc(tableCellProps?.sx, theme)
1069
+ const withoutExpand = columnOrder.filter(id => id !== 'mrt-row-expand');
1070
+ const expandIndex = columnsIncludeCheckboxSelection(tableOptions.columns) ? 1 : 0;
1071
+ return [...withoutExpand.slice(0, expandIndex), 'mrt-row-expand', ...withoutExpand.slice(expandIndex)];
1072
+ };
1073
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
1074
+ const {
1075
+ state: {
1076
+ columnOrder: currentColumnOrderIds = []
1077
+ }
1078
+ } = tableOptions;
1079
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
1080
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
1081
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map(columnDef => getColumnId(columnDef));
1082
+ let allLeafColumnDefIds = reset ? defaultColumnDefIds : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
1083
+ allLeafColumnDefIds = allLeafColumnDefIds.filter(colId => !leadingDisplayColIds.includes(colId) && !trailingDisplayColIds.includes(colId));
1084
+ return [...leadingDisplayColIds, ...allLeafColumnDefIds, ...trailingDisplayColIds];
1085
+ };
1086
+
1087
+ const MRT_SortingFns = {
1088
+ ...reactTable.sortFns
1089
+ };
1090
+
1091
+ const getColumnId = columnDef => columnDef.id ?? columnDef.accessorKey?.toString?.() ?? columnDef.header;
1092
+ const getAllLeafColumnDefs = columns => {
1093
+ const allLeafColumnDefs = [];
1094
+ const getLeafColumns = cols => {
1095
+ cols.forEach(col => {
1096
+ if (col.columns) {
1097
+ getLeafColumns(col.columns);
1098
+ } else {
1099
+ allLeafColumnDefs.push(col);
1100
+ }
1101
+ });
704
1102
  };
1103
+ getLeafColumns(columns);
1104
+ return allLeafColumnDefs;
1105
+ };
1106
+
1107
+ // Must run on the raw, user-authored column array — by the time TanStack
1108
+ // resolves column.columnDef.size (via constructColumn's `{...defaultColumn,
1109
+ // ...columnDef}` merge), a column the consumer never gave a size backfills
1110
+ // MRT_DefaultColumn.size (180) directly into columnDef.size, indistinguishable
1111
+ // from a column that explicitly asked for 180. Checking `size === undefined`
1112
+ // here, before that merge happens, is the only point where the distinction
1113
+ // still exists.
1114
+ const getAutoSizeCandidateColumnIds = columnDefs => new Set(getAllLeafColumnDefs(columnDefs).filter(columnDef => columnDef.size === undefined).map(columnDef => getColumnId(columnDef)));
1115
+ const prepareColumns = ({
1116
+ columnDefs,
1117
+ tableOptions
1118
+ }) => {
1119
+ const {
1120
+ defaultDisplayColumn
1121
+ } = tableOptions;
1122
+ return columnDefs.map(columnDef => {
1123
+ //assign columnId
1124
+ if (!columnDef.id) columnDef.id = getColumnId(columnDef);
1125
+ // __check__ is reserved: MRT always knows how to render a column by this
1126
+ // id as the row-selection checkbox, whether it was auto-injected or
1127
+ // supplied directly in the consumer's own columns array — see
1128
+ // decorateCheckboxSelectionColumn.
1129
+ if (columnDef.id === CHECKBOX_DISPLAY_COLUMN_ID) {
1130
+ columnDef = decorateCheckboxSelectionColumn(columnDef, tableOptions);
1131
+ } else if (columnDef.id === ACTIONS_DISPLAY_COLUMN_ID) {
1132
+ columnDef = decorateRowActionsColumn(columnDef, tableOptions);
1133
+ }
1134
+ //assign columnDefType
1135
+ if (!columnDef.columnDefType) columnDef.columnDefType = 'data';
1136
+ if (columnDef.columns?.length) {
1137
+ columnDef.columnDefType = 'group';
1138
+ //recursively prepare columns if this is a group column
1139
+ columnDef.columns = prepareColumns({
1140
+ columnDefs: columnDef.columns,
1141
+ tableOptions
1142
+ });
1143
+ } else if (columnDef.columnDefType === 'data') {
1144
+ // Multi-aggregation arrays (e.g. aggregationFn: ['count', 'mean']) are
1145
+ // handled natively by v9's rowAggregationFeature — it resolves each
1146
+ // registered name and returns a keyed result object, so no manual
1147
+ // mapping is needed here anymore (v8 required it).
1148
+
1149
+ //assign sortFns
1150
+ if (Object.keys(MRT_SortingFns).includes(columnDef.sortFn)) {
1151
+ // @ts-expect-error - resolving the registered string name to its function
1152
+ columnDef.sortFn = MRT_SortingFns[columnDef.sortFn];
1153
+ }
1154
+ } else if (columnDef.columnDefType === 'display') {
1155
+ columnDef = {
1156
+ ...defaultDisplayColumn,
1157
+ ...columnDef,
1158
+ onClickIconTypeColumn: undefined
1159
+ };
1160
+ }
1161
+ return columnDef;
1162
+ });
705
1163
  };
706
- const getCommonToolbarStyles = ({
707
- table
708
- }) => ({
709
- alignItems: 'flex-start',
710
- backgroundColor: table.options.mrtTheme.baseBackgroundColor,
711
- display: 'grid',
712
- flexWrap: 'wrap-reverse',
713
- position: 'relative',
714
- transition: 'all 150ms ease-in-out',
715
- zIndex: 1
716
- });
717
- const flipIconStyles = theme => theme.direction === 'rtl' ? {
718
- style: {
719
- transform: 'scaleX(-1)'
1164
+ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
1165
+ if (draggedColumn.getCanPin()) {
1166
+ draggedColumn.pin(targetColumn.getIsPinned());
720
1167
  }
721
- } : undefined;
722
- const getCommonTooltipProps = placement => ({
723
- disableInteractive: true,
724
- enterDelay: 1000,
725
- enterNextDelay: 1000,
726
- placement
727
- });
1168
+ const newColumnOrder = [...columnOrder];
1169
+ newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
1170
+ return newColumnOrder;
1171
+ };
728
1172
 
729
- // Stable, row-scoped hook for e2e/unit tests to target a specific default
730
- // row action (e.g. edit, delete) without relying on DOM order or icon markup.
731
- const getRowActionTestId = (rowId, actionName) => `mrt-row-${rowId}-${actionName}-action`;
1173
+ const flexRender = reactTable.flexRender;
1174
+ function createMRTColumnHelper() {
1175
+ return {
1176
+ accessor: (accessor, column) => ({
1177
+ ...column,
1178
+ accessorKey: accessor
1179
+ }),
1180
+ display: column => column,
1181
+ group: column => column
1182
+ };
1183
+ }
1184
+ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => reactTable.constructRow(table, 'mrt-row-create', originalRow ?? Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map(col => ({
1185
+ [getColumnId(col)]: ''
1186
+ }))), rowIndex, depth, subRows, parentId);
732
1187
 
733
1188
  function MRT_DeleteRowButton(t0) {
734
1189
  const $ = compilerRuntime.c(14);
@@ -2006,199 +2461,20 @@ const createExportAction = ({
2006
2461
  });
2007
2462
  };
2008
2463
  return {
2009
- name: 'export',
2010
- renderRow: renderRowAction,
2011
- renderToolbar: renderToolbarAction,
2012
- ...rest
2013
- };
2014
- };
2015
-
2016
- const MRT_AggregationFns = {
2017
- ...reactTable.aggregationFns
2018
- };
2019
-
2020
- const MRT_RowActionMenu = ({
2021
- anchorEl,
2022
- row,
2023
- setAnchorEl,
2024
- staticRowIndex,
2025
- table,
2026
- ...rest
2027
- }) => {
2028
- const {
2029
- options: {
2030
- mrtTheme: {
2031
- menuBackgroundColor
2032
- },
2033
- renderRowActionMenuItems
2034
- }
2035
- } = table;
2036
- const density = reactStore.useSelector(table.store, state => state.density);
2037
- const menuItems = react.useMemo(() => {
2038
- const items = [];
2039
- const rowActionMenuItems = renderRowActionMenuItems?.({
2040
- closeMenu: () => setAnchorEl(null),
2041
- row,
2042
- staticRowIndex,
2043
- table
2044
- });
2045
- if (rowActionMenuItems?.length) items.push(...rowActionMenuItems);
2046
- return items;
2047
- }, [renderRowActionMenuItems, row, staticRowIndex, table]);
2048
- if (!menuItems.length) return null;
2049
- return /*#__PURE__*/jsxRuntime.jsx(Menu, {
2050
- MenuListProps: {
2051
- dense: density === 'compact',
2052
- sx: {
2053
- backgroundColor: menuBackgroundColor
2054
- }
2055
- },
2056
- anchorEl: anchorEl,
2057
- disableScrollLock: true,
2058
- onClick: event => event.stopPropagation(),
2059
- onClose: () => setAnchorEl(null),
2060
- open: !!anchorEl,
2061
- ...rest,
2062
- children: menuItems
2063
- });
2064
- };
2065
-
2066
- const commonIconButtonStyles = {
2067
- '&:hover': {
2068
- opacity: 1
2069
- },
2070
- height: '2rem',
2071
- ml: '10px',
2072
- opacity: 0.5,
2073
- transition: 'opacity 150ms',
2074
- width: '2rem'
2075
- };
2076
- const MRT_ToggleRowActionMenuButton = t0 => {
2077
- const $ = compilerRuntime.c(20);
2078
- let cell;
2079
- let rest;
2080
- let row;
2081
- let staticRowIndex;
2082
- let table;
2083
- if ($[0] !== t0) {
2084
- ({
2085
- cell,
2086
- row,
2087
- staticRowIndex,
2088
- table,
2089
- ...rest
2090
- } = t0);
2091
- $[0] = t0;
2092
- $[1] = cell;
2093
- $[2] = rest;
2094
- $[3] = row;
2095
- $[4] = staticRowIndex;
2096
- $[5] = table;
2097
- } else {
2098
- cell = $[1];
2099
- rest = $[2];
2100
- row = $[3];
2101
- staticRowIndex = $[4];
2102
- table = $[5];
2103
- }
2104
- const {
2105
- options: t1
2106
- } = table;
2107
- const {
2108
- icons: t2,
2109
- localization,
2110
- renderRowActionMenuItems,
2111
- renderRowActions
2112
- } = t1;
2113
- const {
2114
- MoreHorizIcon
2115
- } = t2;
2116
- const [anchorEl, setAnchorEl] = react.useState(null);
2117
- let t3;
2118
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
2119
- t3 = event => {
2120
- event.stopPropagation();
2121
- event.preventDefault();
2122
- setAnchorEl(event.currentTarget);
2123
- };
2124
- $[6] = t3;
2125
- } else {
2126
- t3 = $[6];
2127
- }
2128
- const handleOpenRowActionMenu = t3;
2129
- let t4;
2130
- if ($[7] !== MoreHorizIcon || $[8] !== anchorEl || $[9] !== cell || $[10] !== localization || $[11] !== renderRowActionMenuItems || $[12] !== renderRowActions || $[13] !== rest || $[14] !== row || $[15] !== staticRowIndex || $[16] !== table) {
2131
- t4 = renderRowActions ? renderRowActions({
2132
- cell,
2133
- row,
2134
- staticRowIndex,
2135
- table
2136
- }) : renderRowActionMenuItems?.({
2137
- closeMenu: _temp$B,
2138
- row,
2139
- staticRowIndex,
2140
- table
2141
- })?.length ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2142
- children: [/*#__PURE__*/jsxRuntime.jsx(Tooltip, {
2143
- ...getCommonTooltipProps(),
2144
- title: localization.rowActions,
2145
- children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
2146
- "aria-label": localization.rowActions,
2147
- onClick: handleOpenRowActionMenu,
2148
- size: "small",
2149
- sx: commonIconButtonStyles,
2150
- ...rest,
2151
- children: /*#__PURE__*/jsxRuntime.jsx(MoreHorizIcon, {})
2152
- })
2153
- }), /*#__PURE__*/jsxRuntime.jsx(MRT_RowActionMenu, {
2154
- anchorEl: anchorEl,
2155
- row: row,
2156
- setAnchorEl: setAnchorEl,
2157
- staticRowIndex: staticRowIndex,
2158
- table: table
2159
- })]
2160
- }) : null;
2161
- $[7] = MoreHorizIcon;
2162
- $[8] = anchorEl;
2163
- $[9] = cell;
2164
- $[10] = localization;
2165
- $[11] = renderRowActionMenuItems;
2166
- $[12] = renderRowActions;
2167
- $[13] = rest;
2168
- $[14] = row;
2169
- $[15] = staticRowIndex;
2170
- $[16] = table;
2171
- $[17] = t4;
2172
- } else {
2173
- t4 = $[17];
2174
- }
2175
- let t5;
2176
- if ($[18] !== t4) {
2177
- t5 = /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
2178
- children: t4
2179
- });
2180
- $[18] = t4;
2181
- $[19] = t5;
2182
- } else {
2183
- t5 = $[19];
2184
- }
2185
- return t5;
2464
+ name: 'export',
2465
+ renderRow: renderRowAction,
2466
+ renderToolbar: renderToolbarAction,
2467
+ ...rest
2468
+ };
2469
+ };
2470
+
2471
+ const MRT_AggregationFns = {
2472
+ ...reactTable.aggregationFns
2186
2473
  };
2187
- function _temp$B() {}
2188
2474
 
2189
2475
  const getMRT_RowActionsColumnDef = tableOptions => {
2190
2476
  return {
2191
- Cell: ({
2192
- cell,
2193
- row,
2194
- staticRowIndex,
2195
- table
2196
- }) => /*#__PURE__*/jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, {
2197
- cell: cell,
2198
- row: row,
2199
- staticRowIndex: staticRowIndex,
2200
- table: table
2201
- }),
2477
+ ...getRowActionsCell(),
2202
2478
  ...(tableOptions.positionActionsColumn === 'last' && {
2203
2479
  grow: true
2204
2480
  }),
@@ -2263,7 +2539,7 @@ const MRT_ExpandAllButton = t0 => {
2263
2539
  const {
2264
2540
  isLoading
2265
2541
  } = t3;
2266
- const density = reactStore.useSelector(table.store, _temp$A);
2542
+ const density = reactStore.useSelector(table.store, _temp$z);
2267
2543
  let t4;
2268
2544
  if ($[5] !== muiExpandAllButtonProps || $[6] !== table) {
2269
2545
  t4 = parseFromValuesOrFunc(muiExpandAllButtonProps, {
@@ -2352,7 +2628,7 @@ const MRT_ExpandAllButton = t0 => {
2352
2628
  }
2353
2629
  return t7;
2354
2630
  };
2355
- function _temp$A(state) {
2631
+ function _temp$z(state) {
2356
2632
  return state.density;
2357
2633
  }
2358
2634
 
@@ -2567,11 +2843,11 @@ const MRT_ReorderRowCheckbox = t0 => {
2567
2843
  onChange,
2568
2844
  isSelected
2569
2845
  } = t0;
2570
- const handleClick = _temp$z;
2846
+ const handleClick = _temp$y;
2571
2847
  let t1;
2572
2848
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2573
2849
  t1 = {
2574
- color: _temp2$d,
2850
+ color: _temp2$c,
2575
2851
  height: "1.75rem",
2576
2852
  m: "-0.4rem",
2577
2853
  width: "1.75rem",
@@ -2602,10 +2878,10 @@ const MRT_ReorderRowCheckbox = t0 => {
2602
2878
  }
2603
2879
  return t2;
2604
2880
  };
2605
- function _temp$z(event) {
2881
+ function _temp$y(event) {
2606
2882
  event.stopPropagation();
2607
2883
  }
2608
- function _temp2$d(theme) {
2884
+ function _temp2$c(theme) {
2609
2885
  return theme.palette.warning.main;
2610
2886
  }
2611
2887
  function _temp3$5(theme_0) {
@@ -2927,14 +3203,14 @@ const useTreeRowReorderingHeader = t0 => {
2927
3203
  enableRowReordering,
2928
3204
  onTreeRowReorder
2929
3205
  } = t0;
2930
- const rowReorderingSelection = reactStore.useSelector(table.store, _temp$y);
3206
+ const rowReorderingSelection = reactStore.useSelector(table.store, _temp$x);
2931
3207
  let selectedReorderRowIds;
2932
3208
  let selectedRowsForReorder;
2933
3209
  let t1;
2934
3210
  if ($[0] !== enableRowReordering || $[1] !== rowReorderingSelection || $[2] !== table) {
2935
3211
  selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
2936
3212
  selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
2937
- t1 = !!enableRowReordering && selectedRowsForReorder.length > 0 && selectedRowsForReorder.some(_temp2$c);
3213
+ t1 = !!enableRowReordering && selectedRowsForReorder.length > 0 && selectedRowsForReorder.some(_temp2$b);
2938
3214
  $[0] = enableRowReordering;
2939
3215
  $[1] = rowReorderingSelection;
2940
3216
  $[2] = table;
@@ -2990,10 +3266,10 @@ const useTreeRowReorderingHeader = t0 => {
2990
3266
  }
2991
3267
  return t3;
2992
3268
  };
2993
- function _temp$y(state) {
3269
+ function _temp$x(state) {
2994
3270
  return state.rowReorderingSelection;
2995
3271
  }
2996
- function _temp2$c(selectedRow) {
3272
+ function _temp2$b(selectedRow) {
2997
3273
  return selectedRow.depth > 0;
2998
3274
  }
2999
3275
 
@@ -3332,314 +3608,106 @@ const MRT_TableBodyRowPinButton = t0 => {
3332
3608
  const {
3333
3609
  enableRowPinning,
3334
3610
  rowPinningDisplayMode
3335
- } = t1;
3336
- const density = reactStore.useSelector(table.store, _temp$x);
3337
- const canPin = parseFromValuesOrFunc(enableRowPinning, row);
3338
- if (!canPin) {
3339
- return null;
3340
- }
3341
- let t2;
3342
- if ($[4] !== rest || $[5] !== row || $[6] !== table) {
3343
- t2 = {
3344
- row,
3345
- table,
3346
- ...rest
3347
- };
3348
- $[4] = rest;
3349
- $[5] = row;
3350
- $[6] = table;
3351
- $[7] = t2;
3352
- } else {
3353
- t2 = $[7];
3354
- }
3355
- const rowPinButtonProps = t2;
3356
- if (rowPinningDisplayMode === "top-and-bottom" && !row.getIsPinned()) {
3357
- const t3 = density === "compact" ? "row" : "column";
3358
- let t4;
3359
- if ($[8] !== t3) {
3360
- t4 = {
3361
- display: "flex",
3362
- flexDirection: t3
3363
- };
3364
- $[8] = t3;
3365
- $[9] = t4;
3366
- } else {
3367
- t4 = $[9];
3368
- }
3369
- let t5;
3370
- let t6;
3371
- if ($[10] !== rowPinButtonProps) {
3372
- t5 = /*#__PURE__*/jsxRuntime.jsx(MRT_RowPinButton, {
3373
- pinningPosition: "top",
3374
- ...rowPinButtonProps
3375
- });
3376
- t6 = /*#__PURE__*/jsxRuntime.jsx(MRT_RowPinButton, {
3377
- pinningPosition: "bottom",
3378
- ...rowPinButtonProps
3379
- });
3380
- $[10] = rowPinButtonProps;
3381
- $[11] = t5;
3382
- $[12] = t6;
3383
- } else {
3384
- t5 = $[11];
3385
- t6 = $[12];
3386
- }
3387
- let t7;
3388
- if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
3389
- t7 = /*#__PURE__*/jsxRuntime.jsxs(Box, {
3390
- sx: t4,
3391
- children: [t5, t6]
3392
- });
3393
- $[13] = t4;
3394
- $[14] = t5;
3395
- $[15] = t6;
3396
- $[16] = t7;
3397
- } else {
3398
- t7 = $[16];
3399
- }
3400
- return t7;
3401
- }
3402
- const t3 = rowPinningDisplayMode === "bottom" ? "bottom" : "top";
3403
- let t4;
3404
- if ($[17] !== rowPinButtonProps || $[18] !== t3) {
3405
- t4 = /*#__PURE__*/jsxRuntime.jsx(MRT_RowPinButton, {
3406
- pinningPosition: t3,
3407
- ...rowPinButtonProps
3408
- });
3409
- $[17] = rowPinButtonProps;
3410
- $[18] = t3;
3411
- $[19] = t4;
3412
- } else {
3413
- t4 = $[19];
3414
- }
3415
- return t4;
3416
- };
3417
- function _temp$x(state) {
3418
- return state.density;
3419
- }
3420
-
3421
- const getMRT_RowPinningColumnDef = tableOptions => {
3422
- return {
3423
- Cell: ({
3424
- row,
3425
- table
3426
- }) => /*#__PURE__*/jsxRuntime.jsx(MRT_TableBodyRowPinButton, {
3427
- row: row,
3428
- table: table
3429
- }),
3430
- grow: false,
3431
- ...defaultDisplayColumnProps({
3432
- header: 'pin',
3433
- id: 'mrt-row-pin',
3434
- size: 60,
3435
- tableOptions
3436
- })
3437
- };
3438
- };
3439
-
3440
- const MRT_SelectCheckbox = t0 => {
3441
- const $ = compilerRuntime.c(32);
3442
- let rest;
3443
- let row;
3444
- let staticRowIndex;
3445
- let table;
3446
- if ($[0] !== t0) {
3447
- ({
3448
- row,
3449
- staticRowIndex,
3450
- table,
3451
- ...rest
3452
- } = t0);
3453
- $[0] = t0;
3454
- $[1] = rest;
3455
- $[2] = row;
3456
- $[3] = staticRowIndex;
3457
- $[4] = table;
3458
- } else {
3459
- rest = $[1];
3460
- row = $[2];
3461
- staticRowIndex = $[3];
3462
- table = $[4];
3463
- }
3464
- const {
3465
- getState,
3466
- options: t1
3467
- } = table;
3468
- const {
3469
- enableMultiRowSelection,
3470
- localization,
3471
- muiSelectAllCheckboxProps,
3472
- muiSelectCheckboxProps,
3473
- selectAllMode
3474
- } = t1;
3475
- let t2;
3476
- if ($[5] !== getState) {
3477
- t2 = getState();
3478
- $[5] = getState;
3479
- $[6] = t2;
3480
- } else {
3481
- t2 = $[6];
3482
- }
3483
- const {
3484
- isLoading
3485
- } = t2;
3486
- const density = reactStore.useSelector(table.store, _temp$w);
3487
- const selectAll = !row;
3488
- let t3;
3489
- if ($[7] !== row || $[8] !== staticRowIndex || $[9] !== table) {
3490
- t3 = row ? getMRT_RowSelectionHandler({
3491
- row,
3492
- staticRowIndex,
3493
- table
3494
- }) : undefined;
3495
- $[7] = row;
3496
- $[8] = staticRowIndex;
3497
- $[9] = table;
3498
- $[10] = t3;
3499
- } else {
3500
- t3 = $[10];
3501
- }
3502
- const onSelectionChange = t3;
3503
- let t4;
3504
- if ($[11] !== table) {
3505
- t4 = getMRT_SelectAllHandler({
3506
- table
3507
- });
3508
- $[11] = table;
3509
- $[12] = t4;
3510
- } else {
3511
- t4 = $[12];
3512
- }
3513
- const onSelectAllChange = t4;
3514
- let t5;
3515
- if ($[13] !== density || $[14] !== enableMultiRowSelection || $[15] !== isLoading || $[16] !== localization.toggleSelectAll || $[17] !== localization.toggleSelectRow || $[18] !== muiSelectAllCheckboxProps || $[19] !== muiSelectCheckboxProps || $[20] !== onSelectAllChange || $[21] !== onSelectionChange || $[22] !== rest || $[23] !== row || $[24] !== selectAll || $[25] !== selectAllMode || $[26] !== staticRowIndex || $[27] !== table) {
3516
- t5 = () => {
3517
- const allRowsSelected = selectAll ? selectAllMode === "page" ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected() : undefined;
3518
- const isChecked = selectAll ? allRowsSelected : getIsRowSelected({
3519
- row,
3520
- table
3521
- });
3522
- const checkboxProps = {
3523
- ...(selectAll ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, {
3524
- table
3525
- }) : parseFromValuesOrFunc(muiSelectCheckboxProps, {
3526
- row,
3527
- staticRowIndex,
3528
- table
3529
- })),
3530
- ...rest
3531
- };
3532
- const commonProps = {
3533
- "aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow,
3534
- checked: isChecked,
3535
- disabled: isLoading || row && !row.getCanSelect() || row?.id === "mrt-row-create",
3536
- inputProps: {
3537
- "aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
3538
- },
3539
- onChange: event => {
3540
- event.stopPropagation();
3541
- selectAll ? onSelectAllChange(event) : onSelectionChange(event);
3542
- },
3543
- size: density === "compact" ? "small" : "medium",
3544
- ...checkboxProps,
3545
- onClick: e => {
3546
- e.stopPropagation();
3547
- checkboxProps?.onClick?.(e);
3548
- },
3549
- sx: theme => ({
3550
- height: density === "compact" ? "1.75rem" : "2.5rem",
3551
- m: density !== "compact" ? "-0.4rem" : undefined,
3552
- width: density === "compact" ? "1.75rem" : "2.5rem",
3553
- zIndex: 0,
3554
- ...parseFromValuesOrFunc(checkboxProps?.sx, theme)
3555
- }),
3556
- title: undefined
3557
- };
3558
- return /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
3559
- ...getCommonTooltipProps(),
3560
- title: checkboxProps?.title ?? (selectAll ? localization.toggleSelectAll : localization.toggleSelectRow),
3561
- children: enableMultiRowSelection === false ? /*#__PURE__*/jsxRuntime.jsx(Radio, {
3562
- ...commonProps
3563
- }) : /*#__PURE__*/jsxRuntime.jsx(Checkbox, {
3564
- disableRipple: true,
3565
- indeterminate: !isChecked && selectAll ? table.getIsSomeRowsSelected() : row?.getIsSomeSelected() && row.getCanSelectSubRows(),
3566
- ...commonProps
3567
- })
3568
- });
3611
+ } = t1;
3612
+ const density = reactStore.useSelector(table.store, _temp$w);
3613
+ const canPin = parseFromValuesOrFunc(enableRowPinning, row);
3614
+ if (!canPin) {
3615
+ return null;
3616
+ }
3617
+ let t2;
3618
+ if ($[4] !== rest || $[5] !== row || $[6] !== table) {
3619
+ t2 = {
3620
+ row,
3621
+ table,
3622
+ ...rest
3569
3623
  };
3570
- $[13] = density;
3571
- $[14] = enableMultiRowSelection;
3572
- $[15] = isLoading;
3573
- $[16] = localization.toggleSelectAll;
3574
- $[17] = localization.toggleSelectRow;
3575
- $[18] = muiSelectAllCheckboxProps;
3576
- $[19] = muiSelectCheckboxProps;
3577
- $[20] = onSelectAllChange;
3578
- $[21] = onSelectionChange;
3579
- $[22] = rest;
3580
- $[23] = row;
3581
- $[24] = selectAll;
3582
- $[25] = selectAllMode;
3583
- $[26] = staticRowIndex;
3584
- $[27] = table;
3585
- $[28] = t5;
3624
+ $[4] = rest;
3625
+ $[5] = row;
3626
+ $[6] = table;
3627
+ $[7] = t2;
3586
3628
  } else {
3587
- t5 = $[28];
3629
+ t2 = $[7];
3588
3630
  }
3589
- let t6;
3590
- if ($[29] !== t5 || $[30] !== table.store) {
3591
- t6 = /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
3592
- selector: _temp2$b,
3593
- source: table.store,
3594
- children: t5
3631
+ const rowPinButtonProps = t2;
3632
+ if (rowPinningDisplayMode === "top-and-bottom" && !row.getIsPinned()) {
3633
+ const t3 = density === "compact" ? "row" : "column";
3634
+ let t4;
3635
+ if ($[8] !== t3) {
3636
+ t4 = {
3637
+ display: "flex",
3638
+ flexDirection: t3
3639
+ };
3640
+ $[8] = t3;
3641
+ $[9] = t4;
3642
+ } else {
3643
+ t4 = $[9];
3644
+ }
3645
+ let t5;
3646
+ let t6;
3647
+ if ($[10] !== rowPinButtonProps) {
3648
+ t5 = /*#__PURE__*/jsxRuntime.jsx(MRT_RowPinButton, {
3649
+ pinningPosition: "top",
3650
+ ...rowPinButtonProps
3651
+ });
3652
+ t6 = /*#__PURE__*/jsxRuntime.jsx(MRT_RowPinButton, {
3653
+ pinningPosition: "bottom",
3654
+ ...rowPinButtonProps
3655
+ });
3656
+ $[10] = rowPinButtonProps;
3657
+ $[11] = t5;
3658
+ $[12] = t6;
3659
+ } else {
3660
+ t5 = $[11];
3661
+ t6 = $[12];
3662
+ }
3663
+ let t7;
3664
+ if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
3665
+ t7 = /*#__PURE__*/jsxRuntime.jsxs(Box, {
3666
+ sx: t4,
3667
+ children: [t5, t6]
3668
+ });
3669
+ $[13] = t4;
3670
+ $[14] = t5;
3671
+ $[15] = t6;
3672
+ $[16] = t7;
3673
+ } else {
3674
+ t7 = $[16];
3675
+ }
3676
+ return t7;
3677
+ }
3678
+ const t3 = rowPinningDisplayMode === "bottom" ? "bottom" : "top";
3679
+ let t4;
3680
+ if ($[17] !== rowPinButtonProps || $[18] !== t3) {
3681
+ t4 = /*#__PURE__*/jsxRuntime.jsx(MRT_RowPinButton, {
3682
+ pinningPosition: t3,
3683
+ ...rowPinButtonProps
3595
3684
  });
3596
- $[29] = t5;
3597
- $[30] = table.store;
3598
- $[31] = t6;
3685
+ $[17] = rowPinButtonProps;
3686
+ $[18] = t3;
3687
+ $[19] = t4;
3599
3688
  } else {
3600
- t6 = $[31];
3689
+ t4 = $[19];
3601
3690
  }
3602
- return t6;
3691
+ return t4;
3603
3692
  };
3604
3693
  function _temp$w(state) {
3605
3694
  return state.density;
3606
3695
  }
3607
- function _temp2$b(state_0) {
3608
- return {
3609
- pagination: state_0.pagination,
3610
- rowSelection: state_0.rowSelection
3611
- };
3612
- }
3613
3696
 
3614
- const getMRT_RowSelectColumnDef = tableOptions => {
3615
- const {
3616
- enableMultiRowSelection,
3617
- enableSelectAll
3618
- } = tableOptions;
3697
+ const getMRT_RowPinningColumnDef = tableOptions => {
3619
3698
  return {
3620
3699
  Cell: ({
3621
3700
  row,
3622
- staticRowIndex,
3623
3701
  table
3624
- }) => /*#__PURE__*/jsxRuntime.jsx(MRT_SelectCheckbox, {
3702
+ }) => /*#__PURE__*/jsxRuntime.jsx(MRT_TableBodyRowPinButton, {
3625
3703
  row: row,
3626
- staticRowIndex: staticRowIndex,
3627
3704
  table: table
3628
3705
  }),
3629
- Header: enableSelectAll && enableMultiRowSelection ? ({
3630
- table
3631
- }) => /*#__PURE__*/jsxRuntime.jsx(MRT_SelectCheckbox, {
3632
- table: table
3633
- }) : undefined,
3634
3706
  grow: false,
3635
3707
  ...defaultDisplayColumnProps({
3636
- columnSpecificDefaults: {
3637
- enableColumnActions: true,
3638
- enablePinning: true
3639
- },
3640
- header: 'select',
3641
- id: '__check__',
3642
- size: 56,
3708
+ header: 'pin',
3709
+ id: 'mrt-row-pin',
3710
+ size: 60,
3643
3711
  tableOptions
3644
3712
  })
3645
3713
  };
@@ -3817,6 +3885,7 @@ const MRT_Localization_EN = {
3817
3885
  search: 'Search',
3818
3886
  selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
3819
3887
  select: 'Select',
3888
+ selection: 'Selection',
3820
3889
  selectAllOnAllPages: 'Select all on all pages',
3821
3890
  selectAllOnCurrentPage: 'Select all on current page',
3822
3891
  showAll: 'Show all',
@@ -4484,10 +4553,31 @@ const useMRT_TableInstance = definedTableOptions => {
4484
4553
  const {
4485
4554
  grouping: stateGrouping
4486
4555
  } = statefulTableOptions.state;
4487
- statefulTableOptions.columns = react.useMemo(() => prepareColumns({
4488
- columnDefs: [...[showRowPinningColumn(statefulTableOptions) && getMRT_RowPinningColumnDef(statefulTableOptions), showRowActionsColumn(statefulTableOptions) && getMRT_RowActionsColumnDef(statefulTableOptions), showRowExpandColumn(statefulTableOptions) && getMRT_RowExpandColumnDef(statefulTableOptions), showRowSelectionColumn(statefulTableOptions) && getMRT_RowSelectColumnDef(statefulTableOptions), showRowNumbersColumn(statefulTableOptions) && getMRT_RowNumbersColumnDef(statefulTableOptions)].filter(Boolean), ...rawColumns, ...[showRowSpacerColumn(statefulTableOptions) && getMRT_RowSpacerColumnDef(statefulTableOptions)].filter(Boolean)],
4489
- tableOptions: statefulTableOptions
4490
- }), [rawColumns, defaultDisplayColumn, displayColumnDefOptions, enableEditing, enableExpanding, enableGrouping, enableRowActions, enableRowNumbers, enableRowPinning, enableRowSelection, layoutMode, localization, renderDetailPanel, rowNumberDisplayMode, rowPinningDisplayMode, stateGrouping]);
4556
+ statefulTableOptions.columns = react.useMemo(() => {
4557
+ const displayColumnDefsBefore = [showRowPinningColumn(statefulTableOptions) && getMRT_RowPinningColumnDef(statefulTableOptions), showRowActionsColumn(statefulTableOptions) && getMRT_RowActionsColumnDef(statefulTableOptions), showRowExpandColumn(statefulTableOptions) && getMRT_RowExpandColumnDef(statefulTableOptions), showRowNumbersColumn(statefulTableOptions) && getMRT_RowNumbersColumnDef(statefulTableOptions)].filter(Boolean);
4558
+
4559
+ // Display columns ship with a fixed fallback `size` — a reasonable guess
4560
+ // for before any real content exists (e.g. a checkbox or chevron
4561
+ // button) — but unlike a user-authored column's explicit `size`, that
4562
+ // fallback was never meant to be final. They're autosize candidates the
4563
+ // same as any other column with no explicit size, unless the consumer
4564
+ // pinned one down themselves via `displayColumnDefOptions`. This runs
4565
+ // before `prepareColumns` below for the same reason `rawColumns` is
4566
+ // snapshotted above: once sizes are backfilled, "no explicit size" can
4567
+ // no longer be told apart from "explicitly sized". `mrt-row-spacer` is
4568
+ // structural (tree-depth indentation), never content, so it's excluded
4569
+ // by simply never being added here.
4570
+ displayColumnDefsBefore.forEach(columnDef => {
4571
+ const id = columnDef.id;
4572
+ if (id && displayColumnDefOptions?.[id]?.size === undefined) {
4573
+ autoSizeColumnIdsRef.current.add(id);
4574
+ }
4575
+ });
4576
+ return prepareColumns({
4577
+ columnDefs: [...displayColumnDefsBefore, ...rawColumns, ...[showRowSpacerColumn(statefulTableOptions) && getMRT_RowSpacerColumnDef(statefulTableOptions)].filter(Boolean)],
4578
+ tableOptions: statefulTableOptions
4579
+ });
4580
+ }, [rawColumns, defaultDisplayColumn, displayColumnDefOptions, enableEditing, enableExpanding, enableGrouping, enableRowActions, enableRowNumbers, enableRowPinning, enableRowSelection, layoutMode, localization, renderDetailPanel, rowNumberDisplayMode, rowPinningDisplayMode, stateGrouping]);
4491
4581
 
4492
4582
  //if loading, generate blank rows to show skeleton loaders
4493
4583
  // pagination.pageSize is deliberately read here without being a dependency:
@@ -7352,7 +7442,7 @@ const MRT_IconStatusDot = /*#__PURE__*/react.forwardRef((t0, ref) => {
7352
7442
  MRT_IconStatusDot.displayName = 'MRT_IconStatusDot';
7353
7443
 
7354
7444
  const Iconify = /*#__PURE__*/react.forwardRef((t0, ref) => {
7355
- const $ = compilerRuntime.c(13);
7445
+ const $ = compilerRuntime.c(16);
7356
7446
  let icon;
7357
7447
  let other;
7358
7448
  let sx;
@@ -7376,38 +7466,55 @@ const Iconify = /*#__PURE__*/react.forwardRef((t0, ref) => {
7376
7466
  t1 = $[4];
7377
7467
  }
7378
7468
  const width = t1 === undefined ? 20 : t1;
7469
+ const fallbackSize = typeof width === "number" || typeof width === "string" ? width : 20;
7379
7470
  let t2;
7380
- if ($[5] !== sx || $[6] !== width) {
7381
- t2 = {
7471
+ if ($[5] !== fallbackSize) {
7472
+ t2 = /*#__PURE__*/jsxRuntime.jsx("span", {
7473
+ style: {
7474
+ display: "inline-block",
7475
+ width: fallbackSize,
7476
+ height: fallbackSize
7477
+ }
7478
+ });
7479
+ $[5] = fallbackSize;
7480
+ $[6] = t2;
7481
+ } else {
7482
+ t2 = $[6];
7483
+ }
7484
+ let t3;
7485
+ if ($[7] !== sx || $[8] !== width) {
7486
+ t3 = {
7382
7487
  width,
7383
7488
  height: width,
7384
7489
  ...sx
7385
7490
  };
7386
- $[5] = sx;
7387
- $[6] = width;
7388
- $[7] = t2;
7491
+ $[7] = sx;
7492
+ $[8] = width;
7493
+ $[9] = t3;
7389
7494
  } else {
7390
- t2 = $[7];
7495
+ t3 = $[9];
7391
7496
  }
7392
- let t3;
7393
- if ($[8] !== icon || $[9] !== other || $[10] !== ref || $[11] !== t2) {
7394
- t3 = /*#__PURE__*/jsxRuntime.jsx(Box, {
7497
+ let t4;
7498
+ if ($[10] !== icon || $[11] !== other || $[12] !== ref || $[13] !== t2 || $[14] !== t3) {
7499
+ t4 = /*#__PURE__*/jsxRuntime.jsx(Box, {
7395
7500
  ref: ref,
7396
7501
  component: react$1.Icon,
7397
7502
  className: "component-iconify",
7398
7503
  icon: icon,
7399
- sx: t2,
7504
+ fallback: t2,
7505
+ sx: t3,
7400
7506
  ...other
7401
7507
  });
7402
- $[8] = icon;
7403
- $[9] = other;
7404
- $[10] = ref;
7405
- $[11] = t2;
7406
- $[12] = t3;
7508
+ $[10] = icon;
7509
+ $[11] = other;
7510
+ $[12] = ref;
7511
+ $[13] = t2;
7512
+ $[14] = t3;
7513
+ $[15] = t4;
7407
7514
  } else {
7408
- t3 = $[12];
7515
+ t4 = $[15];
7409
7516
  }
7410
- return t3;
7517
+ return t4;
7411
7518
  });
7412
7519
  var Iconify$1 = Iconify;
7413
7520
 
@@ -10194,6 +10301,7 @@ const MRT_Localization_HR = {
10194
10301
  search: 'Pretraži',
10195
10302
  selectedCountOfRowCountRowsSelected: '{selectedCount} od {rowCount} odabranih redaka',
10196
10303
  select: 'Odaberi',
10304
+ selection: 'Odabir',
10197
10305
  selectAllOnAllPages: 'Odaberi sve na svim stranicama',
10198
10306
  selectAllOnCurrentPage: 'Odaberi sve na trenutnoj stranici',
10199
10307
  showAll: 'Prikaži sve',
@@ -12556,7 +12664,7 @@ const MRT_NewEntryButton = t0 => {
12556
12664
  };
12557
12665
 
12558
12666
  const MRT_ShowHideColumnsMenuItems = t0 => {
12559
- const $ = compilerRuntime.c(47);
12667
+ const $ = compilerRuntime.c(50);
12560
12668
  let allColumns;
12561
12669
  let column;
12562
12670
  let hoveredColumn;
@@ -12609,8 +12717,18 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12609
12717
  columnDefType
12610
12718
  } = columnDef;
12611
12719
  let t3;
12612
- if ($[8] !== columnDefType) {
12613
- t3 = (column_0, isCurrentlyVisible) => {
12720
+ if ($[8] !== column || $[9] !== localization) {
12721
+ t3 = getColumnMenuLabel(column, localization);
12722
+ $[8] = column;
12723
+ $[9] = localization;
12724
+ $[10] = t3;
12725
+ } else {
12726
+ t3 = $[10];
12727
+ }
12728
+ const label = t3;
12729
+ let t4;
12730
+ if ($[11] !== columnDefType) {
12731
+ t4 = (column_0, isCurrentlyVisible) => {
12614
12732
  if (columnDefType === "group") {
12615
12733
  column_0?.columns?.forEach?.(childColumn => {
12616
12734
  childColumn.toggleVisibility(!isCurrentlyVisible);
@@ -12619,34 +12737,34 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12619
12737
  column_0.toggleVisibility();
12620
12738
  }
12621
12739
  };
12622
- $[8] = columnDefType;
12623
- $[9] = t3;
12740
+ $[11] = columnDefType;
12741
+ $[12] = t4;
12624
12742
  } else {
12625
- t3 = $[9];
12743
+ t4 = $[12];
12626
12744
  }
12627
- const handleToggleColumnHidden = t3;
12628
- if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
12745
+ const handleToggleColumnHidden = t4;
12746
+ if (!label || columnDef.visibleInShowHideMenu === false) {
12629
12747
  return null;
12630
12748
  }
12631
- let t4;
12632
- if ($[10] !== column || $[11] !== enableHiding || $[12] !== handleToggleColumnHidden || $[13] !== rest) {
12633
- t4 = event => {
12749
+ let t5;
12750
+ if ($[13] !== column || $[14] !== enableHiding || $[15] !== handleToggleColumnHidden || $[16] !== rest) {
12751
+ t5 = event => {
12634
12752
  rest?.onClick?.(event);
12635
12753
  if (enableHiding && column.getCanHide()) {
12636
12754
  handleToggleColumnHidden(column, column.getIsVisible());
12637
12755
  }
12638
12756
  };
12639
- $[10] = column;
12640
- $[11] = enableHiding;
12641
- $[12] = handleToggleColumnHidden;
12642
- $[13] = rest;
12643
- $[14] = t4;
12757
+ $[13] = column;
12758
+ $[14] = enableHiding;
12759
+ $[15] = handleToggleColumnHidden;
12760
+ $[16] = rest;
12761
+ $[17] = t5;
12644
12762
  } else {
12645
- t4 = $[14];
12763
+ t5 = $[17];
12646
12764
  }
12647
- let t5;
12648
- if ($[15] !== column.depth || $[16] !== column.id || $[17] !== draggingBorderColor || $[18] !== hoveredColumn?.id || $[19] !== rest?.sx) {
12649
- t5 = theme => ({
12765
+ let t6;
12766
+ if ($[18] !== column.depth || $[19] !== column.id || $[20] !== draggingBorderColor || $[21] !== hoveredColumn?.id || $[22] !== rest?.sx) {
12767
+ t6 = theme => ({
12650
12768
  alignItems: "center",
12651
12769
  justifyContent: "flex-start",
12652
12770
  my: 0,
@@ -12656,31 +12774,31 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12656
12774
  py: "6px",
12657
12775
  ...parseFromValuesOrFunc(rest?.sx, theme)
12658
12776
  });
12659
- $[15] = column.depth;
12660
- $[16] = column.id;
12661
- $[17] = draggingBorderColor;
12662
- $[18] = hoveredColumn?.id;
12663
- $[19] = rest?.sx;
12664
- $[20] = t5;
12777
+ $[18] = column.depth;
12778
+ $[19] = column.id;
12779
+ $[20] = draggingBorderColor;
12780
+ $[21] = hoveredColumn?.id;
12781
+ $[22] = rest?.sx;
12782
+ $[23] = t6;
12665
12783
  } else {
12666
- t5 = $[20];
12784
+ t6 = $[23];
12667
12785
  }
12668
- const t6 = `column-show-hide-row-${column.id}`;
12669
- let t7;
12670
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
12671
- t7 = {
12786
+ const t7 = `column-show-hide-row-${column.id}`;
12787
+ let t8;
12788
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
12789
+ t8 = {
12672
12790
  display: "flex",
12673
12791
  flexWrap: "nowrap",
12674
12792
  gap: "8px",
12675
12793
  width: "100%"
12676
12794
  };
12677
- $[21] = t7;
12795
+ $[24] = t8;
12678
12796
  } else {
12679
- t7 = $[21];
12797
+ t8 = $[24];
12680
12798
  }
12681
- let t8;
12682
- if ($[22] !== column || $[23] !== columnDef.header || $[24] !== columnDefType || $[25] !== enableHiding || $[26] !== localization || $[27] !== table.atoms) {
12683
- t8 = enableHiding ? /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
12799
+ let t9;
12800
+ if ($[25] !== column || $[26] !== columnDefType || $[27] !== enableHiding || $[28] !== label || $[29] !== localization || $[30] !== table.atoms) {
12801
+ t9 = enableHiding ? /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
12684
12802
  source: table.atoms.columnVisibility,
12685
12803
  children: () => {
12686
12804
  const switchChecked = column.getIsVisible();
@@ -12702,7 +12820,7 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12702
12820
  })
12703
12821
  }),
12704
12822
  disabled: !column.getCanHide(),
12705
- label: columnDef.header,
12823
+ label: label,
12706
12824
  onChange: _temp$g
12707
12825
  });
12708
12826
  }
@@ -12710,51 +12828,51 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12710
12828
  sx: {
12711
12829
  alignSelf: "center"
12712
12830
  },
12713
- children: columnDef.header
12714
- });
12715
- $[22] = column;
12716
- $[23] = columnDef.header;
12717
- $[24] = columnDefType;
12718
- $[25] = enableHiding;
12719
- $[26] = localization;
12720
- $[27] = table.atoms;
12721
- $[28] = t8;
12722
- } else {
12723
- t8 = $[28];
12724
- }
12725
- let t9;
12726
- if ($[29] !== t6 || $[30] !== t8) {
12727
- t9 = /*#__PURE__*/jsxRuntime.jsx(Box, {
12728
- "data-testid": t6,
12729
- sx: t7,
12730
- children: t8
12831
+ children: label
12731
12832
  });
12732
- $[29] = t6;
12733
- $[30] = t8;
12833
+ $[25] = column;
12834
+ $[26] = columnDefType;
12835
+ $[27] = enableHiding;
12836
+ $[28] = label;
12837
+ $[29] = localization;
12838
+ $[30] = table.atoms;
12734
12839
  $[31] = t9;
12735
12840
  } else {
12736
12841
  t9 = $[31];
12737
12842
  }
12738
12843
  let t10;
12739
- if ($[32] !== rest || $[33] !== t4 || $[34] !== t5 || $[35] !== t9) {
12740
- t10 = /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
12844
+ if ($[32] !== t7 || $[33] !== t9) {
12845
+ t10 = /*#__PURE__*/jsxRuntime.jsx(Box, {
12846
+ "data-testid": t7,
12847
+ sx: t8,
12848
+ children: t9
12849
+ });
12850
+ $[32] = t7;
12851
+ $[33] = t9;
12852
+ $[34] = t10;
12853
+ } else {
12854
+ t10 = $[34];
12855
+ }
12856
+ let t11;
12857
+ if ($[35] !== rest || $[36] !== t10 || $[37] !== t5 || $[38] !== t6) {
12858
+ t11 = /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
12741
12859
  disableRipple: true,
12742
12860
  ...rest,
12743
- onClick: t4,
12744
- sx: t5,
12745
- children: t9
12861
+ onClick: t5,
12862
+ sx: t6,
12863
+ children: t10
12746
12864
  });
12747
- $[32] = rest;
12748
- $[33] = t4;
12749
- $[34] = t5;
12750
- $[35] = t9;
12865
+ $[35] = rest;
12751
12866
  $[36] = t10;
12867
+ $[37] = t5;
12868
+ $[38] = t6;
12869
+ $[39] = t11;
12752
12870
  } else {
12753
- t10 = $[36];
12871
+ t11 = $[39];
12754
12872
  }
12755
- let t11;
12756
- if ($[37] !== allColumns || $[38] !== column.columns || $[39] !== hoveredColumn || $[40] !== isNestedColumns || $[41] !== setHoveredColumn || $[42] !== table) {
12757
- t11 = column.columns?.map((c, i) => /*#__PURE__*/jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, {
12873
+ let t12;
12874
+ if ($[40] !== allColumns || $[41] !== column.columns || $[42] !== hoveredColumn || $[43] !== isNestedColumns || $[44] !== setHoveredColumn || $[45] !== table) {
12875
+ t12 = column.columns?.map((c, i) => /*#__PURE__*/jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, {
12758
12876
  allColumns: allColumns,
12759
12877
  column: c,
12760
12878
  hoveredColumn: hoveredColumn,
@@ -12762,40 +12880,37 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12762
12880
  setHoveredColumn: setHoveredColumn,
12763
12881
  table: table
12764
12882
  }, `${i}-${c.id}`));
12765
- $[37] = allColumns;
12766
- $[38] = column.columns;
12767
- $[39] = hoveredColumn;
12768
- $[40] = isNestedColumns;
12769
- $[41] = setHoveredColumn;
12770
- $[42] = table;
12771
- $[43] = t11;
12883
+ $[40] = allColumns;
12884
+ $[41] = column.columns;
12885
+ $[42] = hoveredColumn;
12886
+ $[43] = isNestedColumns;
12887
+ $[44] = setHoveredColumn;
12888
+ $[45] = table;
12889
+ $[46] = t12;
12772
12890
  } else {
12773
- t11 = $[43];
12891
+ t12 = $[46];
12774
12892
  }
12775
- let t12;
12776
- if ($[44] !== t10 || $[45] !== t11) {
12777
- t12 = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
12778
- children: [t10, t11]
12893
+ let t13;
12894
+ if ($[47] !== t11 || $[48] !== t12) {
12895
+ t13 = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
12896
+ children: [t11, t12]
12779
12897
  });
12780
- $[44] = t10;
12781
- $[45] = t11;
12782
- $[46] = t12;
12898
+ $[47] = t11;
12899
+ $[48] = t12;
12900
+ $[49] = t13;
12783
12901
  } else {
12784
- t12 = $[46];
12902
+ t13 = $[49];
12785
12903
  }
12786
- return t12;
12904
+ return t13;
12787
12905
  };
12788
12906
  function _temp$g() {}
12789
12907
 
12790
- // Matches a column if its own header text contains the search term, or any of
12791
- // its nested (grouped) columns do — a matching group keeps all of its
12792
- // children rather than filtering within the group, so the tree stays intact.
12793
- const columnMatchesSearch = (column, term) => {
12794
- const header = column.columnDef.header;
12908
+ const columnMatchesSearch = (column, term, localization) => {
12909
+ const header = getColumnMenuLabel(column, localization);
12795
12910
  if (typeof header === 'string' && header.toLowerCase().includes(term)) {
12796
12911
  return true;
12797
12912
  }
12798
- return !!column.columns?.some(child => columnMatchesSearch(child, term));
12913
+ return !!column.columns?.some(child => columnMatchesSearch(child, term, localization));
12799
12914
  };
12800
12915
  const MRT_ShowHideColumnsMenu = ({
12801
12916
  anchorEl,
@@ -12852,8 +12967,8 @@ const MRT_ShowHideColumnsMenu = ({
12852
12967
  const trimmedSearchText = searchText.trim().toLowerCase();
12853
12968
  const filteredColumns = react.useMemo(() => {
12854
12969
  if (!trimmedSearchText) return allColumns;
12855
- return allColumns.filter(column_1 => columnMatchesSearch(column_1, trimmedSearchText));
12856
- }, [allColumns, trimmedSearchText]);
12970
+ return allColumns.filter(column_1 => columnMatchesSearch(column_1, trimmedSearchText, localization));
12971
+ }, [allColumns, trimmedSearchText, localization]);
12857
12972
  const handleSearchChange = event => {
12858
12973
  setSearchText(event.target.value);
12859
12974
  };
@@ -13813,7 +13928,7 @@ const BODY_CELL_SELECTOR = '[data-column-id]';
13813
13928
  * the container. Once every candidate is settled it is an early return.
13814
13929
  */
13815
13930
  const MRT_AutoSizeColumnsEffect = t0 => {
13816
- const $ = compilerRuntime.c(9);
13931
+ const $ = compilerRuntime.c(10);
13817
13932
  const {
13818
13933
  table
13819
13934
  } = t0;
@@ -13838,7 +13953,7 @@ const MRT_AutoSizeColumnsEffect = t0 => {
13838
13953
  }
13839
13954
  const settledIdsRef = react.useRef(t2);
13840
13955
  let t3;
13841
- if ($[1] !== autoSizeColumnIdsRef || $[2] !== autoSizedColumnWidthsRef || $[3] !== getColumn || $[4] !== getRowModel || $[5] !== getState || $[6] !== setColumnSizing || $[7] !== tableRef) {
13956
+ if ($[1] !== autoSizeColumnIdsRef || $[2] !== autoSizedColumnWidthsRef || $[3] !== getColumn || $[4] !== getRowModel || $[5] !== getState || $[6] !== setColumnSizing || $[7] !== table || $[8] !== tableRef) {
13842
13957
  t3 = () => {
13843
13958
  const candidateIds = autoSizeColumnIdsRef.current;
13844
13959
  const settledIds = settledIdsRef.current;
@@ -13881,6 +13996,31 @@ const MRT_AutoSizeColumnsEffect = t0 => {
13881
13996
  });
13882
13997
  });
13883
13998
  if (Object.keys(updates).length) {
13999
+ for (const header of table.getFlatHeaders()) {
14000
+ const width = updates[header.column.id];
14001
+ if (width === undefined) {
14002
+ continue;
14003
+ }
14004
+ tableEl.style.setProperty(`--header-${parseCSSVarId(header.id)}-size`, `${width}`);
14005
+ tableEl.style.setProperty(`--col-${parseCSSVarId(header.column.id)}-size`, `${width}`);
14006
+ tableEl.style.setProperty(`--col-${parseCSSVarId(header.column.id)}-grow`, `${getColumnGrowWeight(header.column, table)}`);
14007
+ }
14008
+ if (table.options.layoutMode?.startsWith("grid")) {
14009
+ for (const columnId_0 of Object.keys(updates)) {
14010
+ const column_0 = getColumn(columnId_0);
14011
+ if (!getColumnGrowWeight(column_0, table)) {
14012
+ continue;
14013
+ }
14014
+ const cell = tableEl.querySelector(`[data-column-id="${CSS.escape(columnId_0)}"]`) ?? table.refs.tableHeadCellRefs.current?.[columnId_0];
14015
+ const renderedWidth = cell?.getBoundingClientRect().width ?? 0;
14016
+ const {
14017
+ maxSize
14018
+ } = getColumnSizeBounds(column_0.columnDef);
14019
+ if (renderedWidth > updates[columnId_0]) {
14020
+ updates[columnId_0] = Math.min(renderedWidth, maxSize);
14021
+ }
14022
+ }
14023
+ }
13884
14024
  Object.assign(autoSizedColumnWidthsRef.current, updates);
13885
14025
  setColumnSizing(old => ({
13886
14026
  ...old,
@@ -13894,10 +14034,11 @@ const MRT_AutoSizeColumnsEffect = t0 => {
13894
14034
  $[4] = getRowModel;
13895
14035
  $[5] = getState;
13896
14036
  $[6] = setColumnSizing;
13897
- $[7] = tableRef;
13898
- $[8] = t3;
14037
+ $[7] = table;
14038
+ $[8] = tableRef;
14039
+ $[9] = t3;
13899
14040
  } else {
13900
- t3 = $[8];
14041
+ t3 = $[9];
13901
14042
  }
13902
14043
  react.useLayoutEffect(t3);
13903
14044
  return null;
@@ -14403,10 +14544,17 @@ const MRT_TableBodyCell = ({
14403
14544
  const size = column.getSize();
14404
14545
  setSkeletonWidth(columnDefType === 'display' ? size / 2 : Math.round(Math.random() * (size - size / 3) + size / 3));
14405
14546
  }, [isLoading, showSkeletons]);
14547
+
14548
+ // Asserted with `!important` so this always wins over a consumer's own
14549
+ // `MuiTableCell`/`MuiTableRow` theme overrides (e.g. the common MUI docs
14550
+ // pattern of stripping the last row's border via `&:last-child td`) —
14551
+ // the last row keeping its bottom border is part of MRT's own visual
14552
+ // contract, not something a host app's table theme should be able to undo.
14553
+ const isLastRow = !!numRows && staticRowIndex === numRows - 1;
14554
+ const lastRowBorderBottom = isLastRow ? `1px solid ${theme.palette.divider} !important` : undefined;
14406
14555
  const draggingBorders = react.useMemo(() => {
14407
14556
  const isFirstColumn = column.getIsFirstColumn();
14408
14557
  const isLastColumn = column.getIsLastColumn();
14409
- const isLastRow = numRows && staticRowIndex === numRows - 1;
14410
14558
  const isResizingColumn = isResizingThisColumn;
14411
14559
  const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
14412
14560
  const borderStyle = showResizeBorder ? `2px solid ${draggingBorderColor} !important` : isDraggingColumn || isDraggingRow ? `1px dashed ${theme.palette.grey[500]} !important` : isHoveredColumn || isHoveredRow || isResizingColumn ? `2px dashed ${draggingBorderColor} !important` : undefined;
@@ -14418,12 +14566,12 @@ const MRT_TableBodyCell = ({
14418
14566
  };
14419
14567
  }
14420
14568
  return borderStyle ? {
14421
- borderBottom: isDraggingRow || isHoveredRow || isLastRow && !isResizingColumn ? borderStyle : undefined,
14569
+ borderBottom: isDraggingRow || isHoveredRow || isLastRow && !isResizingColumn ? borderStyle : lastRowBorderBottom,
14422
14570
  borderLeft: isDraggingColumn || isHoveredColumn || (isDraggingRow || isHoveredRow) && isFirstColumn ? borderStyle : undefined,
14423
14571
  borderRight: isDraggingColumn || isHoveredColumn || (isDraggingRow || isHoveredRow) && isLastColumn ? borderStyle : undefined,
14424
14572
  borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined
14425
14573
  } : undefined;
14426
- }, [isResizingThisColumn, isDraggingColumn, isDraggingRow, isHoveredColumn, isHoveredRow, staticRowIndex]);
14574
+ }, [isResizingThisColumn, isDraggingColumn, isDraggingRow, isHoveredColumn, isHoveredRow, isLastRow, lastRowBorderBottom]);
14427
14575
  const isColumnPinned = enableColumnPinning && columnDef.columnDefType !== 'group' && column.getIsPinned();
14428
14576
  const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
14429
14577
  const cellValueProps = {
@@ -14470,6 +14618,7 @@ const MRT_TableBodyCell = ({
14470
14618
  textOverflow: 'clip'
14471
14619
  },
14472
14620
  alignItems: layoutMode?.startsWith('grid') ? 'center' : undefined,
14621
+ borderBottom: lastRowBorderBottom,
14473
14622
  cursor: isRightClickable ? 'context-menu' : 'inherit',
14474
14623
  outline: isActionCell ? `1px solid ${theme_0.palette.grey[500]}` : undefined,
14475
14624
  outlineOffset: '-1px',
@@ -16709,8 +16858,9 @@ const MRT_TableHeadCellResizeHandle = ({
16709
16858
  const {
16710
16859
  column
16711
16860
  } = header;
16712
- const mx = density === 'compact' ? '-2px' : density === 'comfortable' ? '-16px' : '-24px';
16713
- const lr = column.columnDef.columnDefType === 'display' ? '4px' : '0';
16861
+ const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
16862
+ const mx = isCheckboxColumn ? '0' : density === 'compact' ? '-2px' : density === 'comfortable' ? '-16px' : '-24px';
16863
+ const lr = !isCheckboxColumn && column.columnDef.columnDefType === 'display' ? '4px' : '0';
16714
16864
 
16715
16865
  // Drives the resize purely through refs/DOM writes (CSS vars + the indicator line) so
16716
16866
  // dragging causes zero React renders; the only state write is the commit on release.
@@ -16895,7 +17045,9 @@ const MRT_TableHeadCellResizeHandle = ({
16895
17045
  mr: columnResizeDirection === 'ltr' ? mx : undefined,
16896
17046
  position: 'absolute',
16897
17047
  px: '4px',
16898
- right: columnResizeDirection === 'ltr' ? lr : undefined
17048
+ right: columnResizeDirection === 'ltr' ? lr : undefined,
17049
+ top: isCheckboxColumn ? '50%' : undefined,
17050
+ transform: isCheckboxColumn ? 'translateY(-50%)' : undefined
16899
17051
  }),
16900
17052
  children: /*#__PURE__*/jsxRuntime.jsx(Divider, {
16901
17053
  className: "Mui-TableHeadCell-ResizeHandle-Divider",
@@ -16906,7 +17058,7 @@ const MRT_TableHeadCellResizeHandle = ({
16906
17058
  borderWidth: '1px',
16907
17059
  height: '24px',
16908
17060
  touchAction: 'none',
16909
- transform: 'translateX(4px)',
17061
+ transform: isCheckboxColumn && columnResizeDirection === 'rtl' ? 'translateX(-4px)' : 'translateX(4px)',
16910
17062
  transition: column.getIsResizing() ? undefined : 'all 150ms ease-in-out',
16911
17063
  userSelect: 'none',
16912
17064
  zIndex: 4,
@@ -17164,7 +17316,7 @@ const MRT_TableHeadCell = ({
17164
17316
  header,
17165
17317
  table
17166
17318
  }) ?? columnDef.header;
17167
- return /*#__PURE__*/jsxRuntime.jsx(TableCell, {
17319
+ return /*#__PURE__*/jsxRuntime.jsxs(TableCell, {
17168
17320
  align: columnDefType === 'group' ? 'center' : theme.direction === 'rtl' ? 'right' : 'left',
17169
17321
  "aria-sort": column.getIsSorted() ? column.getIsSorted() === 'asc' ? 'ascending' : 'descending' : 'none',
17170
17322
  colSpan: header.colSpan,
@@ -17203,7 +17355,7 @@ const MRT_TableHeadCell = ({
17203
17355
  }),
17204
17356
  ...draggingBorders
17205
17357
  }),
17206
- children: header.isPlaceholder ? null : tableCellProps.children ?? /*#__PURE__*/jsxRuntime.jsxs(Box, {
17358
+ children: [header.isPlaceholder ? null : tableCellProps.children ?? /*#__PURE__*/jsxRuntime.jsxs(Box, {
17207
17359
  className: "Mui-TableHeadCell-Content",
17208
17360
  sx: {
17209
17361
  alignItems: 'center',
@@ -17275,11 +17427,14 @@ const MRT_TableHeadCell = ({
17275
17427
  current: tableHeadCellRefs.current?.[column.id]
17276
17428
  }
17277
17429
  })]
17278
- }), column.getCanResize() && /*#__PURE__*/jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, {
17430
+ }), column.getCanResize() && !isCheckboxColumn && /*#__PURE__*/jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, {
17279
17431
  header: header,
17280
17432
  table: table
17281
17433
  })]
17282
- })
17434
+ }), column.getCanResize() && isCheckboxColumn && !header.isPlaceholder && /*#__PURE__*/jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, {
17435
+ header: header,
17436
+ table: table
17437
+ })]
17283
17438
  });
17284
17439
  };
17285
17440
 
@@ -20846,6 +21001,7 @@ function _temp2(state_0) {
20846
21001
  };
20847
21002
  }
20848
21003
 
21004
+ exports.ACTIONS_DISPLAY_COLUMN_ID = ACTIONS_DISPLAY_COLUMN_ID;
20849
21005
  exports.CHECKBOX_DISPLAY_COLUMN_ID = CHECKBOX_DISPLAY_COLUMN_ID;
20850
21006
  exports.MRT_ActionMenuItem = MRT_ActionMenuItem;
20851
21007
  exports.MRT_AdvancedFilters = MRT_AdvancedFilters;
@@ -20909,16 +21065,22 @@ exports.Memo_MRT_TableBodyCell = Memo_MRT_TableBodyCell;
20909
21065
  exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
20910
21066
  exports.RHF_FormProvider = RHF_FormProvider;
20911
21067
  exports.buildDefaultValues = buildDefaultValues;
21068
+ exports.columnsIncludeCheckboxSelection = columnsIncludeCheckboxSelection;
21069
+ exports.columnsIncludeRowActions = columnsIncludeRowActions;
20912
21070
  exports.createDeleteAction = createDeleteAction;
20913
21071
  exports.createEditAction = createEditAction;
20914
21072
  exports.createExportAction = createExportAction;
20915
21073
  exports.createMRTColumnHelper = createMRTColumnHelper;
20916
21074
  exports.createRow = createRow;
21075
+ exports.decorateCheckboxSelectionColumn = decorateCheckboxSelectionColumn;
21076
+ exports.decorateRowActionsColumn = decorateRowActionsColumn;
20917
21077
  exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
20918
21078
  exports.flexRender = flexRender;
20919
21079
  exports.getAllLeafColumnDefs = getAllLeafColumnDefs;
20920
21080
  exports.getAutoSizeCandidateColumnIds = getAutoSizeCandidateColumnIds;
21081
+ exports.getCheckboxSelectionCellAndHeader = getCheckboxSelectionCellAndHeader;
20921
21082
  exports.getColumnId = getColumnId;
21083
+ exports.getColumnMenuLabel = getColumnMenuLabel;
20922
21084
  exports.getDefaultColumnOrderIds = getDefaultColumnOrderIds;
20923
21085
  exports.getIsAllPagesSelectionActive = getIsAllPagesSelectionActive;
20924
21086
  exports.getIsRowSelected = getIsRowSelected;
@@ -20926,6 +21088,7 @@ exports.getLeadingDisplayColumnIds = getLeadingDisplayColumnIds;
20926
21088
  exports.getMRT_RowSelectionHandler = getMRT_RowSelectionHandler;
20927
21089
  exports.getMRT_Rows = getMRT_Rows;
20928
21090
  exports.getMRT_SelectAllHandler = getMRT_SelectAllHandler;
21091
+ exports.getRowActionsCell = getRowActionsCell;
20929
21092
  exports.getTrailingDisplayColumnIds = getTrailingDisplayColumnIds;
20930
21093
  exports.groupFieldsBySection = groupFieldsBySection;
20931
21094
  exports.normalizeRowExpandColumnOrder = normalizeRowExpandColumnOrder;
@@ -20936,7 +21099,6 @@ exports.showRowActionsColumn = showRowActionsColumn;
20936
21099
  exports.showRowExpandColumn = showRowExpandColumn;
20937
21100
  exports.showRowNumbersColumn = showRowNumbersColumn;
20938
21101
  exports.showRowPinningColumn = showRowPinningColumn;
20939
- exports.showRowSelectionColumn = showRowSelectionColumn;
20940
21102
  exports.showRowSpacerColumn = showRowSpacerColumn;
20941
21103
  exports.sortByOrder = sortByOrder;
20942
21104
  exports.toAdditionalRenderEntries = toAdditionalRenderEntries;