@mui/x-data-grid 7.0.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +246 -4
  2. package/DataGrid/DataGrid.js +5 -0
  3. package/DataGrid/useDataGridProps.js +1 -0
  4. package/README.md +1 -1
  5. package/components/cell/GridCell.js +0 -1
  6. package/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  7. package/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  8. package/components/toolbar/GridToolbarQuickFilter.js +17 -2
  9. package/components/virtualization/GridMainContainer.js +8 -1
  10. package/components/virtualization/GridTopContainer.js +1 -0
  11. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  12. package/hooks/features/dimensions/useGridDimensions.js +3 -2
  13. package/hooks/features/editing/useGridRowEditing.js +13 -4
  14. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  15. package/hooks/features/headerFiltering/useGridHeaderFiltering.js +4 -7
  16. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  17. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -3
  18. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -6
  19. package/index.js +1 -1
  20. package/internals/index.d.ts +1 -1
  21. package/internals/utils/propValidation.d.ts +1 -0
  22. package/internals/utils/propValidation.js +9 -4
  23. package/locales/esES.js +3 -4
  24. package/locales/faIR.js +3 -4
  25. package/locales/ptBR.js +3 -4
  26. package/models/gridExport.d.ts +2 -2
  27. package/models/gridFilterModel.d.ts +3 -3
  28. package/models/params/gridCellParams.d.ts +0 -22
  29. package/models/props/DataGridProps.d.ts +24 -0
  30. package/modern/DataGrid/DataGrid.js +5 -0
  31. package/modern/DataGrid/useDataGridProps.js +1 -0
  32. package/modern/components/cell/GridCell.js +0 -1
  33. package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  34. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  35. package/modern/components/toolbar/GridToolbarQuickFilter.js +17 -2
  36. package/modern/components/virtualization/GridMainContainer.js +8 -1
  37. package/modern/components/virtualization/GridTopContainer.js +1 -0
  38. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
  39. package/modern/hooks/features/editing/useGridRowEditing.js +13 -4
  40. package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +4 -7
  41. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -3
  42. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -6
  43. package/modern/index.js +1 -1
  44. package/modern/internals/utils/propValidation.js +9 -4
  45. package/modern/locales/esES.js +3 -4
  46. package/modern/locales/faIR.js +3 -4
  47. package/modern/locales/ptBR.js +3 -4
  48. package/modern/utils/throttle.js +19 -0
  49. package/node/DataGrid/DataGrid.js +5 -0
  50. package/node/DataGrid/useDataGridProps.js +1 -0
  51. package/node/components/cell/GridCell.js +0 -1
  52. package/node/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  53. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  54. package/node/components/toolbar/GridToolbarQuickFilter.js +17 -2
  55. package/node/components/virtualization/GridMainContainer.js +8 -1
  56. package/node/components/virtualization/GridTopContainer.js +1 -0
  57. package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
  58. package/node/hooks/features/editing/useGridRowEditing.js +13 -4
  59. package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +4 -7
  60. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -3
  61. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -6
  62. package/node/index.js +1 -1
  63. package/node/internals/utils/propValidation.js +12 -6
  64. package/node/locales/esES.js +3 -4
  65. package/node/locales/faIR.js +3 -4
  66. package/node/locales/ptBR.js +3 -4
  67. package/node/utils/throttle.js +25 -0
  68. package/package.json +2 -2
  69. package/utils/throttle.d.ts +4 -0
  70. package/utils/throttle.js +19 -0
@@ -30,10 +30,9 @@ const esESGrid = {
30
30
  toolbarExportPrint: 'Imprimir',
31
31
  toolbarExportExcel: 'Descargar como Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'Buscar',
34
+ columnsManagementNoColumns: 'Sin columnas',
35
+ columnsManagementShowHideAllText: 'Mostrar/Ocultar todas',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'Agregar filtro',
39
38
  filterPanelRemoveAll: 'Remover todos',
@@ -30,10 +30,9 @@ const faIRGrid = {
30
30
  toolbarExportPrint: 'چاپ',
31
31
  toolbarExportExcel: 'دانلود به صورت اکسل',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'جستجو',
34
+ columnsManagementNoColumns: 'بدون سطر',
35
+ columnsManagementShowHideAllText: 'نمایش/مخفی کردن همه',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'افزودن فیلتر',
39
38
  filterPanelRemoveAll: 'حذف همه',
@@ -30,10 +30,9 @@ const ptBRGrid = {
30
30
  toolbarExportPrint: 'Imprimir',
31
31
  toolbarExportExcel: 'Baixar como Excel',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
-
33
+ columnsManagementSearchTitle: 'Buscar',
34
+ columnsManagementNoColumns: 'Nenhuma coluna',
35
+ columnsManagementShowHideAllText: 'Mostrar/Ocultar Todas',
37
36
  // Filter panel text
38
37
  filterPanelAddFilter: 'Adicionar filtro',
39
38
  filterPanelRemoveAll: 'Remover todos',
@@ -0,0 +1,19 @@
1
+ export function throttle(func, wait = 166) {
2
+ let timeout;
3
+ let lastArgs;
4
+ const later = () => {
5
+ timeout = undefined;
6
+ func(...lastArgs);
7
+ };
8
+ function throttled(...args) {
9
+ lastArgs = args;
10
+ if (timeout === undefined) {
11
+ timeout = setTimeout(later, wait);
12
+ }
13
+ }
14
+ throttled.clear = () => {
15
+ clearTimeout(timeout);
16
+ timeout = undefined;
17
+ };
18
+ return throttled;
19
+ }
@@ -615,6 +615,11 @@ DataGridRaw.propTypes = {
615
615
  * @returns {Promise<R> | R} The final values to update the row.
616
616
  */
617
617
  processRowUpdate: _propTypes.default.func,
618
+ /**
619
+ * The milliseconds throttle delay for resizing the grid.
620
+ * @default 60
621
+ */
622
+ resizeThrottleMs: _propTypes.default.number,
618
623
  /**
619
624
  * Row region in pixels to render before/after the viewport
620
625
  * @default 150
@@ -63,6 +63,7 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
63
63
  pagination: false,
64
64
  paginationMode: 'client',
65
65
  rowHeight: 52,
66
+ resizeThrottleMs: 60,
66
67
  pageSizeOptions: [25, 50, 100],
67
68
  rowSpacingType: 'margin',
68
69
  showCellVerticalBorder: false,
@@ -168,7 +168,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
168
168
  const cellRef = React.useRef(null);
169
169
  const handleRef = (0, _utils.unstable_useForkRef)(ref, cellRef);
170
170
  const focusElementRef = React.useRef(null);
171
- // @ts-expect-error To access `cellSelection` flag as it's a `premium` feature
172
171
  const isSelectionMode = rootProps.cellSelection ?? false;
173
172
  const position = gridPinnedColumnPositionLookup[pinnedPosition];
174
173
  const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(position, sectionIndex);
@@ -161,7 +161,9 @@ function GridColumnHeaderItem(props) {
161
161
  const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
162
162
  const elementToFocus = focusableElement || headerCellRef.current;
163
163
  elementToFocus?.focus();
164
- apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
164
+ if (apiRef.current.columnHeadersContainerRef?.current) {
165
+ apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
166
+ }
165
167
  }
166
168
  }, [apiRef, hasFocus]);
167
169
  const headerClassName = typeof colDef.headerClassName === 'function' ? colDef.headerClassName({
@@ -64,7 +64,9 @@ const GridGenericColumnHeaderItem = exports.GridGenericColumnHeaderItem = /*#__P
64
64
  const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
65
65
  const elementToFocus = focusableElement || headerCellRef.current;
66
66
  elementToFocus?.focus();
67
- apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
67
+ if (apiRef.current.columnHeadersContainerRef?.current) {
68
+ apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
69
+ }
68
70
  }
69
71
  }, [apiRef, hasFocus]);
70
72
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({
@@ -8,19 +8,31 @@ exports.GridToolbarQuickFilter = GridToolbarQuickFilter;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
+ var _clsx = _interopRequireDefault(require("clsx"));
11
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
13
  var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
13
14
  var _styles = require("@mui/material/styles");
14
15
  var _utils = require("@mui/utils");
16
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
17
+ var _constants = require("../../constants");
15
18
  var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
16
19
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
17
20
  var _useGridSelector = require("../../hooks/utils/useGridSelector");
18
21
  var _filter = require("../../hooks/features/filter");
19
22
  var _utils2 = require("../../utils/utils");
20
23
  var _jsxRuntime = require("react/jsx-runtime");
21
- const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs"];
24
+ const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs", "className"];
22
25
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
26
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
27
+ const useUtilityClasses = ownerState => {
28
+ const {
29
+ classes
30
+ } = ownerState;
31
+ const slots = {
32
+ root: ['toolbarQuickFilter']
33
+ };
34
+ return (0, _composeClasses.default)(slots, _constants.getDataGridUtilityClass, classes);
35
+ };
24
36
  const GridToolbarQuickFilterRoot = (0, _styles.styled)(_TextField.default, {
25
37
  name: 'MuiDataGrid',
26
38
  slot: 'ToolbarQuickFilter',
@@ -56,11 +68,13 @@ const defaultSearchValueFormatter = values => values.join(' ');
56
68
  function GridToolbarQuickFilter(props) {
57
69
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
58
70
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
71
+ const classes = useUtilityClasses(rootProps);
59
72
  const quickFilterValues = (0, _useGridSelector.useGridSelector)(apiRef, _filter.gridQuickFilterValuesSelector);
60
73
  const {
61
74
  quickFilterParser = defaultSearchValueParser,
62
75
  quickFilterFormatter = defaultSearchValueFormatter,
63
- debounceMs = rootProps.filterDebounceMs
76
+ debounceMs = rootProps.filterDebounceMs,
77
+ className
64
78
  } = props,
65
79
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
66
80
  const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues ?? []));
@@ -95,6 +109,7 @@ function GridToolbarQuickFilter(props) {
95
109
  variant: "standard",
96
110
  value: searchValue,
97
111
  onChange: handleSearchValueChange,
112
+ className: (0, _clsx.default)(className, classes.root),
98
113
  placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
99
114
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
100
115
  type: "search"
@@ -8,19 +8,26 @@ exports.GridMainContainer = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _system = require("@mui/system");
11
+ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
11
12
  var _useGridAriaAttributes = require("../../hooks/utils/useGridAriaAttributes");
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- const Element = (0, _system.styled)('div')({
16
+ const Element = (0, _system.styled)('div', {
17
+ name: 'MuiDataGrid',
18
+ slot: 'Main',
19
+ overridesResolver: (props, styles) => styles.main
20
+ })({
16
21
  flexGrow: 1,
17
22
  position: 'relative',
18
23
  overflow: 'hidden'
19
24
  });
20
25
  const GridMainContainer = exports.GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
21
26
  const ariaAttributes = (0, _useGridAriaAttributes.useGridAriaAttributes)();
27
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
22
28
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, (0, _extends2.default)({
23
29
  ref: ref,
30
+ ownerState: rootProps,
24
31
  className: props.className,
25
32
  tabIndex: -1
26
33
  }, ariaAttributes, {
@@ -30,6 +30,7 @@ const Element = (0, _system.styled)('div')({
30
30
  zIndex: 5,
31
31
  bottom: 0,
32
32
  left: 0,
33
+ right: 0,
33
34
  height: 1,
34
35
  width: 'var(--DataGrid-rowWidth)',
35
36
  backgroundColor: 'var(--DataGrid-rowBorderColor)'
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _utils = require("@mui/utils");
12
12
  var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
13
13
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
14
+ var _throttle = require("../../../utils/throttle");
14
15
  var _useGridLogger = require("../../utils/useGridLogger");
15
16
  var _columns = require("../columns");
16
17
  var _gridDimensionsSelectors = require("./gridDimensionsSelectors");
@@ -68,7 +69,7 @@ function useGridDimensions(apiRef, props) {
68
69
  const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
69
70
  const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
70
71
  const [savedSize, setSavedSize] = React.useState();
71
- const debouncedSetSavedSize = React.useMemo(() => (0, _utils.unstable_debounce)(setSavedSize, 60), []);
72
+ const debouncedSetSavedSize = React.useMemo(() => (0, _throttle.throttle)(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
72
73
  const previousSize = React.useRef();
73
74
  const getRootDimensions = () => apiRef.current.state.dimensions;
74
75
  const setDimensions = (0, _utils.unstable_useEventCallback)(dimensions => {
@@ -54,6 +54,10 @@ const useGridRowEditing = (apiRef, props) => {
54
54
  throw new Error(`MUI X: The row with id=${id} is not in ${mode} mode.`);
55
55
  }
56
56
  }, [apiRef]);
57
+ const hasFieldsWithErrors = React.useCallback(rowId => {
58
+ const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
59
+ return Object.values(editingState[rowId]).some(fieldProps => fieldProps.error);
60
+ }, [apiRef]);
57
61
  const handleCellDoubleClick = React.useCallback((params, event) => {
58
62
  if (!params.isEditable) {
59
63
  return;
@@ -95,6 +99,9 @@ const useGridRowEditing = (apiRef, props) => {
95
99
  if (apiRef.current.getRowMode(params.id) === _gridEditRowModel.GridRowModes.View) {
96
100
  return;
97
101
  }
102
+ if (hasFieldsWithErrors(params.id)) {
103
+ return;
104
+ }
98
105
  const rowParams = apiRef.current.getRowParams(params.id);
99
106
  const newParams = (0, _extends2.default)({}, rowParams, {
100
107
  field: params.field,
@@ -103,7 +110,7 @@ const useGridRowEditing = (apiRef, props) => {
103
110
  apiRef.current.publishEvent('rowEditStop', newParams, event);
104
111
  }
105
112
  });
106
- }, [apiRef]);
113
+ }, [apiRef, hasFieldsWithErrors]);
107
114
  React.useEffect(() => {
108
115
  return () => {
109
116
  clearTimeout(focusTimeout.current);
@@ -149,6 +156,9 @@ const useGridRowEditing = (apiRef, props) => {
149
156
  }
150
157
  }
151
158
  if (reason) {
159
+ if (reason !== _gridRowParams.GridRowEditStopReasons.escapeKeyDown && hasFieldsWithErrors(params.id)) {
160
+ return;
161
+ }
152
162
  const newParams = (0, _extends2.default)({}, apiRef.current.getRowParams(params.id), {
153
163
  reason,
154
164
  field: params.field
@@ -183,7 +193,7 @@ const useGridRowEditing = (apiRef, props) => {
183
193
  apiRef.current.publishEvent('rowEditStart', newParams, event);
184
194
  }
185
195
  }
186
- }, [apiRef]);
196
+ }, [apiRef, hasFieldsWithErrors]);
187
197
  const handleRowEditStart = React.useCallback(params => {
188
198
  const {
189
199
  id,
@@ -367,8 +377,7 @@ const useGridRowEditing = (apiRef, props) => {
367
377
  prevRowModesModel.current[id].mode = _gridEditRowModel.GridRowModes.Edit;
368
378
  return;
369
379
  }
370
- const hasSomeFieldWithError = Object.values(editingState[id]).some(fieldProps => fieldProps.error);
371
- if (hasSomeFieldWithError) {
380
+ if (hasFieldsWithErrors(id)) {
372
381
  prevRowModesModel.current[id].mode = _gridEditRowModel.GridRowModes.Edit;
373
382
  // Revert the mode in the rowModesModel prop back to "edit"
374
383
  updateRowInRowModesModel(id, {
@@ -13,7 +13,6 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
13
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  const headerFilteringStateInitializer = (state, props) => (0, _extends2.default)({}, state, {
16
- // @ts-expect-error Access `Pro` prop in MIT
17
16
  headerFiltering: {
18
17
  enabled: props.headerFilters ?? false,
19
18
  editing: null,
@@ -23,8 +22,6 @@ const headerFilteringStateInitializer = (state, props) => (0, _extends2.default)
23
22
  exports.headerFilteringStateInitializer = headerFilteringStateInitializer;
24
23
  const useGridHeaderFiltering = (apiRef, props) => {
25
24
  const logger = (0, _utils.useGridLogger)(apiRef, 'useGridHeaderFiltering');
26
- // @ts-expect-error Access `Pro` prop in MIT
27
- const isHeaderFilteringEnabled = props.headerFilters ?? false;
28
25
  const setHeaderFilterState = React.useCallback(headerFilterState => {
29
26
  apiRef.current.setState(state => {
30
27
  // Safety check to avoid MIT users from using it
@@ -34,14 +31,14 @@ const useGridHeaderFiltering = (apiRef, props) => {
34
31
  }
35
32
  return (0, _extends2.default)({}, state, {
36
33
  headerFiltering: {
37
- enabled: isHeaderFilteringEnabled ?? false,
34
+ enabled: props.headerFilters ?? false,
38
35
  editing: headerFilterState.editing ?? null,
39
36
  menuOpen: headerFilterState.menuOpen ?? null
40
37
  }
41
38
  });
42
39
  });
43
40
  apiRef.current.forceUpdate();
44
- }, [apiRef, props.signature, isHeaderFilteringEnabled]);
41
+ }, [apiRef, props.signature, props.headerFilters]);
45
42
  const startHeaderFilterEditMode = React.useCallback(field => {
46
43
  logger.debug(`Starting edit mode on header filter for field: ${field}`);
47
44
  apiRef.current.setHeaderFilterState({
@@ -112,9 +109,9 @@ const useGridHeaderFiltering = (apiRef, props) => {
112
109
  isFirstRender.current = false;
113
110
  } else {
114
111
  apiRef.current.setHeaderFilterState({
115
- enabled: isHeaderFilteringEnabled
112
+ enabled: props.headerFilters ?? false
116
113
  });
117
114
  }
118
- }, [apiRef, isHeaderFilteringEnabled]);
115
+ }, [apiRef, props.headerFilters]);
119
116
  };
120
117
  exports.useGridHeaderFiltering = useGridHeaderFiltering;
@@ -77,9 +77,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
77
77
  const initialCurrentPageRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props).rows;
78
78
  const theme = (0, _styles.useTheme)();
79
79
  const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
80
- const headerFilteringEnabled =
81
- // @ts-expect-error // TODO move relevant code to the `DataGridPro`
82
- props.signature !== 'DataGrid' && props.headerFilters;
80
+ const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
83
81
 
84
82
  /**
85
83
  * @param {number} colIndex Index of the column to focus
@@ -50,9 +50,9 @@ const EMPTY_SCROLL_POSITION = {
50
50
  left: 0
51
51
  };
52
52
  const EMPTY_DETAIL_PANELS = exports.EMPTY_DETAIL_PANELS = Object.freeze(new Map());
53
- const createScrollCache = (rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
53
+ const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) => ({
54
54
  direction: ScrollDirection.NONE,
55
- buffer: bufferForDirection(ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
55
+ buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
56
56
  });
57
57
  const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
58
58
  const useGridVirtualScroller = () => {
@@ -104,7 +104,7 @@ const useGridVirtualScroller = () => {
104
104
  const renderContext = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridRenderContextSelector);
105
105
  const scrollTimeout = (0, _useTimeout.default)();
106
106
  const frozenContext = React.useRef(undefined);
107
- const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
107
+ const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(theme.direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
108
108
  const focusedCell = {
109
109
  rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
110
110
  columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
@@ -169,7 +169,7 @@ const useGridVirtualScroller = () => {
169
169
  }
170
170
  }
171
171
  scrollCache.direction = direction;
172
- scrollCache.buffer = bufferForDirection(direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
172
+ scrollCache.buffer = bufferForDirection(theme.direction, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
173
173
  const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
174
174
  const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
175
175
 
@@ -651,7 +651,7 @@ function areRenderContextsEqual(context1, context2) {
651
651
  function computeOffsetLeft(columnPositions, renderContext, direction, pinnedLeftLength) {
652
652
  const factor = direction === 'ltr' ? 1 : -1;
653
653
  const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
654
- return left;
654
+ return Math.abs(left);
655
655
  }
656
656
  function directionForDelta(dx, dy) {
657
657
  if (dx === 0 && dy === 0) {
@@ -673,7 +673,18 @@ function directionForDelta(dx, dy) {
673
673
  }
674
674
  /* eslint-enable */
675
675
  }
676
- function bufferForDirection(direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
676
+ function bufferForDirection(mode, direction, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer) {
677
+ if (mode === 'rtl') {
678
+ switch (direction) {
679
+ case ScrollDirection.LEFT:
680
+ direction = ScrollDirection.RIGHT;
681
+ break;
682
+ case ScrollDirection.RIGHT:
683
+ direction = ScrollDirection.LEFT;
684
+ break;
685
+ default:
686
+ }
687
+ }
677
688
  switch (direction) {
678
689
  case ScrollDirection.NONE:
679
690
  return {
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0
2
+ * @mui/x-data-grid v7.1.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -3,13 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.validateProps = exports.propValidatorsDataGrid = void 0;
7
- const propValidatorsDataGrid = exports.propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined];
8
- const warnedOnceMap = new Set();
6
+ exports.validateProps = exports.propValidatorsDataGrid = exports.clearWarningsCache = void 0;
7
+ var _utils = require("../../utils/utils");
8
+ var _useGridApiEventHandler = require("../../hooks/utils/useGridApiEventHandler");
9
+ const propValidatorsDataGrid = exports.propValidatorsDataGrid = [props => props.autoPageSize && props.autoHeight && ['MUI X: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You cannot use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n') || undefined, props => props.signature === _useGridApiEventHandler.GridSignature.DataGrid && props.paginationMode === 'client' && (0, _utils.isNumber)(props.rowCount) && 'MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect. `rowCount` is only meant to be used with `paginationMode="server"`.' || undefined];
10
+ const warnedOnceCache = new Set();
9
11
  const warnOnce = message => {
10
- if (!warnedOnceMap.has(message)) {
12
+ if (!warnedOnceCache.has(message)) {
11
13
  console.error(message);
12
- warnedOnceMap.add(message);
14
+ warnedOnceCache.add(message);
13
15
  }
14
16
  };
15
17
  const validateProps = (props, validators) => {
@@ -23,4 +25,8 @@ const validateProps = (props, validators) => {
23
25
  }
24
26
  });
25
27
  };
26
- exports.validateProps = validateProps;
28
+ exports.validateProps = validateProps;
29
+ const clearWarningsCache = () => {
30
+ warnedOnceCache.clear();
31
+ };
32
+ exports.clearWarningsCache = clearWarningsCache;
@@ -36,10 +36,9 @@ const esESGrid = {
36
36
  toolbarExportPrint: 'Imprimir',
37
37
  toolbarExportExcel: 'Descargar como Excel',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
-
39
+ columnsManagementSearchTitle: 'Buscar',
40
+ columnsManagementNoColumns: 'Sin columnas',
41
+ columnsManagementShowHideAllText: 'Mostrar/Ocultar todas',
43
42
  // Filter panel text
44
43
  filterPanelAddFilter: 'Agregar filtro',
45
44
  filterPanelRemoveAll: 'Remover todos',
@@ -36,10 +36,9 @@ const faIRGrid = {
36
36
  toolbarExportPrint: 'چاپ',
37
37
  toolbarExportExcel: 'دانلود به صورت اکسل',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
-
39
+ columnsManagementSearchTitle: 'جستجو',
40
+ columnsManagementNoColumns: 'بدون سطر',
41
+ columnsManagementShowHideAllText: 'نمایش/مخفی کردن همه',
43
42
  // Filter panel text
44
43
  filterPanelAddFilter: 'افزودن فیلتر',
45
44
  filterPanelRemoveAll: 'حذف همه',
@@ -36,10 +36,9 @@ const ptBRGrid = {
36
36
  toolbarExportPrint: 'Imprimir',
37
37
  toolbarExportExcel: 'Baixar como Excel',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
-
39
+ columnsManagementSearchTitle: 'Buscar',
40
+ columnsManagementNoColumns: 'Nenhuma coluna',
41
+ columnsManagementShowHideAllText: 'Mostrar/Ocultar Todas',
43
42
  // Filter panel text
44
43
  filterPanelAddFilter: 'Adicionar filtro',
45
44
  filterPanelRemoveAll: 'Remover todos',
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.throttle = throttle;
7
+ function throttle(func, wait = 166) {
8
+ let timeout;
9
+ let lastArgs;
10
+ const later = () => {
11
+ timeout = undefined;
12
+ func(...lastArgs);
13
+ };
14
+ function throttled(...args) {
15
+ lastArgs = args;
16
+ if (timeout === undefined) {
17
+ timeout = setTimeout(later, wait);
18
+ }
19
+ }
20
+ throttled.clear = () => {
21
+ clearTimeout(timeout);
22
+ timeout = undefined;
23
+ };
24
+ return throttled;
25
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.0.0",
4
- "description": "The community edition of the data grid component (MUI X).",
3
+ "version": "7.1.1",
4
+ "description": "The Community plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
7
7
  "license": "MIT",
@@ -0,0 +1,4 @@
1
+ export interface Cancelable {
2
+ clear(): void;
3
+ }
4
+ export declare function throttle<T extends (...args: any[]) => any>(func: T, wait?: number): T & Cancelable;
@@ -0,0 +1,19 @@
1
+ export function throttle(func, wait = 166) {
2
+ let timeout;
3
+ let lastArgs;
4
+ const later = () => {
5
+ timeout = undefined;
6
+ func(...lastArgs);
7
+ };
8
+ function throttled(...args) {
9
+ lastArgs = args;
10
+ if (timeout === undefined) {
11
+ timeout = setTimeout(later, wait);
12
+ }
13
+ }
14
+ throttled.clear = () => {
15
+ clearTimeout(timeout);
16
+ timeout = undefined;
17
+ };
18
+ return throttled;
19
+ }