@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["field", "id", "value", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "getValue"];
|
|
3
|
+
const _excluded = ["field", "id", "value", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "getValue", "api"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
@@ -97,6 +97,12 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
97
97
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
98
98
|
// ----------------------------------------------------------------------
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* GridApi that let you manipulate the grid.
|
|
102
|
+
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
|
|
103
|
+
*/
|
|
104
|
+
api: PropTypes.any.isRequired,
|
|
105
|
+
|
|
100
106
|
/**
|
|
101
107
|
* The mode of the cell.
|
|
102
108
|
*/
|
|
@@ -112,10 +118,21 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
112
118
|
*/
|
|
113
119
|
field: PropTypes.string.isRequired,
|
|
114
120
|
|
|
121
|
+
/**
|
|
122
|
+
* A ref allowing to set imperative focus.
|
|
123
|
+
* It can be passed to the element that should receive focus.
|
|
124
|
+
* @ignore - do not document.
|
|
125
|
+
*/
|
|
126
|
+
focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
127
|
+
current: PropTypes.shape({
|
|
128
|
+
focus: PropTypes.func.isRequired
|
|
129
|
+
})
|
|
130
|
+
})]),
|
|
131
|
+
|
|
115
132
|
/**
|
|
116
133
|
* The cell value formatted with the column valueFormatter.
|
|
117
134
|
*/
|
|
118
|
-
formattedValue: PropTypes.any
|
|
135
|
+
formattedValue: PropTypes.any,
|
|
119
136
|
|
|
120
137
|
/**
|
|
121
138
|
* Get the cell value of a row and field.
|
|
@@ -159,7 +176,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
159
176
|
/**
|
|
160
177
|
* The cell value, but if the column has valueGetter, use getValue.
|
|
161
178
|
*/
|
|
162
|
-
value: PropTypes.any
|
|
179
|
+
value: PropTypes.any
|
|
163
180
|
} : void 0;
|
|
164
181
|
export { GridCellCheckboxForwardRef };
|
|
165
182
|
export const GridCellCheckboxRenderer = /*#__PURE__*/React.memo(GridCellCheckboxForwardRef);
|
|
@@ -80,6 +80,7 @@ const GridPanel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
80
80
|
modifiers: modifiers
|
|
81
81
|
}, other, {
|
|
82
82
|
children: /*#__PURE__*/_jsx(ClickAwayListener, {
|
|
83
|
+
mouseEvent: "onMouseUp",
|
|
83
84
|
onClickAway: handleClickAway,
|
|
84
85
|
children: /*#__PURE__*/_jsx(GridPaperRoot, {
|
|
85
86
|
className: classes.paper,
|
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
5
5
|
import IconButton from '@mui/material/IconButton';
|
|
6
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
6
7
|
import InputLabel from '@mui/material/InputLabel';
|
|
7
8
|
import FormControl from '@mui/material/FormControl';
|
|
8
9
|
import { capitalize, unstable_useId as useId } from '@mui/material/utils';
|
|
@@ -136,6 +137,9 @@ function GridFilterForm(props) {
|
|
|
136
137
|
const filterSelectorRef = React.useRef(null);
|
|
137
138
|
const hasLinkOperatorColumn = hasMultipleFilters && linkOperators.length > 0;
|
|
138
139
|
const baseFormControlProps = rootProps.componentsProps?.baseFormControl || {};
|
|
140
|
+
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
141
|
+
const isBaseSelectNative = baseSelectProps.native ?? true;
|
|
142
|
+
const OptionComponent = isBaseSelectNative ? 'option' : MenuItem;
|
|
139
143
|
const sortedFilterableColumns = React.useMemo(() => {
|
|
140
144
|
switch (columnsSort) {
|
|
141
145
|
case 'asc':
|
|
@@ -245,9 +249,9 @@ function GridFilterForm(props) {
|
|
|
245
249
|
value: multiFilterOperator,
|
|
246
250
|
onChange: changeLinkOperator,
|
|
247
251
|
disabled: !!disableMultiFilterOperator || linkOperators.length === 1,
|
|
248
|
-
native:
|
|
252
|
+
native: isBaseSelectNative
|
|
249
253
|
}, rootProps.componentsProps?.baseSelect, {
|
|
250
|
-
children: linkOperators.map(linkOperator => /*#__PURE__*/_jsx(
|
|
254
|
+
children: linkOperators.map(linkOperator => /*#__PURE__*/_jsx(OptionComponent, {
|
|
251
255
|
value: linkOperator.toString(),
|
|
252
256
|
children: apiRef.current.getLocaleText(getLinkOperatorLocaleKey(linkOperator))
|
|
253
257
|
}, linkOperator.toString()))
|
|
@@ -267,9 +271,9 @@ function GridFilterForm(props) {
|
|
|
267
271
|
label: apiRef.current.getLocaleText('filterPanelColumns'),
|
|
268
272
|
value: item.columnField || '',
|
|
269
273
|
onChange: changeColumn,
|
|
270
|
-
native:
|
|
274
|
+
native: isBaseSelectNative
|
|
271
275
|
}, rootProps.componentsProps?.baseSelect, {
|
|
272
|
-
children: sortedFilterableColumns.map(col => /*#__PURE__*/_jsx(
|
|
276
|
+
children: sortedFilterableColumns.map(col => /*#__PURE__*/_jsx(OptionComponent, {
|
|
273
277
|
value: col.field,
|
|
274
278
|
children: getColumnLabel(col)
|
|
275
279
|
}, col.field))
|
|
@@ -289,10 +293,10 @@ function GridFilterForm(props) {
|
|
|
289
293
|
id: operatorSelectId,
|
|
290
294
|
value: item.operatorValue,
|
|
291
295
|
onChange: changeOperator,
|
|
292
|
-
native:
|
|
296
|
+
native: isBaseSelectNative,
|
|
293
297
|
inputRef: filterSelectorRef
|
|
294
298
|
}, rootProps.componentsProps?.baseSelect, {
|
|
295
|
-
children: currentColumn?.filterOperators?.map(operator => /*#__PURE__*/_jsx(
|
|
299
|
+
children: currentColumn?.filterOperators?.map(operator => /*#__PURE__*/_jsx(OptionComponent, {
|
|
296
300
|
value: operator.value,
|
|
297
301
|
children: operator.label || apiRef.current.getLocaleText(`filterOperator${capitalize(operator.value)}`)
|
|
298
302
|
}, operator.value))
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
5
6
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -16,6 +17,9 @@ export function GridFilterInputBoolean(props) {
|
|
|
16
17
|
|
|
17
18
|
const [filterValueState, setFilterValueState] = React.useState(item.value || '');
|
|
18
19
|
const rootProps = useGridRootProps();
|
|
20
|
+
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
21
|
+
const isSelectNative = baseSelectProps.native ?? true;
|
|
22
|
+
const OptionComponent = isSelectNative ? 'option' : MenuItem;
|
|
19
23
|
const onFilterChange = React.useCallback(event => {
|
|
20
24
|
const value = event.target.value;
|
|
21
25
|
setFilterValueState(value);
|
|
@@ -32,21 +36,22 @@ export function GridFilterInputBoolean(props) {
|
|
|
32
36
|
onChange: onFilterChange,
|
|
33
37
|
variant: "standard",
|
|
34
38
|
select: true,
|
|
35
|
-
SelectProps: {
|
|
36
|
-
native:
|
|
37
|
-
|
|
39
|
+
SelectProps: _extends({
|
|
40
|
+
native: isSelectNative,
|
|
41
|
+
displayEmpty: true
|
|
42
|
+
}, rootProps.componentsProps?.baseSelect),
|
|
38
43
|
InputLabelProps: {
|
|
39
44
|
shrink: true
|
|
40
45
|
},
|
|
41
46
|
inputRef: focusElementRef
|
|
42
47
|
}, others, rootProps.componentsProps?.baseTextField, {
|
|
43
|
-
children: [/*#__PURE__*/_jsx(
|
|
48
|
+
children: [/*#__PURE__*/_jsx(OptionComponent, {
|
|
44
49
|
value: "",
|
|
45
50
|
children: apiRef.current.getLocaleText('filterValueAny')
|
|
46
|
-
}), /*#__PURE__*/_jsx(
|
|
51
|
+
}), /*#__PURE__*/_jsx(OptionComponent, {
|
|
47
52
|
value: "true",
|
|
48
53
|
children: apiRef.current.getLocaleText('filterValueTrue')
|
|
49
|
-
}), /*#__PURE__*/_jsx(
|
|
54
|
+
}), /*#__PURE__*/_jsx(OptionComponent, {
|
|
50
55
|
value: "false",
|
|
51
56
|
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
52
57
|
})]
|
|
@@ -4,6 +4,7 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useId as useId } from '@mui/material/utils';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
7
8
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
8
9
|
import { getValueFromValueOptions } from './filterPanelUtils';
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -12,21 +13,25 @@ const renderSingleSelectOptions = ({
|
|
|
12
13
|
valueOptions,
|
|
13
14
|
valueFormatter,
|
|
14
15
|
field
|
|
15
|
-
}, api) => {
|
|
16
|
+
}, api, OptionComponent) => {
|
|
16
17
|
const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({
|
|
17
18
|
field
|
|
18
19
|
})] : ['', ...(valueOptions || [])];
|
|
19
|
-
return iterableColumnValues.map(option =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
children: valueFormatter && option !== '' ? valueFormatter({
|
|
20
|
+
return iterableColumnValues.map(option => {
|
|
21
|
+
const isOptionTypeObject = typeof option === 'object';
|
|
22
|
+
const key = isOptionTypeObject ? option.value : option;
|
|
23
|
+
const value = isOptionTypeObject ? option.value : option;
|
|
24
|
+
const formattedValue = valueFormatter && option !== '' ? valueFormatter({
|
|
25
25
|
value: option,
|
|
26
26
|
field,
|
|
27
27
|
api
|
|
28
|
-
}) : option
|
|
29
|
-
|
|
28
|
+
}) : option;
|
|
29
|
+
const content = isOptionTypeObject ? option.label : formattedValue;
|
|
30
|
+
return /*#__PURE__*/_jsx(OptionComponent, {
|
|
31
|
+
value: value,
|
|
32
|
+
children: content
|
|
33
|
+
}, key);
|
|
34
|
+
});
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
function GridFilterInputSingleSelect(props) {
|
|
@@ -42,6 +47,8 @@ function GridFilterInputSingleSelect(props) {
|
|
|
42
47
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
43
48
|
const id = useId();
|
|
44
49
|
const rootProps = useGridRootProps();
|
|
50
|
+
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
51
|
+
const isSelectNative = baseSelectProps.native ?? true;
|
|
45
52
|
const currentColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
|
|
46
53
|
const currentValueOptions = React.useMemo(() => {
|
|
47
54
|
return typeof currentColumn.valueOptions === 'function' ? currentColumn.valueOptions({
|
|
@@ -90,11 +97,11 @@ function GridFilterInputSingleSelect(props) {
|
|
|
90
97
|
},
|
|
91
98
|
inputRef: focusElementRef,
|
|
92
99
|
select: true,
|
|
93
|
-
SelectProps: {
|
|
94
|
-
native:
|
|
95
|
-
}
|
|
100
|
+
SelectProps: _extends({
|
|
101
|
+
native: isSelectNative
|
|
102
|
+
}, rootProps.componentsProps?.baseSelect)
|
|
96
103
|
}, others, rootProps.componentsProps?.baseTextField, {
|
|
97
|
-
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current)
|
|
104
|
+
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current, isSelectNative ? 'option' : MenuItem)
|
|
98
105
|
}));
|
|
99
106
|
}
|
|
100
107
|
|
|
@@ -4,6 +4,7 @@ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useId as useId } from '@mui/material/utils';
|
|
7
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
7
8
|
import { GridLoadIcon } from '../../icons';
|
|
8
9
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
9
10
|
import { getValueFromValueOptions } from './filterPanelUtils';
|
|
@@ -19,21 +20,25 @@ const renderSingleSelectOptions = ({
|
|
|
19
20
|
valueOptions,
|
|
20
21
|
valueFormatter,
|
|
21
22
|
field
|
|
22
|
-
}, api) => {
|
|
23
|
+
}, api, OptionComponent) => {
|
|
23
24
|
const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({
|
|
24
25
|
field
|
|
25
26
|
})] : ['', ...(valueOptions || [])];
|
|
26
|
-
return iterableColumnValues.map(option =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
children: valueFormatter && option !== '' ? valueFormatter({
|
|
27
|
+
return iterableColumnValues.map(option => {
|
|
28
|
+
const isOptionTypeObject = typeof option === 'object';
|
|
29
|
+
const key = isOptionTypeObject ? option.value : option;
|
|
30
|
+
const value = isOptionTypeObject ? option.value : option;
|
|
31
|
+
const formattedValue = valueFormatter && option !== '' ? valueFormatter({
|
|
32
32
|
value: option,
|
|
33
33
|
field,
|
|
34
34
|
api
|
|
35
|
-
}) : option
|
|
36
|
-
|
|
35
|
+
}) : option;
|
|
36
|
+
const content = isOptionTypeObject ? option.label : formattedValue;
|
|
37
|
+
return /*#__PURE__*/_jsx(OptionComponent, {
|
|
38
|
+
value: value,
|
|
39
|
+
children: content
|
|
40
|
+
}, key);
|
|
41
|
+
});
|
|
37
42
|
};
|
|
38
43
|
|
|
39
44
|
export const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
@@ -57,12 +62,14 @@ function GridFilterInputValue(props) {
|
|
|
57
62
|
const [applying, setIsApplying] = React.useState(false);
|
|
58
63
|
const id = useId();
|
|
59
64
|
const rootProps = useGridRootProps();
|
|
65
|
+
const baseSelectProps = rootProps.componentsProps?.baseSelect || {};
|
|
66
|
+
const isSelectNative = baseSelectProps.native ?? true;
|
|
60
67
|
const singleSelectProps = type === 'singleSelect' ? {
|
|
61
68
|
select: true,
|
|
62
|
-
SelectProps: {
|
|
63
|
-
native:
|
|
64
|
-
},
|
|
65
|
-
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current)
|
|
69
|
+
SelectProps: _extends({
|
|
70
|
+
native: isSelectNative
|
|
71
|
+
}, rootProps.componentsProps?.baseSelect),
|
|
72
|
+
children: renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current, isSelectNative ? 'option' : MenuItem)
|
|
66
73
|
} : {};
|
|
67
74
|
const onFilterChange = React.useCallback(event => {
|
|
68
75
|
let value = event.target.value; // NativeSelect casts the value to a string.
|
|
@@ -99,7 +99,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
99
99
|
"aria-label": apiRef.current.getLocaleText('toolbarDensityLabel'),
|
|
100
100
|
"aria-expanded": open ? 'true' : undefined,
|
|
101
101
|
"aria-haspopup": "menu",
|
|
102
|
-
"aria-
|
|
102
|
+
"aria-controls": densityMenuId,
|
|
103
103
|
id: densityButtonId
|
|
104
104
|
}, other, {
|
|
105
105
|
onClick: handleDensitySelectorOpen
|
|
@@ -25,6 +25,8 @@ const VirtualScrollerRoot = styled('div', {
|
|
|
25
25
|
overridesResolver: (props, styles) => styles.virtualScroller
|
|
26
26
|
})({
|
|
27
27
|
overflow: 'auto',
|
|
28
|
+
// See https://github.com/mui/mui-x/issues/4360
|
|
29
|
+
position: 'relative',
|
|
28
30
|
'@media print': {
|
|
29
31
|
overflow: 'hidden'
|
|
30
32
|
}
|
|
@@ -24,9 +24,7 @@ const VirtualScrollerContentRoot = styled('div', {
|
|
|
24
24
|
name: 'MuiDataGrid',
|
|
25
25
|
slot: 'VirtualScrollerContent',
|
|
26
26
|
overridesResolver: (props, styles) => styles.virtualScrollerContent
|
|
27
|
-
})({
|
|
28
|
-
position: 'relative'
|
|
29
|
-
});
|
|
27
|
+
})({});
|
|
30
28
|
const GridVirtualScrollerContent = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerContent(props, ref) {
|
|
31
29
|
const {
|
|
32
30
|
className,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
/**
|
|
8
7
|
* Implement the Pipeline Pattern
|
|
9
8
|
*
|
|
@@ -17,7 +16,10 @@ import { GridEvents } from '../../../models/events';
|
|
|
17
16
|
* The plugin containing the custom logic must use:
|
|
18
17
|
*
|
|
19
18
|
* - `useGridRegisterPipeProcessor` to register their processor.
|
|
20
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* - `apiRef.current.unstable_requestPipeProcessorsApplication` to imperatively re-apply a group.
|
|
21
|
+
* This method should be used in last resort.
|
|
22
|
+
* Most of the time, the application should be triggered by an update on the deps of the processor.
|
|
21
23
|
*
|
|
22
24
|
* =====================================================================================================================
|
|
23
25
|
*
|
|
@@ -25,35 +27,65 @@ import { GridEvents } from '../../../models/events';
|
|
|
25
27
|
*
|
|
26
28
|
* - `apiRef.current.unstable_applyPipeProcessors` to run in chain all the processors of a given group.
|
|
27
29
|
*
|
|
28
|
-
* - `
|
|
29
|
-
*
|
|
30
|
+
* - `useGridRegisterPipeApplier` to re-apply the whole pipe when requested.
|
|
31
|
+
* The applier will be called when:
|
|
32
|
+
* * a processor is registered.
|
|
33
|
+
* * `apiRef.current.unstable_requestPipeProcessorsApplication` is called for the given group.
|
|
30
34
|
*/
|
|
31
|
-
|
|
32
35
|
export const useGridPipeProcessing = apiRef => {
|
|
33
36
|
const processorsCache = React.useRef({});
|
|
37
|
+
const runAppliers = React.useCallback(groupCache => {
|
|
38
|
+
if (!groupCache) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Object.values(groupCache.appliers).forEach(callback => {
|
|
43
|
+
callback();
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
34
46
|
const registerPipeProcessor = React.useCallback((group, id, processor) => {
|
|
35
47
|
if (!processorsCache.current[group]) {
|
|
36
|
-
processorsCache.current[group] = {
|
|
48
|
+
processorsCache.current[group] = {
|
|
49
|
+
processors: {},
|
|
50
|
+
appliers: {}
|
|
51
|
+
};
|
|
37
52
|
}
|
|
38
53
|
|
|
39
|
-
const
|
|
40
|
-
const oldProcessor =
|
|
54
|
+
const groupCache = processorsCache.current[group];
|
|
55
|
+
const oldProcessor = groupCache.processors[id];
|
|
41
56
|
|
|
42
57
|
if (oldProcessor !== processor) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
apiRef.current.publishEvent(GridEvents.pipeProcessorRegister, group);
|
|
58
|
+
groupCache.processors[id] = processor;
|
|
59
|
+
runAppliers(groupCache);
|
|
47
60
|
}
|
|
48
61
|
|
|
49
62
|
return () => {
|
|
50
|
-
const
|
|
51
|
-
otherProcessors = _objectWithoutPropertiesLoose(
|
|
63
|
+
const _processors = processorsCache.current[group].processors,
|
|
64
|
+
otherProcessors = _objectWithoutPropertiesLoose(_processors, [id].map(_toPropertyKey));
|
|
52
65
|
|
|
53
|
-
processorsCache.current[group] = otherProcessors;
|
|
54
|
-
apiRef.current.publishEvent(GridEvents.pipeProcessorUnregister, group);
|
|
66
|
+
processorsCache.current[group].processors = otherProcessors;
|
|
55
67
|
};
|
|
56
|
-
}, [
|
|
68
|
+
}, [runAppliers]);
|
|
69
|
+
const registerPipeApplier = React.useCallback((group, id, applier) => {
|
|
70
|
+
if (!processorsCache.current[group]) {
|
|
71
|
+
processorsCache.current[group] = {
|
|
72
|
+
processors: {},
|
|
73
|
+
appliers: {}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
processorsCache.current[group].appliers[id] = applier;
|
|
78
|
+
return () => {
|
|
79
|
+
const _appliers = processorsCache.current[group].appliers,
|
|
80
|
+
otherAppliers = _objectWithoutPropertiesLoose(_appliers, [id].map(_toPropertyKey));
|
|
81
|
+
|
|
82
|
+
processorsCache.current[group].appliers = otherAppliers;
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
const requestPipeProcessorsApplication = React.useCallback(group => {
|
|
86
|
+
const groupCache = processorsCache.current[group];
|
|
87
|
+
runAppliers(groupCache);
|
|
88
|
+
}, [runAppliers]);
|
|
57
89
|
const applyPipeProcessors = React.useCallback((...args) => {
|
|
58
90
|
const [group, value, context] = args;
|
|
59
91
|
|
|
@@ -61,13 +93,15 @@ export const useGridPipeProcessing = apiRef => {
|
|
|
61
93
|
return value;
|
|
62
94
|
}
|
|
63
95
|
|
|
64
|
-
const preProcessors = Object.values(processorsCache.current[group]);
|
|
96
|
+
const preProcessors = Object.values(processorsCache.current[group].processors);
|
|
65
97
|
return preProcessors.reduce((acc, preProcessor) => {
|
|
66
98
|
return preProcessor(acc, context);
|
|
67
99
|
}, value);
|
|
68
100
|
}, []);
|
|
69
101
|
const preProcessingApi = {
|
|
70
102
|
unstable_registerPipeProcessor: registerPipeProcessor,
|
|
103
|
+
unstable_registerPipeApplier: registerPipeApplier,
|
|
104
|
+
unstable_requestPipeProcessorsApplication: requestPipeProcessorsApplication,
|
|
71
105
|
unstable_applyPipeProcessors: applyPipeProcessors
|
|
72
106
|
};
|
|
73
107
|
useGridApiMethod(apiRef, preProcessingApi, 'GridPipeProcessingApi');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useFirstRender } from '../../utils/useFirstRender';
|
|
3
|
+
export const useGridRegisterPipeApplier = (apiRef, group, callback) => {
|
|
4
|
+
const cleanup = React.useRef();
|
|
5
|
+
const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
|
|
6
|
+
const registerPreProcessor = React.useCallback(() => {
|
|
7
|
+
cleanup.current = apiRef.current.unstable_registerPipeApplier(group, id.current, callback);
|
|
8
|
+
}, [apiRef, callback, group]);
|
|
9
|
+
useFirstRender(() => {
|
|
10
|
+
registerPreProcessor();
|
|
11
|
+
});
|
|
12
|
+
const isFirstRender = React.useRef(true);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (isFirstRender.current) {
|
|
15
|
+
isFirstRender.current = false;
|
|
16
|
+
} else {
|
|
17
|
+
registerPreProcessor();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
if (cleanup.current) {
|
|
22
|
+
cleanup.current();
|
|
23
|
+
cleanup.current = null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}, [registerPreProcessor]);
|
|
27
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useFirstRender } from '../../utils/useFirstRender';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TODO: Rename `useGridRegisterPipeProcessor`
|
|
6
|
-
*/
|
|
7
3
|
export const useGridRegisterPipeProcessor = (apiRef, group, callback) => {
|
|
8
4
|
const cleanup = React.useRef();
|
|
9
5
|
const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import * as ReactDOM from 'react-dom';
|
|
3
4
|
import { useForkRef } from '@mui/material/utils';
|
|
5
|
+
import { defaultMemoize } from 'reselect';
|
|
4
6
|
import { useGridApiContext } from '../../utils/useGridApiContext';
|
|
5
7
|
import { useGridSelector } from '../../utils/useGridSelector';
|
|
6
8
|
import { gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from '../columns/gridColumnsSelector';
|
|
@@ -13,7 +15,15 @@ import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
|
13
15
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
14
16
|
import { GridEvents } from '../../../models/events';
|
|
15
17
|
import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
|
|
18
|
+
import { getFirstColumnIndexToRender } from '../columns/gridColumnsUtils';
|
|
19
|
+
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
20
|
+
import { getRenderableIndexes } from '../virtualization/useGridVirtualScroller';
|
|
16
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
|
|
23
|
+
function isUIEvent(event) {
|
|
24
|
+
return !!event.target;
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
export const useGridColumnHeaders = props => {
|
|
18
28
|
const {
|
|
19
29
|
innerRef: innerRefProp,
|
|
@@ -37,18 +47,43 @@ export const useGridColumnHeaders = props => {
|
|
|
37
47
|
const [renderContext, setRenderContext] = React.useState(null);
|
|
38
48
|
const prevRenderContext = React.useRef(renderContext);
|
|
39
49
|
const prevScrollLeft = React.useRef(0);
|
|
50
|
+
const currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
40
51
|
React.useEffect(() => {
|
|
41
52
|
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
42
|
-
}, [apiRef]);
|
|
53
|
+
}, [apiRef]); // memoize `getFirstColumnIndexToRender`, since it's called on scroll
|
|
54
|
+
|
|
55
|
+
const getFirstColumnIndexToRenderRef = React.useRef(defaultMemoize(getFirstColumnIndexToRender, {
|
|
56
|
+
equalityCheck: (a, b) => ['firstColumnIndex', 'minColumnIndex', 'columnBuffer'].every(key => a[key] === b[key])
|
|
57
|
+
}));
|
|
43
58
|
const updateInnerPosition = React.useCallback(nextRenderContext => {
|
|
44
|
-
const
|
|
59
|
+
const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
|
|
60
|
+
firstIndex: nextRenderContext.firstRowIndex,
|
|
61
|
+
lastIndex: nextRenderContext.lastRowIndex,
|
|
62
|
+
minFirstIndex: 0,
|
|
63
|
+
maxLastIndex: currentPage.rows.length,
|
|
64
|
+
buffer: rootProps.rowBuffer
|
|
65
|
+
});
|
|
66
|
+
const firstColumnToRender = getFirstColumnIndexToRenderRef.current({
|
|
67
|
+
firstColumnIndex: nextRenderContext.firstColumnIndex,
|
|
68
|
+
minColumnIndex,
|
|
69
|
+
columnBuffer: rootProps.columnBuffer,
|
|
70
|
+
firstRowToRender,
|
|
71
|
+
lastRowToRender,
|
|
72
|
+
apiRef,
|
|
73
|
+
visibleRows: currentPage.rows
|
|
74
|
+
});
|
|
45
75
|
const offset = firstColumnToRender > 0 ? prevScrollLeft.current - columnPositions[firstColumnToRender] : prevScrollLeft.current;
|
|
46
76
|
innerRef.current.style.transform = `translate3d(${-offset}px, 0px, 0px)`;
|
|
47
|
-
}, [columnPositions, minColumnIndex, rootProps.columnBuffer]);
|
|
77
|
+
}, [columnPositions, minColumnIndex, rootProps.columnBuffer, apiRef, currentPage.rows, rootProps.rowBuffer]);
|
|
78
|
+
React.useLayoutEffect(() => {
|
|
79
|
+
if (renderContext) {
|
|
80
|
+
updateInnerPosition(renderContext);
|
|
81
|
+
}
|
|
82
|
+
}, [renderContext, updateInnerPosition]);
|
|
48
83
|
const handleScroll = React.useCallback(({
|
|
49
84
|
left,
|
|
50
85
|
renderContext: nextRenderContext = null
|
|
51
|
-
}) => {
|
|
86
|
+
}, event) => {
|
|
52
87
|
if (!innerRef.current) {
|
|
53
88
|
return;
|
|
54
89
|
} // Ignore vertical scroll.
|
|
@@ -59,15 +94,32 @@ export const useGridColumnHeaders = props => {
|
|
|
59
94
|
return;
|
|
60
95
|
}
|
|
61
96
|
|
|
62
|
-
prevScrollLeft.current = left;
|
|
97
|
+
prevScrollLeft.current = left; // We can only update the position when we guarantee that the render context has been
|
|
98
|
+
// rendered. This is achieved using ReactDOM.flushSync or when the context doesn't change.
|
|
99
|
+
|
|
100
|
+
let canUpdateInnerPosition = false;
|
|
63
101
|
|
|
64
102
|
if (nextRenderContext !== prevRenderContext.current || !prevRenderContext.current) {
|
|
65
|
-
|
|
103
|
+
// ReactDOM.flushSync cannot be called on `scroll` events fired inside effects
|
|
104
|
+
if (isUIEvent(event)) {
|
|
105
|
+
// To prevent flickering, the inner position can only be updated after the new context has
|
|
106
|
+
// been rendered. ReactDOM.flushSync ensures that the state changes will happen before
|
|
107
|
+
// updating the position.
|
|
108
|
+
ReactDOM.flushSync(() => {
|
|
109
|
+
setRenderContext(nextRenderContext);
|
|
110
|
+
});
|
|
111
|
+
canUpdateInnerPosition = true;
|
|
112
|
+
} else {
|
|
113
|
+
setRenderContext(nextRenderContext);
|
|
114
|
+
}
|
|
115
|
+
|
|
66
116
|
prevRenderContext.current = nextRenderContext;
|
|
117
|
+
} else {
|
|
118
|
+
canUpdateInnerPosition = true;
|
|
67
119
|
} // Pass directly the render context to avoid waiting for the next render
|
|
68
120
|
|
|
69
121
|
|
|
70
|
-
if (nextRenderContext) {
|
|
122
|
+
if (nextRenderContext && canUpdateInnerPosition) {
|
|
71
123
|
updateInnerPosition(nextRenderContext);
|
|
72
124
|
}
|
|
73
125
|
}, [updateInnerPosition]);
|
|
@@ -93,7 +145,22 @@ export const useGridColumnHeaders = props => {
|
|
|
93
145
|
}
|
|
94
146
|
|
|
95
147
|
const columns = [];
|
|
96
|
-
const
|
|
148
|
+
const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
|
|
149
|
+
firstIndex: nextRenderContext.firstRowIndex,
|
|
150
|
+
lastIndex: nextRenderContext.lastRowIndex,
|
|
151
|
+
minFirstIndex: 0,
|
|
152
|
+
maxLastIndex: currentPage.rows.length,
|
|
153
|
+
buffer: rootProps.rowBuffer
|
|
154
|
+
});
|
|
155
|
+
const firstColumnToRender = getFirstColumnIndexToRenderRef.current({
|
|
156
|
+
firstColumnIndex: nextRenderContext.firstColumnIndex,
|
|
157
|
+
minColumnIndex: minFirstColumn,
|
|
158
|
+
columnBuffer: rootProps.columnBuffer,
|
|
159
|
+
apiRef,
|
|
160
|
+
firstRowToRender,
|
|
161
|
+
lastRowToRender,
|
|
162
|
+
visibleRows: currentPage.rows
|
|
163
|
+
});
|
|
97
164
|
const lastColumnToRender = Math.min(nextRenderContext.lastColumnIndex + rootProps.columnBuffer, maxLastColumn);
|
|
98
165
|
const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
99
166
|
|
|
@@ -117,7 +184,7 @@ export const useGridColumnHeaders = props => {
|
|
|
117
184
|
extendRowFullWidth: !rootProps.disableExtendRowFullWidth,
|
|
118
185
|
hasFocus: hasFocus,
|
|
119
186
|
tabIndex: tabIndex
|
|
120
|
-
}, other),
|
|
187
|
+
}, other), column.field));
|
|
121
188
|
}
|
|
122
189
|
|
|
123
190
|
return columns;
|
|
@@ -132,7 +199,6 @@ export const useGridColumnHeaders = props => {
|
|
|
132
199
|
renderContext,
|
|
133
200
|
getColumns,
|
|
134
201
|
isDragging: !!dragCol,
|
|
135
|
-
updateInnerPosition,
|
|
136
202
|
getRootProps: (other = {}) => _extends({
|
|
137
203
|
style: rootStyle
|
|
138
204
|
}, other),
|