@mui/x-data-grid 6.0.3 → 6.1.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 +119 -0
- package/components/GridAutoSizer.js +3 -0
- package/components/GridPagination.d.ts +6 -6
- package/components/GridRow.js +4 -2
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +37 -16
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/components/menu/columnMenu/GridColumnMenu.d.ts +5 -5
- package/components/menu/columnMenu/GridColumnMenu.js +30 -30
- package/components/menu/columnMenu/GridColumnMenuProps.d.ts +1 -1
- 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/GridFilterPanel.js +1 -1
- package/components/reexportable.d.ts +1 -1
- package/components/reexportable.js +1 -1
- 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/columnMenu/columnMenuInterfaces.d.ts +11 -11
- package/hooks/features/columnMenu/{useGridColumnMenuComponents.d.ts → useGridColumnMenuSlots.d.ts} +4 -4
- package/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +21 -26
- package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
- package/hooks/features/columns/useGridColumns.js +1 -1
- 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 +6 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +10 -2
- package/legacy/components/GridAutoSizer.js +3 -0
- package/legacy/components/GridRow.js +5 -2
- 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/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/legacy/components/menu/columnMenu/GridColumnMenu.js +32 -32
- package/legacy/components/panel/GridColumnsPanel.js +19 -6
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/legacy/components/reexportable.js +1 -1
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +25 -30
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/columns/useGridColumns.js +1 -1
- 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 +6 -1
- package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +7 -7
- package/legacy/index.js +10 -2
- package/legacy/locales/coreLocales.js +0 -1
- package/legacy/locales/daDK.js +16 -21
- package/legacy/locales/esES.js +1 -1
- package/legacy/locales/huHU.js +15 -20
- package/legacy/locales/jaJP.js +1 -1
- package/legacy/locales/nbNO.js +10 -12
- package/legacy/locales/nlNL.js +3 -3
- package/legacy/locales/ptBR.js +7 -9
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/svSE.js +2 -2
- package/legacy/models/gridColumnGrouping.js +4 -0
- package/legacy/models/params/gridRowParams.js +8 -0
- package/legacy/utils/createSelector.js +14 -22
- package/locales/coreLocales.js +0 -1
- package/locales/daDK.js +16 -21
- package/locales/esES.js +1 -1
- package/locales/huHU.js +15 -20
- package/locales/jaJP.js +1 -1
- package/locales/nbNO.js +10 -12
- package/locales/nlNL.js +3 -3
- package/locales/ptBR.js +7 -9
- package/locales/ruRU.js +1 -1
- package/locales/svSE.js +2 -2
- 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 +4 -2
- package/modern/components/cell/GridEditDateCell.js +37 -16
- package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/modern/components/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/modern/components/menu/columnMenu/GridColumnMenu.js +30 -30
- package/modern/components/panel/GridColumnsPanel.js +18 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/reexportable.js +1 -1
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +21 -26
- package/modern/hooks/features/columns/useGridColumns.js +1 -1
- 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 +6 -1
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/modern/index.js +10 -2
- package/modern/locales/coreLocales.js +0 -1
- package/modern/locales/daDK.js +16 -21
- package/modern/locales/esES.js +1 -1
- package/modern/locales/huHU.js +15 -20
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/nbNO.js +10 -12
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/ptBR.js +7 -9
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/svSE.js +2 -2
- package/modern/models/gridColumnGrouping.js +4 -0
- package/modern/models/params/gridRowParams.js +8 -0
- package/modern/utils/createSelector.js +12 -22
- package/node/components/GridAutoSizer.js +3 -1
- package/node/components/GridRow.js +4 -2
- 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/columnHeaders/GridColumnHeaderTitle.js +5 -5
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -2
- package/node/components/menu/columnMenu/GridColumnMenu.js +33 -33
- package/node/components/panel/GridColumnsPanel.js +18 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/node/components/reexportable.js +4 -4
- package/node/hooks/core/useGridApiInitialization.js +3 -3
- package/node/hooks/features/columnMenu/{useGridColumnMenuComponents.js → useGridColumnMenuSlots.js} +22 -27
- package/node/hooks/features/columns/useGridColumns.js +1 -1
- 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 +6 -1
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/node/index.js +7 -7
- package/node/locales/daDK.js +16 -21
- package/node/locales/esES.js +1 -1
- package/node/locales/huHU.js +15 -20
- package/node/locales/jaJP.js +1 -1
- package/node/locales/nbNO.js +10 -12
- package/node/locales/nlNL.js +3 -3
- package/node/locales/ptBR.js +7 -9
- package/node/locales/ruRU.js +1 -1
- package/node/locales/svSE.js +2 -2
- 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/package.json +1 -1
- package/utils/createSelector.d.ts +4 -4
- package/utils/createSelector.js +14 -22
|
@@ -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
|
});
|
|
@@ -45,16 +45,15 @@ var ColumnHeaderInnerTitle = /*#__PURE__*/React.forwardRef(function ColumnHeader
|
|
|
45
45
|
function GridColumnHeaderTitle(props) {
|
|
46
46
|
var _rootProps$slotProps;
|
|
47
47
|
var label = props.label,
|
|
48
|
-
description = props.description
|
|
49
|
-
columnWidth = props.columnWidth;
|
|
48
|
+
description = props.description;
|
|
50
49
|
var rootProps = useGridRootProps();
|
|
51
50
|
var titleRef = React.useRef(null);
|
|
52
51
|
var _React$useState = React.useState(''),
|
|
53
52
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
54
53
|
tooltip = _React$useState2[0],
|
|
55
54
|
setTooltip = _React$useState2[1];
|
|
56
|
-
React.
|
|
57
|
-
if (!description && titleRef && titleRef.current) {
|
|
55
|
+
var handleMouseOver = React.useCallback(function () {
|
|
56
|
+
if (!description && titleRef != null && titleRef.current) {
|
|
58
57
|
var isOver = isOverflown(titleRef.current);
|
|
59
58
|
if (isOver) {
|
|
60
59
|
setTooltip(label);
|
|
@@ -62,11 +61,12 @@ function GridColumnHeaderTitle(props) {
|
|
|
62
61
|
setTooltip('');
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
}, [
|
|
64
|
+
}, [description, label]);
|
|
66
65
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
|
|
67
66
|
title: description || tooltip
|
|
68
67
|
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseTooltip, {
|
|
69
68
|
children: /*#__PURE__*/_jsx(ColumnHeaderInnerTitle, {
|
|
69
|
+
onMouseOver: handleMouseOver,
|
|
70
70
|
ref: titleRef,
|
|
71
71
|
children: label
|
|
72
72
|
})
|
|
@@ -19,8 +19,10 @@ function GridColumnHeaderMenu(_ref) {
|
|
|
19
19
|
var hideMenu = React.useCallback(function (event) {
|
|
20
20
|
// Prevent triggering the sorting
|
|
21
21
|
event.stopPropagation();
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (!(target != null && target.contains(event.target))) {
|
|
23
|
+
apiRef.current.hideColumnMenu();
|
|
24
|
+
}
|
|
25
|
+
}, [apiRef, target]);
|
|
24
26
|
if (!target) {
|
|
25
27
|
return null;
|
|
26
28
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["
|
|
4
|
+
var _excluded = ["defaultSlots", "defaultSlotProps", "slots", "slotProps"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import {
|
|
7
|
+
import { useGridColumnMenuSlots } from '../../../hooks/features/columnMenu/useGridColumnMenuSlots';
|
|
8
8
|
import { GridColumnMenuContainer } from './GridColumnMenuContainer';
|
|
9
9
|
import { GridColumnMenuColumnsItem } from './menuItems/GridColumnMenuColumnsItem';
|
|
10
10
|
import { GridColumnMenuFilterItem } from './menuItems/GridColumnMenuFilterItem';
|
|
11
11
|
import { GridColumnMenuSortItem } from './menuItems/GridColumnMenuSortItem';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
export var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export var GRID_COLUMN_MENU_SLOTS = {
|
|
14
|
+
columnMenuSortItem: GridColumnMenuSortItem,
|
|
15
|
+
columnMenuFilterItem: GridColumnMenuFilterItem,
|
|
16
|
+
columnMenuColumnsItem: GridColumnMenuColumnsItem
|
|
17
17
|
};
|
|
18
|
-
export var
|
|
18
|
+
export var GRID_COLUMN_MENU_SLOT_PROPS = {
|
|
19
19
|
columnMenuSortItem: {
|
|
20
20
|
displayOrder: 10
|
|
21
21
|
},
|
|
@@ -27,33 +27,33 @@ export var GRID_COLUMN_MENU_COMPONENTS_PROPS = {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
var GridGenericColumnMenu = /*#__PURE__*/React.forwardRef(function GridGenericColumnMenu(props, ref) {
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
var defaultSlots = props.defaultSlots,
|
|
31
|
+
defaultSlotProps = props.defaultSlotProps,
|
|
32
|
+
slots = props.slots,
|
|
33
|
+
slotProps = props.slotProps,
|
|
34
34
|
other = _objectWithoutProperties(props, _excluded);
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
var orderedSlots = useGridColumnMenuSlots(_extends({}, other, {
|
|
36
|
+
defaultSlots: defaultSlots,
|
|
37
|
+
defaultSlotProps: defaultSlotProps,
|
|
38
|
+
slots: slots,
|
|
39
|
+
slotProps: slotProps
|
|
40
40
|
}));
|
|
41
41
|
return /*#__PURE__*/_jsx(GridColumnMenuContainer, _extends({
|
|
42
42
|
ref: ref
|
|
43
43
|
}, other, {
|
|
44
|
-
children:
|
|
44
|
+
children: orderedSlots.map(function (_ref, index) {
|
|
45
45
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
46
46
|
Component = _ref2[0],
|
|
47
|
-
|
|
48
|
-
return /*#__PURE__*/_jsx(Component, _extends({},
|
|
47
|
+
otherProps = _ref2[1];
|
|
48
|
+
return /*#__PURE__*/_jsx(Component, _extends({}, otherProps), index);
|
|
49
49
|
})
|
|
50
50
|
}));
|
|
51
51
|
});
|
|
52
52
|
var GridColumnMenu = /*#__PURE__*/React.forwardRef(function GridColumnMenu(props, ref) {
|
|
53
53
|
return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({}, props, {
|
|
54
54
|
ref: ref,
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
defaultSlots: GRID_COLUMN_MENU_SLOTS,
|
|
56
|
+
defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS
|
|
57
57
|
}));
|
|
58
58
|
});
|
|
59
59
|
process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
|
|
@@ -62,20 +62,20 @@ process.env.NODE_ENV !== "production" ? GridColumnMenu.propTypes = {
|
|
|
62
62
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
63
63
|
// ----------------------------------------------------------------------
|
|
64
64
|
colDef: PropTypes.object.isRequired,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*/
|
|
70
|
-
components: PropTypes.object,
|
|
65
|
+
hideMenu: PropTypes.func.isRequired,
|
|
66
|
+
id: PropTypes.string,
|
|
67
|
+
labelledby: PropTypes.string,
|
|
68
|
+
open: PropTypes.bool.isRequired,
|
|
71
69
|
/**
|
|
72
70
|
* Could be used to pass new props or override props specific to a column menu component
|
|
73
71
|
* e.g. `displayOrder`
|
|
74
72
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
slotProps: PropTypes.object,
|
|
74
|
+
/**
|
|
75
|
+
* `slots` could be used to add new and (or) override default column menu items
|
|
76
|
+
* If you register a nee component you must pass it's `displayOrder` in `slotProps`
|
|
77
|
+
* or it will be placed in the end of the list
|
|
78
|
+
*/
|
|
79
|
+
slots: PropTypes.object
|
|
80
80
|
} : void 0;
|
|
81
81
|
export { GridColumnMenu, GridGenericColumnMenu };
|
|
@@ -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'])
|
|
@@ -156,7 +156,7 @@ var GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(pro
|
|
|
156
156
|
columnsSort: columnsSort
|
|
157
157
|
}, filterFormProps), item.id == null ? index : item.id);
|
|
158
158
|
})
|
|
159
|
-
}), !rootProps.disableMultipleColumnsFiltering && !disableAddFilterButton &&
|
|
159
|
+
}), !rootProps.disableMultipleColumnsFiltering && !(disableAddFilterButton && disableRemoveAllButton) ? /*#__PURE__*/_jsxs(GridPanelFooter, {
|
|
160
160
|
children: [!disableAddFilterButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
|
|
161
161
|
onClick: addNewFilter,
|
|
162
162
|
startIcon: /*#__PURE__*/_jsx(rootProps.slots.filterPanelAddIcon, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GridColumnMenu,
|
|
1
|
+
export { GridColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } from './menu/columnMenu/GridColumnMenu';
|
|
@@ -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]);
|