@mui/x-data-grid 7.0.0-alpha.4 → 7.0.0-alpha.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 (82) hide show
  1. package/CHANGELOG.md +342 -0
  2. package/DataGrid/DataGrid.js +25 -19
  3. package/DataGrid/useDataGridProps.js +0 -1
  4. package/colDef/gridDateOperators.js +13 -6
  5. package/colDef/gridSingleSelectColDef.js +6 -15
  6. package/components/cell/GridEditSingleSelectCell.d.ts +1 -2
  7. package/components/cell/GridEditSingleSelectCell.js +9 -29
  8. package/components/columnSelection/GridHeaderCheckbox.js +3 -1
  9. package/components/panel/filterPanel/GridFilterForm.js +44 -9
  10. package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  11. package/components/panel/filterPanel/GridFilterInputDate.js +25 -8
  12. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
  13. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -48
  14. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -2
  15. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -57
  16. package/components/panel/filterPanel/filterPanelUtils.d.ts +3 -2
  17. package/components/panel/filterPanel/filterPanelUtils.js +10 -5
  18. package/hooks/features/rowSelection/useGridRowSelection.js +9 -9
  19. package/hooks/features/rowSelection/utils.d.ts +2 -0
  20. package/hooks/features/rowSelection/utils.js +8 -0
  21. package/hooks/utils/useGridAriaAttributes.js +2 -1
  22. package/index.js +1 -1
  23. package/legacy/DataGrid/DataGrid.js +25 -19
  24. package/legacy/DataGrid/useDataGridProps.js +0 -1
  25. package/legacy/colDef/gridDateOperators.js +13 -13
  26. package/legacy/colDef/gridSingleSelectColDef.js +6 -15
  27. package/legacy/components/cell/GridEditSingleSelectCell.js +8 -28
  28. package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -1
  29. package/legacy/components/panel/filterPanel/GridFilterForm.js +51 -19
  30. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  31. package/legacy/components/panel/filterPanel/GridFilterInputDate.js +27 -8
  32. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -53
  33. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -59
  34. package/legacy/components/panel/filterPanel/filterPanelUtils.js +10 -6
  35. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +9 -9
  36. package/legacy/hooks/features/rowSelection/utils.js +8 -0
  37. package/legacy/hooks/utils/useGridAriaAttributes.js +2 -1
  38. package/legacy/index.js +1 -1
  39. package/legacy/locales/svSE.js +31 -33
  40. package/legacy/locales/urPK.js +26 -28
  41. package/locales/svSE.js +31 -33
  42. package/locales/urPK.js +26 -28
  43. package/models/controlStateItem.d.ts +1 -4
  44. package/models/props/DataGridProps.d.ts +26 -25
  45. package/modern/DataGrid/DataGrid.js +25 -19
  46. package/modern/DataGrid/useDataGridProps.js +0 -1
  47. package/modern/colDef/gridDateOperators.js +13 -6
  48. package/modern/colDef/gridSingleSelectColDef.js +6 -15
  49. package/modern/components/cell/GridEditSingleSelectCell.js +9 -29
  50. package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -1
  51. package/modern/components/panel/filterPanel/GridFilterForm.js +44 -9
  52. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  53. package/modern/components/panel/filterPanel/GridFilterInputDate.js +24 -6
  54. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -47
  55. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -56
  56. package/modern/components/panel/filterPanel/filterPanelUtils.js +10 -5
  57. package/modern/hooks/features/rowSelection/useGridRowSelection.js +9 -9
  58. package/modern/hooks/features/rowSelection/utils.js +8 -0
  59. package/modern/hooks/utils/useGridAriaAttributes.js +2 -1
  60. package/modern/index.js +1 -1
  61. package/modern/locales/svSE.js +31 -33
  62. package/modern/locales/urPK.js +26 -28
  63. package/node/DataGrid/DataGrid.js +25 -19
  64. package/node/DataGrid/useDataGridProps.js +0 -1
  65. package/node/colDef/gridDateOperators.js +13 -6
  66. package/node/colDef/gridSingleSelectColDef.js +5 -14
  67. package/node/components/cell/GridEditSingleSelectCell.js +8 -28
  68. package/node/components/columnSelection/GridHeaderCheckbox.js +3 -1
  69. package/node/components/panel/filterPanel/GridFilterForm.js +44 -9
  70. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
  71. package/node/components/panel/filterPanel/GridFilterInputDate.js +24 -6
  72. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -46
  73. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -55
  74. package/node/components/panel/filterPanel/filterPanelUtils.js +12 -7
  75. package/node/hooks/features/rowSelection/useGridRowSelection.js +9 -9
  76. package/node/hooks/features/rowSelection/utils.js +14 -0
  77. package/node/hooks/utils/useGridAriaAttributes.js +2 -1
  78. package/node/index.js +1 -1
  79. package/node/locales/svSE.js +31 -33
  80. package/node/locales/urPK.js +26 -28
  81. package/package.json +3 -3
  82. package/utils/createSelector.d.ts +1 -1
@@ -49,21 +49,21 @@ DataGridRaw.propTypes = {
49
49
  // | To update them edit the TypeScript types and run "yarn proptypes" |
50
50
  // ----------------------------------------------------------------------
51
51
  /**
52
- * The ref object that allows grid manipulation. Can be instantiated with `useGridApiRef()`.
52
+ * The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
53
53
  */
54
54
  apiRef: _propTypes.default.shape({
55
55
  current: _propTypes.default.object.isRequired
56
56
  }),
57
57
  /**
58
- * The label of the grid.
58
+ * The label of the Data Grid.
59
59
  */
60
60
  'aria-label': _propTypes.default.string,
61
61
  /**
62
- * The id of the element containing a label for the grid.
62
+ * The id of the element containing a label for the Data Grid.
63
63
  */
64
64
  'aria-labelledby': _propTypes.default.string,
65
65
  /**
66
- * If `true`, the grid height is dynamic and follow the number of rows in the grid.
66
+ * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
67
67
  * @default false
68
68
  */
69
69
  autoHeight: _propTypes.default.bool,
@@ -77,7 +77,7 @@ DataGridRaw.propTypes = {
77
77
  */
78
78
  cellModesModel: _propTypes.default.object,
79
79
  /**
80
- * If `true`, the grid get a first column with a checkbox that allows to select rows.
80
+ * If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
81
81
  * @default false
82
82
  */
83
83
  checkboxSelection: _propTypes.default.bool,
@@ -97,7 +97,7 @@ DataGridRaw.propTypes = {
97
97
  columnBuffer: _propTypes.default.number,
98
98
  columnGroupingModel: _propTypes.default.arrayOf(_propTypes.default.object),
99
99
  /**
100
- * Sets the height in pixel of the column headers in the grid.
100
+ * Sets the height in pixel of the column headers in the Data Grid.
101
101
  * @default 56
102
102
  */
103
103
  columnHeaderHeight: _propTypes.default.number,
@@ -117,12 +117,12 @@ DataGridRaw.propTypes = {
117
117
  */
118
118
  columnThreshold: _propTypes.default.number,
119
119
  /**
120
- * Set the column visibility model of the grid.
121
- * If defined, the grid will ignore the `hide` property in [[GridColDef]].
120
+ * Set the column visibility model of the Data Grid.
121
+ * If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
122
122
  */
123
123
  columnVisibilityModel: _propTypes.default.object,
124
124
  /**
125
- * Set the density of the grid.
125
+ * Set the density of the Data Grid.
126
126
  * @default "standard"
127
127
  */
128
128
  density: _propTypes.default.oneOf(['comfortable', 'compact', 'standard']),
@@ -152,6 +152,12 @@ DataGridRaw.propTypes = {
152
152
  * @ignore - do not document
153
153
  */
154
154
  disableEval: _propTypes.default.bool,
155
+ /**
156
+ * If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
157
+ * The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
158
+ * @default false (`!props.checkboxSelection` for MIT Data Grid)
159
+ */
160
+ disableMultipleRowSelection: _propTypes.default.bool,
155
161
  /**
156
162
  * If `true`, the selection on click on a row or cell is disabled.
157
163
  * @default false
@@ -188,7 +194,7 @@ DataGridRaw.propTypes = {
188
194
  */
189
195
  filterMode: _propTypes.default.oneOf(['client', 'server']),
190
196
  /**
191
- * Set the filter model of the grid.
197
+ * Set the filter model of the Data Grid.
192
198
  */
193
199
  filterModel: _propTypes.default.shape({
194
200
  items: _propTypes.default.arrayOf(_propTypes.default.shape({
@@ -203,7 +209,7 @@ DataGridRaw.propTypes = {
203
209
  quickFilterValues: _propTypes.default.array
204
210
  }),
205
211
  /**
206
- * Forwarded props for the grid root element.
212
+ * Forwarded props for the Data Grid root element.
207
213
  * @ignore - do not document.
208
214
  */
209
215
  forwardedProps: _propTypes.default.object,
@@ -271,7 +277,7 @@ DataGridRaw.propTypes = {
271
277
  */
272
278
  ignoreDiacritics: _propTypes.default.bool,
273
279
  /**
274
- * If `true`, the grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
280
+ * If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
275
281
  * If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
276
282
  * @default false
277
283
  */
@@ -309,7 +315,7 @@ DataGridRaw.propTypes = {
309
315
  */
310
316
  loading: _propTypes.default.bool,
311
317
  /**
312
- * Set the locale text of the grid.
318
+ * Set the locale text of the Data Grid.
313
319
  * You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
314
320
  */
315
321
  localeText: _propTypes.default.object,
@@ -477,7 +483,7 @@ DataGridRaw.propTypes = {
477
483
  */
478
484
  onProcessRowUpdateError: _propTypes.default.func,
479
485
  /**
480
- * Callback fired when the grid is resized.
486
+ * Callback fired when the Data Grid is resized.
481
487
  * @param {ElementSize} containerSize With all properties from [[ElementSize]].
482
488
  * @param {MuiEvent<{}>} event The event object.
483
489
  * @param {GridCallbackDetails} details Additional details for this callback.
@@ -535,7 +541,7 @@ DataGridRaw.propTypes = {
535
541
  */
536
542
  onSortModelChange: _propTypes.default.func,
537
543
  /**
538
- * Callback fired when the state of the grid is updated.
544
+ * Callback fired when the state of the Data Grid is updated.
539
545
  * @param {GridState} state The new state.
540
546
  * @param {MuiEvent<{}>} event The event object.
541
547
  * @param {GridCallbackDetails} details Additional details for this callback.
@@ -589,7 +595,7 @@ DataGridRaw.propTypes = {
589
595
  */
590
596
  rowCount: _propTypes.default.number,
591
597
  /**
592
- * Sets the height in pixel of a row in the grid.
598
+ * Sets the height in pixel of a row in the Data Grid.
593
599
  * @default 52
594
600
  */
595
601
  rowHeight: _propTypes.default.number,
@@ -614,7 +620,7 @@ DataGridRaw.propTypes = {
614
620
  */
615
621
  rowSelection: _propTypes.default.bool,
616
622
  /**
617
- * Sets the row selection model of the grid.
623
+ * Sets the row selection model of the Data Grid.
618
624
  */
619
625
  rowSelectionModel: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired), _propTypes.default.number, _propTypes.default.string]),
620
626
  /**
@@ -628,7 +634,7 @@ DataGridRaw.propTypes = {
628
634
  */
629
635
  rowThreshold: _propTypes.default.number,
630
636
  /**
631
- * Override the height/width of the grid inner scrollbar.
637
+ * Override the height/width of the Data Grid inner scrollbar.
632
638
  */
633
639
  scrollbarSize: _propTypes.default.number,
634
640
  /**
@@ -662,7 +668,7 @@ DataGridRaw.propTypes = {
662
668
  */
663
669
  sortingOrder: _propTypes.default.arrayOf(_propTypes.default.oneOf(['asc', 'desc'])),
664
670
  /**
665
- * Set the sort model of the grid.
671
+ * Set the sort model of the Data Grid.
666
672
  */
667
673
  sortModel: _propTypes.default.arrayOf(_propTypes.default.shape({
668
674
  field: _propTypes.default.string.isRequired,
@@ -17,7 +17,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
17
17
  const DATA_GRID_FORCED_PROPS = {
18
18
  disableMultipleColumnsFiltering: true,
19
19
  disableMultipleColumnsSorting: true,
20
- disableMultipleRowSelection: true,
21
20
  throttleRowsMs: undefined,
22
21
  hideFooterRowCount: false,
23
22
  pagination: true,
@@ -5,14 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getGridDateOperators = void 0;
7
7
  var _GridFilterInputDate = require("../components/panel/filterPanel/GridFilterInputDate");
8
- const dateRegex = /(\d+)-(\d+)-(\d+)/;
9
- const dateTimeRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+)/;
10
8
  function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
11
9
  if (!filterItem.value) {
12
10
  return null;
13
11
  }
14
- const [year, month, day, hour, minute] = filterItem.value.match(showTime ? dateTimeRegex : dateRegex).slice(1).map(Number);
15
- const time = new Date(year, month - 1, day, hour || 0, minute || 0).getTime();
12
+ const date = new Date(filterItem.value);
13
+ if (showTime) {
14
+ date.setSeconds(0, 0);
15
+ } else {
16
+ date.setHours(0, 0, 0, 0);
17
+ }
18
+ const time = date.getTime();
16
19
  return value => {
17
20
  if (!value) {
18
21
  return false;
@@ -23,8 +26,12 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
23
26
 
24
27
  // Make a copy of the date to not reset the hours in the original object
25
28
  const dateCopy = new Date(value);
26
- const timeToCompare = dateCopy.setHours(showTime ? value.getHours() : 0, showTime ? value.getMinutes() : 0, 0, 0);
27
- return compareFn(timeToCompare, time);
29
+ if (showTime) {
30
+ dateCopy.setSeconds(0, 0);
31
+ } else {
32
+ dateCopy.setHours(0, 0, 0, 0);
33
+ }
34
+ return compareFn(dateCopy.getTime(), time);
28
35
  };
29
36
  }
30
37
  const getGridDateOperators = showTime => [{
@@ -35,16 +35,10 @@ const GRID_SINGLE_SELECT_COL_DEF = exports.GRID_SINGLE_SELECT_COL_DEF = (0, _ext
35
35
  if (!(0, _filterPanelUtils.isSingleSelectColDef)(colDef)) {
36
36
  return '';
37
37
  }
38
- let valueOptions;
39
- if (typeof colDef.valueOptions === 'function') {
40
- valueOptions = colDef.valueOptions({
41
- id,
42
- row: id ? api.getRow(id) : null,
43
- field
44
- });
45
- } else {
46
- valueOptions = colDef.valueOptions;
47
- }
38
+ const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef, {
39
+ id,
40
+ row: id ? api.getRow(id) : null
41
+ });
48
42
  if (value == null) {
49
43
  return '';
50
44
  }
@@ -62,10 +56,7 @@ const GRID_SINGLE_SELECT_COL_DEF = exports.GRID_SINGLE_SELECT_COL_DEF = (0, _ext
62
56
  // @ts-ignore
63
57
  pastedValueParser: (value, params) => {
64
58
  const colDef = params.colDef;
65
- const colDefValueOptions = colDef.valueOptions;
66
- const valueOptions = typeof colDefValueOptions === 'function' ? colDefValueOptions({
67
- field: colDef.field
68
- }) : colDefValueOptions || [];
59
+ const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef) || [];
69
60
  const getOptionValue = colDef.getOptionValue;
70
61
  const valueOption = valueOptions.find(option => {
71
62
  if (getOptionValue(option) === value) {
@@ -19,7 +19,7 @@ var _gridEditRowModel = require("../../models/gridEditRowModel");
19
19
  var _filterPanelUtils = require("../panel/filterPanel/filterPanelUtils");
20
20
  var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
21
21
  var _jsxRuntime = require("react/jsx-runtime");
22
- const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen", "getOptionLabel", "getOptionValue"],
22
+ const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"],
23
23
  _excluded2 = ["MenuProps"];
24
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -37,9 +37,7 @@ function GridEditSingleSelectCell(props) {
37
37
  hasFocus,
38
38
  error,
39
39
  onValueChange,
40
- initialOpen = rootProps.editMode === _gridEditRowModel.GridEditModes.Cell,
41
- getOptionLabel: getOptionLabelProp,
42
- getOptionValue: getOptionValueProp
40
+ initialOpen = rootProps.editMode === _gridEditRowModel.GridEditModes.Cell
43
41
  } = props,
44
42
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
45
43
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
@@ -61,21 +59,15 @@ function GridEditSingleSelectCell(props) {
61
59
  if (!(0, _filterPanelUtils.isSingleSelectColDef)(colDef)) {
62
60
  return null;
63
61
  }
64
- let valueOptions;
65
- if (typeof colDef?.valueOptions === 'function') {
66
- valueOptions = colDef?.valueOptions({
67
- id,
68
- row,
69
- field
70
- });
71
- } else {
72
- valueOptions = colDef?.valueOptions;
73
- }
62
+ const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef, {
63
+ id,
64
+ row
65
+ });
74
66
  if (!valueOptions) {
75
67
  return null;
76
68
  }
77
- const getOptionValue = getOptionValueProp || colDef.getOptionValue;
78
- const getOptionLabel = getOptionLabelProp || colDef.getOptionLabel;
69
+ const getOptionValue = colDef.getOptionValue;
70
+ const getOptionLabel = colDef.getOptionLabel;
79
71
  const handleChange = async event => {
80
72
  if (!(0, _filterPanelUtils.isSingleSelectColDef)(colDef) || !valueOptions) {
81
73
  return;
@@ -164,18 +156,6 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
164
156
  * The cell value formatted with the column valueFormatter.
165
157
  */
166
158
  formattedValue: _propTypes.default.any,
167
- /**
168
- * Used to determine the label displayed for a given value option.
169
- * @param {ValueOptions} value The current value option.
170
- * @returns {string} The text to be displayed.
171
- */
172
- getOptionLabel: _propTypes.default.func,
173
- /**
174
- * Used to determine the value used for a value option.
175
- * @param {ValueOptions} value The current value option.
176
- * @returns {string} The value to be used.
177
- */
178
- getOptionValue: _propTypes.default.func,
179
159
  /**
180
160
  * If true, the cell is the active element.
181
161
  */
@@ -10,6 +10,7 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _utils = require("@mui/utils");
13
+ var _utils2 = require("../../hooks/features/rowSelection/utils");
13
14
  var _useGridSelector = require("../../hooks/utils/useGridSelector");
14
15
  var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
15
16
  var _gridRowSelectionSelector = require("../../hooks/features/rowSelection/gridRowSelectionSelector");
@@ -111,7 +112,8 @@ const GridHeaderCheckbox = exports.GridHeaderCheckbox = /*#__PURE__*/React.forwa
111
112
  'aria-label': label
112
113
  },
113
114
  tabIndex: tabIndex,
114
- onKeyDown: handleKeyDown
115
+ onKeyDown: handleKeyDown,
116
+ disabled: !(0, _utils2.isMultipleRowSelectionEnabled)(rootProps)
115
117
  }, rootProps.slotProps?.baseCheckbox, other));
116
118
  });
117
119
  process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes = {
@@ -20,6 +20,7 @@ var _gridFilterItem = require("../../../models/gridFilterItem");
20
20
  var _useGridApiContext = require("../../../hooks/utils/useGridApiContext");
21
21
  var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
22
22
  var _gridClasses = require("../../../constants/gridClasses");
23
+ var _filterPanelUtils = require("./filterPanelUtils");
23
24
  var _jsxRuntime = require("react/jsx-runtime");
24
25
  const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "multiFilterOperator", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "logicOperators", "columnsSort", "filterColumns", "deleteIconProps", "logicOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "children"],
25
26
  _excluded2 = ["InputComponentProps"];
@@ -138,23 +139,39 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
138
139
  const hasLogicOperatorColumn = hasMultipleFilters && logicOperators.length > 0;
139
140
  const baseFormControlProps = rootProps.slotProps?.baseFormControl || {};
140
141
  const baseSelectProps = rootProps.slotProps?.baseSelect || {};
141
- const isBaseSelectNative = baseSelectProps.native ?? true;
142
+ const isBaseSelectNative = baseSelectProps.native ?? false;
142
143
  const baseInputLabelProps = rootProps.slotProps?.baseInputLabel || {};
143
144
  const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
144
145
  const {
145
146
  InputComponentProps
146
147
  } = valueInputProps,
147
148
  valueInputPropsOther = (0, _objectWithoutPropertiesLoose2.default)(valueInputProps, _excluded2);
148
- const filteredColumns = React.useMemo(() => {
149
+ const {
150
+ filteredColumns,
151
+ selectedField
152
+ } = React.useMemo(() => {
153
+ let itemField = item.field;
149
154
  if (filterColumns === undefined || typeof filterColumns !== 'function') {
150
- return filterableColumns;
155
+ return {
156
+ filteredColumns: filterableColumns,
157
+ selectedField: itemField
158
+ };
151
159
  }
152
160
  const filteredFields = filterColumns({
153
161
  field: item.field,
154
162
  columns: filterableColumns,
155
163
  currentFilters: filterModel?.items || []
156
164
  });
157
- return filterableColumns.filter(column => filteredFields.includes(column.field));
165
+ return {
166
+ filteredColumns: filterableColumns.filter(column => {
167
+ const isFieldIncluded = filteredFields.includes(column.field);
168
+ if (column.field === item.field && !isFieldIncluded) {
169
+ itemField = undefined;
170
+ }
171
+ return isFieldIncluded;
172
+ }),
173
+ selectedField: itemField
174
+ };
158
175
  }, [filterColumns, filterModel?.items, filterableColumns, item.field]);
159
176
  const sortedFilteredColumns = React.useMemo(() => {
160
177
  switch (columnsSort) {
@@ -185,11 +202,29 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
185
202
  const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
186
203
 
187
204
  // Erase filter value if the input component or filtered column type is modified
188
- const eraseItemValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent || column.type !== currentColumn.type;
205
+ const eraseFilterValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent || column.type !== currentColumn.type;
206
+ let filterValue = eraseFilterValue ? undefined : item.value;
207
+
208
+ // Check filter value against the new valueOptions
209
+ if (column.type === 'singleSelect' && filterValue !== undefined) {
210
+ const colDef = column;
211
+ const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef);
212
+ if (Array.isArray(filterValue)) {
213
+ filterValue = filterValue.filter(val => {
214
+ return (
215
+ // Only keep values that are in the new value options
216
+ (0, _filterPanelUtils.getValueFromValueOptions)(val, valueOptions, colDef?.getOptionValue) !== undefined
217
+ );
218
+ });
219
+ } else if ((0, _filterPanelUtils.getValueFromValueOptions)(item.value, valueOptions, colDef?.getOptionValue) === undefined) {
220
+ // Reset the filter value if it is not in the new value options
221
+ filterValue = undefined;
222
+ }
223
+ }
189
224
  applyFilterChanges((0, _extends2.default)({}, item, {
190
225
  field,
191
226
  operator: newOperator.value,
192
- value: eraseItemValue ? undefined : item.value
227
+ value: filterValue
193
228
  }));
194
229
  }, [apiRef, applyFilterChanges, item, currentColumn, currentOperator]);
195
230
  const changeOperator = React.useCallback(event => {
@@ -264,7 +299,7 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
264
299
  inputProps: {
265
300
  'aria-label': apiRef.current.getLocaleText('filterPanelLogicOperator')
266
301
  },
267
- value: multiFilterOperator,
302
+ value: multiFilterOperator ?? '',
268
303
  onChange: changeLogicOperator,
269
304
  disabled: !!disableMultiFilterOperator || logicOperators.length === 1,
270
305
  native: isBaseSelectNative
@@ -289,7 +324,7 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
289
324
  labelId: columnSelectLabelId,
290
325
  id: columnSelectId,
291
326
  label: apiRef.current.getLocaleText('filterPanelColumns'),
292
- value: item.field || '',
327
+ value: selectedField ?? '',
293
328
  onChange: changeColumn,
294
329
  native: isBaseSelectNative
295
330
  }, rootProps.slotProps?.baseSelect, {
@@ -335,7 +370,7 @@ const GridFilterForm = exports.GridFilterForm = /*#__PURE__*/React.forwardRef(fu
335
370
  item: item,
336
371
  applyValue: applyFilterChanges,
337
372
  focusElementRef: valueRef
338
- }, currentOperator.InputComponentProps, InputComponentProps)) : null
373
+ }, currentOperator.InputComponentProps, InputComponentProps), item.field) : null
339
374
  }))]
340
375
  }));
341
376
  });
@@ -40,7 +40,7 @@ function GridFilterInputBoolean(props) {
40
40
  const labelId = (0, _utils.unstable_useId)();
41
41
  const selectId = (0, _utils.unstable_useId)();
42
42
  const baseSelectProps = rootProps.slotProps?.baseSelect || {};
43
- const isSelectNative = baseSelectProps.native ?? true;
43
+ const isSelectNative = baseSelectProps.native ?? false;
44
44
  const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
45
45
  const onFilterChange = React.useCallback(event => {
46
46
  const value = event.target.value;
@@ -16,6 +16,23 @@ var _jsxRuntime = require("react/jsx-runtime");
16
16
  const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "InputProps", "isFilterActive", "clearButton", "tabIndex", "disabled"];
17
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ function convertFilterItemValueToInputValue(itemValue, inputType) {
20
+ if (itemValue == null) {
21
+ return '';
22
+ }
23
+ const dateCopy = new Date(itemValue);
24
+ // The date picker expects the date to be in the local timezone.
25
+ // But .toISOString() converts it to UTC with zero offset.
26
+ // So we need to subtract the timezone offset.
27
+ dateCopy.setMinutes(dateCopy.getMinutes() - dateCopy.getTimezoneOffset());
28
+ if (inputType === 'date') {
29
+ return dateCopy.toISOString().substring(0, 10);
30
+ }
31
+ if (inputType === 'datetime-local') {
32
+ return dateCopy.toISOString().substring(0, 19);
33
+ }
34
+ return dateCopy.toISOString().substring(0, 10);
35
+ }
19
36
  function GridFilterInputDate(props) {
20
37
  const {
21
38
  item,
@@ -30,25 +47,26 @@ function GridFilterInputDate(props) {
30
47
  } = props,
31
48
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
32
49
  const filterTimeout = (0, _useTimeout.useTimeout)();
33
- const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
50
+ const [filterValueState, setFilterValueState] = React.useState(() => convertFilterItemValueToInputValue(item.value, type));
34
51
  const [applying, setIsApplying] = React.useState(false);
35
52
  const id = (0, _utils.unstable_useId)();
36
53
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
37
54
  const onFilterChange = React.useCallback(event => {
55
+ filterTimeout.clear();
38
56
  const value = event.target.value;
39
- setFilterValueState(String(value));
57
+ setFilterValueState(value);
40
58
  setIsApplying(true);
41
59
  filterTimeout.start(rootProps.filterDebounceMs, () => {
42
60
  applyValue((0, _extends2.default)({}, item, {
43
- value
61
+ value: new Date(value)
44
62
  }));
45
63
  setIsApplying(false);
46
64
  });
47
65
  }, [applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
48
66
  React.useEffect(() => {
49
- const itemValue = item.value ?? '';
50
- setFilterValueState(String(itemValue));
51
- }, [item.value]);
67
+ const value = convertFilterItemValueToInputValue(item.value, type);
68
+ setFilterValueState(value);
69
+ }, [item.value, type]);
52
70
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, (0, _extends2.default)({
53
71
  fullWidth: true,
54
72
  id: id,
@@ -14,7 +14,7 @@ var _utils = require("@mui/utils");
14
14
  var _filterPanelUtils = require("./filterPanelUtils");
15
15
  var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "color", "error", "helperText", "size", "variant", "getOptionLabel", "getOptionValue"];
17
+ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "color", "error", "helperText", "size", "variant"];
18
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
20
  const filter = (0, _Autocomplete.createFilterOptions)();
@@ -28,9 +28,7 @@ function GridFilterInputMultipleSingleSelect(props) {
28
28
  error,
29
29
  helperText,
30
30
  size,
31
- variant = 'standard',
32
- getOptionLabel: getOptionLabelProp,
33
- getOptionValue: getOptionValueProp
31
+ variant = 'standard'
34
32
  } = props,
35
33
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
36
34
  const TextFieldProps = {
@@ -49,23 +47,12 @@ function GridFilterInputMultipleSingleSelect(props) {
49
47
  resolvedColumn = column;
50
48
  }
51
49
  }
52
- const getOptionValue = getOptionValueProp || resolvedColumn?.getOptionValue;
53
- const getOptionLabel = getOptionLabelProp || resolvedColumn?.getOptionLabel;
50
+ const getOptionValue = resolvedColumn?.getOptionValue;
51
+ const getOptionLabel = resolvedColumn?.getOptionLabel;
54
52
  const isOptionEqualToValue = React.useCallback((option, value) => getOptionValue(option) === getOptionValue(value), [getOptionValue]);
55
53
  const resolvedValueOptions = React.useMemo(() => {
56
- if (!resolvedColumn?.valueOptions) {
57
- return [];
58
- }
59
- if (typeof resolvedColumn.valueOptions === 'function') {
60
- return resolvedColumn.valueOptions({
61
- field: resolvedColumn.field
62
- });
63
- }
64
- return resolvedColumn.valueOptions;
54
+ return (0, _filterPanelUtils.getValueOptions)(resolvedColumn) || [];
65
55
  }, [resolvedColumn]);
66
- const resolvedFormattedValueOptions = React.useMemo(() => {
67
- return resolvedValueOptions?.map(getOptionValue);
68
- }, [resolvedValueOptions, getOptionValue]);
69
56
 
70
57
  // The value is computed from the item.value and used directly
71
58
  // If it was done by a useEffect/useState, the Autocomplete could receive incoherent value and options
@@ -73,23 +60,8 @@ function GridFilterInputMultipleSingleSelect(props) {
73
60
  if (!Array.isArray(item.value)) {
74
61
  return [];
75
62
  }
76
- if (resolvedValueOptions !== undefined) {
77
- const itemValueIndexes = item.value.map(element => {
78
- // Gets the index matching between values and valueOptions
79
- return resolvedFormattedValueOptions?.findIndex(formattedOption => formattedOption === element);
80
- });
81
- return itemValueIndexes.filter(index => index >= 0).map(index => resolvedValueOptions[index]);
82
- }
83
63
  return item.value;
84
- }, [item.value, resolvedValueOptions, resolvedFormattedValueOptions]);
85
- React.useEffect(() => {
86
- if (!Array.isArray(item.value) || filteredValues.length !== item.value.length) {
87
- // Updates the state if the filter value has been cleaned by the component
88
- applyValue((0, _extends2.default)({}, item, {
89
- value: filteredValues.map(getOptionValue)
90
- }));
91
- }
92
- }, [item, filteredValues, applyValue, getOptionValue]);
64
+ }, [item.value]);
93
65
  const handleChange = React.useCallback((event, value) => {
94
66
  applyValue((0, _extends2.default)({}, item, {
95
67
  value: value.map(getOptionValue)
@@ -132,18 +104,6 @@ process.env.NODE_ENV !== "production" ? GridFilterInputMultipleSingleSelect.prop
132
104
  }).isRequired,
133
105
  applyValue: _propTypes.default.func.isRequired,
134
106
  focusElementRef: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.func, _propTypes.default.object]),
135
- /**
136
- * Used to determine the label displayed for a given value option.
137
- * @param {ValueOptions} value The current value option.
138
- * @returns {string} The text to be displayed.
139
- */
140
- getOptionLabel: _propTypes.default.func,
141
- /**
142
- * Used to determine the value used for a value option.
143
- * @param {ValueOptions} value The current value option.
144
- * @returns {string} The value to be used.
145
- */
146
- getOptionValue: _propTypes.default.func,
147
107
  item: _propTypes.default.shape({
148
108
  field: _propTypes.default.string.isRequired,
149
109
  id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),