@mui/x-data-grid 7.0.0-beta.2 → 7.0.0-beta.3
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 +73 -9
- package/DataGrid/DataGrid.js +0 -6
- package/components/GridRow.d.ts +3 -1
- package/components/GridRow.js +10 -2
- package/components/containers/GridRootStyles.js +1 -4
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -4
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -4
- package/components/panel/filterPanel/GridFilterInputValue.js +4 -3
- package/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -5
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -48
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +9 -0
- package/hooks/features/virtualization/gridVirtualizationSelectors.js +7 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +19 -16
- package/hooks/features/virtualization/useGridVirtualization.d.ts +8 -0
- package/hooks/features/virtualization/useGridVirtualization.js +6 -1
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +0 -6
- package/legacy/components/GridRow.js +10 -2
- package/legacy/components/containers/GridRootStyles.js +1 -4
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +6 -3
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +7 -4
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +4 -2
- package/legacy/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -63
- package/legacy/hooks/features/virtualization/gridVirtualizationSelectors.js +9 -0
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +19 -16
- package/legacy/hooks/features/virtualization/useGridVirtualization.js +6 -1
- package/legacy/index.js +1 -1
- package/models/events/gridEventLookup.d.ts +1 -8
- package/models/props/DataGridProps.d.ts +0 -6
- package/modern/DataGrid/DataGrid.js +0 -6
- package/modern/components/GridRow.js +10 -2
- package/modern/components/containers/GridRootStyles.js +1 -4
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +6 -4
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -4
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +4 -3
- package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -48
- package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +7 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +18 -14
- package/modern/hooks/features/virtualization/useGridVirtualization.js +6 -1
- package/modern/index.js +1 -1
- package/node/DataGrid/DataGrid.js +0 -6
- package/node/components/GridRow.js +10 -2
- package/node/components/containers/GridRootStyles.js +1 -4
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +6 -4
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -4
- package/node/components/panel/filterPanel/GridFilterInputValue.js +4 -3
- package/node/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +45 -47
- package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +8 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -13
- package/node/hooks/features/virtualization/useGridVirtualization.js +7 -2
- package/node/index.js +1 -1
- package/package.json +3 -3
|
@@ -20,7 +20,7 @@ import { selectedIdsLookupSelector } from '../rowSelection/gridRowSelectionSelec
|
|
|
20
20
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
21
21
|
import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils';
|
|
22
22
|
import { getMinimalContentHeight } from '../rows/gridRowsUtils';
|
|
23
|
-
import { gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
|
|
23
|
+
import { gridOffsetsSelector, gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
|
|
24
24
|
import { EMPTY_RENDER_CONTEXT } from './useGridVirtualization';
|
|
25
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
26
|
export const EMPTY_DETAIL_PANELS = Object.freeze(new Map());
|
|
@@ -37,7 +37,6 @@ export const useGridVirtualScroller = () => {
|
|
|
37
37
|
const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
|
|
38
38
|
const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
|
|
39
39
|
const theme = useTheme();
|
|
40
|
-
const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
|
|
41
40
|
const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
|
|
42
41
|
const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
|
|
43
42
|
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
@@ -53,6 +52,7 @@ export const useGridVirtualScroller = () => {
|
|
|
53
52
|
useResizeObserver(mainRef, () => apiRef.current.resize());
|
|
54
53
|
const previousContext = React.useRef(EMPTY_RENDER_CONTEXT);
|
|
55
54
|
const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
|
|
55
|
+
const offsets = useGridSelector(apiRef, gridOffsetsSelector);
|
|
56
56
|
const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
|
|
57
57
|
const scrollPosition = React.useRef({
|
|
58
58
|
top: 0,
|
|
@@ -72,23 +72,17 @@ export const useGridVirtualScroller = () => {
|
|
|
72
72
|
}
|
|
73
73
|
return -1;
|
|
74
74
|
}, [cellFocus, visibleColumns]);
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
var _gridRootRef$current, _gridRootRef$current2;
|
|
77
|
-
const direction = theme.direction === 'ltr' ? 1 : -1;
|
|
78
|
-
const top = gridRowsMetaSelector(apiRef.current.state).positions[renderContext.firstRowIndex];
|
|
79
|
-
const left = direction * columnPositions[renderContext.firstColumnIndex] - columnPositions[pinnedColumns.left.length];
|
|
80
|
-
(_gridRootRef$current = gridRootRef.current) == null || _gridRootRef$current.style.setProperty('--DataGrid-offsetTop', `${top}px`);
|
|
81
|
-
(_gridRootRef$current2 = gridRootRef.current) == null || _gridRootRef$current2.style.setProperty('--DataGrid-offsetLeft', `${left}px`);
|
|
82
|
-
}, [apiRef, gridRootRef, theme.direction, columnPositions, pinnedColumns.left.length, renderContext]);
|
|
83
75
|
const updateRenderContext = React.useCallback((nextRenderContext, rawRenderContext) => {
|
|
84
76
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
85
77
|
return;
|
|
86
78
|
}
|
|
87
79
|
const didRowsIntervalChange = nextRenderContext.firstRowIndex !== previousRowContext.current.firstRowIndex || nextRenderContext.lastRowIndex !== previousRowContext.current.lastRowIndex;
|
|
80
|
+
const nextOffsets = computeOffsets(apiRef, nextRenderContext, theme.direction, pinnedColumns.left.length);
|
|
88
81
|
apiRef.current.setState(state => {
|
|
89
82
|
return _extends({}, state, {
|
|
90
83
|
virtualization: _extends({}, state.virtualization, {
|
|
91
|
-
renderContext: nextRenderContext
|
|
84
|
+
renderContext: nextRenderContext,
|
|
85
|
+
offsets: nextOffsets
|
|
92
86
|
})
|
|
93
87
|
});
|
|
94
88
|
});
|
|
@@ -102,7 +96,7 @@ export const useGridVirtualScroller = () => {
|
|
|
102
96
|
}
|
|
103
97
|
previousContext.current = rawRenderContext;
|
|
104
98
|
prevTotalWidth.current = dimensions.columnsTotalWidth;
|
|
105
|
-
}, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
|
|
99
|
+
}, [apiRef, pinnedColumns.left.length, theme.direction, dimensions.isReady, dimensions.columnsTotalWidth]);
|
|
106
100
|
const triggerUpdateRenderContext = () => {
|
|
107
101
|
const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
|
|
108
102
|
const [nextRenderContext, rawRenderContext] = computeRenderContext(inputs, scrollPosition);
|
|
@@ -300,6 +294,7 @@ export const useGridVirtualScroller = () => {
|
|
|
300
294
|
firstColumnToRender: firstColumnToRender,
|
|
301
295
|
lastColumnToRender: lastColumnToRender,
|
|
302
296
|
selected: isSelected,
|
|
297
|
+
offsets: offsets,
|
|
303
298
|
dimensions: dimensions,
|
|
304
299
|
isFirstVisible: isFirstVisible,
|
|
305
300
|
isLastVisible: isLastVisible,
|
|
@@ -347,10 +342,6 @@ export const useGridVirtualScroller = () => {
|
|
|
347
342
|
// TODO a scroll reset should not be necessary
|
|
348
343
|
scrollerRef.current.scrollLeft = 0;
|
|
349
344
|
scrollerRef.current.scrollTop = 0;
|
|
350
|
-
} else {
|
|
351
|
-
var _gridRootRef$current3, _gridRootRef$current4;
|
|
352
|
-
(_gridRootRef$current3 = gridRootRef.current) == null || _gridRootRef$current3.style.setProperty('--DataGrid-offsetTop', '0px');
|
|
353
|
-
(_gridRootRef$current4 = gridRootRef.current) == null || _gridRootRef$current4.style.setProperty('--DataGrid-offsetLeft', '0px');
|
|
354
345
|
}
|
|
355
346
|
}, [enabled, gridRootRef, scrollerRef]);
|
|
356
347
|
useRunOnce(outerSize.width !== 0, () => {
|
|
@@ -599,4 +590,16 @@ export function areRenderContextsEqual(context1, context2) {
|
|
|
599
590
|
return true;
|
|
600
591
|
}
|
|
601
592
|
return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
|
|
593
|
+
}
|
|
594
|
+
function computeOffsets(apiRef, renderContext, direction, pinnedLeftLength) {
|
|
595
|
+
var _rowPositions$renderC, _columnPositions$rend, _columnPositions$pinn;
|
|
596
|
+
const factor = direction === 'ltr' ? 1 : -1;
|
|
597
|
+
const rowPositions = gridRowsMetaSelector(apiRef.current.state).positions;
|
|
598
|
+
const columnPositions = gridColumnPositionsSelector(apiRef);
|
|
599
|
+
const top = (_rowPositions$renderC = rowPositions[renderContext.firstRowIndex]) != null ? _rowPositions$renderC : 0;
|
|
600
|
+
const left = factor * ((_columnPositions$rend = columnPositions[renderContext.firstColumnIndex]) != null ? _columnPositions$rend : 0) - ((_columnPositions$pinn = columnPositions[pinnedLeftLength]) != null ? _columnPositions$pinn : 0);
|
|
601
|
+
return {
|
|
602
|
+
top,
|
|
603
|
+
left
|
|
604
|
+
};
|
|
602
605
|
}
|
|
@@ -8,6 +8,14 @@ export type GridVirtualizationState = {
|
|
|
8
8
|
enabled: boolean;
|
|
9
9
|
enabledForColumns: boolean;
|
|
10
10
|
renderContext: GridRenderContext;
|
|
11
|
+
offsets: {
|
|
12
|
+
top: number;
|
|
13
|
+
left: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const EMPTY_OFFSETS: {
|
|
17
|
+
top: number;
|
|
18
|
+
left: number;
|
|
11
19
|
};
|
|
12
20
|
export declare const EMPTY_RENDER_CONTEXT: {
|
|
13
21
|
firstRowIndex: number;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
|
+
export const EMPTY_OFFSETS = {
|
|
5
|
+
top: 0,
|
|
6
|
+
left: 0
|
|
7
|
+
};
|
|
4
8
|
export const EMPTY_RENDER_CONTEXT = {
|
|
5
9
|
firstRowIndex: 0,
|
|
6
10
|
lastRowIndex: 0,
|
|
@@ -11,7 +15,8 @@ export const virtualizationStateInitializer = (state, props) => {
|
|
|
11
15
|
const virtualization = {
|
|
12
16
|
enabled: !props.disableVirtualization,
|
|
13
17
|
enabledForColumns: true,
|
|
14
|
-
renderContext: EMPTY_RENDER_CONTEXT
|
|
18
|
+
renderContext: EMPTY_RENDER_CONTEXT,
|
|
19
|
+
offsets: EMPTY_OFFSETS
|
|
15
20
|
};
|
|
16
21
|
return _extends({}, state, {
|
|
17
22
|
virtualization
|
package/index.js
CHANGED
|
@@ -498,12 +498,6 @@ DataGridRaw.propTypes = {
|
|
|
498
498
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
499
499
|
*/
|
|
500
500
|
onRowDoubleClick: PropTypes.func,
|
|
501
|
-
/**
|
|
502
|
-
* Callback fired when the row changes are committed.
|
|
503
|
-
* @param {GridRowId} id The row id.
|
|
504
|
-
* @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
|
|
505
|
-
*/
|
|
506
|
-
onRowEditCommit: PropTypes.func,
|
|
507
501
|
/**
|
|
508
502
|
* Callback fired when the row turns to edit mode.
|
|
509
503
|
* @param {GridRowParams} params With all properties from [[GridRowParams]].
|
|
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "pinnedColumns", "dimensions", "firstColumnToRender", "lastColumnToRender", "isFirstVisible", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
|
|
5
|
+
var _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "pinnedColumns", "offsets", "dimensions", "firstColumnToRender", "lastColumnToRender", "isFirstVisible", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
@@ -65,6 +65,7 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
65
65
|
visibleColumns = props.visibleColumns,
|
|
66
66
|
renderedColumns = props.renderedColumns,
|
|
67
67
|
pinnedColumns = props.pinnedColumns,
|
|
68
|
+
offsets = props.offsets,
|
|
68
69
|
dimensions = props.dimensions,
|
|
69
70
|
firstColumnToRender = props.firstColumnToRender,
|
|
70
71
|
lastColumnToRender = props.lastColumnToRender,
|
|
@@ -366,8 +367,11 @@ var GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
366
367
|
style: style
|
|
367
368
|
}, eventHandlers, other, {
|
|
368
369
|
children: [leftCells, /*#__PURE__*/_jsx("div", {
|
|
370
|
+
role: "presentation",
|
|
369
371
|
className: gridClasses.cellOffsetLeft,
|
|
370
|
-
|
|
372
|
+
style: {
|
|
373
|
+
width: offsets.left
|
|
374
|
+
}
|
|
371
375
|
}), cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
|
|
372
376
|
width: emptyCellWidth
|
|
373
377
|
}), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
@@ -436,6 +440,10 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
436
440
|
isLastVisible: PropTypes.bool.isRequired,
|
|
437
441
|
isNotVisible: PropTypes.bool,
|
|
438
442
|
lastColumnToRender: PropTypes.number.isRequired,
|
|
443
|
+
offsets: PropTypes.shape({
|
|
444
|
+
left: PropTypes.number.isRequired,
|
|
445
|
+
top: PropTypes.number.isRequired
|
|
446
|
+
}).isRequired,
|
|
439
447
|
onClick: PropTypes.func,
|
|
440
448
|
onDoubleClick: PropTypes.func,
|
|
441
449
|
onMouseEnter: PropTypes.func,
|
|
@@ -66,8 +66,6 @@ export var GridRootStyles = styled('div', {
|
|
|
66
66
|
'--DataGrid-width': '0px',
|
|
67
67
|
'--DataGrid-hasScrollX': '0',
|
|
68
68
|
'--DataGrid-hasScrollY': '0',
|
|
69
|
-
'--DataGrid-offsetTop': '0px',
|
|
70
|
-
'--DataGrid-offsetLeft': '0px',
|
|
71
69
|
'--DataGrid-scrollbarSize': '10px',
|
|
72
70
|
'--DataGrid-rowWidth': '0px',
|
|
73
71
|
'--DataGrid-columnsTotalWidth': '0px',
|
|
@@ -339,8 +337,7 @@ export var GridRootStyles = styled('div', {
|
|
|
339
337
|
backgroundColor: pinnedSelectedHoverBackground
|
|
340
338
|
})))), "& .".concat(c.cellOffsetLeft), {
|
|
341
339
|
flex: '0 0 auto',
|
|
342
|
-
display: 'inline-block'
|
|
343
|
-
width: 'var(--DataGrid-offsetLeft)'
|
|
340
|
+
display: 'inline-block'
|
|
344
341
|
}), "& .".concat(c.columnHeaderDraggableContainer), {
|
|
345
342
|
display: 'flex',
|
|
346
343
|
width: '100%',
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
-
var _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "InputLabelProps"];
|
|
5
|
+
var _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "variant", "InputLabelProps"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { refType, unstable_useId as useId } from '@mui/utils';
|
|
@@ -27,6 +27,8 @@ function GridFilterInputBoolean(props) {
|
|
|
27
27
|
clearButton = props.clearButton,
|
|
28
28
|
tabIndex = props.tabIndex,
|
|
29
29
|
labelProp = props.label,
|
|
30
|
+
_props$variant = props.variant,
|
|
31
|
+
variant = _props$variant === void 0 ? 'standard' : _props$variant,
|
|
30
32
|
InputLabelProps = props.InputLabelProps,
|
|
31
33
|
others = _objectWithoutProperties(props, _excluded);
|
|
32
34
|
var _React$useState = React.useState(item.value || ''),
|
|
@@ -56,7 +58,7 @@ function GridFilterInputBoolean(props) {
|
|
|
56
58
|
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseInputLabel, {
|
|
57
59
|
id: labelId,
|
|
58
60
|
shrink: true,
|
|
59
|
-
variant:
|
|
61
|
+
variant: variant,
|
|
60
62
|
children: label
|
|
61
63
|
})), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
|
|
62
64
|
labelId: labelId,
|
|
@@ -64,7 +66,8 @@ function GridFilterInputBoolean(props) {
|
|
|
64
66
|
label: label,
|
|
65
67
|
value: filterValueState,
|
|
66
68
|
onChange: onFilterChange,
|
|
67
|
-
variant:
|
|
69
|
+
variant: variant,
|
|
70
|
+
notched: variant === 'outlined' ? true : undefined,
|
|
68
71
|
native: isSelectNative,
|
|
69
72
|
displayEmpty: true,
|
|
70
73
|
inputProps: {
|
|
@@ -2,7 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
-
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "isFilterActive", "clearButton", "InputLabelProps"];
|
|
5
|
+
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "variant", "isFilterActive", "clearButton", "InputLabelProps"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { unstable_useId as useId } from '@mui/utils';
|
|
@@ -50,6 +50,8 @@ function GridFilterInputSingleSelect(props) {
|
|
|
50
50
|
placeholder = props.placeholder,
|
|
51
51
|
tabIndex = props.tabIndex,
|
|
52
52
|
labelProp = props.label,
|
|
53
|
+
_props$variant = props.variant,
|
|
54
|
+
variant = _props$variant === void 0 ? 'standard' : _props$variant,
|
|
53
55
|
isFilterActive = props.isFilterActive,
|
|
54
56
|
clearButton = props.clearButton,
|
|
55
57
|
InputLabelProps = props.InputLabelProps,
|
|
@@ -91,7 +93,7 @@ function GridFilterInputSingleSelect(props) {
|
|
|
91
93
|
id: labelId,
|
|
92
94
|
htmlFor: id,
|
|
93
95
|
shrink: true,
|
|
94
|
-
variant:
|
|
96
|
+
variant: variant,
|
|
95
97
|
children: label
|
|
96
98
|
})), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
|
|
97
99
|
id: id,
|
|
@@ -99,14 +101,15 @@ function GridFilterInputSingleSelect(props) {
|
|
|
99
101
|
labelId: labelId,
|
|
100
102
|
value: filterValue,
|
|
101
103
|
onChange: onFilterChange,
|
|
102
|
-
variant:
|
|
104
|
+
variant: variant,
|
|
103
105
|
type: type || 'text',
|
|
104
106
|
inputProps: {
|
|
105
107
|
tabIndex: tabIndex,
|
|
106
108
|
ref: focusElementRef,
|
|
107
109
|
placeholder: placeholder != null ? placeholder : apiRef.current.getLocaleText('filterPanelInputPlaceholder')
|
|
108
110
|
},
|
|
109
|
-
native: isSelectNative
|
|
111
|
+
native: isSelectNative,
|
|
112
|
+
notched: variant === 'outlined' ? true : undefined
|
|
110
113
|
}, others /* FIXME: typing error */, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseSelect, {
|
|
111
114
|
children: renderSingleSelectOptions({
|
|
112
115
|
column: resolvedColumn,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps"];
|
|
4
|
+
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps", "variant"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { unstable_useId as useId } from '@mui/utils';
|
|
@@ -20,6 +20,8 @@ function GridFilterInputValue(props) {
|
|
|
20
20
|
isFilterActive = props.isFilterActive,
|
|
21
21
|
clearButton = props.clearButton,
|
|
22
22
|
InputProps = props.InputProps,
|
|
23
|
+
_props$variant = props.variant,
|
|
24
|
+
variant = _props$variant === void 0 ? 'standard' : _props$variant,
|
|
23
25
|
others = _objectWithoutProperties(props, _excluded);
|
|
24
26
|
var filterTimeout = useTimeout();
|
|
25
27
|
var _React$useState = React.useState((_item$value = item.value) != null ? _item$value : ''),
|
|
@@ -58,7 +60,7 @@ function GridFilterInputValue(props) {
|
|
|
58
60
|
placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
|
|
59
61
|
value: filterValueState,
|
|
60
62
|
onChange: onFilterChange,
|
|
61
|
-
variant:
|
|
63
|
+
variant: variant,
|
|
62
64
|
type: type || 'text',
|
|
63
65
|
InputProps: _extends({}, applying || clearButton ? {
|
|
64
66
|
endAdornment: applying ? /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {
|
|
@@ -5,6 +5,9 @@ import * as React from 'react';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { styled } from '@mui/system';
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
9
|
+
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
10
|
+
import { gridOffsetsSelector } from '../../hooks/features/virtualization';
|
|
8
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
9
12
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
10
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -25,18 +28,22 @@ var VirtualScrollerRenderZoneRoot = styled('div', {
|
|
|
25
28
|
position: 'absolute',
|
|
26
29
|
display: 'flex',
|
|
27
30
|
// Prevents margin collapsing when using `getRowSpacing`
|
|
28
|
-
flexDirection: 'column'
|
|
29
|
-
transform: 'translate3d(0, var(--DataGrid-offsetTop), 0)'
|
|
31
|
+
flexDirection: 'column'
|
|
30
32
|
});
|
|
31
33
|
var GridVirtualScrollerRenderZone = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerRenderZone(props, ref) {
|
|
32
34
|
var className = props.className,
|
|
33
35
|
other = _objectWithoutProperties(props, _excluded);
|
|
36
|
+
var apiRef = useGridApiContext();
|
|
34
37
|
var rootProps = useGridRootProps();
|
|
35
38
|
var classes = useUtilityClasses(rootProps);
|
|
39
|
+
var offsets = useGridSelector(apiRef, gridOffsetsSelector);
|
|
36
40
|
return /*#__PURE__*/_jsx(VirtualScrollerRenderZoneRoot, _extends({
|
|
37
41
|
ref: ref,
|
|
38
42
|
className: clsx(classes.root, className),
|
|
39
|
-
ownerState: rootProps
|
|
43
|
+
ownerState: rootProps,
|
|
44
|
+
style: {
|
|
45
|
+
transform: "translate3d(0, ".concat(offsets.top, "px, 0)")
|
|
46
|
+
}
|
|
40
47
|
}, other));
|
|
41
48
|
});
|
|
42
49
|
export { GridVirtualScrollerRenderZone };
|
|
@@ -4,11 +4,12 @@ import * as React from 'react';
|
|
|
4
4
|
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { useGridSelector } from '../../utils';
|
|
7
|
+
import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
7
8
|
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
|
|
8
9
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
9
10
|
import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
|
|
10
11
|
import { gridDimensionsSelector } from '../dimensions';
|
|
11
|
-
import { gridRenderContextColumnsSelector, gridVirtualizationColumnEnabledSelector } from '../virtualization';
|
|
12
|
+
import { gridOffsetsSelector, gridRenderContextColumnsSelector, gridVirtualizationColumnEnabledSelector } from '../virtualization';
|
|
12
13
|
import { GridColumnGroupHeader } from '../../../components/columnHeaders/GridColumnGroupHeader';
|
|
13
14
|
import { GridPinnedColumnPosition, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
|
|
14
15
|
import { GridScrollbarFillerCell as ScrollbarFiller } from '../../../components/GridScrollbarFillerCell';
|
|
@@ -25,21 +26,12 @@ var SpaceFiller = styled('div')({
|
|
|
25
26
|
export var GridColumnHeaderRow = styled('div', {
|
|
26
27
|
name: 'MuiDataGrid',
|
|
27
28
|
slot: 'ColumnHeaderRow',
|
|
28
|
-
overridesResolver: function overridesResolver(
|
|
29
|
+
overridesResolver: function overridesResolver(_, styles) {
|
|
29
30
|
return styles.columnHeaderRow;
|
|
30
31
|
}
|
|
31
|
-
})(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_ref$ownerState$param2 = _ref$ownerState$param === void 0 ? {} : _ref$ownerState$param,
|
|
35
|
-
position = _ref$ownerState$param2.position,
|
|
36
|
-
_ref$ownerState$leftO = _ref$ownerState.leftOverflow,
|
|
37
|
-
leftOverflow = _ref$ownerState$leftO === void 0 ? 0 : _ref$ownerState$leftO;
|
|
38
|
-
return {
|
|
39
|
-
display: 'flex',
|
|
40
|
-
height: 'var(--DataGrid-headerHeight)',
|
|
41
|
-
transform: position === undefined ? "translate3d(".concat(leftOverflow !== 0 ? "calc(var(--DataGrid-offsetLeft) - ".concat(leftOverflow, "px)") : 'var(--DataGrid-offsetLeft)', ", 0, 0)") : undefined
|
|
42
|
-
};
|
|
32
|
+
})({
|
|
33
|
+
display: 'flex',
|
|
34
|
+
height: 'var(--DataGrid-headerHeight)'
|
|
43
35
|
});
|
|
44
36
|
export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
45
37
|
var innerRefProp = props.innerRef,
|
|
@@ -64,10 +56,12 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
64
56
|
resizeCol = _React$useState4[0],
|
|
65
57
|
setResizeCol = _React$useState4[1];
|
|
66
58
|
var apiRef = useGridPrivateApiContext();
|
|
59
|
+
var rootProps = useGridRootProps();
|
|
67
60
|
var hasVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
|
|
68
61
|
var innerRef = React.useRef(null);
|
|
69
62
|
var handleInnerRef = useForkRef(innerRefProp, innerRef);
|
|
70
63
|
var dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
64
|
+
var offsets = useGridSelector(apiRef, gridOffsetsSelector);
|
|
71
65
|
var renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
|
|
72
66
|
var visiblePinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
73
67
|
React.useEffect(function () {
|
|
@@ -92,11 +86,11 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
92
86
|
|
|
93
87
|
// Helper for computation common between getColumnHeaders and getColumnGroupHeaders
|
|
94
88
|
var getColumnsToRender = function getColumnsToRender(params) {
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
currentContext =
|
|
98
|
-
|
|
99
|
-
maxLastColumn =
|
|
89
|
+
var _ref = params || {},
|
|
90
|
+
_ref$renderContext = _ref.renderContext,
|
|
91
|
+
currentContext = _ref$renderContext === void 0 ? renderContext : _ref$renderContext,
|
|
92
|
+
_ref$maxLastColumn = _ref.maxLastColumn,
|
|
93
|
+
maxLastColumn = _ref$maxLastColumn === void 0 ? visibleColumns.length : _ref$maxLastColumn;
|
|
100
94
|
var firstColumnToRender = !hasVirtualization ? 0 : currentContext.firstColumnIndex;
|
|
101
95
|
var lastColumnToRender = !hasVirtualization ? maxLastColumn : currentContext.lastColumnIndex;
|
|
102
96
|
var renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
@@ -106,12 +100,19 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
106
100
|
lastColumnToRender: lastColumnToRender
|
|
107
101
|
};
|
|
108
102
|
};
|
|
109
|
-
var
|
|
110
|
-
var borderTop = arguments.length >
|
|
103
|
+
var getFillers = function getFillers(params, children, leftOverflow) {
|
|
104
|
+
var borderTop = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
111
105
|
var isPinnedRight = (params == null ? void 0 : params.position) === GridPinnedColumnPosition.RIGHT;
|
|
112
|
-
var
|
|
106
|
+
var isNotPinned = (params == null ? void 0 : params.position) === undefined;
|
|
107
|
+
var hasScrollbarFiller = visiblePinnedColumns.right.length > 0 && isPinnedRight || visiblePinnedColumns.right.length === 0 && isNotPinned;
|
|
108
|
+
var leftOffsetWidth = offsets.left - leftOverflow;
|
|
113
109
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
114
|
-
children: [
|
|
110
|
+
children: [isNotPinned && /*#__PURE__*/_jsx("div", {
|
|
111
|
+
role: "presentation",
|
|
112
|
+
style: {
|
|
113
|
+
width: leftOffsetWidth
|
|
114
|
+
}
|
|
115
|
+
}), children, isNotPinned && /*#__PURE__*/_jsx(SpaceFiller, {
|
|
115
116
|
className: gridClasses.columnHeader
|
|
116
117
|
}), hasScrollbarFiller && /*#__PURE__*/_jsx(ScrollbarFiller, {
|
|
117
118
|
header: true,
|
|
@@ -145,13 +146,11 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
145
146
|
tabIndex: tabIndex
|
|
146
147
|
}, other), colDef.field));
|
|
147
148
|
}
|
|
148
|
-
return /*#__PURE__*/
|
|
149
|
+
return /*#__PURE__*/_jsx(GridColumnHeaderRow, {
|
|
149
150
|
role: "row",
|
|
150
151
|
"aria-rowindex": headerGroupingMaxDepth + 1,
|
|
151
|
-
ownerState:
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
children: [columns, getFiller(params)]
|
|
152
|
+
ownerState: rootProps,
|
|
153
|
+
children: getFillers(params, columns, 0)
|
|
155
154
|
});
|
|
156
155
|
};
|
|
157
156
|
var getColumnGroupHeaders = function getColumnGroupHeaders(params) {
|
|
@@ -171,16 +170,16 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
171
170
|
var rowStructure = columnGroupsHeaderStructure[depth];
|
|
172
171
|
var firstColumnFieldToRender = visibleColumns[firstColumnToRender].field;
|
|
173
172
|
var firstGroupToRender = (_apiRef$current$getCo = apiRef.current.getColumnGroupPath(firstColumnFieldToRender)[depth]) != null ? _apiRef$current$getCo : null;
|
|
174
|
-
var firstGroupIndex = rowStructure.findIndex(function (
|
|
175
|
-
var groupId =
|
|
176
|
-
columnFields =
|
|
173
|
+
var firstGroupIndex = rowStructure.findIndex(function (_ref3) {
|
|
174
|
+
var groupId = _ref3.groupId,
|
|
175
|
+
columnFields = _ref3.columnFields;
|
|
177
176
|
return groupId === firstGroupToRender && columnFields.includes(firstColumnFieldToRender);
|
|
178
177
|
});
|
|
179
178
|
var lastColumnFieldToRender = visibleColumns[lastColumnToRender - 1].field;
|
|
180
179
|
var lastGroupToRender = (_apiRef$current$getCo2 = apiRef.current.getColumnGroupPath(lastColumnFieldToRender)[depth]) != null ? _apiRef$current$getCo2 : null;
|
|
181
|
-
var lastGroupIndex = rowStructure.findIndex(function (
|
|
182
|
-
var groupId =
|
|
183
|
-
columnFields =
|
|
180
|
+
var lastGroupIndex = rowStructure.findIndex(function (_ref4) {
|
|
181
|
+
var groupId = _ref4.groupId,
|
|
182
|
+
columnFields = _ref4.columnFields;
|
|
184
183
|
return groupId === lastGroupToRender && columnFields.includes(lastColumnFieldToRender);
|
|
185
184
|
});
|
|
186
185
|
var visibleColumnGroupHeader = rowStructure.slice(firstGroupIndex, lastGroupIndex + 1).map(function (groupStructure) {
|
|
@@ -200,9 +199,9 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
200
199
|
return acc + ((_column$computedWidth = column.computedWidth) != null ? _column$computedWidth : 0);
|
|
201
200
|
}, 0);
|
|
202
201
|
var columnIndex = firstColumnToRender;
|
|
203
|
-
var elements = visibleColumnGroupHeader.map(function (
|
|
204
|
-
var groupId =
|
|
205
|
-
columnFields =
|
|
202
|
+
var elements = visibleColumnGroupHeader.map(function (_ref5) {
|
|
203
|
+
var groupId = _ref5.groupId,
|
|
204
|
+
columnFields = _ref5.columnFields;
|
|
206
205
|
var hasFocus = columnGroupHeaderFocus !== null && columnGroupHeaderFocus.depth === depth && columnFields.includes(columnGroupHeaderFocus.field);
|
|
207
206
|
var tabIndex = columnGroupHeaderTabIndexState !== null && columnGroupHeaderTabIndexState.depth === depth && columnFields.includes(columnGroupHeaderTabIndexState.field) ? 0 : -1;
|
|
208
207
|
var headerInfo = {
|
|
@@ -227,40 +226,38 @@ export var useGridColumnHeaders = function useGridColumnHeaders(props) {
|
|
|
227
226
|
_loop(depth);
|
|
228
227
|
}
|
|
229
228
|
headerToRender.forEach(function (depthInfo, depthIndex) {
|
|
230
|
-
|
|
229
|
+
var children = depthInfo.elements.map(function (_ref2, groupIndex) {
|
|
230
|
+
var groupId = _ref2.groupId,
|
|
231
|
+
width = _ref2.width,
|
|
232
|
+
fields = _ref2.fields,
|
|
233
|
+
colIndex = _ref2.colIndex,
|
|
234
|
+
hasFocus = _ref2.hasFocus,
|
|
235
|
+
tabIndex = _ref2.tabIndex;
|
|
236
|
+
return /*#__PURE__*/_jsx(GridColumnGroupHeader, {
|
|
237
|
+
groupId: groupId,
|
|
238
|
+
width: width,
|
|
239
|
+
fields: fields,
|
|
240
|
+
colIndex: colIndex,
|
|
241
|
+
depth: depthIndex,
|
|
242
|
+
isLastColumn: colIndex === visibleColumns.length - fields.length,
|
|
243
|
+
maxDepth: headerToRender.length,
|
|
244
|
+
height: dimensions.headerHeight,
|
|
245
|
+
hasFocus: hasFocus,
|
|
246
|
+
tabIndex: tabIndex
|
|
247
|
+
}, groupIndex);
|
|
248
|
+
});
|
|
249
|
+
columns.push( /*#__PURE__*/_jsx(GridColumnHeaderRow, {
|
|
231
250
|
role: "row",
|
|
232
251
|
"aria-rowindex": depthIndex + 1,
|
|
233
|
-
ownerState:
|
|
234
|
-
|
|
235
|
-
leftOverflow: depthInfo.leftOverflow
|
|
236
|
-
},
|
|
237
|
-
children: [depthInfo.elements.map(function (_ref3, groupIndex) {
|
|
238
|
-
var groupId = _ref3.groupId,
|
|
239
|
-
width = _ref3.width,
|
|
240
|
-
fields = _ref3.fields,
|
|
241
|
-
colIndex = _ref3.colIndex,
|
|
242
|
-
hasFocus = _ref3.hasFocus,
|
|
243
|
-
tabIndex = _ref3.tabIndex;
|
|
244
|
-
return /*#__PURE__*/_jsx(GridColumnGroupHeader, {
|
|
245
|
-
groupId: groupId,
|
|
246
|
-
width: width,
|
|
247
|
-
fields: fields,
|
|
248
|
-
colIndex: colIndex,
|
|
249
|
-
depth: depthIndex,
|
|
250
|
-
isLastColumn: colIndex === visibleColumns.length - fields.length,
|
|
251
|
-
maxDepth: headerToRender.length,
|
|
252
|
-
height: dimensions.headerHeight,
|
|
253
|
-
hasFocus: hasFocus,
|
|
254
|
-
tabIndex: tabIndex
|
|
255
|
-
}, groupIndex);
|
|
256
|
-
}), getFiller(params)]
|
|
252
|
+
ownerState: rootProps,
|
|
253
|
+
children: getFillers(params, children, depthInfo.leftOverflow)
|
|
257
254
|
}, depthIndex));
|
|
258
255
|
});
|
|
259
256
|
return columns;
|
|
260
257
|
};
|
|
261
258
|
return {
|
|
262
259
|
renderContext: renderContext,
|
|
263
|
-
|
|
260
|
+
getFillers: getFillers,
|
|
264
261
|
getColumnHeaders: getColumnHeaders,
|
|
265
262
|
getColumnsToRender: getColumnsToRender,
|
|
266
263
|
getColumnGroupHeaders: getColumnGroupHeaders,
|
|
@@ -32,6 +32,15 @@ export var gridRenderContextSelector = createSelector(gridVirtualizationSelector
|
|
|
32
32
|
return state.renderContext;
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Get the offsets
|
|
37
|
+
* @category Virtualization
|
|
38
|
+
* @ignore - do not document.
|
|
39
|
+
*/
|
|
40
|
+
export var gridOffsetsSelector = createSelector(gridVirtualizationSelector, function (state) {
|
|
41
|
+
return state.offsets;
|
|
42
|
+
});
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* Get the render context, with only columns filled in.
|
|
37
46
|
* This is cached, so it can be used to only re-render when the column interval changes.
|