@dooherceg/material-react-table 4.1.0 → 4.1.1

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
@@ -2490,7 +2490,7 @@ const MRT_ReorderRowCheckbox = t0 => {
2490
2490
  t1 = {
2491
2491
  color: _temp2$d,
2492
2492
  "&.Mui-checked": {
2493
- color: _temp3$5
2493
+ color: _temp3$6
2494
2494
  }
2495
2495
  };
2496
2496
  $[0] = t1;
@@ -2521,7 +2521,7 @@ function _temp$y(event) {
2521
2521
  function _temp2$d(theme) {
2522
2522
  return theme.palette.warning.main;
2523
2523
  }
2524
- function _temp3$5(theme_0) {
2524
+ function _temp3$6(theme_0) {
2525
2525
  return theme_0.palette.warning.main;
2526
2526
  }
2527
2527
 
@@ -6160,8 +6160,8 @@ const MRT_FilterRuleBooleanEditor = props => {
6160
6160
  t3 = /*#__PURE__*/jsxRuntime.jsx(MRT_SingleValueEditor, {
6161
6161
  ...props,
6162
6162
  options: t2,
6163
- transformValue: _temp3$4,
6164
- valueFormatter: _temp4$1
6163
+ transformValue: _temp3$5,
6164
+ valueFormatter: _temp4$2
6165
6165
  });
6166
6166
  $[7] = props;
6167
6167
  $[8] = t2;
@@ -6359,10 +6359,10 @@ function _temp$q(value) {
6359
6359
  function _temp2$9(value_0) {
6360
6360
  return value_0 === undefined || value_0 === null || value_0 === "" ? "" : String(value_0);
6361
6361
  }
6362
- function _temp3$4(value) {
6362
+ function _temp3$5(value) {
6363
6363
  return value === "true" ? true : value === "false" ? false : "";
6364
6364
  }
6365
- function _temp4$1(value_0) {
6365
+ function _temp4$2(value_0) {
6366
6366
  return value_0 === true ? "true" : value_0 === false ? "false" : "";
6367
6367
  }
6368
6368
  function _temp5$1(n) {
@@ -9915,7 +9915,7 @@ const MRT_AdvancedFiltersContent = t0 => {
9915
9915
  display: "flex",
9916
9916
  justifyContent: "center",
9917
9917
  sx: {
9918
- border: _temp3$3,
9918
+ border: _temp3$4,
9919
9919
  borderRadius: 2,
9920
9920
  flex: 1,
9921
9921
  minHeight: 140,
@@ -10122,7 +10122,7 @@ function _temp$n(current) {
10122
10122
  function _temp2$8(theme) {
10123
10123
  return theme.zIndex.drawer + 1;
10124
10124
  }
10125
- function _temp3$3(theme_0) {
10125
+ function _temp3$4(theme_0) {
10126
10126
  return `1px dashed ${theme_0.palette.divider}`;
10127
10127
  }
10128
10128
 
@@ -11631,7 +11631,7 @@ const MRT_QuickFilterItem = t0 => {
11631
11631
  top: 8,
11632
11632
  zIndex: 1,
11633
11633
  "&:hover": {
11634
- backgroundColor: _temp3$2
11634
+ backgroundColor: _temp3$3
11635
11635
  }
11636
11636
  },
11637
11637
  children: /*#__PURE__*/jsxRuntime.jsx(CloseIcon, {
@@ -11776,7 +11776,7 @@ function _temp$h(theme) {
11776
11776
  function _temp2$6(theme_0) {
11777
11777
  return theme_0.palette.background.paper;
11778
11778
  }
11779
- function _temp3$2(theme_1) {
11779
+ function _temp3$3(theme_1) {
11780
11780
  return theme_1.palette.error.dark;
11781
11781
  }
11782
11782
 
@@ -13662,9 +13662,6 @@ const MRT_CellActionMenu = ({
13662
13662
  });
13663
13663
  };
13664
13664
 
13665
- const PLACEHOLDER_ROW_COUNT = 8;
13666
- // bar length per cell (% of the cell), picked deterministically so the ghost
13667
- // rows look like varied content rather than a uniform grid
13668
13665
  const BAR_WIDTHS = [72, 48, 85, 60, 40, 66, 78, 54, 82, 45];
13669
13666
 
13670
13667
  // animates the row's own opacity around its fade-to-bottom level (--mrt-ghost-o)
@@ -13672,81 +13669,128 @@ const pulse = styles.keyframes`
13672
13669
  0%, 100% { opacity: var(--mrt-ghost-o); }
13673
13670
  50% { opacity: calc(var(--mrt-ghost-o) * 0.45); }
13674
13671
  `;
13675
- // skeletonMode: 'placeholder'. Ghost rows instead of a MUI Skeleton in every
13676
- // cell: plain <td><span> per visible column (no MRT cell logic, hooks or store
13677
- // subscriptions), sized with the same --col-* CSS vars as real cells, so the
13678
- // layout doesn't shift when data arrives. Styles live on the row's sx via
13679
- // descendant selectors (one emotion class shared by all rows), and only the
13680
- // rows' opacity animates.
13681
- const MRT_TableBodyLoadingPlaceholder = ({
13682
- columns,
13683
- density,
13684
- layoutMode
13685
- }) => {
13686
- const rowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
13687
- const isGridLayout = layoutMode?.startsWith('grid');
13688
- const cells = columns.map((column, columnIndex) => {
13689
- const sizeVar = `var(--col-${parseCSSVarId(column.id)}-size)`;
13690
- const {
13691
- columnDefType,
13692
- grow,
13693
- minSize
13694
- } = column.columnDef;
13695
- return {
13696
- columnIndex,
13697
- id: column.id,
13698
- isDisplay: columnDefType === 'display',
13699
- style: {
13700
- flex: layoutMode === 'grid' ? `${[0, false].includes(grow) ? 0 : sizeVar} 0 auto` : layoutMode === 'grid-no-grow' ? `${+(grow || 0)} 0 auto` : undefined,
13701
- minWidth: `max(calc(${sizeVar} * 1px), ${minSize ?? 30}px)`,
13702
- width: `calc(${sizeVar} * 1px)`
13703
- }
13704
- };
13705
- });
13706
- return Array.from({
13707
- length: PLACEHOLDER_ROW_COUNT
13708
- }, (_, rowIndex) => /*#__PURE__*/jsxRuntime.jsx(Box, {
13709
- "aria-hidden": true,
13710
- component: "tr",
13711
- style: {
13712
- '--mrt-ghost-o': 1 - rowIndex / PLACEHOLDER_ROW_COUNT * 0.85,
13713
- animationDelay: `${rowIndex * 90}ms`
13714
- },
13715
- sx: theme => ({
13716
- animation: `${pulse} 1.6s ease-in-out infinite`,
13672
+ // Pulsing loading rows shared by the body placeholder (skeletonMode: 'placeholder')
13673
+ // and the server table's config skeleton. Plain <td><span> per cell (no MRT cell
13674
+ // logic, hooks or store subscriptions); styles live on the row's sx via descendant
13675
+ // selectors (one emotion class shared by all rows), and only the rows' opacity animates.
13676
+ const MRT_GhostRows = ({
13677
+ cells,
13678
+ isGridLayout,
13679
+ rowCount = 8,
13680
+ rowHeight
13681
+ }) => Array.from({
13682
+ length: rowCount
13683
+ }, (_, rowIndex) => /*#__PURE__*/jsxRuntime.jsx(Box, {
13684
+ "aria-hidden": true,
13685
+ component: "tr",
13686
+ style: {
13687
+ '--mrt-ghost-o': 1 - rowIndex / rowCount * 0.85,
13688
+ animationDelay: `${rowIndex * 90}ms`
13689
+ },
13690
+ sx: theme => ({
13691
+ animation: `${pulse} 1.6s ease-in-out infinite`,
13692
+ display: isGridLayout ? 'flex' : undefined,
13693
+ height: rowHeight,
13694
+ opacity: 'var(--mrt-ghost-o)',
13695
+ width: '100%',
13696
+ '& > td': {
13697
+ alignItems: isGridLayout ? 'center' : undefined,
13698
+ borderBottom: `1px solid ${theme.palette.divider}`,
13699
+ boxSizing: 'border-box',
13717
13700
  display: isGridLayout ? 'flex' : undefined,
13718
- height: rowHeight,
13719
- opacity: 'var(--mrt-ghost-o)',
13720
- width: '100%',
13721
- '& > td': {
13722
- alignItems: isGridLayout ? 'center' : undefined,
13723
- borderBottom: `1px solid ${theme.palette.divider}`,
13724
- boxSizing: 'border-box',
13725
- display: isGridLayout ? 'flex' : undefined,
13726
- overflow: 'hidden',
13727
- p: 'var(--mrt-cell-p)'
13728
- },
13729
- '& > td > span': {
13730
- backgroundColor: styles.alpha(theme.palette.text.primary, 0.1),
13731
- borderRadius: 999,
13732
- display: 'block',
13733
- height: 10
13701
+ overflow: 'hidden',
13702
+ // fallback = compact padding, for use outside MRT_Table (server table skeleton)
13703
+ p: 'var(--mrt-cell-p, 0.5rem)'
13704
+ },
13705
+ '& > td > span': {
13706
+ backgroundColor: styles.alpha(theme.palette.text.primary, 0.1),
13707
+ borderRadius: 999,
13708
+ display: 'block',
13709
+ height: 10
13710
+ }
13711
+ }),
13712
+ children: cells.map(({
13713
+ id,
13714
+ isDisplay,
13715
+ style
13716
+ }, columnIndex) => /*#__PURE__*/jsxRuntime.jsx("td", {
13717
+ style: style,
13718
+ children: !isDisplay && /*#__PURE__*/jsxRuntime.jsx("span", {
13719
+ style: {
13720
+ width: `${BAR_WIDTHS[(columnIndex * 3 + rowIndex * 7) % BAR_WIDTHS.length]}%`
13734
13721
  }
13735
- }),
13736
- children: cells.map(({
13737
- columnIndex,
13738
- id,
13739
- isDisplay,
13740
- style
13741
- }) => /*#__PURE__*/jsxRuntime.jsx("td", {
13742
- style: style,
13743
- children: !isDisplay && /*#__PURE__*/jsxRuntime.jsx("span", {
13744
- style: {
13745
- width: `${BAR_WIDTHS[(columnIndex * 3 + rowIndex * 7) % BAR_WIDTHS.length]}%`
13746
- }
13747
- })
13748
- }, id))
13749
- }, rowIndex));
13722
+ })
13723
+ }, id))
13724
+ }, rowIndex));
13725
+
13726
+ // skeletonMode: 'placeholder'. Ghost rows instead of a MUI Skeleton in every
13727
+ // cell, sized with the same --col-* CSS vars as real cells, so the layout
13728
+ // doesn't shift when data arrives.
13729
+ const MRT_TableBodyLoadingPlaceholder = t0 => {
13730
+ const $ = compilerRuntime.c(11);
13731
+ const {
13732
+ columns,
13733
+ density,
13734
+ layoutMode
13735
+ } = t0;
13736
+ const rowHeight = density === "compact" ? 37 : density === "comfortable" ? 53 : 69;
13737
+ let t1;
13738
+ if ($[0] !== columns || $[1] !== layoutMode) {
13739
+ let t2;
13740
+ if ($[3] !== layoutMode) {
13741
+ t2 = column => {
13742
+ const sizeVar = `var(--col-${parseCSSVarId(column.id)}-size)`;
13743
+ const {
13744
+ columnDefType,
13745
+ grow,
13746
+ minSize
13747
+ } = column.columnDef;
13748
+ return {
13749
+ id: column.id,
13750
+ isDisplay: columnDefType === "display",
13751
+ style: {
13752
+ flex: layoutMode === "grid" ? `${[0, false].includes(grow) ? 0 : sizeVar} 0 auto` : layoutMode === "grid-no-grow" ? `${+(grow || 0)} 0 auto` : undefined,
13753
+ minWidth: `max(calc(${sizeVar} * 1px), ${minSize ?? 30}px)`,
13754
+ width: `calc(${sizeVar} * 1px)`
13755
+ }
13756
+ };
13757
+ };
13758
+ $[3] = layoutMode;
13759
+ $[4] = t2;
13760
+ } else {
13761
+ t2 = $[4];
13762
+ }
13763
+ t1 = columns.map(t2);
13764
+ $[0] = columns;
13765
+ $[1] = layoutMode;
13766
+ $[2] = t1;
13767
+ } else {
13768
+ t1 = $[2];
13769
+ }
13770
+ const cells = t1;
13771
+ let t2;
13772
+ if ($[5] !== layoutMode) {
13773
+ t2 = layoutMode?.startsWith("grid");
13774
+ $[5] = layoutMode;
13775
+ $[6] = t2;
13776
+ } else {
13777
+ t2 = $[6];
13778
+ }
13779
+ let t3;
13780
+ if ($[7] !== cells || $[8] !== rowHeight || $[9] !== t2) {
13781
+ t3 = /*#__PURE__*/jsxRuntime.jsx(MRT_GhostRows, {
13782
+ cells: cells,
13783
+ isGridLayout: t2,
13784
+ rowHeight: rowHeight
13785
+ });
13786
+ $[7] = cells;
13787
+ $[8] = rowHeight;
13788
+ $[9] = t2;
13789
+ $[10] = t3;
13790
+ } else {
13791
+ t3 = $[10];
13792
+ }
13793
+ return t3;
13750
13794
  };
13751
13795
 
13752
13796
  const MRT_DisplayColumnCellRenderer = t0 => {
@@ -15330,7 +15374,7 @@ const MRT_ColumnActionMenu = t0 => {
15330
15374
  let t7;
15331
15375
  if ($[15] !== column || $[16] !== setAnchorEl || $[17] !== setColumnResizing) {
15332
15376
  t7 = () => {
15333
- setColumnResizing(_temp3$1);
15377
+ setColumnResizing(_temp3$2);
15334
15378
  column.resetSize();
15335
15379
  setAnchorEl(null);
15336
15380
  };
@@ -15372,7 +15416,7 @@ const MRT_ColumnActionMenu = t0 => {
15372
15416
  if ($[25] !== column || $[26] !== setAnchorEl || $[27] !== setColumnOrder) {
15373
15417
  t10 = () => {
15374
15418
  column.toggleGrouping();
15375
- setColumnOrder(_temp4);
15419
+ setColumnOrder(_temp4$1);
15376
15420
  setAnchorEl(null);
15377
15421
  };
15378
15422
  $[25] = column;
@@ -15573,13 +15617,13 @@ function _temp$8(state) {
15573
15617
  function _temp2$5(state_0) {
15574
15618
  return state_0.density;
15575
15619
  }
15576
- function _temp3$1(old) {
15620
+ function _temp3$2(old) {
15577
15621
  return {
15578
15622
  ...old,
15579
15623
  isResizingColumn: false
15580
15624
  };
15581
15625
  }
15582
- function _temp4(old_0) {
15626
+ function _temp4$1(old_0) {
15583
15627
  return ["mrt-row-expand", ...old_0];
15584
15628
  }
15585
15629
  function _temp5(col) {
@@ -18099,6 +18143,12 @@ const MaterialReactServerTableInstanceComponent = ({
18099
18143
  };
18100
18144
  const MaterialReactServerTableInstance = /*#__PURE__*/react.forwardRef(MaterialReactServerTableInstanceComponent);
18101
18145
 
18146
+ const GHOST_COLUMNS = Array.from({
18147
+ length: 6
18148
+ }, (_, i) => ({
18149
+ id: `${i}`
18150
+ }));
18151
+ const HEADER_BAR_WIDTHS = [55, 40, 65, 45, 60, 35];
18102
18152
  const MaterialReactServerTableSkeleton = () => {
18103
18153
  const $ = compilerRuntime.c(6);
18104
18154
  let t0;
@@ -18106,7 +18156,10 @@ const MaterialReactServerTableSkeleton = () => {
18106
18156
  t0 = {
18107
18157
  display: "flex",
18108
18158
  flexDirection: "column",
18109
- height: "100%"
18159
+ height: "100%",
18160
+ "& > *": {
18161
+ animation: mrtDelayedFadeIn
18162
+ }
18110
18163
  };
18111
18164
  $[0] = t0;
18112
18165
  } else {
@@ -18121,22 +18174,22 @@ const MaterialReactServerTableSkeleton = () => {
18121
18174
  gap: "0.5rem"
18122
18175
  },
18123
18176
  children: [/*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18124
- animation: "wave",
18177
+ animation: "pulse",
18125
18178
  height: 30,
18126
18179
  variant: "rounded",
18127
18180
  width: 73
18128
18181
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18129
- animation: "wave",
18182
+ animation: "pulse",
18130
18183
  height: 30,
18131
18184
  variant: "rounded",
18132
18185
  width: 80
18133
18186
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18134
- animation: "wave",
18187
+ animation: "pulse",
18135
18188
  height: 30,
18136
18189
  variant: "rounded",
18137
18190
  width: 67
18138
18191
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18139
- animation: "wave",
18192
+ animation: "pulse",
18140
18193
  height: 30,
18141
18194
  variant: "rounded",
18142
18195
  width: 135
@@ -18157,7 +18210,7 @@ const MaterialReactServerTableSkeleton = () => {
18157
18210
  gap: "0.5rem"
18158
18211
  },
18159
18212
  children: /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18160
- animation: "wave",
18213
+ animation: "pulse",
18161
18214
  height: 24,
18162
18215
  variant: "circular",
18163
18216
  width: 24
@@ -18171,9 +18224,8 @@ const MaterialReactServerTableSkeleton = () => {
18171
18224
  let t3;
18172
18225
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
18173
18226
  t3 = {
18174
- display: "flex",
18175
18227
  flex: 1,
18176
- padding: "1.3rem"
18228
+ overflow: "hidden"
18177
18229
  };
18178
18230
  $[3] = t3;
18179
18231
  } else {
@@ -18183,13 +18235,20 @@ const MaterialReactServerTableSkeleton = () => {
18183
18235
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
18184
18236
  t4 = /*#__PURE__*/jsxRuntime.jsx(Box, {
18185
18237
  sx: t3,
18186
- children: /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18187
- animation: "wave",
18188
- variant: "rounded",
18189
- sx: {
18190
- flex: 1,
18191
- height: "100%"
18192
- }
18238
+ children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
18239
+ component: "table",
18240
+ sx: _temp2$3,
18241
+ children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
18242
+ "aria-hidden": true,
18243
+ children: /*#__PURE__*/jsxRuntime.jsx("tr", {
18244
+ children: GHOST_COLUMNS.map(_temp3$1)
18245
+ })
18246
+ }), /*#__PURE__*/jsxRuntime.jsx("tbody", {
18247
+ children: /*#__PURE__*/jsxRuntime.jsx(MRT_GhostRows, {
18248
+ cells: GHOST_COLUMNS,
18249
+ rowHeight: 37
18250
+ })
18251
+ })]
18193
18252
  })
18194
18253
  });
18195
18254
  $[4] = t4;
@@ -18202,7 +18261,7 @@ const MaterialReactServerTableSkeleton = () => {
18202
18261
  "data-testid": "server-table-skeleton",
18203
18262
  sx: t0,
18204
18263
  children: [t2, t4, /*#__PURE__*/jsxRuntime.jsx(Box, {
18205
- sx: _temp2$3,
18264
+ sx: _temp4,
18206
18265
  children: /*#__PURE__*/jsxRuntime.jsxs(Box, {
18207
18266
  sx: {
18208
18267
  alignItems: "center",
@@ -18210,27 +18269,27 @@ const MaterialReactServerTableSkeleton = () => {
18210
18269
  gap: "1rem"
18211
18270
  },
18212
18271
  children: [/*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18213
- animation: "wave",
18272
+ animation: "pulse",
18214
18273
  height: 36,
18215
18274
  variant: "rounded",
18216
18275
  width: 136
18217
18276
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18218
- animation: "wave",
18277
+ animation: "pulse",
18219
18278
  height: 31,
18220
18279
  variant: "text",
18221
18280
  width: 176
18222
18281
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18223
- animation: "wave",
18282
+ animation: "pulse",
18224
18283
  height: 22,
18225
18284
  variant: "text",
18226
18285
  width: 70
18227
18286
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18228
- animation: "wave",
18287
+ animation: "pulse",
18229
18288
  height: 24,
18230
18289
  variant: "circular",
18231
18290
  width: 24
18232
18291
  }), /*#__PURE__*/jsxRuntime.jsx(Skeleton, {
18233
- animation: "wave",
18292
+ animation: "pulse",
18234
18293
  height: 24,
18235
18294
  variant: "circular",
18236
18295
  width: 24
@@ -18256,9 +18315,40 @@ function _temp$6(theme) {
18256
18315
  };
18257
18316
  }
18258
18317
  function _temp2$3(theme_0) {
18318
+ return {
18319
+ borderCollapse: "collapse",
18320
+ tableLayout: "fixed",
18321
+ width: "100%",
18322
+ "& th": {
18323
+ borderBottom: `1px solid ${theme_0.palette.divider}`,
18324
+ height: 48,
18325
+ p: "0.5rem",
18326
+ textAlign: "left"
18327
+ },
18328
+ "& th > span": {
18329
+ backgroundColor: styles.alpha(theme_0.palette.text.primary, 0.16),
18330
+ borderRadius: 999,
18331
+ display: "block",
18332
+ height: 12
18333
+ }
18334
+ };
18335
+ }
18336
+ function _temp3$1(t0, i) {
18337
+ const {
18338
+ id
18339
+ } = t0;
18340
+ return /*#__PURE__*/jsxRuntime.jsx("th", {
18341
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
18342
+ style: {
18343
+ width: `${HEADER_BAR_WIDTHS[i]}%`
18344
+ }
18345
+ })
18346
+ }, id);
18347
+ }
18348
+ function _temp4(theme_1) {
18259
18349
  return {
18260
18350
  alignItems: "center",
18261
- borderTop: `1px solid ${theme_0.palette.divider}`,
18351
+ borderTop: `1px solid ${theme_1.palette.divider}`,
18262
18352
  display: "flex",
18263
18353
  height: "3.30rem",
18264
18354
  justifyContent: "flex-end",