@mui/x-data-grid 5.16.0 → 5.17.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 +78 -1
- package/components/GridRow.d.ts +2 -1
- package/components/GridRow.js +132 -83
- package/components/cell/GridBooleanCell.js +2 -1
- package/components/cell/GridEditBooleanCell.js +2 -1
- package/components/cell/GridEditDateCell.js +2 -1
- package/components/cell/GridEditInputCell.js +2 -1
- package/components/cell/GridEditSingleSelectCell.js +2 -1
- package/components/cell/GridSkeletonCell.d.ts +12 -0
- package/components/cell/GridSkeletonCell.js +60 -0
- package/components/cell/index.d.ts +1 -0
- package/components/cell/index.js +2 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/components/containers/GridRootStyles.js +2 -0
- package/components/panel/GridColumnsPanel.d.ts +6 -1
- package/components/panel/GridColumnsPanel.js +38 -6
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +8 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.js +55 -54
- package/hooks/features/filter/useGridFilter.js +1 -1
- package/hooks/features/rows/useGridParamsApi.js +1 -1
- package/hooks/features/rows/useGridRows.js +65 -8
- package/hooks/features/rows/useGridRowsMeta.js +36 -16
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/index.js +1 -1
- package/legacy/components/GridRow.js +135 -83
- package/legacy/components/cell/GridBooleanCell.js +2 -1
- package/legacy/components/cell/GridEditBooleanCell.js +2 -1
- package/legacy/components/cell/GridEditDateCell.js +2 -1
- package/legacy/components/cell/GridEditInputCell.js +2 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +2 -1
- package/legacy/components/cell/GridSkeletonCell.js +57 -0
- package/legacy/components/cell/index.js +2 -1
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/legacy/components/containers/GridRootStyles.js +3 -3
- package/legacy/components/panel/GridColumnsPanel.js +41 -6
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/features/filter/gridFilterUtils.js +61 -56
- package/legacy/hooks/features/filter/useGridFilter.js +1 -1
- package/legacy/hooks/features/rows/useGridParamsApi.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +73 -8
- package/legacy/hooks/features/rows/useGridRowsMeta.js +45 -18
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +31 -13
- package/legacy/index.js +1 -1
- package/legacy/models/events/gridEvents.js +2 -0
- package/legacy/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/legacy/utils/utils.js +18 -0
- package/models/api/gridParamsApi.d.ts +1 -1
- package/models/api/gridRowApi.d.ts +6 -0
- package/models/api/gridRowsMetaApi.d.ts +6 -1
- package/models/events/gridEventLookup.d.ts +7 -1
- package/models/events/gridEvents.d.ts +3 -1
- package/models/events/gridEvents.js +2 -0
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/params/gridCellParams.d.ts +7 -2
- package/models/params/gridRenderedRowsIntervalChangeParams.d.ts +10 -0
- package/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/modern/components/GridRow.js +129 -82
- package/modern/components/cell/GridBooleanCell.js +2 -1
- package/modern/components/cell/GridEditBooleanCell.js +2 -1
- package/modern/components/cell/GridEditDateCell.js +2 -1
- package/modern/components/cell/GridEditInputCell.js +2 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
- package/modern/components/cell/GridSkeletonCell.js +60 -0
- package/modern/components/cell/index.js +2 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/modern/components/containers/GridRootStyles.js +2 -0
- package/modern/components/panel/GridColumnsPanel.js +38 -6
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +54 -53
- package/modern/hooks/features/filter/useGridFilter.js +1 -1
- package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +65 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -16
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/modern/index.js +1 -1
- package/modern/models/events/gridEvents.js +2 -0
- package/modern/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/modern/utils/utils.js +16 -0
- package/node/components/GridRow.js +131 -75
- package/node/components/cell/GridBooleanCell.js +2 -1
- package/node/components/cell/GridEditBooleanCell.js +2 -1
- package/node/components/cell/GridEditDateCell.js +2 -1
- package/node/components/cell/GridEditInputCell.js +2 -1
- package/node/components/cell/GridEditSingleSelectCell.js +2 -1
- package/node/components/cell/GridSkeletonCell.js +81 -0
- package/node/components/cell/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/node/components/containers/GridRootStyles.js +2 -0
- package/node/components/panel/GridColumnsPanel.js +36 -5
- package/node/constants/defaultGridSlotsComponents.js +1 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/filter/gridFilterUtils.js +55 -55
- package/node/hooks/features/filter/useGridFilter.js +1 -1
- package/node/hooks/features/rows/useGridParamsApi.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +60 -7
- package/node/hooks/features/rows/useGridRowsMeta.js +35 -15
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/node/index.js +1 -1
- package/node/models/events/gridEvents.js +2 -0
- package/node/models/params/gridRenderedRowsIntervalChangeParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/node/utils/utils.js +18 -0
- package/package.json +1 -1
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,83 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.17.0
|
|
7
|
+
|
|
8
|
+
_Sep 2, 2022_
|
|
9
|
+
|
|
10
|
+
🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
|
|
11
|
+
|
|
12
|
+
If you are still using picker components from the `lab`, take a look at the [migration guide](https://mui.com/x/react-date-pickers/migration-lab/).
|
|
13
|
+
|
|
14
|
+
We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
15
|
+
|
|
16
|
+
- 🎁 Implement Lazy loading (#5214) @DanailH
|
|
17
|
+
|
|
18
|
+
Pro users now can try the experimental lazy loading feature.
|
|
19
|
+
In a few steps, you can load your data on demand, as the rows are displayed.
|
|
20
|
+
|
|
21
|
+
To enable this feature, add `experimentalFeatures={{ lazyLoading: true }}`.
|
|
22
|
+
Lazy Loading requires a few other settings.
|
|
23
|
+
See the [documentation](https://mui.com/x/react-data-grid/row-updates/#lazy-loading) to explore the example in detail.
|
|
24
|
+
|
|
25
|
+
- 🚀 Improve `pickers` focus management (#5820) @alexfauquette
|
|
26
|
+
- 🎉 Enable disabling `day` on date range picker depending on `position` (#5773) @alexfauquette
|
|
27
|
+
- ✨ Various improvements
|
|
28
|
+
- 📚 Documentation improvements
|
|
29
|
+
- 🐞 Bugfixes
|
|
30
|
+
|
|
31
|
+
### `@mui/x-data-grid@v5.17.0` / `@mui/x-data-grid-pro@v5.17.0` / `@mui/x-data-grid-premium@v5.17.0`
|
|
32
|
+
|
|
33
|
+
#### Changes
|
|
34
|
+
|
|
35
|
+
- [DataGrid] Add `sort` prop to columns panel slot (#5888) @gavbrennan
|
|
36
|
+
- [DataGrid] Do not throw if `fieldToFocus` cannot be found (#5871) @cherniavskii
|
|
37
|
+
- [DataGrid] Support `getRowId` in the `replaceRows` method (#5988) @flaviendelangle
|
|
38
|
+
- [DataGridPro] Add class name to row with open detail panel (#5924) @m4theushw
|
|
39
|
+
- [DataGridPro] Fix crash when using `pinnedRows` + `getRowClassName` props and `rows=[]` (#5851) @cherniavskii
|
|
40
|
+
- [DataGridPro] Fix filtering with inactive filter items (#5993) @alexfauquette
|
|
41
|
+
- [DataGridPro] Implement Lazy loading (#5214) @DanailH
|
|
42
|
+
- [DataGridPro] Support pinned columns and dynamic row height (#5782) @m4theushw
|
|
43
|
+
- [DataGridPremium] Add state initializer for column groups (#5963) @alexfauquette
|
|
44
|
+
- [DataGridPremium] Update grouping when `groupingValueGetter` changes (#5919) @flaviendelangle
|
|
45
|
+
- [DataGridPremium] Use the aggregated value on tree data real groups (#5953) @flaviendelangle
|
|
46
|
+
|
|
47
|
+
### `@mui/x-date-pickers@v5.0.0` / `@mui/x-date-pickers-pro@v5.0.0`
|
|
48
|
+
|
|
49
|
+
#### Changes
|
|
50
|
+
|
|
51
|
+
- [DatePicker] Improve focus management (#5820) @alexfauquette
|
|
52
|
+
- [DateRangePicker] Enable disabling `day` depending on `position` (#5773) @alexfauquette
|
|
53
|
+
- [DateTimePicker] Create a new `tabs` component slot (#5972) @LukasTy
|
|
54
|
+
- [pickers] Do not forward validation props to the DOM on field components (#5971) @flaviendelangle
|
|
55
|
+
- [pickers] Do not hardcode `date-fns` elements in field components (#5975) @flaviendelangle
|
|
56
|
+
- [pickers] Do not require `date-fns` in `@mui/x-date-pickers-pro` (#5941) @flaviendelangle
|
|
57
|
+
- [pickers] Fix mobile picker not opening on label click (#5651) @LukasTy
|
|
58
|
+
- [pickers] Improve DOM event management on `useField` (#5901) @flaviendelangle
|
|
59
|
+
- [pickers] Include `community` package `themeAugmentation` in `pro` package types (#5969) @LukasTy
|
|
60
|
+
- [pickers] Rename `DateRangeField` into `SingleInputDateRangeField` (#5961) @flaviendelangle
|
|
61
|
+
- [pickers] Support `isSameError` on field components (#5984) @flaviendelangle
|
|
62
|
+
|
|
63
|
+
### Docs
|
|
64
|
+
|
|
65
|
+
- [docs] Add `description` and `default` to pickers slots (#5893) @alexfauquette
|
|
66
|
+
- [docs] Fix typo (#5945) @wettopa
|
|
67
|
+
- [docs] Fix typo `onYearPicker` to `onYearChange` (#5954) @alexfauquette
|
|
68
|
+
- [docs] Update `GridCellParams`'s `value` description (#5849) @cherniavskii
|
|
69
|
+
- [docs] Update `README.md` to match Introduction section of the docs (#5754) @samuelsycamore
|
|
70
|
+
|
|
71
|
+
### Core
|
|
72
|
+
|
|
73
|
+
- [core] Fix typo (#5990) @flaviendelangle
|
|
74
|
+
- [core] Remove old babel resolve rule (#5939) @oliviertassinari
|
|
75
|
+
- [core] Remove outdated TODO (#5956) @flaviendelangle
|
|
76
|
+
- [core] Upgrade monorepo (#5960) @cherniavskii
|
|
77
|
+
- [core] Fix statics (#5986) @DanailH
|
|
78
|
+
- [core] Remove unused dependencies (#5937) @oliviertassinari
|
|
79
|
+
- [license] Remove CLI (#5757) @flaviendelangle
|
|
80
|
+
- [test] Fix time zone sensitive test (#5955) @LukasTy
|
|
81
|
+
- [test] Use `userEvent.mousePress` instead of `fireClickEvent` (#5920) @cherniavskii
|
|
82
|
+
|
|
6
83
|
## 5.16.0
|
|
7
84
|
|
|
8
85
|
_Aug 25, 2022_
|
|
@@ -585,7 +662,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
|
|
|
585
662
|
|
|
586
663
|
**MonthPicker**: The prop `onMonthChange` has been removed, you can use `onChange` instead since every change is a month change
|
|
587
664
|
|
|
588
|
-
**YearPicker**: The prop `
|
|
665
|
+
**YearPicker**: The prop `onYearChange` has been removed, you can use `onChange` instead since every change is a year change
|
|
589
666
|
|
|
590
667
|
**DayPicker**: The prop `isDateDisabled` has been removed, you can now use the same validation props as for the other components (`maxDate`, `minDate`, `shouldDisableDate`, `disableFuture` and `disablePast`)
|
|
591
668
|
|
package/components/GridRow.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export interface GridRowProps {
|
|
|
13
13
|
index: number;
|
|
14
14
|
rowHeight: number | 'auto';
|
|
15
15
|
containerWidth: number;
|
|
16
|
-
row: GridRowModel;
|
|
17
16
|
firstColumnToRender: number;
|
|
18
17
|
lastColumnToRender: number;
|
|
19
18
|
visibleColumns: GridStateColDef[];
|
|
@@ -21,6 +20,8 @@ export interface GridRowProps {
|
|
|
21
20
|
cellFocus: GridCellIdentifier | null;
|
|
22
21
|
cellTabIndex: GridCellIdentifier | null;
|
|
23
22
|
editRowsState: GridEditRowsModel;
|
|
23
|
+
position: 'left' | 'center' | 'right';
|
|
24
|
+
row?: GridRowModel;
|
|
24
25
|
isLastVisible?: boolean;
|
|
25
26
|
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
26
27
|
onDoubleClick?: React.MouseEventHandler<HTMLDivElement>;
|
package/components/GridRow.js
CHANGED
|
@@ -1,10 +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 = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
|
|
4
|
-
|
|
5
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
6
|
-
|
|
7
|
-
/* eslint-disable jsx-a11y/interactive-supports-focus */
|
|
3
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
|
|
8
4
|
import * as React from 'react';
|
|
9
5
|
import PropTypes from 'prop-types';
|
|
10
6
|
import clsx from 'clsx';
|
|
@@ -23,6 +19,7 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelTogg
|
|
|
23
19
|
import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
|
|
24
20
|
import { gridRowTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
25
21
|
import { gridDensityHeaderGroupingMaxDepthSelector } from '../hooks/features/density/densitySelector';
|
|
22
|
+
import { randomNumberBetween } from '../utils/utils';
|
|
26
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
25
|
|
|
@@ -66,6 +63,7 @@ function GridRow(props) {
|
|
|
66
63
|
row,
|
|
67
64
|
index,
|
|
68
65
|
style: styleProp,
|
|
66
|
+
position,
|
|
69
67
|
rowHeight,
|
|
70
68
|
className,
|
|
71
69
|
visibleColumns,
|
|
@@ -112,9 +110,9 @@ function GridRow(props) {
|
|
|
112
110
|
React.useLayoutEffect(() => {
|
|
113
111
|
if (rowHeight === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
|
|
114
112
|
// Fallback for IE
|
|
115
|
-
apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight);
|
|
113
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight, position);
|
|
116
114
|
}
|
|
117
|
-
}, [apiRef, rowHeight, rowId]);
|
|
115
|
+
}, [apiRef, rowHeight, rowId, position]);
|
|
118
116
|
React.useLayoutEffect(() => {
|
|
119
117
|
if (currentPage.range) {
|
|
120
118
|
// The index prop is relative to the rows from all pages. As example, the index prop of the
|
|
@@ -139,11 +137,11 @@ function GridRow(props) {
|
|
|
139
137
|
const resizeObserver = new ResizeObserver(entries => {
|
|
140
138
|
const [entry] = entries;
|
|
141
139
|
const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
142
|
-
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
|
|
140
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height, position);
|
|
143
141
|
});
|
|
144
142
|
resizeObserver.observe(rootElement);
|
|
145
143
|
return () => resizeObserver.disconnect();
|
|
146
|
-
}, [apiRef, currentPage.range, index, rowHeight, rowId]);
|
|
144
|
+
}, [apiRef, currentPage.range, index, rowHeight, rowId, position]);
|
|
147
145
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
148
146
|
// Ignore portal
|
|
149
147
|
// The target is not an element when triggered by a Select inside the cell
|
|
@@ -199,47 +197,9 @@ function GridRow(props) {
|
|
|
199
197
|
|
|
200
198
|
publish('rowClick', onClick)(event);
|
|
201
199
|
}, [apiRef, onClick, publish, rowId]);
|
|
200
|
+
const getCell = React.useCallback((column, cellProps) => {
|
|
201
|
+
var _rootProps$components;
|
|
202
202
|
|
|
203
|
-
const style = _extends({}, styleProp, {
|
|
204
|
-
maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
|
|
205
|
-
// max-height doesn't support "auto"
|
|
206
|
-
minHeight: rowHeight
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
|
|
210
|
-
|
|
211
|
-
if (sizes != null && sizes.spacingTop) {
|
|
212
|
-
const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
|
|
213
|
-
style[property] = sizes.spacingTop;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (sizes != null && sizes.spacingBottom) {
|
|
217
|
-
const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
|
|
218
|
-
style[property] = sizes.spacingBottom;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
let rowClassName = null;
|
|
222
|
-
|
|
223
|
-
if (typeof rootProps.getRowClassName === 'function') {
|
|
224
|
-
const indexRelativeToCurrentPage = index - currentPage.range.firstRowIndex;
|
|
225
|
-
|
|
226
|
-
const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
|
|
227
|
-
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
228
|
-
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
|
|
229
|
-
indexRelativeToCurrentPage
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
rowClassName = rootProps.getRowClassName(rowParams);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const cells = [];
|
|
236
|
-
|
|
237
|
-
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
238
|
-
const column = renderedColumns[i];
|
|
239
|
-
const indexRelativeToAllColumns = firstColumnToRender + i;
|
|
240
|
-
const isLastColumn = indexRelativeToAllColumns === visibleColumns.length - 1;
|
|
241
|
-
const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
|
|
242
|
-
const showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
|
|
243
203
|
const cellParams = apiRef.current.getCellParams(rowId, column.field);
|
|
244
204
|
const classNames = [];
|
|
245
205
|
const disableDragEvents = rootProps.disableColumnReorder && column.disableReorder || !rootProps.rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
|
|
@@ -289,53 +249,141 @@ function GridRow(props) {
|
|
|
289
249
|
|
|
290
250
|
const hasFocus = cellFocus !== null && cellFocus.id === rowId && cellFocus.field === column.field;
|
|
291
251
|
const tabIndex = cellTabIndex !== null && cellTabIndex.id === rowId && cellTabIndex.field === column.field && cellParams.cellMode === 'view' ? 0 : -1;
|
|
252
|
+
return /*#__PURE__*/_jsx(rootProps.components.Cell, _extends({
|
|
253
|
+
value: cellParams.value,
|
|
254
|
+
field: column.field,
|
|
255
|
+
width: cellProps.width,
|
|
256
|
+
rowId: rowId,
|
|
257
|
+
height: rowHeight,
|
|
258
|
+
showRightBorder: cellProps.showRightBorder,
|
|
259
|
+
formattedValue: cellParams.formattedValue,
|
|
260
|
+
align: column.align || 'left',
|
|
261
|
+
cellMode: cellParams.cellMode,
|
|
262
|
+
colIndex: cellProps.indexRelativeToAllColumns,
|
|
263
|
+
isEditable: cellParams.isEditable,
|
|
264
|
+
hasFocus: hasFocus,
|
|
265
|
+
tabIndex: tabIndex,
|
|
266
|
+
className: clsx(classNames),
|
|
267
|
+
colSpan: cellProps.colSpan,
|
|
268
|
+
disableDragEvents: disableDragEvents
|
|
269
|
+
}, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.cell, {
|
|
270
|
+
children: content
|
|
271
|
+
}), column.field);
|
|
272
|
+
}, [apiRef, cellTabIndex, editRowsState, cellFocus, rootProps, row, rowHeight, rowId, treeDepth, sortModel.length]);
|
|
273
|
+
const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
|
|
274
|
+
let minHeight = rowHeight;
|
|
275
|
+
|
|
276
|
+
if (minHeight === 'auto' && sizes) {
|
|
277
|
+
let numberOfBaseSizes = 0;
|
|
278
|
+
const maximumSize = Object.entries(sizes).reduce((acc, [key, size]) => {
|
|
279
|
+
const isBaseHeight = /^base[A-Z]/.test(key);
|
|
280
|
+
|
|
281
|
+
if (!isBaseHeight) {
|
|
282
|
+
return acc;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
numberOfBaseSizes += 1;
|
|
286
|
+
|
|
287
|
+
if (size > acc) {
|
|
288
|
+
return size;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return acc;
|
|
292
|
+
}, 0);
|
|
293
|
+
|
|
294
|
+
if (maximumSize > 0 && numberOfBaseSizes > 1) {
|
|
295
|
+
minHeight = maximumSize;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const style = _extends({}, styleProp, {
|
|
300
|
+
maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
|
|
301
|
+
// max-height doesn't support "auto"
|
|
302
|
+
minHeight
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
if (sizes != null && sizes.spacingTop) {
|
|
306
|
+
const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
|
|
307
|
+
style[property] = sizes.spacingTop;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (sizes != null && sizes.spacingBottom) {
|
|
311
|
+
const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
|
|
312
|
+
style[property] = sizes.spacingBottom;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
|
|
316
|
+
|
|
317
|
+
if (typeof rootProps.getRowClassName === 'function') {
|
|
318
|
+
var _currentPage$range;
|
|
319
|
+
|
|
320
|
+
const indexRelativeToCurrentPage = index - (((_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0);
|
|
321
|
+
|
|
322
|
+
const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
|
|
323
|
+
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
324
|
+
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
|
|
325
|
+
indexRelativeToCurrentPage
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const randomNumber = randomNumberBetween(10000, 20, 80);
|
|
332
|
+
const cells = [];
|
|
333
|
+
|
|
334
|
+
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
335
|
+
const column = renderedColumns[i];
|
|
336
|
+
const indexRelativeToAllColumns = firstColumnToRender + i;
|
|
337
|
+
const isLastColumn = indexRelativeToAllColumns === visibleColumns.length - 1;
|
|
338
|
+
const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
|
|
339
|
+
const showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
|
|
292
340
|
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
|
|
293
341
|
|
|
294
342
|
if (cellColSpanInfo && !cellColSpanInfo.spannedByColSpan) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
children: content
|
|
320
|
-
}), column.field));
|
|
343
|
+
if (row) {
|
|
344
|
+
const {
|
|
345
|
+
colSpan,
|
|
346
|
+
width
|
|
347
|
+
} = cellColSpanInfo.cellProps;
|
|
348
|
+
const cellProps = {
|
|
349
|
+
width,
|
|
350
|
+
colSpan,
|
|
351
|
+
showRightBorder,
|
|
352
|
+
indexRelativeToAllColumns
|
|
353
|
+
};
|
|
354
|
+
cells.push(getCell(column, cellProps));
|
|
355
|
+
} else {
|
|
356
|
+
const {
|
|
357
|
+
width
|
|
358
|
+
} = cellColSpanInfo.cellProps;
|
|
359
|
+
const contentWidth = Math.round(randomNumber());
|
|
360
|
+
cells.push( /*#__PURE__*/_jsx(rootProps.components.SkeletonCell, {
|
|
361
|
+
width: width,
|
|
362
|
+
contentWidth: contentWidth,
|
|
363
|
+
field: column.field,
|
|
364
|
+
align: column.align
|
|
365
|
+
}, column.field));
|
|
366
|
+
}
|
|
321
367
|
}
|
|
322
368
|
}
|
|
323
369
|
|
|
324
370
|
const emptyCellWidth = containerWidth - columnsTotalWidth;
|
|
371
|
+
const eventHandlers = row ? {
|
|
372
|
+
onClick: publishClick,
|
|
373
|
+
onDoubleClick: publish('rowDoubleClick', onDoubleClick),
|
|
374
|
+
onMouseEnter: publish('rowMouseEnter', onMouseEnter),
|
|
375
|
+
onMouseLeave: publish('rowMouseLeave', onMouseLeave)
|
|
376
|
+
} : null;
|
|
325
377
|
return /*#__PURE__*/_jsxs("div", _extends({
|
|
326
378
|
ref: ref,
|
|
327
379
|
"data-id": rowId,
|
|
328
380
|
"data-rowindex": index,
|
|
329
381
|
role: "row",
|
|
330
|
-
className: clsx(
|
|
382
|
+
className: clsx(...rowClassNames, classes.root, className),
|
|
331
383
|
"aria-rowindex": ariaRowIndex,
|
|
332
384
|
"aria-selected": selected,
|
|
333
|
-
style: style
|
|
334
|
-
|
|
335
|
-
onDoubleClick: publish('rowDoubleClick', onDoubleClick),
|
|
336
|
-
onMouseEnter: publish('rowMouseEnter', onMouseEnter),
|
|
337
|
-
onMouseLeave: publish('rowMouseLeave', onMouseLeave)
|
|
338
|
-
}, other, {
|
|
385
|
+
style: style
|
|
386
|
+
}, eventHandlers, other, {
|
|
339
387
|
children: [cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
|
|
340
388
|
width: emptyCellWidth
|
|
341
389
|
})]
|
|
@@ -360,8 +408,9 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
360
408
|
index: PropTypes.number.isRequired,
|
|
361
409
|
isLastVisible: PropTypes.bool,
|
|
362
410
|
lastColumnToRender: PropTypes.number.isRequired,
|
|
411
|
+
position: PropTypes.oneOf(['center', 'left', 'right']).isRequired,
|
|
363
412
|
renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
364
|
-
row: PropTypes.object
|
|
413
|
+
row: PropTypes.object,
|
|
365
414
|
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
366
415
|
rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
367
416
|
selected: PropTypes.bool.isRequired,
|
|
@@ -123,7 +123,8 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
123
123
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* The cell value
|
|
126
|
+
* The cell value.
|
|
127
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
127
128
|
*/
|
|
128
129
|
value: PropTypes.any
|
|
129
130
|
} : void 0;
|
|
@@ -161,7 +161,8 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
161
161
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* The cell value
|
|
164
|
+
* The cell value.
|
|
165
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
165
166
|
*/
|
|
166
167
|
value: PropTypes.any
|
|
167
168
|
} : void 0;
|
|
@@ -215,7 +215,8 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
215
215
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
* The cell value
|
|
218
|
+
* The cell value.
|
|
219
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
219
220
|
*/
|
|
220
221
|
value: PropTypes.any
|
|
221
222
|
} : void 0;
|
|
@@ -178,7 +178,8 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
178
178
|
tabIndex: PropTypes.oneOf([-1, 0]),
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
* The cell value
|
|
181
|
+
* The cell value.
|
|
182
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
182
183
|
*/
|
|
183
184
|
value: PropTypes.any
|
|
184
185
|
} : void 0;
|
|
@@ -264,7 +264,8 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
264
264
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
|
-
* The cell value
|
|
267
|
+
* The cell value.
|
|
268
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
268
269
|
*/
|
|
269
270
|
value: PropTypes.any
|
|
270
271
|
} : void 0;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface GridSkeletonCellProps {
|
|
3
|
+
width: number;
|
|
4
|
+
contentWidth: number;
|
|
5
|
+
field: string;
|
|
6
|
+
align: string;
|
|
7
|
+
}
|
|
8
|
+
declare function GridSkeletonCell(props: React.HTMLAttributes<HTMLDivElement> & GridSkeletonCellProps): JSX.Element;
|
|
9
|
+
declare namespace GridSkeletonCell {
|
|
10
|
+
var propTypes: any;
|
|
11
|
+
}
|
|
12
|
+
export { GridSkeletonCell };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["field", "align", "width", "contentWidth"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import Skeleton from '@mui/material/Skeleton';
|
|
7
|
+
import { capitalize } from '@mui/material/utils';
|
|
8
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
9
|
+
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
10
|
+
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
const useUtilityClasses = ownerState => {
|
|
14
|
+
const {
|
|
15
|
+
align,
|
|
16
|
+
classes
|
|
17
|
+
} = ownerState;
|
|
18
|
+
const slots = {
|
|
19
|
+
root: ['cell', 'cellSkeleton', `cell--text${capitalize(align)}`]
|
|
20
|
+
};
|
|
21
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function GridSkeletonCell(props) {
|
|
25
|
+
const {
|
|
26
|
+
align,
|
|
27
|
+
width,
|
|
28
|
+
contentWidth
|
|
29
|
+
} = props,
|
|
30
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
31
|
+
|
|
32
|
+
const rootProps = useGridRootProps();
|
|
33
|
+
const ownerState = {
|
|
34
|
+
classes: rootProps.classes,
|
|
35
|
+
align
|
|
36
|
+
};
|
|
37
|
+
const classes = useUtilityClasses(ownerState);
|
|
38
|
+
return /*#__PURE__*/_jsx("div", _extends({
|
|
39
|
+
className: classes.root,
|
|
40
|
+
style: {
|
|
41
|
+
width
|
|
42
|
+
}
|
|
43
|
+
}, other, {
|
|
44
|
+
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
45
|
+
width: `${contentWidth}%`
|
|
46
|
+
})
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
|
|
51
|
+
// ----------------------------- Warning --------------------------------
|
|
52
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
53
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
54
|
+
// ----------------------------------------------------------------------
|
|
55
|
+
align: PropTypes.string.isRequired,
|
|
56
|
+
contentWidth: PropTypes.number.isRequired,
|
|
57
|
+
field: PropTypes.string.isRequired,
|
|
58
|
+
width: PropTypes.number.isRequired
|
|
59
|
+
} : void 0;
|
|
60
|
+
export { GridSkeletonCell };
|
package/components/cell/index.js
CHANGED
|
@@ -5,4 +5,5 @@ export * from './GridEditDateCell';
|
|
|
5
5
|
export * from './GridEditInputCell';
|
|
6
6
|
export * from './GridEditSingleSelectCell';
|
|
7
7
|
export * from './GridActionsCell';
|
|
8
|
-
export * from './GridActionsCellItem';
|
|
8
|
+
export * from './GridActionsCellItem';
|
|
9
|
+
export * from './GridSkeletonCell';
|
|
@@ -187,7 +187,8 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
187
187
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
|
-
* The cell value
|
|
190
|
+
* The cell value.
|
|
191
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
191
192
|
*/
|
|
192
193
|
value: PropTypes.any
|
|
193
194
|
} : void 0;
|
|
@@ -35,6 +35,8 @@ export const GridRootStyles = styled('div', {
|
|
|
35
35
|
[`& .${gridClasses.cellContent}`]: styles.cellContent
|
|
36
36
|
}, {
|
|
37
37
|
[`& .${gridClasses.cellCheckbox}`]: styles.cellCheckbox
|
|
38
|
+
}, {
|
|
39
|
+
[`& .${gridClasses.cellSkeleton}`]: styles.cellSkeleton
|
|
38
40
|
}, {
|
|
39
41
|
[`& .${gridClasses.checkboxInput}`]: styles.checkboxInput
|
|
40
42
|
}, {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GridPanelWrapperProps } from './GridPanelWrapper';
|
|
3
3
|
export interface GridColumnsPanelProps extends GridPanelWrapperProps {
|
|
4
|
+
sort?: 'asc' | 'desc';
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
declare function GridColumnsPanel(props: GridColumnsPanelProps): JSX.Element;
|
|
7
|
+
declare namespace GridColumnsPanel {
|
|
8
|
+
var propTypes: any;
|
|
9
|
+
}
|
|
10
|
+
export { GridColumnsPanel };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["sort"];
|
|
2
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
3
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
7
|
import IconButton from '@mui/material/IconButton';
|
|
5
8
|
import { switchClasses } from '@mui/material/Switch';
|
|
@@ -54,7 +57,9 @@ const GridColumnsPanelRowRoot = styled('div', {
|
|
|
54
57
|
const GridIconButtonRoot = styled(IconButton)({
|
|
55
58
|
justifyContent: 'flex-end'
|
|
56
59
|
});
|
|
57
|
-
|
|
60
|
+
const collator = new Intl.Collator();
|
|
61
|
+
|
|
62
|
+
function GridColumnsPanel(props) {
|
|
58
63
|
var _rootProps$components, _rootProps$components3, _rootProps$components4;
|
|
59
64
|
|
|
60
65
|
const apiRef = useGridApiContext();
|
|
@@ -68,6 +73,24 @@ export function GridColumnsPanel(props) {
|
|
|
68
73
|
};
|
|
69
74
|
const classes = useUtilityClasses(ownerState);
|
|
70
75
|
|
|
76
|
+
const {
|
|
77
|
+
sort
|
|
78
|
+
} = props,
|
|
79
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
80
|
+
|
|
81
|
+
const sortedColumns = React.useMemo(() => {
|
|
82
|
+
switch (sort) {
|
|
83
|
+
case 'asc':
|
|
84
|
+
return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
85
|
+
|
|
86
|
+
case 'desc':
|
|
87
|
+
return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
|
|
88
|
+
|
|
89
|
+
default:
|
|
90
|
+
return columns;
|
|
91
|
+
}
|
|
92
|
+
}, [columns, sort]);
|
|
93
|
+
|
|
71
94
|
const toggleColumn = event => {
|
|
72
95
|
const {
|
|
73
96
|
name: field
|
|
@@ -101,16 +124,16 @@ export function GridColumnsPanel(props) {
|
|
|
101
124
|
}, []);
|
|
102
125
|
const currentColumns = React.useMemo(() => {
|
|
103
126
|
if (!searchValue) {
|
|
104
|
-
return
|
|
127
|
+
return sortedColumns;
|
|
105
128
|
}
|
|
106
129
|
|
|
107
130
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
108
|
-
return
|
|
109
|
-
}, [
|
|
131
|
+
return sortedColumns.filter(column => (column.headerName || column.field).toLowerCase().indexOf(searchValueToCheck) > -1);
|
|
132
|
+
}, [sortedColumns, searchValue]);
|
|
110
133
|
React.useEffect(() => {
|
|
111
134
|
searchInputRef.current.focus();
|
|
112
135
|
}, []);
|
|
113
|
-
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({},
|
|
136
|
+
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
114
137
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
115
138
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
116
139
|
label: apiRef.current.getLocaleText('columnsPanelTextFieldLabel'),
|
|
@@ -161,4 +184,13 @@ export function GridColumnsPanel(props) {
|
|
|
161
184
|
}))]
|
|
162
185
|
})]
|
|
163
186
|
}));
|
|
164
|
-
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
190
|
+
// ----------------------------- Warning --------------------------------
|
|
191
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
192
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
193
|
+
// ----------------------------------------------------------------------
|
|
194
|
+
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
195
|
+
} : void 0;
|
|
196
|
+
export { GridColumnsPanel };
|