@mui/x-data-grid 6.9.0 → 6.9.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 (154) hide show
  1. package/CHANGELOG.md +136 -8
  2. package/DataGrid/DataGrid.js +4 -1
  3. package/DataGrid/useDataGridComponent.js +1 -1
  4. package/README.md +1 -1
  5. package/colDef/gridActionsColDef.js +2 -1
  6. package/colDef/gridBooleanColDef.js +1 -0
  7. package/colDef/gridBooleanOperators.js +5 -6
  8. package/colDef/gridCheckboxSelectionColDef.js +1 -0
  9. package/colDef/gridDateColDef.js +2 -0
  10. package/colDef/gridDateOperators.js +14 -19
  11. package/colDef/gridNumericColDef.js +3 -1
  12. package/colDef/gridNumericOperators.d.ts +2 -2
  13. package/colDef/gridNumericOperators.js +24 -43
  14. package/colDef/gridSingleSelectOperators.js +9 -14
  15. package/colDef/gridStringColDef.js +3 -1
  16. package/colDef/gridStringOperators.d.ts +2 -2
  17. package/colDef/gridStringOperators.js +22 -36
  18. package/colDef/utils.d.ts +21 -0
  19. package/colDef/utils.js +51 -0
  20. package/components/GridPagination.js +16 -3
  21. package/components/cell/GridCell.js +1 -1
  22. package/components/cell/GridEditDateCell.js +1 -1
  23. package/components/cell/GridEditInputCell.js +3 -3
  24. package/hooks/features/columns/gridColumnsUtils.js +2 -1
  25. package/hooks/features/dimensions/useGridDimensions.js +2 -2
  26. package/hooks/features/editing/useGridEditing.js +2 -1
  27. package/hooks/features/editing/useGridRowEditing.js +2 -2
  28. package/hooks/features/filter/gridFilterState.d.ts +6 -5
  29. package/hooks/features/filter/gridFilterUtils.d.ts +8 -6
  30. package/hooks/features/filter/gridFilterUtils.js +115 -57
  31. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  32. package/hooks/features/filter/useGridFilter.js +34 -25
  33. package/hooks/features/pagination/gridPaginationSelector.js +10 -5
  34. package/hooks/features/rows/gridRowsUtils.d.ts +1 -0
  35. package/hooks/features/rows/gridRowsUtils.js +1 -0
  36. package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
  37. package/hooks/features/rows/useGridParamsApi.js +31 -1
  38. package/hooks/features/rows/useGridRows.js +4 -3
  39. package/index.js +1 -1
  40. package/internals/index.d.ts +2 -1
  41. package/internals/index.js +1 -0
  42. package/joy/joySlots.js +29 -8
  43. package/legacy/DataGrid/DataGrid.js +4 -1
  44. package/legacy/DataGrid/useDataGridComponent.js +1 -1
  45. package/legacy/colDef/gridActionsColDef.js +2 -1
  46. package/legacy/colDef/gridBooleanColDef.js +1 -0
  47. package/legacy/colDef/gridBooleanOperators.js +5 -5
  48. package/legacy/colDef/gridCheckboxSelectionColDef.js +1 -0
  49. package/legacy/colDef/gridDateColDef.js +2 -0
  50. package/legacy/colDef/gridDateOperators.js +14 -16
  51. package/legacy/colDef/gridNumericColDef.js +3 -1
  52. package/legacy/colDef/gridNumericOperators.js +24 -33
  53. package/legacy/colDef/gridSingleSelectOperators.js +9 -11
  54. package/legacy/colDef/gridStringColDef.js +3 -1
  55. package/legacy/colDef/gridStringOperators.js +22 -28
  56. package/legacy/colDef/utils.js +51 -0
  57. package/legacy/components/GridPagination.js +16 -3
  58. package/legacy/components/cell/GridCell.js +2 -1
  59. package/legacy/components/cell/GridEditDateCell.js +1 -1
  60. package/legacy/components/cell/GridEditInputCell.js +3 -3
  61. package/legacy/hooks/features/columns/gridColumnsUtils.js +4 -1
  62. package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
  63. package/legacy/hooks/features/editing/useGridEditing.js +2 -1
  64. package/legacy/hooks/features/editing/useGridRowEditing.js +2 -2
  65. package/legacy/hooks/features/filter/gridFilterUtils.js +115 -65
  66. package/legacy/hooks/features/filter/useGridFilter.js +32 -24
  67. package/legacy/hooks/features/pagination/gridPaginationSelector.js +10 -5
  68. package/legacy/hooks/features/rows/gridRowsUtils.js +1 -0
  69. package/legacy/hooks/features/rows/useGridParamsApi.js +29 -1
  70. package/legacy/hooks/features/rows/useGridRows.js +15 -16
  71. package/legacy/index.js +1 -1
  72. package/legacy/internals/index.js +1 -0
  73. package/legacy/joy/joySlots.js +29 -8
  74. package/legacy/locales/esES.js +3 -3
  75. package/legacy/locales/huHU.js +23 -25
  76. package/legacy/locales/roRO.js +34 -38
  77. package/locales/esES.js +3 -3
  78. package/locales/huHU.js +23 -25
  79. package/locales/roRO.js +34 -38
  80. package/models/api/gridEditingApi.d.ts +1 -1
  81. package/models/api/gridParamsApi.d.ts +22 -1
  82. package/models/colDef/gridColDef.d.ts +13 -1
  83. package/models/gridFilterOperator.d.ts +17 -2
  84. package/models/gridRows.d.ts +1 -1
  85. package/models/props/DataGridProps.d.ts +4 -1
  86. package/modern/DataGrid/DataGrid.js +4 -1
  87. package/modern/DataGrid/useDataGridComponent.js +1 -1
  88. package/modern/colDef/gridActionsColDef.js +2 -1
  89. package/modern/colDef/gridBooleanColDef.js +1 -0
  90. package/modern/colDef/gridBooleanOperators.js +5 -6
  91. package/modern/colDef/gridCheckboxSelectionColDef.js +1 -0
  92. package/modern/colDef/gridDateColDef.js +2 -0
  93. package/modern/colDef/gridDateOperators.js +14 -19
  94. package/modern/colDef/gridNumericColDef.js +3 -1
  95. package/modern/colDef/gridNumericOperators.js +24 -43
  96. package/modern/colDef/gridSingleSelectOperators.js +9 -14
  97. package/modern/colDef/gridStringColDef.js +3 -1
  98. package/modern/colDef/gridStringOperators.js +22 -36
  99. package/modern/colDef/utils.js +51 -0
  100. package/modern/components/GridPagination.js +16 -2
  101. package/modern/components/cell/GridCell.js +1 -1
  102. package/modern/components/cell/GridEditDateCell.js +1 -1
  103. package/modern/components/cell/GridEditInputCell.js +3 -3
  104. package/modern/hooks/features/columns/gridColumnsUtils.js +2 -1
  105. package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
  106. package/modern/hooks/features/editing/useGridEditing.js +1 -1
  107. package/modern/hooks/features/editing/useGridRowEditing.js +2 -2
  108. package/modern/hooks/features/filter/gridFilterUtils.js +110 -54
  109. package/modern/hooks/features/filter/useGridFilter.js +34 -25
  110. package/modern/hooks/features/pagination/gridPaginationSelector.js +9 -5
  111. package/modern/hooks/features/rows/gridRowsUtils.js +1 -0
  112. package/modern/hooks/features/rows/useGridParamsApi.js +29 -1
  113. package/modern/hooks/features/rows/useGridRows.js +4 -3
  114. package/modern/index.js +1 -1
  115. package/modern/internals/index.js +1 -0
  116. package/modern/joy/joySlots.js +29 -7
  117. package/modern/locales/esES.js +3 -3
  118. package/modern/locales/huHU.js +23 -25
  119. package/modern/locales/roRO.js +34 -38
  120. package/node/DataGrid/DataGrid.js +4 -1
  121. package/node/DataGrid/useDataGridComponent.js +1 -1
  122. package/node/colDef/gridActionsColDef.js +2 -1
  123. package/node/colDef/gridBooleanColDef.js +1 -0
  124. package/node/colDef/gridBooleanOperators.js +5 -6
  125. package/node/colDef/gridCheckboxSelectionColDef.js +1 -0
  126. package/node/colDef/gridDateColDef.js +2 -0
  127. package/node/colDef/gridDateOperators.js +14 -19
  128. package/node/colDef/gridNumericColDef.js +3 -1
  129. package/node/colDef/gridNumericOperators.js +24 -43
  130. package/node/colDef/gridSingleSelectOperators.js +9 -14
  131. package/node/colDef/gridStringColDef.js +3 -1
  132. package/node/colDef/gridStringOperators.js +22 -36
  133. package/node/colDef/utils.js +64 -0
  134. package/node/components/GridPagination.js +16 -2
  135. package/node/components/cell/GridCell.js +1 -1
  136. package/node/components/cell/GridEditDateCell.js +1 -1
  137. package/node/components/cell/GridEditInputCell.js +3 -3
  138. package/node/hooks/features/columns/gridColumnsUtils.js +2 -1
  139. package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
  140. package/node/hooks/features/editing/useGridEditing.js +1 -1
  141. package/node/hooks/features/editing/useGridRowEditing.js +1 -1
  142. package/node/hooks/features/filter/gridFilterUtils.js +110 -54
  143. package/node/hooks/features/filter/useGridFilter.js +33 -24
  144. package/node/hooks/features/pagination/gridPaginationSelector.js +9 -5
  145. package/node/hooks/features/rows/gridRowsUtils.js +3 -1
  146. package/node/hooks/features/rows/useGridParamsApi.js +29 -1
  147. package/node/hooks/features/rows/useGridRows.js +3 -2
  148. package/node/index.js +1 -1
  149. package/node/internals/index.js +13 -1
  150. package/node/joy/joySlots.js +29 -7
  151. package/node/locales/esES.js +3 -3
  152. package/node/locales/huHU.js +23 -25
  153. package/node/locales/roRO.js +34 -38
  154. package/package.json +2 -2
@@ -1,35 +1,33 @@
1
1
  import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
2
2
  import { escapeRegExp } from '../utils/utils';
3
3
  import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
4
- export const getGridStringQuickFilterFn = value => {
4
+ import { convertLegacyOperators, tagInternalFilter } from './utils';
5
+ export const getGridStringQuickFilterFn = tagInternalFilter(value => {
5
6
  if (!value) {
6
7
  return null;
7
8
  }
8
9
  const filterRegex = new RegExp(escapeRegExp(value), 'i');
9
- return ({
10
- formattedValue: columnValue
11
- }) => {
10
+ return (_, row, column, apiRef) => {
11
+ const columnValue = apiRef.current.getRowFormattedValue(row, column);
12
12
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
13
13
  };
14
- };
15
- export const getGridStringOperators = (disableTrim = false) => [{
14
+ });
15
+ export const getGridStringOperators = (disableTrim = false) => convertLegacyOperators([{
16
16
  value: 'contains',
17
- getApplyFilterFn: filterItem => {
17
+ getApplyFilterFnV7: filterItem => {
18
18
  if (!filterItem.value) {
19
19
  return null;
20
20
  }
21
21
  const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
22
22
  const filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i');
23
- return ({
24
- value
25
- }) => {
26
- return value != null ? filterRegex.test(value.toString()) : false;
23
+ return value => {
24
+ return value != null ? filterRegex.test(String(value)) : false;
27
25
  };
28
26
  },
29
27
  InputComponent: GridFilterInputValue
30
28
  }, {
31
29
  value: 'equals',
32
- getApplyFilterFn: filterItem => {
30
+ getApplyFilterFnV7: filterItem => {
33
31
  if (!filterItem.value) {
34
32
  return null;
35
33
  }
@@ -38,66 +36,56 @@ export const getGridStringOperators = (disableTrim = false) => [{
38
36
  sensitivity: 'base',
39
37
  usage: 'search'
40
38
  });
41
- return ({
42
- value
43
- }) => {
39
+ return value => {
44
40
  return value != null ? collator.compare(filterItemValue, value.toString()) === 0 : false;
45
41
  };
46
42
  },
47
43
  InputComponent: GridFilterInputValue
48
44
  }, {
49
45
  value: 'startsWith',
50
- getApplyFilterFn: filterItem => {
46
+ getApplyFilterFnV7: filterItem => {
51
47
  if (!filterItem.value) {
52
48
  return null;
53
49
  }
54
50
  const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
55
51
  const filterRegex = new RegExp(`^${escapeRegExp(filterItemValue)}.*$`, 'i');
56
- return ({
57
- value
58
- }) => {
52
+ return value => {
59
53
  return value != null ? filterRegex.test(value.toString()) : false;
60
54
  };
61
55
  },
62
56
  InputComponent: GridFilterInputValue
63
57
  }, {
64
58
  value: 'endsWith',
65
- getApplyFilterFn: filterItem => {
59
+ getApplyFilterFnV7: filterItem => {
66
60
  if (!filterItem.value) {
67
61
  return null;
68
62
  }
69
63
  const filterItemValue = disableTrim ? filterItem.value : filterItem.value.trim();
70
64
  const filterRegex = new RegExp(`.*${escapeRegExp(filterItemValue)}$`, 'i');
71
- return ({
72
- value
73
- }) => {
65
+ return value => {
74
66
  return value != null ? filterRegex.test(value.toString()) : false;
75
67
  };
76
68
  },
77
69
  InputComponent: GridFilterInputValue
78
70
  }, {
79
71
  value: 'isEmpty',
80
- getApplyFilterFn: () => {
81
- return ({
82
- value
83
- }) => {
72
+ getApplyFilterFnV7: () => {
73
+ return value => {
84
74
  return value === '' || value == null;
85
75
  };
86
76
  },
87
77
  requiresFilterValue: false
88
78
  }, {
89
79
  value: 'isNotEmpty',
90
- getApplyFilterFn: () => {
91
- return ({
92
- value
93
- }) => {
80
+ getApplyFilterFnV7: () => {
81
+ return value => {
94
82
  return value !== '' && value != null;
95
83
  };
96
84
  },
97
85
  requiresFilterValue: false
98
86
  }, {
99
87
  value: 'isAnyOf',
100
- getApplyFilterFn: filterItem => {
88
+ getApplyFilterFnV7: filterItem => {
101
89
  if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
102
90
  return null;
103
91
  }
@@ -106,11 +94,9 @@ export const getGridStringOperators = (disableTrim = false) => [{
106
94
  sensitivity: 'base',
107
95
  usage: 'search'
108
96
  });
109
- return ({
110
- value
111
- }) => value != null ? filterItemValue.some(filterValue => {
97
+ return value => value != null ? filterItemValue.some(filterValue => {
112
98
  return collator.compare(filterValue, value.toString() || '') === 0;
113
99
  }) : false;
114
100
  },
115
101
  InputComponent: GridFilterInputMultipleValue
116
- }];
102
+ }]);
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { GridApiCommunity } from '../models/api/gridApiCommunity';
3
+ import { GetApplyFilterFnV7, GetApplyFilterFnLegacy, GridFilterOperator } from '../models';
4
+ import { GetApplyQuickFilterFnV7, GetApplyQuickFilterFnLegacy } from '../models/colDef/gridColDef';
5
+ /**
6
+ * A global API ref, for v7-to-legacy converter
7
+ */
8
+ export declare const GLOBAL_API_REF: {
9
+ current: React.MutableRefObject<GridApiCommunity> | null;
10
+ };
11
+ /**
12
+ * A tagger to determine if the filter is internal or custom user-supplied.
13
+ * To be a valid internal filter, the V7 function *must* be defined/redefined at
14
+ * the same time as the legacy one.
15
+ * https://github.com/mui/mui-x/pull/9254#discussion_r1231095551
16
+ */
17
+ export declare function tagInternalFilter<T>(fn: T): T;
18
+ export declare function isInternalFilter(fn: Function | undefined): boolean;
19
+ export declare function convertFilterV7ToLegacy(fn: GetApplyFilterFnV7): GetApplyFilterFnLegacy;
20
+ export declare function convertLegacyOperators(ops: Omit<GridFilterOperator, 'getApplyFilterFn'>[]): GridFilterOperator[];
21
+ export declare function convertQuickFilterV7ToLegacy(fn: GetApplyQuickFilterFnV7): GetApplyQuickFilterFnLegacy<any, any, any>;
@@ -0,0 +1,51 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ /**
3
+ * A global API ref, for v7-to-legacy converter
4
+ */
5
+ export const GLOBAL_API_REF = {
6
+ current: null
7
+ };
8
+
9
+ /**
10
+ * A tagger to determine if the filter is internal or custom user-supplied.
11
+ * To be a valid internal filter, the V7 function *must* be defined/redefined at
12
+ * the same time as the legacy one.
13
+ * https://github.com/mui/mui-x/pull/9254#discussion_r1231095551
14
+ */
15
+ export function tagInternalFilter(fn) {
16
+ fn.isInternal = true;
17
+ return fn;
18
+ }
19
+ export function isInternalFilter(fn) {
20
+ return fn !== undefined && fn.isInternal === true;
21
+ }
22
+ export function convertFilterV7ToLegacy(fn) {
23
+ return tagInternalFilter((filterItem, column) => {
24
+ const filterFn = fn(filterItem, column);
25
+ if (!filterFn) {
26
+ return filterFn;
27
+ }
28
+ return cellParams => {
29
+ return filterFn(cellParams.value, cellParams.row, column, GLOBAL_API_REF.current);
30
+ };
31
+ });
32
+ }
33
+ export function convertLegacyOperators(ops) {
34
+ return ops.map(op => {
35
+ return _extends({}, op, {
36
+ getApplyFilterFn: convertFilterV7ToLegacy(op.getApplyFilterFnV7),
37
+ getApplyFilterFnV7: tagInternalFilter(op.getApplyFilterFnV7)
38
+ });
39
+ });
40
+ }
41
+ export function convertQuickFilterV7ToLegacy(fn) {
42
+ return tagInternalFilter((filterItem, column, apiRef) => {
43
+ const filterFn = fn(filterItem, column, apiRef);
44
+ if (!filterFn) {
45
+ return filterFn;
46
+ }
47
+ return cellParams => {
48
+ return filterFn(cellParams.value, cellParams.row, column, apiRef);
49
+ };
50
+ });
51
+ }
@@ -25,7 +25,6 @@ const GridPaginationRoot = styled(TablePagination)(({
25
25
  }
26
26
  }));
27
27
  export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
28
- var _rootProps$pageSizeOp;
29
28
  const apiRef = useGridApiContext();
30
29
  const rootProps = useGridRootProps();
31
30
  const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
@@ -42,22 +41,36 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
42
41
  const handlePageChange = React.useCallback((_, page) => {
43
42
  apiRef.current.setPage(page);
44
43
  }, [apiRef]);
44
+ const isPageSizeIncludedInPageSizeOptions = pageSize => {
45
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
46
+ const option = rootProps.pageSizeOptions[i];
47
+ if (typeof option === 'number') {
48
+ if (option === pageSize) {
49
+ return true;
50
+ }
51
+ } else if (option.value === pageSize) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ };
45
57
  if (process.env.NODE_ENV !== 'production') {
46
58
  var _rootProps$pagination, _rootProps$pagination2;
47
59
  // eslint-disable-next-line react-hooks/rules-of-hooks
48
60
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
49
61
  const pageSize = (_rootProps$pagination = (_rootProps$pagination2 = rootProps.paginationModel) == null ? void 0 : _rootProps$pagination2.pageSize) != null ? _rootProps$pagination : paginationModel.pageSize;
50
- if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
62
+ if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
51
63
  console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
52
64
  warnedOnceMissingInPageSizeOptions.current = true;
53
65
  }
54
66
  }
67
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
55
68
  return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
56
69
  ref: ref,
57
70
  component: "div",
58
71
  count: rowCount,
59
72
  page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
60
- rowsPerPageOptions: (_rootProps$pageSizeOp = rootProps.pageSizeOptions) != null && _rootProps$pageSizeOp.includes(paginationModel.pageSize) ? rootProps.pageSizeOptions : [],
73
+ rowsPerPageOptions: pageSizeOptions,
61
74
  rowsPerPage: paginationModel.pageSize,
62
75
  onPageChange: handlePageChange,
63
76
  onRowsPerPageChange: handlePageSizeChange
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["changeReason", "unstable_updateValueOnRender"],
4
- _excluded2 = ["align", "children", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
4
+ _excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
5
5
  _excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
6
6
  _excluded4 = ["changeReason", "unstable_updateValueOnRender"];
7
7
  /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
@@ -112,7 +112,7 @@ function GridEditDateCell(props) {
112
112
  const meta = apiRef.current.unstable_getEditCellMeta(id, field);
113
113
  const handleInputRef = el => {
114
114
  inputRef.current = el;
115
- if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
115
+ if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
116
116
  const inputValue = inputRef.current.value;
117
117
  const parsedDate = parseValueToDate(inputValue);
118
118
  setValueState({
@@ -68,12 +68,12 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
68
68
  unstable_skipValueParser: true
69
69
  }, event);
70
70
  }, [apiRef, debounceMs, field, id, onValueChange]);
71
- const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
71
+ const meta = apiRef.current.unstable_getEditCellMeta(id, field);
72
72
  React.useEffect(() => {
73
- if (meta.changeReason !== 'debouncedSetEditCellValue') {
73
+ if ((meta == null ? void 0 : meta.changeReason) !== 'debouncedSetEditCellValue') {
74
74
  setValueState(value);
75
75
  }
76
- }, [meta.changeReason, value]);
76
+ }, [meta, value]);
77
77
  useEnhancedEffect(() => {
78
78
  if (hasFocus) {
79
79
  inputRef.current.focus();
@@ -15,6 +15,7 @@ export function computeFlexColumnsWidth({
15
15
  totalFlexUnits,
16
16
  flexColumns
17
17
  }) {
18
+ const uniqueFlexColumns = new Set(flexColumns.map(col => col.field));
18
19
  const flexColumnsLookup = {
19
20
  all: {},
20
21
  frozenFields: [],
@@ -30,7 +31,7 @@ export function computeFlexColumnsWidth({
30
31
  // Step 5 of https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths
31
32
  function loopOverFlexItems() {
32
33
  // 5a: If all the flex items on the line are frozen, free space has been distributed.
33
- if (flexColumnsLookup.frozenFields.length === flexColumns.length) {
34
+ if (flexColumnsLookup.frozenFields.length === uniqueFlexColumns.size) {
34
35
  return;
35
36
  }
36
37
  const violationsLookup = {
@@ -73,7 +73,7 @@ export function useGridDimensions(apiRef, props) {
73
73
  let hasScrollY;
74
74
  if (props.autoHeight) {
75
75
  hasScrollY = false;
76
- hasScrollX = Math.round(columnsTotalWidth) > rootDimensionsRef.current.width;
76
+ hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
77
77
  viewportOuterSize = {
78
78
  width: rootDimensionsRef.current.width,
79
79
  height: rowsMeta.currentPageTotalHeight + (hasScrollX ? scrollBarSize : 0)
@@ -89,7 +89,7 @@ export function useGridDimensions(apiRef, props) {
89
89
  height: rowsMeta.currentPageTotalHeight
90
90
  },
91
91
  container: {
92
- width: viewportOuterSize.width,
92
+ width: Math.round(viewportOuterSize.width),
93
93
  height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
94
94
  },
95
95
  scrollBarSize
@@ -106,8 +106,9 @@ export const useGridEditing = (apiRef, props) => {
106
106
  return props.editMode === GridEditModes.Cell ? apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.getRowWithUpdatedValuesFromRowEditing(id);
107
107
  }, [apiRef, props.editMode]);
108
108
  const getEditCellMeta = React.useCallback((id, field) => {
109
+ var _editingState$id$fiel, _editingState$id;
109
110
  const editingState = gridEditRowsStateSelector(apiRef.current.state);
110
- return editingState[id][field];
111
+ return (_editingState$id$fiel = (_editingState$id = editingState[id]) == null ? void 0 : _editingState$id[field]) != null ? _editingState$id$fiel : null;
111
112
  }, [apiRef]);
112
113
  const editingSharedApi = {
113
114
  isCellEditable,
@@ -10,7 +10,7 @@ import { GridEditModes, GridRowModes } from '../../../models/gridEditRowModel';
10
10
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
11
11
  import { gridEditRowsStateSelector } from './gridEditingSelectors';
12
12
  import { isPrintableKey } from '../../../utils/keyboardUtils';
13
- import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
13
+ import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from '../columns/gridColumnsSelector';
14
14
  import { buildWarning } from '../../../utils/warning';
15
15
  import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
16
16
  import { deepClone } from '../../../utils/utils';
@@ -115,7 +115,7 @@ export const useGridRowEditing = (apiRef, props) => {
115
115
  } else if (event.key === 'Enter') {
116
116
  reason = GridRowEditStopReasons.enterKeyDown;
117
117
  } else if (event.key === 'Tab') {
118
- const columnFields = gridColumnFieldsSelector(apiRef).filter(field => {
118
+ const columnFields = gridVisibleColumnFieldsSelector(apiRef).filter(field => {
119
119
  const column = apiRef.current.getColumn(field);
120
120
  if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
121
121
  return true;
@@ -1,6 +1,6 @@
1
1
  import { GridFilterItem } from '../../../models/gridFilterItem';
2
2
  import { GridFilterModel } from '../../../models/gridFilterModel';
3
- import { GridRowId } from '../../../models/gridRows';
3
+ import { GridRowId, GridValidRowModel } from '../../../models/gridRows';
4
4
  export type GridFilterItemResult = {
5
5
  [key: Required<GridFilterItem>['id']]: boolean;
6
6
  };
@@ -28,14 +28,15 @@ export interface GridFilterState {
28
28
  export interface GridFilterInitialState {
29
29
  filterModel?: GridFilterModel;
30
30
  }
31
+ export interface GridAggregatedFilterItemApplierResult {
32
+ passingFilterItems: null | GridFilterItemResult;
33
+ passingQuickFilterValues: null | GridQuickFilterValueResult;
34
+ }
31
35
  /**
32
36
  * @param {GridRowId} rowId The id of the row we want to filter.
33
37
  * @param {(filterItem: GridFilterItem) => boolean} shouldApplyItem An optional callback to allow the filtering engine to only apply some items.
34
38
  */
35
- export type GridAggregatedFilterItemApplier = (rowId: GridRowId, shouldApplyItem?: (field: string) => boolean) => {
36
- passingFilterItems: null | GridFilterItemResult;
37
- passingQuickFilterValues: null | GridQuickFilterValueResult;
38
- };
39
+ export type GridAggregatedFilterItemApplier = (row: GridValidRowModel, shouldApplyItem: ((field: string) => boolean) | undefined, result: GridAggregatedFilterItemApplierResult) => void;
39
40
  export interface GridFilteringMethodParams {
40
41
  isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
41
42
  filterModel: GridFilterModel;
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
- import { GridFilterItem, GridFilterModel, GridRowId } from '../../../models';
2
+ import { GridFilterItem, GridFilterModel, GridRowIdGetter, GridValidRowModel } from '../../../models';
3
3
  import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
4
4
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
5
5
  import { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from './gridFilterState';
6
- type GridFilterItemApplierNotAggregated = (rowId: GridRowId, shouldApplyItem?: (field: string) => boolean) => GridFilterItemResult;
6
+ type GridFilterItemApplierNotAggregated = (row: GridValidRowModel, shouldApplyItem?: (field: string) => boolean) => GridFilterItemResult;
7
7
  /**
8
8
  * Adds default values to the optional fields of a filter items.
9
9
  * @param {GridFilterItem} item The raw filter item.
@@ -16,19 +16,21 @@ export declare const sanitizeFilterModel: (model: GridFilterModel, disableMultip
16
16
  export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridApiCommunity>) => (filteringState: GridStateCommunity['filter']) => GridStateCommunity['filter'];
17
17
  /**
18
18
  * Generates a method to easily check if a row is matching the current filter model.
19
+ * @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
19
20
  * @param {GridFilterModel} filterModel The model with which we want to filter the rows.
20
21
  * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
21
22
  * @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.
22
23
  */
23
- export declare const buildAggregatedFilterItemsApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
24
+ export declare const buildAggregatedFilterItemsApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
24
25
  /**
25
26
  * Generates a method to easily check if a row is matching the current quick filter.
26
- * @param {any[]} values The model with which we want to filter the rows.
27
+ * @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
28
+ * @param {any[]} filterModel The model with which we want to filter the rows.
27
29
  * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
28
30
  * @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.
29
31
  */
30
- export declare const buildAggregatedQuickFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
31
- export declare const buildAggregatedFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridAggregatedFilterItemApplier;
32
+ export declare const buildAggregatedQuickFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
33
+ export declare const buildAggregatedFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridAggregatedFilterItemApplier;
32
34
  type FilterCache = {
33
35
  cleanedFilterItems?: GridFilterItem[];
34
36
  };