@dooherceg/material-react-table 3.2.10 → 3.2.12

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 CHANGED
@@ -1292,6 +1292,9 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1292
1292
  table: MRT_TableInstance<TData>;
1293
1293
  }) => BoxProps) | BoxProps;
1294
1294
  muiNewEntryModalProps?: MRT_NewEntryModalOverrides;
1295
+ newEntryButtonProps?: ((props: {
1296
+ table: MRT_TableInstance<TData>;
1297
+ }) => ButtonProps) | ButtonProps;
1295
1298
  formConfig?: MRT_FormConfig<TData>;
1296
1299
  onActionCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
1297
1300
  onColumnFilterFnsChange?: OnChangeFn<{
package/dist/index.esm.js CHANGED
@@ -1677,7 +1677,13 @@ const MRT_ExpandAllButton = (_a) => {
1677
1677
  table,
1678
1678
  })), rest);
1679
1679
  const isAllRowsExpanded = getIsAllRowsExpanded();
1680
- return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : (isAllRowsExpanded ? localization.collapseAll : localization.expandAll), children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsx(KeyboardDoubleArrowDownIcon, { style: {
1680
+ const handleToggleExpandAll = (event) => {
1681
+ var _a;
1682
+ event.stopPropagation();
1683
+ toggleAllRowsExpanded(!isAllRowsExpanded);
1684
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1685
+ };
1686
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : (isAllRowsExpanded ? localization.collapseAll : localization.expandAll), children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()) }, iconButtonProps, { onClick: handleToggleExpandAll, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsx(KeyboardDoubleArrowDownIcon, { style: {
1681
1687
  transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
1682
1688
  transition: 'transform 150ms',
1683
1689
  } })) })) }) })));
@@ -1720,18 +1726,29 @@ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1720
1726
  const INSERT_HERE_TOOLTIP = 'Insert here';
1721
1727
  const ACTION_ICON_SIZE$1 = 'small';
1722
1728
  const MRT_InsertHereAction = ({ onClick, }) => {
1723
- return (jsx(Tooltip, { title: INSERT_HERE_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE$1, children: jsx(SubdirectoryArrowLeftIcon, { color: "warning" }) }) }));
1729
+ const handleClick = (event) => {
1730
+ event.stopPropagation();
1731
+ onClick();
1732
+ };
1733
+ return (jsx(Tooltip, { title: INSERT_HERE_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: handleClick, size: ACTION_ICON_SIZE$1, children: jsx(SubdirectoryArrowLeftIcon, { color: "warning" }) }) }));
1724
1734
  };
1725
1735
 
1726
1736
  const MOVE_TO_TOP_TOOLTIP = 'Move to top level';
1727
1737
  const ACTION_ICON_SIZE = 'small';
1728
1738
  const ACTION_BUTTON_HEIGHT = '1.75rem';
1729
1739
  const MRT_MoveToTopAction = ({ onClick }) => {
1730
- return (jsx(Tooltip, { title: MOVE_TO_TOP_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE, sx: { height: ACTION_BUTTON_HEIGHT }, children: jsx(VerticalAlignTopIcon, { fontSize: "small" }) }) }));
1740
+ const handleClick = (event) => {
1741
+ event.stopPropagation();
1742
+ onClick();
1743
+ };
1744
+ return (jsx(Tooltip, { title: MOVE_TO_TOP_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: handleClick, size: ACTION_ICON_SIZE, sx: { height: ACTION_BUTTON_HEIGHT }, children: jsx(VerticalAlignTopIcon, { fontSize: "small" }) }) }));
1731
1745
  };
1732
1746
 
1733
1747
  const MRT_ReorderRowCheckbox = ({ onChange, isSelected, }) => {
1734
- return (jsx(Checkbox, { checked: isSelected, color: "warning", disableRipple: true, onChange: onChange, sx: {
1748
+ const handleClick = (event) => {
1749
+ event.stopPropagation();
1750
+ };
1751
+ return (jsx(Checkbox, { checked: isSelected, color: "warning", disableRipple: true, onChange: onChange, onClick: handleClick, sx: {
1735
1752
  color: (theme) => theme.palette.warning.main,
1736
1753
  '&.Mui-checked': {
1737
1754
  color: (theme) => theme.palette.warning.main,
@@ -2002,7 +2019,7 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
2002
2019
  });
2003
2020
  if (groupedColumnMode === 'remove' && row.groupingColumnId) {
2004
2021
  const defaultGroupedCell = (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) })));
2005
- return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), column.columnDef.GroupedCell
2022
+ return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), column.columnDef.GroupedCell
2006
2023
  ? customGroupedCell
2007
2024
  : defaultGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick })), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
2008
2025
  }
@@ -6319,15 +6336,19 @@ const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
6319
6336
  };
6320
6337
 
6321
6338
  const MRT_NewEntryButton = (_a) => {
6322
- var _b;
6339
+ var _b, _c;
6323
6340
  var { table } = _a, rest = __rest(_a, ["table"]);
6324
- const { options: { icons: { AddIcon }, localization, }, setNewEntryModal, } = table;
6341
+ const { options: { icons: { AddIcon }, localization, newEntryButtonProps, }, setNewEntryModal, } = table;
6325
6342
  const handleOpenNewEntryModal = (event) => {
6326
6343
  // Prevent bubbling to muiTableBodyRowProps onClick (row click handlers)
6327
6344
  event.stopPropagation();
6328
6345
  setNewEntryModal({ open: true });
6329
6346
  };
6330
- return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.newEntry, children: jsx(Button, Object.assign({ "aria-label": localization.newEntry, onClick: handleOpenNewEntryModal, size: "small", startIcon: jsx(AddIcon, { fontSize: "small" }), variant: "text" }, rest, { title: undefined, children: localization.newEntry })) }));
6347
+ // When the consumer supplies onClick via newEntryButtonProps (or rest), it fully
6348
+ // replaces handleOpenNewEntryModal below — matches the override convention used by
6349
+ // every other mui*ButtonProps option in this codebase.
6350
+ const buttonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(newEntryButtonProps, { table })), rest);
6351
+ return (jsx(Tooltip, { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : localization.newEntry, children: jsx(Button, Object.assign({ "aria-label": localization.newEntry, onClick: handleOpenNewEntryModal, size: "small", startIcon: 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 })) }));
6331
6352
  };
6332
6353
 
6333
6354
  const MRT_ShowHideColumnsMenuItems = (_a) => {