@dooherceg/material-react-table 3.2.9 → 3.2.11
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.d.ts +13 -1
- package/dist/index.esm.js +43 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -773,7 +773,12 @@ function MRT_DeleteRowButton({ onClick, }) {
|
|
|
773
773
|
const iconButtonStyle = {
|
|
774
774
|
p: 0,
|
|
775
775
|
};
|
|
776
|
-
|
|
776
|
+
const handleClick = (event) => {
|
|
777
|
+
// Prevent bubbling to muiTableBodyRowProps onClick (row click handlers)
|
|
778
|
+
event.stopPropagation();
|
|
779
|
+
onClick();
|
|
780
|
+
};
|
|
781
|
+
return (jsxRuntime.jsx(IconButton, { disableRipple: true, color: "error", sx: iconButtonStyle, onClick: handleClick, children: jsxRuntime.jsx(DeleteOutlineIcon, {}) }));
|
|
777
782
|
}
|
|
778
783
|
|
|
779
784
|
const DeleteRowAction = ({ onDeleteConfirm, table, deleteConfirmation, }) => {
|
|
@@ -808,7 +813,11 @@ const DeleteRowAction = ({ onDeleteConfirm, table, deleteConfirmation, }) => {
|
|
|
808
813
|
const handleClose = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
809
814
|
setOpen(false);
|
|
810
815
|
});
|
|
811
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Dialog, { open: open, onClose: () => setOpen(false), keepMounted: true, "aria-describedby": "alert-dialog-slide-description", role: "alertdialog", sx: dialogSx, children: jsxRuntime.jsxs(Stack, { flexDirection: "column", height: "min-content", sx: contentContainerSx,
|
|
816
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Dialog, { open: open, onClose: () => setOpen(false), keepMounted: true, "aria-describedby": "alert-dialog-slide-description", role: "alertdialog", sx: dialogSx, children: jsxRuntime.jsxs(Stack, { flexDirection: "column", height: "min-content", sx: contentContainerSx,
|
|
817
|
+
// Dialog renders via a portal, but React still bubbles synthetic events up
|
|
818
|
+
// through the component tree — stop here so clicks inside the confirmation
|
|
819
|
+
// dialog don't reach muiTableBodyRowProps onClick (row click handlers).
|
|
820
|
+
onClick: (event) => event.stopPropagation(), children: [jsxRuntime.jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", sx: Object.assign({ width: '100%' }, headerSx), children: [jsxRuntime.jsx(DialogTitle, { sx: Object.assign({ p: '0.7rem' }, titleSx), children: deleteConfirmationTitle }), jsxRuntime.jsx(DialogActions, { sx: {
|
|
812
821
|
p: '0.7rem',
|
|
813
822
|
}, children: jsxRuntime.jsx(IconButton, Object.assign({ color: "error", "aria-label": "close", onClick: handleClose }, closeButtonProps, { children: jsxRuntime.jsx(CancelIcon, {}) })) })] }), jsxRuntime.jsxs(Stack, { children: [jsxRuntime.jsx(DialogContent, { sx: Object.assign({ pr: '6rem' }, bodySx), children: deleteConfirmationMessage }), jsxRuntime.jsxs(DialogActions, { sx: footerSx, children: [jsxRuntime.jsx(Button, Object.assign({ onClick: () => setOpen(false), disabled: deleting, autoFocus: true, variant: "soft" }, cancelButtonProps, { children: cancelButtonLabel })), jsxRuntime.jsx(Button, Object.assign({ onClick: handleConfirmDelete, disabled: deleting, variant: "contained", color: "error" }, confirmButtonProps, { children: deleting ? deletingLabel : confirmButtonLabel }))] })] })] }) }), jsxRuntime.jsx(MRT_DeleteRowButton, { onClick: handleDeleteRowButtonClick })] }));
|
|
814
823
|
};
|
|
@@ -874,7 +883,12 @@ const createDeleteAction = (_a = {}) => {
|
|
|
874
883
|
};
|
|
875
884
|
|
|
876
885
|
const MRT_EditRowButton = ({ onClick }) => {
|
|
877
|
-
|
|
886
|
+
const handleClick = (event) => {
|
|
887
|
+
// Prevent bubbling to muiTableBodyRowProps onClick (row click handlers)
|
|
888
|
+
event.stopPropagation();
|
|
889
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
890
|
+
};
|
|
891
|
+
return (jsxRuntime.jsx(IconButton, { sx: { p: 0 }, disableRipple: true, color: "primary", onClick: handleClick, children: jsxRuntime.jsx(EditNoteIcon, {}) }));
|
|
878
892
|
};
|
|
879
893
|
|
|
880
894
|
const EditRowAction = ({ onEditButtonClick, }) => {
|
|
@@ -6307,13 +6321,19 @@ const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
|
|
|
6307
6321
|
};
|
|
6308
6322
|
|
|
6309
6323
|
const MRT_NewEntryButton = (_a) => {
|
|
6310
|
-
var _b;
|
|
6324
|
+
var _b, _c;
|
|
6311
6325
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
6312
|
-
const { options: { icons: { AddIcon }, localization, }, setNewEntryModal, } = table;
|
|
6313
|
-
const handleOpenNewEntryModal = () => {
|
|
6326
|
+
const { options: { icons: { AddIcon }, localization, newEntryButtonProps, }, setNewEntryModal, } = table;
|
|
6327
|
+
const handleOpenNewEntryModal = (event) => {
|
|
6328
|
+
// Prevent bubbling to muiTableBodyRowProps onClick (row click handlers)
|
|
6329
|
+
event.stopPropagation();
|
|
6314
6330
|
setNewEntryModal({ open: true });
|
|
6315
6331
|
};
|
|
6316
|
-
|
|
6332
|
+
// When the consumer supplies onClick via newEntryButtonProps (or rest), it fully
|
|
6333
|
+
// replaces handleOpenNewEntryModal below — matches the override convention used by
|
|
6334
|
+
// every other mui*ButtonProps option in this codebase.
|
|
6335
|
+
const buttonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(newEntryButtonProps, { table })), rest);
|
|
6336
|
+
return (jsxRuntime.jsx(Tooltip, { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : localization.newEntry, children: jsxRuntime.jsx(Button, Object.assign({ "aria-label": localization.newEntry, onClick: handleOpenNewEntryModal, size: "small", startIcon: jsxRuntime.jsx(AddIcon, { fontSize: "small" }), variant: "text" }, buttonProps, { title: undefined, children: (_c = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.children) !== null && _c !== void 0 ? _c : localization.newEntry })) }));
|
|
6317
6337
|
};
|
|
6318
6338
|
|
|
6319
6339
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
@@ -8517,6 +8537,9 @@ const useServerTableState = ({ initialState, saveState, saveDebounceMs = 500, })
|
|
|
8517
8537
|
const [expanded, setExpanded] = react.useState((_k = initialState === null || initialState === void 0 ? void 0 : initialState.expanded) !== null && _k !== void 0 ? _k : {});
|
|
8518
8538
|
const [rowSelection, setRowSelection] = react.useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.rowSelection) !== null && _l !== void 0 ? _l : {});
|
|
8519
8539
|
const [activeExports, setActiveExports] = react.useState(initialState === null || initialState === void 0 ? void 0 : initialState.activeExports);
|
|
8540
|
+
// Counter that increments on every manual refetch() call, without changing any other state
|
|
8541
|
+
const [refetchIndex, setRefetchIndex] = react.useState(0);
|
|
8542
|
+
const refetch = () => setRefetchIndex((prev) => prev + 1);
|
|
8520
8543
|
// --- Debounced save ---
|
|
8521
8544
|
// saveState is optional — if not provided, do nothing
|
|
8522
8545
|
const debouncedSave = useDebounce.useDebouncedCallback((partial) => {
|
|
@@ -8599,7 +8622,9 @@ const useServerTableState = ({ initialState, saveState, saveDebounceMs = 500, })
|
|
|
8599
8622
|
pagination,
|
|
8600
8623
|
sorting,
|
|
8601
8624
|
columnVisibilityShowTrigger,
|
|
8625
|
+
refetchIndex,
|
|
8602
8626
|
},
|
|
8627
|
+
refetch,
|
|
8603
8628
|
};
|
|
8604
8629
|
};
|
|
8605
8630
|
|
|
@@ -8643,7 +8668,7 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
|
|
|
8643
8668
|
grouped: false,
|
|
8644
8669
|
});
|
|
8645
8670
|
};
|
|
8646
|
-
const
|
|
8671
|
+
const MaterialReactServerTableInstanceComponent = (_a, ref) => {
|
|
8647
8672
|
var _b, _c;
|
|
8648
8673
|
var { config, loadData, saveState, getAllSelectableRowIds, getTotalRows, onSaveFilters, onDeleteSavedFilter, initialSavedFilters, loadExport, exportPermissions, enableNewEntryButton, actions, deleteRowsFn, editRowFn, enableResetState, resetState, extendColumns } = _a,
|
|
8649
8674
|
// Extra MRT_TableOptions props (e.g. formConfig) passed directly through to useMaterialReactTable
|
|
@@ -8671,7 +8696,7 @@ const MaterialReactServerTableInstance = (_a) => {
|
|
|
8671
8696
|
});
|
|
8672
8697
|
return Object.fromEntries(allowedEntries);
|
|
8673
8698
|
}, [config.availableExports, exportPermissions]);
|
|
8674
|
-
const { tableState, handlers, fetchTrigger } = useServerTableState({
|
|
8699
|
+
const { tableState, handlers, fetchTrigger, refetch } = useServerTableState({
|
|
8675
8700
|
initialState: Object.assign(Object.assign({}, config.initialState), { activeExports: buildInitialExportState(allowedExports, (_b = config.initialState) === null || _b === void 0 ? void 0 : _b.activeExports) }),
|
|
8676
8701
|
saveState,
|
|
8677
8702
|
});
|
|
@@ -8691,6 +8716,9 @@ const MaterialReactServerTableInstance = (_a) => {
|
|
|
8691
8716
|
editRowFn,
|
|
8692
8717
|
onSaveFilters,
|
|
8693
8718
|
onDeleteSavedFilter, initialSavedFilters: initialSavedFilters !== null && initialSavedFilters !== void 0 ? initialSavedFilters : (_c = config.initialState) === null || _c === void 0 ? void 0 : _c.savedFilters, availableExports: hasAvailableExports ? allowedExports : undefined, loadExport: hasAvailableExports ? loadExport : undefined, enableNewEntryButton }, tableOptionsOverrides), handlers));
|
|
8719
|
+
// Lets any code that already has `table` (row actions, deleteRowsFn/editRowFn,
|
|
8720
|
+
// custom cell renderers, etc.) trigger a manual reload without needing a ref.
|
|
8721
|
+
table.refetch = refetch;
|
|
8694
8722
|
const fetchData = react.useCallback((tableInstance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8695
8723
|
setIsLoading(true);
|
|
8696
8724
|
try {
|
|
@@ -8718,9 +8746,12 @@ const MaterialReactServerTableInstance = (_a) => {
|
|
|
8718
8746
|
fetchTrigger.pagination,
|
|
8719
8747
|
fetchTrigger.sorting,
|
|
8720
8748
|
fetchTrigger.columnVisibilityShowTrigger,
|
|
8749
|
+
fetchTrigger.refetchIndex,
|
|
8721
8750
|
]);
|
|
8751
|
+
react.useImperativeHandle(ref, () => ({ refetch, table }), [refetch, table]);
|
|
8722
8752
|
return jsxRuntime.jsx(MaterialReactTable, { table: table });
|
|
8723
8753
|
};
|
|
8754
|
+
const MaterialReactServerTableInstance = react.forwardRef(MaterialReactServerTableInstanceComponent);
|
|
8724
8755
|
|
|
8725
8756
|
const MaterialReactServerTableSkeleton = () => (jsxRuntime.jsxs(Paper, { "data-testid": "server-table-skeleton", sx: {
|
|
8726
8757
|
display: 'flex',
|
|
@@ -8743,7 +8774,7 @@ const MaterialReactServerTableSkeleton = () => (jsxRuntime.jsxs(Paper, { "data-t
|
|
|
8743
8774
|
px: '1.3rem',
|
|
8744
8775
|
}), children: jsxRuntime.jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '1rem' }, children: [jsxRuntime.jsx(Skeleton, { animation: "wave", height: 36, variant: "rounded", width: 136 }), jsxRuntime.jsx(Skeleton, { animation: "wave", height: 31, variant: "text", width: 176 }), jsxRuntime.jsx(Skeleton, { animation: "wave", height: 22, variant: "text", width: 70 }), jsxRuntime.jsx(Skeleton, { animation: "wave", height: 24, variant: "circular", width: 24 }), jsxRuntime.jsx(Skeleton, { animation: "wave", height: 24, variant: "circular", width: 24 })] }) })] }));
|
|
8745
8776
|
|
|
8746
|
-
const
|
|
8777
|
+
const MaterialReactServerTableComponent = (_a, ref) => {
|
|
8747
8778
|
var { loadConfig, saveState, localization } = _a, instanceProps = __rest(_a, ["loadConfig", "saveState", "localization"]);
|
|
8748
8779
|
const mergedLocalization = Object.assign(Object.assign({}, MRT_Localization_HR), localization);
|
|
8749
8780
|
const [configLoading, setConfigLoading] = react.useState(true);
|
|
@@ -8779,8 +8810,9 @@ const MaterialReactServerTable = (_a) => {
|
|
|
8779
8810
|
if (!config) {
|
|
8780
8811
|
return (jsxRuntime.jsx(MaterialReactServerTableError, { description: mergedLocalization.serverTableErrorMessage }));
|
|
8781
8812
|
}
|
|
8782
|
-
return (jsxRuntime.jsx(MaterialReactServerTableInstance, Object.assign({ config: config, saveState: saveState }, instanceProps)));
|
|
8813
|
+
return (jsxRuntime.jsx(MaterialReactServerTableInstance, Object.assign({ ref: ref, config: config, saveState: saveState }, instanceProps)));
|
|
8783
8814
|
};
|
|
8815
|
+
const MaterialReactServerTable = react.forwardRef(MaterialReactServerTableComponent);
|
|
8784
8816
|
|
|
8785
8817
|
const MRT_ColumnPinningButtons = (_a) => {
|
|
8786
8818
|
var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
|