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