@mui/x-data-grid 7.0.0-alpha.5 → 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.
- package/CHANGELOG.md +226 -6
- package/DataGrid/DataGrid.js +25 -19
- package/DataGrid/useDataGridProps.js +0 -1
- package/colDef/gridDateOperators.js +13 -6
- package/colDef/gridSingleSelectColDef.js +6 -15
- 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/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 +25 -19
- 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/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/models/props/DataGridProps.d.ts +26 -25
- package/modern/DataGrid/DataGrid.js +25 -19
- 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/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/node/DataGrid/DataGrid.js +25 -19
- 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/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/package.json +3 -3
|
@@ -41,21 +41,21 @@ DataGridRaw.propTypes = {
|
|
|
41
41
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
42
42
|
// ----------------------------------------------------------------------
|
|
43
43
|
/**
|
|
44
|
-
* The ref object that allows
|
|
44
|
+
* The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
|
|
45
45
|
*/
|
|
46
46
|
apiRef: PropTypes.shape({
|
|
47
47
|
current: PropTypes.object.isRequired
|
|
48
48
|
}),
|
|
49
49
|
/**
|
|
50
|
-
* The label of the
|
|
50
|
+
* The label of the Data Grid.
|
|
51
51
|
*/
|
|
52
52
|
'aria-label': PropTypes.string,
|
|
53
53
|
/**
|
|
54
|
-
* The id of the element containing a label for the
|
|
54
|
+
* The id of the element containing a label for the Data Grid.
|
|
55
55
|
*/
|
|
56
56
|
'aria-labelledby': PropTypes.string,
|
|
57
57
|
/**
|
|
58
|
-
* If `true`, the
|
|
58
|
+
* If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
autoHeight: PropTypes.bool,
|
|
@@ -69,7 +69,7 @@ DataGridRaw.propTypes = {
|
|
|
69
69
|
*/
|
|
70
70
|
cellModesModel: PropTypes.object,
|
|
71
71
|
/**
|
|
72
|
-
* If `true`, the
|
|
72
|
+
* If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
|
|
73
73
|
* @default false
|
|
74
74
|
*/
|
|
75
75
|
checkboxSelection: PropTypes.bool,
|
|
@@ -89,7 +89,7 @@ DataGridRaw.propTypes = {
|
|
|
89
89
|
columnBuffer: PropTypes.number,
|
|
90
90
|
columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
|
|
91
91
|
/**
|
|
92
|
-
* Sets the height in pixel of the column headers in the
|
|
92
|
+
* Sets the height in pixel of the column headers in the Data Grid.
|
|
93
93
|
* @default 56
|
|
94
94
|
*/
|
|
95
95
|
columnHeaderHeight: PropTypes.number,
|
|
@@ -111,12 +111,12 @@ DataGridRaw.propTypes = {
|
|
|
111
111
|
*/
|
|
112
112
|
columnThreshold: PropTypes.number,
|
|
113
113
|
/**
|
|
114
|
-
* Set the column visibility model of the
|
|
115
|
-
* If defined, the
|
|
114
|
+
* Set the column visibility model of the Data Grid.
|
|
115
|
+
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
116
116
|
*/
|
|
117
117
|
columnVisibilityModel: PropTypes.object,
|
|
118
118
|
/**
|
|
119
|
-
* Set the density of the
|
|
119
|
+
* Set the density of the Data Grid.
|
|
120
120
|
* @default "standard"
|
|
121
121
|
*/
|
|
122
122
|
density: PropTypes.oneOf(['comfortable', 'compact', 'standard']),
|
|
@@ -146,6 +146,12 @@ DataGridRaw.propTypes = {
|
|
|
146
146
|
* @ignore - do not document
|
|
147
147
|
*/
|
|
148
148
|
disableEval: PropTypes.bool,
|
|
149
|
+
/**
|
|
150
|
+
* If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
|
|
151
|
+
* The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
|
|
152
|
+
* @default false (`!props.checkboxSelection` for MIT Data Grid)
|
|
153
|
+
*/
|
|
154
|
+
disableMultipleRowSelection: PropTypes.bool,
|
|
149
155
|
/**
|
|
150
156
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
151
157
|
* @default false
|
|
@@ -182,7 +188,7 @@ DataGridRaw.propTypes = {
|
|
|
182
188
|
*/
|
|
183
189
|
filterMode: PropTypes.oneOf(['client', 'server']),
|
|
184
190
|
/**
|
|
185
|
-
* Set the filter model of the
|
|
191
|
+
* Set the filter model of the Data Grid.
|
|
186
192
|
*/
|
|
187
193
|
filterModel: PropTypes.shape({
|
|
188
194
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -197,7 +203,7 @@ DataGridRaw.propTypes = {
|
|
|
197
203
|
quickFilterValues: PropTypes.array
|
|
198
204
|
}),
|
|
199
205
|
/**
|
|
200
|
-
* Forwarded props for the
|
|
206
|
+
* Forwarded props for the Data Grid root element.
|
|
201
207
|
* @ignore - do not document.
|
|
202
208
|
*/
|
|
203
209
|
forwardedProps: PropTypes.object,
|
|
@@ -265,7 +271,7 @@ DataGridRaw.propTypes = {
|
|
|
265
271
|
*/
|
|
266
272
|
ignoreDiacritics: PropTypes.bool,
|
|
267
273
|
/**
|
|
268
|
-
* If `true`, the
|
|
274
|
+
* If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
269
275
|
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
270
276
|
* @default false
|
|
271
277
|
*/
|
|
@@ -303,7 +309,7 @@ DataGridRaw.propTypes = {
|
|
|
303
309
|
*/
|
|
304
310
|
loading: PropTypes.bool,
|
|
305
311
|
/**
|
|
306
|
-
* Set the locale text of the
|
|
312
|
+
* Set the locale text of the Data Grid.
|
|
307
313
|
* 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.
|
|
308
314
|
*/
|
|
309
315
|
localeText: PropTypes.object,
|
|
@@ -471,7 +477,7 @@ DataGridRaw.propTypes = {
|
|
|
471
477
|
*/
|
|
472
478
|
onProcessRowUpdateError: PropTypes.func,
|
|
473
479
|
/**
|
|
474
|
-
* Callback fired when the
|
|
480
|
+
* Callback fired when the Data Grid is resized.
|
|
475
481
|
* @param {ElementSize} containerSize With all properties from [[ElementSize]].
|
|
476
482
|
* @param {MuiEvent<{}>} event The event object.
|
|
477
483
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -529,7 +535,7 @@ DataGridRaw.propTypes = {
|
|
|
529
535
|
*/
|
|
530
536
|
onSortModelChange: PropTypes.func,
|
|
531
537
|
/**
|
|
532
|
-
* Callback fired when the state of the
|
|
538
|
+
* Callback fired when the state of the Data Grid is updated.
|
|
533
539
|
* @param {GridState} state The new state.
|
|
534
540
|
* @param {MuiEvent<{}>} event The event object.
|
|
535
541
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -583,7 +589,7 @@ DataGridRaw.propTypes = {
|
|
|
583
589
|
*/
|
|
584
590
|
rowCount: PropTypes.number,
|
|
585
591
|
/**
|
|
586
|
-
* Sets the height in pixel of a row in the
|
|
592
|
+
* Sets the height in pixel of a row in the Data Grid.
|
|
587
593
|
* @default 52
|
|
588
594
|
*/
|
|
589
595
|
rowHeight: PropTypes.number,
|
|
@@ -608,7 +614,7 @@ DataGridRaw.propTypes = {
|
|
|
608
614
|
*/
|
|
609
615
|
rowSelection: PropTypes.bool,
|
|
610
616
|
/**
|
|
611
|
-
* Sets the row selection model of the
|
|
617
|
+
* Sets the row selection model of the Data Grid.
|
|
612
618
|
*/
|
|
613
619
|
rowSelectionModel: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired), PropTypes.number, PropTypes.string]),
|
|
614
620
|
/**
|
|
@@ -622,7 +628,7 @@ DataGridRaw.propTypes = {
|
|
|
622
628
|
*/
|
|
623
629
|
rowThreshold: PropTypes.number,
|
|
624
630
|
/**
|
|
625
|
-
* Override the height/width of the
|
|
631
|
+
* Override the height/width of the Data Grid inner scrollbar.
|
|
626
632
|
*/
|
|
627
633
|
scrollbarSize: PropTypes.number,
|
|
628
634
|
/**
|
|
@@ -656,7 +662,7 @@ DataGridRaw.propTypes = {
|
|
|
656
662
|
*/
|
|
657
663
|
sortingOrder: PropTypes.arrayOf(PropTypes.oneOf(['asc', 'desc'])),
|
|
658
664
|
/**
|
|
659
|
-
* Set the sort model of the
|
|
665
|
+
* Set the sort model of the Data Grid.
|
|
660
666
|
*/
|
|
661
667
|
sortModel: PropTypes.arrayOf(PropTypes.shape({
|
|
662
668
|
field: PropTypes.string.isRequired,
|
|
@@ -8,7 +8,6 @@ import { computeSlots, useProps } from '../internals/utils';
|
|
|
8
8
|
var DATA_GRID_FORCED_PROPS = {
|
|
9
9
|
disableMultipleColumnsFiltering: true,
|
|
10
10
|
disableMultipleColumnsSorting: true,
|
|
11
|
-
disableMultipleRowSelection: true,
|
|
12
11
|
throttleRowsMs: undefined,
|
|
13
12
|
hideFooterRowCount: false,
|
|
14
13
|
pagination: true,
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import { GridFilterInputDate } from '../components/panel/filterPanel/GridFilterInputDate';
|
|
3
|
-
var dateRegex = /(\d+)-(\d+)-(\d+)/;
|
|
4
|
-
var dateTimeRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+)/;
|
|
5
2
|
function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
6
3
|
if (!filterItem.value) {
|
|
7
4
|
return null;
|
|
8
5
|
}
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var time = new Date(year, month - 1, day, hour || 0, minute || 0).getTime();
|
|
6
|
+
var date = new Date(filterItem.value);
|
|
7
|
+
if (showTime) {
|
|
8
|
+
date.setSeconds(0, 0);
|
|
9
|
+
} else {
|
|
10
|
+
date.setHours(0, 0, 0, 0);
|
|
11
|
+
}
|
|
12
|
+
var time = date.getTime();
|
|
17
13
|
return function (value) {
|
|
18
14
|
if (!value) {
|
|
19
15
|
return false;
|
|
@@ -24,8 +20,12 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
|
24
20
|
|
|
25
21
|
// Make a copy of the date to not reset the hours in the original object
|
|
26
22
|
var dateCopy = new Date(value);
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
if (showTime) {
|
|
24
|
+
dateCopy.setSeconds(0, 0);
|
|
25
|
+
} else {
|
|
26
|
+
dateCopy.setHours(0, 0, 0, 0);
|
|
27
|
+
}
|
|
28
|
+
return compareFn(dateCopy.getTime(), time);
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
export var getGridDateOperators = function getGridDateOperators(showTime) {
|
|
@@ -3,7 +3,7 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
|
3
3
|
import { GRID_STRING_COL_DEF } from './gridStringColDef';
|
|
4
4
|
import { renderEditSingleSelectCell } from '../components/cell/GridEditSingleSelectCell';
|
|
5
5
|
import { getGridSingleSelectOperators } from './gridSingleSelectOperators';
|
|
6
|
-
import { isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
|
|
6
|
+
import { getValueOptions, isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
|
|
7
7
|
import { isObject } from '../utils/utils';
|
|
8
8
|
var isArrayOfObjects = function isArrayOfObjects(options) {
|
|
9
9
|
return _typeof(options[0]) === 'object';
|
|
@@ -27,16 +27,10 @@ export var GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
27
27
|
if (!isSingleSelectColDef(colDef)) {
|
|
28
28
|
return '';
|
|
29
29
|
}
|
|
30
|
-
var valueOptions
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
row: id ? api.getRow(id) : null,
|
|
35
|
-
field: field
|
|
36
|
-
});
|
|
37
|
-
} else {
|
|
38
|
-
valueOptions = colDef.valueOptions;
|
|
39
|
-
}
|
|
30
|
+
var valueOptions = getValueOptions(colDef, {
|
|
31
|
+
id: id,
|
|
32
|
+
row: id ? api.getRow(id) : null
|
|
33
|
+
});
|
|
40
34
|
if (value == null) {
|
|
41
35
|
return '';
|
|
42
36
|
}
|
|
@@ -56,10 +50,7 @@ export var GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
56
50
|
// @ts-ignore
|
|
57
51
|
pastedValueParser: function pastedValueParser(value, params) {
|
|
58
52
|
var colDef = params.colDef;
|
|
59
|
-
var
|
|
60
|
-
var valueOptions = typeof colDefValueOptions === 'function' ? colDefValueOptions({
|
|
61
|
-
field: colDef.field
|
|
62
|
-
}) : colDefValueOptions || [];
|
|
53
|
+
var valueOptions = getValueOptions(colDef) || [];
|
|
63
54
|
var getOptionValue = colDef.getOptionValue;
|
|
64
55
|
var valueOption = valueOptions.find(function (option) {
|
|
65
56
|
if (getOptionValue(option) === value) {
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"
|
|
5
|
+
var _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"],
|
|
6
6
|
_excluded2 = ["MenuProps"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import * as React from 'react';
|
|
@@ -12,7 +12,7 @@ import { GridCellEditStopReasons } from '../../models/params/gridEditCellParams'
|
|
|
12
12
|
import { isEscapeKey } from '../../utils/keyboardUtils';
|
|
13
13
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
14
14
|
import { GridEditModes } from '../../models/gridEditRowModel';
|
|
15
|
-
import { getValueFromValueOptions, isSingleSelectColDef } from '../panel/filterPanel/filterPanelUtils';
|
|
15
|
+
import { getValueFromValueOptions, getValueOptions, isSingleSelectColDef } from '../panel/filterPanel/filterPanelUtils';
|
|
16
16
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
17
17
|
import { createElement as _createElement } from "react";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -41,8 +41,6 @@ function GridEditSingleSelectCell(props) {
|
|
|
41
41
|
onValueChange = props.onValueChange,
|
|
42
42
|
_props$initialOpen = props.initialOpen,
|
|
43
43
|
initialOpen = _props$initialOpen === void 0 ? rootProps.editMode === GridEditModes.Cell : _props$initialOpen,
|
|
44
|
-
getOptionLabelProp = props.getOptionLabel,
|
|
45
|
-
getOptionValueProp = props.getOptionValue,
|
|
46
44
|
other = _objectWithoutProperties(props, _excluded);
|
|
47
45
|
var apiRef = useGridApiContext();
|
|
48
46
|
var ref = React.useRef();
|
|
@@ -65,21 +63,15 @@ function GridEditSingleSelectCell(props) {
|
|
|
65
63
|
if (!isSingleSelectColDef(colDef)) {
|
|
66
64
|
return null;
|
|
67
65
|
}
|
|
68
|
-
var valueOptions
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
row: row,
|
|
73
|
-
field: field
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
valueOptions = colDef == null ? void 0 : colDef.valueOptions;
|
|
77
|
-
}
|
|
66
|
+
var valueOptions = getValueOptions(colDef, {
|
|
67
|
+
id: id,
|
|
68
|
+
row: row
|
|
69
|
+
});
|
|
78
70
|
if (!valueOptions) {
|
|
79
71
|
return null;
|
|
80
72
|
}
|
|
81
|
-
var getOptionValue =
|
|
82
|
-
var getOptionLabel =
|
|
73
|
+
var getOptionValue = colDef.getOptionValue;
|
|
74
|
+
var getOptionLabel = colDef.getOptionLabel;
|
|
83
75
|
var handleChange = /*#__PURE__*/function () {
|
|
84
76
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
85
77
|
var target, formattedTargetValue;
|
|
@@ -190,18 +182,6 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
190
182
|
* The cell value formatted with the column valueFormatter.
|
|
191
183
|
*/
|
|
192
184
|
formattedValue: PropTypes.any,
|
|
193
|
-
/**
|
|
194
|
-
* Used to determine the label displayed for a given value option.
|
|
195
|
-
* @param {ValueOptions} value The current value option.
|
|
196
|
-
* @returns {string} The text to be displayed.
|
|
197
|
-
*/
|
|
198
|
-
getOptionLabel: PropTypes.func,
|
|
199
|
-
/**
|
|
200
|
-
* Used to determine the value used for a value option.
|
|
201
|
-
* @param {ValueOptions} value The current value option.
|
|
202
|
-
* @returns {string} The value to be used.
|
|
203
|
-
*/
|
|
204
|
-
getOptionValue: PropTypes.func,
|
|
205
185
|
/**
|
|
206
186
|
* If true, the cell is the active element.
|
|
207
187
|
*/
|
|
@@ -5,6 +5,7 @@ var _excluded = ["field", "colDef"];
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
|
+
import { isMultipleRowSelectionEnabled } from '../../hooks/features/rowSelection/utils';
|
|
8
9
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
9
10
|
import { gridTabIndexColumnHeaderSelector } from '../../hooks/features/focus/gridFocusStateSelector';
|
|
10
11
|
import { gridRowSelectionStateSelector } from '../../hooks/features/rowSelection/gridRowSelectionSelector';
|
|
@@ -112,7 +113,8 @@ var GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderCheckb
|
|
|
112
113
|
'aria-label': label
|
|
113
114
|
},
|
|
114
115
|
tabIndex: tabIndex,
|
|
115
|
-
onKeyDown: handleKeyDown
|
|
116
|
+
onKeyDown: handleKeyDown,
|
|
117
|
+
disabled: !isMultipleRowSelectionEnabled(rootProps)
|
|
116
118
|
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseCheckbox, other));
|
|
117
119
|
});
|
|
118
120
|
process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes = {
|
|
@@ -14,6 +14,7 @@ import { GridLogicOperator } from '../../../models/gridFilterItem';
|
|
|
14
14
|
import { useGridApiContext } from '../../../hooks/utils/useGridApiContext';
|
|
15
15
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
16
16
|
import { getDataGridUtilityClass } from '../../../constants/gridClasses';
|
|
17
|
+
import { getValueFromValueOptions, getValueOptions } from './filterPanelUtils';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
import { createElement as _createElement } from "react";
|
|
19
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -150,24 +151,37 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
|
|
|
150
151
|
var hasLogicOperatorColumn = hasMultipleFilters && logicOperators.length > 0;
|
|
151
152
|
var baseFormControlProps = ((_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseFormControl) || {};
|
|
152
153
|
var baseSelectProps = ((_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseSelect) || {};
|
|
153
|
-
var isBaseSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati :
|
|
154
|
+
var isBaseSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : false;
|
|
154
155
|
var baseInputLabelProps = ((_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseInputLabel) || {};
|
|
155
156
|
var baseSelectOptionProps = ((_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseSelectOption) || {};
|
|
156
157
|
var InputComponentProps = valueInputProps.InputComponentProps,
|
|
157
158
|
valueInputPropsOther = _objectWithoutProperties(valueInputProps, _excluded2);
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
var _React$useMemo = React.useMemo(function () {
|
|
160
|
+
var itemField = item.field;
|
|
161
|
+
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
162
|
+
return {
|
|
163
|
+
filteredColumns: filterableColumns,
|
|
164
|
+
selectedField: itemField
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
var filteredFields = filterColumns({
|
|
168
|
+
field: item.field,
|
|
169
|
+
columns: filterableColumns,
|
|
170
|
+
currentFilters: (filterModel == null ? void 0 : filterModel.items) || []
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
filteredColumns: filterableColumns.filter(function (column) {
|
|
174
|
+
var isFieldIncluded = filteredFields.includes(column.field);
|
|
175
|
+
if (column.field === item.field && !isFieldIncluded) {
|
|
176
|
+
itemField = undefined;
|
|
177
|
+
}
|
|
178
|
+
return isFieldIncluded;
|
|
179
|
+
}),
|
|
180
|
+
selectedField: itemField
|
|
181
|
+
};
|
|
182
|
+
}, [filterColumns, filterModel == null ? void 0 : filterModel.items, filterableColumns, item.field]),
|
|
183
|
+
filteredColumns = _React$useMemo.filteredColumns,
|
|
184
|
+
selectedField = _React$useMemo.selectedField;
|
|
171
185
|
var sortedFilteredColumns = React.useMemo(function () {
|
|
172
186
|
switch (columnsSort) {
|
|
173
187
|
case 'asc':
|
|
@@ -206,11 +220,29 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
|
|
|
206
220
|
}) || column.filterOperators[0];
|
|
207
221
|
|
|
208
222
|
// Erase filter value if the input component or filtered column type is modified
|
|
209
|
-
var
|
|
223
|
+
var eraseFilterValue = !newOperator.InputComponent || newOperator.InputComponent !== (currentOperator == null ? void 0 : currentOperator.InputComponent) || column.type !== currentColumn.type;
|
|
224
|
+
var filterValue = eraseFilterValue ? undefined : item.value;
|
|
225
|
+
|
|
226
|
+
// Check filter value against the new valueOptions
|
|
227
|
+
if (column.type === 'singleSelect' && filterValue !== undefined) {
|
|
228
|
+
var colDef = column;
|
|
229
|
+
var valueOptions = getValueOptions(colDef);
|
|
230
|
+
if (Array.isArray(filterValue)) {
|
|
231
|
+
filterValue = filterValue.filter(function (val) {
|
|
232
|
+
return (
|
|
233
|
+
// Only keep values that are in the new value options
|
|
234
|
+
getValueFromValueOptions(val, valueOptions, colDef == null ? void 0 : colDef.getOptionValue) !== undefined
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
} else if (getValueFromValueOptions(item.value, valueOptions, colDef == null ? void 0 : colDef.getOptionValue) === undefined) {
|
|
238
|
+
// Reset the filter value if it is not in the new value options
|
|
239
|
+
filterValue = undefined;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
210
242
|
applyFilterChanges(_extends({}, item, {
|
|
211
243
|
field: field,
|
|
212
244
|
operator: newOperator.value,
|
|
213
|
-
value:
|
|
245
|
+
value: filterValue
|
|
214
246
|
}));
|
|
215
247
|
}, [apiRef, applyFilterChanges, item, currentColumn, currentOperator]);
|
|
216
248
|
var changeOperator = React.useCallback(function (event) {
|
|
@@ -290,7 +322,7 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
|
|
|
290
322
|
inputProps: {
|
|
291
323
|
'aria-label': apiRef.current.getLocaleText('filterPanelLogicOperator')
|
|
292
324
|
},
|
|
293
|
-
value: multiFilterOperator,
|
|
325
|
+
value: multiFilterOperator != null ? multiFilterOperator : '',
|
|
294
326
|
onChange: changeLogicOperator,
|
|
295
327
|
disabled: !!disableMultiFilterOperator || logicOperators.length === 1,
|
|
296
328
|
native: isBaseSelectNative
|
|
@@ -317,7 +349,7 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
|
|
|
317
349
|
labelId: columnSelectLabelId,
|
|
318
350
|
id: columnSelectId,
|
|
319
351
|
label: apiRef.current.getLocaleText('filterPanelColumns'),
|
|
320
|
-
value:
|
|
352
|
+
value: selectedField != null ? selectedField : '',
|
|
321
353
|
onChange: changeColumn,
|
|
322
354
|
native: isBaseSelectNative
|
|
323
355
|
}, (_rootProps$slotProps7 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps7.baseSelect, {
|
|
@@ -367,7 +399,7 @@ var GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(props
|
|
|
367
399
|
item: item,
|
|
368
400
|
applyValue: applyFilterChanges,
|
|
369
401
|
focusElementRef: valueRef
|
|
370
|
-
}, currentOperator.InputComponentProps, InputComponentProps)) : null
|
|
402
|
+
}, currentOperator.InputComponentProps, InputComponentProps), item.field) : null
|
|
371
403
|
}))]
|
|
372
404
|
}));
|
|
373
405
|
});
|
|
@@ -37,7 +37,7 @@ function GridFilterInputBoolean(props) {
|
|
|
37
37
|
var labelId = useId();
|
|
38
38
|
var selectId = useId();
|
|
39
39
|
var baseSelectProps = ((_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseSelect) || {};
|
|
40
|
-
var isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati :
|
|
40
|
+
var isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : false;
|
|
41
41
|
var baseSelectOptionProps = ((_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseSelectOption) || {};
|
|
42
42
|
var onFilterChange = React.useCallback(function (event) {
|
|
43
43
|
var value = event.target.value;
|
|
@@ -8,8 +8,25 @@ import { unstable_useId as useId } from '@mui/utils';
|
|
|
8
8
|
import { useTimeout } from '../../../hooks/utils/useTimeout';
|
|
9
9
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
function convertFilterItemValueToInputValue(itemValue, inputType) {
|
|
12
|
+
if (itemValue == null) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
var dateCopy = new Date(itemValue);
|
|
16
|
+
// The date picker expects the date to be in the local timezone.
|
|
17
|
+
// But .toISOString() converts it to UTC with zero offset.
|
|
18
|
+
// So we need to subtract the timezone offset.
|
|
19
|
+
dateCopy.setMinutes(dateCopy.getMinutes() - dateCopy.getTimezoneOffset());
|
|
20
|
+
if (inputType === 'date') {
|
|
21
|
+
return dateCopy.toISOString().substring(0, 10);
|
|
22
|
+
}
|
|
23
|
+
if (inputType === 'datetime-local') {
|
|
24
|
+
return dateCopy.toISOString().substring(0, 19);
|
|
25
|
+
}
|
|
26
|
+
return dateCopy.toISOString().substring(0, 10);
|
|
27
|
+
}
|
|
11
28
|
function GridFilterInputDate(props) {
|
|
12
|
-
var
|
|
29
|
+
var _rootProps$slotProps;
|
|
13
30
|
var item = props.item,
|
|
14
31
|
applyValue = props.applyValue,
|
|
15
32
|
type = props.type,
|
|
@@ -22,7 +39,9 @@ function GridFilterInputDate(props) {
|
|
|
22
39
|
disabled = props.disabled,
|
|
23
40
|
other = _objectWithoutProperties(props, _excluded);
|
|
24
41
|
var filterTimeout = useTimeout();
|
|
25
|
-
var _React$useState = React.useState((
|
|
42
|
+
var _React$useState = React.useState(function () {
|
|
43
|
+
return convertFilterItemValueToInputValue(item.value, type);
|
|
44
|
+
}),
|
|
26
45
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
27
46
|
filterValueState = _React$useState2[0],
|
|
28
47
|
setFilterValueState = _React$useState2[1];
|
|
@@ -33,21 +52,21 @@ function GridFilterInputDate(props) {
|
|
|
33
52
|
var id = useId();
|
|
34
53
|
var rootProps = useGridRootProps();
|
|
35
54
|
var onFilterChange = React.useCallback(function (event) {
|
|
55
|
+
filterTimeout.clear();
|
|
36
56
|
var value = event.target.value;
|
|
37
|
-
setFilterValueState(
|
|
57
|
+
setFilterValueState(value);
|
|
38
58
|
setIsApplying(true);
|
|
39
59
|
filterTimeout.start(rootProps.filterDebounceMs, function () {
|
|
40
60
|
applyValue(_extends({}, item, {
|
|
41
|
-
value: value
|
|
61
|
+
value: new Date(value)
|
|
42
62
|
}));
|
|
43
63
|
setIsApplying(false);
|
|
44
64
|
});
|
|
45
65
|
}, [applyValue, item, rootProps.filterDebounceMs, filterTimeout]);
|
|
46
66
|
React.useEffect(function () {
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, [item.value]);
|
|
67
|
+
var value = convertFilterItemValueToInputValue(item.value, type);
|
|
68
|
+
setFilterValueState(value);
|
|
69
|
+
}, [item.value, type]);
|
|
51
70
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
|
|
52
71
|
fullWidth: true,
|
|
53
72
|
id: id,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "color", "error", "helperText", "size", "variant"
|
|
3
|
+
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "color", "error", "helperText", "size", "variant"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
|
|
7
7
|
import { unstable_useId as useId } from '@mui/utils';
|
|
8
|
-
import { isSingleSelectColDef } from './filterPanelUtils';
|
|
8
|
+
import { getValueOptions, isSingleSelectColDef } from './filterPanelUtils';
|
|
9
9
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
var filter = createFilterOptions();
|
|
@@ -22,8 +22,6 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
22
22
|
size = props.size,
|
|
23
23
|
_props$variant = props.variant,
|
|
24
24
|
variant = _props$variant === void 0 ? 'standard' : _props$variant,
|
|
25
|
-
getOptionLabelProp = props.getOptionLabel,
|
|
26
|
-
getOptionValueProp = props.getOptionValue,
|
|
27
25
|
other = _objectWithoutProperties(props, _excluded);
|
|
28
26
|
var TextFieldProps = {
|
|
29
27
|
color: color,
|
|
@@ -41,26 +39,14 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
41
39
|
resolvedColumn = column;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
var getOptionValue =
|
|
45
|
-
var getOptionLabel =
|
|
42
|
+
var getOptionValue = (_resolvedColumn = resolvedColumn) == null ? void 0 : _resolvedColumn.getOptionValue;
|
|
43
|
+
var getOptionLabel = (_resolvedColumn2 = resolvedColumn) == null ? void 0 : _resolvedColumn2.getOptionLabel;
|
|
46
44
|
var isOptionEqualToValue = React.useCallback(function (option, value) {
|
|
47
45
|
return getOptionValue(option) === getOptionValue(value);
|
|
48
46
|
}, [getOptionValue]);
|
|
49
47
|
var resolvedValueOptions = React.useMemo(function () {
|
|
50
|
-
|
|
51
|
-
if (!((_resolvedColumn3 = resolvedColumn) != null && _resolvedColumn3.valueOptions)) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
if (typeof resolvedColumn.valueOptions === 'function') {
|
|
55
|
-
return resolvedColumn.valueOptions({
|
|
56
|
-
field: resolvedColumn.field
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return resolvedColumn.valueOptions;
|
|
48
|
+
return getValueOptions(resolvedColumn) || [];
|
|
60
49
|
}, [resolvedColumn]);
|
|
61
|
-
var resolvedFormattedValueOptions = React.useMemo(function () {
|
|
62
|
-
return resolvedValueOptions == null ? void 0 : resolvedValueOptions.map(getOptionValue);
|
|
63
|
-
}, [resolvedValueOptions, getOptionValue]);
|
|
64
50
|
|
|
65
51
|
// The value is computed from the item.value and used directly
|
|
66
52
|
// If it was done by a useEffect/useState, the Autocomplete could receive incoherent value and options
|
|
@@ -68,29 +54,8 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
68
54
|
if (!Array.isArray(item.value)) {
|
|
69
55
|
return [];
|
|
70
56
|
}
|
|
71
|
-
if (resolvedValueOptions !== undefined) {
|
|
72
|
-
var itemValueIndexes = item.value.map(function (element) {
|
|
73
|
-
// Gets the index matching between values and valueOptions
|
|
74
|
-
return resolvedFormattedValueOptions == null ? void 0 : resolvedFormattedValueOptions.findIndex(function (formattedOption) {
|
|
75
|
-
return formattedOption === element;
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
return itemValueIndexes.filter(function (index) {
|
|
79
|
-
return index >= 0;
|
|
80
|
-
}).map(function (index) {
|
|
81
|
-
return resolvedValueOptions[index];
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
57
|
return item.value;
|
|
85
|
-
}, [item.value
|
|
86
|
-
React.useEffect(function () {
|
|
87
|
-
if (!Array.isArray(item.value) || filteredValues.length !== item.value.length) {
|
|
88
|
-
// Updates the state if the filter value has been cleaned by the component
|
|
89
|
-
applyValue(_extends({}, item, {
|
|
90
|
-
value: filteredValues.map(getOptionValue)
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
}, [item, filteredValues, applyValue, getOptionValue]);
|
|
58
|
+
}, [item.value]);
|
|
94
59
|
var handleChange = React.useCallback(function (event, value) {
|
|
95
60
|
applyValue(_extends({}, item, {
|
|
96
61
|
value: value.map(getOptionValue)
|
|
@@ -140,18 +105,6 @@ process.env.NODE_ENV !== "production" ? GridFilterInputMultipleSingleSelect.prop
|
|
|
140
105
|
}).isRequired,
|
|
141
106
|
applyValue: PropTypes.func.isRequired,
|
|
142
107
|
focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
|
|
143
|
-
/**
|
|
144
|
-
* Used to determine the label displayed for a given value option.
|
|
145
|
-
* @param {ValueOptions} value The current value option.
|
|
146
|
-
* @returns {string} The text to be displayed.
|
|
147
|
-
*/
|
|
148
|
-
getOptionLabel: PropTypes.func,
|
|
149
|
-
/**
|
|
150
|
-
* Used to determine the value used for a value option.
|
|
151
|
-
* @param {ValueOptions} value The current value option.
|
|
152
|
-
* @returns {string} The value to be used.
|
|
153
|
-
*/
|
|
154
|
-
getOptionValue: PropTypes.func,
|
|
155
108
|
item: PropTypes.shape({
|
|
156
109
|
field: PropTypes.string.isRequired,
|
|
157
110
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|