@mui/x-data-grid 5.6.0 → 5.6.1
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 +43 -0
- package/DataGrid/DataGrid.js +18 -3
- package/DataGrid/useDataGridComponent.js +19 -15
- package/DataGrid/useDataGridProps.js +3 -2
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridNumericOperators.js +1 -1
- package/components/ErrorBoundary.d.ts +2 -2
- package/components/GridRow.js +29 -3
- package/components/base/GridErrorHandler.d.ts +8 -2
- package/components/base/GridErrorHandler.js +13 -2
- package/components/cell/GridBooleanCell.d.ts +2 -1
- package/components/cell/GridCell.js +4 -2
- package/components/cell/GridEditBooleanCell.d.ts +2 -1
- package/components/cell/GridEditDateCell.d.ts +2 -1
- package/components/cell/GridEditInputCell.d.ts +2 -1
- package/components/cell/GridEditSingleSelectCell.d.ts +2 -1
- package/components/cell/GridEditSingleSelectCell.js +2 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/components/containers/GridRootStyles.js +1 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
- package/components/panel/filterPanel/filterPanelUtils.d.ts +2 -2
- package/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/constants/gridClasses.d.ts +5 -1
- package/constants/gridClasses.js +1 -1
- package/context/GridContextProvider.d.ts +9 -6
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -0
- package/hooks/features/columnMenu/useGridColumnMenu.js +6 -7
- package/hooks/features/columns/gridColumnsSelector.d.ts +8 -8
- package/hooks/features/columns/gridColumnsSelector.js +11 -10
- package/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/hooks/features/density/useGridDensity.d.ts +2 -0
- package/hooks/features/density/useGridDensity.js +3 -4
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/editRows/useGridEditing.d.ts +2 -0
- package/hooks/features/editRows/useGridEditing.js +3 -4
- package/hooks/features/export/serializers/csvSerializer.js +4 -4
- package/hooks/features/filter/gridFilterSelector.d.ts +1 -0
- package/hooks/features/filter/gridFilterSelector.js +1 -0
- package/hooks/features/focus/useGridFocus.d.ts +2 -0
- package/hooks/features/focus/useGridFocus.js +10 -11
- package/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/hooks/features/pagination/useGridPage.d.ts +1 -2
- package/hooks/features/pagination/useGridPage.js +5 -17
- package/hooks/features/pagination/useGridPageSize.d.ts +1 -2
- package/hooks/features/pagination/useGridPageSize.js +5 -26
- package/hooks/features/pagination/useGridPagination.d.ts +2 -0
- package/hooks/features/pagination/useGridPagination.js +25 -2
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +3 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +10 -11
- package/hooks/features/rows/useGridParamsApi.js +3 -10
- package/hooks/features/rows/useGridRows.js +14 -6
- package/hooks/features/rows/useGridRowsMeta.d.ts +3 -1
- package/hooks/features/rows/useGridRowsMeta.js +42 -24
- package/hooks/features/selection/gridSelectionSelector.d.ts +1 -1
- package/hooks/features/selection/useGridSelection.d.ts +2 -0
- package/hooks/features/selection/useGridSelection.js +28 -16
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -3
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/hooks/utils/useGridApi.js +10 -1
- package/hooks/utils/useGridInitializeState.d.ts +2 -1
- package/hooks/utils/useGridSelector.js +4 -4
- package/hooks/utils/useGridState.js +10 -1
- package/hooks/utils/{useCurrentPageRows.d.ts → useGridVisibleRows.d.ts} +7 -6
- package/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
- package/index.js +1 -1
- package/internals/index.d.ts +9 -12
- package/internals/index.js +9 -12
- package/legacy/DataGrid/DataGrid.js +18 -3
- package/legacy/DataGrid/useDataGridComponent.js +19 -15
- package/legacy/DataGrid/useDataGridProps.js +8 -2
- package/legacy/colDef/gridNumericOperators.js +1 -1
- package/legacy/components/GridRow.js +30 -3
- package/legacy/components/base/GridErrorHandler.js +13 -2
- package/legacy/components/cell/GridCell.js +4 -2
- package/legacy/components/cell/GridEditSingleSelectCell.js +10 -9
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/legacy/components/containers/GridRootStyles.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +29 -26
- package/legacy/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +8 -9
- package/legacy/hooks/features/columns/gridColumnsSelector.js +13 -12
- package/legacy/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/legacy/hooks/features/density/useGridDensity.js +5 -6
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/legacy/hooks/features/editRows/useGridEditing.js +5 -6
- package/legacy/hooks/features/export/serializers/csvSerializer.js +4 -4
- package/legacy/hooks/features/filter/gridFilterSelector.js +1 -0
- package/legacy/hooks/features/focus/useGridFocus.js +12 -13
- package/legacy/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/legacy/hooks/features/pagination/useGridPage.js +5 -17
- package/legacy/hooks/features/pagination/useGridPageSize.js +5 -26
- package/legacy/hooks/features/pagination/useGridPagination.js +25 -2
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +10 -11
- package/legacy/hooks/features/rows/useGridParamsApi.js +3 -10
- package/legacy/hooks/features/rows/useGridRows.js +17 -6
- package/legacy/hooks/features/rows/useGridRowsMeta.js +44 -26
- package/legacy/hooks/features/selection/useGridSelection.js +29 -19
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/legacy/hooks/utils/useGridApi.js +7 -0
- package/legacy/hooks/utils/useGridSelector.js +4 -4
- package/legacy/hooks/utils/useGridState.js +7 -0
- package/legacy/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +9 -12
- package/legacy/models/colDef/gridDefaultColumnTypes.js +4 -4
- package/legacy/utils/createSelector.js +4 -4
- package/legacy/utils/getGridLocalization.js +2 -2
- package/lib/lodash/_baseGetAllKeys.d.ts +1 -1
- package/lib/lodash/_baseIsEqual.d.ts +1 -1
- package/lib/lodash/_baseIsEqualDeep.d.ts +1 -1
- package/lib/lodash/_baseKeys.d.ts +1 -1
- package/lib/lodash/_cacheHas.d.ts +1 -1
- package/lib/lodash/_equalArrays.d.ts +1 -1
- package/lib/lodash/_equalByTag.d.ts +1 -1
- package/lib/lodash/_equalObjects.d.ts +1 -1
- package/lib/lodash/_getAllKeys.d.ts +1 -1
- package/lib/lodash/_getMapData.d.ts +1 -1
- package/lib/lodash/_getNative.d.ts +1 -1
- package/lib/lodash/_getValue.d.ts +1 -1
- package/lib/lodash/_hashSet.d.ts +1 -1
- package/lib/lodash/_listCacheSet.d.ts +1 -1
- package/lib/lodash/_mapCacheSet.d.ts +1 -1
- package/lib/lodash/_mapToArray.d.ts +1 -1
- package/lib/lodash/_setCacheAdd.d.ts +1 -1
- package/lib/lodash/_setToArray.d.ts +1 -1
- package/lib/lodash/_stackSet.d.ts +1 -1
- package/lib/lodash/keys.d.ts +1 -1
- package/models/api/gridRowApi.d.ts +6 -0
- package/models/api/gridRowsMetaApi.d.ts +7 -0
- package/models/api/gridSortApi.d.ts +1 -0
- package/models/colDef/gridColDef.d.ts +1 -2
- package/models/colDef/gridDefaultColumnTypes.js +2 -2
- package/models/gridRows.d.ts +8 -2
- package/models/params/gridRowParams.d.ts +29 -1
- package/models/props/DataGridProps.d.ts +20 -4
- package/modern/DataGrid/DataGrid.js +18 -3
- package/modern/DataGrid/useDataGridComponent.js +19 -15
- package/modern/DataGrid/useDataGridProps.js +3 -2
- package/modern/colDef/gridNumericOperators.js +1 -1
- package/modern/components/GridRow.js +29 -3
- package/modern/components/base/GridErrorHandler.js +13 -2
- package/modern/components/cell/GridCell.js +2 -2
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/modern/components/containers/GridRootStyles.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
- package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +6 -7
- package/modern/hooks/features/columns/gridColumnsSelector.js +11 -10
- package/modern/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/modern/hooks/features/density/useGridDensity.js +3 -4
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/modern/hooks/features/editRows/useGridEditing.js +3 -4
- package/modern/hooks/features/export/serializers/csvSerializer.js +4 -4
- package/modern/hooks/features/filter/gridFilterSelector.js +1 -0
- package/modern/hooks/features/focus/useGridFocus.js +10 -11
- package/modern/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/modern/hooks/features/pagination/useGridPage.js +1 -9
- package/modern/hooks/features/pagination/useGridPageSize.js +1 -20
- package/modern/hooks/features/pagination/useGridPagination.js +23 -2
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +6 -7
- package/modern/hooks/features/rows/useGridParamsApi.js +3 -10
- package/modern/hooks/features/rows/useGridRows.js +14 -6
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -24
- package/modern/hooks/features/selection/useGridSelection.js +24 -16
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/modern/hooks/utils/useGridApi.js +10 -1
- package/modern/hooks/utils/useGridSelector.js +4 -4
- package/modern/hooks/utils/useGridState.js +10 -1
- package/modern/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
- package/modern/index.js +1 -1
- package/modern/internals/index.js +9 -12
- package/modern/models/colDef/gridDefaultColumnTypes.js +2 -2
- package/modern/utils/createSelector.js +4 -4
- package/modern/utils/getGridLocalization.js +1 -1
- package/node/DataGrid/DataGrid.js +18 -3
- package/node/DataGrid/useDataGridComponent.js +11 -9
- package/node/DataGrid/useDataGridProps.js +3 -2
- package/node/colDef/gridNumericOperators.js +1 -1
- package/node/components/GridRow.js +28 -3
- package/node/components/base/GridErrorHandler.js +11 -1
- package/node/components/cell/GridCell.js +4 -2
- package/node/components/cell/GridEditSingleSelectCell.js +2 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/node/components/containers/GridRootStyles.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
- package/node/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +10 -8
- package/node/hooks/features/columns/gridColumnsSelector.js +11 -9
- package/node/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/node/hooks/features/density/useGridDensity.js +7 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/node/hooks/features/editRows/useGridEditing.js +8 -5
- package/node/hooks/features/export/serializers/csvSerializer.js +5 -4
- package/node/hooks/features/filter/gridFilterSelector.js +1 -0
- package/node/hooks/features/focus/useGridFocus.js +15 -13
- package/node/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/node/hooks/features/pagination/useGridPage.js +7 -20
- package/node/hooks/features/pagination/useGridPageSize.js +6 -26
- package/node/hooks/features/pagination/useGridPagination.js +31 -1
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +15 -13
- package/node/hooks/features/rows/useGridParamsApi.js +4 -10
- package/node/hooks/features/rows/useGridRows.js +15 -6
- package/node/hooks/features/rows/useGridRowsMeta.js +47 -26
- package/node/hooks/features/selection/useGridSelection.js +32 -18
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/hooks/utils/useGridApi.js +11 -1
- package/node/hooks/utils/useGridSelector.js +6 -4
- package/node/hooks/utils/useGridState.js +11 -1
- package/node/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +11 -10
- package/node/index.js +1 -1
- package/node/internals/index.js +45 -21
- package/node/models/colDef/gridDefaultColumnTypes.js +2 -2
- package/node/utils/createSelector.js +5 -4
- package/node/utils/getGridLocalization.js +2 -2
- package/package.json +2 -2
- package/utils/createSelector.js +4 -4
- package/utils/getGridLocalization.d.ts +2 -1
- package/utils/getGridLocalization.js +2 -2
- package/utils/keyboardUtils.d.ts +1 -1
- package/utils/warning.d.ts +1 -1
- package/hooks/utils/useGridStateInit.d.ts +0 -7
- package/hooks/utils/useGridStateInit.js +0 -9
- package/legacy/hooks/utils/useGridStateInit.js +0 -9
- package/modern/hooks/utils/useGridStateInit.js +0 -9
- package/node/hooks/utils/useGridStateInit.js +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,49 @@
|
|
|
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.6.1
|
|
7
|
+
|
|
8
|
+
_Mar 10, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- [DataGrid] Allow to add margins or borders between rows (#3848) @m4theushw
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<DataGrid getRowSpacing={() => ({ top: 10, bottom: 10 })} />
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Check the [documentation](https://mui.com/components/data-grid/rows/#row-spacing) for more information.
|
|
19
|
+
|
|
20
|
+
### `@mui/x-data-grid@v5.6.1` / `@mui/x-data-grid-pro@v5.6.1`
|
|
21
|
+
|
|
22
|
+
#### Changes
|
|
23
|
+
|
|
24
|
+
- [DataGrid] Display column's filter icon if a filter is applied (#4120) @DanailH
|
|
25
|
+
- [DataGrid] Do not loop through rows to compute top level rows count when the tree is flat (#4081) @flaviendelangle
|
|
26
|
+
- [DataGrid] Rename API method (#4148) @m4theushw
|
|
27
|
+
- [DataGrid] Support extending built-in column types (#4114) @cherniavskii
|
|
28
|
+
- [DataGridPro] Re-export the components removed by mistake during bundle split (#4134) @flaviendelangle
|
|
29
|
+
|
|
30
|
+
### Docs
|
|
31
|
+
|
|
32
|
+
- [docs] Fix links to prevent duplicate search result (#4130) @siriwatknp
|
|
33
|
+
- [docs] Fix outdated links to `localeTextConstants.ts` (#4080) @patilvishal755
|
|
34
|
+
- [docs] Neglect e2e tests related to search (#4118) @siriwatknp
|
|
35
|
+
- [docs] Use regex instead of specific url in e2e-website-tests (#4121) @siriwatknp
|
|
36
|
+
|
|
37
|
+
### Core
|
|
38
|
+
|
|
39
|
+
- [core] Enforce `noImplicitAny` (#4084) @cherniavskii
|
|
40
|
+
- [core] Improve the Pro support issue template (#4082) @oliviertassinari
|
|
41
|
+
- [core] Initialize remaining states before feature hooks (#4036) @m4theushw
|
|
42
|
+
- [core] Merge `page` and `pageSize` state initializer into a single `pagination` state initializer (#4087) @flaviendelangle
|
|
43
|
+
- [core] Prepare `yarn docs:api:build` scripts for multi packages support (#4111) @flaviendelangle
|
|
44
|
+
- [core] Upgrade `@mui/monorepo` (#4149) @cherniavskii
|
|
45
|
+
- [core] Use `buildWarning` and `wrapWithWarningOnCall` for deprecated methods and wrong usages (#4056) @flaviendelangle
|
|
46
|
+
- [test] Make focus state out-of-sync warning opt-in (#4129) @m4theushw
|
|
47
|
+
- [test] Only test custom input keyboard event in edit mode (#4075) @alexfauquette
|
|
48
|
+
|
|
6
49
|
## 5.6.0
|
|
7
50
|
|
|
8
51
|
_Mar 4, 2022_
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -79,6 +79,7 @@ DataGridRaw.propTypes = {
|
|
|
79
79
|
* Set of columns of type [[GridColumns]].
|
|
80
80
|
*/
|
|
81
81
|
columns: chainPropTypes(PropTypes.array.isRequired, props => {
|
|
82
|
+
// @ts-ignore because otherwise `build:api` doesn't work
|
|
82
83
|
if (props.columns && props.columns.some(column => column.resizable)) {
|
|
83
84
|
return new Error([`MUI: \`column.resizable = true\` is not a valid prop.`, 'Column resizing is not available in the MIT version.', '', 'You need to upgrade to the DataGridPro component to unlock this feature.'].join('\n'));
|
|
84
85
|
}
|
|
@@ -182,7 +183,8 @@ DataGridRaw.propTypes = {
|
|
|
182
183
|
* For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
|
|
183
184
|
*/
|
|
184
185
|
experimentalFeatures: PropTypes.shape({
|
|
185
|
-
preventCommitWhileValidating: PropTypes.bool
|
|
186
|
+
preventCommitWhileValidating: PropTypes.bool,
|
|
187
|
+
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
186
188
|
}),
|
|
187
189
|
|
|
188
190
|
/**
|
|
@@ -221,7 +223,7 @@ DataGridRaw.propTypes = {
|
|
|
221
223
|
|
|
222
224
|
/**
|
|
223
225
|
* Function that applies CSS classes dynamically on rows.
|
|
224
|
-
* @param {
|
|
226
|
+
* @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
|
|
225
227
|
* @returns {string} The CSS class to apply to the row.
|
|
226
228
|
*/
|
|
227
229
|
getRowClassName: PropTypes.func,
|
|
@@ -238,6 +240,13 @@ DataGridRaw.propTypes = {
|
|
|
238
240
|
*/
|
|
239
241
|
getRowId: PropTypes.func,
|
|
240
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Function that allows to specify the spacing between rows.
|
|
245
|
+
* @param {GridRowSpacingParams} params With all properties from [[GridRowSpacingParams]].
|
|
246
|
+
* @returns {GridRowSpacing} The row spacing values.
|
|
247
|
+
*/
|
|
248
|
+
getRowSpacing: PropTypes.func,
|
|
249
|
+
|
|
241
250
|
/**
|
|
242
251
|
* Set the height in pixel of the column headers in the grid.
|
|
243
252
|
* @default 56
|
|
@@ -290,7 +299,7 @@ DataGridRaw.propTypes = {
|
|
|
290
299
|
|
|
291
300
|
/**
|
|
292
301
|
* Set the locale text of the grid.
|
|
293
|
-
* You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/
|
|
302
|
+
* You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
|
|
294
303
|
*/
|
|
295
304
|
localeText: PropTypes.object,
|
|
296
305
|
|
|
@@ -614,6 +623,12 @@ DataGridRaw.propTypes = {
|
|
|
614
623
|
*/
|
|
615
624
|
rows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
616
625
|
|
|
626
|
+
/**
|
|
627
|
+
* Sets the type of space between rows added by `getRowSpacing`.
|
|
628
|
+
* @default "margin"
|
|
629
|
+
*/
|
|
630
|
+
rowSpacingType: PropTypes.oneOf(['border', 'margin']),
|
|
631
|
+
|
|
617
632
|
/**
|
|
618
633
|
* Select the pageSize dynamically using the component UI.
|
|
619
634
|
* @default [25, 50, 100]
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import { useGridInitialization } from '../hooks/core/useGridInitialization';
|
|
2
2
|
import { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
3
3
|
import { useGridClipboard } from '../hooks/features/clipboard/useGridClipboard';
|
|
4
|
-
import { useGridColumnMenu } from '../hooks/features/columnMenu/useGridColumnMenu';
|
|
4
|
+
import { columnMenuStateInitializer, useGridColumnMenu } from '../hooks/features/columnMenu/useGridColumnMenu';
|
|
5
5
|
import { useGridColumns, columnsStateInitializer } from '../hooks/features/columns/useGridColumns';
|
|
6
|
-
import { useGridDensity } from '../hooks/features/density/useGridDensity';
|
|
6
|
+
import { densityStateInitializer, useGridDensity } from '../hooks/features/density/useGridDensity';
|
|
7
7
|
import { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
8
8
|
import { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
|
|
9
9
|
import { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
|
|
10
|
-
import { useGridFocus } from '../hooks/features/focus/useGridFocus';
|
|
10
|
+
import { focusStateInitializer, useGridFocus } from '../hooks/features/focus/useGridFocus';
|
|
11
11
|
import { useGridKeyboard } from '../hooks/features/keyboard/useGridKeyboard';
|
|
12
12
|
import { useGridKeyboardNavigation } from '../hooks/features/keyboard/useGridKeyboardNavigation';
|
|
13
|
-
import { useGridPagination } from '../hooks/features/pagination/useGridPagination';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { useGridPreferencesPanel } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
17
|
-
import { useGridEditing } from '../hooks/features/editRows/useGridEditing';
|
|
13
|
+
import { useGridPagination, paginationStateInitializer } from '../hooks/features/pagination/useGridPagination';
|
|
14
|
+
import { useGridPreferencesPanel, preferencePanelStateInitializer } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
15
|
+
import { useGridEditing, editingStateInitializer } from '../hooks/features/editRows/useGridEditing';
|
|
18
16
|
import { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
|
|
19
17
|
import { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
20
|
-
import { useGridSelection } from '../hooks/features/selection/useGridSelection';
|
|
18
|
+
import { selectionStateInitializer, useGridSelection } from '../hooks/features/selection/useGridSelection';
|
|
21
19
|
import { useGridSelectionPreProcessors } from '../hooks/features/selection/useGridSelectionPreProcessors';
|
|
22
20
|
import { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
23
21
|
import { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
24
22
|
import { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
25
23
|
import { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
26
|
-
import { useGridRowsMeta } from '../hooks/features/rows/useGridRowsMeta';
|
|
24
|
+
import { rowsMetaStateInitializer, useGridRowsMeta } from '../hooks/features/rows/useGridRowsMeta';
|
|
27
25
|
import { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
28
26
|
export const useDataGridComponent = props => {
|
|
29
27
|
const apiRef = useGridInitialization(undefined, props);
|
|
@@ -36,12 +34,18 @@ export const useDataGridComponent = props => {
|
|
|
36
34
|
* Register all state initializers here.
|
|
37
35
|
*/
|
|
38
36
|
|
|
39
|
-
useGridInitializeState(
|
|
40
|
-
useGridInitializeState(
|
|
41
|
-
useGridInitializeState(pageStateInitializer, apiRef, props);
|
|
37
|
+
useGridInitializeState(selectionStateInitializer, apiRef, props);
|
|
38
|
+
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
42
39
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
40
|
+
useGridInitializeState(editingStateInitializer, apiRef, props);
|
|
41
|
+
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
43
42
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
44
|
-
useGridInitializeState(
|
|
43
|
+
useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
|
|
44
|
+
useGridInitializeState(filterStateInitializer, apiRef, props);
|
|
45
|
+
useGridInitializeState(densityStateInitializer, apiRef, props);
|
|
46
|
+
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
47
|
+
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
48
|
+
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
45
49
|
useGridSelection(apiRef, props);
|
|
46
50
|
useGridColumns(apiRef, props);
|
|
47
51
|
useGridRows(apiRef, props);
|
|
@@ -49,7 +53,7 @@ export const useDataGridComponent = props => {
|
|
|
49
53
|
useGridEditing(apiRef, props);
|
|
50
54
|
useGridFocus(apiRef, props);
|
|
51
55
|
useGridSorting(apiRef, props);
|
|
52
|
-
useGridPreferencesPanel(apiRef
|
|
56
|
+
useGridPreferencesPanel(apiRef);
|
|
53
57
|
useGridFilter(apiRef, props);
|
|
54
58
|
useGridDensity(apiRef, props);
|
|
55
59
|
useGridPagination(apiRef, props);
|
|
@@ -54,6 +54,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
54
54
|
paginationMode: GridFeatureModeConstant.client,
|
|
55
55
|
rowHeight: 52,
|
|
56
56
|
rowsPerPageOptions: [25, 50, 100],
|
|
57
|
+
rowSpacingType: 'margin',
|
|
57
58
|
showCellRightBorder: false,
|
|
58
59
|
showColumnRightBorder: false,
|
|
59
60
|
sortingOrder: ['asc', 'desc', null],
|
|
@@ -80,8 +81,8 @@ export const useDataGridProps = inProps => {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
const mergedComponents = {};
|
|
83
|
-
Object.
|
|
84
|
-
mergedComponents[key] = overrides[key] === undefined ?
|
|
84
|
+
Object.entries(DATA_GRID_DEFAULT_SLOTS_COMPONENTS).forEach(([key, defaultComponent]) => {
|
|
85
|
+
mergedComponents[key] = overrides[key] === undefined ? defaultComponent : overrides[key];
|
|
85
86
|
});
|
|
86
87
|
return mergedComponents;
|
|
87
88
|
}, [themedProps.components]);
|
|
@@ -3,4 +3,4 @@ export declare const getGridNumericOperators: () => GridFilterOperator[];
|
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated Use `getGridNumericOperators` instead.
|
|
5
5
|
*/
|
|
6
|
-
export declare const getGridNumericColumnOperators: () => GridFilterOperator[];
|
|
6
|
+
export declare const getGridNumericColumnOperators: (() => GridFilterOperator[]) | ((...args: any[]) => any);
|
|
@@ -174,4 +174,4 @@ export const getGridNumericOperators = () => [{
|
|
|
174
174
|
* @deprecated Use `getGridNumericOperators` instead.
|
|
175
175
|
*/
|
|
176
176
|
|
|
177
|
-
export const getGridNumericColumnOperators = wrapWithWarningOnCall(getGridNumericOperators, 'MUI:
|
|
177
|
+
export const getGridNumericColumnOperators = wrapWithWarningOnCall(getGridNumericOperators, ['MUI: The method getGridNumericColumnOperators is deprecated and will be removed in the next major version.', 'Use getGridNumericOperators instead.']);
|
|
@@ -10,9 +10,9 @@ export interface ErrorBoundaryProps {
|
|
|
10
10
|
componentProps?: any[];
|
|
11
11
|
}
|
|
12
12
|
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, any> {
|
|
13
|
-
static getDerivedStateFromError(error:
|
|
13
|
+
static getDerivedStateFromError(error: Error): {
|
|
14
14
|
hasError: boolean;
|
|
15
|
-
error:
|
|
15
|
+
error: Error;
|
|
16
16
|
};
|
|
17
17
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
18
18
|
logError(error: Error, errorInfo?: ErrorInfo): void;
|
package/components/GridRow.js
CHANGED
|
@@ -16,6 +16,7 @@ import { getDataGridUtilityClass, gridClasses } from '../constants/gridClasses';
|
|
|
16
16
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
17
17
|
import { gridColumnsTotalWidthSelector } from '../hooks/features/columns/gridColumnsSelector';
|
|
18
18
|
import { useGridSelector } from '../hooks/utils/useGridSelector';
|
|
19
|
+
import { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
19
20
|
import { findParentElementFromClassName } from '../utils/domUtils';
|
|
20
21
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
|
|
21
22
|
import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
|
|
@@ -83,6 +84,7 @@ function GridRow(props) {
|
|
|
83
84
|
|
|
84
85
|
const apiRef = useGridApiContext();
|
|
85
86
|
const rootProps = useGridRootProps();
|
|
87
|
+
const currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
86
88
|
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
87
89
|
const {
|
|
88
90
|
hasScrollX,
|
|
@@ -150,12 +152,36 @@ function GridRow(props) {
|
|
|
150
152
|
publish(GridEvents.rowClick, onClick)(event);
|
|
151
153
|
}, [apiRef, onClick, publish, rowId]);
|
|
152
154
|
|
|
153
|
-
const style = _extends({
|
|
155
|
+
const style = _extends({}, styleProp, {
|
|
154
156
|
maxHeight: rowHeight,
|
|
155
157
|
minHeight: rowHeight
|
|
156
|
-
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
|
|
161
|
+
|
|
162
|
+
if (sizes != null && sizes.spacingTop) {
|
|
163
|
+
const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
|
|
164
|
+
style[property] = sizes.spacingTop;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (sizes != null && sizes.spacingBottom) {
|
|
168
|
+
const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
|
|
169
|
+
style[property] = sizes.spacingBottom;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
let rowClassName = null;
|
|
173
|
+
|
|
174
|
+
if (typeof rootProps.getRowClassName === 'function') {
|
|
175
|
+
const indexRelativeToCurrentPage = index - currentPage.range.firstRowIndex;
|
|
176
|
+
|
|
177
|
+
const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
|
|
178
|
+
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
179
|
+
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
rowClassName = rootProps.getRowClassName(rowParams);
|
|
183
|
+
}
|
|
157
184
|
|
|
158
|
-
const rowClassName = typeof rootProps.getRowClassName === 'function' && rootProps.getRowClassName(apiRef.current.getRowParams(rowId));
|
|
159
185
|
const cells = [];
|
|
160
186
|
|
|
161
187
|
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
declare function GridErrorHandler(props: {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}): JSX.Element;
|
|
5
|
+
declare namespace GridErrorHandler {
|
|
6
|
+
var propTypes: any;
|
|
7
|
+
}
|
|
8
|
+
export { GridErrorHandler };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
3
4
|
import { styled } from '@mui/material/styles';
|
|
4
5
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
5
6
|
import { useGridLogger } from '../../hooks/utils/useGridLogger';
|
|
@@ -15,7 +16,8 @@ const ErrorOverlayWrapper = styled('div')({
|
|
|
15
16
|
width: '100%',
|
|
16
17
|
height: '100%'
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
function GridErrorHandler(props) {
|
|
19
21
|
const {
|
|
20
22
|
children
|
|
21
23
|
} = props;
|
|
@@ -47,4 +49,13 @@ export function GridErrorHandler(props) {
|
|
|
47
49
|
}),
|
|
48
50
|
children: children
|
|
49
51
|
});
|
|
50
|
-
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
process.env.NODE_ENV !== "production" ? GridErrorHandler.propTypes = {
|
|
55
|
+
// ----------------------------- Warning --------------------------------
|
|
56
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
57
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
58
|
+
// ----------------------------------------------------------------------
|
|
59
|
+
children: PropTypes.node
|
|
60
|
+
} : void 0;
|
|
61
|
+
export { GridErrorHandler };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
3
|
import { GridRenderCellParams } from '../../models/params/gridCellParams';
|
|
4
|
+
import { GridColDef } from '../../models/colDef/gridColDef';
|
|
4
5
|
interface GridBooleanCellProps extends GridRenderCellParams, Omit<SvgIconProps, 'tabIndex' | 'id'> {
|
|
5
6
|
}
|
|
6
7
|
export declare const GridBooleanCell: React.MemoExoticComponent<(props: GridBooleanCellProps) => JSX.Element>;
|
|
7
|
-
export declare const renderBooleanCell:
|
|
8
|
+
export declare const renderBooleanCell: GridColDef['renderCell'];
|
|
8
9
|
export {};
|
|
@@ -48,6 +48,8 @@ const useUtilityClasses = ownerState => {
|
|
|
48
48
|
let warnedOnce = false;
|
|
49
49
|
|
|
50
50
|
function GridCell(props) {
|
|
51
|
+
var _rootProps$experiment;
|
|
52
|
+
|
|
51
53
|
const {
|
|
52
54
|
align,
|
|
53
55
|
children,
|
|
@@ -141,7 +143,7 @@ function GridCell(props) {
|
|
|
141
143
|
}, [hasFocus, cellMode, apiRef]);
|
|
142
144
|
let handleFocus = other.onFocus;
|
|
143
145
|
|
|
144
|
-
if (process.env.NODE_ENV === 'test') {
|
|
146
|
+
if (process.env.NODE_ENV === 'test' && (_rootProps$experiment = rootProps.experimentalFeatures) != null && _rootProps$experiment.warnIfFocusStateIsNotSynced) {
|
|
145
147
|
handleFocus = event => {
|
|
146
148
|
const focusedCell = gridFocusCellSelector(apiRef);
|
|
147
149
|
|
|
@@ -154,7 +156,7 @@ function GridCell(props) {
|
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
if (!warnedOnce) {
|
|
157
|
-
console.
|
|
159
|
+
console.warn([`MUI: The cell with id=${rowId} and field=${field} received focus.`, `According to the state, the focus should be at id=${focusedCell == null ? void 0 : focusedCell.id}, field=${focusedCell == null ? void 0 : focusedCell.field}.`, "Not syncing the state may cause unwanted behaviors since the `cellFocusIn` event won't be fired.", 'Call `fireEvent.mouseUp` before the `fireEvent.click` to sync the focus with the state.'].join('\n'));
|
|
158
160
|
warnedOnce = true;
|
|
159
161
|
}
|
|
160
162
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridRenderEditCellParams } from '../../models/params/gridCellParams';
|
|
3
|
+
import { GridColDef } from '../../models/colDef/gridColDef';
|
|
3
4
|
export declare function GridEditBooleanCell(props: GridRenderEditCellParams & Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, 'id'>): JSX.Element;
|
|
4
|
-
export declare const renderEditBooleanCell:
|
|
5
|
+
export declare const renderEditBooleanCell: GridColDef['renderEditCell'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputBaseProps } from '@mui/material/InputBase';
|
|
3
3
|
import { GridRenderEditCellParams } from '../../models/params/gridCellParams';
|
|
4
|
+
import { GridColDef } from '../../models/colDef/gridColDef';
|
|
4
5
|
export declare function GridEditDateCell(props: GridRenderEditCellParams & Omit<InputBaseProps, 'id'>): JSX.Element;
|
|
5
|
-
export declare const renderEditDateCell:
|
|
6
|
+
export declare const renderEditDateCell: GridColDef['renderEditCell'];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { InputBaseProps } from '@mui/material/InputBase';
|
|
3
3
|
import { GridRenderEditCellParams } from '../../models/params/gridCellParams';
|
|
4
|
+
import { GridColDef } from '../../models/colDef/gridColDef';
|
|
4
5
|
interface GridEditInputCellProps {
|
|
5
6
|
debounceMs?: number;
|
|
6
7
|
}
|
|
@@ -9,4 +10,4 @@ declare namespace GridEditInputCell {
|
|
|
9
10
|
var propTypes: any;
|
|
10
11
|
}
|
|
11
12
|
export { GridEditInputCell };
|
|
12
|
-
export declare const renderEditInputCell:
|
|
13
|
+
export declare const renderEditInputCell: GridColDef['renderEditCell'];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SelectProps } from '@mui/material/Select';
|
|
3
3
|
import { GridRenderEditCellParams } from '../../models/params/gridCellParams';
|
|
4
|
+
import { GridColDef } from '../../models/colDef/gridColDef';
|
|
4
5
|
declare function GridEditSingleSelectCell(props: GridRenderEditCellParams & Omit<SelectProps, 'id'>): JSX.Element;
|
|
5
6
|
declare namespace GridEditSingleSelectCell {
|
|
6
7
|
var propTypes: any;
|
|
7
8
|
}
|
|
8
9
|
export { GridEditSingleSelectCell };
|
|
9
|
-
export declare const renderEditSingleSelectCell:
|
|
10
|
+
export declare const renderEditSingleSelectCell: GridColDef['renderEditCell'];
|
|
@@ -70,10 +70,11 @@ function GridEditSingleSelectCell(props) {
|
|
|
70
70
|
|
|
71
71
|
const handleChange = async event => {
|
|
72
72
|
setOpen(false);
|
|
73
|
+
const target = event.target;
|
|
73
74
|
const isValid = await api.setEditCellValue({
|
|
74
75
|
id,
|
|
75
76
|
field,
|
|
76
|
-
value:
|
|
77
|
+
value: target.value
|
|
77
78
|
}, event); // We use isValid === false because the default return is undefined which evaluates to true with !isValid
|
|
78
79
|
|
|
79
80
|
if (rootProps.editMode === GridEditModes.Row || isValid === false) {
|
|
@@ -23,13 +23,15 @@ const useUtilityClasses = ownerState => {
|
|
|
23
23
|
classes,
|
|
24
24
|
isDragging,
|
|
25
25
|
sortDirection,
|
|
26
|
-
showRightBorder
|
|
26
|
+
showRightBorder,
|
|
27
|
+
filterItemsCounter
|
|
27
28
|
} = ownerState;
|
|
28
|
-
const isColumnSorted = sortDirection != null;
|
|
29
|
+
const isColumnSorted = sortDirection != null;
|
|
30
|
+
const isColumnFiltered = filterItemsCounter != null && filterItemsCounter > 0; // todo refactor to a prop on col isNumeric or ?? ie: coltype===price wont work
|
|
29
31
|
|
|
30
32
|
const isColumnNumeric = column.type === 'number';
|
|
31
33
|
const slots = {
|
|
32
|
-
root: ['columnHeader', column.headerAlign === 'left' && 'columnHeader--alignLeft', column.headerAlign === 'center' && 'columnHeader--alignCenter', column.headerAlign === 'right' && 'columnHeader--alignRight', column.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnNumeric && 'columnHeader--numeric', showRightBorder && 'withBorder'],
|
|
34
|
+
root: ['columnHeader', column.headerAlign === 'left' && 'columnHeader--alignLeft', column.headerAlign === 'center' && 'columnHeader--alignCenter', column.headerAlign === 'right' && 'columnHeader--alignRight', column.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', showRightBorder && 'withBorder'],
|
|
33
35
|
draggableContainer: ['columnHeaderDraggableContainer'],
|
|
34
36
|
titleContainer: ['columnHeaderTitleContainer'],
|
|
35
37
|
titleContainerContent: ['columnHeaderTitleContainerContent']
|
|
@@ -138,7 +138,7 @@ export const GridRootStyles = styled('div', {
|
|
|
138
138
|
display: 'flex',
|
|
139
139
|
alignItems: 'center'
|
|
140
140
|
},
|
|
141
|
-
[`& .${gridClasses['columnHeader--sorted']} .${gridClasses.iconButtonContainer}`]: {
|
|
141
|
+
[`& .${gridClasses['columnHeader--sorted']} .${gridClasses.iconButtonContainer}, & .${gridClasses['columnHeader--filtered']} .${gridClasses.iconButtonContainer}`]: {
|
|
142
142
|
visibility: 'visible',
|
|
143
143
|
width: 'auto'
|
|
144
144
|
},
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AutocompleteProps } from '@mui/material/Autocomplete';
|
|
3
3
|
import { GridFilterItem } from '../../../models/gridFilterItem';
|
|
4
|
+
import type { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
4
5
|
export declare type GridFilterInputMultipleSingleSelectProps = {
|
|
5
6
|
item: GridFilterItem;
|
|
6
7
|
applyValue: (value: GridFilterItem) => void;
|
|
7
|
-
apiRef:
|
|
8
|
+
apiRef: React.MutableRefObject<GridApiCommon>;
|
|
8
9
|
focusElementRef?: React.Ref<any>;
|
|
9
10
|
type?: 'singleSelect';
|
|
10
11
|
} & Omit<AutocompleteProps<any[], true, false, true>, 'options' | 'renderInput'>;
|
|
@@ -10,21 +10,6 @@ import { unstable_useId as useId } from '@mui/material/utils';
|
|
|
10
10
|
import { getValueFromOption } from './filterPanelUtils';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
|
|
13
|
-
const getSingleSelectOptionFormatter = ({
|
|
14
|
-
valueFormatter,
|
|
15
|
-
field
|
|
16
|
-
}, api) => option => {
|
|
17
|
-
if (typeof option === 'object') {
|
|
18
|
-
return option.label;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return valueFormatter && option !== '' ? valueFormatter({
|
|
22
|
-
value: option,
|
|
23
|
-
field,
|
|
24
|
-
api
|
|
25
|
-
}) : option;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
13
|
const isOptionEqualToValue = (option, value) => getValueFromOption(option) === getValueFromOption(value);
|
|
29
14
|
|
|
30
15
|
const filter = createFilterOptions();
|
|
@@ -41,15 +26,31 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
41
26
|
const id = useId();
|
|
42
27
|
const resolvedColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
|
|
43
28
|
const resolvedValueOptions = React.useMemo(() => {
|
|
44
|
-
return typeof resolvedColumn.valueOptions === 'function' ? resolvedColumn.valueOptions({
|
|
29
|
+
return typeof (resolvedColumn == null ? void 0 : resolvedColumn.valueOptions) === 'function' ? resolvedColumn.valueOptions({
|
|
45
30
|
field: resolvedColumn.field
|
|
46
|
-
}) : resolvedColumn.valueOptions;
|
|
31
|
+
}) : resolvedColumn == null ? void 0 : resolvedColumn.valueOptions;
|
|
47
32
|
}, [resolvedColumn]);
|
|
48
33
|
const resolvedFormattedValueOptions = React.useMemo(() => {
|
|
49
|
-
return resolvedValueOptions.map(getValueFromOption);
|
|
34
|
+
return resolvedValueOptions == null ? void 0 : resolvedValueOptions.map(getValueFromOption);
|
|
50
35
|
}, [resolvedValueOptions]);
|
|
51
|
-
const
|
|
52
|
-
|
|
36
|
+
const {
|
|
37
|
+
valueFormatter,
|
|
38
|
+
field
|
|
39
|
+
} = apiRef.current.getColumn(item.columnField);
|
|
40
|
+
|
|
41
|
+
const filterValueOptionFormatter = option => {
|
|
42
|
+
if (typeof option === 'object') {
|
|
43
|
+
return option.label;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return valueFormatter && option !== '' ? valueFormatter({
|
|
47
|
+
value: option,
|
|
48
|
+
field,
|
|
49
|
+
api: apiRef.current
|
|
50
|
+
}) : option;
|
|
51
|
+
}; // The value is computed from the item.value and used directly
|
|
52
|
+
// If it was done by a useEffect/useState, the Autocomplete could receive incoherent value and options
|
|
53
|
+
|
|
53
54
|
|
|
54
55
|
const filterValues = React.useMemo(() => {
|
|
55
56
|
if (!Array.isArray(item.value)) {
|
|
@@ -60,7 +61,7 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
60
61
|
const itemValueIndexes = item.value.map(element => {
|
|
61
62
|
// get the index matching between values and valueoptions
|
|
62
63
|
const formattedElement = getValueFromOption(element);
|
|
63
|
-
const index = resolvedFormattedValueOptions.findIndex(formatedOption => formatedOption === formattedElement);
|
|
64
|
+
const index = (resolvedFormattedValueOptions == null ? void 0 : resolvedFormattedValueOptions.findIndex(formatedOption => formatedOption === formattedElement)) || 0;
|
|
64
65
|
return index;
|
|
65
66
|
});
|
|
66
67
|
return itemValueIndexes.filter(index => index >= 0).map(index => resolvedValueOptions[index]);
|
|
@@ -85,7 +86,8 @@ function GridFilterInputMultipleSingleSelect(props) {
|
|
|
85
86
|
multiple: true,
|
|
86
87
|
freeSolo: false,
|
|
87
88
|
limitTags: 1,
|
|
88
|
-
options: resolvedValueOptions
|
|
89
|
+
options: resolvedValueOptions // TODO: avoid `any`?
|
|
90
|
+
,
|
|
89
91
|
isOptionEqualToValue: isOptionEqualToValue,
|
|
90
92
|
filterOptions: filter,
|
|
91
93
|
id: id,
|
|
@@ -116,7 +118,9 @@ process.env.NODE_ENV !== "production" ? GridFilterInputMultipleSingleSelect.prop
|
|
|
116
118
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
117
119
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
118
120
|
// ----------------------------------------------------------------------
|
|
119
|
-
apiRef: PropTypes.
|
|
121
|
+
apiRef: PropTypes.shape({
|
|
122
|
+
current: PropTypes.object.isRequired
|
|
123
|
+
}).isRequired,
|
|
120
124
|
applyValue: PropTypes.func.isRequired,
|
|
121
125
|
focusElementRef: PropTypes
|
|
122
126
|
/* @typescript-to-proptypes-ignore */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getValueFromOption(option: any): any;
|
|
2
|
-
export declare function getValueFromValueOptions(value:
|
|
1
|
+
export declare function getValueFromOption(option: any | undefined): any;
|
|
2
|
+
export declare function getValueFromValueOptions(value: string, valueOptions: any[]): any;
|
|
@@ -24,7 +24,10 @@ const VirtualScrollerRenderZoneRoot = styled('div', {
|
|
|
24
24
|
slot: 'VirtualScrollerRenderZone',
|
|
25
25
|
overridesResolver: (props, styles) => styles.virtualScrollerRenderZone
|
|
26
26
|
})({
|
|
27
|
-
position: 'absolute'
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
display: 'flex',
|
|
29
|
+
// Prevents margin collapsing when using `getRowSpacing`
|
|
30
|
+
flexDirection: 'column'
|
|
28
31
|
});
|
|
29
32
|
const GridVirtualScrollerRenderZone = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerRenderZone(props, ref) {
|
|
30
33
|
const {
|
|
@@ -79,6 +79,10 @@ export interface GridClasses {
|
|
|
79
79
|
* Styles applied to the column header if the column is sorted.
|
|
80
80
|
*/
|
|
81
81
|
'columnHeader--sorted': string;
|
|
82
|
+
/**
|
|
83
|
+
* Styles applied to the column header if the column has a filter applied to it.
|
|
84
|
+
*/
|
|
85
|
+
'columnHeader--filtered': string;
|
|
82
86
|
/**
|
|
83
87
|
* Styles applied to the column header element.
|
|
84
88
|
*/
|
|
@@ -371,4 +375,4 @@ export interface GridClasses {
|
|
|
371
375
|
}
|
|
372
376
|
export declare type GridClassKey = keyof GridClasses;
|
|
373
377
|
export declare function getDataGridUtilityClass(slot: string): string;
|
|
374
|
-
export declare const gridClasses: Record<"overlay" | "cell" | "row" | "menu" | "main" | "root" | "paper" | "autoHeight" | "booleanCell" | "cell--editable" | "cell--editing" | "cell--textCenter" | "cell--textLeft" | "cell--textRight" | "cell--withRenderer" | "cellContent" | "cellCheckbox" | "checkboxInput" | "columnHeader--alignCenter" | "columnHeader--alignLeft" | "columnHeader--alignRight" | "columnHeader--dragging" | "columnHeader--moving" | "columnHeader--numeric" | "columnHeader--sortable" | "columnHeader--sorted" | "columnHeader" | "columnHeaderCheckbox" | "columnHeaderDraggableContainer" | "columnHeaderDropZone" | "columnHeaderTitle" | "columnHeaderTitleContainer" | "columnHeaderTitleContainerContent" | "columnHeaders" | "columnHeadersInner" | "columnHeadersInner--scrollable" | "columnSeparator--resizable" | "columnSeparator--resizing" | "columnSeparator--sideLeft" | "columnSeparator--sideRight" | "columnSeparator" | "columnsPanel" | "columnsPanelRow" | "detailPanel" | "detailPanels" | "detailPanelToggleCell" | "detailPanelToggleCell--expanded" | "panel" | "panelHeader" | "panelWrapper" | "panelContent" | "panelFooter" | "editBooleanCell" | "filterForm" | "filterFormDeleteIcon" | "filterFormLinkOperatorInput" | "filterFormColumnInput" | "filterFormOperatorInput" | "filterFormValueInput" | "editInputCell" | "filterIcon" | "footerContainer" | "iconButtonContainer" | "iconSeparator" | "menuIcon" | "menuIconButton" | "menuOpen" | "menuList" | "virtualScroller" | "virtualScrollerContent" | "virtualScrollerContent--overflowed" | "virtualScrollerRenderZone" | "pinnedColumns" | "pinnedColumns--left" | "pinnedColumns--right" | "pinnedColumnHeaders" | "pinnedColumnHeaders--left" | "pinnedColumnHeaders--right" | "row--editable" | "row--editing" | "row--lastVisible" | "rowCount" | "scrollArea" | "scrollArea--left" | "scrollArea--right" | "selectedRowCount" | "sortIcon" | "toolbarContainer" | "toolbarFilterList" | "withBorder" | "treeDataGroupingCell" | "treeDataGroupingCellToggle" | "actionsCell" | "groupingCriteriaCell" | "groupingCriteriaCellToggle", string>;
|
|
378
|
+
export declare const gridClasses: Record<"overlay" | "cell" | "row" | "menu" | "main" | "root" | "paper" | "autoHeight" | "booleanCell" | "cell--editable" | "cell--editing" | "cell--textCenter" | "cell--textLeft" | "cell--textRight" | "cell--withRenderer" | "cellContent" | "cellCheckbox" | "checkboxInput" | "columnHeader--alignCenter" | "columnHeader--alignLeft" | "columnHeader--alignRight" | "columnHeader--dragging" | "columnHeader--moving" | "columnHeader--numeric" | "columnHeader--sortable" | "columnHeader--sorted" | "columnHeader--filtered" | "columnHeader" | "columnHeaderCheckbox" | "columnHeaderDraggableContainer" | "columnHeaderDropZone" | "columnHeaderTitle" | "columnHeaderTitleContainer" | "columnHeaderTitleContainerContent" | "columnHeaders" | "columnHeadersInner" | "columnHeadersInner--scrollable" | "columnSeparator--resizable" | "columnSeparator--resizing" | "columnSeparator--sideLeft" | "columnSeparator--sideRight" | "columnSeparator" | "columnsPanel" | "columnsPanelRow" | "detailPanel" | "detailPanels" | "detailPanelToggleCell" | "detailPanelToggleCell--expanded" | "panel" | "panelHeader" | "panelWrapper" | "panelContent" | "panelFooter" | "editBooleanCell" | "filterForm" | "filterFormDeleteIcon" | "filterFormLinkOperatorInput" | "filterFormColumnInput" | "filterFormOperatorInput" | "filterFormValueInput" | "editInputCell" | "filterIcon" | "footerContainer" | "iconButtonContainer" | "iconSeparator" | "menuIcon" | "menuIconButton" | "menuOpen" | "menuList" | "virtualScroller" | "virtualScrollerContent" | "virtualScrollerContent--overflowed" | "virtualScrollerRenderZone" | "pinnedColumns" | "pinnedColumns--left" | "pinnedColumns--right" | "pinnedColumnHeaders" | "pinnedColumnHeaders--left" | "pinnedColumnHeaders--right" | "row--editable" | "row--editing" | "row--lastVisible" | "rowCount" | "scrollArea" | "scrollArea--left" | "scrollArea--right" | "selectedRowCount" | "sortIcon" | "toolbarContainer" | "toolbarFilterList" | "withBorder" | "treeDataGroupingCell" | "treeDataGroupingCellToggle" | "actionsCell" | "groupingCriteriaCell" | "groupingCriteriaCellToggle", string>;
|
package/constants/gridClasses.js
CHANGED
|
@@ -2,4 +2,4 @@ import { generateUtilityClasses, generateUtilityClass } from '@mui/material';
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'row--editable', 'row--editing', 'row', 'row--lastVisible', 'rowCount', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'row--editable', 'row--editing', 'row', 'row--lastVisible', 'rowCount', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|