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