@mui/x-data-grid 7.23.4 → 7.23.6

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 (83) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/DataGrid/useDataGridComponent.d.ts +1 -1
  3. package/components/cell/GridActionsCellItem.d.ts +3 -3
  4. package/components/cell/GridEditDateCell.js +1 -1
  5. package/components/cell/GridEditInputCell.js +1 -1
  6. package/components/cell/GridEditSingleSelectCell.js +2 -2
  7. package/components/columnHeaders/ColumnHeaderMenuIcon.d.ts +1 -1
  8. package/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  9. package/components/columnSelection/GridHeaderCheckbox.js +6 -2
  10. package/components/panel/GridPanel.d.ts +1 -1
  11. package/components/panel/filterPanel/GridFilterInputValue.js +7 -10
  12. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
  13. package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +1 -1
  14. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
  15. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
  16. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
  17. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
  18. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
  19. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +1 -1
  20. package/hooks/core/useGridApiInitialization.d.ts +1 -1
  21. package/hooks/core/useGridApiInitialization.js +2 -2
  22. package/hooks/core/useGridInitialization.d.ts +1 -1
  23. package/hooks/core/useGridIsRtl.d.ts +1 -1
  24. package/hooks/core/useGridLocaleText.d.ts +1 -1
  25. package/hooks/core/useGridLoggerFactory.d.ts +1 -1
  26. package/hooks/core/useGridRefs.d.ts +1 -1
  27. package/hooks/core/useGridStateInitialization.d.ts +1 -1
  28. package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
  29. package/hooks/features/columnResize/useGridColumnResize.js +4 -4
  30. package/hooks/features/dimensions/useGridDimensions.js +1 -1
  31. package/hooks/features/editing/useGridRowEditing.js +1 -1
  32. package/hooks/features/export/useGridPrintExport.js +1 -1
  33. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  34. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
  35. package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +1 -1
  36. package/hooks/features/rows/useGridRowsPreProcessors.d.ts +1 -1
  37. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -3
  38. package/hooks/features/virtualization/useGridVirtualScroller.js +5 -1
  39. package/hooks/utils/useGridApiEventHandler.js +1 -1
  40. package/hooks/utils/useGridApiMethod.d.ts +1 -1
  41. package/hooks/utils/useGridApiRef.d.ts +1 -1
  42. package/hooks/utils/useGridInitializeState.d.ts +2 -2
  43. package/hooks/utils/useGridLogger.d.ts +1 -1
  44. package/hooks/utils/useGridVisibleRows.d.ts +2 -2
  45. package/index.js +1 -1
  46. package/models/api/gridCoreApi.d.ts +7 -7
  47. package/models/api/gridDensityApi.d.ts +1 -1
  48. package/models/props/DataGridProps.d.ts +1 -1
  49. package/modern/components/cell/GridEditDateCell.js +1 -1
  50. package/modern/components/cell/GridEditInputCell.js +1 -1
  51. package/modern/components/cell/GridEditSingleSelectCell.js +2 -2
  52. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  53. package/modern/components/columnSelection/GridHeaderCheckbox.js +6 -2
  54. package/modern/components/panel/filterPanel/GridFilterInputValue.js +7 -10
  55. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
  56. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
  57. package/modern/hooks/core/useGridApiInitialization.js +2 -2
  58. package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -4
  59. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
  60. package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
  61. package/modern/hooks/features/export/useGridPrintExport.js +1 -1
  62. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
  63. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -1
  64. package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
  65. package/modern/index.js +1 -1
  66. package/node/components/cell/GridEditDateCell.js +1 -1
  67. package/node/components/cell/GridEditInputCell.js +1 -1
  68. package/node/components/cell/GridEditSingleSelectCell.js +2 -2
  69. package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  70. package/node/components/columnSelection/GridHeaderCheckbox.js +6 -2
  71. package/node/components/panel/filterPanel/GridFilterInputValue.js +7 -10
  72. package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
  73. package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
  74. package/node/hooks/core/useGridApiInitialization.js +2 -2
  75. package/node/hooks/features/columnResize/useGridColumnResize.js +4 -4
  76. package/node/hooks/features/dimensions/useGridDimensions.js +1 -1
  77. package/node/hooks/features/editing/useGridRowEditing.js +1 -1
  78. package/node/hooks/features/export/useGridPrintExport.js +1 -1
  79. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
  80. package/node/hooks/features/virtualization/useGridVirtualScroller.js +5 -1
  81. package/node/hooks/utils/useGridApiEventHandler.js +1 -1
  82. package/node/index.js +1 -1
  83. package/package.json +2 -2
@@ -5,6 +5,6 @@ import { DataGridProcessedProps } from '../../models/props/DataGridProps';
5
5
  type DeepPartial<T> = {
6
6
  [P in keyof T]?: DeepPartial<T[P]>;
7
7
  };
8
- export type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity> = (state: DeepPartial<PrivateApi['state']>, props: P, privateApiRef: React.MutableRefObject<PrivateApi>) => DeepPartial<PrivateApi['state']>;
9
- export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps>, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(initializer: GridStateInitializer<P, PrivateApi>, privateApiRef: React.MutableRefObject<PrivateApi>, props: P) => void;
8
+ export type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity> = (state: DeepPartial<PrivateApi['state']>, props: P, privateApiRef: React.RefObject<PrivateApi>) => DeepPartial<PrivateApi['state']>;
9
+ export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps>, PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(initializer: GridStateInitializer<P, PrivateApi>, privateApiRef: React.RefObject<PrivateApi>, props: P) => void;
10
10
  export {};
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { Logger } from '../../models/logger';
3
3
  import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
4
- export declare function useGridLogger<PrivateApi extends GridPrivateApiCommon>(privateApiRef: React.MutableRefObject<PrivateApi>, name: string): Logger;
4
+ export declare function useGridLogger<PrivateApi extends GridPrivateApiCommon>(privateApiRef: React.RefObject<PrivateApi>, name: string): Logger;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { DataGridProcessedProps } from '../../models/props/DataGridProps';
3
3
  import type { GridApiCommon, GridRowEntry } from '../../models';
4
- export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
4
+ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.RefObject<Api>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
5
5
  rows: GridRowEntry<import("../..").GridValidRowModel>[];
6
6
  range: {
7
7
  firstRowIndex: number;
@@ -15,7 +15,7 @@ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.M
15
15
  * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
16
16
  * - If the row tree is flat, it only contains up to `state.pageSize` rows.
17
17
  */
18
- export declare const useGridVisibleRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
18
+ export declare const useGridVisibleRows: <Api extends GridApiCommon>(apiRef: React.RefObject<Api>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
19
19
  rows: GridRowEntry<import("../..").GridValidRowModel>[];
20
20
  range: {
21
21
  firstRowIndex: number;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.23.4
2
+ * @mui/x-data-grid v7.23.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -13,7 +13,7 @@ export interface GridCoreApi {
13
13
  * The React ref of the grid root container div element.
14
14
  * @ignore - do not document.
15
15
  */
16
- rootElementRef: React.RefObject<HTMLDivElement>;
16
+ rootElementRef: React.RefObject<HTMLDivElement | null>;
17
17
  /**
18
18
  * Registers a handler for an event.
19
19
  * @param {string} event The name of the event.
@@ -59,27 +59,27 @@ export interface GridCorePrivateApi<GridPublicApi extends GridApiCommon, GridPri
59
59
  /**
60
60
  * The React ref of the grid main container div element.
61
61
  */
62
- mainElementRef: React.MutableRefObject<HTMLDivElement | null>;
62
+ mainElementRef: React.RefObject<HTMLDivElement | null>;
63
63
  /**
64
64
  * The React ref of the grid's virtual scroller container element.
65
65
  */
66
- virtualScrollerRef: React.RefObject<HTMLDivElement>;
66
+ virtualScrollerRef: React.RefObject<HTMLDivElement | null>;
67
67
  /**
68
68
  * The React ref of the grid's vertical virtual scrollbar container element.
69
69
  */
70
- virtualScrollbarVerticalRef: React.RefObject<HTMLDivElement>;
70
+ virtualScrollbarVerticalRef: React.RefObject<HTMLDivElement | null>;
71
71
  /**
72
72
  * The React ref of the grid's horizontal virtual scrollbar container element.
73
73
  */
74
- virtualScrollbarHorizontalRef: React.RefObject<HTMLDivElement>;
74
+ virtualScrollbarHorizontalRef: React.RefObject<HTMLDivElement | null>;
75
75
  /**
76
76
  * The React ref of the grid column container virtualized div element.
77
77
  */
78
- columnHeadersContainerRef: React.RefObject<HTMLDivElement>;
78
+ columnHeadersContainerRef: React.RefObject<HTMLDivElement | null>;
79
79
  /**
80
80
  * The React ref of the grid header filter row element.
81
81
  */
82
- headerFiltersElementRef?: React.RefObject<HTMLDivElement>;
82
+ headerFiltersElementRef?: React.RefObject<HTMLDivElement | null>;
83
83
  register: <V extends 'public' | 'private', T extends V extends 'public' ? Partial<GridPublicApi> : Partial<Omit<GridPrivateApi, keyof GridPublicApi>>>(visibility: V, methods: T) => void;
84
84
  /**
85
85
  * Returns the public API.
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { GridDensity } from '../gridDensity';
3
3
  export interface GridDensityOption {
4
- icon: React.ReactElement;
4
+ icon: React.ReactElement<any>;
5
5
  label: string;
6
6
  value: GridDensity;
7
7
  }
@@ -386,7 +386,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
386
386
  /**
387
387
  * The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
388
388
  */
389
- apiRef?: React.MutableRefObject<GridApiCommunity>;
389
+ apiRef?: React.RefObject<GridApiCommunity>;
390
390
  /**
391
391
  * Forwarded props for the Data Grid root element.
392
392
  * @ignore - do not document.
@@ -35,7 +35,7 @@ function GridEditDateCell(props) {
35
35
  other = _objectWithoutPropertiesLoose(props, _excluded);
36
36
  const isDateTime = colDef.type === 'dateTime';
37
37
  const apiRef = useGridApiContext();
38
- const inputRef = React.useRef();
38
+ const inputRef = React.useRef(null);
39
39
  const valueTransformed = React.useMemo(() => {
40
40
  let parsedDate;
41
41
  if (valueProp == null) {
@@ -47,7 +47,7 @@ const GridEditInputCell = forwardRef((props, ref) => {
47
47
  } = props,
48
48
  other = _objectWithoutPropertiesLoose(props, _excluded);
49
49
  const apiRef = useGridApiContext();
50
- const inputRef = React.useRef();
50
+ const inputRef = React.useRef(null);
51
51
  const [valueState, setValueState] = React.useState(value);
52
52
  const classes = useUtilityClasses(rootProps);
53
53
  const handleChange = React.useCallback(async event => {
@@ -30,8 +30,8 @@ function GridEditSingleSelectCell(props) {
30
30
  } = props,
31
31
  other = _objectWithoutPropertiesLoose(props, _excluded);
32
32
  const apiRef = useGridApiContext();
33
- const ref = React.useRef();
34
- const inputRef = React.useRef();
33
+ const ref = React.useRef(null);
34
+ const inputRef = React.useRef(null);
35
35
  const [open, setOpen] = React.useState(initialOpen);
36
36
  const baseSelectProps = rootProps.slotProps?.baseSelect || {};
37
37
  const isSelectNative = baseSelectProps.native ?? false;
@@ -88,7 +88,8 @@ const GridCellCheckboxForwardRef = forwardRef(function GridCellCheckboxRenderer(
88
88
  onChange: handleChange,
89
89
  className: classes.root,
90
90
  inputProps: {
91
- 'aria-label': label
91
+ 'aria-label': label,
92
+ name: 'select_row'
92
93
  },
93
94
  onKeyDown: handleKeyDown,
94
95
  indeterminate: isIndeterminate,
@@ -42,13 +42,16 @@ const GridHeaderCheckbox = forwardRef(function GridHeaderCheckbox(props, ref) {
42
42
  return selection;
43
43
  }
44
44
  return selection.filter(id => {
45
+ if (rootProps.keepNonExistentRowsSelected) {
46
+ return true;
47
+ }
45
48
  // The row might have been deleted
46
49
  if (!apiRef.current.getRow(id)) {
47
50
  return false;
48
51
  }
49
52
  return rootProps.isRowSelectable(apiRef.current.getRowParams(id));
50
53
  });
51
- }, [apiRef, rootProps.isRowSelectable, selection]);
54
+ }, [apiRef, rootProps.isRowSelectable, selection, rootProps.keepNonExistentRowsSelected]);
52
55
 
53
56
  // All the rows that could be selected / unselected by toggling this checkbox
54
57
  const selectionCandidates = React.useMemo(() => {
@@ -101,7 +104,8 @@ const GridHeaderCheckbox = forwardRef(function GridHeaderCheckbox(props, ref) {
101
104
  onChange: handleChange,
102
105
  className: classes.root,
103
106
  inputProps: {
104
- 'aria-label': label
107
+ 'aria-label': label,
108
+ name: 'select_all_rows'
105
109
  },
106
110
  tabIndex: tabIndex,
107
111
  onKeyDown: handleKeyDown,
@@ -22,17 +22,17 @@ function GridFilterInputValue(props) {
22
22
  } = props,
23
23
  others = _objectWithoutPropertiesLoose(props, _excluded);
24
24
  const filterTimeout = useTimeout();
25
- const [filterValueState, setFilterValueState] = React.useState(sanitizeFilterItemValue(item.value, type));
25
+ const [filterValueState, setFilterValueState] = React.useState(sanitizeFilterItemValue(item.value));
26
26
  const [applying, setIsApplying] = React.useState(false);
27
27
  const id = useId();
28
28
  const rootProps = useGridRootProps();
29
29
  const onFilterChange = React.useCallback(event => {
30
- const value = sanitizeFilterItemValue(event.target.value, type);
30
+ const value = sanitizeFilterItemValue(event.target.value);
31
31
  setFilterValueState(value);
32
32
  setIsApplying(true);
33
33
  filterTimeout.start(rootProps.filterDebounceMs, () => {
34
34
  const newItem = _extends({}, item, {
35
- value,
35
+ value: type === 'number' && !Number.isNaN(Number(value)) ? Number(value) : value,
36
36
  fromInput: id
37
37
  });
38
38
  applyValue(newItem);
@@ -42,14 +42,14 @@ function GridFilterInputValue(props) {
42
42
  React.useEffect(() => {
43
43
  const itemPlusTag = item;
44
44
  if (itemPlusTag.fromInput !== id || item.value == null) {
45
- setFilterValueState(sanitizeFilterItemValue(item.value, type));
45
+ setFilterValueState(sanitizeFilterItemValue(item.value));
46
46
  }
47
- }, [id, item, type]);
47
+ }, [id, item]);
48
48
  return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
49
49
  id: id,
50
50
  label: apiRef.current.getLocaleText('filterPanelInputLabel'),
51
51
  placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
52
- value: filterValueState === undefined ? '' : String(filterValueState),
52
+ value: filterValueState ?? '',
53
53
  onChange: onFilterChange,
54
54
  variant: variant,
55
55
  type: type || 'text',
@@ -71,13 +71,10 @@ function GridFilterInputValue(props) {
71
71
  inputRef: focusElementRef
72
72
  }, others, rootProps.slotProps?.baseTextField));
73
73
  }
74
- function sanitizeFilterItemValue(value, type) {
74
+ function sanitizeFilterItemValue(value) {
75
75
  if (value == null || value === '') {
76
76
  return undefined;
77
77
  }
78
- if (type === 'number') {
79
- return Number(value);
80
- }
81
78
  return String(value);
82
79
  }
83
80
  process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useFirstRender } from "../../utils/useFirstRender.js";
3
3
  export const useGridRegisterPipeApplier = (apiRef, group, callback) => {
4
- const cleanup = React.useRef();
4
+ const cleanup = React.useRef(null);
5
5
  const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
6
6
  const registerPreProcessor = React.useCallback(() => {
7
7
  cleanup.current = apiRef.current.registerPipeApplier(group, id.current, callback);
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useFirstRender } from "../../utils/useFirstRender.js";
3
3
  export const useGridRegisterPipeProcessor = (apiRef, group, callback) => {
4
- const cleanup = React.useRef();
4
+ const cleanup = React.useRef(null);
5
5
  const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
6
6
  const registerPreProcessor = React.useCallback(() => {
7
7
  cleanup.current = apiRef.current.registerPipeProcessor(group, id.current, callback);
@@ -68,8 +68,8 @@ function createPublicAPI(privateApiRef) {
68
68
  return publicApi;
69
69
  }
70
70
  export function useGridApiInitialization(inputApiRef, props) {
71
- const publicApiRef = React.useRef();
72
- const privateApiRef = React.useRef();
71
+ const publicApiRef = React.useRef(null);
72
+ const privateApiRef = React.useRef(null);
73
73
  if (!privateApiRef.current) {
74
74
  privateApiRef.current = createPrivateAPI(publicApiRef);
75
75
  }
@@ -70,7 +70,7 @@ function preventClick(event) {
70
70
  * is disabled.
71
71
  */
72
72
  function useColumnVirtualizationDisabled(apiRef) {
73
- const promise = React.useRef();
73
+ const promise = React.useRef(undefined);
74
74
  const selector = () => gridVirtualizationColumnEnabledSelector(apiRef);
75
75
  const value = useGridSelector(apiRef, selector);
76
76
  React.useEffect(() => {
@@ -184,10 +184,10 @@ export const useGridColumnResize = (apiRef, props) => {
184
184
  // To improve accessibility, the separator has padding on both sides.
185
185
  // Clicking inside the padding area should be treated as a click in the separator.
186
186
  // This ref stores the offset between the click and the separator.
187
- const initialOffsetToSeparator = React.useRef();
188
- const resizeDirection = React.useRef();
187
+ const initialOffsetToSeparator = React.useRef(null);
188
+ const resizeDirection = React.useRef(null);
189
189
  const stopResizeEventTimeout = useTimeout();
190
- const touchId = React.useRef();
190
+ const touchId = React.useRef(undefined);
191
191
  const updateWidth = newWidth => {
192
192
  logger.debug(`Updating width to ${newWidth} for col ${refs.colDef.field}`);
193
193
  const prevWidth = refs.columnHeaderElement.offsetWidth;
@@ -67,7 +67,7 @@ export function useGridDimensions(apiRef, props) {
67
67
  const [savedSize, setSavedSize] = React.useState();
68
68
  const debouncedSetSavedSize = React.useMemo(() => throttle(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
69
69
  React.useEffect(() => debouncedSetSavedSize.clear, [debouncedSetSavedSize]);
70
- const previousSize = React.useRef();
70
+ const previousSize = React.useRef(undefined);
71
71
  const getRootDimensions = () => apiRef.current.state.dimensions;
72
72
  const setDimensions = useEventCallback(dimensions => {
73
73
  apiRef.current.setState(state => _extends({}, state, {
@@ -21,7 +21,7 @@ export const useGridRowEditing = (apiRef, props) => {
21
21
  const [rowModesModel, setRowModesModel] = React.useState({});
22
22
  const rowModesModelRef = React.useRef(rowModesModel);
23
23
  const prevRowModesModel = React.useRef({});
24
- const focusTimeout = React.useRef();
24
+ const focusTimeout = React.useRef(undefined);
25
25
  const nextFocusedCell = React.useRef(null);
26
26
  const {
27
27
  processRowUpdate,
@@ -44,7 +44,7 @@ export const useGridPrintExport = (apiRef, props) => {
44
44
  const previousGridState = React.useRef(null);
45
45
  const previousColumnVisibility = React.useRef({});
46
46
  const previousRows = React.useRef([]);
47
- const previousVirtualizationState = React.useRef();
47
+ const previousVirtualizationState = React.useRef(null);
48
48
  React.useEffect(() => {
49
49
  doc.current = ownerDocument(apiRef.current.rootElementRef.current);
50
50
  }, [apiRef, hasRootReference]);
@@ -15,8 +15,8 @@ export const preferencePanelStateInitializer = (state, props) => _extends({}, st
15
15
  */
16
16
  export const useGridPreferencesPanel = (apiRef, props) => {
17
17
  const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
18
- const hideTimeout = React.useRef();
19
- const immediateTimeout = React.useRef();
18
+ const hideTimeout = React.useRef(undefined);
19
+ const immediateTimeout = React.useRef(undefined);
20
20
 
21
21
  /**
22
22
  * API METHODS
@@ -86,6 +86,7 @@ export const useGridVirtualScroller = () => {
86
86
  const contentHeight = dimensions.contentSize.height;
87
87
  const columnsTotalWidth = dimensions.columnsTotalWidth;
88
88
  const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
89
+ const previousSize = React.useRef(null);
89
90
  const mainRefCallback = React.useCallback(node => {
90
91
  mainRef.current = node;
91
92
  if (!node) {
@@ -93,7 +94,10 @@ export const useGridVirtualScroller = () => {
93
94
  }
94
95
  const initialRect = node.getBoundingClientRect();
95
96
  let lastSize = roundDimensions(initialRect);
96
- apiRef.current.publishEvent('resize', lastSize);
97
+ if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
98
+ previousSize.current = lastSize;
99
+ apiRef.current.publishEvent('resize', lastSize);
100
+ }
97
101
  if (typeof ResizeObserver === 'undefined') {
98
102
  return undefined;
99
103
  }
@@ -24,7 +24,7 @@ export function createUseGridApiEventHandler(registryContainer) {
24
24
  }
25
25
  const [objectRetainedByReact] = React.useState(new ObjectToBeRetainedByReact());
26
26
  const subscription = React.useRef(null);
27
- const handlerRef = React.useRef();
27
+ const handlerRef = React.useRef(null);
28
28
  handlerRef.current = handler;
29
29
  const cleanupTokenRef = React.useRef(null);
30
30
  if (!subscription.current && handlerRef.current) {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.23.4
2
+ * @mui/x-data-grid v7.23.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -44,7 +44,7 @@ function GridEditDateCell(props) {
44
44
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
45
45
  const isDateTime = colDef.type === 'dateTime';
46
46
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
47
- const inputRef = React.useRef();
47
+ const inputRef = React.useRef(null);
48
48
  const valueTransformed = React.useMemo(() => {
49
49
  let parsedDate;
50
50
  if (valueProp == null) {
@@ -55,7 +55,7 @@ const GridEditInputCell = exports.GridEditInputCell = (0, _forwardRef.forwardRef
55
55
  } = props,
56
56
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
57
57
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
58
- const inputRef = React.useRef();
58
+ const inputRef = React.useRef(null);
59
59
  const [valueState, setValueState] = React.useState(value);
60
60
  const classes = useUtilityClasses(rootProps);
61
61
  const handleChange = React.useCallback(async event => {
@@ -39,8 +39,8 @@ function GridEditSingleSelectCell(props) {
39
39
  } = props,
40
40
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
41
41
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
42
- const ref = React.useRef();
43
- const inputRef = React.useRef();
42
+ const ref = React.useRef(null);
43
+ const inputRef = React.useRef(null);
44
44
  const [open, setOpen] = React.useState(initialOpen);
45
45
  const baseSelectProps = rootProps.slotProps?.baseSelect || {};
46
46
  const isSelectNative = baseSelectProps.native ?? false;
@@ -96,7 +96,8 @@ const GridCellCheckboxForwardRef = exports.GridCellCheckboxForwardRef = (0, _for
96
96
  onChange: handleChange,
97
97
  className: classes.root,
98
98
  inputProps: {
99
- 'aria-label': label
99
+ 'aria-label': label,
100
+ name: 'select_row'
100
101
  },
101
102
  onKeyDown: handleKeyDown,
102
103
  indeterminate: isIndeterminate,
@@ -50,13 +50,16 @@ const GridHeaderCheckbox = exports.GridHeaderCheckbox = (0, _forwardRef.forwardR
50
50
  return selection;
51
51
  }
52
52
  return selection.filter(id => {
53
+ if (rootProps.keepNonExistentRowsSelected) {
54
+ return true;
55
+ }
53
56
  // The row might have been deleted
54
57
  if (!apiRef.current.getRow(id)) {
55
58
  return false;
56
59
  }
57
60
  return rootProps.isRowSelectable(apiRef.current.getRowParams(id));
58
61
  });
59
- }, [apiRef, rootProps.isRowSelectable, selection]);
62
+ }, [apiRef, rootProps.isRowSelectable, selection, rootProps.keepNonExistentRowsSelected]);
60
63
 
61
64
  // All the rows that could be selected / unselected by toggling this checkbox
62
65
  const selectionCandidates = React.useMemo(() => {
@@ -109,7 +112,8 @@ const GridHeaderCheckbox = exports.GridHeaderCheckbox = (0, _forwardRef.forwardR
109
112
  onChange: handleChange,
110
113
  className: classes.root,
111
114
  inputProps: {
112
- 'aria-label': label
115
+ 'aria-label': label,
116
+ name: 'select_all_rows'
113
117
  },
114
118
  tabIndex: tabIndex,
115
119
  onKeyDown: handleKeyDown,
@@ -30,17 +30,17 @@ function GridFilterInputValue(props) {
30
30
  } = props,
31
31
  others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
32
32
  const filterTimeout = (0, _useTimeout.useTimeout)();
33
- const [filterValueState, setFilterValueState] = React.useState(sanitizeFilterItemValue(item.value, type));
33
+ const [filterValueState, setFilterValueState] = React.useState(sanitizeFilterItemValue(item.value));
34
34
  const [applying, setIsApplying] = React.useState(false);
35
35
  const id = (0, _utils.unstable_useId)();
36
36
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
37
37
  const onFilterChange = React.useCallback(event => {
38
- const value = sanitizeFilterItemValue(event.target.value, type);
38
+ const value = sanitizeFilterItemValue(event.target.value);
39
39
  setFilterValueState(value);
40
40
  setIsApplying(true);
41
41
  filterTimeout.start(rootProps.filterDebounceMs, () => {
42
42
  const newItem = (0, _extends2.default)({}, item, {
43
- value,
43
+ value: type === 'number' && !Number.isNaN(Number(value)) ? Number(value) : value,
44
44
  fromInput: id
45
45
  });
46
46
  applyValue(newItem);
@@ -50,14 +50,14 @@ function GridFilterInputValue(props) {
50
50
  React.useEffect(() => {
51
51
  const itemPlusTag = item;
52
52
  if (itemPlusTag.fromInput !== id || item.value == null) {
53
- setFilterValueState(sanitizeFilterItemValue(item.value, type));
53
+ setFilterValueState(sanitizeFilterItemValue(item.value));
54
54
  }
55
- }, [id, item, type]);
55
+ }, [id, item]);
56
56
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, (0, _extends2.default)({
57
57
  id: id,
58
58
  label: apiRef.current.getLocaleText('filterPanelInputLabel'),
59
59
  placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
60
- value: filterValueState === undefined ? '' : String(filterValueState),
60
+ value: filterValueState ?? '',
61
61
  onChange: onFilterChange,
62
62
  variant: variant,
63
63
  type: type || 'text',
@@ -79,13 +79,10 @@ function GridFilterInputValue(props) {
79
79
  inputRef: focusElementRef
80
80
  }, others, rootProps.slotProps?.baseTextField));
81
81
  }
82
- function sanitizeFilterItemValue(value, type) {
82
+ function sanitizeFilterItemValue(value) {
83
83
  if (value == null || value === '') {
84
84
  return undefined;
85
85
  }
86
- if (type === 'number') {
87
- return Number(value);
88
- }
89
86
  return String(value);
90
87
  }
91
88
  process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
@@ -8,7 +8,7 @@ exports.useGridRegisterPipeApplier = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _useFirstRender = require("../../utils/useFirstRender");
10
10
  const useGridRegisterPipeApplier = (apiRef, group, callback) => {
11
- const cleanup = React.useRef();
11
+ const cleanup = React.useRef(null);
12
12
  const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
13
13
  const registerPreProcessor = React.useCallback(() => {
14
14
  cleanup.current = apiRef.current.registerPipeApplier(group, id.current, callback);
@@ -8,7 +8,7 @@ exports.useGridRegisterPipeProcessor = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _useFirstRender = require("../../utils/useFirstRender");
10
10
  const useGridRegisterPipeProcessor = (apiRef, group, callback) => {
11
- const cleanup = React.useRef();
11
+ const cleanup = React.useRef(null);
12
12
  const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
13
13
  const registerPreProcessor = React.useCallback(() => {
14
14
  cleanup.current = apiRef.current.registerPipeProcessor(group, id.current, callback);
@@ -76,8 +76,8 @@ function createPublicAPI(privateApiRef) {
76
76
  return publicApi;
77
77
  }
78
78
  function useGridApiInitialization(inputApiRef, props) {
79
- const publicApiRef = React.useRef();
80
- const privateApiRef = React.useRef();
79
+ const publicApiRef = React.useRef(null);
80
+ const privateApiRef = React.useRef(null);
81
81
  if (!privateApiRef.current) {
82
82
  privateApiRef.current = createPrivateAPI(publicApiRef);
83
83
  }
@@ -78,7 +78,7 @@ function preventClick(event) {
78
78
  * is disabled.
79
79
  */
80
80
  function useColumnVirtualizationDisabled(apiRef) {
81
- const promise = React.useRef();
81
+ const promise = React.useRef(undefined);
82
82
  const selector = () => (0, _virtualization.gridVirtualizationColumnEnabledSelector)(apiRef);
83
83
  const value = (0, _utils2.useGridSelector)(apiRef, selector);
84
84
  React.useEffect(() => {
@@ -193,10 +193,10 @@ const useGridColumnResize = (apiRef, props) => {
193
193
  // To improve accessibility, the separator has padding on both sides.
194
194
  // Clicking inside the padding area should be treated as a click in the separator.
195
195
  // This ref stores the offset between the click and the separator.
196
- const initialOffsetToSeparator = React.useRef();
197
- const resizeDirection = React.useRef();
196
+ const initialOffsetToSeparator = React.useRef(null);
197
+ const resizeDirection = React.useRef(null);
198
198
  const stopResizeEventTimeout = (0, _useTimeout.useTimeout)();
199
- const touchId = React.useRef();
199
+ const touchId = React.useRef(undefined);
200
200
  const updateWidth = newWidth => {
201
201
  logger.debug(`Updating width to ${newWidth} for col ${refs.colDef.field}`);
202
202
  const prevWidth = refs.columnHeaderElement.offsetWidth;
@@ -77,7 +77,7 @@ function useGridDimensions(apiRef, props) {
77
77
  const [savedSize, setSavedSize] = React.useState();
78
78
  const debouncedSetSavedSize = React.useMemo(() => (0, _throttle.throttle)(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
79
79
  React.useEffect(() => debouncedSetSavedSize.clear, [debouncedSetSavedSize]);
80
- const previousSize = React.useRef();
80
+ const previousSize = React.useRef(undefined);
81
81
  const getRootDimensions = () => apiRef.current.state.dimensions;
82
82
  const setDimensions = (0, _utils.unstable_useEventCallback)(dimensions => {
83
83
  apiRef.current.setState(state => (0, _extends2.default)({}, state, {
@@ -29,7 +29,7 @@ const useGridRowEditing = (apiRef, props) => {
29
29
  const [rowModesModel, setRowModesModel] = React.useState({});
30
30
  const rowModesModelRef = React.useRef(rowModesModel);
31
31
  const prevRowModesModel = React.useRef({});
32
- const focusTimeout = React.useRef();
32
+ const focusTimeout = React.useRef(undefined);
33
33
  const nextFocusedCell = React.useRef(null);
34
34
  const {
35
35
  processRowUpdate,
@@ -52,7 +52,7 @@ const useGridPrintExport = (apiRef, props) => {
52
52
  const previousGridState = React.useRef(null);
53
53
  const previousColumnVisibility = React.useRef({});
54
54
  const previousRows = React.useRef([]);
55
- const previousVirtualizationState = React.useRef();
55
+ const previousVirtualizationState = React.useRef(null);
56
56
  React.useEffect(() => {
57
57
  doc.current = (0, _utils.unstable_ownerDocument)(apiRef.current.rootElementRef.current);
58
58
  }, [apiRef, hasRootReference]);
@@ -24,8 +24,8 @@ const preferencePanelStateInitializer = (state, props) => (0, _extends2.default)
24
24
  exports.preferencePanelStateInitializer = preferencePanelStateInitializer;
25
25
  const useGridPreferencesPanel = (apiRef, props) => {
26
26
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridPreferencesPanel');
27
- const hideTimeout = React.useRef();
28
- const immediateTimeout = React.useRef();
27
+ const hideTimeout = React.useRef(undefined);
28
+ const immediateTimeout = React.useRef(undefined);
29
29
 
30
30
  /**
31
31
  * API METHODS
@@ -97,6 +97,7 @@ const useGridVirtualScroller = () => {
97
97
  const contentHeight = dimensions.contentSize.height;
98
98
  const columnsTotalWidth = dimensions.columnsTotalWidth;
99
99
  const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
100
+ const previousSize = React.useRef(null);
100
101
  const mainRefCallback = React.useCallback(node => {
101
102
  mainRef.current = node;
102
103
  if (!node) {
@@ -104,7 +105,10 @@ const useGridVirtualScroller = () => {
104
105
  }
105
106
  const initialRect = node.getBoundingClientRect();
106
107
  let lastSize = roundDimensions(initialRect);
107
- apiRef.current.publishEvent('resize', lastSize);
108
+ if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
109
+ previousSize.current = lastSize;
110
+ apiRef.current.publishEvent('resize', lastSize);
111
+ }
108
112
  if (typeof ResizeObserver === 'undefined') {
109
113
  return undefined;
110
114
  }
@@ -34,7 +34,7 @@ function createUseGridApiEventHandler(registryContainer) {
34
34
  }
35
35
  const [objectRetainedByReact] = React.useState(new ObjectToBeRetainedByReact());
36
36
  const subscription = React.useRef(null);
37
- const handlerRef = React.useRef();
37
+ const handlerRef = React.useRef(null);
38
38
  handlerRef.current = handler;
39
39
  const cleanupTokenRef = React.useRef(null);
40
40
  if (!subscription.current && handlerRef.current) {