@dooherceg/material-react-table 4.0.0 → 4.0.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 +420 -252
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +420 -252
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ var IconButton = require('@mui/material/IconButton');
|
|
|
12
12
|
var Stack = require('@mui/material/Stack');
|
|
13
13
|
var compilerRuntime = require('react/compiler-runtime');
|
|
14
14
|
var DeleteOutlineIcon = require('@mui/icons-material/DeleteOutline');
|
|
15
|
+
var Tooltip = require('@mui/material/Tooltip');
|
|
16
|
+
var styles = require('@mui/material/styles');
|
|
15
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
18
|
var EditNoteIcon = require('@mui/icons-material/EditNote');
|
|
17
19
|
var FileDownloadIcon = require('@mui/icons-material/FileDownload');
|
|
@@ -25,8 +27,6 @@ var Menu = require('@mui/material/Menu');
|
|
|
25
27
|
var MenuItem = require('@mui/material/MenuItem');
|
|
26
28
|
var Radio = require('@mui/material/Radio');
|
|
27
29
|
var RadioGroup = require('@mui/material/RadioGroup');
|
|
28
|
-
var styles = require('@mui/material/styles');
|
|
29
|
-
var Tooltip = require('@mui/material/Tooltip');
|
|
30
30
|
var Typography = require('@mui/material/Typography');
|
|
31
31
|
var printJS = require('print-js');
|
|
32
32
|
var notistack = require('notistack');
|
|
@@ -490,10 +490,176 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
|
490
490
|
[getColumnId(col)]: ''
|
|
491
491
|
}))), rowIndex, depth, subRows, parentId);
|
|
492
492
|
|
|
493
|
+
const parseCSSVarId = id => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
494
|
+
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
495
|
+
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
496
|
+
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
497
|
+
return {
|
|
498
|
+
baseBackgroundColor,
|
|
499
|
+
cellNavigationOutlineColor: muiTheme.palette.primary.main,
|
|
500
|
+
draggingBorderColor: muiTheme.palette.primary.main,
|
|
501
|
+
matchHighlightColor: muiTheme.palette.mode === 'dark' ? styles.darken(muiTheme.palette.warning.dark, 0.25) : styles.lighten(muiTheme.palette.warning.light, 0.5),
|
|
502
|
+
menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07),
|
|
503
|
+
pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1),
|
|
504
|
+
selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2),
|
|
505
|
+
...mrtThemeOverrides
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
const commonCellBeforeAfterStyles = {
|
|
509
|
+
content: '""',
|
|
510
|
+
height: '100%',
|
|
511
|
+
left: 0,
|
|
512
|
+
position: 'absolute',
|
|
513
|
+
top: 0,
|
|
514
|
+
width: '100%',
|
|
515
|
+
zIndex: -1
|
|
516
|
+
};
|
|
517
|
+
const getCommonPinnedCellStyles = ({
|
|
518
|
+
table,
|
|
519
|
+
theme
|
|
520
|
+
}) => {
|
|
521
|
+
const {
|
|
522
|
+
baseBackgroundColor
|
|
523
|
+
} = table.options.mrtTheme;
|
|
524
|
+
return {
|
|
525
|
+
'&[data-pinned="true"]': {
|
|
526
|
+
'&:before': {
|
|
527
|
+
backgroundColor: styles.alpha(styles.darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97),
|
|
528
|
+
...commonCellBeforeAfterStyles
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
const getCommonMRTCellStyles = ({
|
|
534
|
+
column,
|
|
535
|
+
header,
|
|
536
|
+
isDraggingColumn,
|
|
537
|
+
isHoveredColumn,
|
|
538
|
+
table,
|
|
539
|
+
tableCellProps,
|
|
540
|
+
theme
|
|
541
|
+
}) => {
|
|
542
|
+
const {
|
|
543
|
+
options: {
|
|
544
|
+
enableColumnVirtualization,
|
|
545
|
+
layoutMode
|
|
546
|
+
}
|
|
547
|
+
} = table;
|
|
548
|
+
const {
|
|
549
|
+
columnDef
|
|
550
|
+
} = column;
|
|
551
|
+
const {
|
|
552
|
+
columnDefType
|
|
553
|
+
} = columnDef;
|
|
554
|
+
const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
555
|
+
const widthStyles = {
|
|
556
|
+
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
|
|
557
|
+
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`
|
|
558
|
+
};
|
|
559
|
+
if (layoutMode === 'grid') {
|
|
560
|
+
widthStyles.flex = `${[0, false].includes(columnDef.grow) ? 0 : `var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size)`} 0 auto`;
|
|
561
|
+
} else if (layoutMode === 'grid-no-grow') {
|
|
562
|
+
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// The checkbox column is technically pinned (for sticky positioning) but
|
|
566
|
+
// should look like a regular center column — no background overlay or shadow.
|
|
567
|
+
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
568
|
+
|
|
569
|
+
// Count all currently pinned column IDs across both sides.
|
|
570
|
+
// Checkbox is always pinned (counts as 1), so > 1 means the user has
|
|
571
|
+
// explicitly pinned at least one additional column.
|
|
572
|
+
// Avoid spreading into a new array on this per-cell hot path — a length sum
|
|
573
|
+
// is enough, we never need the combined array itself.
|
|
574
|
+
const {
|
|
575
|
+
columnPinning
|
|
576
|
+
} = table.getState();
|
|
577
|
+
const totalPinnedColumnCount = (columnPinning.start?.length ?? 0) + (columnPinning.end?.length ?? 0);
|
|
578
|
+
const hasNoPinnedColumns = totalPinnedColumnCount === 0;
|
|
579
|
+
const pinnedStyles = isColumnPinned ? {
|
|
580
|
+
// For checkbox: suppress pinned background/shadow only when other
|
|
581
|
+
// columns are also pinned (> 1 total). When it is the sole pinned column
|
|
582
|
+
// no override is needed. For all other columns apply standard pinned styles.
|
|
583
|
+
...(isCheckboxColumn ? hasNoPinnedColumns ? {
|
|
584
|
+
// Use doubled class selector (&&) to beat the row-level
|
|
585
|
+
// td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
|
|
586
|
+
'&&[data-pinned="true"]': {
|
|
587
|
+
'&:before': {
|
|
588
|
+
backgroundColor: 'transparent',
|
|
589
|
+
boxShadow: 'none'
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
} :
|
|
593
|
+
// Other columns are also pinned — apply standard pinned background
|
|
594
|
+
// so the checkbox header matches the pinned row cells below it.
|
|
595
|
+
getCommonPinnedCellStyles({
|
|
596
|
+
column,
|
|
597
|
+
table,
|
|
598
|
+
theme
|
|
599
|
+
}) : getCommonPinnedCellStyles({
|
|
600
|
+
column,
|
|
601
|
+
table,
|
|
602
|
+
theme
|
|
603
|
+
})),
|
|
604
|
+
// Logical CSS insets (not left/right) so pinning stays correct in RTL
|
|
605
|
+
// without branching on theme.direction here.
|
|
606
|
+
insetInlineStart: isColumnPinned === 'start' ? `${column.getStart('start')}px` : undefined,
|
|
607
|
+
// Skip opacity reduction for checkbox — keep it fully opaque like center columns
|
|
608
|
+
opacity: isCheckboxColumn ? undefined : 0.97,
|
|
609
|
+
position: 'sticky',
|
|
610
|
+
insetInlineEnd: isColumnPinned === 'end' ? `${column.getAfter('end')}px` : undefined
|
|
611
|
+
} : {};
|
|
612
|
+
return {
|
|
613
|
+
backgroundColor: 'inherit',
|
|
614
|
+
backgroundImage: 'inherit',
|
|
615
|
+
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
|
616
|
+
justifyContent: columnDefType === 'group' ? 'center' : layoutMode?.startsWith('grid') ? tableCellProps.align : undefined,
|
|
617
|
+
opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1,
|
|
618
|
+
position: 'relative',
|
|
619
|
+
transition: enableColumnVirtualization ? 'none' : `padding 150ms ease-in-out`,
|
|
620
|
+
zIndex: column.getIsResizing() || isDraggingColumn ? 2 : columnDefType !== 'group' && isColumnPinned ? 1 : 0,
|
|
621
|
+
'&:focus-visible': {
|
|
622
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
623
|
+
outlineOffset: '-2px'
|
|
624
|
+
},
|
|
625
|
+
...pinnedStyles,
|
|
626
|
+
...widthStyles,
|
|
627
|
+
...parseFromValuesOrFunc(tableCellProps?.sx, theme)
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
const getCommonToolbarStyles = ({
|
|
631
|
+
table
|
|
632
|
+
}) => ({
|
|
633
|
+
alignItems: 'flex-start',
|
|
634
|
+
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
635
|
+
display: 'grid',
|
|
636
|
+
flexWrap: 'wrap-reverse',
|
|
637
|
+
position: 'relative',
|
|
638
|
+
transition: 'all 150ms ease-in-out',
|
|
639
|
+
zIndex: 1
|
|
640
|
+
});
|
|
641
|
+
const flipIconStyles = theme => theme.direction === 'rtl' ? {
|
|
642
|
+
style: {
|
|
643
|
+
transform: 'scaleX(-1)'
|
|
644
|
+
}
|
|
645
|
+
} : undefined;
|
|
646
|
+
const getCommonTooltipProps = placement => ({
|
|
647
|
+
disableInteractive: true,
|
|
648
|
+
enterDelay: 1000,
|
|
649
|
+
enterNextDelay: 1000,
|
|
650
|
+
placement
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
// Stable, row-scoped hook for e2e/unit tests to target a specific default
|
|
654
|
+
// row action (e.g. edit, delete) without relying on DOM order or icon markup.
|
|
655
|
+
const getRowActionTestId = (rowId, actionName) => `mrt-row-${rowId}-${actionName}-action`;
|
|
656
|
+
|
|
493
657
|
function MRT_DeleteRowButton(t0) {
|
|
494
|
-
const $ = compilerRuntime.c(
|
|
658
|
+
const $ = compilerRuntime.c(14);
|
|
495
659
|
const {
|
|
496
|
-
onClick
|
|
660
|
+
onClick,
|
|
661
|
+
row,
|
|
662
|
+
table
|
|
497
663
|
} = t0;
|
|
498
664
|
let t1;
|
|
499
665
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -517,34 +683,68 @@ function MRT_DeleteRowButton(t0) {
|
|
|
517
683
|
t2 = $[2];
|
|
518
684
|
}
|
|
519
685
|
const handleClick = t2;
|
|
686
|
+
const deleteLabel = table?.options.localization.deleteConfirmYes ?? "Delete";
|
|
520
687
|
let t3;
|
|
521
688
|
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
522
|
-
t3 =
|
|
689
|
+
t3 = getCommonTooltipProps();
|
|
523
690
|
$[3] = t3;
|
|
524
691
|
} else {
|
|
525
692
|
t3 = $[3];
|
|
526
693
|
}
|
|
527
694
|
let t4;
|
|
528
|
-
if ($[4] !==
|
|
529
|
-
t4 =
|
|
695
|
+
if ($[4] !== row) {
|
|
696
|
+
t4 = row ? getRowActionTestId(row.id, "delete") : undefined;
|
|
697
|
+
$[4] = row;
|
|
698
|
+
$[5] = t4;
|
|
699
|
+
} else {
|
|
700
|
+
t4 = $[5];
|
|
701
|
+
}
|
|
702
|
+
let t5;
|
|
703
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
704
|
+
t5 = /*#__PURE__*/jsxRuntime.jsx(DeleteOutlineIcon, {});
|
|
705
|
+
$[6] = t5;
|
|
706
|
+
} else {
|
|
707
|
+
t5 = $[6];
|
|
708
|
+
}
|
|
709
|
+
let t6;
|
|
710
|
+
if ($[7] !== deleteLabel || $[8] !== handleClick || $[9] !== t4) {
|
|
711
|
+
t6 = /*#__PURE__*/jsxRuntime.jsx(IconButton, {
|
|
530
712
|
disableRipple: true,
|
|
531
713
|
color: "error",
|
|
714
|
+
"aria-label": deleteLabel,
|
|
715
|
+
"data-testid": t4,
|
|
532
716
|
sx: iconButtonStyle,
|
|
533
717
|
onClick: handleClick,
|
|
534
|
-
children:
|
|
718
|
+
children: t5
|
|
535
719
|
});
|
|
536
|
-
$[
|
|
537
|
-
$[
|
|
720
|
+
$[7] = deleteLabel;
|
|
721
|
+
$[8] = handleClick;
|
|
722
|
+
$[9] = t4;
|
|
723
|
+
$[10] = t6;
|
|
538
724
|
} else {
|
|
539
|
-
|
|
725
|
+
t6 = $[10];
|
|
540
726
|
}
|
|
541
|
-
|
|
727
|
+
let t7;
|
|
728
|
+
if ($[11] !== deleteLabel || $[12] !== t6) {
|
|
729
|
+
t7 = /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
730
|
+
...t3,
|
|
731
|
+
title: deleteLabel,
|
|
732
|
+
children: t6
|
|
733
|
+
});
|
|
734
|
+
$[11] = deleteLabel;
|
|
735
|
+
$[12] = t6;
|
|
736
|
+
$[13] = t7;
|
|
737
|
+
} else {
|
|
738
|
+
t7 = $[13];
|
|
739
|
+
}
|
|
740
|
+
return t7;
|
|
542
741
|
}
|
|
543
742
|
|
|
544
743
|
const DeleteRowAction = ({
|
|
545
744
|
onDeleteConfirm,
|
|
546
745
|
table,
|
|
547
|
-
deleteConfirmation
|
|
746
|
+
deleteConfirmation,
|
|
747
|
+
row
|
|
548
748
|
}) => {
|
|
549
749
|
// Toolbar context — no specific row is targeted
|
|
550
750
|
const [open, setOpen] = react.useState(false);
|
|
@@ -662,7 +862,9 @@ const DeleteRowAction = ({
|
|
|
662
862
|
})]
|
|
663
863
|
})
|
|
664
864
|
}), /*#__PURE__*/jsxRuntime.jsx(MRT_DeleteRowButton, {
|
|
665
|
-
onClick: handleDeleteRowButtonClick
|
|
865
|
+
onClick: handleDeleteRowButtonClick,
|
|
866
|
+
row: row,
|
|
867
|
+
table: table
|
|
666
868
|
})]
|
|
667
869
|
});
|
|
668
870
|
};
|
|
@@ -751,7 +953,8 @@ const createDeleteAction = ({
|
|
|
751
953
|
return /*#__PURE__*/jsxRuntime.jsx(DeleteRowAction$1, {
|
|
752
954
|
onDeleteConfirm: onRowDelete,
|
|
753
955
|
table: context.table,
|
|
754
|
-
deleteConfirmation: deleteConfirmation
|
|
956
|
+
deleteConfirmation: deleteConfirmation,
|
|
957
|
+
row: context.row
|
|
755
958
|
});
|
|
756
959
|
};
|
|
757
960
|
|
|
@@ -778,9 +981,11 @@ const createDeleteAction = ({
|
|
|
778
981
|
};
|
|
779
982
|
|
|
780
983
|
const MRT_EditRowButton = t0 => {
|
|
781
|
-
const $ = compilerRuntime.c(
|
|
984
|
+
const $ = compilerRuntime.c(14);
|
|
782
985
|
const {
|
|
783
|
-
onClick
|
|
986
|
+
onClick,
|
|
987
|
+
row,
|
|
988
|
+
table
|
|
784
989
|
} = t0;
|
|
785
990
|
let t1;
|
|
786
991
|
if ($[0] !== onClick) {
|
|
@@ -794,56 +999,95 @@ const MRT_EditRowButton = t0 => {
|
|
|
794
999
|
t1 = $[1];
|
|
795
1000
|
}
|
|
796
1001
|
const handleClick = t1;
|
|
1002
|
+
const editLabel = table?.options.localization.edit ?? "Edit";
|
|
797
1003
|
let t2;
|
|
798
1004
|
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
799
|
-
t2 =
|
|
800
|
-
p: 0
|
|
801
|
-
};
|
|
1005
|
+
t2 = getCommonTooltipProps();
|
|
802
1006
|
$[2] = t2;
|
|
803
1007
|
} else {
|
|
804
1008
|
t2 = $[2];
|
|
805
1009
|
}
|
|
806
1010
|
let t3;
|
|
807
|
-
if ($[3]
|
|
808
|
-
t3 =
|
|
809
|
-
$[3] =
|
|
1011
|
+
if ($[3] !== row) {
|
|
1012
|
+
t3 = row ? getRowActionTestId(row.id, "edit") : undefined;
|
|
1013
|
+
$[3] = row;
|
|
1014
|
+
$[4] = t3;
|
|
810
1015
|
} else {
|
|
811
|
-
t3 = $[
|
|
1016
|
+
t3 = $[4];
|
|
812
1017
|
}
|
|
813
1018
|
let t4;
|
|
814
|
-
if ($[
|
|
815
|
-
t4 =
|
|
816
|
-
|
|
1019
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1020
|
+
t4 = {
|
|
1021
|
+
p: 0
|
|
1022
|
+
};
|
|
1023
|
+
$[5] = t4;
|
|
1024
|
+
} else {
|
|
1025
|
+
t4 = $[5];
|
|
1026
|
+
}
|
|
1027
|
+
let t5;
|
|
1028
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1029
|
+
t5 = /*#__PURE__*/jsxRuntime.jsx(EditNoteIcon, {});
|
|
1030
|
+
$[6] = t5;
|
|
1031
|
+
} else {
|
|
1032
|
+
t5 = $[6];
|
|
1033
|
+
}
|
|
1034
|
+
let t6;
|
|
1035
|
+
if ($[7] !== editLabel || $[8] !== handleClick || $[9] !== t3) {
|
|
1036
|
+
t6 = /*#__PURE__*/jsxRuntime.jsx(IconButton, {
|
|
1037
|
+
"aria-label": editLabel,
|
|
1038
|
+
"data-testid": t3,
|
|
1039
|
+
sx: t4,
|
|
817
1040
|
disableRipple: true,
|
|
818
1041
|
color: "primary",
|
|
819
1042
|
onClick: handleClick,
|
|
820
|
-
children:
|
|
1043
|
+
children: t5
|
|
821
1044
|
});
|
|
822
|
-
$[
|
|
823
|
-
$[
|
|
1045
|
+
$[7] = editLabel;
|
|
1046
|
+
$[8] = handleClick;
|
|
1047
|
+
$[9] = t3;
|
|
1048
|
+
$[10] = t6;
|
|
824
1049
|
} else {
|
|
825
|
-
|
|
1050
|
+
t6 = $[10];
|
|
826
1051
|
}
|
|
827
|
-
|
|
1052
|
+
let t7;
|
|
1053
|
+
if ($[11] !== editLabel || $[12] !== t6) {
|
|
1054
|
+
t7 = /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
1055
|
+
...t2,
|
|
1056
|
+
title: editLabel,
|
|
1057
|
+
children: t6
|
|
1058
|
+
});
|
|
1059
|
+
$[11] = editLabel;
|
|
1060
|
+
$[12] = t6;
|
|
1061
|
+
$[13] = t7;
|
|
1062
|
+
} else {
|
|
1063
|
+
t7 = $[13];
|
|
1064
|
+
}
|
|
1065
|
+
return t7;
|
|
828
1066
|
};
|
|
829
1067
|
var MRT_EditRowButton$1 = MRT_EditRowButton;
|
|
830
1068
|
|
|
831
1069
|
const EditRowAction = t0 => {
|
|
832
|
-
const $ = compilerRuntime.c(
|
|
1070
|
+
const $ = compilerRuntime.c(4);
|
|
833
1071
|
const {
|
|
834
|
-
onEditButtonClick
|
|
1072
|
+
onEditButtonClick,
|
|
1073
|
+
row,
|
|
1074
|
+
table
|
|
835
1075
|
} = t0;
|
|
836
1076
|
let t1;
|
|
837
|
-
if ($[0] !== onEditButtonClick) {
|
|
1077
|
+
if ($[0] !== onEditButtonClick || $[1] !== row || $[2] !== table) {
|
|
838
1078
|
t1 = /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
839
1079
|
children: /*#__PURE__*/jsxRuntime.jsx(MRT_EditRowButton$1, {
|
|
840
|
-
onClick: onEditButtonClick
|
|
1080
|
+
onClick: onEditButtonClick,
|
|
1081
|
+
row: row,
|
|
1082
|
+
table: table
|
|
841
1083
|
})
|
|
842
1084
|
});
|
|
843
1085
|
$[0] = onEditButtonClick;
|
|
844
|
-
$[1] =
|
|
1086
|
+
$[1] = row;
|
|
1087
|
+
$[2] = table;
|
|
1088
|
+
$[3] = t1;
|
|
845
1089
|
} else {
|
|
846
|
-
t1 = $[
|
|
1090
|
+
t1 = $[3];
|
|
847
1091
|
}
|
|
848
1092
|
return t1;
|
|
849
1093
|
};
|
|
@@ -912,7 +1156,9 @@ const createEditAction = ({
|
|
|
912
1156
|
});
|
|
913
1157
|
}
|
|
914
1158
|
return /*#__PURE__*/jsxRuntime.jsx(EditRowAction$1, {
|
|
915
|
-
onEditButtonClick: onRowEdit
|
|
1159
|
+
onEditButtonClick: onRowEdit,
|
|
1160
|
+
row: context.row,
|
|
1161
|
+
table: context.table
|
|
916
1162
|
});
|
|
917
1163
|
};
|
|
918
1164
|
return {
|
|
@@ -1219,121 +1465,201 @@ const MRT_ExportsToolbar = ({
|
|
|
1219
1465
|
};
|
|
1220
1466
|
|
|
1221
1467
|
const MRT_ExportRowButton = t0 => {
|
|
1222
|
-
const $ = compilerRuntime.c(
|
|
1468
|
+
const $ = compilerRuntime.c(12);
|
|
1223
1469
|
const {
|
|
1224
|
-
onClick
|
|
1470
|
+
onClick,
|
|
1471
|
+
row,
|
|
1472
|
+
table
|
|
1225
1473
|
} = t0;
|
|
1474
|
+
const exportLabel = table?.options.localization.exportDownload ?? "Export";
|
|
1226
1475
|
let t1;
|
|
1227
1476
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1228
|
-
t1 =
|
|
1229
|
-
p: 0
|
|
1230
|
-
};
|
|
1477
|
+
t1 = getCommonTooltipProps();
|
|
1231
1478
|
$[0] = t1;
|
|
1232
1479
|
} else {
|
|
1233
1480
|
t1 = $[0];
|
|
1234
1481
|
}
|
|
1235
1482
|
let t2;
|
|
1236
|
-
if ($[1]
|
|
1237
|
-
t2 =
|
|
1483
|
+
if ($[1] !== row) {
|
|
1484
|
+
t2 = row ? getRowActionTestId(row.id, "export") : undefined;
|
|
1485
|
+
$[1] = row;
|
|
1486
|
+
$[2] = t2;
|
|
1487
|
+
} else {
|
|
1488
|
+
t2 = $[2];
|
|
1489
|
+
}
|
|
1490
|
+
let t3;
|
|
1491
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1492
|
+
t3 = {
|
|
1493
|
+
p: 0
|
|
1494
|
+
};
|
|
1495
|
+
$[3] = t3;
|
|
1496
|
+
} else {
|
|
1497
|
+
t3 = $[3];
|
|
1498
|
+
}
|
|
1499
|
+
let t4;
|
|
1500
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1501
|
+
t4 = /*#__PURE__*/jsxRuntime.jsx(FileDownloadIcon, {
|
|
1238
1502
|
fontSize: "small"
|
|
1239
1503
|
});
|
|
1240
|
-
$[
|
|
1504
|
+
$[4] = t4;
|
|
1241
1505
|
} else {
|
|
1242
|
-
|
|
1506
|
+
t4 = $[4];
|
|
1243
1507
|
}
|
|
1244
|
-
let
|
|
1245
|
-
if ($[
|
|
1246
|
-
|
|
1247
|
-
|
|
1508
|
+
let t5;
|
|
1509
|
+
if ($[5] !== exportLabel || $[6] !== onClick || $[7] !== t2) {
|
|
1510
|
+
t5 = /*#__PURE__*/jsxRuntime.jsx(IconButton, {
|
|
1511
|
+
"aria-label": exportLabel,
|
|
1512
|
+
"data-testid": t2,
|
|
1513
|
+
sx: t3,
|
|
1248
1514
|
disableRipple: true,
|
|
1249
1515
|
onClick: onClick,
|
|
1250
|
-
children:
|
|
1516
|
+
children: t4
|
|
1251
1517
|
});
|
|
1252
|
-
$[
|
|
1253
|
-
$[
|
|
1518
|
+
$[5] = exportLabel;
|
|
1519
|
+
$[6] = onClick;
|
|
1520
|
+
$[7] = t2;
|
|
1521
|
+
$[8] = t5;
|
|
1254
1522
|
} else {
|
|
1255
|
-
|
|
1523
|
+
t5 = $[8];
|
|
1256
1524
|
}
|
|
1257
|
-
|
|
1525
|
+
let t6;
|
|
1526
|
+
if ($[9] !== exportLabel || $[10] !== t5) {
|
|
1527
|
+
t6 = /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
1528
|
+
...t1,
|
|
1529
|
+
title: exportLabel,
|
|
1530
|
+
children: t5
|
|
1531
|
+
});
|
|
1532
|
+
$[9] = exportLabel;
|
|
1533
|
+
$[10] = t5;
|
|
1534
|
+
$[11] = t6;
|
|
1535
|
+
} else {
|
|
1536
|
+
t6 = $[11];
|
|
1537
|
+
}
|
|
1538
|
+
return t6;
|
|
1258
1539
|
};
|
|
1259
1540
|
var MRT_ExportRowButton$1 = MRT_ExportRowButton;
|
|
1260
1541
|
|
|
1261
1542
|
const MRT_PrintRowButton = t0 => {
|
|
1262
|
-
const $ = compilerRuntime.c(
|
|
1543
|
+
const $ = compilerRuntime.c(12);
|
|
1263
1544
|
const {
|
|
1264
|
-
onClick
|
|
1545
|
+
onClick,
|
|
1546
|
+
row,
|
|
1547
|
+
table
|
|
1265
1548
|
} = t0;
|
|
1549
|
+
const printLabel = table?.options.localization.exportPrintPdf ?? "Print";
|
|
1266
1550
|
let t1;
|
|
1267
1551
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1268
|
-
t1 =
|
|
1269
|
-
p: 0
|
|
1270
|
-
};
|
|
1552
|
+
t1 = getCommonTooltipProps();
|
|
1271
1553
|
$[0] = t1;
|
|
1272
1554
|
} else {
|
|
1273
1555
|
t1 = $[0];
|
|
1274
1556
|
}
|
|
1275
1557
|
let t2;
|
|
1276
|
-
if ($[1]
|
|
1277
|
-
t2 =
|
|
1558
|
+
if ($[1] !== row) {
|
|
1559
|
+
t2 = row ? getRowActionTestId(row.id, "print") : undefined;
|
|
1560
|
+
$[1] = row;
|
|
1561
|
+
$[2] = t2;
|
|
1562
|
+
} else {
|
|
1563
|
+
t2 = $[2];
|
|
1564
|
+
}
|
|
1565
|
+
let t3;
|
|
1566
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1567
|
+
t3 = {
|
|
1568
|
+
p: 0
|
|
1569
|
+
};
|
|
1570
|
+
$[3] = t3;
|
|
1571
|
+
} else {
|
|
1572
|
+
t3 = $[3];
|
|
1573
|
+
}
|
|
1574
|
+
let t4;
|
|
1575
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1576
|
+
t4 = /*#__PURE__*/jsxRuntime.jsx(PrintIcon, {
|
|
1278
1577
|
fontSize: "small"
|
|
1279
1578
|
});
|
|
1280
|
-
$[
|
|
1579
|
+
$[4] = t4;
|
|
1281
1580
|
} else {
|
|
1282
|
-
|
|
1581
|
+
t4 = $[4];
|
|
1283
1582
|
}
|
|
1284
|
-
let
|
|
1285
|
-
if ($[
|
|
1286
|
-
|
|
1287
|
-
|
|
1583
|
+
let t5;
|
|
1584
|
+
if ($[5] !== onClick || $[6] !== printLabel || $[7] !== t2) {
|
|
1585
|
+
t5 = /*#__PURE__*/jsxRuntime.jsx(IconButton, {
|
|
1586
|
+
"aria-label": printLabel,
|
|
1587
|
+
"data-testid": t2,
|
|
1588
|
+
sx: t3,
|
|
1288
1589
|
disableRipple: true,
|
|
1289
1590
|
onClick: onClick,
|
|
1290
|
-
children:
|
|
1591
|
+
children: t4
|
|
1291
1592
|
});
|
|
1292
|
-
$[
|
|
1293
|
-
$[
|
|
1593
|
+
$[5] = onClick;
|
|
1594
|
+
$[6] = printLabel;
|
|
1595
|
+
$[7] = t2;
|
|
1596
|
+
$[8] = t5;
|
|
1294
1597
|
} else {
|
|
1295
|
-
|
|
1598
|
+
t5 = $[8];
|
|
1296
1599
|
}
|
|
1297
|
-
|
|
1600
|
+
let t6;
|
|
1601
|
+
if ($[9] !== printLabel || $[10] !== t5) {
|
|
1602
|
+
t6 = /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
1603
|
+
...t1,
|
|
1604
|
+
title: printLabel,
|
|
1605
|
+
children: t5
|
|
1606
|
+
});
|
|
1607
|
+
$[9] = printLabel;
|
|
1608
|
+
$[10] = t5;
|
|
1609
|
+
$[11] = t6;
|
|
1610
|
+
} else {
|
|
1611
|
+
t6 = $[11];
|
|
1612
|
+
}
|
|
1613
|
+
return t6;
|
|
1298
1614
|
};
|
|
1299
1615
|
var MRT_PrintRowButton$1 = MRT_PrintRowButton;
|
|
1300
1616
|
|
|
1301
1617
|
const ExportRowAction = t0 => {
|
|
1302
|
-
const $ = compilerRuntime.c(
|
|
1618
|
+
const $ = compilerRuntime.c(11);
|
|
1303
1619
|
const {
|
|
1304
1620
|
onExport,
|
|
1305
|
-
onPrint
|
|
1621
|
+
onPrint,
|
|
1622
|
+
row,
|
|
1623
|
+
table
|
|
1306
1624
|
} = t0;
|
|
1307
1625
|
let t1;
|
|
1308
|
-
if ($[0] !== onExport) {
|
|
1626
|
+
if ($[0] !== onExport || $[1] !== row || $[2] !== table) {
|
|
1309
1627
|
t1 = /*#__PURE__*/jsxRuntime.jsx(MRT_ExportRowButton$1, {
|
|
1310
|
-
onClick: onExport
|
|
1628
|
+
onClick: onExport,
|
|
1629
|
+
row: row,
|
|
1630
|
+
table: table
|
|
1311
1631
|
});
|
|
1312
1632
|
$[0] = onExport;
|
|
1313
|
-
$[1] =
|
|
1633
|
+
$[1] = row;
|
|
1634
|
+
$[2] = table;
|
|
1635
|
+
$[3] = t1;
|
|
1314
1636
|
} else {
|
|
1315
|
-
t1 = $[
|
|
1637
|
+
t1 = $[3];
|
|
1316
1638
|
}
|
|
1317
1639
|
let t2;
|
|
1318
|
-
if ($[
|
|
1640
|
+
if ($[4] !== onPrint || $[5] !== row || $[6] !== table) {
|
|
1319
1641
|
t2 = onPrint && /*#__PURE__*/jsxRuntime.jsx(MRT_PrintRowButton$1, {
|
|
1320
|
-
onClick: onPrint
|
|
1642
|
+
onClick: onPrint,
|
|
1643
|
+
row: row,
|
|
1644
|
+
table: table
|
|
1321
1645
|
});
|
|
1322
|
-
$[
|
|
1323
|
-
$[
|
|
1646
|
+
$[4] = onPrint;
|
|
1647
|
+
$[5] = row;
|
|
1648
|
+
$[6] = table;
|
|
1649
|
+
$[7] = t2;
|
|
1324
1650
|
} else {
|
|
1325
|
-
t2 = $[
|
|
1651
|
+
t2 = $[7];
|
|
1326
1652
|
}
|
|
1327
1653
|
let t3;
|
|
1328
|
-
if ($[
|
|
1654
|
+
if ($[8] !== t1 || $[9] !== t2) {
|
|
1329
1655
|
t3 = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1330
1656
|
children: [t1, t2]
|
|
1331
1657
|
});
|
|
1332
|
-
$[
|
|
1333
|
-
$[
|
|
1334
|
-
$[
|
|
1658
|
+
$[8] = t1;
|
|
1659
|
+
$[9] = t2;
|
|
1660
|
+
$[10] = t3;
|
|
1335
1661
|
} else {
|
|
1336
|
-
t3 = $[
|
|
1662
|
+
t3 = $[10];
|
|
1337
1663
|
}
|
|
1338
1664
|
return t3;
|
|
1339
1665
|
};
|
|
@@ -1532,7 +1858,9 @@ const createExportAction = ({
|
|
|
1532
1858
|
}
|
|
1533
1859
|
return /*#__PURE__*/jsxRuntime.jsx(ExportRowAction$1, {
|
|
1534
1860
|
onExport: onRowExport,
|
|
1535
|
-
onPrint: onRowPrint
|
|
1861
|
+
onPrint: onRowPrint,
|
|
1862
|
+
row: context.row,
|
|
1863
|
+
table: context.table
|
|
1536
1864
|
});
|
|
1537
1865
|
};
|
|
1538
1866
|
|
|
@@ -1659,166 +1987,6 @@ const MRT_RowActionMenu = ({
|
|
|
1659
1987
|
});
|
|
1660
1988
|
};
|
|
1661
1989
|
|
|
1662
|
-
const parseCSSVarId = id => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
1663
|
-
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
1664
|
-
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
1665
|
-
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
1666
|
-
return {
|
|
1667
|
-
baseBackgroundColor,
|
|
1668
|
-
cellNavigationOutlineColor: muiTheme.palette.primary.main,
|
|
1669
|
-
draggingBorderColor: muiTheme.palette.primary.main,
|
|
1670
|
-
matchHighlightColor: muiTheme.palette.mode === 'dark' ? styles.darken(muiTheme.palette.warning.dark, 0.25) : styles.lighten(muiTheme.palette.warning.light, 0.5),
|
|
1671
|
-
menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07),
|
|
1672
|
-
pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1),
|
|
1673
|
-
selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2),
|
|
1674
|
-
...mrtThemeOverrides
|
|
1675
|
-
};
|
|
1676
|
-
};
|
|
1677
|
-
const commonCellBeforeAfterStyles = {
|
|
1678
|
-
content: '""',
|
|
1679
|
-
height: '100%',
|
|
1680
|
-
left: 0,
|
|
1681
|
-
position: 'absolute',
|
|
1682
|
-
top: 0,
|
|
1683
|
-
width: '100%',
|
|
1684
|
-
zIndex: -1
|
|
1685
|
-
};
|
|
1686
|
-
const getCommonPinnedCellStyles = ({
|
|
1687
|
-
table,
|
|
1688
|
-
theme
|
|
1689
|
-
}) => {
|
|
1690
|
-
const {
|
|
1691
|
-
baseBackgroundColor
|
|
1692
|
-
} = table.options.mrtTheme;
|
|
1693
|
-
return {
|
|
1694
|
-
'&[data-pinned="true"]': {
|
|
1695
|
-
'&:before': {
|
|
1696
|
-
backgroundColor: styles.alpha(styles.darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97),
|
|
1697
|
-
...commonCellBeforeAfterStyles
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
};
|
|
1701
|
-
};
|
|
1702
|
-
const getCommonMRTCellStyles = ({
|
|
1703
|
-
column,
|
|
1704
|
-
header,
|
|
1705
|
-
isDraggingColumn,
|
|
1706
|
-
isHoveredColumn,
|
|
1707
|
-
table,
|
|
1708
|
-
tableCellProps,
|
|
1709
|
-
theme
|
|
1710
|
-
}) => {
|
|
1711
|
-
const {
|
|
1712
|
-
options: {
|
|
1713
|
-
enableColumnVirtualization,
|
|
1714
|
-
layoutMode
|
|
1715
|
-
}
|
|
1716
|
-
} = table;
|
|
1717
|
-
const {
|
|
1718
|
-
columnDef
|
|
1719
|
-
} = column;
|
|
1720
|
-
const {
|
|
1721
|
-
columnDefType
|
|
1722
|
-
} = columnDef;
|
|
1723
|
-
const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
1724
|
-
const widthStyles = {
|
|
1725
|
-
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px), ${columnDef.minSize ?? 30}px)`,
|
|
1726
|
-
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size) * 1px)`
|
|
1727
|
-
};
|
|
1728
|
-
if (layoutMode === 'grid') {
|
|
1729
|
-
widthStyles.flex = `${[0, false].includes(columnDef.grow) ? 0 : `var(--${header ? 'header' : 'col'}-${parseCSSVarId(header?.id ?? column.id)}-size)`} 0 auto`;
|
|
1730
|
-
} else if (layoutMode === 'grid-no-grow') {
|
|
1731
|
-
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
// The checkbox column is technically pinned (for sticky positioning) but
|
|
1735
|
-
// should look like a regular center column — no background overlay or shadow.
|
|
1736
|
-
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
1737
|
-
|
|
1738
|
-
// Count all currently pinned column IDs across both sides.
|
|
1739
|
-
// Checkbox is always pinned (counts as 1), so > 1 means the user has
|
|
1740
|
-
// explicitly pinned at least one additional column.
|
|
1741
|
-
// Avoid spreading into a new array on this per-cell hot path — a length sum
|
|
1742
|
-
// is enough, we never need the combined array itself.
|
|
1743
|
-
const {
|
|
1744
|
-
columnPinning
|
|
1745
|
-
} = table.getState();
|
|
1746
|
-
const totalPinnedColumnCount = (columnPinning.start?.length ?? 0) + (columnPinning.end?.length ?? 0);
|
|
1747
|
-
const hasNoPinnedColumns = totalPinnedColumnCount === 0;
|
|
1748
|
-
const pinnedStyles = isColumnPinned ? {
|
|
1749
|
-
// For checkbox: suppress pinned background/shadow only when other
|
|
1750
|
-
// columns are also pinned (> 1 total). When it is the sole pinned column
|
|
1751
|
-
// no override is needed. For all other columns apply standard pinned styles.
|
|
1752
|
-
...(isCheckboxColumn ? hasNoPinnedColumns ? {
|
|
1753
|
-
// Use doubled class selector (&&) to beat the row-level
|
|
1754
|
-
// td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
|
|
1755
|
-
'&&[data-pinned="true"]': {
|
|
1756
|
-
'&:before': {
|
|
1757
|
-
backgroundColor: 'transparent',
|
|
1758
|
-
boxShadow: 'none'
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
} :
|
|
1762
|
-
// Other columns are also pinned — apply standard pinned background
|
|
1763
|
-
// so the checkbox header matches the pinned row cells below it.
|
|
1764
|
-
getCommonPinnedCellStyles({
|
|
1765
|
-
column,
|
|
1766
|
-
table,
|
|
1767
|
-
theme
|
|
1768
|
-
}) : getCommonPinnedCellStyles({
|
|
1769
|
-
column,
|
|
1770
|
-
table,
|
|
1771
|
-
theme
|
|
1772
|
-
})),
|
|
1773
|
-
// Logical CSS insets (not left/right) so pinning stays correct in RTL
|
|
1774
|
-
// without branching on theme.direction here.
|
|
1775
|
-
insetInlineStart: isColumnPinned === 'start' ? `${column.getStart('start')}px` : undefined,
|
|
1776
|
-
// Skip opacity reduction for checkbox — keep it fully opaque like center columns
|
|
1777
|
-
opacity: isCheckboxColumn ? undefined : 0.97,
|
|
1778
|
-
position: 'sticky',
|
|
1779
|
-
insetInlineEnd: isColumnPinned === 'end' ? `${column.getAfter('end')}px` : undefined
|
|
1780
|
-
} : {};
|
|
1781
|
-
return {
|
|
1782
|
-
backgroundColor: 'inherit',
|
|
1783
|
-
backgroundImage: 'inherit',
|
|
1784
|
-
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
|
1785
|
-
justifyContent: columnDefType === 'group' ? 'center' : layoutMode?.startsWith('grid') ? tableCellProps.align : undefined,
|
|
1786
|
-
opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1,
|
|
1787
|
-
position: 'relative',
|
|
1788
|
-
transition: enableColumnVirtualization ? 'none' : `padding 150ms ease-in-out`,
|
|
1789
|
-
zIndex: column.getIsResizing() || isDraggingColumn ? 2 : columnDefType !== 'group' && isColumnPinned ? 1 : 0,
|
|
1790
|
-
'&:focus-visible': {
|
|
1791
|
-
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
1792
|
-
outlineOffset: '-2px'
|
|
1793
|
-
},
|
|
1794
|
-
...pinnedStyles,
|
|
1795
|
-
...widthStyles,
|
|
1796
|
-
...parseFromValuesOrFunc(tableCellProps?.sx, theme)
|
|
1797
|
-
};
|
|
1798
|
-
};
|
|
1799
|
-
const getCommonToolbarStyles = ({
|
|
1800
|
-
table
|
|
1801
|
-
}) => ({
|
|
1802
|
-
alignItems: 'flex-start',
|
|
1803
|
-
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
1804
|
-
display: 'grid',
|
|
1805
|
-
flexWrap: 'wrap-reverse',
|
|
1806
|
-
position: 'relative',
|
|
1807
|
-
transition: 'all 150ms ease-in-out',
|
|
1808
|
-
zIndex: 1
|
|
1809
|
-
});
|
|
1810
|
-
const flipIconStyles = theme => theme.direction === 'rtl' ? {
|
|
1811
|
-
style: {
|
|
1812
|
-
transform: 'scaleX(-1)'
|
|
1813
|
-
}
|
|
1814
|
-
} : undefined;
|
|
1815
|
-
const getCommonTooltipProps = placement => ({
|
|
1816
|
-
disableInteractive: true,
|
|
1817
|
-
enterDelay: 1000,
|
|
1818
|
-
enterNextDelay: 1000,
|
|
1819
|
-
placement
|
|
1820
|
-
});
|
|
1821
|
-
|
|
1822
1990
|
const commonIconButtonStyles = {
|
|
1823
1991
|
'&:hover': {
|
|
1824
1992
|
opacity: 1
|