@dooherceg/material-react-table 4.1.5 → 4.1.7

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
@@ -97,6 +97,7 @@ var CheckIcon = require('@mui/icons-material/Check');
97
97
  var ClickAwayListener = require('@mui/material/ClickAwayListener');
98
98
  var ErrorOutlineRoundedIcon = require('@mui/icons-material/ErrorOutlineRounded');
99
99
  var Paper = require('@mui/material/Paper');
100
+ var Alert = require('@mui/material/Alert');
100
101
  var Collapse = require('@mui/material/Collapse');
101
102
  var LinearProgress = require('@mui/material/LinearProgress');
102
103
  var Pagination = require('@mui/material/Pagination');
@@ -108,6 +109,7 @@ var ListItemIcon = require('@mui/material/ListItemIcon');
108
109
  var ListItemText = require('@mui/material/ListItemText');
109
110
  var BookmarkIcon = require('@mui/icons-material/Bookmark');
110
111
  var DeleteForeverIcon = require('@mui/icons-material/DeleteForever');
112
+ var InputAdornment = require('@mui/material/InputAdornment');
111
113
  var Switch = require('@mui/material/Switch');
112
114
  var Badge = require('@mui/material/Badge');
113
115
  var TableContainer = require('@mui/material/TableContainer');
@@ -124,7 +126,6 @@ var Accordion = require('@mui/material/Accordion');
124
126
  var AccordionDetails = require('@mui/material/AccordionDetails');
125
127
  var AccordionSummary = require('@mui/material/AccordionSummary');
126
128
  var Modal = require('@mui/material/Modal');
127
- var Alert = require('@mui/material/Alert');
128
129
  var AlertTitle = require('@mui/material/AlertTitle');
129
130
 
130
131
  const MRT_SortingFns = {
@@ -146,6 +147,15 @@ const getAllLeafColumnDefs = columns => {
146
147
  getLeafColumns(columns);
147
148
  return allLeafColumnDefs;
148
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)));
149
159
  const prepareColumns = ({
150
160
  columnDefs,
151
161
  tableOptions
@@ -196,6 +206,7 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
196
206
  };
197
207
 
198
208
  function defaultDisplayColumnProps({
209
+ columnSpecificDefaults,
199
210
  header,
200
211
  id,
201
212
  size,
@@ -210,6 +221,7 @@ function defaultDisplayColumnProps({
210
221
  ...defaultDisplayColumn,
211
222
  header: header ? localization[header] : '',
212
223
  size,
224
+ ...columnSpecificDefaults,
213
225
  ...displayColumnDefOptions?.[id],
214
226
  id
215
227
  };
@@ -248,42 +260,10 @@ const getTrailingDisplayColumnIds = tableOptions => [tableOptions.positionAction
248
260
  /** The internal ID used by TanStack Table for the row-selection checkbox column */
249
261
  const CHECKBOX_DISPLAY_COLUMN_ID = '__check__';
250
262
 
251
- /**
252
- * Builds the default columnPinning state so that the checkbox column
253
- * is always the first start-pinned column when row selection is enabled.
254
- * The checkbox is pinned for sticky positioning only — its visual styles are
255
- * intentionally overridden in style.utils.ts to match center column appearance.
256
- * Any user-supplied start-pinned column IDs are kept, but appended after the
257
- * checkbox so they never appear before it.
258
- */
259
- const getDefaultColumnPinningState = (tableOptions, existingColumnPinning = {}) => {
260
- const existingStart = existingColumnPinning.start ?? [];
261
- const existingEnd = existingColumnPinning.end ?? [];
262
-
263
- // Only pin the checkbox automatically when the column is actually rendered
264
- if (!tableOptions.enableRowSelection) {
265
- return {
266
- start: existingStart,
267
- end: existingEnd
268
- };
269
- }
270
-
271
- // Remove checkbox from wherever it is to check remaining pinned columns
272
- const startWithoutCheckbox = existingStart.filter(colId => colId !== CHECKBOX_DISPLAY_COLUMN_ID);
273
-
274
- // Only force checkbox to the front when start or end pinned columns exist
275
- const updatedStart = existingStart.length > 0 ? [CHECKBOX_DISPLAY_COLUMN_ID, ...startWithoutCheckbox] : existingStart;
276
- return {
277
- start: updatedStart,
278
- end: existingEnd
279
- };
280
- };
281
-
282
263
  /**
283
264
  * Forces mrt-row-expand to a fixed slot in columnOrder: right after the
284
265
  * checkbox column when row selection is enabled, otherwise the very first
285
- * column. Not configurable — mirrors how getDefaultColumnPinningState
286
- * forces the checkbox column itself to the front of columnPinning.start.
266
+ * column. This slot is independent of column pinning.
287
267
  */
288
268
  const normalizeRowExpandColumnOrder = (tableOptions, columnOrder) => {
289
269
  if (!showRowExpandColumn(tableOptions)) {
@@ -505,6 +485,89 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
505
485
  [getColumnId(col)]: ''
506
486
  }))), rowIndex, depth, subRows, parentId);
507
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 => {
510
+ 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));
560
+ }
561
+ if (contentWidth > 0) {
562
+ contentWidth = Math.ceil(contentWidth) + MEASUREMENT_SAFETY_MARGIN_PX;
563
+ }
564
+ const bounds = getColumnSizeBounds({
565
+ minSize,
566
+ maxSize
567
+ });
568
+ return Math.min(Math.max(contentWidth, bounds.minSize), bounds.maxSize);
569
+ };
570
+
508
571
  // Loading indicators fade in after a short delay
509
572
  // (`animation: ${mrtDelayedFadeIn}`), so fast responses don't flash them.
510
573
  const mrtDelayedFadeIn = `${styles.keyframes`
@@ -536,6 +599,7 @@ const commonCellBeforeAfterStyles = {
536
599
  zIndex: -1
537
600
  };
538
601
  const getCommonPinnedCellStyles = ({
602
+ column,
539
603
  table,
540
604
  theme
541
605
  }) => {
@@ -545,12 +609,30 @@ const getCommonPinnedCellStyles = ({
545
609
  return {
546
610
  '&[data-pinned="true"]': {
547
611
  '&:before': {
548
- backgroundColor: styles.alpha(styles.darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97),
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',
549
618
  ...commonCellBeforeAfterStyles
550
619
  }
551
620
  }
552
621
  };
553
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) => {
627
+ 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;
635
+ };
554
636
  const getCommonMRTCellStyles = ({
555
637
  column,
556
638
  header,
@@ -573,67 +655,33 @@ const getCommonMRTCellStyles = ({
573
655
  columnDefType
574
656
  } = columnDef;
575
657
  const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
658
+ 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})`;
576
664
  const widthStyles = {
577
- maxWidth: `${columnDef.maxSize ?? 1000}px`,
578
- minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
579
- width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`
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
580
670
  };
581
671
  if (layoutMode === 'grid' || layoutMode === 'grid-no-grow') {
582
- // `grow: false`/`0` opts a column out of the fit entirely (fixed width, e.g. for
583
- // pinned columns so their sticky offsets don't shift); an explicit positive number
584
- // is used as a custom weight; otherwise (the common case — no `grow` set) every
585
- // other column shares leftover/deficit row width weighted by its own size, so a
586
- // handful of columns fill a wide viewport evenly, and widening one via resize
587
- // shrinks the others to keep the row's total width pinned to the container — all
588
- // through native flexbox, no JS redistribution needed.
589
- const weight = isColumnPinned ? 0 : [0, false].includes(columnDef.grow) ? 0 : typeof columnDef.grow === 'number' ? columnDef.grow : `var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size)`;
590
- widthStyles.flex = `${weight} ${weight} auto`;
591
- }
592
-
593
- // The checkbox column is technically pinned (for sticky positioning) but
594
- // should look like a regular center column — no background overlay or shadow.
595
- const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
596
-
597
- // Count all currently pinned column IDs across both sides.
598
- // Checkbox is always pinned (counts as 1), so > 1 means the user has
599
- // explicitly pinned at least one additional column.
600
- // Avoid spreading into a new array on this per-cell hot path — a length sum
601
- // is enough, we never need the combined array itself.
602
- const {
603
- columnPinning
604
- } = table.getState();
605
- const totalPinnedColumnCount = (columnPinning.start?.length ?? 0) + (columnPinning.end?.length ?? 0);
606
- const hasNoPinnedColumns = totalPinnedColumnCount === 0;
672
+ const weight = getColumnGrowWeight(column, table);
673
+ const growVar = `var(--col-${parseCSSVarId(column.id)}-grow, ${weight})`;
674
+ widthStyles.flex = `${growVar} 0 auto`;
675
+ }
607
676
  const pinnedStyles = isColumnPinned ? {
608
- // For checkbox: suppress pinned background/shadow only when other
609
- // columns are also pinned (> 1 total). When it is the sole pinned column
610
- // no override is needed. For all other columns apply standard pinned styles.
611
- ...(isCheckboxColumn ? hasNoPinnedColumns ? {
612
- // Use doubled class selector (&&) to beat the row-level
613
- // td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
614
- '&&[data-pinned="true"]': {
615
- '&:before': {
616
- backgroundColor: 'transparent',
617
- boxShadow: 'none'
618
- }
619
- }
620
- } :
621
- // Other columns are also pinned — apply standard pinned background
622
- // so the checkbox header matches the pinned row cells below it.
623
- getCommonPinnedCellStyles({
624
- column,
625
- table,
626
- theme
627
- }) : getCommonPinnedCellStyles({
677
+ ...getCommonPinnedCellStyles({
628
678
  column,
629
679
  table,
630
680
  theme
631
- })),
681
+ }),
632
682
  // Logical CSS insets (not left/right) so pinning stays correct in RTL
633
683
  // without branching on theme.direction here.
634
684
  insetInlineStart: isColumnPinned === 'start' ? `${column.getStart('start')}px` : undefined,
635
- // Skip opacity reduction for checkbox — keep it fully opaque like center columns
636
- opacity: isCheckboxColumn ? undefined : 0.97,
637
685
  position: 'sticky',
638
686
  insetInlineEnd: isColumnPinned === 'end' ? `${column.getAfter('end')}px` : undefined
639
687
  } : {};
@@ -2086,7 +2134,7 @@ const MRT_ToggleRowActionMenuButton = t0 => {
2086
2134
  staticRowIndex,
2087
2135
  table
2088
2136
  }) : renderRowActionMenuItems?.({
2089
- closeMenu: _temp$A,
2137
+ closeMenu: _temp$B,
2090
2138
  row,
2091
2139
  staticRowIndex,
2092
2140
  table
@@ -2136,7 +2184,7 @@ const MRT_ToggleRowActionMenuButton = t0 => {
2136
2184
  }
2137
2185
  return t5;
2138
2186
  };
2139
- function _temp$A() {}
2187
+ function _temp$B() {}
2140
2188
 
2141
2189
  const getMRT_RowActionsColumnDef = tableOptions => {
2142
2190
  return {
@@ -2152,14 +2200,17 @@ const getMRT_RowActionsColumnDef = tableOptions => {
2152
2200
  table: table
2153
2201
  }),
2154
2202
  ...(tableOptions.positionActionsColumn === 'last' && {
2155
- grow: true,
2156
- muiTableBodyCellProps: {
2157
- sx: {
2158
- minWidth: 'max-content'
2159
- }
2160
- }
2203
+ grow: true
2161
2204
  }),
2162
2205
  ...defaultDisplayColumnProps({
2206
+ // Unlike other display columns, the actions column is draggable,
2207
+ // orderable, and resizable by default — it behaves like a user column
2208
+ // for layout purposes, just without filtering/sorting/hiding.
2209
+ columnSpecificDefaults: {
2210
+ enableColumnDragging: true,
2211
+ enableColumnOrdering: true,
2212
+ enableResizing: true
2213
+ },
2163
2214
  header: 'actions',
2164
2215
  id: 'mrt-row-actions',
2165
2216
  size: 70,
@@ -2212,7 +2263,7 @@ const MRT_ExpandAllButton = t0 => {
2212
2263
  const {
2213
2264
  isLoading
2214
2265
  } = t3;
2215
- const density = reactStore.useSelector(table.store, _temp$z);
2266
+ const density = reactStore.useSelector(table.store, _temp$A);
2216
2267
  let t4;
2217
2268
  if ($[5] !== muiExpandAllButtonProps || $[6] !== table) {
2218
2269
  t4 = parseFromValuesOrFunc(muiExpandAllButtonProps, {
@@ -2301,7 +2352,7 @@ const MRT_ExpandAllButton = t0 => {
2301
2352
  }
2302
2353
  return t7;
2303
2354
  };
2304
- function _temp$z(state) {
2355
+ function _temp$A(state) {
2305
2356
  return state.density;
2306
2357
  }
2307
2358
 
@@ -2384,10 +2435,12 @@ const MRT_ExpandButton = ({
2384
2435
  "aria-label": localization.expand,
2385
2436
  disabled: !canExpand && !detailPanel,
2386
2437
  ...iconButtonProps,
2438
+ disableRipple: true,
2387
2439
  onClick: handleToggleExpand,
2388
2440
  sx: theme_0 => ({
2389
2441
  opacity: !canExpand && !detailPanel ? 0.3 : 1,
2390
2442
  [theme_0.direction === 'rtl' || positionExpandColumn === 'last' ? 'mr' : 'ml']: `${row.depth * 16}px`,
2443
+ height: density === 'compact' ? '1.75rem' : '2.25rem',
2391
2444
  width: density === 'compact' ? '1.75rem' : '2.25rem',
2392
2445
  ...parseFromValuesOrFunc(iconButtonProps?.sx, theme_0)
2393
2446
  }),
@@ -2514,13 +2567,16 @@ const MRT_ReorderRowCheckbox = t0 => {
2514
2567
  onChange,
2515
2568
  isSelected
2516
2569
  } = t0;
2517
- const handleClick = _temp$y;
2570
+ const handleClick = _temp$z;
2518
2571
  let t1;
2519
2572
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2520
2573
  t1 = {
2521
2574
  color: _temp2$d,
2575
+ height: "1.75rem",
2576
+ m: "-0.4rem",
2577
+ width: "1.75rem",
2522
2578
  "&.Mui-checked": {
2523
- color: _temp3$6
2579
+ color: _temp3$5
2524
2580
  }
2525
2581
  };
2526
2582
  $[0] = t1;
@@ -2535,6 +2591,7 @@ const MRT_ReorderRowCheckbox = t0 => {
2535
2591
  disableRipple: true,
2536
2592
  onChange: onChange,
2537
2593
  onClick: handleClick,
2594
+ size: "small",
2538
2595
  sx: t1
2539
2596
  });
2540
2597
  $[1] = isSelected;
@@ -2545,13 +2602,13 @@ const MRT_ReorderRowCheckbox = t0 => {
2545
2602
  }
2546
2603
  return t2;
2547
2604
  };
2548
- function _temp$y(event) {
2605
+ function _temp$z(event) {
2549
2606
  event.stopPropagation();
2550
2607
  }
2551
2608
  function _temp2$d(theme) {
2552
2609
  return theme.palette.warning.main;
2553
2610
  }
2554
- function _temp3$6(theme_0) {
2611
+ function _temp3$5(theme_0) {
2555
2612
  return theme_0.palette.warning.main;
2556
2613
  }
2557
2614
 
@@ -2870,7 +2927,7 @@ const useTreeRowReorderingHeader = t0 => {
2870
2927
  enableRowReordering,
2871
2928
  onTreeRowReorder
2872
2929
  } = t0;
2873
- const rowReorderingSelection = reactStore.useSelector(table.store, _temp$x);
2930
+ const rowReorderingSelection = reactStore.useSelector(table.store, _temp$y);
2874
2931
  let selectedReorderRowIds;
2875
2932
  let selectedRowsForReorder;
2876
2933
  let t1;
@@ -2933,7 +2990,7 @@ const useTreeRowReorderingHeader = t0 => {
2933
2990
  }
2934
2991
  return t3;
2935
2992
  };
2936
- function _temp$x(state) {
2993
+ function _temp$y(state) {
2937
2994
  return state.rowReorderingSelection;
2938
2995
  }
2939
2996
  function _temp2$c(selectedRow) {
@@ -3276,7 +3333,7 @@ const MRT_TableBodyRowPinButton = t0 => {
3276
3333
  enableRowPinning,
3277
3334
  rowPinningDisplayMode
3278
3335
  } = t1;
3279
- const density = reactStore.useSelector(table.store, _temp$w);
3336
+ const density = reactStore.useSelector(table.store, _temp$x);
3280
3337
  const canPin = parseFromValuesOrFunc(enableRowPinning, row);
3281
3338
  if (!canPin) {
3282
3339
  return null;
@@ -3357,7 +3414,7 @@ const MRT_TableBodyRowPinButton = t0 => {
3357
3414
  }
3358
3415
  return t4;
3359
3416
  };
3360
- function _temp$w(state) {
3417
+ function _temp$x(state) {
3361
3418
  return state.density;
3362
3419
  }
3363
3420
 
@@ -3380,166 +3437,6 @@ const getMRT_RowPinningColumnDef = tableOptions => {
3380
3437
  };
3381
3438
  };
3382
3439
 
3383
- const MRT_SelectAllMenu = ({
3384
- table
3385
- }) => {
3386
- const [anchorEl, setAnchorEl] = react.useState(null);
3387
- const [isSelectingAllPages, setIsSelectingAllPages] = react.useState(false);
3388
- const {
3389
- getState,
3390
- options: {
3391
- enableRowPinning,
3392
- getAllSelectableRowIds,
3393
- localization,
3394
- rowPinningDisplayMode
3395
- },
3396
- refs: {
3397
- allSelectableRowIdsRef
3398
- }
3399
- } = table;
3400
- const {
3401
- isLoading
3402
- } = getState();
3403
- const handleOpen = event => {
3404
- setAnchorEl(event.currentTarget);
3405
- };
3406
- const handleClose = () => {
3407
- setAnchorEl(null);
3408
- };
3409
-
3410
- // Clears row pinning on every bulk selection/deselection
3411
- const clearPinning = () => {
3412
- if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
3413
- table.setRowPinning({
3414
- bottom: [],
3415
- top: []
3416
- });
3417
- }
3418
- };
3419
-
3420
- // ── Current-page actions ────────────────────────────────────────────────────
3421
-
3422
- const handleSelectCurrentPage = () => {
3423
- table.toggleAllPageRowsSelected(true);
3424
- clearPinning();
3425
- handleClose();
3426
- };
3427
- const handleDeselectCurrentPage = () => {
3428
- if (allSelectableRowIdsRef.current.length > 0) {
3429
- // When all pages are selected, deselecting the current page must clear the entire selection — otherwise rows on other pages remain "ghost-selected" but the user can't see them.
3430
- table.setRowSelection({});
3431
- allSelectableRowIdsRef.current = [];
3432
- } else {
3433
- table.toggleAllPageRowsSelected(false);
3434
- }
3435
- clearPinning();
3436
- handleClose();
3437
- };
3438
-
3439
- // ── All-pages actions ───────────────────────────────────────────────────────
3440
-
3441
- const handleSelectAllPages = async () => {
3442
- handleClose();
3443
- if (getAllSelectableRowIds) {
3444
- // Server-side: IDs are not available locally, fetch them from the API
3445
- setIsSelectingAllPages(true);
3446
- table.setShowProgressBars(true);
3447
- try {
3448
- const ids = await getAllSelectableRowIds({
3449
- table
3450
- });
3451
- allSelectableRowIdsRef.current = ids;
3452
- const newSelection = {};
3453
- ids.forEach(id => {
3454
- newSelection[id] = true;
3455
- });
3456
- table.setRowSelection(newSelection);
3457
- clearPinning();
3458
- } finally {
3459
- setIsSelectingAllPages(false);
3460
- table.setShowProgressBars(false);
3461
- }
3462
- } else {
3463
- // Client-side: all data is available locally
3464
- table.toggleAllRowsSelected(true);
3465
- clearPinning();
3466
- }
3467
- };
3468
- const handleDeselectAllPages = () => {
3469
- if (getAllSelectableRowIds) {
3470
- table.setRowSelection({});
3471
- } else {
3472
- table.toggleAllRowsSelected(false);
3473
- }
3474
- allSelectableRowIdsRef.current = [];
3475
- clearPinning();
3476
- handleClose();
3477
- };
3478
- const isDisabled = isLoading || isSelectingAllPages;
3479
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3480
- children: [/*#__PURE__*/jsxRuntime.jsx(Tooltip, {
3481
- ...getCommonTooltipProps(),
3482
- title: localization.toggleSelectAll,
3483
- children: /*#__PURE__*/jsxRuntime.jsx("span", {
3484
- children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
3485
- "aria-label": localization.toggleSelectAll,
3486
- disabled: isDisabled,
3487
- onClick: handleOpen,
3488
- size: "small",
3489
- sx: {
3490
- height: '1.5rem',
3491
- width: '1.5rem'
3492
- },
3493
- children: /*#__PURE__*/jsxRuntime.jsx(table.options.icons.MoreVertIcon, {
3494
- style: {
3495
- transform: 'scale(0.85)'
3496
- }
3497
- })
3498
- })
3499
- })
3500
- }), /*#__PURE__*/jsxRuntime.jsx(Menu, {
3501
- anchorEl: anchorEl,
3502
- onClose: handleClose,
3503
- open: Boolean(anchorEl),
3504
- children: /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
3505
- selector: state => ({
3506
- pagination: state.pagination,
3507
- rowSelection: state.rowSelection
3508
- }),
3509
- source: table.store,
3510
- children: ({
3511
- rowSelection
3512
- }) => {
3513
- const isAllCurrentPageSelected = table.getIsAllPageRowsSelected();
3514
- const isAllPagesActive = getIsAllPagesSelectionActive(table, rowSelection);
3515
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3516
- children: [isAllCurrentPageSelected ? /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
3517
- onClick: handleDeselectCurrentPage,
3518
- children: localization.deselectAllOnCurrentPage
3519
- }) : /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
3520
- onClick: handleSelectCurrentPage,
3521
- children: localization.selectAllOnCurrentPage
3522
- }), isAllPagesActive ? /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
3523
- onClick: handleDeselectAllPages,
3524
- children: localization.deselectAllOnAllPages
3525
- }) : /*#__PURE__*/jsxRuntime.jsxs(MenuItem, {
3526
- disabled: isSelectingAllPages,
3527
- onClick: handleSelectAllPages,
3528
- children: [isSelectingAllPages && /*#__PURE__*/jsxRuntime.jsx(CircularProgress, {
3529
- "aria-label": "Loading",
3530
- size: 14,
3531
- sx: {
3532
- mr: 1
3533
- }
3534
- }), localization.selectAllOnAllPages]
3535
- })]
3536
- });
3537
- }
3538
- })
3539
- })]
3540
- });
3541
- };
3542
-
3543
3440
  const MRT_SelectCheckbox = t0 => {
3544
3441
  const $ = compilerRuntime.c(32);
3545
3442
  let rest;
@@ -3586,7 +3483,7 @@ const MRT_SelectCheckbox = t0 => {
3586
3483
  const {
3587
3484
  isLoading
3588
3485
  } = t2;
3589
- const density = reactStore.useSelector(table.store, _temp$v);
3486
+ const density = reactStore.useSelector(table.store, _temp$w);
3590
3487
  const selectAll = !row;
3591
3488
  let t3;
3592
3489
  if ($[7] !== row || $[8] !== staticRowIndex || $[9] !== table) {
@@ -3704,7 +3601,7 @@ const MRT_SelectCheckbox = t0 => {
3704
3601
  }
3705
3602
  return t6;
3706
3603
  };
3707
- function _temp$v(state) {
3604
+ function _temp$w(state) {
3708
3605
  return state.density;
3709
3606
  }
3710
3607
  function _temp2$b(state_0) {
@@ -3731,23 +3628,18 @@ const getMRT_RowSelectColumnDef = tableOptions => {
3731
3628
  }),
3732
3629
  Header: enableSelectAll && enableMultiRowSelection ? ({
3733
3630
  table
3734
- }) => /*#__PURE__*/jsxRuntime.jsxs(Box, {
3735
- sx: {
3736
- alignItems: 'center',
3737
- display: 'flex'
3738
- },
3739
- children: [/*#__PURE__*/jsxRuntime.jsx(MRT_SelectCheckbox, {
3740
- table: table
3741
- }), /*#__PURE__*/jsxRuntime.jsx(MRT_SelectAllMenu, {
3742
- table: table
3743
- })]
3631
+ }) => /*#__PURE__*/jsxRuntime.jsx(MRT_SelectCheckbox, {
3632
+ table: table
3744
3633
  }) : undefined,
3745
3634
  grow: false,
3746
3635
  ...defaultDisplayColumnProps({
3636
+ columnSpecificDefaults: {
3637
+ enableColumnActions: true,
3638
+ enablePinning: true
3639
+ },
3747
3640
  header: 'select',
3748
3641
  id: '__check__',
3749
- size: enableSelectAll ? 90 : 70,
3750
- // widened from 60 to accommodate both the checkbox and the menu button
3642
+ size: 56,
3751
3643
  tableOptions
3752
3644
  })
3753
3645
  };
@@ -3820,6 +3712,7 @@ const MRT_Default_Icons = {
3820
3712
  // ComponentType<SvgIconProps> is the correct type for all MUI SvgIcon components.
3821
3713
 
3822
3714
  const MRT_Localization_EN = {
3715
+ retryLoading: 'Retry',
3823
3716
  language: 'en',
3824
3717
  actions: 'Actions',
3825
3718
  and: 'and',
@@ -4486,6 +4379,8 @@ const useMRT_TableInstance = definedTableOptions => {
4486
4379
  const tableRef = react.useRef(null);
4487
4380
  const isResizingRef = react.useRef(false);
4488
4381
  const resizeIndicatorRef = react.useRef(null);
4382
+ const autoSizeColumnIdsRef = react.useRef(new Set());
4383
+ const autoSizedColumnWidthsRef = react.useRef({});
4489
4384
 
4490
4385
  //transform initial state with proper column order
4491
4386
  const initialState = react.useMemo(() => {
@@ -4499,12 +4394,6 @@ const useMRT_TableInstance = definedTableOptions => {
4499
4394
  }
4500
4395
  };
4501
4396
  initState.columnOrder = normalizeRowExpandColumnOrder(mergedOptionsSnapshot, initState.columnOrder ?? getDefaultColumnOrderIds(mergedOptionsSnapshot));
4502
-
4503
- // Ensure the checkbox column is always the leftmost sticky column when
4504
- // row selection is enabled, regardless of what the user pinned initially.
4505
- // The checkbox is pinned for positioning only — visual styles are overridden
4506
- // in style.utils.ts so it looks like a regular center column.
4507
- initState.columnPinning = getDefaultColumnPinningState(mergedOptionsSnapshot, initState.columnPinning ?? {});
4508
4397
  initState.showAdvancedFilters = initState.showAdvancedFilters ?? false;
4509
4398
  // getInitialState() on a custom TanStack feature only receives the
4510
4399
  // accumulated initialState object, not the full table options — so the
@@ -4550,23 +4439,12 @@ const useMRT_TableInstance = definedTableOptions => {
4550
4439
  ...definedTableOptions.state
4551
4440
  };
4552
4441
 
4553
- // Normalize controlled columnPinning state: if the user passes state.columnPinning
4554
- // directly (controlled mode), we still need to ensure that the checkbox column
4555
- // is always at the front of the start-pinned group, just like we do for initialState.
4556
- const assembledColumnPinning = definedTableOptions.state.columnPinning;
4557
- if (assembledColumnPinning && !!definedTableOptions.enableRowSelection) {
4558
- definedTableOptions.state = {
4559
- ...definedTableOptions.state,
4560
- columnPinning: getDefaultColumnPinningState(definedTableOptions, assembledColumnPinning)
4561
- };
4562
- }
4563
-
4564
4442
  //The table options now include all state needed to help determine column visibility and order logic
4565
4443
  const statefulTableOptions = definedTableOptions;
4566
4444
 
4567
4445
  // Keep mrt-row-expand locked to its slot (right after the checkbox, or
4568
4446
  // first if there's no checkbox) regardless of what columnOrder the
4569
- // consumer passes in — same enforcement model as columnPinning above.
4447
+ // consumer passes in.
4570
4448
  statefulTableOptions.state = {
4571
4449
  ...statefulTableOptions.state,
4572
4450
  columnOrder: normalizeRowExpandColumnOrder(statefulTableOptions, statefulTableOptions.state.columnOrder)
@@ -4578,6 +4456,12 @@ const useMRT_TableInstance = definedTableOptions => {
4578
4456
  //recompute (and recreate every cell of every row) on unrelated renders
4579
4457
  //like hover, menu open/close, or density toggle
4580
4458
  const rawColumns = statefulTableOptions.columns;
4459
+ // Snapshot of "no explicit size" must be taken here, on the raw user-authored
4460
+ // columns — prepareColumns/constructColumn below backfill MRT_DefaultColumn.size
4461
+ // into columnDef.size for any column that didn't provide one, after which the
4462
+ // distinction MRT_AutoSizeColumnsEffect needs is gone. Memoized on rawColumns so
4463
+ // it's recomputed only when the column array itself actually changes.
4464
+ autoSizeColumnIdsRef.current = react.useMemo(() => getAutoSizeCandidateColumnIds(rawColumns), [rawColumns]);
4581
4465
  const {
4582
4466
  defaultDisplayColumn,
4583
4467
  displayColumnDefOptions,
@@ -4675,6 +4559,8 @@ const useMRT_TableInstance = definedTableOptions => {
4675
4559
  table.refs = {
4676
4560
  actionCellRef,
4677
4561
  allSelectableRowIdsRef,
4562
+ autoSizeColumnIdsRef,
4563
+ autoSizedColumnWidthsRef,
4678
4564
  bottomToolbarRef,
4679
4565
  editInputRefs,
4680
4566
  isResizingRef,
@@ -4719,7 +4605,7 @@ const useMRT_TableInstance = definedTableOptions => {
4719
4605
  // setRowsState updater in tableCrudFns.ts), not at memo-creation time — so
4720
4606
  // this memo doesn't need pagination as a dependency at all, keeping it
4721
4607
  // stable across pagination changes instead of rebuilding every page turn.
4722
- const getPageSize = react.useCallback(() => table.store.state.pagination.pageSize, [table]);
4608
+ const getPageSize = react.useCallback(() => table.options.enablePagination ? table.store.state.pagination.pageSize : undefined, [table]);
4723
4609
  const crudHandlers = react.useMemo(() => {
4724
4610
  const context = {
4725
4611
  getRowId: resolveRowId,
@@ -4863,6 +4749,41 @@ const useMRT_Rows = table => {
4863
4749
  return rows;
4864
4750
  };
4865
4751
 
4752
+ /** Shared by row rendering, virtualization, and initial server batch sizing. */
4753
+ const getDefaultRowHeight = density => density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
4754
+ const getViewportRowCount = ({
4755
+ containerHeight,
4756
+ headerHeight = 0,
4757
+ footerHeight = 0,
4758
+ density,
4759
+ estimatedRowHeight
4760
+ }) => {
4761
+ if (!Number.isFinite(containerHeight) || containerHeight <= 0) return undefined;
4762
+ const rowHeight = estimatedRowHeight && Number.isFinite(estimatedRowHeight) && estimatedRowHeight > 0 ? estimatedRowHeight : getDefaultRowHeight(density);
4763
+ return Math.max(1, Math.ceil(Math.max(0, containerHeight - headerHeight - footerHeight) / rowHeight));
4764
+ };
4765
+
4766
+ /** Ghost placeholders and detail panels must not stand in for real data rows. */
4767
+ const measureBodyRowHeight = tableElement => {
4768
+ let height = Infinity;
4769
+ tableElement?.querySelectorAll('tbody tr[data-testid^="body-row-"]').forEach(row => {
4770
+ const measured = row.getBoundingClientRect().height;
4771
+ if (Number.isFinite(measured) && measured > 0) height = Math.min(height, measured);
4772
+ });
4773
+ // With variable-height content the shortest rendered row is the safe estimate:
4774
+ // taller rows consume more space, so this still fetches enough for one view.
4775
+ return height === Infinity ? undefined : height;
4776
+ };
4777
+
4778
+ /** Identical density spacing for the real table and its loading skeleton. */
4779
+ const getDensityStyles = density => ({
4780
+ '--mrt-cell-p': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '1rem' : '1.5rem',
4781
+ '--mrt-display-cell-p': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '0.5rem 0.75rem' : '1rem 1.25rem',
4782
+ '--mrt-head-display-cell-p': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '0.75rem' : '1rem 1.25rem',
4783
+ '--mrt-head-cell-pb': density === 'compact' ? '0.1rem' : '0.6rem',
4784
+ '--mrt-head-cell-pt': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '.75rem' : '1.25rem'
4785
+ });
4786
+
4866
4787
  const useMRT_RowVirtualizer = (table, rows) => {
4867
4788
  const {
4868
4789
  getRowModel,
@@ -4900,7 +4821,7 @@ const useMRT_RowVirtualizer = (table, rows) => {
4900
4821
  //matches the defaultRowHeight assumption in MRT_TableBodyRow so the
4901
4822
  //initial estimate (before measureElement corrects it for dynamic content)
4902
4823
  //doesn't cause scroll-position drift
4903
- const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
4824
+ const normalRowHeight = getDefaultRowHeight(density);
4904
4825
  const rangeExtractor = react.useCallback(range => extraIndexRangeExtractor(range, draggingRowIndex), [draggingRowIndex]);
4905
4826
 
4906
4827
  // enableRowVirtualization can't change after mount (frozen in
@@ -5204,7 +5125,7 @@ const MRT_ActiveFilterItemContainer = t0 => {
5204
5125
  if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
5205
5126
  t6 = {
5206
5127
  alignItems: "center",
5207
- border: _temp$u,
5128
+ border: _temp$v,
5208
5129
  borderRadius: 1,
5209
5130
  display: "flex",
5210
5131
  gap: 0.5
@@ -5329,7 +5250,7 @@ const MRT_ActiveFilterItemContainer = t0 => {
5329
5250
  return t17;
5330
5251
  };
5331
5252
  var MRT_ActiveFilterItemContainer$1 = MRT_ActiveFilterItemContainer;
5332
- function _temp$u(theme) {
5253
+ function _temp$v(theme) {
5333
5254
  return `1px dashed ${theme.palette.divider}`;
5334
5255
  }
5335
5256
 
@@ -5392,7 +5313,7 @@ const MRT_FreeMultiValueEditor = t0 => {
5392
5313
  value: displayValues,
5393
5314
  onChange: handleChange,
5394
5315
  size: "small",
5395
- renderTags: _temp$t,
5316
+ renderTags: _temp$u,
5396
5317
  renderInput: _temp2$a
5397
5318
  });
5398
5319
  $[6] = displayValues;
@@ -5403,7 +5324,7 @@ const MRT_FreeMultiValueEditor = t0 => {
5403
5324
  }
5404
5325
  return t4;
5405
5326
  };
5406
- function _temp$t(value, getTagProps) {
5327
+ function _temp$u(value, getTagProps) {
5407
5328
  return value.map((option, index) => {
5408
5329
  const {
5409
5330
  key,
@@ -5484,7 +5405,7 @@ const MRT_MultiValueEditor = t0 => {
5484
5405
  }
5485
5406
  let t5;
5486
5407
  if ($[8] !== options) {
5487
- t5 = options.map(_temp$s);
5408
+ t5 = options.map(_temp$t);
5488
5409
  $[8] = options;
5489
5410
  $[9] = t5;
5490
5411
  } else {
@@ -5514,7 +5435,7 @@ const MRT_MultiValueEditor = t0 => {
5514
5435
  }
5515
5436
  return t6;
5516
5437
  };
5517
- function _temp$s(option) {
5438
+ function _temp$t(option) {
5518
5439
  const {
5519
5440
  label,
5520
5441
  value
@@ -5881,7 +5802,7 @@ const MRT_SingleValueEditor = t0 => {
5881
5802
  const t6 = options?.length ? undefined : inputType;
5882
5803
  let t7;
5883
5804
  if ($[9] !== options) {
5884
- t7 = options?.map(_temp$r);
5805
+ t7 = options?.map(_temp$s);
5885
5806
  $[9] = options;
5886
5807
  $[10] = t7;
5887
5808
  } else {
@@ -5915,7 +5836,7 @@ const MRT_SingleValueEditor = t0 => {
5915
5836
  }
5916
5837
  return t8;
5917
5838
  };
5918
- function _temp$r(option) {
5839
+ function _temp$s(option) {
5919
5840
  const {
5920
5841
  label,
5921
5842
  value
@@ -6149,7 +6070,7 @@ const MRT_FilterRuleNumberEditor = props => {
6149
6070
  t0 = /*#__PURE__*/jsxRuntime.jsx(MRT_SingleValueEditor, {
6150
6071
  ...props,
6151
6072
  inputType: "number",
6152
- transformValue: _temp$q,
6073
+ transformValue: _temp$r,
6153
6074
  valueFormatter: _temp2$9
6154
6075
  });
6155
6076
  $[0] = props;
@@ -6199,8 +6120,8 @@ const MRT_FilterRuleBooleanEditor = props => {
6199
6120
  t3 = /*#__PURE__*/jsxRuntime.jsx(MRT_SingleValueEditor, {
6200
6121
  ...props,
6201
6122
  options: t2,
6202
- transformValue: _temp3$5,
6203
- valueFormatter: _temp4$2
6123
+ transformValue: _temp3$4,
6124
+ valueFormatter: _temp4$1
6204
6125
  });
6205
6126
  $[7] = props;
6206
6127
  $[8] = t2;
@@ -6392,16 +6313,16 @@ const MRT_FilterRuleMultiNumberEditor = props => {
6392
6313
  }
6393
6314
  return t0;
6394
6315
  };
6395
- function _temp$q(value) {
6316
+ function _temp$r(value) {
6396
6317
  return value === "" ? "" : Number(value);
6397
6318
  }
6398
6319
  function _temp2$9(value_0) {
6399
6320
  return value_0 === undefined || value_0 === null || value_0 === "" ? "" : String(value_0);
6400
6321
  }
6401
- function _temp3$5(value) {
6322
+ function _temp3$4(value) {
6402
6323
  return value === "true" ? true : value === "false" ? false : "";
6403
6324
  }
6404
- function _temp4$2(value_0) {
6325
+ function _temp4$1(value_0) {
6405
6326
  return value_0 === true ? "true" : value_0 === false ? "false" : "";
6406
6327
  }
6407
6328
  function _temp5$1(n) {
@@ -7229,7 +7150,7 @@ const MRT_FormEnumInput = t0 => {
7229
7150
  onChange: e => handleChange(e.target.value),
7230
7151
  renderValue: renderSelectedValue,
7231
7152
  value: currentValue,
7232
- children: enumOptions.map(_temp$p)
7153
+ children: enumOptions.map(_temp$q)
7233
7154
  }), (fieldState.error?.message || fieldConfig?.helperText) && /*#__PURE__*/jsxRuntime.jsx(FormHelperText, {
7234
7155
  children: fieldState.error?.message ?? fieldConfig?.helperText
7235
7156
  })]
@@ -7261,7 +7182,7 @@ const MRT_FormEnumInput = t0 => {
7261
7182
  }
7262
7183
  return t4;
7263
7184
  };
7264
- function _temp$p(option_0) {
7185
+ function _temp$q(option_0) {
7265
7186
  return /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
7266
7187
  value: option_0.value,
7267
7188
  children: option_0.label
@@ -9497,7 +9418,7 @@ const useMRT_AdvancedFiltersDraft = table => {
9497
9418
  if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
9498
9419
  t7 = () => {
9499
9420
  isDraftDirty.current = false;
9500
- setDraftFilters(_temp$o);
9421
+ setDraftFilters(_temp$p);
9501
9422
  };
9502
9423
  $[13] = t7;
9503
9424
  } else {
@@ -9685,7 +9606,7 @@ const useMRT_AdvancedFiltersDraft = table => {
9685
9606
  }
9686
9607
  return t17;
9687
9608
  };
9688
- function _temp$o(current_0) {
9609
+ function _temp$p(current_0) {
9689
9610
  return {
9690
9611
  ...getDefaultFiltersState(),
9691
9612
  pinnedFilters: current_0.pinnedFilters
@@ -9746,7 +9667,7 @@ const MRT_AdvancedFiltersContent = t0 => {
9746
9667
  if ($[2] !== clearRules || $[3] !== handleClose || $[4] !== setFilters) {
9747
9668
  t4 = () => {
9748
9669
  clearRules();
9749
- setFilters(_temp$n);
9670
+ setFilters(_temp$o);
9750
9671
  handleClose();
9751
9672
  };
9752
9673
  $[2] = clearRules;
@@ -9956,7 +9877,7 @@ const MRT_AdvancedFiltersContent = t0 => {
9956
9877
  display: "flex",
9957
9878
  justifyContent: "center",
9958
9879
  sx: {
9959
- border: _temp3$4,
9880
+ border: _temp3$3,
9960
9881
  borderRadius: 2,
9961
9882
  flex: 1,
9962
9883
  minHeight: 140,
@@ -10154,7 +10075,7 @@ const MRT_AdvancedFilters = t0 => {
10154
10075
  }
10155
10076
  return t1;
10156
10077
  };
10157
- function _temp$n(current) {
10078
+ function _temp$o(current) {
10158
10079
  return {
10159
10080
  ...getDefaultFiltersState(),
10160
10081
  pinnedFilters: current.pinnedFilters
@@ -10163,11 +10084,12 @@ function _temp$n(current) {
10163
10084
  function _temp2$8(theme) {
10164
10085
  return theme.zIndex.drawer + 1;
10165
10086
  }
10166
- function _temp3$4(theme_0) {
10087
+ function _temp3$3(theme_0) {
10167
10088
  return `1px dashed ${theme_0.palette.divider}`;
10168
10089
  }
10169
10090
 
10170
10091
  const MRT_Localization_HR = {
10092
+ retryLoading: 'Pokušaj ponovo',
10171
10093
  language: 'hr',
10172
10094
  actions: 'Radnje',
10173
10095
  and: 'i',
@@ -10366,7 +10288,7 @@ const MaterialReactServerTableError = t0 => {
10366
10288
  let t3;
10367
10289
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
10368
10290
  t3 = /*#__PURE__*/jsxRuntime.jsx(Box, {
10369
- sx: _temp$m,
10291
+ sx: _temp$n,
10370
10292
  children: /*#__PURE__*/jsxRuntime.jsx(ErrorOutlineRoundedIcon, {
10371
10293
  sx: {
10372
10294
  fontSize: "2.25rem"
@@ -10442,7 +10364,7 @@ const MaterialReactServerTableError = t0 => {
10442
10364
  }
10443
10365
  return t10;
10444
10366
  };
10445
- function _temp$m(theme) {
10367
+ function _temp$n(theme) {
10446
10368
  return {
10447
10369
  alignItems: "center",
10448
10370
  backgroundColor: theme.palette.error.main + "14",
@@ -10455,39 +10377,227 @@ function _temp$m(theme) {
10455
10377
  };
10456
10378
  }
10457
10379
 
10458
- function RowActionsCell(t0) {
10459
- const $ = compilerRuntime.c(6);
10460
- const {
10461
- row,
10462
- table
10463
- } = t0;
10464
- const {
10465
- actions
10466
- } = table.options;
10467
- let t1;
10468
- if ($[0] !== actions || $[1] !== row || $[2] !== table) {
10469
- t1 = actions?.map(action => /*#__PURE__*/jsxRuntime.jsx(react.Fragment, {
10470
- children: action.renderRow?.({
10471
- row,
10472
- table
10473
- })
10474
- }, action.name));
10475
- $[0] = actions;
10476
- $[1] = row;
10477
- $[2] = table;
10478
- $[3] = t1;
10479
- } else {
10480
- t1 = $[3];
10481
- }
10482
- let t2;
10483
- if ($[4] !== t1) {
10484
- t2 = /*#__PURE__*/jsxRuntime.jsx(Box, {
10485
- children: t1
10486
- });
10487
- $[4] = t1;
10488
- $[5] = t2;
10489
- } else {
10490
- t2 = $[5];
10380
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
10381
+
10382
+ /** Choose the smallest offered page size that covers the viewport. */
10383
+ const getInfinitePageSize = (visibleRowCount, options = defaultRowsPerPage, fallback = 10) => {
10384
+ if (visibleRowCount === undefined) return fallback;
10385
+ const sizes = [...new Set(options.map(option => typeof option === 'number' ? option : option.value))].filter(size => Number.isInteger(size) && size > 0).sort((a, b) => a - b);
10386
+ return sizes.find(size => size >= visibleRowCount) ?? sizes.at(-1) ?? fallback;
10387
+ };
10388
+
10389
+ /** Owns request sequencing; the table remains the sole owner of loaded rows. */
10390
+ const useMRT_ServerDataLoader = ({
10391
+ table,
10392
+ loadData,
10393
+ paginationMode,
10394
+ fetchTrigger,
10395
+ onResult,
10396
+ onLoadingChange,
10397
+ onLoaded
10398
+ }) => {
10399
+ const measuredRowHeights = react.useRef({});
10400
+ const [error, setError] = react.useState(false);
10401
+ const [revision, setRevision] = react.useState(0);
10402
+ const latest = react.useRef({
10403
+ table,
10404
+ loadData,
10405
+ onResult,
10406
+ onLoadingChange,
10407
+ onLoaded
10408
+ });
10409
+ latest.current = {
10410
+ table,
10411
+ loadData,
10412
+ onResult,
10413
+ onLoadingChange,
10414
+ onLoaded
10415
+ };
10416
+ const request = react.useRef({
10417
+ generation: 0,
10418
+ pending: false,
10419
+ nextPage: 0,
10420
+ ready: false,
10421
+ hasMore: true,
10422
+ failed: false
10423
+ });
10424
+ const infinite = paginationMode === 'infinite';
10425
+ const {
10426
+ pageIndex,
10427
+ pageSize
10428
+ } = fetchTrigger.pagination;
10429
+ const fetchPage = react.useCallback(async () => {
10430
+ const current = request.current;
10431
+ if (!current.ready || current.pending || !current.hasMore) return;
10432
+ current.pending = true;
10433
+ current.failed = false;
10434
+ setError(false);
10435
+ latest.current.onLoadingChange(true);
10436
+ const generation = current.generation;
10437
+ const page = current.nextPage;
10438
+ const snapshot = latest.current.table.getState();
10439
+ try {
10440
+ const result = await latest.current.loadData({
10441
+ ...snapshot,
10442
+ pagination: {
10443
+ pageIndex: page,
10444
+ pageSize: snapshot.pagination.pageSize
10445
+ }
10446
+ });
10447
+ if (request.current.generation !== generation) return;
10448
+ const target = latest.current.table;
10449
+ const previous = infinite && page > 0 ? target.options.data ?? [] : [];
10450
+ // Keep order stable while replacing duplicate IDs with the latest data.
10451
+ const rows = new Map(previous.map(row => [row.id, row]));
10452
+ result.data.forEach(row_0 => rows.set(row_0.id, row_0));
10453
+ target.setRows(infinite ? Array.from(rows.values()) : result.data);
10454
+ current.nextPage = page + 1;
10455
+ current.hasMore = infinite && result.data.length > 0 && (page === 0 || rows.size > previous.length) && (result.hasNextPage ?? rows.size < result.rowCount);
10456
+ latest.current.onResult(result);
10457
+ latest.current.onLoaded();
10458
+ } catch {
10459
+ if (request.current.generation !== generation) return;
10460
+ current.failed = true;
10461
+ setError(true);
10462
+ } finally {
10463
+ if (request.current.generation === generation) {
10464
+ current.pending = false;
10465
+ latest.current.onLoadingChange(false);
10466
+ setRevision(value => value + 1);
10467
+ }
10468
+ }
10469
+ }, [infinite]);
10470
+
10471
+ // A different viewport/density can choose a different offered size. Restart
10472
+ // at page zero in that case so pageIndex * pageSize stays valid.
10473
+ const syncPageSize = react.useCallback(() => {
10474
+ if (!infinite) return false;
10475
+ const target_0 = latest.current.table;
10476
+ const currentSize = target_0.getState().pagination.pageSize;
10477
+ const density = target_0.getState().density;
10478
+ const measuredHeight = target_0.getState().showSkeletons !== true && target_0.options.data?.length ? measureBodyRowHeight(target_0.refs.tableRef.current) : undefined;
10479
+ if (measuredHeight !== undefined) measuredRowHeights.current[density] = measuredHeight;
10480
+ const virtualizerOptions = parseFromValuesOrFunc(target_0.options.rowVirtualizerOptions, {
10481
+ table: target_0
10482
+ });
10483
+ const paginationProps = parseFromValuesOrFunc(target_0.options.muiPaginationProps, {
10484
+ table: target_0
10485
+ });
10486
+ const size = getInfinitePageSize(getViewportRowCount({
10487
+ containerHeight: target_0.refs.tableContainerRef.current?.clientHeight ?? 0,
10488
+ headerHeight: target_0.refs.tableHeadRef.current?.offsetHeight ?? 0,
10489
+ footerHeight: target_0.refs.tableFooterRef.current?.offsetHeight ?? 0,
10490
+ density,
10491
+ estimatedRowHeight: measuredRowHeights.current[density] ?? virtualizerOptions?.estimateSize?.(0)
10492
+ }), paginationProps?.rowsPerPageOptions, currentSize);
10493
+ if (size === currentSize) return false;
10494
+ request.current.ready = false;
10495
+ request.current.generation += 1;
10496
+ target_0.setPagination({
10497
+ pageIndex: 0,
10498
+ pageSize: size
10499
+ });
10500
+ return true;
10501
+ }, [infinite]);
10502
+ const density_0 = table.getState().density;
10503
+ react.useEffect(() => {
10504
+ syncPageSize();
10505
+ }, [density_0, syncPageSize]);
10506
+
10507
+ // Query changes invalidate all older requests, including their finally blocks.
10508
+ const visiblePage = infinite ? 0 : pageIndex;
10509
+ react.useEffect(() => {
10510
+ const target_1 = latest.current.table;
10511
+ if (syncPageSize()) return;
10512
+ request.current = {
10513
+ generation: request.current.generation + 1,
10514
+ pending: false,
10515
+ nextPage: visiblePage,
10516
+ ready: true,
10517
+ hasMore: true,
10518
+ failed: false
10519
+ };
10520
+ if (infinite) {
10521
+ target_1.setRows([]);
10522
+ if (target_1.getState().pagination.pageIndex !== 0) target_1.setPageIndex(0);
10523
+ const node = target_1.refs.tableContainerRef.current;
10524
+ if (node) node.scrollTop = 0;
10525
+ target_1.options.rowVirtualizerInstanceRef?.current?.scrollToIndex(0);
10526
+ }
10527
+ void fetchPage();
10528
+ return () => {
10529
+ request.current.generation += 1;
10530
+ };
10531
+ }, [fetchPage, syncPageSize, loadData, infinite, visiblePage, pageSize, fetchTrigger.filterRules, fetchTrigger.sorting, fetchTrigger.columnVisibilityShowTrigger, fetchTrigger.refetchIndex]);
10532
+ const loadMore = react.useCallback(() => {
10533
+ if (infinite && !request.current.failed) void fetchPage();
10534
+ }, [fetchPage, infinite]);
10535
+ const checkScroll = react.useCallback(node_0 => {
10536
+ if (node_0 && node_0.clientHeight > 0 && node_0.scrollHeight - node_0.scrollTop - node_0.clientHeight < 200) loadMore();
10537
+ }, [loadMore]);
10538
+ react.useEffect(() => {
10539
+ if (!infinite) return;
10540
+ const node_1 = latest.current.table.refs.tableContainerRef.current;
10541
+ const observer = new ResizeObserver(() => {
10542
+ if (!syncPageSize() && node_1 && node_1.scrollHeight <= node_1.clientHeight) checkScroll(node_1);
10543
+ });
10544
+ if (node_1) observer.observe(node_1);
10545
+ const target_2 = latest.current.table;
10546
+ // The same observer also catches content/font/density changes without
10547
+ // adding an observer per row. A new body is attached after each data update.
10548
+ const body = target_2.refs.tableRef.current?.querySelector('tbody');
10549
+ if (body) observer.observe(body);
10550
+ if (target_2.refs.tableHeadRef.current) observer.observe(target_2.refs.tableHeadRef.current);
10551
+ if (target_2.refs.tableFooterRef.current) observer.observe(target_2.refs.tableFooterRef.current);
10552
+ return () => observer.disconnect();
10553
+ }, [checkScroll, infinite, syncPageSize, revision]);
10554
+ react.useEffect(() => {
10555
+ if (!infinite) return;
10556
+ const node_2 = latest.current.table.refs.tableContainerRef.current;
10557
+ // Correct the density estimate once real row heights become measurable.
10558
+ // Cached heights survive setRows([]), preventing estimate/measurement loops.
10559
+ if (!syncPageSize() && node_2 && node_2.scrollHeight <= node_2.clientHeight) checkScroll(node_2);
10560
+ }, [checkScroll, infinite, syncPageSize, revision]);
10561
+ return {
10562
+ error,
10563
+ checkScroll,
10564
+ retry: fetchPage
10565
+ };
10566
+ };
10567
+
10568
+ function RowActionsCell(t0) {
10569
+ const $ = compilerRuntime.c(6);
10570
+ const {
10571
+ row,
10572
+ table
10573
+ } = t0;
10574
+ const {
10575
+ actions
10576
+ } = table.options;
10577
+ let t1;
10578
+ if ($[0] !== actions || $[1] !== row || $[2] !== table) {
10579
+ t1 = actions?.map(action => /*#__PURE__*/jsxRuntime.jsx(react.Fragment, {
10580
+ children: action.renderRow?.({
10581
+ row,
10582
+ table
10583
+ })
10584
+ }, action.name));
10585
+ $[0] = actions;
10586
+ $[1] = row;
10587
+ $[2] = table;
10588
+ $[3] = t1;
10589
+ } else {
10590
+ t1 = $[3];
10591
+ }
10592
+ let t2;
10593
+ if ($[4] !== t1) {
10594
+ t2 = /*#__PURE__*/jsxRuntime.jsx(Box, {
10595
+ children: t1
10596
+ });
10597
+ $[4] = t1;
10598
+ $[5] = t2;
10599
+ } else {
10600
+ t2 = $[5];
10491
10601
  }
10492
10602
  return t2;
10493
10603
  }
@@ -10640,7 +10750,7 @@ const MRT_ActiveFilters = t0 => {
10640
10750
  let t3;
10641
10751
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
10642
10752
  t3 = {
10643
- borderBottom: _temp$l
10753
+ borderBottom: _temp$m
10644
10754
  };
10645
10755
  $[4] = t3;
10646
10756
  } else {
@@ -10679,7 +10789,7 @@ const MRT_ActiveFilters = t0 => {
10679
10789
  }
10680
10790
  return t1;
10681
10791
  };
10682
- function _temp$l(theme) {
10792
+ function _temp$m(theme) {
10683
10793
  return `1px solid ${theme.palette.divider}`;
10684
10794
  }
10685
10795
 
@@ -10721,7 +10831,7 @@ const MRT_LinearProgressBar = t0 => {
10721
10831
  const {
10722
10832
  isSaving
10723
10833
  } = t2;
10724
- const showProgressBars = reactStore.useSelector(table.store, _temp$k);
10834
+ const showProgressBars = reactStore.useSelector(table.store, _temp$l);
10725
10835
  let t3;
10726
10836
  if ($[6] !== isTopToolbar || $[7] !== muiLinearProgressProps || $[8] !== table) {
10727
10837
  t3 = parseFromValuesOrFunc(muiLinearProgressProps, {
@@ -10805,7 +10915,7 @@ const MRT_LinearProgressBar = t0 => {
10805
10915
  }
10806
10916
  return t11;
10807
10917
  };
10808
- function _temp$k(state) {
10918
+ function _temp$l(state) {
10809
10919
  return state.showProgressBars;
10810
10920
  }
10811
10921
 
@@ -10858,7 +10968,7 @@ const MRT_SelectionCountBadge = t0 => {
10858
10968
  let t3;
10859
10969
  if ($[2] !== t2 || $[3] !== table.atoms.rowSelection) {
10860
10970
  t3 = /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
10861
- selector: _temp$j,
10971
+ selector: _temp$k,
10862
10972
  source: table.atoms.rowSelection,
10863
10973
  children: t2
10864
10974
  });
@@ -10870,11 +10980,10 @@ const MRT_SelectionCountBadge = t0 => {
10870
10980
  }
10871
10981
  return t3;
10872
10982
  };
10873
- function _temp$j(rowSelection) {
10983
+ function _temp$k(rowSelection) {
10874
10984
  return Object.values(rowSelection).filter(Boolean).length;
10875
10985
  }
10876
10986
 
10877
- const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
10878
10987
  const isPaginationItemColor = color => color === 'primary' || color === 'secondary' || color === 'standard';
10879
10988
  const MRT_TablePagination = ({
10880
10989
  position = 'bottom',
@@ -11156,7 +11265,7 @@ const MRT_ToolbarDropZone = t0 => {
11156
11265
  showToolbarDropZone,
11157
11266
  draggingColumn,
11158
11267
  hoveredColumn
11159
- } = reactStore.useSelector(table.store, _temp$i);
11268
+ } = reactStore.useSelector(table.store, _temp$j);
11160
11269
  let t3;
11161
11270
  if ($[5] !== setHoveredColumn) {
11162
11271
  t3 = _event => {
@@ -11272,7 +11381,7 @@ const MRT_ToolbarDropZone = t0 => {
11272
11381
  }
11273
11382
  return t10;
11274
11383
  };
11275
- function _temp$i(state) {
11384
+ function _temp$j(state) {
11276
11385
  return {
11277
11386
  showToolbarDropZone: state.showToolbarDropZone,
11278
11387
  draggingColumn: state.draggingColumn,
@@ -11692,7 +11801,7 @@ const MRT_QuickFilterItem = t0 => {
11692
11801
  onClick: handleUnpin,
11693
11802
  size: "small",
11694
11803
  sx: {
11695
- backgroundColor: _temp$h,
11804
+ backgroundColor: _temp$i,
11696
11805
  color: _temp2$6,
11697
11806
  width: 18,
11698
11807
  height: 18,
@@ -11701,7 +11810,7 @@ const MRT_QuickFilterItem = t0 => {
11701
11810
  top: 8,
11702
11811
  zIndex: 1,
11703
11812
  "&:hover": {
11704
- backgroundColor: _temp3$3
11813
+ backgroundColor: _temp3$2
11705
11814
  }
11706
11815
  },
11707
11816
  children: /*#__PURE__*/jsxRuntime.jsx(CloseIcon, {
@@ -11842,13 +11951,13 @@ const MRT_QuickFiltersBar = t0 => {
11842
11951
  }
11843
11952
  return t1;
11844
11953
  };
11845
- function _temp$h(theme) {
11954
+ function _temp$i(theme) {
11846
11955
  return theme.palette.error.main;
11847
11956
  }
11848
11957
  function _temp2$6(theme_0) {
11849
11958
  return theme_0.palette.background.paper;
11850
11959
  }
11851
- function _temp3$3(theme_1) {
11960
+ function _temp3$2(theme_1) {
11852
11961
  return theme_1.palette.error.dark;
11853
11962
  }
11854
11963
 
@@ -12038,7 +12147,7 @@ function MRT_TableOptionsMenu(t0) {
12038
12147
  anchorEl: anchorEl,
12039
12148
  anchorOrigin: t3,
12040
12149
  disableScrollLock: true,
12041
- onClick: _temp$g,
12150
+ onClick: _temp$h,
12042
12151
  onClose: onClose,
12043
12152
  open: open,
12044
12153
  transformOrigin: t4,
@@ -12056,7 +12165,7 @@ function MRT_TableOptionsMenu(t0) {
12056
12165
  }
12057
12166
  return t8;
12058
12167
  }
12059
- function _temp$g(event) {
12168
+ function _temp$h(event) {
12060
12169
  return event.stopPropagation();
12061
12170
  }
12062
12171
 
@@ -12447,7 +12556,7 @@ const MRT_NewEntryButton = t0 => {
12447
12556
  };
12448
12557
 
12449
12558
  const MRT_ShowHideColumnsMenuItems = t0 => {
12450
- const $ = compilerRuntime.c(42);
12559
+ const $ = compilerRuntime.c(47);
12451
12560
  let allColumns;
12452
12561
  let column;
12453
12562
  let hoveredColumn;
@@ -12520,8 +12629,24 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12520
12629
  return null;
12521
12630
  }
12522
12631
  let t4;
12523
- if ($[10] !== column.depth || $[11] !== column.id || $[12] !== draggingBorderColor || $[13] !== hoveredColumn?.id || $[14] !== rest?.sx) {
12524
- t4 = theme => ({
12632
+ if ($[10] !== column || $[11] !== enableHiding || $[12] !== handleToggleColumnHidden || $[13] !== rest) {
12633
+ t4 = event => {
12634
+ rest?.onClick?.(event);
12635
+ if (enableHiding && column.getCanHide()) {
12636
+ handleToggleColumnHidden(column, column.getIsVisible());
12637
+ }
12638
+ };
12639
+ $[10] = column;
12640
+ $[11] = enableHiding;
12641
+ $[12] = handleToggleColumnHidden;
12642
+ $[13] = rest;
12643
+ $[14] = t4;
12644
+ } else {
12645
+ t4 = $[14];
12646
+ }
12647
+ let t5;
12648
+ if ($[15] !== column.depth || $[16] !== column.id || $[17] !== draggingBorderColor || $[18] !== hoveredColumn?.id || $[19] !== rest?.sx) {
12649
+ t5 = theme => ({
12525
12650
  alignItems: "center",
12526
12651
  justifyContent: "flex-start",
12527
12652
  my: 0,
@@ -12531,30 +12656,31 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12531
12656
  py: "6px",
12532
12657
  ...parseFromValuesOrFunc(rest?.sx, theme)
12533
12658
  });
12534
- $[10] = column.depth;
12535
- $[11] = column.id;
12536
- $[12] = draggingBorderColor;
12537
- $[13] = hoveredColumn?.id;
12538
- $[14] = rest?.sx;
12539
- $[15] = t4;
12659
+ $[15] = column.depth;
12660
+ $[16] = column.id;
12661
+ $[17] = draggingBorderColor;
12662
+ $[18] = hoveredColumn?.id;
12663
+ $[19] = rest?.sx;
12664
+ $[20] = t5;
12540
12665
  } else {
12541
- t4 = $[15];
12666
+ t5 = $[20];
12542
12667
  }
12543
- const t5 = `column-show-hide-row-${column.id}`;
12544
- let t6;
12545
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
12546
- t6 = {
12668
+ const t6 = `column-show-hide-row-${column.id}`;
12669
+ let t7;
12670
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
12671
+ t7 = {
12547
12672
  display: "flex",
12548
12673
  flexWrap: "nowrap",
12549
- gap: "8px"
12674
+ gap: "8px",
12675
+ width: "100%"
12550
12676
  };
12551
- $[16] = t6;
12677
+ $[21] = t7;
12552
12678
  } else {
12553
- t6 = $[16];
12679
+ t7 = $[21];
12554
12680
  }
12555
- let t7;
12556
- if ($[17] !== column || $[18] !== columnDef.header || $[19] !== columnDefType || $[20] !== enableHiding || $[21] !== handleToggleColumnHidden || $[22] !== localization || $[23] !== table.atoms) {
12557
- t7 = enableHiding ? /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
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, {
12558
12684
  source: table.atoms.columnVisibility,
12559
12685
  children: () => {
12560
12686
  const switchChecked = column.getIsVisible();
@@ -12577,7 +12703,7 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12577
12703
  }),
12578
12704
  disabled: !column.getCanHide(),
12579
12705
  label: columnDef.header,
12580
- onChange: () => handleToggleColumnHidden(column, switchChecked)
12706
+ onChange: _temp$g
12581
12707
  });
12582
12708
  }
12583
12709
  }) : /*#__PURE__*/jsxRuntime.jsx(Typography, {
@@ -12586,48 +12712,49 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12586
12712
  },
12587
12713
  children: columnDef.header
12588
12714
  });
12589
- $[17] = column;
12590
- $[18] = columnDef.header;
12591
- $[19] = columnDefType;
12592
- $[20] = enableHiding;
12593
- $[21] = handleToggleColumnHidden;
12594
- $[22] = localization;
12595
- $[23] = table.atoms;
12596
- $[24] = t7;
12597
- } else {
12598
- t7 = $[24];
12599
- }
12600
- let t8;
12601
- if ($[25] !== t5 || $[26] !== t7) {
12602
- t8 = /*#__PURE__*/jsxRuntime.jsx(Box, {
12603
- "data-testid": t5,
12604
- sx: t6,
12605
- children: t7
12606
- });
12607
- $[25] = t5;
12608
- $[26] = t7;
12609
- $[27] = t8;
12715
+ $[22] = column;
12716
+ $[23] = columnDef.header;
12717
+ $[24] = columnDefType;
12718
+ $[25] = enableHiding;
12719
+ $[26] = localization;
12720
+ $[27] = table.atoms;
12721
+ $[28] = t8;
12610
12722
  } else {
12611
- t8 = $[27];
12723
+ t8 = $[28];
12612
12724
  }
12613
12725
  let t9;
12614
- if ($[28] !== rest || $[29] !== t4 || $[30] !== t8) {
12615
- t9 = /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
12616
- disableRipple: true,
12617
- ...rest,
12618
- sx: t4,
12726
+ if ($[29] !== t6 || $[30] !== t8) {
12727
+ t9 = /*#__PURE__*/jsxRuntime.jsx(Box, {
12728
+ "data-testid": t6,
12729
+ sx: t7,
12619
12730
  children: t8
12620
12731
  });
12621
- $[28] = rest;
12622
- $[29] = t4;
12732
+ $[29] = t6;
12623
12733
  $[30] = t8;
12624
12734
  $[31] = t9;
12625
12735
  } else {
12626
12736
  t9 = $[31];
12627
12737
  }
12628
12738
  let t10;
12629
- if ($[32] !== allColumns || $[33] !== column.columns || $[34] !== hoveredColumn || $[35] !== isNestedColumns || $[36] !== setHoveredColumn || $[37] !== table) {
12630
- t10 = column.columns?.map((c, i) => /*#__PURE__*/jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, {
12739
+ if ($[32] !== rest || $[33] !== t4 || $[34] !== t5 || $[35] !== t9) {
12740
+ t10 = /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
12741
+ disableRipple: true,
12742
+ ...rest,
12743
+ onClick: t4,
12744
+ sx: t5,
12745
+ children: t9
12746
+ });
12747
+ $[32] = rest;
12748
+ $[33] = t4;
12749
+ $[34] = t5;
12750
+ $[35] = t9;
12751
+ $[36] = t10;
12752
+ } else {
12753
+ t10 = $[36];
12754
+ }
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, {
12631
12758
  allColumns: allColumns,
12632
12759
  column: c,
12633
12760
  hoveredColumn: hoveredColumn,
@@ -12635,30 +12762,41 @@ const MRT_ShowHideColumnsMenuItems = t0 => {
12635
12762
  setHoveredColumn: setHoveredColumn,
12636
12763
  table: table
12637
12764
  }, `${i}-${c.id}`));
12638
- $[32] = allColumns;
12639
- $[33] = column.columns;
12640
- $[34] = hoveredColumn;
12641
- $[35] = isNestedColumns;
12642
- $[36] = setHoveredColumn;
12643
- $[37] = table;
12644
- $[38] = t10;
12765
+ $[37] = allColumns;
12766
+ $[38] = column.columns;
12767
+ $[39] = hoveredColumn;
12768
+ $[40] = isNestedColumns;
12769
+ $[41] = setHoveredColumn;
12770
+ $[42] = table;
12771
+ $[43] = t11;
12645
12772
  } else {
12646
- t10 = $[38];
12773
+ t11 = $[43];
12647
12774
  }
12648
- let t11;
12649
- if ($[39] !== t10 || $[40] !== t9) {
12650
- t11 = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
12651
- children: [t9, t10]
12775
+ let t12;
12776
+ if ($[44] !== t10 || $[45] !== t11) {
12777
+ t12 = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
12778
+ children: [t10, t11]
12652
12779
  });
12653
- $[39] = t10;
12654
- $[40] = t9;
12655
- $[41] = t11;
12780
+ $[44] = t10;
12781
+ $[45] = t11;
12782
+ $[46] = t12;
12656
12783
  } else {
12657
- t11 = $[41];
12784
+ t12 = $[46];
12658
12785
  }
12659
- return t11;
12786
+ return t12;
12787
+ };
12788
+ function _temp$g() {}
12789
+
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;
12795
+ if (typeof header === 'string' && header.toLowerCase().includes(term)) {
12796
+ return true;
12797
+ }
12798
+ return !!column.columns?.some(child => columnMatchesSearch(child, term));
12660
12799
  };
12661
-
12662
12800
  const MRT_ShowHideColumnsMenu = ({
12663
12801
  anchorEl,
12664
12802
  setAnchorEl,
@@ -12676,6 +12814,10 @@ const MRT_ShowHideColumnsMenu = ({
12676
12814
  getState,
12677
12815
  options: {
12678
12816
  enableHiding,
12817
+ icons: {
12818
+ CloseIcon,
12819
+ SearchIcon
12820
+ },
12679
12821
  localization,
12680
12822
  mrtTheme: {
12681
12823
  menuBackgroundColor
@@ -12687,6 +12829,7 @@ const MRT_ShowHideColumnsMenu = ({
12687
12829
  columnPinning
12688
12830
  } = getState();
12689
12831
  const density = reactStore.useSelector(table.store, state => state.density);
12832
+ const [searchText, setSearchText] = react.useState('');
12690
12833
  const handleToggleAllColumns = value => {
12691
12834
  const updates = getAllLeafColumns().filter(column => column.columnDef.enableHiding !== false).reduce((acc, column_0) => {
12692
12835
  acc[column_0.id] = value ?? !column_0.getIsVisible();
@@ -12706,19 +12849,87 @@ const MRT_ShowHideColumnsMenu = ({
12706
12849
  }, [columnOrder, columnPinning, getAllColumns(), getCenterLeafColumns(), getStartLeafColumns(), getEndLeafColumns()]);
12707
12850
  const isNestedColumns = allColumns.some(col_1 => col_1.columnDef.columnDefType === 'group');
12708
12851
  const [hoveredColumn, setHoveredColumn] = react.useState(null);
12852
+ const trimmedSearchText = searchText.trim().toLowerCase();
12853
+ const filteredColumns = react.useMemo(() => {
12854
+ if (!trimmedSearchText) return allColumns;
12855
+ return allColumns.filter(column_1 => columnMatchesSearch(column_1, trimmedSearchText));
12856
+ }, [allColumns, trimmedSearchText]);
12857
+ const handleSearchChange = event => {
12858
+ setSearchText(event.target.value);
12859
+ };
12709
12860
  return /*#__PURE__*/jsxRuntime.jsxs(Menu, {
12710
12861
  MenuListProps: {
12711
12862
  dense: density === 'compact',
12712
12863
  sx: {
12713
12864
  backgroundColor: menuBackgroundColor
12714
12865
  }
12866
+ }
12867
+ // Default anchor/transform origins both resolve to the anchor's own
12868
+ // top-left corner, so the menu opened directly on top of the "Columns"
12869
+ // button instead of below it — anchoring from the button's bottom edge
12870
+ // keeps the button visible once the menu is open.
12871
+ ,
12872
+ anchorOrigin: {
12873
+ horizontal: 'left',
12874
+ vertical: 'bottom'
12875
+ },
12876
+ transformOrigin: {
12877
+ horizontal: 'left',
12878
+ vertical: 'top'
12715
12879
  },
12716
12880
  anchorEl: anchorEl,
12881
+ autoFocus: false,
12717
12882
  disableScrollLock: true,
12718
- onClose: () => setAnchorEl(null),
12883
+ onClose: () => {
12884
+ setAnchorEl(null);
12885
+ setSearchText('');
12886
+ },
12719
12887
  open: !!anchorEl,
12720
12888
  ...rest,
12721
- children: [/*#__PURE__*/jsxRuntime.jsxs(Box, {
12889
+ children: [/*#__PURE__*/jsxRuntime.jsx(Box, {
12890
+ sx: {
12891
+ px: '0.5rem',
12892
+ pb: '0.25rem'
12893
+ },
12894
+ children: /*#__PURE__*/jsxRuntime.jsx(TextField, {
12895
+ autoFocus: true,
12896
+ fullWidth: true,
12897
+ onChange: handleSearchChange,
12898
+ onKeyDown: event_0 => {
12899
+ // Stop MUI's menu type-ahead/arrow-key handling from treating
12900
+ // keystrokes typed here as list navigation.
12901
+ event_0.stopPropagation();
12902
+ if (event_0.key === 'Escape') {
12903
+ setAnchorEl(null);
12904
+ setSearchText('');
12905
+ }
12906
+ },
12907
+ placeholder: localization.search,
12908
+ size: "small",
12909
+ slotProps: {
12910
+ input: {
12911
+ startAdornment: /*#__PURE__*/jsxRuntime.jsx(InputAdornment, {
12912
+ position: "start",
12913
+ children: /*#__PURE__*/jsxRuntime.jsx(SearchIcon, {
12914
+ fontSize: "small"
12915
+ })
12916
+ }),
12917
+ endAdornment: searchText && /*#__PURE__*/jsxRuntime.jsx(InputAdornment, {
12918
+ position: "end",
12919
+ children: /*#__PURE__*/jsxRuntime.jsx(IconButton, {
12920
+ "aria-label": localization.clearSearch,
12921
+ onClick: () => setSearchText(''),
12922
+ size: "small",
12923
+ children: /*#__PURE__*/jsxRuntime.jsx(CloseIcon, {
12924
+ fontSize: "small"
12925
+ })
12926
+ })
12927
+ })
12928
+ }
12929
+ },
12930
+ value: searchText
12931
+ })
12932
+ }), /*#__PURE__*/jsxRuntime.jsxs(Box, {
12722
12933
  sx: {
12723
12934
  display: 'flex',
12724
12935
  justifyContent: 'space-between',
@@ -12740,14 +12951,21 @@ const MRT_ShowHideColumnsMenu = ({
12740
12951
  children: localization.showAll
12741
12952
  })
12742
12953
  })]
12743
- }), /*#__PURE__*/jsxRuntime.jsx(Divider, {}), allColumns.map((column_1, index) => /*#__PURE__*/jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, {
12954
+ }), /*#__PURE__*/jsxRuntime.jsx(Divider, {}), filteredColumns.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(Typography, {
12955
+ sx: {
12956
+ p: '0.75rem',
12957
+ textAlign: 'center'
12958
+ },
12959
+ variant: "body2",
12960
+ children: localization.noResultsFound
12961
+ }) : filteredColumns.map((column_2, index) => /*#__PURE__*/jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, {
12744
12962
  allColumns: allColumns,
12745
- column: column_1,
12963
+ column: column_2,
12746
12964
  hoveredColumn: hoveredColumn,
12747
12965
  isNestedColumns: isNestedColumns,
12748
12966
  setHoveredColumn: setHoveredColumn,
12749
12967
  table: table
12750
- }, `${index}-${column_1.id}`))]
12968
+ }, `${index}-${column_2.id}`))]
12751
12969
  });
12752
12970
  };
12753
12971
 
@@ -13568,6 +13786,123 @@ const MRT_TopToolbar = ({
13568
13786
  });
13569
13787
  };
13570
13788
 
13789
+ const BODY_CELL_SELECTOR = '[data-column-id]';
13790
+
13791
+ /**
13792
+ * Headless (renders nothing) — commits a body-content-based width for every
13793
+ * column the consumer didn't give an explicit `size`/`width`, using the same
13794
+ * measurement the resize handle's double-click autosize uses
13795
+ * (computeAutoSizedColumnWidth). The header title is never measured.
13796
+ *
13797
+ * Body content only exists once real rows are rendered, so this waits until
13798
+ * the table is neither loading nor showing skeletons and at least one body
13799
+ * cell is in the DOM. Until then such columns keep their default width and
13800
+ * share free space through growth. Measuring happens in a layout effect, so
13801
+ * the final width is applied before the first paint of the loaded rows.
13802
+ *
13803
+ * Each column is settled once: measured when its cells are rendered, or left
13804
+ * at its default width when it's visible but has no rendered cells (column
13805
+ * virtualization) — later pages, batches or horizontal scrolling never change
13806
+ * it again. A hidden column stays pending and is measured when first shown.
13807
+ * Only the currently rendered rows are measured (row virtualization); a wider
13808
+ * value further down needs a double-click on the resize handle.
13809
+ *
13810
+ * Rendered after <MRT_Table> in the container so the table ref is attached
13811
+ * when its layout effect runs. Runs on every render (no dependency array):
13812
+ * rows arriving via setRows or isLoading/showSkeletons toggling re-render
13813
+ * the container. Once every candidate is settled it is an early return.
13814
+ */
13815
+ const MRT_AutoSizeColumnsEffect = t0 => {
13816
+ const $ = compilerRuntime.c(9);
13817
+ const {
13818
+ table
13819
+ } = t0;
13820
+ const {
13821
+ getColumn,
13822
+ getRowModel,
13823
+ getState,
13824
+ refs: t1,
13825
+ setColumnSizing
13826
+ } = table;
13827
+ const {
13828
+ autoSizeColumnIdsRef,
13829
+ autoSizedColumnWidthsRef,
13830
+ tableRef
13831
+ } = t1;
13832
+ let t2;
13833
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
13834
+ t2 = new Set();
13835
+ $[0] = t2;
13836
+ } else {
13837
+ t2 = $[0];
13838
+ }
13839
+ const settledIdsRef = react.useRef(t2);
13840
+ let t3;
13841
+ if ($[1] !== autoSizeColumnIdsRef || $[2] !== autoSizedColumnWidthsRef || $[3] !== getColumn || $[4] !== getRowModel || $[5] !== getState || $[6] !== setColumnSizing || $[7] !== tableRef) {
13842
+ t3 = () => {
13843
+ const candidateIds = autoSizeColumnIdsRef.current;
13844
+ const settledIds = settledIdsRef.current;
13845
+ if ([...candidateIds].every(id => settledIds.has(id))) {
13846
+ return;
13847
+ }
13848
+ const {
13849
+ columnSizing,
13850
+ isLoading,
13851
+ showSkeletons
13852
+ } = getState();
13853
+ const tableEl = tableRef.current;
13854
+ if (isLoading || showSkeletons || !tableEl || !getRowModel().rows.length || !tableEl.querySelector(BODY_CELL_SELECTOR)) {
13855
+ return;
13856
+ }
13857
+ const updates = {};
13858
+ candidateIds.forEach(columnId => {
13859
+ if (settledIds.has(columnId)) {
13860
+ return;
13861
+ }
13862
+ const column = getColumn(columnId);
13863
+ if (!column) {
13864
+ return;
13865
+ }
13866
+ if (columnSizing[columnId] !== undefined) {
13867
+ settledIds.add(columnId);
13868
+ return;
13869
+ }
13870
+ if (!column.getIsVisible()) {
13871
+ return;
13872
+ }
13873
+ settledIds.add(columnId);
13874
+ const bodyCellEls = tableEl.querySelectorAll(`[data-column-id="${CSS.escape(columnId)}"]`);
13875
+ if (!bodyCellEls.length) {
13876
+ return;
13877
+ }
13878
+ updates[columnId] = computeAutoSizedColumnWidth({
13879
+ bodyCellEls,
13880
+ ...getColumnSizeBounds(column.columnDef)
13881
+ });
13882
+ });
13883
+ if (Object.keys(updates).length) {
13884
+ Object.assign(autoSizedColumnWidthsRef.current, updates);
13885
+ setColumnSizing(old => ({
13886
+ ...old,
13887
+ ...updates
13888
+ }));
13889
+ }
13890
+ };
13891
+ $[1] = autoSizeColumnIdsRef;
13892
+ $[2] = autoSizedColumnWidthsRef;
13893
+ $[3] = getColumn;
13894
+ $[4] = getRowModel;
13895
+ $[5] = getState;
13896
+ $[6] = setColumnSizing;
13897
+ $[7] = tableRef;
13898
+ $[8] = t3;
13899
+ } else {
13900
+ t3 = $[8];
13901
+ }
13902
+ react.useLayoutEffect(t3);
13903
+ return null;
13904
+ };
13905
+
13571
13906
  /**
13572
13907
  * Headless (renders nothing) — owns its own reactive subscription so this
13573
13908
  * correction runs independently of whatever the root `useTable()` selector
@@ -14024,6 +14359,9 @@ const MRT_TableBodyCell = ({
14024
14359
  hoveredRow
14025
14360
  } = reactStore.useSelector(table.store, state => ({
14026
14361
  actionCell: state.actionCell,
14362
+ // Pinned-group edges can change without this cell's identity changing.
14363
+ columnPinning: state.columnPinning,
14364
+ columnVisibility: state.columnVisibility,
14027
14365
  columnResizing: state.columnResizing,
14028
14366
  density: state.density,
14029
14367
  draggingColumn: state.draggingColumn,
@@ -14497,7 +14835,7 @@ const MRT_TableBodyRow = ({
14497
14835
  const tableHeadHeight = enableStickyHeader && tableHeadRef.current?.clientHeight || 0;
14498
14836
  const tableFooterHeight = enableStickyFooter && tableFooterRef.current?.clientHeight || 0;
14499
14837
  const sx = parseFromValuesOrFunc(tableRowProps?.sx, theme);
14500
- const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
14838
+ const defaultRowHeight = getDefaultRowHeight(density);
14501
14839
  const customRowHeight =
14502
14840
  // @ts-expect-error
14503
14841
  parseInt(tableRowProps?.style?.height ?? sx?.height, 10) || undefined;
@@ -15219,34 +15557,167 @@ const MRT_TableFooter = ({
15219
15557
  });
15220
15558
  };
15221
15559
 
15222
- const MRT_ActionMenuItem = t0 => {
15223
- const $ = compilerRuntime.c(20);
15224
- let icon;
15225
- let label;
15226
- let onOpenSubMenu;
15227
- let rest;
15228
- let table;
15229
- if ($[0] !== t0) {
15230
- ({
15231
- icon,
15232
- label,
15233
- onOpenSubMenu,
15234
- table,
15235
- ...rest
15236
- } = t0);
15237
- $[0] = t0;
15238
- $[1] = icon;
15239
- $[2] = label;
15240
- $[3] = onOpenSubMenu;
15241
- $[4] = rest;
15242
- $[5] = table;
15243
- } else {
15244
- icon = $[1];
15245
- label = $[2];
15246
- onOpenSubMenu = $[3];
15247
- rest = $[4];
15248
- table = $[5];
15249
- }
15560
+ const MRT_SelectAllMenuItems = ({
15561
+ table,
15562
+ closeMenu: handleClose
15563
+ }) => {
15564
+ const [isSelectingAllPages, setIsSelectingAllPages] = react.useState(false);
15565
+ const {
15566
+ getState,
15567
+ options: {
15568
+ enableRowPinning,
15569
+ getAllSelectableRowIds,
15570
+ localization,
15571
+ rowPinningDisplayMode
15572
+ },
15573
+ refs: {
15574
+ allSelectableRowIdsRef
15575
+ }
15576
+ } = table;
15577
+ const {
15578
+ isLoading,
15579
+ showProgressBars
15580
+ } = getState();
15581
+
15582
+ // Clears row pinning on every bulk selection/deselection
15583
+ const clearPinning = () => {
15584
+ if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
15585
+ table.setRowPinning({
15586
+ bottom: [],
15587
+ top: []
15588
+ });
15589
+ }
15590
+ };
15591
+
15592
+ // ── Current-page actions ────────────────────────────────────────────────────
15593
+
15594
+ const handleSelectCurrentPage = () => {
15595
+ table.toggleAllPageRowsSelected(true);
15596
+ clearPinning();
15597
+ handleClose();
15598
+ };
15599
+ const handleDeselectCurrentPage = () => {
15600
+ if (allSelectableRowIdsRef.current.length > 0) {
15601
+ // When all pages are selected, deselecting the current page must clear the entire selection — otherwise rows on other pages remain "ghost-selected" but the user can't see them.
15602
+ table.setRowSelection({});
15603
+ allSelectableRowIdsRef.current = [];
15604
+ } else {
15605
+ table.toggleAllPageRowsSelected(false);
15606
+ }
15607
+ clearPinning();
15608
+ handleClose();
15609
+ };
15610
+
15611
+ // ── All-pages actions ───────────────────────────────────────────────────────
15612
+
15613
+ const handleSelectAllPages = async () => {
15614
+ handleClose();
15615
+ if (getAllSelectableRowIds) {
15616
+ // Server-side: IDs are not available locally, fetch them from the API
15617
+ setIsSelectingAllPages(true);
15618
+ table.setShowProgressBars(true);
15619
+ try {
15620
+ const ids = await getAllSelectableRowIds({
15621
+ table
15622
+ });
15623
+ allSelectableRowIdsRef.current = ids;
15624
+ const newSelection = {};
15625
+ ids.forEach(id => {
15626
+ newSelection[id] = true;
15627
+ });
15628
+ table.setRowSelection(newSelection);
15629
+ clearPinning();
15630
+ } finally {
15631
+ setIsSelectingAllPages(false);
15632
+ table.setShowProgressBars(false);
15633
+ }
15634
+ } else {
15635
+ // Client-side: all data is available locally
15636
+ table.toggleAllRowsSelected(true);
15637
+ clearPinning();
15638
+ }
15639
+ };
15640
+ const handleDeselectAllPages = () => {
15641
+ if (getAllSelectableRowIds) {
15642
+ table.setRowSelection({});
15643
+ } else {
15644
+ table.toggleAllRowsSelected(false);
15645
+ }
15646
+ allSelectableRowIdsRef.current = [];
15647
+ clearPinning();
15648
+ handleClose();
15649
+ };
15650
+ const isDisabled = isLoading || showProgressBars || isSelectingAllPages;
15651
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
15652
+ children: /*#__PURE__*/jsxRuntime.jsx(reactTable.Subscribe, {
15653
+ selector: state => ({
15654
+ pagination: state.pagination,
15655
+ rowSelection: state.rowSelection
15656
+ }),
15657
+ source: table.store,
15658
+ children: ({
15659
+ rowSelection
15660
+ }) => {
15661
+ const isAllCurrentPageSelected = table.getIsAllPageRowsSelected();
15662
+ const isAllPagesActive = getIsAllPagesSelectionActive(table, rowSelection);
15663
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
15664
+ children: [isAllCurrentPageSelected ? /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
15665
+ disabled: isDisabled,
15666
+ onClick: handleDeselectCurrentPage,
15667
+ children: localization.deselectAllOnCurrentPage
15668
+ }) : /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
15669
+ disabled: isDisabled,
15670
+ onClick: handleSelectCurrentPage,
15671
+ children: localization.selectAllOnCurrentPage
15672
+ }), isAllPagesActive ? /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
15673
+ disabled: isDisabled,
15674
+ onClick: handleDeselectAllPages,
15675
+ children: localization.deselectAllOnAllPages
15676
+ }) : /*#__PURE__*/jsxRuntime.jsxs(MenuItem, {
15677
+ disabled: isDisabled,
15678
+ onClick: handleSelectAllPages,
15679
+ children: [isSelectingAllPages && /*#__PURE__*/jsxRuntime.jsx(CircularProgress, {
15680
+ "aria-label": "Loading",
15681
+ size: 14,
15682
+ sx: {
15683
+ mr: 1
15684
+ }
15685
+ }), localization.selectAllOnAllPages]
15686
+ })]
15687
+ });
15688
+ }
15689
+ })
15690
+ });
15691
+ };
15692
+
15693
+ const MRT_ActionMenuItem = t0 => {
15694
+ const $ = compilerRuntime.c(20);
15695
+ let icon;
15696
+ let label;
15697
+ let onOpenSubMenu;
15698
+ let rest;
15699
+ let table;
15700
+ if ($[0] !== t0) {
15701
+ ({
15702
+ icon,
15703
+ label,
15704
+ onOpenSubMenu,
15705
+ table,
15706
+ ...rest
15707
+ } = t0);
15708
+ $[0] = t0;
15709
+ $[1] = icon;
15710
+ $[2] = label;
15711
+ $[3] = onOpenSubMenu;
15712
+ $[4] = rest;
15713
+ $[5] = table;
15714
+ } else {
15715
+ icon = $[1];
15716
+ label = $[2];
15717
+ onOpenSubMenu = $[3];
15718
+ rest = $[4];
15719
+ table = $[5];
15720
+ }
15250
15721
  const {
15251
15722
  options: t1
15252
15723
  } = table;
@@ -15337,7 +15808,7 @@ const MRT_ActionMenuItem = t0 => {
15337
15808
  };
15338
15809
 
15339
15810
  const MRT_ColumnActionMenu = t0 => {
15340
- const $ = compilerRuntime.c(73);
15811
+ const $ = compilerRuntime.c(81);
15341
15812
  let anchorEl;
15342
15813
  let header;
15343
15814
  let rest;
@@ -15373,6 +15844,8 @@ const MRT_ColumnActionMenu = t0 => {
15373
15844
  const {
15374
15845
  enableColumnPinning,
15375
15846
  enableColumnResizing,
15847
+ enableMultiRowSelection,
15848
+ enableSelectAll,
15376
15849
  enableGrouping,
15377
15850
  enableHiding,
15378
15851
  enableSorting,
@@ -15447,7 +15920,7 @@ const MRT_ColumnActionMenu = t0 => {
15447
15920
  let t7;
15448
15921
  if ($[15] !== column || $[16] !== setAnchorEl || $[17] !== setColumnResizing) {
15449
15922
  t7 = () => {
15450
- setColumnResizing(_temp3$2);
15923
+ setColumnResizing(_temp3$1);
15451
15924
  column.resetSize();
15452
15925
  setAnchorEl(null);
15453
15926
  };
@@ -15489,7 +15962,7 @@ const MRT_ColumnActionMenu = t0 => {
15489
15962
  if ($[25] !== column || $[26] !== setAnchorEl || $[27] !== setColumnOrder) {
15490
15963
  t10 = () => {
15491
15964
  column.toggleGrouping();
15492
- setColumnOrder(_temp4$1);
15965
+ setColumnOrder(_temp4);
15493
15966
  setAnchorEl(null);
15494
15967
  };
15495
15968
  $[25] = column;
@@ -15514,7 +15987,7 @@ const MRT_ColumnActionMenu = t0 => {
15514
15987
  }
15515
15988
  const handleShowAllColumns = t11;
15516
15989
  let t12;
15517
- if ($[32] !== ClearAllIcon || $[33] !== DynamicFeedIcon || $[34] !== PushPinIcon || $[35] !== RestartAltIcon || $[36] !== SortIcon || $[37] !== ViewColumnIcon || $[38] !== VisibilityOffIcon || $[39] !== anchorEl || $[40] !== column || $[41] !== columnDef || $[42] !== columnSizing || $[43] !== columnVisibility || $[44] !== density || $[45] !== enableColumnPinning || $[46] !== enableColumnResizing || $[47] !== enableGrouping || $[48] !== enableHiding || $[49] !== enableSorting || $[50] !== enableSortingRemoval || $[51] !== handleClearSort || $[52] !== handleGroupByColumn || $[53] !== handleHideColumn || $[54] !== handlePinColumn || $[55] !== handleResetColumnSize || $[56] !== handleShowAllColumns || $[57] !== handleSortAsc || $[58] !== handleSortDesc || $[59] !== localization || $[60] !== menuBackgroundColor || $[61] !== renderColumnActionsMenuItems || $[62] !== rest || $[63] !== setAnchorEl || $[64] !== table) {
15990
+ if ($[32] !== ClearAllIcon || $[33] !== DynamicFeedIcon || $[34] !== PushPinIcon || $[35] !== RestartAltIcon || $[36] !== SortIcon || $[37] !== ViewColumnIcon || $[38] !== VisibilityOffIcon || $[39] !== anchorEl || $[40] !== column || $[41] !== columnDef || $[42] !== columnSizing || $[43] !== columnVisibility || $[44] !== density || $[45] !== enableColumnPinning || $[46] !== enableColumnResizing || $[47] !== enableGrouping || $[48] !== enableHiding || $[49] !== enableMultiRowSelection || $[50] !== enableSelectAll || $[51] !== enableSorting || $[52] !== enableSortingRemoval || $[53] !== handleClearSort || $[54] !== handleGroupByColumn || $[55] !== handleHideColumn || $[56] !== handlePinColumn || $[57] !== handleResetColumnSize || $[58] !== handleShowAllColumns || $[59] !== handleSortAsc || $[60] !== handleSortDesc || $[61] !== localization || $[62] !== menuBackgroundColor || $[63] !== renderColumnActionsMenuItems || $[64] !== rest || $[65] !== setAnchorEl || $[66] !== table) {
15518
15991
  const internalColumnMenuItems = [...(enableSorting && column.getCanSort() ? [enableSortingRemoval !== false && /*#__PURE__*/jsxRuntime.jsx(MRT_ActionMenuItem, {
15519
15992
  disabled: column.getIsSorted() === false,
15520
15993
  icon: /*#__PURE__*/jsxRuntime.jsx(ClearAllIcon, {}),
@@ -15592,43 +16065,58 @@ const MRT_ColumnActionMenu = t0 => {
15592
16065
  }, 12)] : [])].filter(Boolean);
15593
16066
  const t13 = density === "compact";
15594
16067
  let t14;
15595
- if ($[66] !== menuBackgroundColor) {
16068
+ if ($[68] !== menuBackgroundColor) {
15596
16069
  t14 = {
15597
16070
  backgroundColor: menuBackgroundColor
15598
16071
  };
15599
- $[66] = menuBackgroundColor;
15600
- $[67] = t14;
16072
+ $[68] = menuBackgroundColor;
16073
+ $[69] = t14;
15601
16074
  } else {
15602
- t14 = $[67];
16075
+ t14 = $[69];
15603
16076
  }
15604
16077
  let t15;
15605
- if ($[68] !== t13 || $[69] !== t14) {
16078
+ if ($[70] !== t13 || $[71] !== t14) {
15606
16079
  t15 = {
15607
16080
  dense: t13,
15608
16081
  sx: t14
15609
16082
  };
15610
- $[68] = t13;
15611
- $[69] = t14;
15612
- $[70] = t15;
16083
+ $[70] = t13;
16084
+ $[71] = t14;
16085
+ $[72] = t15;
15613
16086
  } else {
15614
- t15 = $[70];
16087
+ t15 = $[72];
15615
16088
  }
15616
16089
  let t16;
15617
- if ($[71] !== setAnchorEl) {
16090
+ if ($[73] !== setAnchorEl) {
15618
16091
  t16 = () => setAnchorEl(null);
15619
- $[71] = setAnchorEl;
15620
- $[72] = t16;
16092
+ $[73] = setAnchorEl;
16093
+ $[74] = t16;
15621
16094
  } else {
15622
- t16 = $[72];
16095
+ t16 = $[74];
15623
16096
  }
15624
- t12 = /*#__PURE__*/jsxRuntime.jsx(Menu, {
16097
+ let t17;
16098
+ if ($[75] !== column.id || $[76] !== enableMultiRowSelection || $[77] !== enableSelectAll || $[78] !== setAnchorEl || $[79] !== table) {
16099
+ t17 = column.id === CHECKBOX_DISPLAY_COLUMN_ID && enableSelectAll && enableMultiRowSelection && /*#__PURE__*/jsxRuntime.jsx(MRT_SelectAllMenuItems, {
16100
+ closeMenu: () => setAnchorEl(null),
16101
+ table: table
16102
+ });
16103
+ $[75] = column.id;
16104
+ $[76] = enableMultiRowSelection;
16105
+ $[77] = enableSelectAll;
16106
+ $[78] = setAnchorEl;
16107
+ $[79] = table;
16108
+ $[80] = t17;
16109
+ } else {
16110
+ t17 = $[80];
16111
+ }
16112
+ t12 = /*#__PURE__*/jsxRuntime.jsxs(Menu, {
15625
16113
  MenuListProps: t15,
15626
16114
  anchorEl: anchorEl,
15627
16115
  disableScrollLock: true,
15628
16116
  onClose: t16,
15629
16117
  open: !!anchorEl,
15630
16118
  ...rest,
15631
- children: columnDef.renderColumnActionsMenuItems?.({
16119
+ children: [t17, column.id === CHECKBOX_DISPLAY_COLUMN_ID && enableSelectAll && enableMultiRowSelection && internalColumnMenuItems.length > 0 && /*#__PURE__*/jsxRuntime.jsx(Divider, {}), columnDef.renderColumnActionsMenuItems?.({
15632
16120
  closeMenu: () => setAnchorEl(null),
15633
16121
  column,
15634
16122
  internalColumnMenuItems,
@@ -15638,7 +16126,7 @@ const MRT_ColumnActionMenu = t0 => {
15638
16126
  column,
15639
16127
  internalColumnMenuItems,
15640
16128
  table
15641
- }) ?? internalColumnMenuItems
16129
+ }) ?? internalColumnMenuItems]
15642
16130
  });
15643
16131
  $[32] = ClearAllIcon;
15644
16132
  $[33] = DynamicFeedIcon;
@@ -15657,25 +16145,27 @@ const MRT_ColumnActionMenu = t0 => {
15657
16145
  $[46] = enableColumnResizing;
15658
16146
  $[47] = enableGrouping;
15659
16147
  $[48] = enableHiding;
15660
- $[49] = enableSorting;
15661
- $[50] = enableSortingRemoval;
15662
- $[51] = handleClearSort;
15663
- $[52] = handleGroupByColumn;
15664
- $[53] = handleHideColumn;
15665
- $[54] = handlePinColumn;
15666
- $[55] = handleResetColumnSize;
15667
- $[56] = handleShowAllColumns;
15668
- $[57] = handleSortAsc;
15669
- $[58] = handleSortDesc;
15670
- $[59] = localization;
15671
- $[60] = menuBackgroundColor;
15672
- $[61] = renderColumnActionsMenuItems;
15673
- $[62] = rest;
15674
- $[63] = setAnchorEl;
15675
- $[64] = table;
15676
- $[65] = t12;
15677
- } else {
15678
- t12 = $[65];
16148
+ $[49] = enableMultiRowSelection;
16149
+ $[50] = enableSelectAll;
16150
+ $[51] = enableSorting;
16151
+ $[52] = enableSortingRemoval;
16152
+ $[53] = handleClearSort;
16153
+ $[54] = handleGroupByColumn;
16154
+ $[55] = handleHideColumn;
16155
+ $[56] = handlePinColumn;
16156
+ $[57] = handleResetColumnSize;
16157
+ $[58] = handleShowAllColumns;
16158
+ $[59] = handleSortAsc;
16159
+ $[60] = handleSortDesc;
16160
+ $[61] = localization;
16161
+ $[62] = menuBackgroundColor;
16162
+ $[63] = renderColumnActionsMenuItems;
16163
+ $[64] = rest;
16164
+ $[65] = setAnchorEl;
16165
+ $[66] = table;
16166
+ $[67] = t12;
16167
+ } else {
16168
+ t12 = $[67];
15679
16169
  }
15680
16170
  return t12;
15681
16171
  };
@@ -15690,13 +16180,13 @@ function _temp$8(state) {
15690
16180
  function _temp2$5(state_0) {
15691
16181
  return state_0.density;
15692
16182
  }
15693
- function _temp3$2(old) {
16183
+ function _temp3$1(old) {
15694
16184
  return {
15695
16185
  ...old,
15696
16186
  isResizingColumn: false
15697
16187
  };
15698
16188
  }
15699
- function _temp4$1(old_0) {
16189
+ function _temp4(old_0) {
15700
16190
  return ["mrt-row-expand", ...old_0];
15701
16191
  }
15702
16192
  function _temp5(col) {
@@ -16195,34 +16685,6 @@ const MRT_TableHeadCellGrabHandle = t0 => {
16195
16685
  return t8;
16196
16686
  };
16197
16687
 
16198
- // `el` normally has an explicit width/min-width/flex-basis (driven by the
16199
- // column's size CSS var), so nothing overflows and `scrollWidth` just reports
16200
- // that forced size back — and `min-width` alone would otherwise stop it from
16201
- // ever shrinking below the current (large) column size. Temporarily switching
16202
- // to `max-content` with min-width/grow/shrink zeroed out lets the browser lay
16203
- // it out at its natural content size instead — then the inline style is
16204
- // restored before this task yields, so there's no visible flash.
16205
- const measureIntrinsicWidth = el => {
16206
- const {
16207
- width,
16208
- minWidth,
16209
- flexBasis,
16210
- flexGrow,
16211
- flexShrink
16212
- } = el.style;
16213
- el.style.width = 'max-content';
16214
- el.style.minWidth = '0';
16215
- el.style.flexBasis = 'auto';
16216
- el.style.flexGrow = '0';
16217
- el.style.flexShrink = '0';
16218
- const measured = Math.ceil(el.getBoundingClientRect().width);
16219
- el.style.width = width;
16220
- el.style.minWidth = minWidth;
16221
- el.style.flexBasis = flexBasis;
16222
- el.style.flexGrow = flexGrow;
16223
- el.style.flexShrink = flexShrink;
16224
- return measured;
16225
- };
16226
16688
  const MRT_TableHeadCellResizeHandle = ({
16227
16689
  header,
16228
16690
  table,
@@ -16233,6 +16695,7 @@ const MRT_TableHeadCellResizeHandle = ({
16233
16695
  columnResizeDirection
16234
16696
  },
16235
16697
  refs: {
16698
+ autoSizedColumnWidthsRef,
16236
16699
  isResizingRef,
16237
16700
  resizeIndicatorRef,
16238
16701
  tableContainerRef,
@@ -16255,10 +16718,17 @@ const MRT_TableHeadCellResizeHandle = ({
16255
16718
  const tableEl = tableRef.current;
16256
16719
  const containerEl = tableContainerRef.current;
16257
16720
  const indicatorEl = resizeIndicatorRef.current;
16258
- const startSize = column.getSize();
16721
+ const startSize = tableHeadCellRefs.current?.[column.id]?.getBoundingClientRect().width || column.getSize();
16722
+ // Freeze flex growth while CSS variables drive the drag without renders.
16723
+ const growVar = `--col-${parseCSSVarId(column.id)}-grow`;
16724
+ tableEl?.style.setProperty(growVar, '0');
16725
+ tableEl?.style.setProperty(`--header-${parseCSSVarId(header.id)}-size`, `${startSize}`);
16726
+ tableEl?.style.setProperty(`--col-${parseCSSVarId(column.id)}-size`, `${startSize}`);
16259
16727
  const dir = columnResizeDirection === 'rtl' ? -1 : 1;
16260
- const minSize = column.columnDef.minSize ?? 40;
16261
- const maxSize = column.columnDef.maxSize ?? 1000;
16728
+ const {
16729
+ minSize,
16730
+ maxSize
16731
+ } = getColumnSizeBounds(column.columnDef);
16262
16732
  let size = startSize;
16263
16733
  // The "effective" cursor position used to compute size. Normally this just
16264
16734
  // mirrors the real cursor 1:1, but while pinned at the window edge (see
@@ -16369,6 +16839,7 @@ const MRT_TableHeadCellResizeHandle = ({
16369
16839
  document.body.style.cursor = '';
16370
16840
  document.body.style.userSelect = '';
16371
16841
  if (indicatorEl) indicatorEl.style.display = 'none';
16842
+ delete autoSizedColumnWidthsRef.current[column.id];
16372
16843
  setColumnSizing(old => ({
16373
16844
  ...old,
16374
16845
  [column.id]: size
@@ -16380,7 +16851,7 @@ const MRT_TableHeadCellResizeHandle = ({
16380
16851
  passive: false
16381
16852
  });
16382
16853
  document.addEventListener('touchend', handleEnd);
16383
- }, [column, columnResizeDirection, header.id, isResizingRef, resizeIndicatorRef, setColumnSizing, tableContainerRef, tableHeadCellRefs, tableRef]);
16854
+ }, [autoSizedColumnWidthsRef, column, columnResizeDirection, header.id, isResizingRef, resizeIndicatorRef, setColumnSizing, tableContainerRef, tableHeadCellRefs, tableRef]);
16384
16855
  return /*#__PURE__*/jsxRuntime.jsx(Box, {
16385
16856
  className: "Mui-TableHeadCell-ResizeHandle-Wrapper",
16386
16857
  onDoubleClick: () => {
@@ -16388,18 +16859,18 @@ const MRT_TableHeadCellResizeHandle = ({
16388
16859
  ...old_0,
16389
16860
  isResizingColumn: false
16390
16861
  }));
16391
- const minSize_0 = column.columnDef.minSize ?? 40;
16392
- const maxSize_0 = column.columnDef.maxSize ?? 1000;
16393
- // Only the currently rendered (visible, due to row virtualization) body
16394
- // cells are measured — a full-dataset autosize would require rendering
16395
- // every row off-screen, which defeats the point of virtualization.
16396
- const headCellEl = tableHeadCellRefs.current?.[column.id];
16397
- let contentWidth = headCellEl ? measureIntrinsicWidth(headCellEl) : 0;
16398
- const bodyCells = tableRef.current?.querySelectorAll(`[data-column-id="${CSS.escape(column.id)}"]`);
16399
- bodyCells?.forEach(cellEl_0 => {
16400
- contentWidth = Math.max(contentWidth, measureIntrinsicWidth(cellEl_0));
16862
+ const bodyCellEls = tableRef.current?.querySelectorAll(`[data-column-id="${CSS.escape(column.id)}"]`);
16863
+ // Content-only, like the initial autosize: with no rendered body
16864
+ // cells there is nothing to fit, so the current width is kept.
16865
+ if (!bodyCellEls?.length) return;
16866
+ // Same measurement MRT_AutoSizeColumnsEffect uses for the initial
16867
+ // auto-size — double-click always re-runs it fresh, regardless of
16868
+ // whether this column has an explicit `size` or was already resized.
16869
+ const newSize = computeAutoSizedColumnWidth({
16870
+ bodyCellEls,
16871
+ ...getColumnSizeBounds(column.columnDef)
16401
16872
  });
16402
- const newSize = Math.min(Math.max(contentWidth, minSize_0), maxSize_0);
16873
+ delete autoSizedColumnWidthsRef.current[column.id];
16403
16874
  setColumnSizing(old_1 => ({
16404
16875
  ...old_1,
16405
16876
  [column.id]: newSize
@@ -16608,6 +17079,7 @@ const MRT_TableHeadCell = ({
16608
17079
  const {
16609
17080
  columnDefType
16610
17081
  } = columnDef;
17082
+ const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
16611
17083
  const {
16612
17084
  columnResizing,
16613
17085
  draggingColumn,
@@ -16771,8 +17243,12 @@ const MRT_TableHeadCell = ({
16771
17243
  header: header,
16772
17244
  table: table,
16773
17245
  sx: {
16774
- // Show sort label when the cell is hovered or the column is actively sorted
16775
- visibility: isColumnCellHovered || column.getIsSorted() ? 'visible' : 'hidden'
17246
+ // Show sort label when the cell is hovered or the column is actively sorted.
17247
+ // The label's own `flex: '0 0'`/`width: '3ch'` defaults would otherwise
17248
+ // permanently reserve that space even while hidden — collapsing width to 0
17249
+ // here gives the header text that room while the icon isn't shown.
17250
+ visibility: isColumnCellHovered || column.getIsSorted() ? 'visible' : 'hidden',
17251
+ width: isColumnCellHovered || column.getIsSorted() ? '3ch' : 0
16776
17252
  }
16777
17253
  })]
16778
17254
  }), columnDefType !== 'group' && /*#__PURE__*/jsxRuntime.jsxs(Box, {
@@ -16783,9 +17259,11 @@ const MRT_TableHeadCell = ({
16783
17259
  flexDirection: 'row',
16784
17260
  alignItems: 'center',
16785
17261
  gap: '0.5rem',
16786
- width: isColumnCellHovered ? 'auto' : 0,
17262
+ // Keep the checkbox menu in one position when hover ends.
17263
+ width: isCheckboxColumn || isColumnCellHovered ? 'auto' : 0,
17264
+ flexShrink: isCheckboxColumn ? 0 : undefined,
16787
17265
  visibility: isColumnCellHovered ? 'visible' : 'hidden',
16788
- px: isColumnCellHovered ? '0.2rem' : 0
17266
+ px: isCheckboxColumn || isColumnCellHovered ? '0.2rem' : 0
16789
17267
  },
16790
17268
  children: [showColumnActions && /*#__PURE__*/jsxRuntime.jsx(MRT_TableHeadCellColumnActionsButton, {
16791
17269
  header: header,
@@ -17062,7 +17540,7 @@ const MRT_Table = ({
17062
17540
  // changes — this is the reactive boundary that makes that happen instead of
17063
17541
  // relying on a root cascade re-render.
17064
17542
  reactStore.useSelector(table.atoms.columnOrder);
17065
- reactStore.useSelector(table.atoms.columnPinning);
17543
+ const columnPinning = reactStore.useSelector(table.atoms.columnPinning);
17066
17544
  const density = reactStore.useSelector(table.store, state => state.density);
17067
17545
  const tableProps = {
17068
17546
  ...parseFromValuesOrFunc(muiTableProps, {
@@ -17084,38 +17562,36 @@ const MRT_Table = ({
17084
17562
  for (let i = 0; i < headers.length; i++) {
17085
17563
  const header = headers[i];
17086
17564
  const colSize = header.getSize();
17565
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-grow`] = getColumnGrowWeight(header.column, table);
17087
17566
  colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
17088
17567
  colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
17089
17568
  }
17090
17569
  return colSizes;
17091
- }, [columns, columnVisibility]);
17570
+ }, [columns, columnVisibility, columnPinning]);
17092
17571
 
17093
17572
  // Keeps the CSS size vars in sync with columnSizing after mount, without
17094
17573
  // subscribing this component to it (see comment above columnVisibility).
17095
17574
  react.useEffect(() => {
17096
- const subscription = table.atoms.columnSizing.subscribe(() => {
17575
+ const syncColumnSizing = () => {
17097
17576
  const node = tableRef.current;
17098
17577
  if (!node) return;
17099
17578
  const headers_0 = getFlatHeaders();
17100
17579
  for (let i_0 = 0; i_0 < headers_0.length; i_0++) {
17101
17580
  const header_0 = headers_0[i_0];
17102
17581
  const colSize_0 = header_0.getSize();
17582
+ node.style.setProperty(`--col-${parseCSSVarId(header_0.column.id)}-grow`, `${getColumnGrowWeight(header_0.column, table)}`);
17103
17583
  node.style.setProperty(`--header-${parseCSSVarId(header_0.id)}-size`, `${colSize_0}`);
17104
17584
  node.style.setProperty(`--col-${parseCSSVarId(header_0.column.id)}-size`, `${colSize_0}`);
17105
17585
  }
17106
- });
17586
+ };
17587
+ syncColumnSizing();
17588
+ const subscription = table.atoms.columnSizing.subscribe(syncColumnSizing);
17107
17589
  return () => subscription.unsubscribe();
17108
- }, [table]);
17590
+ }, [table, columns, columnVisibility, columnPinning]);
17109
17591
 
17110
17592
  // Padding values keyed off density, read by cell/header/footer sx so density toggles
17111
17593
  // reuse existing emotion classes instead of generating new ones per cell.
17112
- const densityVars = react.useMemo(() => ({
17113
- '--mrt-cell-p': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '1rem' : '1.5rem',
17114
- '--mrt-display-cell-p': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '0.5rem 0.75rem' : '1rem 1.25rem',
17115
- '--mrt-head-display-cell-p': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '0.75rem' : '1rem 1.25rem',
17116
- '--mrt-head-cell-pb': density === 'compact' ? '0.1rem' : '0.6rem',
17117
- '--mrt-head-cell-pt': density === 'compact' ? '0.1rem' : density === 'comfortable' ? '.75rem' : '1.25rem'
17118
- }), [density]);
17594
+ const densityVars = react.useMemo(() => getDensityStyles(density), [density]);
17119
17595
  const columnVirtualizer = useMRT_ColumnVirtualizer(table);
17120
17596
  const commonTableGroupProps = {
17121
17597
  columnVirtualizer,
@@ -17490,6 +17966,8 @@ const MRT_TableContainer = ({
17490
17966
  table: table
17491
17967
  }), /*#__PURE__*/jsxRuntime.jsx(MRT_Table, {
17492
17968
  table: table
17969
+ }), /*#__PURE__*/jsxRuntime.jsx(MRT_AutoSizeColumnsEffect, {
17970
+ table: table
17493
17971
  }), newEntryModal.open && /*#__PURE__*/jsxRuntime.jsx(react.Suspense, {
17494
17972
  fallback: null,
17495
17973
  children: /*#__PURE__*/jsxRuntime.jsx(MRT_NewEntryModal$2, {
@@ -18152,6 +18630,7 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
18152
18630
 
18153
18631
  const MaterialReactServerTableInstanceComponent = ({
18154
18632
  config,
18633
+ paginationMode = 'pages',
18155
18634
  loadData,
18156
18635
  saveState,
18157
18636
  getAllSelectableRowIds,
@@ -18173,11 +18652,9 @@ const MaterialReactServerTableInstanceComponent = ({
18173
18652
  }, ref) => {
18174
18653
  const [pageCount, setPageCount] = react.useState(undefined);
18175
18654
  const [rowCount, setRowCount] = react.useState(0);
18176
- const [isLoading, setIsLoading] = react.useState(false);
18177
- // Skeletons only until the first data arrives. On later refetches (filter, sort, paging)
18178
- // the current rows stay visible with a progress bar - swapping every cell to a Skeleton
18179
- // and back remounts the whole table body twice per refetch.
18655
+ const [isLoading, setIsLoading] = react.useState(true);
18180
18656
  const [hasLoadedOnce, setHasLoadedOnce] = react.useState(false);
18657
+ const infinite = paginationMode === 'infinite';
18181
18658
 
18182
18659
  // Filter availableExports by exportPermissions if provided.
18183
18660
  // exportPermissions maps export key → required permission strings.
@@ -18204,6 +18681,11 @@ const MaterialReactServerTableInstanceComponent = ({
18204
18681
  } = useServerTableState({
18205
18682
  initialState: {
18206
18683
  ...config.initialState,
18684
+ density: tableOptionsOverrides.initialState?.density ?? config.initialState?.density ?? 'compact',
18685
+ pagination: {
18686
+ pageIndex: infinite ? 0 : config.initialState?.pagination?.pageIndex ?? 0,
18687
+ pageSize: config.initialState?.pagination?.pageSize ?? 10
18688
+ },
18207
18689
  activeExports: buildInitialExportState(allowedExports, config.initialState?.activeExports)
18208
18690
  },
18209
18691
  saveState
@@ -18224,6 +18706,7 @@ const MaterialReactServerTableInstanceComponent = ({
18224
18706
  manualFiltering: true,
18225
18707
  manualPagination: true,
18226
18708
  manualSorting: true,
18709
+ enableRowVirtualization: infinite,
18227
18710
  enableRowPinning: false,
18228
18711
  getRowId: originalRow => originalRow.id,
18229
18712
  state: {
@@ -18251,7 +18734,9 @@ const MaterialReactServerTableInstanceComponent = ({
18251
18734
  rowsPerPageOptions: config.rowsPerPageOptions
18252
18735
  },
18253
18736
  ...tableOptionsOverrides,
18254
- ...handlers
18737
+ ...handlers,
18738
+ enablePagination: infinite ? false : tableOptionsOverrides.enablePagination ?? true,
18739
+ positionProgressBars: tableOptionsOverrides.positionProgressBars ?? (infinite ? 'bottom' : 'header')
18255
18740
  });
18256
18741
 
18257
18742
  // Lets any code that already has `table` (row actions, deleteRowsFn/editRowFn,
@@ -18289,41 +18774,40 @@ const MaterialReactServerTableInstanceComponent = ({
18289
18774
  setRowCount(prev_0 => prev_0 + insertedCount);
18290
18775
  }
18291
18776
  };
18292
- const fetchData = react.useCallback(async tableInstance => {
18293
- setIsLoading(true);
18294
- try {
18295
- const {
18296
- data: newData,
18297
- rowCount: newRowCount,
18298
- hasNextPage
18299
- } = await loadData(tableInstance.getState());
18300
- tableInstance.setRows(newData);
18301
- setHasLoadedOnce(true);
18302
- if (hasNextPage) {
18303
- setPageCount(-1);
18304
- setRowCount(0);
18305
- } else {
18306
- setPageCount(undefined);
18307
- setRowCount(newRowCount);
18308
- }
18309
- } finally {
18310
- setIsLoading(false);
18777
+ const loader = useMRT_ServerDataLoader({
18778
+ table,
18779
+ loadData,
18780
+ paginationMode,
18781
+ fetchTrigger,
18782
+ onLoadingChange: setIsLoading,
18783
+ onLoaded: () => setHasLoadedOnce(true),
18784
+ onResult: result => {
18785
+ setPageCount(result.hasNextPage ? -1 : undefined);
18786
+ setRowCount(result.hasNextPage && !result.rowCount ? 0 : result.rowCount);
18311
18787
  }
18312
- }, [loadData]);
18313
- react.useEffect(() => {
18314
- void fetchData(table);
18315
- // `table` is deliberately excluded from these deps. v9's useTable()
18316
- // memoizes its returned wrapper on the options object identity
18317
- // (see @tanstack/react-table's useTable.ts), and useMRT_TableInstance
18318
- // builds a fresh options object every render — so `table` is a new
18319
- // reference on every render regardless of whether anything relevant
18320
- // changed. Including it here would re-fire this data-fetching effect on
18321
- // every render (any unrelated state change anywhere in the tree),
18322
- // which triggers setRows/setIsLoading, causing another render, another
18323
- // new `table`, and an infinite fetch loop. The effect body always closes
18324
- // over the current render's `table`, so omitting it from deps only
18325
- // changes *when* the effect reruns, not what it reads when it does.
18326
- }, [fetchData, fetchTrigger.filterRules, fetchTrigger.pagination, fetchTrigger.sorting, fetchTrigger.columnVisibilityShowTrigger, fetchTrigger.refetchIndex]);
18788
+ });
18789
+ const userContainerProps = tableOptionsOverrides.muiTableContainerProps;
18790
+ table.options.muiTableContainerProps = props_0 => {
18791
+ const userProps = parseFromValuesOrFunc(userContainerProps, props_0);
18792
+ return {
18793
+ ...userProps,
18794
+ onScroll: event => {
18795
+ userProps?.onScroll?.(event);
18796
+ if (infinite) loader.checkScroll(event.currentTarget);
18797
+ }
18798
+ };
18799
+ };
18800
+ const customBottomActions = tableOptionsOverrides.renderBottomToolbarCustomActions;
18801
+ table.options.renderBottomToolbarCustomActions = props_1 => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
18802
+ children: [customBottomActions?.(props_1), loader.error && /*#__PURE__*/jsxRuntime.jsx(Alert, {
18803
+ severity: "error",
18804
+ action: /*#__PURE__*/jsxRuntime.jsx(Button, {
18805
+ onClick: () => void loader.retry(),
18806
+ children: table.options.localization.retryLoading ?? 'Retry'
18807
+ }),
18808
+ children: table.options.localization.errorMessage
18809
+ })]
18810
+ });
18327
18811
  react.useImperativeHandle(ref, () => ({
18328
18812
  refetch,
18329
18813
  table
@@ -18340,11 +18824,15 @@ const GHOST_COLUMNS = Array.from({
18340
18824
  id: `${i}`
18341
18825
  }));
18342
18826
  const HEADER_BAR_WIDTHS = [55, 40, 65, 45, 60, 35];
18343
- const MaterialReactServerTableSkeleton = () => {
18344
- const $ = compilerRuntime.c(6);
18345
- let t0;
18827
+ const MaterialReactServerTableSkeleton = t0 => {
18828
+ const $ = compilerRuntime.c(21);
18829
+ const {
18830
+ density: t1
18831
+ } = t0;
18832
+ const density = t1 === undefined ? "compact" : t1;
18833
+ let t2;
18346
18834
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
18347
- t0 = {
18835
+ t2 = {
18348
18836
  display: "flex",
18349
18837
  flexDirection: "column",
18350
18838
  height: "100%",
@@ -18352,13 +18840,13 @@ const MaterialReactServerTableSkeleton = () => {
18352
18840
  animation: mrtDelayedFadeIn
18353
18841
  }
18354
18842
  };
18355
- $[0] = t0;
18843
+ $[0] = t2;
18356
18844
  } else {
18357
- t0 = $[0];
18845
+ t2 = $[0];
18358
18846
  }
18359
- let t1;
18847
+ let t3;
18360
18848
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
18361
- t1 = /*#__PURE__*/jsxRuntime.jsxs(Box, {
18849
+ t3 = /*#__PURE__*/jsxRuntime.jsxs(Box, {
18362
18850
  sx: {
18363
18851
  alignItems: "center",
18364
18852
  display: "flex",
@@ -18386,15 +18874,15 @@ const MaterialReactServerTableSkeleton = () => {
18386
18874
  width: 135
18387
18875
  })]
18388
18876
  });
18389
- $[1] = t1;
18877
+ $[1] = t3;
18390
18878
  } else {
18391
- t1 = $[1];
18879
+ t3 = $[1];
18392
18880
  }
18393
- let t2;
18881
+ let t4;
18394
18882
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
18395
- t2 = /*#__PURE__*/jsxRuntime.jsxs(Box, {
18883
+ t4 = /*#__PURE__*/jsxRuntime.jsxs(Box, {
18396
18884
  sx: _temp$6,
18397
- children: [t1, /*#__PURE__*/jsxRuntime.jsx(Box, {
18885
+ children: [t3, /*#__PURE__*/jsxRuntime.jsx(Box, {
18398
18886
  sx: {
18399
18887
  alignItems: "center",
18400
18888
  display: "flex",
@@ -18408,91 +18896,179 @@ const MaterialReactServerTableSkeleton = () => {
18408
18896
  })
18409
18897
  })]
18410
18898
  });
18411
- $[2] = t2;
18899
+ $[2] = t4;
18412
18900
  } else {
18413
- t2 = $[2];
18901
+ t4 = $[2];
18414
18902
  }
18415
- let t3;
18903
+ let t5;
18416
18904
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
18417
- t3 = {
18905
+ t5 = {
18418
18906
  flex: 1,
18419
18907
  overflow: "hidden"
18420
18908
  };
18421
- $[3] = t3;
18909
+ $[3] = t5;
18422
18910
  } else {
18423
- t3 = $[3];
18911
+ t5 = $[3];
18424
18912
  }
18425
- let t4;
18426
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
18427
- t4 = /*#__PURE__*/jsxRuntime.jsx(Box, {
18428
- sx: t3,
18429
- children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
18430
- component: "table",
18431
- sx: _temp2$3,
18432
- children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
18433
- "aria-hidden": true,
18434
- children: /*#__PURE__*/jsxRuntime.jsx("tr", {
18435
- children: GHOST_COLUMNS.map(_temp3$1)
18436
- })
18437
- }), /*#__PURE__*/jsxRuntime.jsx("tbody", {
18438
- children: /*#__PURE__*/jsxRuntime.jsx(MRT_GhostRows, {
18439
- cells: GHOST_COLUMNS,
18440
- rowHeight: 37
18441
- })
18442
- })]
18443
- })
18913
+ let t6;
18914
+ if ($[4] !== density) {
18915
+ t6 = theme_0 => ({
18916
+ ...getDensityStyles(density),
18917
+ borderCollapse: "collapse",
18918
+ tableLayout: "fixed",
18919
+ width: "100%",
18920
+ "& th": {
18921
+ borderBottom: `1px solid ${theme_0.palette.divider}`,
18922
+ fontSize: 14,
18923
+ p: "var(--mrt-cell-p)",
18924
+ pt: "var(--mrt-head-cell-pt)",
18925
+ pb: "var(--mrt-head-cell-pb)",
18926
+ textAlign: "left"
18927
+ },
18928
+ "& th span": {
18929
+ backgroundColor: styles.alpha(theme_0.palette.text.primary, 0.16),
18930
+ borderRadius: 999,
18931
+ display: "block",
18932
+ height: 12
18933
+ }
18444
18934
  });
18445
- $[4] = t4;
18935
+ $[4] = density;
18936
+ $[5] = t6;
18446
18937
  } else {
18447
- t4 = $[4];
18938
+ t6 = $[5];
18448
18939
  }
18449
- let t5;
18450
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
18451
- t5 = /*#__PURE__*/jsxRuntime.jsxs(Paper, {
18452
- "data-testid": "server-table-skeleton",
18453
- sx: t0,
18454
- children: [t2, t4, /*#__PURE__*/jsxRuntime.jsx(Box, {
18455
- sx: _temp4,
18456
- children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
18940
+ let t7;
18941
+ if ($[6] !== density) {
18942
+ t7 = GHOST_COLUMNS.map((t8, i) => {
18943
+ const {
18944
+ id
18945
+ } = t8;
18946
+ return /*#__PURE__*/jsxRuntime.jsx("th", {
18947
+ children: /*#__PURE__*/jsxRuntime.jsx(Box, {
18457
18948
  sx: {
18458
18949
  alignItems: "center",
18459
18950
  display: "flex",
18460
- gap: "1rem"
18951
+ height: density === "compact" ? "1.75rem" : "1.5em"
18461
18952
  },
18462
- children: [/*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18463
- animation: "pulse",
18464
- height: 36,
18465
- variant: "rounded",
18466
- width: 136
18467
- }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18468
- animation: "pulse",
18469
- height: 31,
18470
- variant: "text",
18471
- width: 176
18472
- }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18473
- animation: "pulse",
18474
- height: 22,
18475
- variant: "text",
18476
- width: 70
18477
- }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18478
- animation: "pulse",
18479
- height: 24,
18480
- variant: "circular",
18481
- width: 24
18482
- }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18483
- animation: "pulse",
18484
- height: 24,
18485
- variant: "circular",
18486
- width: 24
18487
- })]
18953
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
18954
+ style: {
18955
+ width: `${HEADER_BAR_WIDTHS[i]}%`
18956
+ }
18957
+ })
18488
18958
  })
18489
- })]
18959
+ }, id);
18490
18960
  });
18491
- $[5] = t5;
18961
+ $[6] = density;
18962
+ $[7] = t7;
18492
18963
  } else {
18493
- t5 = $[5];
18964
+ t7 = $[7];
18494
18965
  }
18495
- return t5;
18966
+ let t8;
18967
+ if ($[8] !== t7) {
18968
+ t8 = /*#__PURE__*/jsxRuntime.jsx("thead", {
18969
+ "aria-hidden": true,
18970
+ children: /*#__PURE__*/jsxRuntime.jsx("tr", {
18971
+ children: t7
18972
+ })
18973
+ });
18974
+ $[8] = t7;
18975
+ $[9] = t8;
18976
+ } else {
18977
+ t8 = $[9];
18978
+ }
18979
+ let t9;
18980
+ if ($[10] !== density) {
18981
+ t9 = getDefaultRowHeight(density);
18982
+ $[10] = density;
18983
+ $[11] = t9;
18984
+ } else {
18985
+ t9 = $[11];
18986
+ }
18987
+ let t10;
18988
+ if ($[12] !== t9) {
18989
+ t10 = /*#__PURE__*/jsxRuntime.jsx("tbody", {
18990
+ children: /*#__PURE__*/jsxRuntime.jsx(MRT_GhostRows, {
18991
+ cells: GHOST_COLUMNS,
18992
+ rowHeight: t9
18993
+ })
18994
+ });
18995
+ $[12] = t9;
18996
+ $[13] = t10;
18997
+ } else {
18998
+ t10 = $[13];
18999
+ }
19000
+ let t11;
19001
+ if ($[14] !== t10 || $[15] !== t6 || $[16] !== t8) {
19002
+ t11 = /*#__PURE__*/jsxRuntime.jsx(Box, {
19003
+ sx: t5,
19004
+ children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
19005
+ component: "table",
19006
+ sx: t6,
19007
+ children: [t8, t10]
19008
+ })
19009
+ });
19010
+ $[14] = t10;
19011
+ $[15] = t6;
19012
+ $[16] = t8;
19013
+ $[17] = t11;
19014
+ } else {
19015
+ t11 = $[17];
19016
+ }
19017
+ let t12;
19018
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
19019
+ t12 = /*#__PURE__*/jsxRuntime.jsx(Box, {
19020
+ sx: _temp2$3,
19021
+ children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
19022
+ sx: {
19023
+ alignItems: "center",
19024
+ display: "flex",
19025
+ gap: "1rem"
19026
+ },
19027
+ children: [/*#__PURE__*/jsxRuntime.jsx(Skeleton, {
19028
+ animation: "pulse",
19029
+ height: 36,
19030
+ variant: "rounded",
19031
+ width: 136
19032
+ }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
19033
+ animation: "pulse",
19034
+ height: 31,
19035
+ variant: "text",
19036
+ width: 176
19037
+ }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
19038
+ animation: "pulse",
19039
+ height: 22,
19040
+ variant: "text",
19041
+ width: 70
19042
+ }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
19043
+ animation: "pulse",
19044
+ height: 24,
19045
+ variant: "circular",
19046
+ width: 24
19047
+ }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
19048
+ animation: "pulse",
19049
+ height: 24,
19050
+ variant: "circular",
19051
+ width: 24
19052
+ })]
19053
+ })
19054
+ });
19055
+ $[18] = t12;
19056
+ } else {
19057
+ t12 = $[18];
19058
+ }
19059
+ let t13;
19060
+ if ($[19] !== t11) {
19061
+ t13 = /*#__PURE__*/jsxRuntime.jsxs(Paper, {
19062
+ "data-testid": "server-table-skeleton",
19063
+ sx: t2,
19064
+ children: [t4, t11, t12]
19065
+ });
19066
+ $[19] = t11;
19067
+ $[20] = t13;
19068
+ } else {
19069
+ t13 = $[20];
19070
+ }
19071
+ return t13;
18496
19072
  };
18497
19073
  function _temp$6(theme) {
18498
19074
  return {
@@ -18505,38 +19081,7 @@ function _temp$6(theme) {
18505
19081
  paddingRight: "0.3rem"
18506
19082
  };
18507
19083
  }
18508
- function _temp2$3(theme_0) {
18509
- return {
18510
- borderCollapse: "collapse",
18511
- tableLayout: "fixed",
18512
- width: "100%",
18513
- "& th": {
18514
- borderBottom: `1px solid ${theme_0.palette.divider}`,
18515
- height: 48,
18516
- p: "0.5rem",
18517
- textAlign: "left"
18518
- },
18519
- "& th > span": {
18520
- backgroundColor: styles.alpha(theme_0.palette.text.primary, 0.16),
18521
- borderRadius: 999,
18522
- display: "block",
18523
- height: 12
18524
- }
18525
- };
18526
- }
18527
- function _temp3$1(t0, i) {
18528
- const {
18529
- id
18530
- } = t0;
18531
- return /*#__PURE__*/jsxRuntime.jsx("th", {
18532
- children: /*#__PURE__*/jsxRuntime.jsx("span", {
18533
- style: {
18534
- width: `${HEADER_BAR_WIDTHS[i]}%`
18535
- }
18536
- })
18537
- }, id);
18538
- }
18539
- function _temp4(theme_1) {
19084
+ function _temp2$3(theme_1) {
18540
19085
  return {
18541
19086
  alignItems: "center",
18542
19087
  borderTop: `1px solid ${theme_1.palette.divider}`,
@@ -18581,7 +19126,9 @@ const MaterialReactServerTableComponent = ({
18581
19126
  };
18582
19127
  }, [loadConfig]);
18583
19128
  if (configLoading) {
18584
- return /*#__PURE__*/jsxRuntime.jsx(MaterialReactServerTableSkeleton, {});
19129
+ return /*#__PURE__*/jsxRuntime.jsx(MaterialReactServerTableSkeleton, {
19130
+ density: instanceProps.state?.density ?? instanceProps.initialState?.density ?? 'compact'
19131
+ });
18585
19132
  }
18586
19133
  if (!config) {
18587
19134
  return /*#__PURE__*/jsxRuntime.jsx(MaterialReactServerTableError, {
@@ -20321,7 +20868,7 @@ exports.MRT_NewEntryModal = MRT_NewEntryModal;
20321
20868
  exports.MRT_PaginationBoundsEffect = MRT_PaginationBoundsEffect;
20322
20869
  exports.MRT_RowActionMenu = MRT_RowActionMenu;
20323
20870
  exports.MRT_RowPinButton = MRT_RowPinButton;
20324
- exports.MRT_SelectAllMenu = MRT_SelectAllMenu;
20871
+ exports.MRT_SelectAllMenuItems = MRT_SelectAllMenuItems;
20325
20872
  exports.MRT_SelectCheckbox = MRT_SelectCheckbox;
20326
20873
  exports.MRT_SelectionCountBadge = MRT_SelectionCountBadge;
20327
20874
  exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
@@ -20370,9 +20917,9 @@ exports.createRow = createRow;
20370
20917
  exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
20371
20918
  exports.flexRender = flexRender;
20372
20919
  exports.getAllLeafColumnDefs = getAllLeafColumnDefs;
20920
+ exports.getAutoSizeCandidateColumnIds = getAutoSizeCandidateColumnIds;
20373
20921
  exports.getColumnId = getColumnId;
20374
20922
  exports.getDefaultColumnOrderIds = getDefaultColumnOrderIds;
20375
- exports.getDefaultColumnPinningState = getDefaultColumnPinningState;
20376
20923
  exports.getIsAllPagesSelectionActive = getIsAllPagesSelectionActive;
20377
20924
  exports.getIsRowSelected = getIsRowSelected;
20378
20925
  exports.getLeadingDisplayColumnIds = getLeadingDisplayColumnIds;