material-react-table 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +616 -545
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +614 -543
- package/dist/index.js.map +1 -1
- package/locales/fr/index.esm.js +1 -1
- package/locales/fr/index.js +1 -1
- package/locales/he/index.d.ts +3 -0
- package/locales/he/index.esm.d.ts +3 -0
- package/locales/he/index.esm.js +93 -0
- package/locales/he/index.js +97 -0
- package/locales/he/package.json +6 -0
- package/package.json +25 -25
- package/src/body/MRT_TableBodyCell.tsx +22 -19
- package/src/body/MRT_TableBodyCellValue.tsx +9 -9
- package/src/body/MRT_TableBodyRow.tsx +13 -13
- package/src/buttons/MRT_RowPinButton.tsx +2 -2
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -2
- package/src/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/head/MRT_TableHeadCell.tsx +25 -20
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +19 -9
- package/src/hooks/useMRT_DisplayColumns.tsx +172 -125
- package/src/hooks/useMRT_TableOptions.ts +8 -0
- package/src/inputs/MRT_EditCellTextField.tsx +3 -1
- package/src/inputs/MRT_FilterCheckbox.tsx +2 -2
- package/src/inputs/MRT_FilterTextField.tsx +17 -17
- package/src/inputs/MRT_SelectCheckbox.tsx +2 -2
- package/src/locales/fr.ts +1 -1
- package/src/locales/he.ts +94 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -2
- package/src/style.utils.ts +2 -2
- package/src/toolbar/MRT_TablePagination.tsx +8 -4
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +6 -6
- package/src/types.ts +2 -2
- package/dist/types/MaterialReactTable.d.ts +0 -7
- package/dist/types/aggregationFns.d.ts +0 -11
- package/dist/types/body/MRT_TableBody.d.ts +0 -13
- package/dist/types/body/MRT_TableBodyCell.d.ts +0 -15
- package/dist/types/body/MRT_TableBodyCellValue.d.ts +0 -8
- package/dist/types/body/MRT_TableBodyRow.d.ts +0 -18
- package/dist/types/body/MRT_TableBodyRowGrabHandle.d.ts +0 -10
- package/dist/types/body/MRT_TableBodyRowPinButton.d.ts +0 -8
- package/dist/types/body/MRT_TableDetailPanel.d.ts +0 -13
- package/dist/types/body/index.d.ts +0 -7
- package/dist/types/buttons/MRT_ColumnPinningButtons.d.ts +0 -8
- package/dist/types/buttons/MRT_CopyButton.d.ts +0 -8
- package/dist/types/buttons/MRT_EditActionButtons.d.ts +0 -9
- package/dist/types/buttons/MRT_ExpandAllButton.d.ts +0 -7
- package/dist/types/buttons/MRT_ExpandButton.d.ts +0 -8
- package/dist/types/buttons/MRT_GrabHandleButton.d.ts +0 -12
- package/dist/types/buttons/MRT_RowPinButton.d.ts +0 -10
- package/dist/types/buttons/MRT_ShowHideColumnsButton.d.ts +0 -7
- package/dist/types/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -7
- package/dist/types/buttons/MRT_ToggleFiltersButton.d.ts +0 -7
- package/dist/types/buttons/MRT_ToggleFullScreenButton.d.ts +0 -7
- package/dist/types/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -7
- package/dist/types/buttons/MRT_ToggleRowActionMenuButton.d.ts +0 -9
- package/dist/types/buttons/index.d.ts +0 -13
- package/dist/types/column.utils.d.ts +0 -127
- package/dist/types/filterFns.d.ts +0 -69
- package/dist/types/footer/MRT_TableFooter.d.ts +0 -11
- package/dist/types/footer/MRT_TableFooterCell.d.ts +0 -8
- package/dist/types/footer/MRT_TableFooterRow.d.ts +0 -12
- package/dist/types/footer/index.d.ts +0 -3
- package/dist/types/head/MRT_TableHead.d.ts +0 -11
- package/dist/types/head/MRT_TableHeadCell.d.ts +0 -8
- package/dist/types/head/MRT_TableHeadCellColumnActionsButton.d.ts +0 -8
- package/dist/types/head/MRT_TableHeadCellFilterContainer.d.ts +0 -8
- package/dist/types/head/MRT_TableHeadCellFilterLabel.d.ts +0 -8
- package/dist/types/head/MRT_TableHeadCellGrabHandle.d.ts +0 -10
- package/dist/types/head/MRT_TableHeadCellResizeHandle.d.ts +0 -8
- package/dist/types/head/MRT_TableHeadCellSortLabel.d.ts +0 -8
- package/dist/types/head/MRT_TableHeadRow.d.ts +0 -12
- package/dist/types/head/index.d.ts +0 -9
- package/dist/types/hooks/index.d.ts +0 -4
- package/dist/types/hooks/useMRT_DisplayColumns.d.ts +0 -9
- package/dist/types/hooks/useMRT_Effects.d.ts +0 -2
- package/dist/types/hooks/useMRT_TableInstance.d.ts +0 -2
- package/dist/types/hooks/useMRT_TableOptions.d.ts +0 -22
- package/dist/types/icons.d.ts +0 -36
- package/dist/types/index.d.ts +0 -18
- package/dist/types/inputs/MRT_EditCellTextField.d.ts +0 -8
- package/dist/types/inputs/MRT_FilterCheckbox.d.ts +0 -8
- package/dist/types/inputs/MRT_FilterRangeFields.d.ts +0 -8
- package/dist/types/inputs/MRT_FilterRangeSlider.d.ts +0 -8
- package/dist/types/inputs/MRT_FilterTextField.d.ts +0 -9
- package/dist/types/inputs/MRT_GlobalFilterTextField.d.ts +0 -7
- package/dist/types/inputs/MRT_SelectCheckbox.d.ts +0 -9
- package/dist/types/inputs/index.d.ts +0 -7
- package/dist/types/locales/am.d.ts +0 -2
- package/dist/types/locales/ar.d.ts +0 -2
- package/dist/types/locales/az.d.ts +0 -2
- package/dist/types/locales/bg.d.ts +0 -2
- package/dist/types/locales/cs.d.ts +0 -2
- package/dist/types/locales/da.d.ts +0 -2
- package/dist/types/locales/de.d.ts +0 -2
- package/dist/types/locales/en.d.ts +0 -2
- package/dist/types/locales/es.d.ts +0 -2
- package/dist/types/locales/et.d.ts +0 -2
- package/dist/types/locales/fa.d.ts +0 -2
- package/dist/types/locales/fi.d.ts +0 -2
- package/dist/types/locales/fr.d.ts +0 -2
- package/dist/types/locales/hu.d.ts +0 -2
- package/dist/types/locales/hy.d.ts +0 -2
- package/dist/types/locales/id.d.ts +0 -2
- package/dist/types/locales/it.d.ts +0 -2
- package/dist/types/locales/ja.d.ts +0 -2
- package/dist/types/locales/ko.d.ts +0 -2
- package/dist/types/locales/nl.d.ts +0 -2
- package/dist/types/locales/no.d.ts +0 -2
- package/dist/types/locales/np.d.ts +0 -2
- package/dist/types/locales/pl.d.ts +0 -2
- package/dist/types/locales/pt-BR.d.ts +0 -2
- package/dist/types/locales/pt.d.ts +0 -2
- package/dist/types/locales/ro.d.ts +0 -2
- package/dist/types/locales/ru.d.ts +0 -2
- package/dist/types/locales/sk.d.ts +0 -2
- package/dist/types/locales/sr-Cyrl-RS.d.ts +0 -2
- package/dist/types/locales/sr-Latn-RS.d.ts +0 -2
- package/dist/types/locales/sv.d.ts +0 -2
- package/dist/types/locales/tr.d.ts +0 -2
- package/dist/types/locales/uk.d.ts +0 -2
- package/dist/types/locales/vi.d.ts +0 -2
- package/dist/types/locales/zh-Hans.d.ts +0 -2
- package/dist/types/locales/zh-Hant.d.ts +0 -2
- package/dist/types/menus/MRT_ColumnActionMenu.d.ts +0 -20
- package/dist/types/menus/MRT_FilterOptionMenu.d.ts +0 -13
- package/dist/types/menus/MRT_RowActionMenu.d.ts +0 -12
- package/dist/types/menus/MRT_ShowHideColumnsMenu.d.ts +0 -10
- package/dist/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +0 -12
- package/dist/types/menus/index.d.ts +0 -5
- package/dist/types/modals/MRT_EditRowModal.d.ts +0 -8
- package/dist/types/modals/index.d.ts +0 -1
- package/dist/types/sortingFns.d.ts +0 -12
- package/dist/types/style.utils.d.ts +0 -32
- package/dist/types/table/MRT_Table.d.ts +0 -7
- package/dist/types/table/MRT_TableContainer.d.ts +0 -7
- package/dist/types/table/MRT_TableLoadingOverlay.d.ts +0 -7
- package/dist/types/table/MRT_TablePaper.d.ts +0 -7
- package/dist/types/table/index.d.ts +0 -5
- package/dist/types/toolbar/MRT_BottomToolbar.d.ts +0 -7
- package/dist/types/toolbar/MRT_LinearProgressBar.d.ts +0 -8
- package/dist/types/toolbar/MRT_TablePagination.d.ts +0 -14
- package/dist/types/toolbar/MRT_ToolbarAlertBanner.d.ts +0 -8
- package/dist/types/toolbar/MRT_ToolbarDropZone.d.ts +0 -7
- package/dist/types/toolbar/MRT_ToolbarInternalButtons.d.ts +0 -7
- package/dist/types/toolbar/MRT_TopToolbar.d.ts +0 -6
- package/dist/types/toolbar/index.d.ts +0 -7
- package/dist/types/types.d.ts +0 -854
- package/dist/types/useMaterialReactTable.d.ts +0 -2
package/dist/index.js
CHANGED
@@ -684,7 +684,9 @@ const MRT_EditCellTextField = (_a) => {
|
|
684
684
|
? columnDef.header
|
685
685
|
: undefined, margin: "none", name: column.id, placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
|
686
686
|
? columnDef.header
|
687
|
-
: undefined, select: isSelectEdit, size: "small", value: value, variant: "standard" }, textFieldProps, { InputProps: Object.assign(Object.assign({
|
687
|
+
: undefined, select: isSelectEdit, size: "small", value: value, variant: "standard" }, textFieldProps, { InputProps: Object.assign(Object.assign(Object.assign({}, (textFieldProps.variant !== 'outlined'
|
688
|
+
? { disableUnderline: editDisplayMode === 'table' }
|
689
|
+
: {})), textFieldProps.InputProps), { sx: (theme) => {
|
688
690
|
var _a;
|
689
691
|
return (Object.assign({ mb: 0 }, parseFromValuesOrFunc((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.sx, theme)));
|
690
692
|
} }), inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
|
@@ -706,7 +708,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
706
708
|
var _b, _c, _d, _e, _f;
|
707
709
|
var { cell, measureElement, numRows, rowIndex, rowRef, table, virtualIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowIndex", "rowRef", "table", "virtualIndex"]);
|
708
710
|
const theme = styles.useTheme();
|
709
|
-
const { getState, options: { columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiSkeletonProps, muiTableBodyCellProps, rowNumberDisplayMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
711
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiSkeletonProps, muiTableBodyCellProps, rowNumberDisplayMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
710
712
|
const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
711
713
|
const { column, row } = cell;
|
712
714
|
const { columnDef } = column;
|
@@ -737,23 +739,23 @@ const MRT_TableBodyCell = (_a) => {
|
|
737
739
|
const isFirstColumn = getIsFirstColumn(column, table);
|
738
740
|
const isLastColumn = getIsLastColumn(column, table);
|
739
741
|
const isLastRow = numRows && rowIndex === numRows - 1;
|
740
|
-
const
|
741
|
-
|
742
|
+
const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
|
743
|
+
const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
|
742
744
|
const borderStyle = showResizeBorder
|
743
745
|
? `2px solid ${draggingBorderColor} !important`
|
744
746
|
: isDraggingColumn || isDraggingRow
|
745
747
|
? `1px dashed ${theme.palette.grey[500]} !important`
|
746
|
-
: isHoveredColumn ||
|
747
|
-
isHoveredRow ||
|
748
|
-
columnSizingInfo.isResizingColumn === column.id
|
748
|
+
: isHoveredColumn || isHoveredRow || isResizingColumn
|
749
749
|
? `2px dashed ${draggingBorderColor} !important`
|
750
750
|
: undefined;
|
751
751
|
if (showResizeBorder) {
|
752
|
-
return
|
752
|
+
return columnResizeDirection === 'ltr'
|
753
|
+
? { borderRight: borderStyle }
|
754
|
+
: { borderLeft: borderStyle };
|
753
755
|
}
|
754
756
|
return borderStyle
|
755
757
|
? {
|
756
|
-
borderBottom: isDraggingRow || isHoveredRow || isLastRow
|
758
|
+
borderBottom: isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn)
|
757
759
|
? borderStyle
|
758
760
|
: undefined,
|
759
761
|
borderLeft: isDraggingColumn ||
|
@@ -777,7 +779,8 @@ const MRT_TableBodyCell = (_a) => {
|
|
777
779
|
hoveredRow,
|
778
780
|
rowIndex,
|
779
781
|
]);
|
780
|
-
const isEditable =
|
782
|
+
const isEditable = !cell.getIsPlaceholder() &&
|
783
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
781
784
|
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
|
782
785
|
const isEditing = isEditable &&
|
783
786
|
!['custom', 'modal'].includes(editDisplayMode) &&
|
@@ -816,7 +819,8 @@ const MRT_TableBodyCell = (_a) => {
|
|
816
819
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
817
820
|
}
|
818
821
|
} }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
|
819
|
-
outline:
|
822
|
+
outline: (editDisplayMode === 'cell' && isEditable) ||
|
823
|
+
(editDisplayMode === 'table' && (isCreating || isEditing))
|
820
824
|
? `1px solid ${theme.palette.grey[500]}`
|
821
825
|
: undefined,
|
822
826
|
outlineOffset: '-1px',
|
@@ -1731,7 +1735,7 @@ const MRT_FilterTextField = (_a) => {
|
|
1731
1735
|
lineHeight: '0.8rem',
|
1732
1736
|
whiteSpace: 'nowrap',
|
1733
1737
|
},
|
1734
|
-
}, InputProps: endAdornment //hack because mui looks for
|
1738
|
+
}, InputProps: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
|
1735
1739
|
? { endAdornment, startAdornment }
|
1736
1740
|
: { startAdornment }, fullWidth: true, helperText: showChangeModeButton ? (jsxRuntime.jsx("label", { children: localization.filterMode.replace('{filterType}',
|
1737
1741
|
// @ts-ignore
|
@@ -1975,15 +1979,22 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
1975
1979
|
const MRT_TableHeadCellResizeHandle = (_a) => {
|
1976
1980
|
var _b;
|
1977
1981
|
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
1978
|
-
const { getState, options: { columnResizeMode }, setColumnSizingInfo, } = table;
|
1982
|
+
const { getState, options: { columnResizeDirection, columnResizeMode }, setColumnSizingInfo, } = table;
|
1979
1983
|
const { density } = getState();
|
1980
1984
|
const { column } = header;
|
1985
|
+
const mx = density === 'compact'
|
1986
|
+
? '-8px'
|
1987
|
+
: density === 'comfortable'
|
1988
|
+
? '-16px'
|
1989
|
+
: '-24px';
|
1990
|
+
const lr = column.columnDef.columnDefType === 'display' ? '4px' : '0';
|
1981
1991
|
return (jsxRuntime.jsx(Box__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
|
1982
1992
|
setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
|
1983
1993
|
column.resetSize();
|
1984
1994
|
}, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), style: {
|
1985
1995
|
transform: column.getIsResizing() && columnResizeMode === 'onEnd'
|
1986
|
-
? `translateX(${(
|
1996
|
+
? `translateX(${(columnResizeDirection === 'rtl' ? -1 : 1) *
|
1997
|
+
((_b = getState().columnSizingInfo.deltaOffset) !== null && _b !== void 0 ? _b : 0)}px)`
|
1987
1998
|
: undefined,
|
1988
1999
|
}, sx: (theme) => ({
|
1989
2000
|
'&:active > hr': {
|
@@ -1991,15 +2002,13 @@ const MRT_TableHeadCellResizeHandle = (_a) => {
|
|
1991
2002
|
opacity: header.subHeaders.length || columnResizeMode === 'onEnd' ? 1 : 0,
|
1992
2003
|
},
|
1993
2004
|
cursor: 'col-resize',
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
? '-20px'
|
1998
|
-
: '-28px',
|
2005
|
+
left: columnResizeDirection === 'rtl' ? lr : undefined,
|
2006
|
+
ml: columnResizeDirection === 'rtl' ? mx : undefined,
|
2007
|
+
mr: columnResizeDirection === 'ltr' ? mx : undefined,
|
1999
2008
|
position: 'absolute',
|
2000
2009
|
px: '4px',
|
2001
|
-
right:
|
2002
|
-
}), children: jsxRuntime.jsx(Divider__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transition: column.getIsResizing()
|
2010
|
+
right: columnResizeDirection === 'ltr' ? lr : undefined,
|
2011
|
+
}), children: jsxRuntime.jsx(Divider__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transform: 'translateX(4px)', transition: column.getIsResizing()
|
2003
2012
|
? undefined
|
2004
2013
|
: 'all 150ms ease-in-out', userSelect: 'none', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) }) }));
|
2005
2014
|
};
|
@@ -2042,7 +2051,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
2042
2051
|
var _b, _c, _d, _f, _g, _h;
|
2043
2052
|
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
2044
2053
|
const theme = styles.useTheme();
|
2045
|
-
const { getState, options: { columnFilterDisplayMode, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
2054
|
+
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
2046
2055
|
const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
2047
2056
|
const { column } = header;
|
2048
2057
|
const { columnDef } = column;
|
@@ -2083,7 +2092,9 @@ const MRT_TableHeadCell = (_a) => {
|
|
2083
2092
|
? `2px dashed ${draggingBorderColor}`
|
2084
2093
|
: undefined;
|
2085
2094
|
if (showResizeBorder) {
|
2086
|
-
return
|
2095
|
+
return columnResizeDirection === 'ltr'
|
2096
|
+
? { borderRight: borderStyle }
|
2097
|
+
: { borderLeft: borderStyle };
|
2087
2098
|
}
|
2088
2099
|
const draggingBorders = borderStyle
|
2089
2100
|
? {
|
@@ -2176,7 +2187,9 @@ const MRT_TableHeadCell = (_a) => {
|
|
2176
2187
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
2177
2188
|
? 'nowrap'
|
2178
2189
|
: 'normal',
|
2179
|
-
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
2190
|
+
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
2191
|
+
whiteSpace: 'nowrap',
|
2192
|
+
}, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
2180
2193
|
current: tableHeadCellRefs.current[column.id],
|
2181
2194
|
} })), showColumnActions && (jsxRuntime.jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
2182
2195
|
};
|
@@ -2225,7 +2238,7 @@ const MRT_TablePagination = (_a) => {
|
|
2225
2238
|
const showFirstLastPageButtons = numberOfPages > 2;
|
2226
2239
|
const firstRowIndex = pageIndex * pageSize;
|
2227
2240
|
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
2228
|
-
const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
2241
|
+
const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
2229
2242
|
return (jsxRuntime.jsxs(Box__default["default"], { className: "MuiTablePagination-root", sx: {
|
2230
2243
|
alignItems: 'center',
|
2231
2244
|
display: 'flex',
|
@@ -2242,17 +2255,17 @@ const MRT_TablePagination = (_a) => {
|
|
2242
2255
|
px: '8px',
|
2243
2256
|
py: '12px',
|
2244
2257
|
zIndex: 2,
|
2245
|
-
}, children: [showRowsPerPage && (jsxRuntime.jsxs(Box__default["default"], { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsxRuntime.jsx(InputLabel__default["default"], { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsxRuntime.jsx(Select__default["default"], Object.assign({ disableUnderline: true, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
|
2258
|
+
}, children: [showRowsPerPage && (jsxRuntime.jsxs(Box__default["default"], { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsxRuntime.jsx(InputLabel__default["default"], { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsxRuntime.jsx(Select__default["default"], Object.assign({ disableUnderline: true, disabled: disabled, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
|
2246
2259
|
var _a;
|
2247
2260
|
const value = typeof option !== 'number' ? option.value : option;
|
2248
2261
|
const label = typeof option !== 'number' ? option.label : `${option}`;
|
2249
2262
|
return ((_a = SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.children) !== null && _a !== void 0 ? _a : ((SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) ? (jsxRuntime.jsx("option", { value: value, children: label }, value)) : (jsxRuntime.jsx(MenuItem__default["default"], { sx: { m: 0 }, value: value, children: label }, value))));
|
2250
|
-
}) }))] })), paginationDisplayMode === 'pages' ? (jsxRuntime.jsx(Pagination__default["default"], Object.assign({ count: numberOfPages, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsxRuntime.jsx(PaginationItem__default["default"], Object.assign({ slots: {
|
2263
|
+
}) }))] })), paginationDisplayMode === 'pages' ? (jsxRuntime.jsx(Pagination__default["default"], Object.assign({ count: numberOfPages, disabled: disabled, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsxRuntime.jsx(PaginationItem__default["default"], Object.assign({ slots: {
|
2251
2264
|
first: FirstPageIcon,
|
2252
2265
|
last: LastPageIcon,
|
2253
2266
|
next: ChevronRightIcon,
|
2254
2267
|
previous: ChevronLeftIcon,
|
2255
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) })), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }), showLastButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
2268
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) })), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }), showLastButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
2256
2269
|
};
|
2257
2270
|
|
2258
2271
|
const MRT_GlobalFilterTextField = (_a) => {
|
@@ -3068,225 +3081,579 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
3068
3081
|
['modal', 'row'].includes(editDisplayMode) ? (jsxRuntime.jsx(Tooltip__default["default"], { placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(EditIcon, {}) })) })) : renderRowActionMenuItems ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(MoreHorizIcon, {}) })) }), jsxRuntime.jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
|
3069
3082
|
};
|
3070
3083
|
|
3071
|
-
const
|
3072
|
-
|
3073
|
-
const
|
3074
|
-
const
|
3075
|
-
|
3076
|
-
|
3077
|
-
|
3078
|
-
|
3084
|
+
const useMRT_DisplayColumns = (params) => {
|
3085
|
+
var _a, _b, _c, _d;
|
3086
|
+
const { columnOrder, creatingRow, grouping, tableOptions } = params;
|
3087
|
+
const order = (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder;
|
3088
|
+
return react.useMemo(() => [
|
3089
|
+
makeRowPinColumn,
|
3090
|
+
makeRowDragColumn,
|
3091
|
+
makeRowActionsColumn,
|
3092
|
+
makeRowExpandColumn,
|
3093
|
+
makeRowSelectColumn,
|
3094
|
+
makeRowNumbersColumn,
|
3095
|
+
makeSpacerColumn,
|
3096
|
+
]
|
3097
|
+
.map((makeCol) => makeCol(params, order))
|
3098
|
+
.filter(Boolean), [
|
3099
|
+
columnOrder,
|
3100
|
+
creatingRow,
|
3101
|
+
grouping,
|
3102
|
+
tableOptions.displayColumnDefOptions,
|
3103
|
+
tableOptions.editDisplayMode,
|
3104
|
+
tableOptions.enableColumnDragging,
|
3105
|
+
tableOptions.enableColumnFilterModes,
|
3106
|
+
tableOptions.enableColumnOrdering,
|
3107
|
+
tableOptions.enableEditing,
|
3108
|
+
tableOptions.enableExpandAll,
|
3109
|
+
tableOptions.enableExpanding,
|
3110
|
+
tableOptions.enableGrouping,
|
3111
|
+
tableOptions.enableRowActions,
|
3112
|
+
tableOptions.enableRowDragging,
|
3113
|
+
tableOptions.enableRowNumbers,
|
3114
|
+
tableOptions.enableRowOrdering,
|
3115
|
+
tableOptions.enableRowSelection,
|
3116
|
+
tableOptions.enableSelectAll,
|
3117
|
+
tableOptions.localization,
|
3118
|
+
tableOptions.positionActionsColumn,
|
3119
|
+
tableOptions.renderDetailPanel,
|
3120
|
+
tableOptions.renderRowActionMenuItems,
|
3121
|
+
tableOptions.renderRowActions,
|
3122
|
+
(_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.columnOrder,
|
3123
|
+
(_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.grouping,
|
3124
|
+
]);
|
3079
3125
|
};
|
3080
|
-
|
3081
|
-
|
3082
|
-
|
3083
|
-
|
3084
|
-
|
3085
|
-
.
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
.
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
.
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
equals,
|
3148
|
-
fuzzy,
|
3149
|
-
greaterThan,
|
3150
|
-
greaterThanOrEqualTo,
|
3151
|
-
lessThan,
|
3152
|
-
lessThanOrEqualTo,
|
3153
|
-
notEmpty,
|
3154
|
-
notEquals,
|
3155
|
-
startsWith });
|
3126
|
+
function defaultDisplayColumnProps({ defaultDisplayColumn, displayColumnDefOptions, localization, }, id, header, size = 60) {
|
3127
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
|
3128
|
+
}
|
3129
|
+
function makeRowPinColumn({ tableOptions }, order) {
|
3130
|
+
const id = 'mrt-row-pin';
|
3131
|
+
if (order.includes(id)) {
|
3132
|
+
return Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_TableBodyRowPinButton, { row: row, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'pin'));
|
3133
|
+
}
|
3134
|
+
return null;
|
3135
|
+
}
|
3136
|
+
function makeRowDragColumn({ tableOptions }, order) {
|
3137
|
+
const id = 'mrt-row-drag';
|
3138
|
+
if (order.includes(id)) {
|
3139
|
+
return Object.assign({ Cell: ({ row, rowRef, table }) => (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'move'));
|
3140
|
+
}
|
3141
|
+
return null;
|
3142
|
+
}
|
3143
|
+
function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
|
3144
|
+
const id = 'mrt-row-actions';
|
3145
|
+
if (order.includes(id) ||
|
3146
|
+
(creatingRow && tableOptions.createDisplayMode === 'row')) {
|
3147
|
+
return Object.assign({ Cell: ({ cell, row, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'actions'));
|
3148
|
+
}
|
3149
|
+
return null;
|
3150
|
+
}
|
3151
|
+
function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
3152
|
+
var _a, _b;
|
3153
|
+
const id = 'mrt-row-expand';
|
3154
|
+
if (order.includes(id) &&
|
3155
|
+
showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
|
3156
|
+
return Object.assign({ Cell: ({ row, table }) => jsxRuntime.jsx(MRT_ExpandButton, { row: row, table: table }), Header: tableOptions.enableExpandAll
|
3157
|
+
? ({ table }) => jsxRuntime.jsx(MRT_ExpandAllButton, { table: table })
|
3158
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand'));
|
3159
|
+
}
|
3160
|
+
return null;
|
3161
|
+
}
|
3162
|
+
function makeRowSelectColumn({ tableOptions }, order) {
|
3163
|
+
const id = 'mrt-row-select';
|
3164
|
+
if (order.includes(id)) {
|
3165
|
+
return Object.assign({ Cell: ({ row, table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
3166
|
+
? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
3167
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
|
3168
|
+
}
|
3169
|
+
return null;
|
3170
|
+
}
|
3171
|
+
function makeRowNumbersColumn({ tableOptions }, order) {
|
3172
|
+
const id = 'mrt-row-numbers';
|
3173
|
+
if (order.includes(id) || tableOptions.enableRowNumbers)
|
3174
|
+
return Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
|
3175
|
+
return null;
|
3176
|
+
}
|
3177
|
+
const blankColProps = {
|
3178
|
+
children: null,
|
3179
|
+
sx: {
|
3180
|
+
flex: '1 0 auto',
|
3181
|
+
minWidth: 0,
|
3182
|
+
p: 0,
|
3183
|
+
width: 0,
|
3184
|
+
},
|
3185
|
+
};
|
3186
|
+
function makeSpacerColumn({ tableOptions }, order) {
|
3187
|
+
const id = 'mrt-row-spacer';
|
3188
|
+
if (order.includes(id)) {
|
3189
|
+
return Object.assign(Object.assign({}, defaultDisplayColumnProps(tableOptions, id, undefined, 0)), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
|
3190
|
+
}
|
3191
|
+
return null;
|
3192
|
+
}
|
3156
3193
|
|
3157
|
-
const
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
|
3171
|
-
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3177
|
-
|
3178
|
-
|
3179
|
-
|
3180
|
-
|
3181
|
-
|
3182
|
-
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3194
|
+
const useMRT_Effects = (table) => {
|
3195
|
+
const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
|
3196
|
+
const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
3197
|
+
const rerender = react.useReducer(() => ({}), {})[1];
|
3198
|
+
const isMounted = react.useRef(false);
|
3199
|
+
const initialBodyHeight = react.useRef();
|
3200
|
+
const previousTop = react.useRef();
|
3201
|
+
react.useEffect(() => {
|
3202
|
+
if (typeof window !== 'undefined') {
|
3203
|
+
initialBodyHeight.current = document.body.style.height;
|
3204
|
+
}
|
3205
|
+
}, []);
|
3206
|
+
react.useEffect(() => {
|
3207
|
+
if (isMounted && typeof window !== 'undefined') {
|
3208
|
+
if (isFullScreen) {
|
3209
|
+
previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
|
3210
|
+
document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
|
3211
|
+
}
|
3212
|
+
else {
|
3213
|
+
document.body.style.height = initialBodyHeight.current;
|
3214
|
+
if (!previousTop.current)
|
3215
|
+
return;
|
3216
|
+
//restore scroll position
|
3217
|
+
window.scrollTo({
|
3218
|
+
behavior: 'instant',
|
3219
|
+
top: -1 * previousTop.current,
|
3220
|
+
});
|
3221
|
+
}
|
3222
|
+
}
|
3223
|
+
isMounted.current = true;
|
3224
|
+
}, [isFullScreen]);
|
3225
|
+
//if page index is out of bounds, set it to the last page
|
3226
|
+
react.useEffect(() => {
|
3227
|
+
if (!enablePagination || isLoading || showSkeletons)
|
3228
|
+
return;
|
3229
|
+
const { pageIndex, pageSize } = pagination;
|
3230
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
|
3231
|
+
const firstVisibleRowIndex = pageIndex * pageSize;
|
3232
|
+
if (firstVisibleRowIndex > totalRowCount) {
|
3233
|
+
table.setPageIndex(Math.floor(totalRowCount / pageSize));
|
3234
|
+
}
|
3235
|
+
}, [rowCount, table.getPrePaginationRowModel().rows.length]);
|
3236
|
+
//turn off sort when global filter is looking for ranked results
|
3237
|
+
const appliedSort = react.useRef(sorting);
|
3238
|
+
react.useEffect(() => {
|
3239
|
+
if (sorting.length) {
|
3240
|
+
appliedSort.current = sorting;
|
3241
|
+
}
|
3242
|
+
}, [sorting]);
|
3243
|
+
react.useEffect(() => {
|
3244
|
+
if (!getCanRankRows(table))
|
3245
|
+
return;
|
3246
|
+
if (globalFilter) {
|
3247
|
+
table.setSorting([]);
|
3248
|
+
}
|
3249
|
+
else {
|
3250
|
+
table.setSorting(() => appliedSort.current || []);
|
3251
|
+
}
|
3252
|
+
}, [globalFilter]);
|
3253
|
+
react.useEffect(() => {
|
3254
|
+
if (enableRowPinning && getIsSomeRowsPinned()) {
|
3255
|
+
setTimeout(() => {
|
3256
|
+
rerender();
|
3257
|
+
}, 150);
|
3258
|
+
}
|
3259
|
+
}, [density]);
|
3191
3260
|
};
|
3192
3261
|
|
3193
|
-
const
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
|
3203
|
-
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
|
3226
|
-
|
3227
|
-
|
3228
|
-
|
3229
|
-
|
3230
|
-
|
3231
|
-
|
3232
|
-
|
3233
|
-
|
3234
|
-
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3262
|
+
const useMRT_TableInstance = (tableOptions) => {
|
3263
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
3264
|
+
const bottomToolbarRef = react.useRef(null);
|
3265
|
+
const editInputRefs = react.useRef({});
|
3266
|
+
const filterInputRefs = react.useRef({});
|
3267
|
+
const searchInputRef = react.useRef(null);
|
3268
|
+
const tableContainerRef = react.useRef(null);
|
3269
|
+
const tableHeadCellRefs = react.useRef({});
|
3270
|
+
const tablePaperRef = react.useRef(null);
|
3271
|
+
const topToolbarRef = react.useRef(null);
|
3272
|
+
const tableHeadRef = react.useRef(null);
|
3273
|
+
const tableFooterRef = react.useRef(null);
|
3274
|
+
const initialState = react.useMemo(() => {
|
3275
|
+
var _a, _b, _c;
|
3276
|
+
const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
|
3277
|
+
initState.columnOrder =
|
3278
|
+
(_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
|
3279
|
+
initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
|
3280
|
+
return initState;
|
3281
|
+
}, []);
|
3282
|
+
const [creatingRow, _setCreatingRow] = react.useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
|
3283
|
+
const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
|
3284
|
+
var _a, _b, _c, _d;
|
3285
|
+
return ({
|
3286
|
+
[getColumnId(col)]: col.filterFn instanceof Function
|
3287
|
+
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
3288
|
+
: (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
|
3289
|
+
});
|
3290
|
+
})));
|
3291
|
+
const [columnOrder, setColumnOrder] = react.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
|
3292
|
+
const [density, setDensity] = react.useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
|
3293
|
+
const [draggingColumn, setDraggingColumn] = react.useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
|
3294
|
+
const [draggingRow, setDraggingRow] = react.useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
|
3295
|
+
const [editingCell, setEditingCell] = react.useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
|
3296
|
+
const [editingRow, setEditingRow] = react.useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
|
3297
|
+
const [globalFilterFn, setGlobalFilterFn] = react.useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
|
3298
|
+
const [grouping, setGrouping] = react.useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
|
3299
|
+
const [hoveredColumn, setHoveredColumn] = react.useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
|
3300
|
+
const [hoveredRow, setHoveredRow] = react.useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
|
3301
|
+
const [isFullScreen, setIsFullScreen] = react.useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
|
3302
|
+
const [showAlertBanner, setShowAlertBanner] = react.useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
|
3303
|
+
const [showColumnFilters, setShowColumnFilters] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
|
3304
|
+
const [showGlobalFilter, setShowGlobalFilter] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
|
3305
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
|
3306
|
+
const displayColumns = useMRT_DisplayColumns({
|
3307
|
+
columnOrder,
|
3308
|
+
creatingRow,
|
3309
|
+
grouping,
|
3310
|
+
tableOptions,
|
3311
|
+
});
|
3312
|
+
const columnDefs = react.useMemo(() => {
|
3313
|
+
var _a, _b, _c;
|
3314
|
+
return prepareColumns({
|
3315
|
+
aggregationFns: tableOptions.aggregationFns,
|
3316
|
+
columnDefs: [...displayColumns, ...tableOptions.columns],
|
3317
|
+
columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
|
3318
|
+
defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
|
3319
|
+
filterFns: tableOptions.filterFns,
|
3320
|
+
sortingFns: tableOptions.sortingFns,
|
3321
|
+
});
|
3322
|
+
}, [
|
3323
|
+
columnFilterFns,
|
3324
|
+
displayColumns,
|
3325
|
+
tableOptions.columns,
|
3326
|
+
(_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
|
3327
|
+
]);
|
3328
|
+
const data = react.useMemo(() => {
|
3329
|
+
var _a, _b, _c, _d, _e;
|
3330
|
+
return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
|
3331
|
+
!tableOptions.data.length
|
3332
|
+
? [
|
3333
|
+
...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
|
3334
|
+
((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
|
3335
|
+
10).fill(null),
|
3336
|
+
].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
|
3337
|
+
[getColumnId(col)]: null,
|
3338
|
+
}))))
|
3339
|
+
: tableOptions.data;
|
3340
|
+
}, [
|
3341
|
+
tableOptions.data,
|
3342
|
+
(_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
|
3343
|
+
(_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
|
3344
|
+
]);
|
3345
|
+
//@ts-ignore
|
3346
|
+
const table = reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
|
3347
|
+
? reactTable.getExpandedRowModel()
|
3348
|
+
: undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
|
3349
|
+
? reactTable.getFacetedMinMaxValues()
|
3350
|
+
: undefined, getFacetedRowModel: tableOptions.enableFacetedValues
|
3351
|
+
? reactTable.getFacetedRowModel()
|
3352
|
+
: undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
|
3353
|
+
? reactTable.getFacetedUniqueValues()
|
3354
|
+
: undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
|
3355
|
+
tableOptions.enableGlobalFilter ||
|
3356
|
+
tableOptions.enableFilters
|
3357
|
+
? reactTable.getFilteredRowModel()
|
3358
|
+
: undefined, getGroupedRowModel: tableOptions.enableGrouping
|
3359
|
+
? reactTable.getGroupedRowModel()
|
3360
|
+
: undefined, getPaginationRowModel: tableOptions.enablePagination
|
3361
|
+
? reactTable.getPaginationRowModel()
|
3362
|
+
: undefined, getSortedRowModel: tableOptions.enableSorting
|
3363
|
+
? reactTable.getSortedRowModel()
|
3364
|
+
: undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping }, tableOptions), {
|
3365
|
+
//@ts-ignore
|
3366
|
+
columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ columnFilterFns,
|
3367
|
+
columnOrder,
|
3368
|
+
creatingRow,
|
3369
|
+
density,
|
3370
|
+
draggingColumn,
|
3371
|
+
draggingRow,
|
3372
|
+
editingCell,
|
3373
|
+
editingRow,
|
3374
|
+
globalFilterFn,
|
3375
|
+
grouping,
|
3376
|
+
hoveredColumn,
|
3377
|
+
hoveredRow,
|
3378
|
+
isFullScreen,
|
3379
|
+
showAlertBanner,
|
3380
|
+
showColumnFilters,
|
3381
|
+
showGlobalFilter,
|
3382
|
+
showToolbarDropZone }, tableOptions.state) }));
|
3383
|
+
// @ts-ignore
|
3384
|
+
table.refs = {
|
3385
|
+
// @ts-ignore
|
3386
|
+
bottomToolbarRef,
|
3387
|
+
editInputRefs,
|
3388
|
+
filterInputRefs,
|
3389
|
+
// @ts-ignore
|
3390
|
+
searchInputRef,
|
3391
|
+
// @ts-ignore
|
3392
|
+
tableContainerRef,
|
3393
|
+
// @ts-ignore
|
3394
|
+
tableFooterRef,
|
3395
|
+
tableHeadCellRefs,
|
3396
|
+
// @ts-ignore
|
3397
|
+
tableHeadRef,
|
3398
|
+
// @ts-ignore
|
3399
|
+
tablePaperRef,
|
3400
|
+
// @ts-ignore
|
3401
|
+
topToolbarRef,
|
3402
|
+
};
|
3403
|
+
const setCreatingRow = (row) => {
|
3404
|
+
var _a, _b;
|
3405
|
+
let _row = row;
|
3406
|
+
if (row === true) {
|
3407
|
+
_row = createRow(table);
|
3408
|
+
}
|
3409
|
+
(_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
|
3410
|
+
};
|
3411
|
+
table.setCreatingRow = setCreatingRow;
|
3412
|
+
table.setColumnFilterFns =
|
3413
|
+
(_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
|
3414
|
+
table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
|
3415
|
+
table.setDraggingColumn =
|
3416
|
+
(_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
|
3417
|
+
table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
|
3418
|
+
table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
|
3419
|
+
table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
|
3420
|
+
table.setGlobalFilterFn =
|
3421
|
+
(_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
|
3422
|
+
table.setHoveredColumn =
|
3423
|
+
(_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
|
3424
|
+
table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
|
3425
|
+
table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
|
3426
|
+
table.setShowAlertBanner =
|
3427
|
+
(_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
|
3428
|
+
table.setShowColumnFilters =
|
3429
|
+
(_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
|
3430
|
+
table.setShowGlobalFilter =
|
3431
|
+
(_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
|
3432
|
+
table.setShowToolbarDropZone =
|
3433
|
+
(_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
|
3434
|
+
useMRT_Effects(table);
|
3435
|
+
return table;
|
3283
3436
|
};
|
3284
3437
|
|
3285
|
-
const
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3438
|
+
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
3439
|
+
|
3440
|
+
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
3441
|
+
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), filterValue, {
|
3442
|
+
threshold: matchSorterUtils.rankings.MATCHES,
|
3443
|
+
});
|
3444
|
+
addMeta(itemRank);
|
3445
|
+
return itemRank.passed;
|
3446
|
+
};
|
3447
|
+
fuzzy.autoRemove = (val) => !val;
|
3448
|
+
const contains = (row, id, filterValue) => row
|
3449
|
+
.getValue(id)
|
3450
|
+
.toString()
|
3451
|
+
.toLowerCase()
|
3452
|
+
.trim()
|
3453
|
+
.includes(filterValue.toString().toLowerCase().trim());
|
3454
|
+
contains.autoRemove = (val) => !val;
|
3455
|
+
const startsWith = (row, id, filterValue) => row
|
3456
|
+
.getValue(id)
|
3457
|
+
.toString()
|
3458
|
+
.toLowerCase()
|
3459
|
+
.trim()
|
3460
|
+
.startsWith(filterValue.toString().toLowerCase().trim());
|
3461
|
+
startsWith.autoRemove = (val) => !val;
|
3462
|
+
const endsWith = (row, id, filterValue) => row
|
3463
|
+
.getValue(id)
|
3464
|
+
.toString()
|
3465
|
+
.toLowerCase()
|
3466
|
+
.trim()
|
3467
|
+
.endsWith(filterValue.toString().toLowerCase().trim());
|
3468
|
+
endsWith.autoRemove = (val) => !val;
|
3469
|
+
const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
|
3470
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3471
|
+
equals.autoRemove = (val) => !val;
|
3472
|
+
const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
|
3473
|
+
filterValue.toString().toLowerCase().trim();
|
3474
|
+
notEquals.autoRemove = (val) => !val;
|
3475
|
+
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3476
|
+
? +row.getValue(id) > +filterValue
|
3477
|
+
: row.getValue(id).toString().toLowerCase().trim() >
|
3478
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3479
|
+
greaterThan.autoRemove = (val) => !val;
|
3480
|
+
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
3481
|
+
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
3482
|
+
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3483
|
+
? +row.getValue(id) < +filterValue
|
3484
|
+
: row.getValue(id).toString().toLowerCase().trim() <
|
3485
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3486
|
+
lessThan.autoRemove = (val) => !val;
|
3487
|
+
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
3488
|
+
lessThanOrEqualTo.autoRemove = (val) => !val;
|
3489
|
+
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
3490
|
+
greaterThan(row, id, filterValues[0])) &&
|
3491
|
+
((!isNaN(+filterValues[0]) &&
|
3492
|
+
!isNaN(+filterValues[1]) &&
|
3493
|
+
+filterValues[0] > +filterValues[1]) ||
|
3494
|
+
['', undefined].includes(filterValues[1]) ||
|
3495
|
+
lessThan(row, id, filterValues[1]));
|
3496
|
+
between.autoRemove = (val) => !val;
|
3497
|
+
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
3498
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
3499
|
+
((!isNaN(+filterValues[0]) &&
|
3500
|
+
!isNaN(+filterValues[1]) &&
|
3501
|
+
+filterValues[0] > +filterValues[1]) ||
|
3502
|
+
['', undefined].includes(filterValues[1]) ||
|
3503
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
3504
|
+
betweenInclusive.autoRemove = (val) => !val;
|
3505
|
+
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
3506
|
+
empty.autoRemove = (val) => !val;
|
3507
|
+
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
3508
|
+
notEmpty.autoRemove = (val) => !val;
|
3509
|
+
const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
|
3510
|
+
betweenInclusive,
|
3511
|
+
contains,
|
3512
|
+
empty,
|
3513
|
+
endsWith,
|
3514
|
+
equals,
|
3515
|
+
fuzzy,
|
3516
|
+
greaterThan,
|
3517
|
+
greaterThanOrEqualTo,
|
3518
|
+
lessThan,
|
3519
|
+
lessThanOrEqualTo,
|
3520
|
+
notEmpty,
|
3521
|
+
notEquals,
|
3522
|
+
startsWith });
|
3523
|
+
|
3524
|
+
const MRT_Default_Icons = {
|
3525
|
+
ArrowDownwardIcon: ArrowDownwardIcon__default["default"],
|
3526
|
+
ArrowRightIcon: ArrowRightIcon__default["default"],
|
3527
|
+
CancelIcon: CancelIcon__default["default"],
|
3528
|
+
ChevronLeftIcon: ChevronLeftIcon__default["default"],
|
3529
|
+
ChevronRightIcon: ChevronRightIcon__default["default"],
|
3530
|
+
ClearAllIcon: ClearAllIcon__default["default"],
|
3531
|
+
CloseIcon: CloseIcon__default["default"],
|
3532
|
+
DensityLargeIcon: DensityLargeIcon__default["default"],
|
3533
|
+
DensityMediumIcon: DensityMediumIcon__default["default"],
|
3534
|
+
DensitySmallIcon: DensitySmallIcon__default["default"],
|
3535
|
+
DragHandleIcon: DragHandleIcon__default["default"],
|
3536
|
+
DynamicFeedIcon: DynamicFeedIcon__default["default"],
|
3537
|
+
EditIcon: EditIcon__default["default"],
|
3538
|
+
ExpandMoreIcon: ExpandMoreIcon__default["default"],
|
3539
|
+
FilterAltIcon: FilterAltIcon__default["default"],
|
3540
|
+
FilterListIcon: FilterListIcon__default["default"],
|
3541
|
+
FilterListOffIcon: FilterListOffIcon__default["default"],
|
3542
|
+
FirstPageIcon: FirstPageIcon__default["default"],
|
3543
|
+
FullscreenExitIcon: FullscreenExitIcon__default["default"],
|
3544
|
+
FullscreenIcon: FullscreenIcon__default["default"],
|
3545
|
+
KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDownIcon__default["default"],
|
3546
|
+
LastPageIcon: LastPageIcon__default["default"],
|
3547
|
+
MoreHorizIcon: MoreHorizIcon__default["default"],
|
3548
|
+
MoreVertIcon: MoreVertIcon__default["default"],
|
3549
|
+
PushPinIcon: PushPinIcon__default["default"],
|
3550
|
+
RestartAltIcon: RestartAltIcon__default["default"],
|
3551
|
+
SaveIcon: SaveIcon__default["default"],
|
3552
|
+
SearchIcon: SearchIcon__default["default"],
|
3553
|
+
SearchOffIcon: SearchOffIcon__default["default"],
|
3554
|
+
SortIcon: SortIcon__default["default"],
|
3555
|
+
SyncAltIcon: SyncAltIcon__default["default"],
|
3556
|
+
ViewColumnIcon: ViewColumnIcon__default["default"],
|
3557
|
+
VisibilityOffIcon: VisibilityOffIcon__default["default"],
|
3558
|
+
};
|
3559
|
+
|
3560
|
+
const MRT_Localization_EN = {
|
3561
|
+
actions: 'Actions',
|
3562
|
+
and: 'and',
|
3563
|
+
cancel: 'Cancel',
|
3564
|
+
changeFilterMode: 'Change filter mode',
|
3565
|
+
changeSearchMode: 'Change search mode',
|
3566
|
+
clearFilter: 'Clear filter',
|
3567
|
+
clearSearch: 'Clear search',
|
3568
|
+
clearSort: 'Clear sort',
|
3569
|
+
clickToCopy: 'Click to copy',
|
3570
|
+
collapse: 'Collapse',
|
3571
|
+
collapseAll: 'Collapse all',
|
3572
|
+
columnActions: 'Column Actions',
|
3573
|
+
copiedToClipboard: 'Copied to clipboard',
|
3574
|
+
dropToGroupBy: 'Drop to group by {column}',
|
3575
|
+
edit: 'Edit',
|
3576
|
+
expand: 'Expand',
|
3577
|
+
expandAll: 'Expand all',
|
3578
|
+
filterArrIncludes: 'Includes',
|
3579
|
+
filterArrIncludesAll: 'Includes all',
|
3580
|
+
filterArrIncludesSome: 'Includes',
|
3581
|
+
filterBetween: 'Between',
|
3582
|
+
filterBetweenInclusive: 'Between Inclusive',
|
3583
|
+
filterByColumn: 'Filter by {column}',
|
3584
|
+
filterContains: 'Contains',
|
3585
|
+
filterEmpty: 'Empty',
|
3586
|
+
filterEndsWith: 'Ends With',
|
3587
|
+
filterEquals: 'Equals',
|
3588
|
+
filterEqualsString: 'Equals',
|
3589
|
+
filterFuzzy: 'Fuzzy',
|
3590
|
+
filterGreaterThan: 'Greater Than',
|
3591
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
3592
|
+
filterInNumberRange: 'Between',
|
3593
|
+
filterIncludesString: 'Contains',
|
3594
|
+
filterIncludesStringSensitive: 'Contains',
|
3595
|
+
filterLessThan: 'Less Than',
|
3596
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
3597
|
+
filterMode: 'Filter Mode: {filterType}',
|
3598
|
+
filterNotEmpty: 'Not Empty',
|
3599
|
+
filterNotEquals: 'Not Equals',
|
3600
|
+
filterStartsWith: 'Starts With',
|
3601
|
+
filterWeakEquals: 'Equals',
|
3602
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
3603
|
+
goToFirstPage: 'Go to first page',
|
3604
|
+
goToLastPage: 'Go to last page',
|
3605
|
+
goToNextPage: 'Go to next page',
|
3606
|
+
goToPreviousPage: 'Go to previous page',
|
3607
|
+
grab: 'Grab',
|
3608
|
+
groupByColumn: 'Group by {column}',
|
3609
|
+
groupedBy: 'Grouped by ',
|
3610
|
+
hideAll: 'Hide all',
|
3611
|
+
hideColumn: 'Hide {column} column',
|
3612
|
+
max: 'Max',
|
3613
|
+
min: 'Min',
|
3614
|
+
move: 'Move',
|
3615
|
+
noRecordsToDisplay: 'No records to display',
|
3616
|
+
noResultsFound: 'No results found',
|
3617
|
+
of: 'of',
|
3618
|
+
or: 'or',
|
3619
|
+
pin: 'Pin',
|
3620
|
+
pinToLeft: 'Pin to left',
|
3621
|
+
pinToRight: 'Pin to right',
|
3622
|
+
resetColumnSize: 'Reset column size',
|
3623
|
+
resetOrder: 'Reset order',
|
3624
|
+
rowActions: 'Row Actions',
|
3625
|
+
rowNumber: '#',
|
3626
|
+
rowNumbers: 'Row Numbers',
|
3627
|
+
rowsPerPage: 'Rows per page',
|
3628
|
+
save: 'Save',
|
3629
|
+
search: 'Search',
|
3630
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
3631
|
+
select: 'Select',
|
3632
|
+
showAll: 'Show all',
|
3633
|
+
showAllColumns: 'Show all columns',
|
3634
|
+
showHideColumns: 'Show/Hide columns',
|
3635
|
+
showHideFilters: 'Show/Hide filters',
|
3636
|
+
showHideSearch: 'Show/Hide search',
|
3637
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
3638
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
3639
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
3640
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
3641
|
+
thenBy: ', then by ',
|
3642
|
+
toggleDensity: 'Toggle density',
|
3643
|
+
toggleFullScreen: 'Toggle full screen',
|
3644
|
+
toggleSelectAll: 'Toggle select all',
|
3645
|
+
toggleSelectRow: 'Toggle select row',
|
3646
|
+
toggleVisibility: 'Toggle visibility',
|
3647
|
+
ungroupByColumn: 'Ungroup by {column}',
|
3648
|
+
unpin: 'Unpin',
|
3649
|
+
unpinAll: 'Unpin all',
|
3650
|
+
};
|
3651
|
+
|
3652
|
+
const MRT_DefaultColumn = {
|
3653
|
+
filterVariant: 'text',
|
3654
|
+
maxSize: 1000,
|
3655
|
+
minSize: 40,
|
3656
|
+
size: 180,
|
3290
3657
|
};
|
3291
3658
|
const MRT_DefaultDisplayColumn = {
|
3292
3659
|
columnDefType: 'display',
|
@@ -3304,7 +3671,8 @@ const MRT_DefaultDisplayColumn = {
|
|
3304
3671
|
};
|
3305
3672
|
const useMRT_TableOptions = (_a) => {
|
3306
3673
|
var _b;
|
3307
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
3674
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
3675
|
+
const theme = material.useTheme();
|
3308
3676
|
const _icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
3309
3677
|
const _localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
3310
3678
|
const _aggregationFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
@@ -3312,6 +3680,9 @@ const useMRT_TableOptions = (_a) => {
|
|
3312
3680
|
const _sortingFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
3313
3681
|
const _defaultColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
|
3314
3682
|
const _defaultDisplayColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
|
3683
|
+
if (!columnResizeDirection) {
|
3684
|
+
columnResizeDirection = theme.direction || 'ltr';
|
3685
|
+
}
|
3315
3686
|
layoutMode =
|
3316
3687
|
layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
|
3317
3688
|
if (layoutMode === 'semantic' &&
|
@@ -3332,6 +3703,7 @@ const useMRT_TableOptions = (_a) => {
|
|
3332
3703
|
}
|
3333
3704
|
return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
|
3334
3705
|
columnFilterDisplayMode,
|
3706
|
+
columnResizeDirection,
|
3335
3707
|
columnResizeMode,
|
3336
3708
|
createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
|
3337
3709
|
enableBottomToolbar,
|
@@ -3377,307 +3749,6 @@ const useMRT_TableOptions = (_a) => {
|
|
3377
3749
|
selectAllMode, sortingFns: _sortingFns }, rest);
|
3378
3750
|
};
|
3379
3751
|
|
3380
|
-
const blankColProps = {
|
3381
|
-
children: null,
|
3382
|
-
sx: {
|
3383
|
-
flex: '1 0 auto',
|
3384
|
-
minWidth: 0,
|
3385
|
-
p: 0,
|
3386
|
-
width: 0,
|
3387
|
-
},
|
3388
|
-
};
|
3389
|
-
const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOptions, }) => {
|
3390
|
-
var _a, _b;
|
3391
|
-
return react.useMemo(() => {
|
3392
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3393
|
-
return [
|
3394
|
-
((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-pin') && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), header: tableOptions.localization.pin, size: 60 }, (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-pin']), { columnDefType: 'display', id: 'mrt-row-pin' }),
|
3395
|
-
((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-drag']), { columnDefType: 'display', id: 'mrt-row-drag' }),
|
3396
|
-
(((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-actions') ||
|
3397
|
-
(creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, (_j = tableOptions.displayColumnDefOptions) === null || _j === void 0 ? void 0 : _j['mrt-row-actions']), { columnDefType: 'display', id: 'mrt-row-actions' }),
|
3398
|
-
((_l = (_k = tableOptions.state) === null || _k === void 0 ? void 0 : _k.columnOrder) !== null && _l !== void 0 ? _l : columnOrder).includes('mrt-row-expand') &&
|
3399
|
-
showExpandColumn(tableOptions, (_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.grouping) !== null && _o !== void 0 ? _o : grouping) && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
|
3400
|
-
? ({ table }) => jsxRuntime.jsx(MRT_ExpandAllButton, { table: table })
|
3401
|
-
: null, header: tableOptions.localization.expand, size: 60 }, (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-expand']), { columnDefType: 'display', id: 'mrt-row-expand' }),
|
3402
|
-
((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
|
3403
|
-
tableOptions.enableMultiRowSelection
|
3404
|
-
? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
3405
|
-
: null, header: tableOptions.localization.select, size: 60 }, (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-select']), { columnDefType: 'display', id: 'mrt-row-select' }),
|
3406
|
-
((_u = (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnOrder) !== null && _u !== void 0 ? _u : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, (_v = tableOptions.displayColumnDefOptions) === null || _v === void 0 ? void 0 : _v['mrt-row-numbers']), { columnDefType: 'display', id: 'mrt-row-numbers' }),
|
3407
|
-
((_x = (_w = tableOptions.state) === null || _w === void 0 ? void 0 : _w.columnOrder) !== null && _x !== void 0 ? _x : columnOrder).includes('mrt-row-spacer') && Object.assign(Object.assign(Object.assign({}, (_y = tableOptions.displayColumnDefOptions) === null || _y === void 0 ? void 0 : _y['mrt-row-spacer']), MRT_DefaultDisplayColumn), { columnDefType: 'display', header: '', id: 'mrt-row-spacer', muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps }),
|
3408
|
-
].filter(Boolean);
|
3409
|
-
}, [
|
3410
|
-
columnOrder,
|
3411
|
-
grouping,
|
3412
|
-
tableOptions.displayColumnDefOptions,
|
3413
|
-
tableOptions.editDisplayMode,
|
3414
|
-
tableOptions.enableColumnDragging,
|
3415
|
-
tableOptions.enableColumnFilterModes,
|
3416
|
-
tableOptions.enableColumnOrdering,
|
3417
|
-
tableOptions.enableEditing,
|
3418
|
-
tableOptions.enableExpandAll,
|
3419
|
-
tableOptions.enableExpanding,
|
3420
|
-
tableOptions.enableGrouping,
|
3421
|
-
tableOptions.enableRowActions,
|
3422
|
-
tableOptions.enableRowDragging,
|
3423
|
-
tableOptions.enableRowNumbers,
|
3424
|
-
tableOptions.enableRowOrdering,
|
3425
|
-
tableOptions.enableRowSelection,
|
3426
|
-
tableOptions.enableSelectAll,
|
3427
|
-
tableOptions.localization,
|
3428
|
-
tableOptions.positionActionsColumn,
|
3429
|
-
tableOptions.renderDetailPanel,
|
3430
|
-
tableOptions.renderRowActionMenuItems,
|
3431
|
-
tableOptions.renderRowActions,
|
3432
|
-
(_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
|
3433
|
-
(_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
|
3434
|
-
]);
|
3435
|
-
};
|
3436
|
-
|
3437
|
-
const useMRT_Effects = (table) => {
|
3438
|
-
const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
|
3439
|
-
const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
3440
|
-
const rerender = react.useReducer(() => ({}), {})[1];
|
3441
|
-
const isMounted = react.useRef(false);
|
3442
|
-
const initialBodyHeight = react.useRef();
|
3443
|
-
const previousTop = react.useRef();
|
3444
|
-
react.useEffect(() => {
|
3445
|
-
if (typeof window !== 'undefined') {
|
3446
|
-
initialBodyHeight.current = document.body.style.height;
|
3447
|
-
}
|
3448
|
-
}, []);
|
3449
|
-
react.useEffect(() => {
|
3450
|
-
if (isMounted && typeof window !== 'undefined') {
|
3451
|
-
if (isFullScreen) {
|
3452
|
-
previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
|
3453
|
-
document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
|
3454
|
-
}
|
3455
|
-
else {
|
3456
|
-
document.body.style.height = initialBodyHeight.current;
|
3457
|
-
if (!previousTop.current)
|
3458
|
-
return;
|
3459
|
-
//restore scroll position
|
3460
|
-
window.scrollTo({
|
3461
|
-
behavior: 'instant',
|
3462
|
-
top: -1 * previousTop.current,
|
3463
|
-
});
|
3464
|
-
}
|
3465
|
-
}
|
3466
|
-
isMounted.current = true;
|
3467
|
-
}, [isFullScreen]);
|
3468
|
-
//if page index is out of bounds, set it to the last page
|
3469
|
-
react.useEffect(() => {
|
3470
|
-
if (!enablePagination || isLoading || showSkeletons)
|
3471
|
-
return;
|
3472
|
-
const { pageIndex, pageSize } = pagination;
|
3473
|
-
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
|
3474
|
-
const firstVisibleRowIndex = pageIndex * pageSize;
|
3475
|
-
if (firstVisibleRowIndex > totalRowCount) {
|
3476
|
-
table.setPageIndex(Math.floor(totalRowCount / pageSize));
|
3477
|
-
}
|
3478
|
-
}, [rowCount, table.getPrePaginationRowModel().rows.length]);
|
3479
|
-
//turn off sort when global filter is looking for ranked results
|
3480
|
-
const appliedSort = react.useRef(sorting);
|
3481
|
-
react.useEffect(() => {
|
3482
|
-
if (sorting.length) {
|
3483
|
-
appliedSort.current = sorting;
|
3484
|
-
}
|
3485
|
-
}, [sorting]);
|
3486
|
-
react.useEffect(() => {
|
3487
|
-
if (!getCanRankRows(table))
|
3488
|
-
return;
|
3489
|
-
if (globalFilter) {
|
3490
|
-
table.setSorting([]);
|
3491
|
-
}
|
3492
|
-
else {
|
3493
|
-
table.setSorting(() => appliedSort.current || []);
|
3494
|
-
}
|
3495
|
-
}, [globalFilter]);
|
3496
|
-
react.useEffect(() => {
|
3497
|
-
if (enableRowPinning && getIsSomeRowsPinned()) {
|
3498
|
-
setTimeout(() => {
|
3499
|
-
rerender();
|
3500
|
-
}, 150);
|
3501
|
-
}
|
3502
|
-
}, [density]);
|
3503
|
-
};
|
3504
|
-
|
3505
|
-
const useMRT_TableInstance = (tableOptions) => {
|
3506
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
3507
|
-
const bottomToolbarRef = react.useRef(null);
|
3508
|
-
const editInputRefs = react.useRef({});
|
3509
|
-
const filterInputRefs = react.useRef({});
|
3510
|
-
const searchInputRef = react.useRef(null);
|
3511
|
-
const tableContainerRef = react.useRef(null);
|
3512
|
-
const tableHeadCellRefs = react.useRef({});
|
3513
|
-
const tablePaperRef = react.useRef(null);
|
3514
|
-
const topToolbarRef = react.useRef(null);
|
3515
|
-
const tableHeadRef = react.useRef(null);
|
3516
|
-
const tableFooterRef = react.useRef(null);
|
3517
|
-
const initialState = react.useMemo(() => {
|
3518
|
-
var _a, _b, _c;
|
3519
|
-
const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
|
3520
|
-
initState.columnOrder =
|
3521
|
-
(_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
|
3522
|
-
initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
|
3523
|
-
return initState;
|
3524
|
-
}, []);
|
3525
|
-
const [creatingRow, _setCreatingRow] = react.useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
|
3526
|
-
const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
|
3527
|
-
var _a, _b, _c, _d;
|
3528
|
-
return ({
|
3529
|
-
[getColumnId(col)]: col.filterFn instanceof Function
|
3530
|
-
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
3531
|
-
: (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
|
3532
|
-
});
|
3533
|
-
})));
|
3534
|
-
const [columnOrder, setColumnOrder] = react.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
|
3535
|
-
const [density, setDensity] = react.useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
|
3536
|
-
const [draggingColumn, setDraggingColumn] = react.useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
|
3537
|
-
const [draggingRow, setDraggingRow] = react.useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
|
3538
|
-
const [editingCell, setEditingCell] = react.useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
|
3539
|
-
const [editingRow, setEditingRow] = react.useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
|
3540
|
-
const [globalFilterFn, setGlobalFilterFn] = react.useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
|
3541
|
-
const [grouping, setGrouping] = react.useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
|
3542
|
-
const [hoveredColumn, setHoveredColumn] = react.useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
|
3543
|
-
const [hoveredRow, setHoveredRow] = react.useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
|
3544
|
-
const [isFullScreen, setIsFullScreen] = react.useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
|
3545
|
-
const [showAlertBanner, setShowAlertBanner] = react.useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
|
3546
|
-
const [showColumnFilters, setShowColumnFilters] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
|
3547
|
-
const [showGlobalFilter, setShowGlobalFilter] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
|
3548
|
-
const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
|
3549
|
-
const displayColumns = useMRT_DisplayColumns({
|
3550
|
-
columnOrder,
|
3551
|
-
creatingRow,
|
3552
|
-
grouping,
|
3553
|
-
tableOptions,
|
3554
|
-
});
|
3555
|
-
const columnDefs = react.useMemo(() => {
|
3556
|
-
var _a, _b, _c;
|
3557
|
-
return prepareColumns({
|
3558
|
-
aggregationFns: tableOptions.aggregationFns,
|
3559
|
-
columnDefs: [...displayColumns, ...tableOptions.columns],
|
3560
|
-
columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
|
3561
|
-
defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
|
3562
|
-
filterFns: tableOptions.filterFns,
|
3563
|
-
sortingFns: tableOptions.sortingFns,
|
3564
|
-
});
|
3565
|
-
}, [
|
3566
|
-
columnFilterFns,
|
3567
|
-
displayColumns,
|
3568
|
-
tableOptions.columns,
|
3569
|
-
(_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
|
3570
|
-
]);
|
3571
|
-
const data = react.useMemo(() => {
|
3572
|
-
var _a, _b, _c, _d, _e;
|
3573
|
-
return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
|
3574
|
-
!tableOptions.data.length
|
3575
|
-
? [
|
3576
|
-
...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
|
3577
|
-
((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
|
3578
|
-
10).fill(null),
|
3579
|
-
].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
|
3580
|
-
[getColumnId(col)]: null,
|
3581
|
-
}))))
|
3582
|
-
: tableOptions.data;
|
3583
|
-
}, [
|
3584
|
-
tableOptions.data,
|
3585
|
-
(_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
|
3586
|
-
(_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
|
3587
|
-
]);
|
3588
|
-
//@ts-ignore
|
3589
|
-
const table = reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
|
3590
|
-
? reactTable.getExpandedRowModel()
|
3591
|
-
: undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
|
3592
|
-
? reactTable.getFacetedMinMaxValues()
|
3593
|
-
: undefined, getFacetedRowModel: tableOptions.enableFacetedValues
|
3594
|
-
? reactTable.getFacetedRowModel()
|
3595
|
-
: undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
|
3596
|
-
? reactTable.getFacetedUniqueValues()
|
3597
|
-
: undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
|
3598
|
-
tableOptions.enableGlobalFilter ||
|
3599
|
-
tableOptions.enableFilters
|
3600
|
-
? reactTable.getFilteredRowModel()
|
3601
|
-
: undefined, getGroupedRowModel: tableOptions.enableGrouping
|
3602
|
-
? reactTable.getGroupedRowModel()
|
3603
|
-
: undefined, getPaginationRowModel: tableOptions.enablePagination
|
3604
|
-
? reactTable.getPaginationRowModel()
|
3605
|
-
: undefined, getSortedRowModel: tableOptions.enableSorting
|
3606
|
-
? reactTable.getSortedRowModel()
|
3607
|
-
: undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping }, tableOptions), {
|
3608
|
-
//@ts-ignore
|
3609
|
-
columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ columnFilterFns,
|
3610
|
-
columnOrder,
|
3611
|
-
creatingRow,
|
3612
|
-
density,
|
3613
|
-
draggingColumn,
|
3614
|
-
draggingRow,
|
3615
|
-
editingCell,
|
3616
|
-
editingRow,
|
3617
|
-
globalFilterFn,
|
3618
|
-
grouping,
|
3619
|
-
hoveredColumn,
|
3620
|
-
hoveredRow,
|
3621
|
-
isFullScreen,
|
3622
|
-
showAlertBanner,
|
3623
|
-
showColumnFilters,
|
3624
|
-
showGlobalFilter,
|
3625
|
-
showToolbarDropZone }, tableOptions.state) }));
|
3626
|
-
// @ts-ignore
|
3627
|
-
table.refs = {
|
3628
|
-
// @ts-ignore
|
3629
|
-
bottomToolbarRef,
|
3630
|
-
editInputRefs,
|
3631
|
-
filterInputRefs,
|
3632
|
-
// @ts-ignore
|
3633
|
-
searchInputRef,
|
3634
|
-
// @ts-ignore
|
3635
|
-
tableContainerRef,
|
3636
|
-
// @ts-ignore
|
3637
|
-
tableFooterRef,
|
3638
|
-
tableHeadCellRefs,
|
3639
|
-
// @ts-ignore
|
3640
|
-
tableHeadRef,
|
3641
|
-
// @ts-ignore
|
3642
|
-
tablePaperRef,
|
3643
|
-
// @ts-ignore
|
3644
|
-
topToolbarRef,
|
3645
|
-
};
|
3646
|
-
const setCreatingRow = (row) => {
|
3647
|
-
var _a, _b;
|
3648
|
-
let _row = row;
|
3649
|
-
if (row === true) {
|
3650
|
-
_row = createRow(table);
|
3651
|
-
}
|
3652
|
-
(_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
|
3653
|
-
};
|
3654
|
-
table.setCreatingRow = setCreatingRow;
|
3655
|
-
table.setColumnFilterFns =
|
3656
|
-
(_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
|
3657
|
-
table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
|
3658
|
-
table.setDraggingColumn =
|
3659
|
-
(_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
|
3660
|
-
table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
|
3661
|
-
table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
|
3662
|
-
table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
|
3663
|
-
table.setGlobalFilterFn =
|
3664
|
-
(_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
|
3665
|
-
table.setHoveredColumn =
|
3666
|
-
(_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
|
3667
|
-
table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
|
3668
|
-
table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
|
3669
|
-
table.setShowAlertBanner =
|
3670
|
-
(_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
|
3671
|
-
table.setShowColumnFilters =
|
3672
|
-
(_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
|
3673
|
-
table.setShowGlobalFilter =
|
3674
|
-
(_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
|
3675
|
-
table.setShowToolbarDropZone =
|
3676
|
-
(_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
|
3677
|
-
useMRT_Effects(table);
|
3678
|
-
return table;
|
3679
|
-
};
|
3680
|
-
|
3681
3752
|
const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
3682
3753
|
|
3683
3754
|
const isTableInstanceProp = (props) => props.table !== undefined;
|