material-react-table 3.0.1 → 3.0.3

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
@@ -1076,7 +1076,7 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
1076
1076
  row: MRT_Row<TData>;
1077
1077
  table: MRT_TableInstance<TData>;
1078
1078
  values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
1079
- }) => void;
1079
+ }) => Promise<void> | void;
1080
1080
  onDensityChange?: OnChangeFn<MRT_DensityState>;
1081
1081
  onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
1082
1082
  onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
package/dist/index.esm.js CHANGED
@@ -436,6 +436,8 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
436
436
  var _a, _b, _c, _d, _e, _f, _g, _h;
437
437
  if (!table.options.enableKeyboardShortcuts)
438
438
  return;
439
+ if (event.isPropagationStopped())
440
+ return;
439
441
  const currentCell = event.currentTarget;
440
442
  if (cellValue && isWinCtrlMacMeta(event) && event.key === 'c') {
441
443
  navigator.clipboard.writeText(cellValue);
@@ -924,7 +926,7 @@ const MRT_RowActionMenu = (_a) => {
924
926
  const menuItems = useMemo(() => {
925
927
  const items = [];
926
928
  const editItem = parseFromValuesOrFunc(enableEditing, row) &&
927
- ['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }));
929
+ ['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
928
930
  if (editItem)
929
931
  items.push(editItem);
930
932
  const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
@@ -2101,7 +2103,7 @@ const MRT_EditCellTextField = (_a) => {
2101
2103
  : {})), textFieldProps.InputProps), { sx: (theme) => {
2102
2104
  var _a;
2103
2105
  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)));
2104
- } }), SelectProps: Object.assign({ MenuProps: { disableScrollLock: true } }, textFieldProps.SelectProps), inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
2106
+ } }), SelectProps: Object.assign({ MenuProps: { disableScrollLock: true } }, textFieldProps.SelectProps), inputProps: Object.assign({ autoComplete: 'off' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
2105
2107
  var _a;
2106
2108
  e.stopPropagation();
2107
2109
  (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
@@ -2244,13 +2246,13 @@ const MRT_TableBodyCell = (_a) => {
2244
2246
  };
2245
2247
  const handleKeyDown = (event) => {
2246
2248
  var _a;
2249
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2247
2250
  cellKeyboardShortcuts({
2248
2251
  cell,
2249
2252
  cellValue: cell.getValue(),
2250
2253
  event,
2251
2254
  table,
2252
2255
  });
2253
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2254
2256
  };
2255
2257
  return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2256
2258
  outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
@@ -2525,12 +2527,12 @@ const MRT_TableFooterCell = (_a) => {
2525
2527
  const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2526
2528
  const handleKeyDown = (event) => {
2527
2529
  var _a;
2530
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2528
2531
  cellKeyboardShortcuts({
2529
2532
  event,
2530
2533
  cellValue: footer.column.columnDef.footer,
2531
2534
  table,
2532
2535
  });
2533
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2534
2536
  };
2535
2537
  return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2536
2538
  ? 'center'
@@ -3137,7 +3139,7 @@ const MRT_FilterTextField = (_a) => {
3137
3139
  localization[`filter${((_k = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _k === void 0 ? void 0 : _k.toUpperCase()) +
3138
3140
  (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputProps: {
3139
3141
  'aria-label': filterPlaceholder,
3140
- autoComplete: 'new-password', // disable autocomplete and autofill
3142
+ autoComplete: 'off',
3141
3143
  disabled: !!filterChipLabel,
3142
3144
  sx: {
3143
3145
  textOverflow: 'ellipsis',
@@ -3180,15 +3182,21 @@ const MRT_FilterTextField = (_a) => {
3180
3182
  } }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
3181
3183
  field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_q = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _q === void 0 ? void 0 : _q.field),
3182
3184
  textField: Object.assign(Object.assign({}, commonTextFieldProps), (_r = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.textField),
3183
- } }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_s = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _s !== void 0 ? _s : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
3185
+ } }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label,
3186
+ // @ts-ignore
3187
+ onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_s = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _s !== void 0 ? _s : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
3184
3188
  var _a;
3185
3189
  return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
3186
3190
  }, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
3187
- ? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
3191
+ ? (selected) => !Array.isArray(selected) || selected.length === 0 ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
3188
3192
  const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
3189
3193
  return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
3190
3194
  }) }))
3191
- : undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
3195
+ : undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
3196
+ ? Array.isArray(filterValue)
3197
+ ? filterValue
3198
+ : []
3199
+ : filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
3192
3200
  jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
3193
3201
  ...[
3194
3202
  (_t = textFieldProps.children) !== null && _t !== void 0 ? _t : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
@@ -3537,13 +3545,13 @@ const MRT_TableHeadCell = (_a) => {
3537
3545
  };
3538
3546
  const handleKeyDown = (event) => {
3539
3547
  var _a;
3548
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
3540
3549
  cellKeyboardShortcuts({
3541
3550
  event,
3542
3551
  cellValue: header.column.columnDef.header,
3543
3552
  table,
3544
3553
  header,
3545
3554
  });
3546
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
3547
3555
  };
3548
3556
  const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
3549
3557
  column,
@@ -4249,7 +4257,7 @@ const MRT_GlobalFilterTextField = (_a) => {
4249
4257
  }
4250
4258
  isMounted.current = true;
4251
4259
  }, [globalFilter]);
4252
- return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onChange: handleChange, placeholder: localization.search, size: "small", value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "outlined" }, textFieldProps, { InputProps: Object.assign(Object.assign({ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { title: (_b = localization.clearSearch) !== null && _b !== void 0 ? _b : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsx(CloseIcon, {}) }) }) }) })), startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { title: localization.changeSearchMode, children: jsx(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(SearchIcon, {}) }) }) })) : (jsx(SearchIcon, { style: { marginRight: '4px' } })) }, textFieldProps.InputProps), { sx: (theme) => {
4260
+ return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ inputProps: Object.assign({ autoComplete: 'off' }, textFieldProps.inputProps), onChange: handleChange, placeholder: localization.search, size: "small", value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "outlined" }, textFieldProps, { InputProps: Object.assign(Object.assign({ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { title: (_b = localization.clearSearch) !== null && _b !== void 0 ? _b : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsx(CloseIcon, {}) }) }) }) })), startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { title: localization.changeSearchMode, children: jsx(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(SearchIcon, {}) }) }) })) : (jsx(SearchIcon, { style: { marginRight: '4px' } })) }, textFieldProps.InputProps), { sx: (theme) => {
4253
4261
  var _a;
4254
4262
  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)));
4255
4263
  } }), inputRef: (inputRef) => {