@mui/x-data-grid 6.11.0 → 6.11.2

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 (78) hide show
  1. package/CHANGELOG.md +119 -1
  2. package/DataGrid/DataGrid.d.ts +10 -0
  3. package/DataGrid/DataGrid.js +24 -1
  4. package/DataGrid/useDataGridProps.js +2 -0
  5. package/components/GridPagination.d.ts +6 -2
  6. package/components/cell/GridActionsCellItem.d.ts +6 -2
  7. package/components/panel/GridPanel.d.ts +2 -2
  8. package/components/panel/filterPanel/GridFilterInputDate.d.ts +0 -1
  9. package/components/panel/filterPanel/GridFilterInputDate.js +5 -11
  10. package/components/panel/filterPanel/GridFilterInputValue.d.ts +0 -1
  11. package/components/panel/filterPanel/GridFilterInputValue.js +16 -18
  12. package/components/panel/filterPanel/GridFilterPanel.js +1 -3
  13. package/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
  14. package/components/toolbar/GridToolbarQuickFilter.js +5 -5
  15. package/hooks/features/export/useGridPrintExport.js +0 -5
  16. package/hooks/features/export/utils.js +7 -1
  17. package/hooks/features/filter/gridFilterUtils.d.ts +2 -2
  18. package/hooks/features/filter/gridFilterUtils.js +23 -19
  19. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  20. package/hooks/features/filter/useGridFilter.js +2 -2
  21. package/hooks/features/rows/useGridRows.js +11 -0
  22. package/hooks/utils/useTimeout.d.ts +9 -0
  23. package/hooks/utils/useTimeout.js +28 -0
  24. package/index.js +1 -1
  25. package/legacy/DataGrid/DataGrid.js +24 -1
  26. package/legacy/DataGrid/useDataGridProps.js +2 -0
  27. package/legacy/components/panel/filterPanel/GridFilterInputDate.js +5 -11
  28. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +16 -18
  29. package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -3
  30. package/legacy/components/toolbar/GridToolbarQuickFilter.js +5 -5
  31. package/legacy/hooks/features/export/useGridPrintExport.js +0 -5
  32. package/legacy/hooks/features/export/utils.js +8 -6
  33. package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
  34. package/legacy/hooks/features/filter/useGridFilter.js +2 -2
  35. package/legacy/hooks/features/rows/useGridRows.js +11 -0
  36. package/legacy/hooks/utils/useTimeout.js +38 -0
  37. package/legacy/index.js +1 -1
  38. package/legacy/locales/esES.js +26 -28
  39. package/legacy/locales/zhCN.js +25 -27
  40. package/legacy/locales/zhTW.js +34 -38
  41. package/locales/esES.js +26 -28
  42. package/locales/zhCN.js +25 -27
  43. package/locales/zhTW.js +34 -38
  44. package/models/api/gridRowApi.d.ts +6 -0
  45. package/models/props/DataGridProps.d.ts +11 -0
  46. package/modern/DataGrid/DataGrid.js +24 -1
  47. package/modern/DataGrid/useDataGridProps.js +2 -0
  48. package/modern/components/panel/filterPanel/GridFilterInputDate.js +5 -11
  49. package/modern/components/panel/filterPanel/GridFilterInputValue.js +15 -17
  50. package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -3
  51. package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -5
  52. package/modern/hooks/features/export/useGridPrintExport.js +0 -5
  53. package/modern/hooks/features/export/utils.js +7 -1
  54. package/modern/hooks/features/filter/gridFilterUtils.js +23 -19
  55. package/modern/hooks/features/filter/useGridFilter.js +2 -2
  56. package/modern/hooks/features/rows/useGridRows.js +11 -0
  57. package/modern/hooks/utils/useTimeout.js +28 -0
  58. package/modern/index.js +1 -1
  59. package/modern/locales/esES.js +26 -28
  60. package/modern/locales/zhCN.js +25 -27
  61. package/modern/locales/zhTW.js +34 -38
  62. package/node/DataGrid/DataGrid.js +26 -1
  63. package/node/DataGrid/useDataGridProps.js +2 -0
  64. package/node/components/panel/filterPanel/GridFilterInputDate.js +5 -13
  65. package/node/components/panel/filterPanel/GridFilterInputValue.js +15 -19
  66. package/node/components/panel/filterPanel/GridFilterPanel.js +1 -3
  67. package/node/components/toolbar/GridToolbarQuickFilter.js +5 -5
  68. package/node/hooks/features/export/useGridPrintExport.js +0 -5
  69. package/node/hooks/features/export/utils.js +7 -1
  70. package/node/hooks/features/filter/gridFilterUtils.js +23 -19
  71. package/node/hooks/features/filter/useGridFilter.js +2 -2
  72. package/node/hooks/features/rows/useGridRows.js +11 -0
  73. package/node/hooks/utils/useTimeout.js +34 -0
  74. package/node/index.js +1 -1
  75. package/node/locales/esES.js +26 -28
  76. package/node/locales/zhCN.js +25 -27
  77. package/node/locales/zhTW.js +34 -38
  78. package/package.json +3 -3
@@ -4,6 +4,13 @@ import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
4
4
  import { getDefaultGridFilterModel } from './gridFilterState';
5
5
  import { buildWarning } from '../../../utils/warning';
6
6
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
7
+ let hasEval;
8
+ try {
9
+ // eslint-disable-next-line no-eval
10
+ hasEval = eval('true');
11
+ } catch (_) {
12
+ hasEval = false;
13
+ }
7
14
  /**
8
15
  * Adds default values to the optional fields of a filter items.
9
16
  * @param {GridFilterItem} item The raw filter item.
@@ -127,7 +134,7 @@ let filterItemsApplierId = 1;
127
134
  * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
128
135
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
129
136
  */
130
- export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef) => {
137
+ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef, disableEval) => {
131
138
  const {
132
139
  items
133
140
  } = filterModel;
@@ -135,22 +142,19 @@ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef)
135
142
  if (appliers.length === 0) {
136
143
  return null;
137
144
  }
138
-
139
- // Original logic:
140
- // return (row, shouldApplyFilter) => {
141
- // const resultPerItemId: GridFilterItemResult = {};
142
- //
143
- // for (let i = 0; i < appliers.length; i += 1) {
144
- // const applier = appliers[i];
145
- // if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
146
- // resultPerItemId[applier.item.id!] = applier.v7
147
- // ? applier.fn(row)
148
- // : applier.fn(getRowId ? getRowId(row) : row.id);
149
- // }
150
- // }
151
- //
152
- // return resultPerItemId;
153
- // };
145
+ if (!hasEval || disableEval) {
146
+ // This is the original logic, which is used if `eval()` is not supported (aka prevented by CSP).
147
+ return (row, shouldApplyFilter) => {
148
+ const resultPerItemId = {};
149
+ for (let i = 0; i < appliers.length; i += 1) {
150
+ const applier = appliers[i];
151
+ if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
152
+ resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId ? getRowId(row) : row.id);
153
+ }
154
+ }
155
+ return resultPerItemId;
156
+ };
157
+ }
154
158
 
155
159
  // We generate a new function with `eval()` to avoid expensive patterns for JS engines
156
160
  // such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
@@ -260,8 +264,8 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
260
264
  return result;
261
265
  };
262
266
  };
263
- export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef) => {
264
- const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef);
267
+ export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef, disableEval) => {
268
+ const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef, disableEval);
265
269
  const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(getRowId, filterModel, apiRef);
266
270
  return function isRowMatchingFilters(row, shouldApplyFilter, result) {
267
271
  var _isRowMatchingFilterI, _isRowMatchingQuickFi;
@@ -8,4 +8,4 @@ export declare const filterStateInitializer: GridStateInitializer<Pick<DataGridP
8
8
  * @requires useGridParamsApi (method)
9
9
  * @requires useGridRows (event)
10
10
  */
11
- export declare const useGridFilter: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rows' | 'initialState' | 'filterModel' | 'getRowId' | 'onFilterModelChange' | 'filterMode' | 'disableMultipleColumnsFiltering' | 'slots' | 'slotProps' | 'disableColumnFilter'>) => void;
11
+ export declare const useGridFilter: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rows' | 'initialState' | 'filterModel' | 'getRowId' | 'onFilterModelChange' | 'filterMode' | 'disableMultipleColumnsFiltering' | 'slots' | 'slotProps' | 'disableColumnFilter' | 'disableEval'>) => void;
@@ -61,7 +61,7 @@ export const useGridFilter = (apiRef, props) => {
61
61
  const updateFilteredRows = React.useCallback(() => {
62
62
  apiRef.current.setState(state => {
63
63
  const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
64
- const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef) : null;
64
+ const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef, props.disableEval) : null;
65
65
  const filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
66
66
  isRowMatchingFilters,
67
67
  filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
@@ -75,7 +75,7 @@ export const useGridFilter = (apiRef, props) => {
75
75
  });
76
76
  });
77
77
  apiRef.current.publishEvent('filteredRowsSet');
78
- }, [apiRef, props.filterMode, props.getRowId]);
78
+ }, [apiRef, props.filterMode, props.getRowId, props.disableEval]);
79
79
  const addColumnMenuItem = React.useCallback((columnMenuItems, colDef) => {
80
80
  if (colDef == null || colDef.filterable === false || props.disableColumnFilter) {
81
81
  return columnMenuItems;
@@ -52,6 +52,16 @@ export const useGridRows = (apiRef, props) => {
52
52
  }
53
53
  return null;
54
54
  }, [apiRef]);
55
+ const getRowIdProp = props.getRowId;
56
+ const getRowId = React.useCallback(row => {
57
+ if (GRID_ID_AUTOGENERATED in row) {
58
+ return row[GRID_ID_AUTOGENERATED];
59
+ }
60
+ if (getRowIdProp) {
61
+ return getRowIdProp(row);
62
+ }
63
+ return row.id;
64
+ }, [getRowIdProp]);
55
65
  const lookup = React.useMemo(() => currentPage.rows.reduce((acc, {
56
66
  id
57
67
  }, index) => {
@@ -297,6 +307,7 @@ export const useGridRows = (apiRef, props) => {
297
307
  }, [apiRef, props.signature, props.getRowId]);
298
308
  const rowApi = {
299
309
  getRow,
310
+ getRowId,
300
311
  getRowModels,
301
312
  getRowsCount,
302
313
  getAllRowIds,
@@ -0,0 +1,9 @@
1
+ declare class Timeout {
2
+ static create(): Timeout;
3
+ currentId: number;
4
+ start(delay: number, fn: Function): void;
5
+ clear: () => void;
6
+ disposeEffect: () => () => void;
7
+ }
8
+ export declare function useTimeout(): Timeout;
9
+ export {};
@@ -0,0 +1,28 @@
1
+ import { useLazyRef } from './useLazyRef';
2
+ import { useOnMount } from './useOnMount';
3
+ class Timeout {
4
+ constructor() {
5
+ this.currentId = 0;
6
+ this.clear = () => {
7
+ if (this.currentId !== 0) {
8
+ clearTimeout(this.currentId);
9
+ this.currentId = 0;
10
+ }
11
+ };
12
+ this.disposeEffect = () => {
13
+ return this.clear;
14
+ };
15
+ }
16
+ static create() {
17
+ return new Timeout();
18
+ }
19
+ start(delay, fn) {
20
+ this.clear();
21
+ this.currentId = setTimeout(fn, delay);
22
+ }
23
+ }
24
+ export function useTimeout() {
25
+ const timeout = useLazyRef(Timeout.create).current;
26
+ useOnMount(timeout.disposeEffect);
27
+ return timeout;
28
+ }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.11.0
2
+ * @mui/x-data-grid v6.11.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -5,7 +5,7 @@ import { chainPropTypes } from '@mui/utils';
5
5
  import { GridBody, GridFooterPlaceholder, GridHeader, GridRoot } from '../components';
6
6
  import { GridContextProvider } from '../context/GridContextProvider';
7
7
  import { useDataGridComponent } from './useDataGridComponent';
8
- import { useDataGridProps } from './useDataGridProps';
8
+ import { useDataGridProps, DATA_GRID_PROPS_DEFAULT_VALUES } from './useDataGridProps';
9
9
  import { DataGridVirtualScroller } from '../components/DataGridVirtualScroller';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -28,6 +28,18 @@ var DataGridRaw = /*#__PURE__*/React.forwardRef(function DataGrid(inProps, ref)
28
28
  });
29
29
  });
30
30
  export var DataGrid = /*#__PURE__*/React.memo(DataGridRaw);
31
+
32
+ /**
33
+ * Remove at v7
34
+ * @deprecated
35
+ */
36
+ export var SUBMIT_FILTER_STROKE_TIME = DATA_GRID_PROPS_DEFAULT_VALUES.filterDebounceMs;
37
+
38
+ /**
39
+ * Remove at v7
40
+ * @deprecated
41
+ */
42
+ export var SUBMIT_FILTER_DATE_STROKE_TIME = DATA_GRID_PROPS_DEFAULT_VALUES.filterDebounceMs;
31
43
  DataGridRaw.propTypes = {
32
44
  // ----------------------------- Warning --------------------------------
33
45
  // | These PropTypes are generated from the TypeScript type definitions |
@@ -143,6 +155,12 @@ DataGridRaw.propTypes = {
143
155
  * @default false
144
156
  */
145
157
  disableDensitySelector: PropTypes.bool,
158
+ /**
159
+ * If `true`, `eval()` is not used for performance optimization.
160
+ * @default false
161
+ * @ignore - do not document
162
+ */
163
+ disableEval: PropTypes.bool,
146
164
  /**
147
165
  * If `true`, the selection on click on a row or cell is disabled.
148
166
  * @default false
@@ -167,6 +185,11 @@ DataGridRaw.propTypes = {
167
185
  columnGrouping: PropTypes.bool,
168
186
  warnIfFocusStateIsNotSynced: PropTypes.bool
169
187
  }),
188
+ /**
189
+ * The milliseconds delay to wait after a keystroke before triggering filtering.
190
+ * @default 150
191
+ */
192
+ filterDebounceMs: PropTypes.number,
170
193
  /**
171
194
  * Filtering can be processed on the server or client-side.
172
195
  * Set it to 'server' if you would like to handle filtering on the server-side.
@@ -38,6 +38,7 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
38
38
  disableColumnMenu: false,
39
39
  disableColumnSelector: false,
40
40
  disableDensitySelector: false,
41
+ disableEval: false,
41
42
  disableMultipleColumnsFiltering: false,
42
43
  disableMultipleRowSelection: false,
43
44
  disableMultipleColumnsSorting: false,
@@ -45,6 +46,7 @@ export var DATA_GRID_PROPS_DEFAULT_VALUES = {
45
46
  disableVirtualization: false,
46
47
  editMode: GridEditModes.Cell,
47
48
  filterMode: 'client',
49
+ filterDebounceMs: 150,
48
50
  columnHeaderHeight: 56,
49
51
  hideFooter: false,
50
52
  hideFooterPagination: false,
@@ -5,9 +5,9 @@ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "Inp
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { unstable_useId as useId } from '@mui/utils';
8
+ import { useTimeout } from '../../../hooks/utils/useTimeout';
8
9
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export var SUBMIT_FILTER_DATE_STROKE_TIME = 500;
11
11
  function GridFilterInputDate(props) {
12
12
  var _item$value, _rootProps$slotProps;
13
13
  var item = props.item,
@@ -21,7 +21,7 @@ function GridFilterInputDate(props) {
21
21
  tabIndex = props.tabIndex,
22
22
  disabled = props.disabled,
23
23
  other = _objectWithoutProperties(props, _excluded);
24
- var filterTimeout = React.useRef();
24
+ var filterTimeout = useTimeout();
25
25
  var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
26
26
  _React$useState2 = _slicedToArray(_React$useState, 2),
27
27
  filterValueState = _React$useState2[0],
@@ -34,21 +34,15 @@ function GridFilterInputDate(props) {
34
34
  var rootProps = useGridRootProps();
35
35
  var onFilterChange = React.useCallback(function (event) {
36
36
  var value = event.target.value;
37
- clearTimeout(filterTimeout.current);
38
37
  setFilterValueState(String(value));
39
38
  setIsApplying(true);
40
- filterTimeout.current = setTimeout(function () {
39
+ filterTimeout.start(rootProps.filterDebounceMs, function () {
41
40
  applyValue(_extends({}, item, {
42
41
  value: value
43
42
  }));
44
43
  setIsApplying(false);
45
- }, SUBMIT_FILTER_DATE_STROKE_TIME);
46
- }, [applyValue, item]);
47
- React.useEffect(function () {
48
- return function () {
49
- clearTimeout(filterTimeout.current);
50
- };
51
- }, []);
44
+ });
45
+ }, [applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
52
46
  React.useEffect(function () {
53
47
  var _item$value2;
54
48
  var itemValue = (_item$value2 = item.value) != null ? _item$value2 : '';
@@ -5,9 +5,9 @@ var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tab
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { unstable_useId as useId } from '@mui/utils';
8
+ import { useTimeout } from '../../../hooks/utils/useTimeout';
8
9
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export var SUBMIT_FILTER_STROKE_TIME = 500;
11
11
  function GridFilterInputValue(props) {
12
12
  var _item$value, _rootProps$slotProps;
13
13
  var item = props.item,
@@ -21,7 +21,7 @@ function GridFilterInputValue(props) {
21
21
  clearButton = props.clearButton,
22
22
  InputProps = props.InputProps,
23
23
  others = _objectWithoutProperties(props, _excluded);
24
- var filterTimeout = React.useRef();
24
+ var filterTimeout = useTimeout();
25
25
  var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
26
26
  _React$useState2 = _slicedToArray(_React$useState, 2),
27
27
  filterValueState = _React$useState2[0],
@@ -34,26 +34,24 @@ function GridFilterInputValue(props) {
34
34
  var rootProps = useGridRootProps();
35
35
  var onFilterChange = React.useCallback(function (event) {
36
36
  var value = event.target.value;
37
- clearTimeout(filterTimeout.current);
38
37
  setFilterValueState(String(value));
39
38
  setIsApplying(true);
40
- filterTimeout.current = setTimeout(function () {
41
- applyValue(_extends({}, item, {
42
- value: value
43
- }));
39
+ filterTimeout.start(rootProps.filterDebounceMs, function () {
40
+ var newItem = _extends({}, item, {
41
+ value: value,
42
+ fromInput: id
43
+ });
44
+ applyValue(newItem);
44
45
  setIsApplying(false);
45
- }, SUBMIT_FILTER_STROKE_TIME);
46
- }, [applyValue, item]);
46
+ });
47
+ }, [id, applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
47
48
  React.useEffect(function () {
48
- return function () {
49
- clearTimeout(filterTimeout.current);
50
- };
51
- }, []);
52
- React.useEffect(function () {
53
- var _item$value2;
54
- var itemValue = (_item$value2 = item.value) != null ? _item$value2 : '';
55
- setFilterValueState(String(itemValue));
56
- }, [item.value]);
49
+ var itemPlusTag = item;
50
+ if (itemPlusTag.fromInput !== id) {
51
+ var _item$value2;
52
+ setFilterValueState(String((_item$value2 = item.value) != null ? _item$value2 : ''));
53
+ }
54
+ }, [id, item]);
57
55
  return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
58
56
  id: id,
59
57
  label: apiRef.current.getLocaleText('filterPanelInputLabel'),
@@ -42,9 +42,7 @@ var GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(pro
42
42
  _props$disableRemoveA = props.disableRemoveAllButton,
43
43
  disableRemoveAllButton = _props$disableRemoveA === void 0 ? false : _props$disableRemoveA,
44
44
  other = _objectWithoutProperties(props, _excluded);
45
- var applyFilter = React.useCallback(function (item) {
46
- apiRef.current.upsertFilterItem(item);
47
- }, [apiRef]);
45
+ var applyFilter = apiRef.current.upsertFilterItem;
48
46
  var applyFilterLogicOperator = React.useCallback(function (operator) {
49
47
  apiRef.current.setFilterLogicOperator(operator);
50
48
  }, [apiRef]);
@@ -52,16 +52,16 @@ var defaultSearchValueFormatter = function defaultSearchValueFormatter(values) {
52
52
  };
53
53
  function GridToolbarQuickFilter(props) {
54
54
  var _rootProps$slotProps, _rootProps$slotProps2;
55
+ var apiRef = useGridApiContext();
56
+ var rootProps = useGridRootProps();
57
+ var quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
55
58
  var _props$quickFilterPar = props.quickFilterParser,
56
59
  quickFilterParser = _props$quickFilterPar === void 0 ? defaultSearchValueParser : _props$quickFilterPar,
57
60
  _props$quickFilterFor = props.quickFilterFormatter,
58
61
  quickFilterFormatter = _props$quickFilterFor === void 0 ? defaultSearchValueFormatter : _props$quickFilterFor,
59
62
  _props$debounceMs = props.debounceMs,
60
- debounceMs = _props$debounceMs === void 0 ? 500 : _props$debounceMs,
63
+ debounceMs = _props$debounceMs === void 0 ? rootProps.filterDebounceMs : _props$debounceMs,
61
64
  other = _objectWithoutProperties(props, _excluded);
62
- var apiRef = useGridApiContext();
63
- var rootProps = useGridRootProps();
64
- var quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
65
65
  var _React$useState = React.useState(function () {
66
66
  return quickFilterFormatter(quickFilterValues != null ? quickFilterValues : []);
67
67
  }),
@@ -133,7 +133,7 @@ process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
133
133
  // ----------------------------------------------------------------------
134
134
  /**
135
135
  * The debounce time in milliseconds.
136
- * @default 500
136
+ * @default 150
137
137
  */
138
138
  debounceMs: PropTypes.number,
139
139
  /**
@@ -50,11 +50,6 @@ export var useGridPrintExport = function useGridPrintExport(apiRef, props) {
50
50
  // the new state needs to be in place before the grid can be sized correctly
51
51
  var updateGridColumnsForPrint = React.useCallback(function (fields, allColumns) {
52
52
  return new Promise(function (resolve) {
53
- // TODO remove unused Promise
54
- if (!fields && !allColumns) {
55
- resolve();
56
- return;
57
- }
58
53
  var exportedColumnFields = getColumnsToExport({
59
54
  apiRef: apiRef,
60
55
  options: {
@@ -7,13 +7,15 @@ export var getColumnsToExport = function getColumnsToExport(_ref) {
7
7
  options = _ref.options;
8
8
  var columns = gridColumnDefinitionsSelector(apiRef);
9
9
  if (options.fields) {
10
- return options.fields.map(function (field) {
11
- return columns.find(function (column) {
12
- return column.field === field;
10
+ return options.fields.reduce(function (currentColumns, field) {
11
+ var column = columns.find(function (col) {
12
+ return col.field === field;
13
13
  });
14
- }).filter(function (column) {
15
- return !!column;
16
- });
14
+ if (column) {
15
+ currentColumns.push(column);
16
+ }
17
+ return currentColumns;
18
+ }, []);
17
19
  }
18
20
  var validColumns = options.allColumns ? columns : gridVisibleColumnDefinitionsSelector(apiRef);
19
21
  return validColumns.filter(function (column) {
@@ -4,6 +4,13 @@ import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
4
4
  import { getDefaultGridFilterModel } from './gridFilterState';
5
5
  import { buildWarning } from '../../../utils/warning';
6
6
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
7
+ var hasEval;
8
+ try {
9
+ // eslint-disable-next-line no-eval
10
+ hasEval = eval('true');
11
+ } catch (_) {
12
+ hasEval = false;
13
+ }
7
14
  /**
8
15
  * Adds default values to the optional fields of a filter items.
9
16
  * @param {GridFilterItem} item The raw filter item.
@@ -141,7 +148,7 @@ var filterItemsApplierId = 1;
141
148
  * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
142
149
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
143
150
  */
144
- export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef) {
151
+ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef, disableEval) {
145
152
  var items = filterModel.items;
146
153
  var appliers = items.map(function (item) {
147
154
  return getFilterCallbackFromItem(item, apiRef);
@@ -151,22 +158,19 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
151
158
  if (appliers.length === 0) {
152
159
  return null;
153
160
  }
154
-
155
- // Original logic:
156
- // return (row, shouldApplyFilter) => {
157
- // const resultPerItemId: GridFilterItemResult = {};
158
- //
159
- // for (let i = 0; i < appliers.length; i += 1) {
160
- // const applier = appliers[i];
161
- // if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
162
- // resultPerItemId[applier.item.id!] = applier.v7
163
- // ? applier.fn(row)
164
- // : applier.fn(getRowId ? getRowId(row) : row.id);
165
- // }
166
- // }
167
- //
168
- // return resultPerItemId;
169
- // };
161
+ if (!hasEval || disableEval) {
162
+ // This is the original logic, which is used if `eval()` is not supported (aka prevented by CSP).
163
+ return function (row, shouldApplyFilter) {
164
+ var resultPerItemId = {};
165
+ for (var i = 0; i < appliers.length; i += 1) {
166
+ var applier = appliers[i];
167
+ if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
168
+ resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId ? getRowId(row) : row.id);
169
+ }
170
+ }
171
+ return resultPerItemId;
172
+ };
173
+ }
170
174
 
171
175
  // We generate a new function with `eval()` to avoid expensive patterns for JS engines
172
176
  // such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
@@ -270,8 +274,8 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
270
274
  return result;
271
275
  };
272
276
  };
273
- export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(getRowId, filterModel, apiRef) {
274
- var isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef);
277
+ export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(getRowId, filterModel, apiRef, disableEval) {
278
+ var isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef, disableEval);
275
279
  var isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(getRowId, filterModel, apiRef);
276
280
  return function isRowMatchingFilters(row, shouldApplyFilter, result) {
277
281
  var _isRowMatchingFilterI, _isRowMatchingQuickFi;
@@ -62,7 +62,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
62
62
  var updateFilteredRows = React.useCallback(function () {
63
63
  apiRef.current.setState(function (state) {
64
64
  var filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
65
- var isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef) : null;
65
+ var isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef, props.disableEval) : null;
66
66
  var filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
67
67
  isRowMatchingFilters: isRowMatchingFilters,
68
68
  filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
@@ -76,7 +76,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
76
76
  });
77
77
  });
78
78
  apiRef.current.publishEvent('filteredRowsSet');
79
- }, [apiRef, props.filterMode, props.getRowId]);
79
+ }, [apiRef, props.filterMode, props.getRowId, props.disableEval]);
80
80
  var addColumnMenuItem = React.useCallback(function (columnMenuItems, colDef) {
81
81
  if (colDef == null || colDef.filterable === false || props.disableColumnFilter) {
82
82
  return columnMenuItems;
@@ -53,6 +53,16 @@ export var useGridRows = function useGridRows(apiRef, props) {
53
53
  }
54
54
  return null;
55
55
  }, [apiRef]);
56
+ var getRowIdProp = props.getRowId;
57
+ var getRowId = React.useCallback(function (row) {
58
+ if (GRID_ID_AUTOGENERATED in row) {
59
+ return row[GRID_ID_AUTOGENERATED];
60
+ }
61
+ if (getRowIdProp) {
62
+ return getRowIdProp(row);
63
+ }
64
+ return row.id;
65
+ }, [getRowIdProp]);
56
66
  var lookup = React.useMemo(function () {
57
67
  return currentPage.rows.reduce(function (acc, _ref2, index) {
58
68
  var id = _ref2.id;
@@ -314,6 +324,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
314
324
  }, [apiRef, props.signature, props.getRowId]);
315
325
  var rowApi = {
316
326
  getRow: getRow,
327
+ getRowId: getRowId,
317
328
  getRowModels: getRowModels,
318
329
  getRowsCount: getRowsCount,
319
330
  getAllRowIds: getAllRowIds,
@@ -0,0 +1,38 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import { useLazyRef } from './useLazyRef';
4
+ import { useOnMount } from './useOnMount';
5
+ var Timeout = /*#__PURE__*/function () {
6
+ function Timeout() {
7
+ var _this = this;
8
+ _classCallCheck(this, Timeout);
9
+ this.currentId = 0;
10
+ this.clear = function () {
11
+ if (_this.currentId !== 0) {
12
+ clearTimeout(_this.currentId);
13
+ _this.currentId = 0;
14
+ }
15
+ };
16
+ this.disposeEffect = function () {
17
+ return _this.clear;
18
+ };
19
+ }
20
+ _createClass(Timeout, [{
21
+ key: "start",
22
+ value: function start(delay, fn) {
23
+ this.clear();
24
+ this.currentId = setTimeout(fn, delay);
25
+ }
26
+ }], [{
27
+ key: "create",
28
+ value: function create() {
29
+ return new Timeout();
30
+ }
31
+ }]);
32
+ return Timeout;
33
+ }();
34
+ export function useTimeout() {
35
+ var timeout = useLazyRef(Timeout.create).current;
36
+ useOnMount(timeout.disposeEffect);
37
+ return timeout;
38
+ }
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.11.0
2
+ * @mui/x-data-grid v6.11.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -59,37 +59,35 @@ var esESGrid = {
59
59
  filterOperatorOnOrAfter: 'es en o posterior',
60
60
  filterOperatorBefore: 'es anterior',
61
61
  filterOperatorOnOrBefore: 'es en o anterior',
62
- filterOperatorIsEmpty: 'está vacío',
62
+ filterOperatorIsEmpty: 'esta vacío',
63
63
  filterOperatorIsNotEmpty: 'no esta vacío',
64
64
  filterOperatorIsAnyOf: 'es cualquiera de',
65
- // 'filterOperator=': '=',
66
- // 'filterOperator!=': '!=',
67
- // 'filterOperator>': '>',
68
- // 'filterOperator>=': '>=',
69
- // 'filterOperator<': '<',
70
- // 'filterOperator<=': '<=',
71
-
65
+ 'filterOperator=': '=',
66
+ 'filterOperator!=': '!=',
67
+ 'filterOperator>': '>',
68
+ 'filterOperator>=': '>=',
69
+ 'filterOperator<': '<',
70
+ 'filterOperator<=': '<=',
72
71
  // Header filter operators text
73
- // headerFilterOperatorContains: 'Contains',
74
- // headerFilterOperatorEquals: 'Equals',
75
- // headerFilterOperatorStartsWith: 'Starts with',
76
- // headerFilterOperatorEndsWith: 'Ends with',
77
- // headerFilterOperatorIs: 'Is',
78
- // headerFilterOperatorNot: 'Is not',
79
- // headerFilterOperatorAfter: 'Is after',
80
- // headerFilterOperatorOnOrAfter: 'Is on or after',
81
- // headerFilterOperatorBefore: 'Is before',
82
- // headerFilterOperatorOnOrBefore: 'Is on or before',
83
- // headerFilterOperatorIsEmpty: 'Is empty',
84
- // headerFilterOperatorIsNotEmpty: 'Is not empty',
85
- // headerFilterOperatorIsAnyOf: 'Is any of',
86
- // 'headerFilterOperator=': 'Equals',
87
- // 'headerFilterOperator!=': 'Not equals',
88
- // 'headerFilterOperator>': 'Greater than',
89
- // 'headerFilterOperator>=': 'Greater than or equal to',
90
- // 'headerFilterOperator<': 'Less than',
91
- // 'headerFilterOperator<=': 'Less than or equal to',
92
-
72
+ headerFilterOperatorContains: 'Contiene',
73
+ headerFilterOperatorEquals: 'Es igual a',
74
+ headerFilterOperatorStartsWith: 'Comienza con',
75
+ headerFilterOperatorEndsWith: 'Termina con',
76
+ headerFilterOperatorIs: 'Es',
77
+ headerFilterOperatorNot: 'No es',
78
+ headerFilterOperatorAfter: 'Esta después de',
79
+ headerFilterOperatorOnOrAfter: 'Esta en o después de',
80
+ headerFilterOperatorBefore: 'Esta antes de',
81
+ headerFilterOperatorOnOrBefore: 'Esta en o antes de',
82
+ headerFilterOperatorIsEmpty: 'Esta vacío',
83
+ headerFilterOperatorIsNotEmpty: 'No esta vacío',
84
+ headerFilterOperatorIsAnyOf: 'Es cualquiera de',
85
+ 'headerFilterOperator=': 'Es igual a',
86
+ 'headerFilterOperator!=': 'Es diferente a',
87
+ 'headerFilterOperator>': 'Es mayor que',
88
+ 'headerFilterOperator>=': 'Es mayor o igual que',
89
+ 'headerFilterOperator<': 'Es menor que',
90
+ 'headerFilterOperator<=': 'Es menor o igual que',
93
91
  // Filter values text
94
92
  filterValueAny: 'cualquiera',
95
93
  filterValueTrue: 'verdadero',