@mui/x-data-grid 7.0.0-alpha.5 → 7.0.0-alpha.7
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.
- package/CHANGELOG.md +408 -6
- package/DataGrid/DataGrid.js +31 -21
- package/DataGrid/useDataGridProps.js +0 -1
- package/colDef/gridDateOperators.js +13 -6
- package/colDef/gridSingleSelectColDef.js +6 -15
- package/components/GridPagination.d.ts +2 -2
- package/components/cell/GridEditSingleSelectCell.d.ts +1 -2
- package/components/cell/GridEditSingleSelectCell.js +9 -29
- package/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +25 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -48
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -57
- package/components/panel/filterPanel/filterPanelUtils.d.ts +3 -2
- package/components/panel/filterPanel/filterPanelUtils.js +10 -5
- package/hooks/features/filter/gridFilterUtils.js +21 -24
- package/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/hooks/features/rowSelection/utils.d.ts +2 -0
- package/hooks/features/rowSelection/utils.js +8 -0
- package/hooks/utils/useGridAriaAttributes.js +2 -1
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +31 -21
- package/legacy/DataGrid/useDataGridProps.js +0 -1
- package/legacy/colDef/gridDateOperators.js +13 -13
- package/legacy/colDef/gridSingleSelectColDef.js +6 -15
- package/legacy/components/cell/GridEditSingleSelectCell.js +8 -28
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +51 -19
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +27 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -53
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -59
- package/legacy/components/panel/filterPanel/filterPanelUtils.js +10 -6
- package/legacy/hooks/features/filter/gridFilterUtils.js +20 -17
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/legacy/hooks/features/rowSelection/utils.js +8 -0
- package/legacy/hooks/utils/useGridAriaAttributes.js +2 -1
- package/legacy/index.js +1 -1
- package/legacy/locales/csCZ.js +2 -2
- package/locales/csCZ.js +2 -2
- package/models/props/DataGridProps.d.ts +26 -26
- package/modern/DataGrid/DataGrid.js +31 -21
- package/modern/DataGrid/useDataGridProps.js +0 -1
- package/modern/colDef/gridDateOperators.js +13 -6
- package/modern/colDef/gridSingleSelectColDef.js +6 -15
- package/modern/components/cell/GridEditSingleSelectCell.js +9 -29
- package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +24 -6
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -47
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -56
- package/modern/components/panel/filterPanel/filterPanelUtils.js +10 -5
- package/modern/hooks/features/filter/gridFilterUtils.js +21 -24
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/modern/hooks/features/rowSelection/utils.js +8 -0
- package/modern/hooks/utils/useGridAriaAttributes.js +2 -1
- package/modern/index.js +1 -1
- package/modern/locales/csCZ.js +2 -2
- package/node/DataGrid/DataGrid.js +31 -21
- package/node/DataGrid/useDataGridProps.js +0 -1
- package/node/colDef/gridDateOperators.js +13 -6
- package/node/colDef/gridSingleSelectColDef.js +5 -14
- package/node/components/cell/GridEditSingleSelectCell.js +8 -28
- package/node/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +24 -6
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -46
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -55
- package/node/components/panel/filterPanel/filterPanelUtils.js +12 -7
- package/node/hooks/features/filter/gridFilterUtils.js +21 -23
- package/node/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/node/hooks/features/rowSelection/utils.js +14 -0
- package/node/hooks/utils/useGridAriaAttributes.js +2 -1
- package/node/index.js +1 -1
- package/node/locales/csCZ.js +2 -2
- package/package.json +4 -4
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
@@ -71,13 +71,18 @@ DataGridRaw.propTypes = {
|
|
|
71
71
|
* If `true`, the pageSize is calculated according to the container size and the max number of rows to avoid rendering a vertical scroll bar.
|
|
72
72
|
* @default false
|
|
73
73
|
*/
|
|
74
|
-
autoPageSize: _propTypes.default.bool,
|
|
74
|
+
autoPageSize: (0, _utils.chainPropTypes)(_propTypes.default.bool, props => {
|
|
75
|
+
if (props.autoHeight && props.autoPageSize) {
|
|
76
|
+
return new Error(['MUI: `<DataGrid autoPageSize={true} autoHeight={true} />` are not valid props.', 'You can not use both the `autoPageSize` and `autoHeight` props at the same time because `autoHeight` scales the height of the Data Grid according to the `pageSize`.', '', 'Please remove one of these two props.'].join('\n'));
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}),
|
|
75
80
|
/**
|
|
76
81
|
* Controls the modes of the cells.
|
|
77
82
|
*/
|
|
78
83
|
cellModesModel: _propTypes.default.object,
|
|
79
84
|
/**
|
|
80
|
-
* If `true`, the
|
|
85
|
+
* If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
|
|
81
86
|
* @default false
|
|
82
87
|
*/
|
|
83
88
|
checkboxSelection: _propTypes.default.bool,
|
|
@@ -97,7 +102,7 @@ DataGridRaw.propTypes = {
|
|
|
97
102
|
columnBuffer: _propTypes.default.number,
|
|
98
103
|
columnGroupingModel: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
99
104
|
/**
|
|
100
|
-
* Sets the height in pixel of the column headers in the
|
|
105
|
+
* Sets the height in pixel of the column headers in the Data Grid.
|
|
101
106
|
* @default 56
|
|
102
107
|
*/
|
|
103
108
|
columnHeaderHeight: _propTypes.default.number,
|
|
@@ -117,12 +122,12 @@ DataGridRaw.propTypes = {
|
|
|
117
122
|
*/
|
|
118
123
|
columnThreshold: _propTypes.default.number,
|
|
119
124
|
/**
|
|
120
|
-
* Set the column visibility model of the
|
|
121
|
-
* If defined, the
|
|
125
|
+
* Set the column visibility model of the Data Grid.
|
|
126
|
+
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
122
127
|
*/
|
|
123
128
|
columnVisibilityModel: _propTypes.default.object,
|
|
124
129
|
/**
|
|
125
|
-
* Set the density of the
|
|
130
|
+
* Set the density of the Data Grid.
|
|
126
131
|
* @default "standard"
|
|
127
132
|
*/
|
|
128
133
|
density: _propTypes.default.oneOf(['comfortable', 'compact', 'standard']),
|
|
@@ -149,9 +154,14 @@ DataGridRaw.propTypes = {
|
|
|
149
154
|
/**
|
|
150
155
|
* If `true`, `eval()` is not used for performance optimization.
|
|
151
156
|
* @default false
|
|
152
|
-
* @ignore - do not document
|
|
153
157
|
*/
|
|
154
158
|
disableEval: _propTypes.default.bool,
|
|
159
|
+
/**
|
|
160
|
+
* If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
|
|
161
|
+
* The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
|
|
162
|
+
* @default false (`!props.checkboxSelection` for MIT Data Grid)
|
|
163
|
+
*/
|
|
164
|
+
disableMultipleRowSelection: _propTypes.default.bool,
|
|
155
165
|
/**
|
|
156
166
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
157
167
|
* @default false
|
|
@@ -188,7 +198,7 @@ DataGridRaw.propTypes = {
|
|
|
188
198
|
*/
|
|
189
199
|
filterMode: _propTypes.default.oneOf(['client', 'server']),
|
|
190
200
|
/**
|
|
191
|
-
* Set the filter model of the
|
|
201
|
+
* Set the filter model of the Data Grid.
|
|
192
202
|
*/
|
|
193
203
|
filterModel: _propTypes.default.shape({
|
|
194
204
|
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -203,7 +213,7 @@ DataGridRaw.propTypes = {
|
|
|
203
213
|
quickFilterValues: _propTypes.default.array
|
|
204
214
|
}),
|
|
205
215
|
/**
|
|
206
|
-
* Forwarded props for the
|
|
216
|
+
* Forwarded props for the Data Grid root element.
|
|
207
217
|
* @ignore - do not document.
|
|
208
218
|
*/
|
|
209
219
|
forwardedProps: _propTypes.default.object,
|
|
@@ -271,7 +281,7 @@ DataGridRaw.propTypes = {
|
|
|
271
281
|
*/
|
|
272
282
|
ignoreDiacritics: _propTypes.default.bool,
|
|
273
283
|
/**
|
|
274
|
-
* If `true`, the
|
|
284
|
+
* If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
275
285
|
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
276
286
|
* @default false
|
|
277
287
|
*/
|
|
@@ -309,7 +319,7 @@ DataGridRaw.propTypes = {
|
|
|
309
319
|
*/
|
|
310
320
|
loading: _propTypes.default.bool,
|
|
311
321
|
/**
|
|
312
|
-
* Set the locale text of the
|
|
322
|
+
* Set the locale text of the Data Grid.
|
|
313
323
|
* 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
324
|
*/
|
|
315
325
|
localeText: _propTypes.default.object,
|
|
@@ -477,7 +487,7 @@ DataGridRaw.propTypes = {
|
|
|
477
487
|
*/
|
|
478
488
|
onProcessRowUpdateError: _propTypes.default.func,
|
|
479
489
|
/**
|
|
480
|
-
* Callback fired when the
|
|
490
|
+
* Callback fired when the Data Grid is resized.
|
|
481
491
|
* @param {ElementSize} containerSize With all properties from [[ElementSize]].
|
|
482
492
|
* @param {MuiEvent<{}>} event The event object.
|
|
483
493
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -535,7 +545,7 @@ DataGridRaw.propTypes = {
|
|
|
535
545
|
*/
|
|
536
546
|
onSortModelChange: _propTypes.default.func,
|
|
537
547
|
/**
|
|
538
|
-
* Callback fired when the state of the
|
|
548
|
+
* Callback fired when the state of the Data Grid is updated.
|
|
539
549
|
* @param {GridState} state The new state.
|
|
540
550
|
* @param {MuiEvent<{}>} event The event object.
|
|
541
551
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -589,7 +599,7 @@ DataGridRaw.propTypes = {
|
|
|
589
599
|
*/
|
|
590
600
|
rowCount: _propTypes.default.number,
|
|
591
601
|
/**
|
|
592
|
-
* Sets the height in pixel of a row in the
|
|
602
|
+
* Sets the height in pixel of a row in the Data Grid.
|
|
593
603
|
* @default 52
|
|
594
604
|
*/
|
|
595
605
|
rowHeight: _propTypes.default.number,
|
|
@@ -614,7 +624,7 @@ DataGridRaw.propTypes = {
|
|
|
614
624
|
*/
|
|
615
625
|
rowSelection: _propTypes.default.bool,
|
|
616
626
|
/**
|
|
617
|
-
* Sets the row selection model of the
|
|
627
|
+
* Sets the row selection model of the Data Grid.
|
|
618
628
|
*/
|
|
619
629
|
rowSelectionModel: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired), _propTypes.default.number, _propTypes.default.string]),
|
|
620
630
|
/**
|
|
@@ -628,7 +638,7 @@ DataGridRaw.propTypes = {
|
|
|
628
638
|
*/
|
|
629
639
|
rowThreshold: _propTypes.default.number,
|
|
630
640
|
/**
|
|
631
|
-
* Override the height/width of the
|
|
641
|
+
* Override the height/width of the Data Grid inner scrollbar.
|
|
632
642
|
*/
|
|
633
643
|
scrollbarSize: _propTypes.default.number,
|
|
634
644
|
/**
|
|
@@ -662,7 +672,7 @@ DataGridRaw.propTypes = {
|
|
|
662
672
|
*/
|
|
663
673
|
sortingOrder: _propTypes.default.arrayOf(_propTypes.default.oneOf(['asc', 'desc'])),
|
|
664
674
|
/**
|
|
665
|
-
* Set the sort model of the
|
|
675
|
+
* Set the sort model of the Data Grid.
|
|
666
676
|
*/
|
|
667
677
|
sortModel: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
668
678
|
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
|
|
15
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
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"
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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 =
|
|
78
|
-
const 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 ??
|
|
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
|
|
149
|
+
const {
|
|
150
|
+
filteredColumns,
|
|
151
|
+
selectedField
|
|
152
|
+
} = React.useMemo(() => {
|
|
153
|
+
let itemField = item.field;
|
|
149
154
|
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
150
|
-
return
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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 ??
|
|
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(
|
|
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
|
|
50
|
-
setFilterValueState(
|
|
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"
|
|
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 =
|
|
53
|
-
const 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
|
-
|
|
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
|
|
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]),
|