@mui/x-data-grid 6.0.4 → 6.2.0
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 +110 -0
- package/components/GridAutoSizer.js +3 -0
- package/components/GridPagination.d.ts +6 -6
- package/components/GridRow.js +3 -1
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +37 -16
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/components/panel/GridColumnsPanel.d.ts +8 -0
- package/components/panel/GridColumnsPanel.js +18 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
- package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.js +3 -3
- package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -1
- package/hooks/features/editing/useGridEditing.js +1 -3
- package/hooks/features/editing/useGridRowEditing.js +5 -1
- package/hooks/features/filter/gridFilterState.js +6 -1
- package/hooks/features/filter/useGridFilter.js +5 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
- package/index.js +9 -1
- package/legacy/components/GridAutoSizer.js +3 -0
- package/legacy/components/GridRow.js +4 -1
- package/legacy/components/cell/GridEditBooleanCell.js +19 -21
- package/legacy/components/cell/GridEditDateCell.js +69 -39
- package/legacy/components/cell/GridEditInputCell.js +25 -27
- package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
- package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/legacy/components/panel/GridColumnsPanel.js +19 -6
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
- package/legacy/hooks/features/editing/useGridEditing.js +17 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
- package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
- package/legacy/hooks/features/filter/gridFilterState.js +6 -1
- package/legacy/hooks/features/filter/useGridFilter.js +5 -0
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
- package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
- package/legacy/index.js +9 -1
- package/legacy/locales/coreLocales.js +0 -1
- package/legacy/locales/frFR.js +7 -9
- package/legacy/locales/huHU.js +15 -20
- package/legacy/locales/jaJP.js +1 -1
- package/legacy/locales/nlNL.js +3 -3
- package/legacy/locales/ptBR.js +7 -9
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/urPK.js +6 -6
- package/legacy/models/gridColumnGrouping.js +4 -0
- package/legacy/models/params/gridRowParams.js +8 -0
- package/legacy/utils/createSelector.js +14 -22
- package/legacy/utils/utils.js +1 -1
- package/locales/coreLocales.js +0 -1
- package/locales/frFR.js +7 -9
- package/locales/huHU.js +15 -20
- package/locales/jaJP.js +1 -1
- package/locales/nlNL.js +3 -3
- package/locales/ptBR.js +7 -9
- package/locales/ruRU.js +1 -1
- package/locales/urPK.js +6 -6
- package/models/api/gridCoreApi.d.ts +3 -1
- package/models/api/gridEditingApi.d.ts +4 -0
- package/models/gridColumnGrouping.js +4 -0
- package/models/params/gridRowParams.js +8 -0
- package/modern/components/GridAutoSizer.js +3 -0
- package/modern/components/GridRow.js +3 -1
- package/modern/components/cell/GridEditDateCell.js +37 -16
- package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/modern/components/panel/GridColumnsPanel.js +18 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
- package/modern/hooks/features/editing/useGridEditing.js +1 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
- package/modern/hooks/features/filter/gridFilterState.js +6 -1
- package/modern/hooks/features/filter/useGridFilter.js +5 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/modern/index.js +9 -1
- package/modern/locales/coreLocales.js +0 -1
- package/modern/locales/frFR.js +7 -9
- package/modern/locales/huHU.js +15 -20
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/ptBR.js +7 -9
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/urPK.js +6 -6
- package/modern/models/gridColumnGrouping.js +4 -0
- package/modern/models/params/gridRowParams.js +8 -0
- package/modern/utils/createSelector.js +12 -22
- package/modern/utils/utils.js +1 -1
- package/node/components/GridAutoSizer.js +3 -1
- package/node/components/GridRow.js +3 -1
- package/node/components/cell/GridCell.js +1 -0
- package/node/components/cell/GridEditDateCell.js +37 -16
- package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/node/components/panel/GridColumnsPanel.js +18 -6
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
- package/node/hooks/core/useGridApiInitialization.js +3 -3
- package/node/hooks/features/editing/useGridCellEditing.js +5 -1
- package/node/hooks/features/editing/useGridEditing.js +1 -3
- package/node/hooks/features/editing/useGridRowEditing.js +5 -1
- package/node/hooks/features/filter/gridFilterState.js +5 -0
- package/node/hooks/features/filter/useGridFilter.js +5 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
- package/node/index.js +1 -1
- package/node/locales/frFR.js +7 -9
- package/node/locales/huHU.js +15 -20
- package/node/locales/jaJP.js +1 -1
- package/node/locales/nlNL.js +3 -3
- package/node/locales/ptBR.js +7 -9
- package/node/locales/ruRU.js +1 -1
- package/node/locales/urPK.js +6 -6
- package/node/models/gridColumnGrouping.js +4 -0
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/models/params/gridRowParams.js +9 -0
- package/node/utils/createSelector.js +12 -22
- package/node/utils/utils.js +1 -1
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -4
- package/utils/createSelector.js +14 -22
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +1 -1
|
@@ -74,54 +74,66 @@ function GridEditDateCell(props) {
|
|
|
74
74
|
classes: rootProps.classes
|
|
75
75
|
};
|
|
76
76
|
var classes = useUtilityClasses(ownerState);
|
|
77
|
+
var hasUpdatedEditValueOnMount = React.useRef(false);
|
|
78
|
+
var parseValueToDate = React.useCallback(function (value) {
|
|
79
|
+
if (value === '') {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
var _value$split = value.split('T'),
|
|
83
|
+
_value$split2 = _slicedToArray(_value$split, 2),
|
|
84
|
+
date = _value$split2[0],
|
|
85
|
+
time = _value$split2[1];
|
|
86
|
+
var _date$split = date.split('-'),
|
|
87
|
+
_date$split2 = _slicedToArray(_date$split, 3),
|
|
88
|
+
year = _date$split2[0],
|
|
89
|
+
month = _date$split2[1],
|
|
90
|
+
day = _date$split2[2];
|
|
91
|
+
var parsedDate = new Date();
|
|
92
|
+
parsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
93
|
+
parsedDate.setHours(0, 0, 0, 0);
|
|
94
|
+
if (time) {
|
|
95
|
+
var _time$split = time.split(':'),
|
|
96
|
+
_time$split2 = _slicedToArray(_time$split, 2),
|
|
97
|
+
hours = _time$split2[0],
|
|
98
|
+
minutes = _time$split2[1];
|
|
99
|
+
parsedDate.setHours(Number(hours), Number(minutes), 0, 0);
|
|
100
|
+
}
|
|
101
|
+
return parsedDate;
|
|
102
|
+
}, []);
|
|
77
103
|
var handleChange = React.useCallback( /*#__PURE__*/function () {
|
|
78
104
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
79
|
-
var newFormattedDate, newParsedDate
|
|
105
|
+
var newFormattedDate, newParsedDate;
|
|
80
106
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
81
|
-
while (1) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
newParsedDate = null;
|
|
87
|
-
} else {
|
|
88
|
-
_newFormattedDate$spl = newFormattedDate.split('T'), _newFormattedDate$spl2 = _slicedToArray(_newFormattedDate$spl, 2), date = _newFormattedDate$spl2[0], time = _newFormattedDate$spl2[1];
|
|
89
|
-
_date$split = date.split('-'), _date$split2 = _slicedToArray(_date$split, 3), year = _date$split2[0], month = _date$split2[1], day = _date$split2[2];
|
|
90
|
-
newParsedDate = new Date();
|
|
91
|
-
newParsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
92
|
-
newParsedDate.setHours(0, 0, 0, 0);
|
|
93
|
-
if (time) {
|
|
94
|
-
_time$split = time.split(':'), _time$split2 = _slicedToArray(_time$split, 2), hours = _time$split2[0], minutes = _time$split2[1];
|
|
95
|
-
newParsedDate.setHours(Number(hours), Number(minutes), 0, 0);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (!onValueChange) {
|
|
99
|
-
_context.next = 5;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
107
|
+
while (1) switch (_context.prev = _context.next) {
|
|
108
|
+
case 0:
|
|
109
|
+
newFormattedDate = event.target.value;
|
|
110
|
+
newParsedDate = parseValueToDate(newFormattedDate);
|
|
111
|
+
if (!onValueChange) {
|
|
102
112
|
_context.next = 5;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
_context.next = 5;
|
|
116
|
+
return onValueChange(event, newParsedDate);
|
|
117
|
+
case 5:
|
|
118
|
+
setValueState({
|
|
119
|
+
parsed: newParsedDate,
|
|
120
|
+
formatted: newFormattedDate
|
|
121
|
+
});
|
|
122
|
+
apiRef.current.setEditCellValue({
|
|
123
|
+
id: id,
|
|
124
|
+
field: field,
|
|
125
|
+
value: newParsedDate
|
|
126
|
+
}, event);
|
|
127
|
+
case 7:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context.stop();
|
|
118
130
|
}
|
|
119
131
|
}, _callee);
|
|
120
132
|
}));
|
|
121
133
|
return function (_x) {
|
|
122
134
|
return _ref.apply(this, arguments);
|
|
123
135
|
};
|
|
124
|
-
}(), [apiRef, field, id, onValueChange]);
|
|
136
|
+
}(), [apiRef, field, id, onValueChange, parseValueToDate]);
|
|
125
137
|
React.useEffect(function () {
|
|
126
138
|
setValueState(function (state) {
|
|
127
139
|
var _valueTransformed$par, _state$parsed;
|
|
@@ -136,8 +148,26 @@ function GridEditDateCell(props) {
|
|
|
136
148
|
inputRef.current.focus();
|
|
137
149
|
}
|
|
138
150
|
}, [hasFocus]);
|
|
151
|
+
var meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
152
|
+
var handleInputRef = function handleInputRef(el) {
|
|
153
|
+
inputRef.current = el;
|
|
154
|
+
if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
155
|
+
var inputValue = inputRef.current.value;
|
|
156
|
+
var parsedDate = parseValueToDate(inputValue);
|
|
157
|
+
setValueState({
|
|
158
|
+
parsed: parsedDate,
|
|
159
|
+
formatted: inputValue
|
|
160
|
+
});
|
|
161
|
+
apiRef.current.setEditCellValue({
|
|
162
|
+
id: id,
|
|
163
|
+
field: field,
|
|
164
|
+
value: parsedDate
|
|
165
|
+
});
|
|
166
|
+
hasUpdatedEditValueOnMount.current = true;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
139
169
|
return /*#__PURE__*/_jsx(StyledInputBase, _extends({
|
|
140
|
-
inputRef:
|
|
170
|
+
inputRef: handleInputRef,
|
|
141
171
|
fullWidth: true,
|
|
142
172
|
className: classes.root,
|
|
143
173
|
type: isDateTime ? 'datetime-local' : 'date',
|
|
@@ -67,34 +67,32 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
67
67
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
68
68
|
var newValue, column, parsedValue;
|
|
69
69
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
70
|
-
while (1) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!onValueChange) {
|
|
75
|
-
_context.next = 4;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
70
|
+
while (1) switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
newValue = event.target.value;
|
|
73
|
+
if (!onValueChange) {
|
|
78
74
|
_context.next = 4;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
apiRef.current.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
_context.next = 4;
|
|
78
|
+
return onValueChange(event, newValue);
|
|
79
|
+
case 4:
|
|
80
|
+
column = apiRef.current.getColumn(field);
|
|
81
|
+
parsedValue = newValue;
|
|
82
|
+
if (column.valueParser) {
|
|
83
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
84
|
+
}
|
|
85
|
+
setValueState(parsedValue);
|
|
86
|
+
apiRef.current.setEditCellValue({
|
|
87
|
+
id: id,
|
|
88
|
+
field: field,
|
|
89
|
+
value: parsedValue,
|
|
90
|
+
debounceMs: debounceMs,
|
|
91
|
+
unstable_skipValueParser: true
|
|
92
|
+
}, event);
|
|
93
|
+
case 9:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context.stop();
|
|
98
96
|
}
|
|
99
97
|
}, _callee);
|
|
100
98
|
}));
|
|
@@ -83,35 +83,33 @@ function GridEditSingleSelectCell(props) {
|
|
|
83
83
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
84
84
|
var target, formattedTargetValue;
|
|
85
85
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
86
|
-
while (1) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!onValueChange) {
|
|
99
|
-
_context.next = 8;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
86
|
+
while (1) switch (_context.prev = _context.next) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (!(!isSingleSelectColDef(colDef) || !valueOptions)) {
|
|
89
|
+
_context.next = 2;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
return _context.abrupt("return");
|
|
93
|
+
case 2:
|
|
94
|
+
setOpen(false);
|
|
95
|
+
target = event.target; // NativeSelect casts the value to a string.
|
|
96
|
+
formattedTargetValue = getValueFromValueOptions(target.value, valueOptions, getOptionValue);
|
|
97
|
+
if (!onValueChange) {
|
|
102
98
|
_context.next = 8;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
_context.next = 8;
|
|
102
|
+
return onValueChange(event, formattedTargetValue);
|
|
103
|
+
case 8:
|
|
104
|
+
_context.next = 10;
|
|
105
|
+
return apiRef.current.setEditCellValue({
|
|
106
|
+
id: id,
|
|
107
|
+
field: field,
|
|
108
|
+
value: formattedTargetValue
|
|
109
|
+
}, event);
|
|
110
|
+
case 10:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context.stop();
|
|
115
113
|
}
|
|
116
114
|
}, _callee);
|
|
117
115
|
}));
|
|
@@ -15,7 +15,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
15
15
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
16
16
|
};
|
|
17
17
|
export var ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(function (props) {
|
|
18
|
-
var _rootProps$slotProps;
|
|
18
|
+
var _rootProps$slotProps, _rootProps$slotProps2;
|
|
19
19
|
var colDef = props.colDef,
|
|
20
20
|
open = props.open,
|
|
21
21
|
columnMenuId = props.columnMenuId,
|
|
@@ -34,22 +34,26 @@ export var ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(function (props) {
|
|
|
34
34
|
}, [apiRef, colDef.field]);
|
|
35
35
|
return /*#__PURE__*/_jsx("div", {
|
|
36
36
|
className: classes.root,
|
|
37
|
-
children: /*#__PURE__*/_jsx(rootProps.slots.
|
|
38
|
-
ref: iconButtonRef,
|
|
39
|
-
tabIndex: -1,
|
|
40
|
-
className: classes.button,
|
|
41
|
-
"aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
|
|
37
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
|
|
42
38
|
title: apiRef.current.getLocaleText('columnMenuLabel'),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
enterDelay: 1000
|
|
40
|
+
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseTooltip, {
|
|
41
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
42
|
+
ref: iconButtonRef,
|
|
43
|
+
tabIndex: -1,
|
|
44
|
+
className: classes.button,
|
|
45
|
+
"aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
|
|
46
|
+
size: "small",
|
|
47
|
+
onClick: handleMenuIconClick,
|
|
48
|
+
"aria-expanded": open ? 'true' : undefined,
|
|
49
|
+
"aria-haspopup": "true",
|
|
50
|
+
"aria-controls": columnMenuId,
|
|
51
|
+
id: columnMenuButtonId
|
|
52
|
+
}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseIconButton, {
|
|
53
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
|
|
54
|
+
fontSize: "small"
|
|
55
|
+
})
|
|
56
|
+
}))
|
|
53
57
|
}))
|
|
54
58
|
});
|
|
55
59
|
});
|
|
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
var _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton"];
|
|
6
|
+
var _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
@@ -84,6 +84,7 @@ function GridColumnsPanel(props) {
|
|
|
84
84
|
disableHideAllButton = _props$disableHideAll === void 0 ? false : _props$disableHideAll,
|
|
85
85
|
_props$disableShowAll = props.disableShowAllButton,
|
|
86
86
|
disableShowAllButton = _props$disableShowAll === void 0 ? false : _props$disableShowAll,
|
|
87
|
+
getTogglableColumns = props.getTogglableColumns,
|
|
87
88
|
other = _objectWithoutProperties(props, _excluded);
|
|
88
89
|
var sortedColumns = React.useMemo(function () {
|
|
89
90
|
switch (sort) {
|
|
@@ -123,14 +124,18 @@ function GridColumnsPanel(props) {
|
|
|
123
124
|
setSearchValue(event.target.value);
|
|
124
125
|
}, []);
|
|
125
126
|
var currentColumns = React.useMemo(function () {
|
|
127
|
+
var togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
128
|
+
var togglableSortedColumns = togglableColumns ? sortedColumns.filter(function (_ref4) {
|
|
129
|
+
var field = _ref4.field;
|
|
130
|
+
return togglableColumns.includes(field);
|
|
131
|
+
}) : sortedColumns;
|
|
126
132
|
if (!searchValue) {
|
|
127
|
-
return
|
|
133
|
+
return togglableSortedColumns;
|
|
128
134
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return searchPredicate(column, searchValueToCheck);
|
|
135
|
+
return togglableSortedColumns.filter(function (column) {
|
|
136
|
+
return searchPredicate(column, searchValue.toLowerCase());
|
|
132
137
|
});
|
|
133
|
-
}, [sortedColumns, searchValue, searchPredicate]);
|
|
138
|
+
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
134
139
|
var firstSwitchRef = React.useRef(null);
|
|
135
140
|
React.useEffect(function () {
|
|
136
141
|
if (autoFocusSearchField) {
|
|
@@ -215,6 +220,14 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
215
220
|
autoFocusSearchField: PropTypes.bool,
|
|
216
221
|
disableHideAllButton: PropTypes.bool,
|
|
217
222
|
disableShowAllButton: PropTypes.bool,
|
|
223
|
+
/**
|
|
224
|
+
* Returns the list of togglable columns.
|
|
225
|
+
* If used, only those columns will be displayed in the panel
|
|
226
|
+
* which are passed as the return value of the function.
|
|
227
|
+
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
228
|
+
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
229
|
+
*/
|
|
230
|
+
getTogglableColumns: PropTypes.func,
|
|
218
231
|
searchPredicate: PropTypes.func,
|
|
219
232
|
slotProps: PropTypes.object,
|
|
220
233
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
@@ -3,11 +3,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["item", "applyValue", "apiRef", "focusElementRef"];
|
|
5
5
|
import * as React from 'react';
|
|
6
|
+
import { unstable_useId as useId } from '@mui/utils';
|
|
6
7
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
export function GridFilterInputBoolean(props) {
|
|
10
|
-
var _rootProps$slotProps, _baseSelectProps$nati, _rootProps$slotProps2, _rootProps$slotProps3
|
|
11
|
+
var _rootProps$slotProps, _baseSelectProps$nati, _rootProps$slotProps2, _rootProps$slotProps3;
|
|
11
12
|
var item = props.item,
|
|
12
13
|
applyValue = props.applyValue,
|
|
13
14
|
apiRef = props.apiRef,
|
|
@@ -18,6 +19,8 @@ export function GridFilterInputBoolean(props) {
|
|
|
18
19
|
filterValueState = _React$useState2[0],
|
|
19
20
|
setFilterValueState = _React$useState2[1];
|
|
20
21
|
var rootProps = useGridRootProps();
|
|
22
|
+
var labelId = useId();
|
|
23
|
+
var selectId = useId();
|
|
21
24
|
var baseSelectProps = ((_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseSelect) || {};
|
|
22
25
|
var isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : true;
|
|
23
26
|
var baseSelectOptionProps = ((_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseSelectOption) || {};
|
|
@@ -31,34 +34,39 @@ export function GridFilterInputBoolean(props) {
|
|
|
31
34
|
React.useEffect(function () {
|
|
32
35
|
setFilterValueState(item.value || '');
|
|
33
36
|
}, [item.value]);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
var label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
38
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
39
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseInputLabel, {
|
|
40
|
+
id: labelId,
|
|
41
|
+
shrink: true,
|
|
42
|
+
variant: "standard",
|
|
43
|
+
children: label
|
|
44
|
+
})), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
|
|
45
|
+
labelId: labelId,
|
|
46
|
+
id: selectId,
|
|
47
|
+
label: label,
|
|
48
|
+
value: filterValueState,
|
|
49
|
+
onChange: onFilterChange,
|
|
50
|
+
variant: "standard",
|
|
42
51
|
native: isSelectNative,
|
|
43
|
-
displayEmpty: true
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
52
|
+
displayEmpty: true,
|
|
53
|
+
inputProps: {
|
|
54
|
+
ref: focusElementRef
|
|
55
|
+
}
|
|
56
|
+
}, others, baseSelectProps, {
|
|
57
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
|
|
58
|
+
native: isSelectNative,
|
|
59
|
+
value: "",
|
|
60
|
+
children: apiRef.current.getLocaleText('filterValueAny')
|
|
61
|
+
})), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
|
|
62
|
+
native: isSelectNative,
|
|
63
|
+
value: "true",
|
|
64
|
+
children: apiRef.current.getLocaleText('filterValueTrue')
|
|
65
|
+
})), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
|
|
66
|
+
native: isSelectNative,
|
|
67
|
+
value: "false",
|
|
68
|
+
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
69
|
+
}))]
|
|
62
70
|
}))]
|
|
63
|
-
})
|
|
71
|
+
});
|
|
64
72
|
}
|
|
@@ -10,6 +10,7 @@ import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
|
10
10
|
import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
|
|
11
11
|
import { createElement as _createElement } from "react";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
var renderSingleSelectOptions = function renderSingleSelectOptions(_ref) {
|
|
14
15
|
var _ref$column = _ref.column,
|
|
15
16
|
valueOptions = _ref$column.valueOptions,
|
|
@@ -33,7 +34,7 @@ var renderSingleSelectOptions = function renderSingleSelectOptions(_ref) {
|
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
function GridFilterInputSingleSelect(props) {
|
|
36
|
-
var _item$value, _rootProps$slotProps
|
|
37
|
+
var _item$value, _rootProps$slotProps$, _rootProps$slotProps, _rootProps$slotProps$2, _resolvedColumn, _resolvedColumn2, _rootProps$slotProps2, _rootProps$slotProps3, _rootProps$slotProps4;
|
|
37
38
|
var item = props.item,
|
|
38
39
|
applyValue = props.applyValue,
|
|
39
40
|
type = props.type,
|
|
@@ -47,10 +48,9 @@ function GridFilterInputSingleSelect(props) {
|
|
|
47
48
|
filterValueState = _React$useState2[0],
|
|
48
49
|
setFilterValueState = _React$useState2[1];
|
|
49
50
|
var id = useId();
|
|
51
|
+
var labelId = useId();
|
|
50
52
|
var rootProps = useGridRootProps();
|
|
51
|
-
var
|
|
52
|
-
var isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : true;
|
|
53
|
-
var baseSelectOptionProps = ((_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseSelectOption) || {};
|
|
53
|
+
var isSelectNative = (_rootProps$slotProps$ = (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : (_rootProps$slotProps$2 = _rootProps$slotProps.baseSelect) == null ? void 0 : _rootProps$slotProps$2.native) != null ? _rootProps$slotProps$ : true;
|
|
54
54
|
var resolvedColumn = null;
|
|
55
55
|
if (item.field) {
|
|
56
56
|
var column = apiRef.current.getColumn(item.field);
|
|
@@ -102,33 +102,37 @@ function GridFilterInputSingleSelect(props) {
|
|
|
102
102
|
if (!isSingleSelectColDef(resolvedColumn)) {
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
var label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
106
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
107
|
+
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseInputLabel, {
|
|
108
|
+
id: labelId,
|
|
109
|
+
shrink: true,
|
|
110
|
+
variant: "standard",
|
|
111
|
+
children: label
|
|
112
|
+
})), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
|
|
113
|
+
id: id,
|
|
114
|
+
label: label,
|
|
115
|
+
labelId: labelId,
|
|
116
|
+
value: filterValueState,
|
|
117
|
+
onChange: onFilterChange,
|
|
118
|
+
variant: "standard",
|
|
119
|
+
type: type || 'text',
|
|
120
|
+
inputProps: {
|
|
121
|
+
ref: focusElementRef,
|
|
122
|
+
placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
|
|
123
|
+
},
|
|
120
124
|
native: isSelectNative
|
|
121
|
-
}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
})
|
|
131
|
-
})
|
|
125
|
+
}, others, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
|
|
126
|
+
children: renderSingleSelectOptions({
|
|
127
|
+
column: resolvedColumn,
|
|
128
|
+
OptionComponent: rootProps.slots.baseSelectOption,
|
|
129
|
+
getOptionLabel: getOptionLabel,
|
|
130
|
+
getOptionValue: getOptionValue,
|
|
131
|
+
isSelectNative: isSelectNative,
|
|
132
|
+
baseSelectOptionProps: (_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseSelectOption
|
|
133
|
+
})
|
|
134
|
+
}))]
|
|
135
|
+
});
|
|
132
136
|
}
|
|
133
137
|
process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
|
|
134
138
|
// ----------------------------- Warning --------------------------------
|
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { useGridApiMethod } from '../utils/useGridApiMethod';
|
|
3
3
|
import { GridSignature } from '../utils/useGridApiEventHandler';
|
|
4
4
|
import { EventManager } from '../../utils/EventManager';
|
|
5
|
-
import { unstable_resetCreateSelectorCache } from '../../utils/createSelector';
|
|
6
5
|
var isSyntheticEvent = function isSyntheticEvent(event) {
|
|
7
6
|
return event.isPropagationStopped !== undefined;
|
|
8
7
|
};
|
|
@@ -40,7 +39,9 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
40
39
|
if (!publicApiRef.current) {
|
|
41
40
|
publicApiRef.current = {
|
|
42
41
|
state: {},
|
|
43
|
-
instanceId:
|
|
42
|
+
instanceId: {
|
|
43
|
+
id: globalId
|
|
44
|
+
}
|
|
44
45
|
};
|
|
45
46
|
globalId += 1;
|
|
46
47
|
}
|
|
@@ -86,7 +87,6 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
86
87
|
React.useEffect(function () {
|
|
87
88
|
var api = privateApiRef.current;
|
|
88
89
|
return function () {
|
|
89
|
-
unstable_resetCreateSelectorCache(api.instanceId);
|
|
90
90
|
api.publishEvent('unmount');
|
|
91
91
|
};
|
|
92
92
|
}, [privateApiRef]);
|
|
@@ -183,7 +183,7 @@ export var applyInitialState = function applyInitialState(columnsState, initialS
|
|
|
183
183
|
return !orderedFieldsLookup[field];
|
|
184
184
|
})));
|
|
185
185
|
var newColumnLookup = _extends({}, columnsState.lookup);
|
|
186
|
-
var _loop = function _loop(
|
|
186
|
+
var _loop = function _loop() {
|
|
187
187
|
var field = columnsWithUpdatedDimensions[_i];
|
|
188
188
|
var newColDef = _extends({}, newColumnLookup[field], {
|
|
189
189
|
hasBeenResized: true
|
|
@@ -197,7 +197,7 @@ export var applyInitialState = function applyInitialState(columnsState, initialS
|
|
|
197
197
|
newColumnLookup[field] = newColDef;
|
|
198
198
|
};
|
|
199
199
|
for (var _i = 0; _i < columnsWithUpdatedDimensions.length; _i += 1) {
|
|
200
|
-
_loop(
|
|
200
|
+
_loop();
|
|
201
201
|
}
|
|
202
202
|
var newColumnsState = _extends({}, columnsState, {
|
|
203
203
|
orderedFields: newOrderedFields,
|