@mui/x-data-grid 5.8.0 → 5.9.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 +141 -63
- package/DataGrid/DataGrid.js +1 -1
- package/DataGrid/useDataGridComponent.js +3 -1
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/components/GridRow.d.ts +4 -0
- package/components/GridRow.js +49 -23
- package/components/base/GridOverlays.js +4 -3
- package/components/cell/GridActionsCell.d.ts +5 -1
- package/components/cell/GridActionsCell.js +170 -21
- package/components/cell/GridActionsCellItem.d.ts +66 -4
- package/components/cell/GridActionsCellItem.js +7 -5
- package/components/cell/GridCell.d.ts +1 -0
- package/components/cell/GridCell.js +28 -7
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +22 -13
- package/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/components/columnHeaders/GridColumnHeaders.d.ts +0 -1
- package/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.d.ts +3 -3
- package/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/components/panel/GridPanel.js +1 -0
- package/components/panel/filterPanel/GridFilterForm.js +14 -10
- package/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -15
- package/components/panel/filterPanel/GridFilterInputValue.js +22 -15
- package/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +2 -0
- package/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/constants/gridDetailPanelToggleField.d.ts +1 -0
- package/constants/gridDetailPanelToggleField.js +2 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +32 -15
- package/hooks/core/pipeProcessing/index.d.ts +1 -0
- package/hooks/core/pipeProcessing/index.js +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +8 -3
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +3 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +0 -3
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +19 -1
- package/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/hooks/features/columns/useGridColumnSpanning.d.ts +7 -0
- package/hooks/features/columns/useGridColumnSpanning.js +109 -0
- package/hooks/features/columns/useGridColumns.js +24 -18
- package/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/hooks/features/editRows/useGridRowEditing.new.js +23 -15
- package/hooks/features/filter/useGridFilter.js +14 -9
- package/hooks/features/focus/useGridFocus.js +19 -9
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -7
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -0
- package/hooks/features/rows/gridRowsSelector.js +1 -0
- package/hooks/features/rows/gridRowsState.d.ts +4 -0
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +5 -4
- package/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/hooks/features/scroll/useGridScroll.d.ts +2 -0
- package/hooks/features/scroll/useGridScroll.js +25 -3
- package/hooks/features/selection/useGridSelection.js +3 -2
- package/hooks/features/sorting/useGridSorting.js +10 -10
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +7 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +54 -27
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/legacy/DataGrid/DataGrid.js +1 -1
- package/legacy/DataGrid/useDataGridComponent.js +3 -1
- package/legacy/components/GridRow.js +47 -23
- package/legacy/components/base/GridOverlays.js +4 -3
- package/legacy/components/cell/GridActionsCell.js +188 -27
- package/legacy/components/cell/GridActionsCellItem.js +7 -5
- package/legacy/components/cell/GridCell.js +29 -7
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +33 -24
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/legacy/components/columnHeaders/GridColumnHeaders.js +2 -3
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +21 -3
- package/legacy/components/panel/GridPanel.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterForm.js +14 -10
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -17
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +22 -17
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/legacy/components/virtualization/GridVirtualScroller.js +2 -0
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/legacy/constants/gridDetailPanelToggleField.js +2 -0
- package/legacy/hooks/core/pipeProcessing/index.js +2 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +60 -24
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +89 -10
- package/legacy/hooks/features/columns/gridColumnsUtils.js +79 -22
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +107 -0
- package/legacy/hooks/features/columns/useGridColumns.js +24 -18
- package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -8
- package/legacy/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +32 -24
- package/legacy/hooks/features/filter/useGridFilter.js +14 -9
- package/legacy/hooks/features/focus/useGridFocus.js +19 -9
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -6
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -0
- package/legacy/hooks/features/rows/useGridRows.js +5 -4
- package/legacy/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/legacy/hooks/features/scroll/useGridScroll.js +25 -3
- package/legacy/hooks/features/selection/useGridSelection.js +3 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +5 -7
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +65 -37
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/locales/huHU.js +120 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/models/api/gridColumnSpanning.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -3
- package/legacy/models/gridColumnSpanning.js +1 -0
- package/locales/huHU.d.ts +2 -0
- package/locales/huHU.js +108 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/models/api/gridApiCommon.d.ts +2 -1
- package/models/api/gridColumnSpanning.d.ts +28 -0
- package/models/api/gridColumnSpanning.js +1 -0
- package/models/api/gridEditingApi.d.ts +49 -3
- package/models/colDef/gridColDef.d.ts +5 -0
- package/models/events/gridEventLookup.d.ts +3 -8
- package/models/events/gridEvents.d.ts +9 -14
- package/models/events/gridEvents.js +2 -3
- package/models/gridColumnSpanning.d.ts +12 -0
- package/models/gridColumnSpanning.js +1 -0
- package/models/gridEditRowModel.d.ts +1 -1
- package/models/params/gridCellParams.d.ts +12 -2
- package/models/params/gridRowParams.d.ts +5 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +1 -1
- package/modern/DataGrid/useDataGridComponent.js +3 -1
- package/modern/components/GridRow.js +47 -21
- package/modern/components/base/GridOverlays.js +4 -3
- package/modern/components/cell/GridActionsCell.js +168 -21
- package/modern/components/cell/GridActionsCellItem.js +7 -5
- package/modern/components/cell/GridCell.js +28 -7
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +20 -11
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/modern/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/modern/components/panel/GridPanel.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterForm.js +10 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +11 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +20 -13
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +20 -13
- package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +2 -0
- package/modern/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/modern/constants/gridDetailPanelToggleField.js +2 -0
- package/modern/hooks/core/pipeProcessing/index.js +2 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
- package/modern/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/modern/hooks/features/columns/useGridColumnSpanning.js +107 -0
- package/modern/hooks/features/columns/useGridColumns.js +24 -18
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/modern/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +23 -15
- package/modern/hooks/features/filter/useGridFilter.js +14 -9
- package/modern/hooks/features/focus/useGridFocus.js +19 -9
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +37 -7
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -0
- package/modern/hooks/features/rows/useGridRows.js +5 -4
- package/modern/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/modern/hooks/features/scroll/useGridScroll.js +23 -3
- package/modern/hooks/features/selection/useGridSelection.js +3 -2
- package/modern/hooks/features/sorting/useGridSorting.js +10 -10
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +54 -23
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/locales/huHU.js +108 -0
- package/modern/locales/index.js +1 -0
- package/modern/models/api/gridColumnSpanning.js +1 -0
- package/modern/models/events/gridEvents.js +2 -3
- package/modern/models/gridColumnSpanning.js +1 -0
- package/node/DataGrid/DataGrid.js +1 -1
- package/node/DataGrid/useDataGridComponent.js +4 -1
- package/node/components/GridRow.js +50 -23
- package/node/components/base/GridOverlays.js +3 -2
- package/node/components/cell/GridActionsCell.js +172 -21
- package/node/components/cell/GridActionsCellItem.js +7 -4
- package/node/components/cell/GridCell.js +28 -7
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +23 -13
- package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/node/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/node/components/panel/GridPanel.js +1 -0
- package/node/components/panel/filterPanel/GridFilterForm.js +15 -10
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +14 -8
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +23 -15
- package/node/components/panel/filterPanel/GridFilterInputValue.js +23 -15
- package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +2 -0
- package/node/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/node/constants/gridDetailPanelToggleField.js +9 -0
- package/node/hooks/core/pipeProcessing/index.js +13 -0
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +51 -20
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +42 -0
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +80 -10
- package/node/hooks/features/columns/gridColumnsUtils.js +65 -9
- package/node/hooks/features/columns/useGridColumnSpanning.js +130 -0
- package/node/hooks/features/columns/useGridColumns.js +23 -17
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/node/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/node/hooks/features/editRows/useGridEditing.new.js +6 -2
- package/node/hooks/features/editRows/useGridRowEditing.new.js +21 -14
- package/node/hooks/features/filter/useGridFilter.js +14 -9
- package/node/hooks/features/focus/useGridFocus.js +19 -9
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +40 -7
- package/node/hooks/features/rows/gridRowsSelector.js +3 -1
- package/node/hooks/features/rows/useGridRows.js +5 -4
- package/node/hooks/features/rows/useGridRowsMeta.js +6 -14
- package/node/hooks/features/scroll/useGridScroll.js +26 -2
- package/node/hooks/features/selection/useGridSelection.js +4 -2
- package/node/hooks/features/sorting/useGridSorting.js +10 -10
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +59 -27
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -0
- package/node/locales/huHU.js +118 -0
- package/node/locales/index.js +13 -0
- package/node/models/api/gridColumnSpanning.js +5 -0
- package/node/models/events/gridEvents.js +2 -3
- package/node/models/gridColumnSpanning.js +5 -0
- package/package.json +4 -4
- package/utils/domUtils.d.ts +2 -2
|
@@ -25,7 +25,7 @@ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
|
25
25
|
|
|
26
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
27
|
|
|
28
|
-
const _excluded = ["
|
|
28
|
+
const _excluded = ["className"];
|
|
29
29
|
|
|
30
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
31
|
|
|
@@ -31,7 +31,7 @@ var _gridClasses = require("../../constants/gridClasses");
|
|
|
31
31
|
|
|
32
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
33
|
|
|
34
|
-
const _excluded = ["field", "id", "value", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "getValue"];
|
|
34
|
+
const _excluded = ["field", "id", "value", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "getValue", "api"];
|
|
35
35
|
|
|
36
36
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
37
|
|
|
@@ -126,6 +126,12 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
126
126
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
127
127
|
// ----------------------------------------------------------------------
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* GridApi that let you manipulate the grid.
|
|
131
|
+
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
|
|
132
|
+
*/
|
|
133
|
+
api: _propTypes.default.any.isRequired,
|
|
134
|
+
|
|
129
135
|
/**
|
|
130
136
|
* The mode of the cell.
|
|
131
137
|
*/
|
|
@@ -141,10 +147,21 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
141
147
|
*/
|
|
142
148
|
field: _propTypes.default.string.isRequired,
|
|
143
149
|
|
|
150
|
+
/**
|
|
151
|
+
* A ref allowing to set imperative focus.
|
|
152
|
+
* It can be passed to the element that should receive focus.
|
|
153
|
+
* @ignore - do not document.
|
|
154
|
+
*/
|
|
155
|
+
focusElementRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
156
|
+
current: _propTypes.default.shape({
|
|
157
|
+
focus: _propTypes.default.func.isRequired
|
|
158
|
+
})
|
|
159
|
+
})]),
|
|
160
|
+
|
|
144
161
|
/**
|
|
145
162
|
* The cell value formatted with the column valueFormatter.
|
|
146
163
|
*/
|
|
147
|
-
formattedValue: _propTypes.default.any
|
|
164
|
+
formattedValue: _propTypes.default.any,
|
|
148
165
|
|
|
149
166
|
/**
|
|
150
167
|
* Get the cell value of a row and field.
|
|
@@ -188,7 +205,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
188
205
|
/**
|
|
189
206
|
* The cell value, but if the column has valueGetter, use getValue.
|
|
190
207
|
*/
|
|
191
|
-
value: _propTypes.default.any
|
|
208
|
+
value: _propTypes.default.any
|
|
192
209
|
} : void 0;
|
|
193
210
|
const GridCellCheckboxRenderer = /*#__PURE__*/React.memo(GridCellCheckboxForwardRef);
|
|
194
211
|
exports.GridCellCheckboxRenderer = GridCellCheckboxRenderer;
|
|
@@ -109,6 +109,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
109
109
|
modifiers: modifiers
|
|
110
110
|
}, other, {
|
|
111
111
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayListener.default, {
|
|
112
|
+
mouseEvent: "onMouseUp",
|
|
112
113
|
onClickAway: handleClickAway,
|
|
113
114
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridPaperRoot, {
|
|
114
115
|
className: classes.paper,
|
|
@@ -17,6 +17,8 @@ var _material = require("@mui/material");
|
|
|
17
17
|
|
|
18
18
|
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
19
19
|
|
|
20
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
21
|
+
|
|
20
22
|
var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
|
|
21
23
|
|
|
22
24
|
var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
|
|
@@ -131,7 +133,7 @@ const getColumnLabel = col => col.headerName || col.field;
|
|
|
131
133
|
const collator = new Intl.Collator();
|
|
132
134
|
|
|
133
135
|
function GridFilterForm(props) {
|
|
134
|
-
var _rootProps$components, _rootProps$components2, _rootProps$components3, _rootProps$components4, _currentColumn$filter2;
|
|
136
|
+
var _rootProps$components, _rootProps$components2, _baseSelectProps$nati, _rootProps$components3, _rootProps$components4, _rootProps$components5, _currentColumn$filter2;
|
|
135
137
|
|
|
136
138
|
const {
|
|
137
139
|
item,
|
|
@@ -166,6 +168,9 @@ function GridFilterForm(props) {
|
|
|
166
168
|
const filterSelectorRef = React.useRef(null);
|
|
167
169
|
const hasLinkOperatorColumn = hasMultipleFilters && linkOperators.length > 0;
|
|
168
170
|
const baseFormControlProps = ((_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.baseFormControl) || {};
|
|
171
|
+
const baseSelectProps = ((_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSelect) || {};
|
|
172
|
+
const isBaseSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : true;
|
|
173
|
+
const OptionComponent = isBaseSelectNative ? 'option' : _MenuItem.default;
|
|
169
174
|
const sortedFilterableColumns = React.useMemo(() => {
|
|
170
175
|
switch (columnsSort) {
|
|
171
176
|
case 'asc':
|
|
@@ -279,9 +284,9 @@ function GridFilterForm(props) {
|
|
|
279
284
|
value: multiFilterOperator,
|
|
280
285
|
onChange: changeLinkOperator,
|
|
281
286
|
disabled: !!disableMultiFilterOperator || linkOperators.length === 1,
|
|
282
|
-
native:
|
|
283
|
-
}, (_rootProps$
|
|
284
|
-
children: linkOperators.map(linkOperator => /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
287
|
+
native: isBaseSelectNative
|
|
288
|
+
}, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.baseSelect, {
|
|
289
|
+
children: linkOperators.map(linkOperator => /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
285
290
|
value: linkOperator.toString(),
|
|
286
291
|
children: apiRef.current.getLocaleText(getLinkOperatorLocaleKey(linkOperator))
|
|
287
292
|
}, linkOperator.toString()))
|
|
@@ -301,9 +306,9 @@ function GridFilterForm(props) {
|
|
|
301
306
|
label: apiRef.current.getLocaleText('filterPanelColumns'),
|
|
302
307
|
value: item.columnField || '',
|
|
303
308
|
onChange: changeColumn,
|
|
304
|
-
native:
|
|
305
|
-
}, (_rootProps$
|
|
306
|
-
children: sortedFilterableColumns.map(col => /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
309
|
+
native: isBaseSelectNative
|
|
310
|
+
}, (_rootProps$components4 = rootProps.componentsProps) == null ? void 0 : _rootProps$components4.baseSelect, {
|
|
311
|
+
children: sortedFilterableColumns.map(col => /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
307
312
|
value: col.field,
|
|
308
313
|
children: getColumnLabel(col)
|
|
309
314
|
}, col.field))
|
|
@@ -323,10 +328,10 @@ function GridFilterForm(props) {
|
|
|
323
328
|
id: operatorSelectId,
|
|
324
329
|
value: item.operatorValue,
|
|
325
330
|
onChange: changeOperator,
|
|
326
|
-
native:
|
|
331
|
+
native: isBaseSelectNative,
|
|
327
332
|
inputRef: filterSelectorRef
|
|
328
|
-
}, (_rootProps$
|
|
329
|
-
children: currentColumn == null ? void 0 : (_currentColumn$filter2 = currentColumn.filterOperators) == null ? void 0 : _currentColumn$filter2.map(operator => /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
333
|
+
}, (_rootProps$components5 = rootProps.componentsProps) == null ? void 0 : _rootProps$components5.baseSelect, {
|
|
334
|
+
children: currentColumn == null ? void 0 : (_currentColumn$filter2 = currentColumn.filterOperators) == null ? void 0 : _currentColumn$filter2.map(operator => /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
330
335
|
value: operator.value,
|
|
331
336
|
children: operator.label || apiRef.current.getLocaleText(`filterOperator${(0, _utils.capitalize)(operator.value)}`)
|
|
332
337
|
}, operator.value))
|
|
@@ -13,6 +13,8 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
13
13
|
|
|
14
14
|
var React = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
17
|
+
|
|
16
18
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
17
19
|
|
|
18
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -24,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
24
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
27
|
|
|
26
28
|
function GridFilterInputBoolean(props) {
|
|
27
|
-
var _rootProps$components;
|
|
29
|
+
var _rootProps$components, _baseSelectProps$nati, _rootProps$components2, _rootProps$components3;
|
|
28
30
|
|
|
29
31
|
const {
|
|
30
32
|
item,
|
|
@@ -35,6 +37,9 @@ function GridFilterInputBoolean(props) {
|
|
|
35
37
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
36
38
|
const [filterValueState, setFilterValueState] = React.useState(item.value || '');
|
|
37
39
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
40
|
+
const baseSelectProps = ((_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.baseSelect) || {};
|
|
41
|
+
const isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : true;
|
|
42
|
+
const OptionComponent = isSelectNative ? 'option' : _MenuItem.default;
|
|
38
43
|
const onFilterChange = React.useCallback(event => {
|
|
39
44
|
const value = event.target.value;
|
|
40
45
|
setFilterValueState(value);
|
|
@@ -51,21 +56,22 @@ function GridFilterInputBoolean(props) {
|
|
|
51
56
|
onChange: onFilterChange,
|
|
52
57
|
variant: "standard",
|
|
53
58
|
select: true,
|
|
54
|
-
SelectProps: {
|
|
55
|
-
native:
|
|
56
|
-
|
|
59
|
+
SelectProps: (0, _extends2.default)({
|
|
60
|
+
native: isSelectNative,
|
|
61
|
+
displayEmpty: true
|
|
62
|
+
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSelect),
|
|
57
63
|
InputLabelProps: {
|
|
58
64
|
shrink: true
|
|
59
65
|
},
|
|
60
66
|
inputRef: focusElementRef
|
|
61
|
-
}, others, (_rootProps$
|
|
62
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
67
|
+
}, others, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.baseTextField, {
|
|
68
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
63
69
|
value: "",
|
|
64
70
|
children: apiRef.current.getLocaleText('filterValueAny')
|
|
65
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
71
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
66
72
|
value: "true",
|
|
67
73
|
children: apiRef.current.getLocaleText('filterValueTrue')
|
|
68
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
74
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
69
75
|
value: "false",
|
|
70
76
|
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
71
77
|
})]
|
|
@@ -17,6 +17,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
17
17
|
|
|
18
18
|
var _utils = require("@mui/material/utils");
|
|
19
19
|
|
|
20
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
21
|
+
|
|
20
22
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
21
23
|
|
|
22
24
|
var _filterPanelUtils = require("./filterPanelUtils");
|
|
@@ -33,25 +35,29 @@ const renderSingleSelectOptions = ({
|
|
|
33
35
|
valueOptions,
|
|
34
36
|
valueFormatter,
|
|
35
37
|
field
|
|
36
|
-
}, api) => {
|
|
38
|
+
}, api, OptionComponent) => {
|
|
37
39
|
const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({
|
|
38
40
|
field
|
|
39
41
|
})] : ['', ...(valueOptions || [])];
|
|
40
|
-
return iterableColumnValues.map(option =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
children: valueFormatter && option !== '' ? valueFormatter({
|
|
42
|
+
return iterableColumnValues.map(option => {
|
|
43
|
+
const isOptionTypeObject = typeof option === 'object';
|
|
44
|
+
const key = isOptionTypeObject ? option.value : option;
|
|
45
|
+
const value = isOptionTypeObject ? option.value : option;
|
|
46
|
+
const formattedValue = valueFormatter && option !== '' ? valueFormatter({
|
|
46
47
|
value: option,
|
|
47
48
|
field,
|
|
48
49
|
api
|
|
49
|
-
}) : option
|
|
50
|
-
|
|
50
|
+
}) : option;
|
|
51
|
+
const content = isOptionTypeObject ? option.label : formattedValue;
|
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
53
|
+
value: value,
|
|
54
|
+
children: content
|
|
55
|
+
}, key);
|
|
56
|
+
});
|
|
51
57
|
};
|
|
52
58
|
|
|
53
59
|
function GridFilterInputSingleSelect(props) {
|
|
54
|
-
var _item$value, _rootProps$components;
|
|
60
|
+
var _item$value, _rootProps$components, _baseSelectProps$nati, _rootProps$components2, _rootProps$components3;
|
|
55
61
|
|
|
56
62
|
const {
|
|
57
63
|
item,
|
|
@@ -64,6 +70,8 @@ function GridFilterInputSingleSelect(props) {
|
|
|
64
70
|
const [filterValueState, setFilterValueState] = React.useState((_item$value = item.value) != null ? _item$value : '');
|
|
65
71
|
const id = (0, _utils.unstable_useId)();
|
|
66
72
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
73
|
+
const baseSelectProps = ((_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.baseSelect) || {};
|
|
74
|
+
const isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : true;
|
|
67
75
|
const currentColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
|
|
68
76
|
const currentValueOptions = React.useMemo(() => {
|
|
69
77
|
return typeof currentColumn.valueOptions === 'function' ? currentColumn.valueOptions({
|
|
@@ -114,11 +122,11 @@ function GridFilterInputSingleSelect(props) {
|
|
|
114
122
|
},
|
|
115
123
|
inputRef: focusElementRef,
|
|
116
124
|
select: true,
|
|
117
|
-
SelectProps: {
|
|
118
|
-
native:
|
|
119
|
-
}
|
|
120
|
-
}, others, (_rootProps$
|
|
121
|
-
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current)
|
|
125
|
+
SelectProps: (0, _extends2.default)({
|
|
126
|
+
native: isSelectNative
|
|
127
|
+
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSelect)
|
|
128
|
+
}, others, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.baseTextField, {
|
|
129
|
+
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current, isSelectNative ? 'option' : _MenuItem.default)
|
|
122
130
|
}));
|
|
123
131
|
}
|
|
124
132
|
|
|
@@ -18,6 +18,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
18
18
|
|
|
19
19
|
var _utils = require("@mui/material/utils");
|
|
20
20
|
|
|
21
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
22
|
+
|
|
21
23
|
var _icons = require("../../icons");
|
|
22
24
|
|
|
23
25
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
@@ -43,28 +45,32 @@ const renderSingleSelectOptions = ({
|
|
|
43
45
|
valueOptions,
|
|
44
46
|
valueFormatter,
|
|
45
47
|
field
|
|
46
|
-
}, api) => {
|
|
48
|
+
}, api, OptionComponent) => {
|
|
47
49
|
const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({
|
|
48
50
|
field
|
|
49
51
|
})] : ['', ...(valueOptions || [])];
|
|
50
|
-
return iterableColumnValues.map(option =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
children: valueFormatter && option !== '' ? valueFormatter({
|
|
52
|
+
return iterableColumnValues.map(option => {
|
|
53
|
+
const isOptionTypeObject = typeof option === 'object';
|
|
54
|
+
const key = isOptionTypeObject ? option.value : option;
|
|
55
|
+
const value = isOptionTypeObject ? option.value : option;
|
|
56
|
+
const formattedValue = valueFormatter && option !== '' ? valueFormatter({
|
|
56
57
|
value: option,
|
|
57
58
|
field,
|
|
58
59
|
api
|
|
59
|
-
}) : option
|
|
60
|
-
|
|
60
|
+
}) : option;
|
|
61
|
+
const content = isOptionTypeObject ? option.label : formattedValue;
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionComponent, {
|
|
63
|
+
value: value,
|
|
64
|
+
children: content
|
|
65
|
+
}, key);
|
|
66
|
+
});
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
64
70
|
exports.SUBMIT_FILTER_STROKE_TIME = SUBMIT_FILTER_STROKE_TIME;
|
|
65
71
|
|
|
66
72
|
function GridFilterInputValue(props) {
|
|
67
|
-
var _item$value, _rootProps$components;
|
|
73
|
+
var _item$value, _rootProps$components, _baseSelectProps$nati, _rootProps$components2, _rootProps$components3;
|
|
68
74
|
|
|
69
75
|
const {
|
|
70
76
|
item,
|
|
@@ -84,12 +90,14 @@ function GridFilterInputValue(props) {
|
|
|
84
90
|
const [applying, setIsApplying] = React.useState(false);
|
|
85
91
|
const id = (0, _utils.unstable_useId)();
|
|
86
92
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
93
|
+
const baseSelectProps = ((_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.baseSelect) || {};
|
|
94
|
+
const isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : true;
|
|
87
95
|
const singleSelectProps = type === 'singleSelect' ? {
|
|
88
96
|
select: true,
|
|
89
|
-
SelectProps: {
|
|
90
|
-
native:
|
|
91
|
-
},
|
|
92
|
-
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current)
|
|
97
|
+
SelectProps: (0, _extends2.default)({
|
|
98
|
+
native: isSelectNative
|
|
99
|
+
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSelect),
|
|
100
|
+
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current, isSelectNative ? 'option' : _MenuItem.default)
|
|
93
101
|
} : {};
|
|
94
102
|
const onFilterChange = React.useCallback(event => {
|
|
95
103
|
let value = event.target.value; // NativeSelect casts the value to a string.
|
|
@@ -140,7 +148,7 @@ function GridFilterInputValue(props) {
|
|
|
140
148
|
shrink: true
|
|
141
149
|
},
|
|
142
150
|
inputRef: focusElementRef
|
|
143
|
-
}, singleSelectProps, others, (_rootProps$
|
|
151
|
+
}, singleSelectProps, others, (_rootProps$components3 = rootProps.componentsProps) == null ? void 0 : _rootProps$components3.baseTextField));
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
process.env.NODE_ENV !== "production" ? GridFilterInputValue.propTypes = {
|
|
@@ -129,7 +129,7 @@ const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function GridTo
|
|
|
129
129
|
"aria-label": apiRef.current.getLocaleText('toolbarDensityLabel'),
|
|
130
130
|
"aria-expanded": open ? 'true' : undefined,
|
|
131
131
|
"aria-haspopup": "menu",
|
|
132
|
-
"aria-
|
|
132
|
+
"aria-controls": densityMenuId,
|
|
133
133
|
id: densityButtonId
|
|
134
134
|
}, other, {
|
|
135
135
|
onClick: handleDensitySelectorOpen
|
|
@@ -47,6 +47,8 @@ const VirtualScrollerRoot = (0, _styles.styled)('div', {
|
|
|
47
47
|
overridesResolver: (props, styles) => styles.virtualScroller
|
|
48
48
|
})({
|
|
49
49
|
overflow: 'auto',
|
|
50
|
+
// See https://github.com/mui/mui-x/issues/4360
|
|
51
|
+
position: 'relative',
|
|
50
52
|
'@media print': {
|
|
51
53
|
overflow: 'hidden'
|
|
52
54
|
}
|
|
@@ -46,9 +46,7 @@ const VirtualScrollerContentRoot = (0, _styles.styled)('div', {
|
|
|
46
46
|
name: 'MuiDataGrid',
|
|
47
47
|
slot: 'VirtualScrollerContent',
|
|
48
48
|
overridesResolver: (props, styles) => styles.virtualScrollerContent
|
|
49
|
-
})({
|
|
50
|
-
position: 'relative'
|
|
51
|
-
});
|
|
49
|
+
})({});
|
|
52
50
|
const GridVirtualScrollerContent = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerContent(props, ref) {
|
|
53
51
|
const {
|
|
54
52
|
className,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = void 0;
|
|
7
|
+
// Can't import from pro package - hence duplication
|
|
8
|
+
const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
|
9
|
+
exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = GRID_DETAIL_PANEL_TOGGLE_FIELD;
|
|
@@ -41,4 +41,17 @@ Object.keys(_useGridRegisterPipeProcessor).forEach(function (key) {
|
|
|
41
41
|
return _useGridRegisterPipeProcessor[key];
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _useGridRegisterPipeApplier = require("./useGridRegisterPipeApplier");
|
|
47
|
+
|
|
48
|
+
Object.keys(_useGridRegisterPipeApplier).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _useGridRegisterPipeApplier[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _useGridRegisterPipeApplier[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
44
57
|
});
|
|
@@ -11,14 +11,10 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
11
11
|
|
|
12
12
|
var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
|
|
13
13
|
|
|
14
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
-
|
|
16
14
|
var React = _interopRequireWildcard(require("react"));
|
|
17
15
|
|
|
18
16
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
19
17
|
|
|
20
|
-
var _events = require("../../../models/events");
|
|
21
|
-
|
|
22
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
19
|
|
|
24
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -36,7 +32,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
36
32
|
* The plugin containing the custom logic must use:
|
|
37
33
|
*
|
|
38
34
|
* - `useGridRegisterPipeProcessor` to register their processor.
|
|
39
|
-
*
|
|
35
|
+
*
|
|
36
|
+
* - `apiRef.current.unstable_requestPipeProcessorsApplication` to imperatively re-apply a group.
|
|
37
|
+
* This method should be used in last resort.
|
|
38
|
+
* Most of the time, the application should be triggered by an update on the deps of the processor.
|
|
40
39
|
*
|
|
41
40
|
* =====================================================================================================================
|
|
42
41
|
*
|
|
@@ -44,33 +43,63 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
44
43
|
*
|
|
45
44
|
* - `apiRef.current.unstable_applyPipeProcessors` to run in chain all the processors of a given group.
|
|
46
45
|
*
|
|
47
|
-
* - `
|
|
48
|
-
*
|
|
46
|
+
* - `useGridRegisterPipeApplier` to re-apply the whole pipe when requested.
|
|
47
|
+
* The applier will be called when:
|
|
48
|
+
* * a processor is registered.
|
|
49
|
+
* * `apiRef.current.unstable_requestPipeProcessorsApplication` is called for the given group.
|
|
49
50
|
*/
|
|
50
51
|
const useGridPipeProcessing = apiRef => {
|
|
51
52
|
const processorsCache = React.useRef({});
|
|
53
|
+
const runAppliers = React.useCallback(groupCache => {
|
|
54
|
+
if (!groupCache) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Object.values(groupCache.appliers).forEach(callback => {
|
|
59
|
+
callback();
|
|
60
|
+
});
|
|
61
|
+
}, []);
|
|
52
62
|
const registerPipeProcessor = React.useCallback((group, id, processor) => {
|
|
53
63
|
if (!processorsCache.current[group]) {
|
|
54
|
-
processorsCache.current[group] = {
|
|
64
|
+
processorsCache.current[group] = {
|
|
65
|
+
processors: {},
|
|
66
|
+
appliers: {}
|
|
67
|
+
};
|
|
55
68
|
}
|
|
56
69
|
|
|
57
|
-
const
|
|
58
|
-
const oldProcessor =
|
|
70
|
+
const groupCache = processorsCache.current[group];
|
|
71
|
+
const oldProcessor = groupCache.processors[id];
|
|
59
72
|
|
|
60
73
|
if (oldProcessor !== processor) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
apiRef.current.publishEvent(_events.GridEvents.pipeProcessorRegister, group);
|
|
74
|
+
groupCache.processors[id] = processor;
|
|
75
|
+
runAppliers(groupCache);
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
return () => {
|
|
68
|
-
const
|
|
69
|
-
otherProcessors = (0, _objectWithoutPropertiesLoose2.default)(
|
|
70
|
-
processorsCache.current[group] = otherProcessors;
|
|
71
|
-
apiRef.current.publishEvent(_events.GridEvents.pipeProcessorUnregister, group);
|
|
79
|
+
const _processors = processorsCache.current[group].processors,
|
|
80
|
+
otherProcessors = (0, _objectWithoutPropertiesLoose2.default)(_processors, [id].map(_toPropertyKey2.default));
|
|
81
|
+
processorsCache.current[group].processors = otherProcessors;
|
|
72
82
|
};
|
|
73
|
-
}, [
|
|
83
|
+
}, [runAppliers]);
|
|
84
|
+
const registerPipeApplier = React.useCallback((group, id, applier) => {
|
|
85
|
+
if (!processorsCache.current[group]) {
|
|
86
|
+
processorsCache.current[group] = {
|
|
87
|
+
processors: {},
|
|
88
|
+
appliers: {}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
processorsCache.current[group].appliers[id] = applier;
|
|
93
|
+
return () => {
|
|
94
|
+
const _appliers = processorsCache.current[group].appliers,
|
|
95
|
+
otherAppliers = (0, _objectWithoutPropertiesLoose2.default)(_appliers, [id].map(_toPropertyKey2.default));
|
|
96
|
+
processorsCache.current[group].appliers = otherAppliers;
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
const requestPipeProcessorsApplication = React.useCallback(group => {
|
|
100
|
+
const groupCache = processorsCache.current[group];
|
|
101
|
+
runAppliers(groupCache);
|
|
102
|
+
}, [runAppliers]);
|
|
74
103
|
const applyPipeProcessors = React.useCallback((...args) => {
|
|
75
104
|
const [group, value, context] = args;
|
|
76
105
|
|
|
@@ -78,13 +107,15 @@ const useGridPipeProcessing = apiRef => {
|
|
|
78
107
|
return value;
|
|
79
108
|
}
|
|
80
109
|
|
|
81
|
-
const preProcessors = Object.values(processorsCache.current[group]);
|
|
110
|
+
const preProcessors = Object.values(processorsCache.current[group].processors);
|
|
82
111
|
return preProcessors.reduce((acc, preProcessor) => {
|
|
83
112
|
return preProcessor(acc, context);
|
|
84
113
|
}, value);
|
|
85
114
|
}, []);
|
|
86
115
|
const preProcessingApi = {
|
|
87
116
|
unstable_registerPipeProcessor: registerPipeProcessor,
|
|
117
|
+
unstable_registerPipeApplier: registerPipeApplier,
|
|
118
|
+
unstable_requestPipeProcessorsApplication: requestPipeProcessorsApplication,
|
|
88
119
|
unstable_applyPipeProcessors: applyPipeProcessors
|
|
89
120
|
};
|
|
90
121
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, preProcessingApi, 'GridPipeProcessingApi');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGridRegisterPipeApplier = void 0;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _useFirstRender = require("../../utils/useFirstRender");
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
16
|
+
const useGridRegisterPipeApplier = (apiRef, group, callback) => {
|
|
17
|
+
const cleanup = React.useRef();
|
|
18
|
+
const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
|
|
19
|
+
const registerPreProcessor = React.useCallback(() => {
|
|
20
|
+
cleanup.current = apiRef.current.unstable_registerPipeApplier(group, id.current, callback);
|
|
21
|
+
}, [apiRef, callback, group]);
|
|
22
|
+
(0, _useFirstRender.useFirstRender)(() => {
|
|
23
|
+
registerPreProcessor();
|
|
24
|
+
});
|
|
25
|
+
const isFirstRender = React.useRef(true);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (isFirstRender.current) {
|
|
28
|
+
isFirstRender.current = false;
|
|
29
|
+
} else {
|
|
30
|
+
registerPreProcessor();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
if (cleanup.current) {
|
|
35
|
+
cleanup.current();
|
|
36
|
+
cleanup.current = null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, [registerPreProcessor]);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.useGridRegisterPipeApplier = useGridRegisterPipeApplier;
|
|
@@ -13,9 +13,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* TODO: Rename `useGridRegisterPipeProcessor`
|
|
18
|
-
*/
|
|
19
16
|
const useGridRegisterPipeProcessor = (apiRef, group, callback) => {
|
|
20
17
|
const cleanup = React.useRef();
|
|
21
18
|
const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
|