@mui/x-data-grid 6.10.1 → 6.11.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 +156 -0
- package/DataGrid/DataGrid.d.ts +1 -1
- package/DataGrid/DataGrid.js +2 -1
- package/colDef/utils.d.ts +1 -1
- package/colDef/utils.js +1 -1
- package/components/GridRow.d.ts +2 -0
- package/components/GridRow.js +50 -22
- package/components/cell/GridCell.d.ts +2 -2
- package/components/cell/GridCell.js +95 -60
- package/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
- package/components/containers/GridMainContainer.js +10 -3
- package/components/containers/GridRoot.js +7 -13
- package/components/containers/GridRootStyles.js +1 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +7 -4
- package/hooks/features/virtualization/useGridVirtualScroller.js +75 -8
- package/hooks/utils/useGridAriaAttributes.d.ts +6 -0
- package/hooks/utils/useGridAriaAttributes.js +25 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +2 -1
- package/legacy/colDef/utils.js +1 -1
- package/legacy/components/GridRow.js +47 -21
- package/legacy/components/cell/GridCell.js +95 -60
- package/legacy/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
- package/legacy/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
- package/legacy/components/containers/GridMainContainer.js +10 -3
- package/legacy/components/containers/GridRoot.js +7 -13
- package/legacy/components/containers/GridRootStyles.js +1 -0
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +79 -8
- package/legacy/hooks/utils/useGridAriaAttributes.js +25 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/locales/fiFI.js +29 -31
- package/legacy/locales/heIL.js +26 -29
- package/legacy/locales/itIT.js +34 -38
- package/locales/fiFI.js +29 -31
- package/locales/heIL.js +26 -29
- package/locales/itIT.js +34 -38
- package/models/gridFilterOperator.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +7 -1
- package/modern/DataGrid/DataGrid.js +2 -1
- package/modern/colDef/utils.js +1 -1
- package/modern/components/GridRow.js +50 -22
- package/modern/components/cell/GridCell.js +92 -57
- package/modern/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
- package/modern/components/containers/GridMainContainer.js +9 -3
- package/modern/components/containers/GridRoot.js +6 -13
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +75 -8
- package/modern/hooks/utils/useGridAriaAttributes.js +24 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/locales/fiFI.js +29 -31
- package/modern/locales/heIL.js +26 -29
- package/modern/locales/itIT.js +34 -38
- package/node/DataGrid/DataGrid.js +2 -1
- package/node/colDef/utils.js +1 -1
- package/node/components/GridRow.js +50 -22
- package/node/components/cell/GridCell.js +92 -57
- package/node/components/columnHeaders/GridBaseColumnHeaders.js +3 -1
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
- package/node/components/containers/GridMainContainer.js +10 -3
- package/node/components/containers/GridRoot.js +6 -13
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/hooks/features/columns/gridColumnsUtils.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +75 -8
- package/node/hooks/utils/useGridAriaAttributes.js +31 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +7 -0
- package/node/locales/fiFI.js +29 -31
- package/node/locales/heIL.js +26 -29
- package/node/locales/itIT.js +34 -38
- package/package.json +2 -2
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["changeReason", "unstable_updateValueOnRender"],
|
|
4
|
-
_excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
5
|
-
_excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
4
|
+
_excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
5
|
+
_excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
6
6
|
_excluded4 = ["changeReason", "unstable_updateValueOnRender"];
|
|
7
|
-
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
8
7
|
import * as React from 'react';
|
|
9
8
|
import PropTypes from 'prop-types';
|
|
10
9
|
import clsx from 'clsx';
|
|
@@ -150,7 +149,7 @@ var GridCellWrapper = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
150
149
|
return /*#__PURE__*/React.createElement(CellComponent, cellProps);
|
|
151
150
|
});
|
|
152
151
|
var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
153
|
-
var _rootProps$experiment;
|
|
152
|
+
var _rootProps$experiment, _rootProps$experiment2;
|
|
154
153
|
var align = props.align,
|
|
155
154
|
childrenProp = props.children,
|
|
156
155
|
editCellState = props.editCellState,
|
|
@@ -173,6 +172,7 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
173
172
|
row = props.row,
|
|
174
173
|
colSpan = props.colSpan,
|
|
175
174
|
disableDragEvents = props.disableDragEvents,
|
|
175
|
+
isNotVisible = props.isNotVisible,
|
|
176
176
|
onClick = props.onClick,
|
|
177
177
|
onDoubleClick = props.onDoubleClick,
|
|
178
178
|
onMouseDown = props.onMouseDown,
|
|
@@ -228,13 +228,23 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
}, [apiRef, field, rowId]);
|
|
231
|
-
var style = {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
231
|
+
var style = React.useMemo(function () {
|
|
232
|
+
if (isNotVisible) {
|
|
233
|
+
return {
|
|
234
|
+
padding: 0,
|
|
235
|
+
opacity: 0,
|
|
236
|
+
width: 0
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
var cellStyle = {
|
|
240
|
+
minWidth: width,
|
|
241
|
+
maxWidth: width,
|
|
242
|
+
minHeight: height,
|
|
243
|
+
maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
|
|
244
|
+
};
|
|
237
245
|
|
|
246
|
+
return cellStyle;
|
|
247
|
+
}, [width, height, isNotVisible]);
|
|
238
248
|
React.useEffect(function () {
|
|
239
249
|
if (!hasFocus || cellMode === GridCellModes.Edit) {
|
|
240
250
|
return;
|
|
@@ -277,6 +287,7 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
277
287
|
children = /*#__PURE__*/_jsx("div", {
|
|
278
288
|
className: classes.content,
|
|
279
289
|
title: valueString,
|
|
290
|
+
role: "presentation",
|
|
280
291
|
children: valueString
|
|
281
292
|
});
|
|
282
293
|
}
|
|
@@ -289,27 +300,32 @@ var GridCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
289
300
|
onDragEnter: publish('cellDragEnter', onDragEnter),
|
|
290
301
|
onDragOver: publish('cellDragOver', onDragOver)
|
|
291
302
|
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
"
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
303
|
+
var ariaV7 = (_rootProps$experiment2 = rootProps.experimentalFeatures) == null ? void 0 : _rootProps$experiment2.ariaV7;
|
|
304
|
+
return (
|
|
305
|
+
/*#__PURE__*/
|
|
306
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
307
|
+
_jsx("div", _extends({
|
|
308
|
+
ref: handleRef,
|
|
309
|
+
className: clsx(className, classes.root),
|
|
310
|
+
role: ariaV7 ? 'gridcell' : 'cell',
|
|
311
|
+
"data-field": field,
|
|
312
|
+
"data-colindex": colIndex,
|
|
313
|
+
"aria-colindex": colIndex + 1,
|
|
314
|
+
"aria-colspan": colSpan,
|
|
315
|
+
style: style,
|
|
316
|
+
tabIndex: tabIndex,
|
|
317
|
+
onClick: publish('cellClick', onClick),
|
|
318
|
+
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
319
|
+
onMouseOver: publish('cellMouseOver', onMouseOver),
|
|
320
|
+
onMouseDown: publishMouseDown('cellMouseDown'),
|
|
321
|
+
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
322
|
+
onKeyDown: publish('cellKeyDown', onKeyDown),
|
|
323
|
+
onKeyUp: publish('cellKeyUp', onKeyUp)
|
|
324
|
+
}, draggableEventHandlers, other, {
|
|
325
|
+
onFocus: handleFocus,
|
|
326
|
+
children: children
|
|
327
|
+
}))
|
|
328
|
+
);
|
|
313
329
|
});
|
|
314
330
|
var MemoizedCellWrapper = fastMemo(GridCellWrapper);
|
|
315
331
|
process.env.NODE_ENV !== "production" ? GridCellWrapper.propTypes = {
|
|
@@ -354,6 +370,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
354
370
|
isValidating: PropTypes.bool,
|
|
355
371
|
value: PropTypes.any
|
|
356
372
|
}),
|
|
373
|
+
isNotVisible: PropTypes.bool,
|
|
357
374
|
height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
358
375
|
onClick: PropTypes.func,
|
|
359
376
|
onDoubleClick: PropTypes.func,
|
|
@@ -368,7 +385,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
368
385
|
} : void 0;
|
|
369
386
|
export { MemoizedCellWrapper as GridCellWrapper, GridCell };
|
|
370
387
|
var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
371
|
-
var _rootProps$
|
|
388
|
+
var _rootProps$experiment3, _rootProps$experiment4;
|
|
372
389
|
var column = props.column,
|
|
373
390
|
rowId = props.rowId,
|
|
374
391
|
editCellState = props.editCellState,
|
|
@@ -383,6 +400,7 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
383
400
|
row = props.row,
|
|
384
401
|
colSpan = props.colSpan,
|
|
385
402
|
disableDragEvents = props.disableDragEvents,
|
|
403
|
+
isNotVisible = props.isNotVisible,
|
|
386
404
|
onClick = props.onClick,
|
|
387
405
|
onDoubleClick = props.onDoubleClick,
|
|
388
406
|
onMouseDown = props.onMouseDown,
|
|
@@ -480,13 +498,23 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
480
498
|
}
|
|
481
499
|
};
|
|
482
500
|
}, [apiRef, field, rowId]);
|
|
483
|
-
var style = {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
501
|
+
var style = React.useMemo(function () {
|
|
502
|
+
if (isNotVisible) {
|
|
503
|
+
return {
|
|
504
|
+
padding: 0,
|
|
505
|
+
opacity: 0,
|
|
506
|
+
width: 0
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
var cellStyle = {
|
|
510
|
+
minWidth: width,
|
|
511
|
+
maxWidth: width,
|
|
512
|
+
minHeight: height,
|
|
513
|
+
maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
|
|
514
|
+
};
|
|
489
515
|
|
|
516
|
+
return cellStyle;
|
|
517
|
+
}, [width, height, isNotVisible]);
|
|
490
518
|
React.useEffect(function () {
|
|
491
519
|
if (!hasFocus || cellMode === GridCellModes.Edit) {
|
|
492
520
|
return;
|
|
@@ -510,7 +538,7 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
510
538
|
return null;
|
|
511
539
|
}
|
|
512
540
|
var handleFocus = other.onFocus;
|
|
513
|
-
if (process.env.NODE_ENV === 'test' && (_rootProps$
|
|
541
|
+
if (process.env.NODE_ENV === 'test' && (_rootProps$experiment3 = rootProps.experimentalFeatures) != null && _rootProps$experiment3.warnIfFocusStateIsNotSynced) {
|
|
514
542
|
handleFocus = function handleFocus(event) {
|
|
515
543
|
var focusedCell = gridFocusCellSelector(apiRef);
|
|
516
544
|
if ((focusedCell == null ? void 0 : focusedCell.id) === rowId && focusedCell.field === field) {
|
|
@@ -550,6 +578,7 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
550
578
|
children = /*#__PURE__*/_jsx("div", {
|
|
551
579
|
className: classes.content,
|
|
552
580
|
title: valueString,
|
|
581
|
+
role: "presentation",
|
|
553
582
|
children: valueString
|
|
554
583
|
});
|
|
555
584
|
}
|
|
@@ -562,27 +591,32 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
562
591
|
onDragEnter: publish('cellDragEnter', onDragEnter),
|
|
563
592
|
onDragOver: publish('cellDragOver', onDragOver)
|
|
564
593
|
};
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
"
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
594
|
+
var ariaV7 = (_rootProps$experiment4 = rootProps.experimentalFeatures) == null ? void 0 : _rootProps$experiment4.ariaV7;
|
|
595
|
+
return (
|
|
596
|
+
/*#__PURE__*/
|
|
597
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
598
|
+
_jsx("div", _extends({
|
|
599
|
+
ref: handleRef,
|
|
600
|
+
className: clsx(className, classNames, classes.root),
|
|
601
|
+
role: ariaV7 ? 'gridcell' : 'cell',
|
|
602
|
+
"data-field": field,
|
|
603
|
+
"data-colindex": colIndex,
|
|
604
|
+
"aria-colindex": colIndex + 1,
|
|
605
|
+
"aria-colspan": colSpan,
|
|
606
|
+
style: style,
|
|
607
|
+
tabIndex: tabIndex,
|
|
608
|
+
onClick: publish('cellClick', onClick),
|
|
609
|
+
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
610
|
+
onMouseOver: publish('cellMouseOver', onMouseOver),
|
|
611
|
+
onMouseDown: publishMouseDown('cellMouseDown'),
|
|
612
|
+
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
613
|
+
onKeyDown: publish('cellKeyDown', onKeyDown),
|
|
614
|
+
onKeyUp: publish('cellKeyUp', onKeyUp)
|
|
615
|
+
}, draggableEventHandlers, other, {
|
|
616
|
+
onFocus: handleFocus,
|
|
617
|
+
children: children
|
|
618
|
+
}))
|
|
619
|
+
);
|
|
586
620
|
});
|
|
587
621
|
process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
|
|
588
622
|
// ----------------------------- Warning --------------------------------
|
|
@@ -602,6 +636,7 @@ process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
|
|
|
602
636
|
value: PropTypes.any
|
|
603
637
|
}),
|
|
604
638
|
height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
639
|
+
isNotVisible: PropTypes.bool,
|
|
605
640
|
onClick: PropTypes.func,
|
|
606
641
|
onDoubleClick: PropTypes.func,
|
|
607
642
|
onDragEnter: PropTypes.func,
|
|
@@ -81,10 +81,12 @@ var GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridGen
|
|
|
81
81
|
}, other, {
|
|
82
82
|
children: [/*#__PURE__*/_jsxs("div", _extends({
|
|
83
83
|
className: classes.draggableContainer,
|
|
84
|
-
draggable: isDraggable
|
|
84
|
+
draggable: isDraggable,
|
|
85
|
+
role: "presentation"
|
|
85
86
|
}, draggableContainerProps, {
|
|
86
87
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
87
88
|
className: classes.titleContainer,
|
|
89
|
+
role: "presentation",
|
|
88
90
|
children: [/*#__PURE__*/_jsx("div", {
|
|
89
91
|
className: classes.titleContainerContent,
|
|
90
92
|
children: headerComponent !== undefined ? headerComponent : /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
3
4
|
import { styled } from '@mui/system';
|
|
4
5
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
5
6
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
7
|
+
import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
8
10
|
var classes = ownerState.classes;
|
|
@@ -27,12 +29,17 @@ var GridMainContainerRoot = styled('div', {
|
|
|
27
29
|
};
|
|
28
30
|
});
|
|
29
31
|
export var GridMainContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
32
|
+
var _rootProps$experiment;
|
|
30
33
|
var rootProps = useGridRootProps();
|
|
31
34
|
var classes = useUtilityClasses(rootProps);
|
|
32
|
-
|
|
35
|
+
var getAriaAttributes = (_rootProps$experiment = rootProps.experimentalFeatures) != null && _rootProps$experiment.ariaV7 // ariaV7 should never change
|
|
36
|
+
? useGridAriaAttributes : null;
|
|
37
|
+
var ariaAttributes = typeof getAriaAttributes === 'function' ? getAriaAttributes() : null;
|
|
38
|
+
return /*#__PURE__*/_jsx(GridMainContainerRoot, _extends({
|
|
33
39
|
ref: ref,
|
|
34
40
|
className: classes.root,
|
|
35
|
-
ownerState: rootProps
|
|
41
|
+
ownerState: rootProps
|
|
42
|
+
}, ariaAttributes, {
|
|
36
43
|
children: props.children
|
|
37
|
-
});
|
|
44
|
+
}));
|
|
38
45
|
});
|
|
@@ -7,14 +7,12 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_capitalize as capitalize, unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
9
9
|
import { GridRootStyles } from './GridRootStyles';
|
|
10
|
-
import { gridVisibleColumnDefinitionsSelector } from '../../hooks/features/columns/gridColumnsSelector';
|
|
11
10
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
12
11
|
import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
|
|
13
12
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
14
13
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
15
14
|
import { gridDensityValueSelector } from '../../hooks/features/density/densitySelector';
|
|
16
|
-
import {
|
|
17
|
-
import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../../hooks/features/rows/gridRowsSelector';
|
|
15
|
+
import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
|
|
18
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
17
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
20
18
|
var autoHeight = ownerState.autoHeight,
|
|
@@ -26,18 +24,18 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
26
24
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
27
25
|
};
|
|
28
26
|
var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
27
|
+
var _rootProps$experiment;
|
|
29
28
|
var rootProps = useGridRootProps();
|
|
30
29
|
var children = props.children,
|
|
31
30
|
className = props.className,
|
|
32
31
|
other = _objectWithoutProperties(props, _excluded);
|
|
33
32
|
var apiRef = useGridPrivateApiContext();
|
|
34
|
-
var visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
35
|
-
var totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
36
33
|
var densityValue = useGridSelector(apiRef, gridDensityValueSelector);
|
|
37
|
-
var headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
|
|
38
34
|
var rootContainerRef = React.useRef(null);
|
|
39
35
|
var handleRef = useForkRef(rootContainerRef, ref);
|
|
40
|
-
var
|
|
36
|
+
var getAriaAttributes = (_rootProps$experiment = rootProps.experimentalFeatures) != null && _rootProps$experiment.ariaV7 // ariaV7 should never change
|
|
37
|
+
? null : useGridAriaAttributes;
|
|
38
|
+
var ariaAttributes = typeof getAriaAttributes === 'function' ? getAriaAttributes() : null;
|
|
41
39
|
var ownerState = _extends({}, rootProps, {
|
|
42
40
|
density: densityValue
|
|
43
41
|
});
|
|
@@ -60,12 +58,8 @@ var GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
|
|
|
60
58
|
return /*#__PURE__*/_jsx(GridRootStyles, _extends({
|
|
61
59
|
ref: handleRef,
|
|
62
60
|
className: clsx(className, classes.root),
|
|
63
|
-
ownerState: ownerState
|
|
64
|
-
|
|
65
|
-
"aria-colcount": visibleColumns.length,
|
|
66
|
-
"aria-rowcount": headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
|
|
67
|
-
"aria-multiselectable": !rootProps.disableMultipleRowSelection
|
|
68
|
-
}, other, {
|
|
61
|
+
ownerState: ownerState
|
|
62
|
+
}, ariaAttributes, other, {
|
|
69
63
|
children: children
|
|
70
64
|
}));
|
|
71
65
|
});
|
|
@@ -39,6 +39,7 @@ export var GridRootStyles = styled('div', {
|
|
|
39
39
|
'--unstable_DataGrid-radius': typeof radius === 'number' ? "".concat(radius, "px") : radius,
|
|
40
40
|
'--unstable_DataGrid-headWeight': theme.typography.fontWeightMedium,
|
|
41
41
|
'--unstable_DataGrid-overlayBackground': theme.vars ? "rgba(".concat(theme.vars.palette.background.defaultChannel, " / ").concat(theme.vars.palette.action.disabledOpacity, ")") : alpha(theme.palette.background.default, theme.palette.action.disabledOpacity),
|
|
42
|
+
'--DataGrid-cellOffsetMultiplier': 2,
|
|
42
43
|
flex: 1,
|
|
43
44
|
boxSizing: 'border-box',
|
|
44
45
|
position: 'relative',
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
import { DEFAULT_GRID_COL_TYPE_KEY } from '../../../colDef';
|
|
5
|
+
import { DEFAULT_GRID_COL_TYPE_KEY, GRID_STRING_COL_DEF } from '../../../colDef';
|
|
6
6
|
import { gridColumnsStateSelector, gridColumnVisibilityModelSelector } from './gridColumnsSelector';
|
|
7
7
|
import { clamp } from '../../../utils/utils';
|
|
8
8
|
import { gridDensityFactorSelector } from '../density/densitySelector';
|
|
@@ -130,7 +130,7 @@ export var hydrateColumnsWidth = function hydrateColumnsWidth(rawState, viewport
|
|
|
130
130
|
computedWidth = 0;
|
|
131
131
|
flexColumns.push(newColumn);
|
|
132
132
|
} else {
|
|
133
|
-
computedWidth = clamp(newColumn.width, newColumn.minWidth, newColumn.maxWidth);
|
|
133
|
+
computedWidth = clamp(newColumn.width || GRID_STRING_COL_DEF.width, newColumn.minWidth || GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || GRID_STRING_COL_DEF.maxWidth);
|
|
134
134
|
}
|
|
135
135
|
widthAllocatedBeforeFlex += computedWidth;
|
|
136
136
|
newColumn.computedWidth = computedWidth;
|
|
@@ -272,7 +272,7 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
272
272
|
}
|
|
273
273
|
if (field) {
|
|
274
274
|
var column = apiRef.current.getColumn(field);
|
|
275
|
-
if (column.type === GRID_ACTIONS_COLUMN_TYPE) {
|
|
275
|
+
if ((column == null ? void 0 : column.type) === GRID_ACTIONS_COLUMN_TYPE) {
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
5
|
var _excluded = ["style"],
|
|
@@ -106,9 +107,35 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
106
107
|
var rowStyleCache = React.useRef(Object.create(null));
|
|
107
108
|
var prevGetRowProps = React.useRef();
|
|
108
109
|
var prevRootRowStyle = React.useRef();
|
|
109
|
-
var getRenderedColumnsRef = React.useRef(defaultMemoize(function (columns, firstColumnToRender, lastColumnToRender) {
|
|
110
|
-
|
|
110
|
+
var getRenderedColumnsRef = React.useRef(defaultMemoize(function (columns, firstColumnToRender, lastColumnToRender, minFirstColumn, maxLastColumn, indexOfColumnWithFocusedCell) {
|
|
111
|
+
// If the selected column is not within the current range of columns being displayed,
|
|
112
|
+
// we need to render it at either the left or right of the columns,
|
|
113
|
+
// depending on whether it is above or below the range.
|
|
114
|
+
var focusedCellColumnIndexNotInRange;
|
|
115
|
+
var renderedColumns = columns.slice(firstColumnToRender, lastColumnToRender);
|
|
116
|
+
if (indexOfColumnWithFocusedCell > -1) {
|
|
117
|
+
// check if it is not on the left pinned column.
|
|
118
|
+
if (firstColumnToRender > indexOfColumnWithFocusedCell && indexOfColumnWithFocusedCell >= minFirstColumn) {
|
|
119
|
+
focusedCellColumnIndexNotInRange = indexOfColumnWithFocusedCell;
|
|
120
|
+
}
|
|
121
|
+
// check if it is not on the right pinned column.
|
|
122
|
+
else if (lastColumnToRender < indexOfColumnWithFocusedCell && indexOfColumnWithFocusedCell < maxLastColumn) {
|
|
123
|
+
focusedCellColumnIndexNotInRange = indexOfColumnWithFocusedCell;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
focusedCellColumnIndexNotInRange: focusedCellColumnIndexNotInRange,
|
|
128
|
+
renderedColumns: renderedColumns
|
|
129
|
+
};
|
|
111
130
|
}, MEMOIZE_OPTIONS));
|
|
131
|
+
var indexOfColumnWithFocusedCell = React.useMemo(function () {
|
|
132
|
+
if (cellFocus !== null) {
|
|
133
|
+
return visibleColumns.findIndex(function (column) {
|
|
134
|
+
return column.field === cellFocus.field;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return -1;
|
|
138
|
+
}, [cellFocus, visibleColumns]);
|
|
112
139
|
var getNearestIndexToRender = React.useCallback(function (offset) {
|
|
113
140
|
var _currentPage$range, _currentPage$range2;
|
|
114
141
|
var lastMeasuredIndexRelativeToAllRows = apiRef.current.getLastMeasuredRowIndex();
|
|
@@ -324,6 +351,14 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
324
351
|
var handleTouchMove = useEventCallback(function (event) {
|
|
325
352
|
apiRef.current.publishEvent('virtualScrollerTouchMove', {}, event);
|
|
326
353
|
});
|
|
354
|
+
var indexOfRowWithFocusedCell = React.useMemo(function () {
|
|
355
|
+
if (cellFocus !== null) {
|
|
356
|
+
return currentPage.rows.findIndex(function (row) {
|
|
357
|
+
return row.id === cellFocus.id;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return -1;
|
|
361
|
+
}, [cellFocus, currentPage.rows]);
|
|
327
362
|
var getRows = function getRows() {
|
|
328
363
|
var _rootProps$slotProps;
|
|
329
364
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
@@ -382,6 +417,28 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
382
417
|
});
|
|
383
418
|
}
|
|
384
419
|
}
|
|
420
|
+
// If the selected row is not within the current range of rows being displayed,
|
|
421
|
+
// we need to render it at either the top or bottom of the rows,
|
|
422
|
+
// depending on whether it is above or below the range.
|
|
423
|
+
|
|
424
|
+
var isRowWithFocusedCellNotInRange = false;
|
|
425
|
+
if (indexOfRowWithFocusedCell > -1) {
|
|
426
|
+
var rowWithFocusedCell = currentPage.rows[indexOfRowWithFocusedCell];
|
|
427
|
+
if (firstRowToRender > indexOfRowWithFocusedCell || lastRowToRender < indexOfRowWithFocusedCell) {
|
|
428
|
+
isRowWithFocusedCellNotInRange = true;
|
|
429
|
+
if (indexOfRowWithFocusedCell > firstRowToRender) {
|
|
430
|
+
renderedRows.push(rowWithFocusedCell);
|
|
431
|
+
} else {
|
|
432
|
+
renderedRows.unshift(rowWithFocusedCell);
|
|
433
|
+
}
|
|
434
|
+
apiRef.current.calculateColSpan({
|
|
435
|
+
rowId: rowWithFocusedCell.id,
|
|
436
|
+
minFirstColumn: minFirstColumn,
|
|
437
|
+
maxLastColumn: maxLastColumn,
|
|
438
|
+
columns: visibleColumns
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
}
|
|
385
442
|
var _getRenderableIndexes11 = getRenderableIndexes({
|
|
386
443
|
firstIndex: nextRenderContext.firstColumnIndex,
|
|
387
444
|
lastIndex: nextRenderContext.lastColumnIndex,
|
|
@@ -399,7 +456,13 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
399
456
|
lastRowToRender: lastRowToRender,
|
|
400
457
|
visibleRows: currentPage.rows
|
|
401
458
|
});
|
|
402
|
-
var
|
|
459
|
+
var isColumnWihFocusedCellNotInRange = false;
|
|
460
|
+
if (firstColumnToRender > indexOfColumnWithFocusedCell || lastColumnToRender < indexOfColumnWithFocusedCell) {
|
|
461
|
+
isColumnWihFocusedCellNotInRange = true;
|
|
462
|
+
}
|
|
463
|
+
var _getRenderedColumnsRe = getRenderedColumnsRef.current(visibleColumns, firstColumnToRender, lastColumnToRender, minFirstColumn, maxLastColumn, isColumnWihFocusedCellNotInRange ? indexOfColumnWithFocusedCell : -1),
|
|
464
|
+
focusedCellColumnIndexNotInRange = _getRenderedColumnsRe.focusedCellColumnIndexNotInRange,
|
|
465
|
+
renderedColumns = _getRenderedColumnsRe.renderedColumns;
|
|
403
466
|
var _ref4 = ((_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.row) || {},
|
|
404
467
|
rootRowStyle = _ref4.style,
|
|
405
468
|
rootRowProps = _objectWithoutProperties(_ref4, _excluded);
|
|
@@ -413,7 +476,8 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
413
476
|
var _renderedRows$_i = renderedRows[_i],
|
|
414
477
|
_id = _renderedRows$_i.id,
|
|
415
478
|
_model = _renderedRows$_i.model;
|
|
416
|
-
var
|
|
479
|
+
var isRowNotVisible = isRowWithFocusedCellNotInRange && cellFocus.id === _id;
|
|
480
|
+
var lastVisibleRowIndex = isRowWithFocusedCellNotInRange ? firstRowToRender + _i === currentPage.rows.length : firstRowToRender + _i === currentPage.rows.length - 1;
|
|
417
481
|
var baseRowHeight = !apiRef.current.rowHasAutoHeight(_id) ? apiRef.current.unstable_getRowHeight(_id) : 'auto';
|
|
418
482
|
var isSelected = void 0;
|
|
419
483
|
if (selectedRowsLookup[_id] == null) {
|
|
@@ -425,6 +489,8 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
425
489
|
onRowRender(_id);
|
|
426
490
|
}
|
|
427
491
|
var focusedCell = cellFocus !== null && cellFocus.id === _id ? cellFocus.field : null;
|
|
492
|
+
var columnWithFocusedCellNotInRange = focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange];
|
|
493
|
+
var renderedColumnsWithFocusedCell = columnWithFocusedCellNotInRange && focusedCell ? [columnWithFocusedCellNotInRange].concat(_toConsumableArray(renderedColumns)) : renderedColumns;
|
|
428
494
|
var tabbableCell = null;
|
|
429
495
|
if (cellTabIndex !== null && cellTabIndex.id === _id) {
|
|
430
496
|
var cellParams = apiRef.current.getCellParams(_id, cellTabIndex.field);
|
|
@@ -440,10 +506,12 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
440
506
|
rows.push( /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
|
|
441
507
|
row: _model,
|
|
442
508
|
rowId: _id,
|
|
509
|
+
focusedCellColumnIndexNotInRange: focusedCellColumnIndexNotInRange,
|
|
510
|
+
isNotVisible: isRowNotVisible,
|
|
443
511
|
rowHeight: baseRowHeight,
|
|
444
512
|
focusedCell: focusedCell,
|
|
445
513
|
tabbableCell: tabbableCell,
|
|
446
|
-
renderedColumns:
|
|
514
|
+
renderedColumns: renderedColumnsWithFocusedCell,
|
|
447
515
|
visibleColumns: visibleColumns,
|
|
448
516
|
firstColumnToRender: firstColumnToRender,
|
|
449
517
|
lastColumnToRender: lastColumnToRender,
|
|
@@ -512,19 +580,22 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
512
580
|
onWheel: handleWheel,
|
|
513
581
|
onTouchMove: handleTouchMove
|
|
514
582
|
}, inputProps, {
|
|
515
|
-
style: inputProps.style ? _extends({}, inputProps.style, rootStyle) : rootStyle
|
|
583
|
+
style: inputProps.style ? _extends({}, inputProps.style, rootStyle) : rootStyle,
|
|
584
|
+
role: 'presentation'
|
|
516
585
|
});
|
|
517
586
|
},
|
|
518
587
|
getContentProps: function getContentProps() {
|
|
519
588
|
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
520
589
|
style = _ref6.style;
|
|
521
590
|
return {
|
|
522
|
-
style: style ? _extends({}, style, contentSize) : contentSize
|
|
591
|
+
style: style ? _extends({}, style, contentSize) : contentSize,
|
|
592
|
+
role: 'presentation'
|
|
523
593
|
};
|
|
524
594
|
},
|
|
525
595
|
getRenderZoneProps: function getRenderZoneProps() {
|
|
526
596
|
return {
|
|
527
|
-
ref: renderZoneRef
|
|
597
|
+
ref: renderZoneRef,
|
|
598
|
+
role: 'rowgroup'
|
|
528
599
|
};
|
|
529
600
|
}
|
|
530
601
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { gridVisibleColumnDefinitionsSelector } from '../features/columns/gridColumnsSelector';
|
|
2
|
+
import { useGridSelector } from './useGridSelector';
|
|
3
|
+
import { useGridRootProps } from './useGridRootProps';
|
|
4
|
+
import { gridColumnGroupsHeaderMaxDepthSelector } from '../features/columnGrouping/gridColumnGroupsSelector';
|
|
5
|
+
import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../features/rows/gridRowsSelector';
|
|
6
|
+
import { useGridPrivateApiContext } from './useGridPrivateApiContext';
|
|
7
|
+
export var useGridAriaAttributes = function useGridAriaAttributes() {
|
|
8
|
+
var _rootProps$experiment;
|
|
9
|
+
var apiRef = useGridPrivateApiContext();
|
|
10
|
+
var rootProps = useGridRootProps();
|
|
11
|
+
var visibleColumns = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
|
|
12
|
+
var totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
13
|
+
var headerGroupingMaxDepth = useGridSelector(apiRef, gridColumnGroupsHeaderMaxDepthSelector);
|
|
14
|
+
var pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
|
|
15
|
+
var role = 'grid';
|
|
16
|
+
if ((_rootProps$experiment = rootProps.experimentalFeatures) != null && _rootProps$experiment.ariaV7 && rootProps.treeData) {
|
|
17
|
+
role = 'treegrid';
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
role: role,
|
|
21
|
+
'aria-colcount': visibleColumns.length,
|
|
22
|
+
'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
|
|
23
|
+
'aria-multiselectable': !rootProps.disableMultipleRowSelection
|
|
24
|
+
};
|
|
25
|
+
};
|
package/legacy/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreP
|
|
|
34
34
|
export { getTreeNodeDescendants, buildRootGroup } from '../hooks/features/rows/gridRowsUtils';
|
|
35
35
|
export { useGridRowsMeta, rowsMetaStateInitializer } from '../hooks/features/rows/useGridRowsMeta';
|
|
36
36
|
export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
37
|
-
export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
|
|
37
|
+
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED } from '../hooks/features/rows/gridRowsUtils';
|
|
38
38
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
39
39
|
export { headerFilteringStateInitializer, useGridHeaderFiltering } from '../hooks/features/headerFiltering/useGridHeaderFiltering';
|
|
40
40
|
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|