@mui/x-data-grid 5.11.1 → 5.12.2
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 +199 -20
- package/DataGrid/DataGrid.js +26 -1
- package/README.md +2 -2
- package/colDef/gridCheckboxSelectionColDef.d.ts +1 -0
- package/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/colDef/gridDateOperators.d.ts +1 -1
- package/colDef/gridNumericColDef.js +1 -1
- package/components/GridRow.d.ts +1 -1
- package/components/GridRow.js +51 -12
- package/components/cell/GridActionsCellItem.d.ts +1 -1
- package/components/cell/GridCell.d.ts +2 -1
- package/components/cell/GridCell.js +12 -7
- package/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/components/containers/GridRootStyles.js +8 -3
- package/components/menu/GridMenu.js +9 -2
- package/components/panel/GridColumnsPanel.js +12 -7
- package/components/panel/GridPanelWrapper.d.ts +1 -1
- package/components/panel/GridPanelWrapper.js +3 -3
- package/components/panel/filterPanel/GridFilterForm.d.ts +61 -4
- package/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -5
- package/components/panel/filterPanel/GridFilterPanel.js +26 -11
- package/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +7 -0
- package/components/toolbar/GridToolbarQuickFilter.js +57 -4
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -0
- package/hooks/core/useGridStateInitialization.js +19 -6
- package/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -0
- package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
- package/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +13 -15
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -0
- package/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/hooks/features/editRows/useGridCellEditing.new.js +11 -4
- package/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +2 -0
- package/hooks/features/filter/gridFilterSelector.d.ts +5 -0
- package/hooks/features/filter/gridFilterSelector.js +6 -0
- package/hooks/features/filter/gridFilterState.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +10 -2
- package/hooks/features/filter/gridFilterUtils.js +3 -6
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +29 -12
- package/hooks/features/pagination/useGridPage.js +1 -1
- package/hooks/features/pagination/useGridPageSize.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +133 -67
- package/hooks/features/selection/useGridSelection.js +1 -1
- package/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +65 -11
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/legacy/DataGrid/DataGrid.js +26 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/legacy/colDef/gridNumericColDef.js +1 -1
- package/legacy/components/GridRow.js +56 -12
- package/legacy/components/cell/GridCell.js +12 -7
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +11 -6
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/legacy/components/containers/GridRootStyles.js +10 -7
- package/legacy/components/menu/GridMenu.js +9 -2
- package/legacy/components/panel/GridColumnsPanel.js +14 -7
- package/legacy/components/panel/GridPanelWrapper.js +3 -3
- package/legacy/components/panel/filterPanel/GridFilterForm.js +89 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +28 -12
- package/legacy/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/legacy/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/legacy/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/legacy/components/toolbar/GridToolbarQuickFilter.js +67 -6
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +1 -0
- package/legacy/hooks/core/useGridStateInitialization.js +18 -6
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/legacy/hooks/features/columns/useGridColumns.js +13 -15
- package/legacy/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -7
- package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/legacy/hooks/features/events/useGridEvents.js +2 -0
- package/legacy/hooks/features/filter/gridFilterSelector.js +8 -0
- package/legacy/hooks/features/filter/gridFilterUtils.js +4 -7
- package/legacy/hooks/features/filter/useGridFilter.js +33 -12
- package/legacy/hooks/features/pagination/useGridPage.js +1 -1
- package/legacy/hooks/features/pagination/useGridPageSize.js +1 -1
- package/legacy/hooks/features/rows/useGridRowsMeta.js +133 -66
- package/legacy/hooks/features/selection/useGridSelection.js +1 -1
- package/legacy/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +84 -26
- package/legacy/index.js +1 -1
- package/legacy/locales/arSD.js +1 -0
- package/legacy/locales/bgBG.js +1 -0
- package/legacy/locales/csCZ.js +1 -0
- package/legacy/locales/daDK.js +1 -0
- package/legacy/locales/deDE.js +1 -0
- package/legacy/locales/elGR.js +1 -0
- package/legacy/locales/esES.js +1 -0
- package/legacy/locales/faIR.js +1 -0
- package/legacy/locales/fiFI.js +1 -0
- package/legacy/locales/frFR.js +1 -0
- package/legacy/locales/heIL.js +10 -9
- package/legacy/locales/huHU.js +1 -0
- package/legacy/locales/itIT.js +1 -0
- package/legacy/locales/jaJP.js +29 -24
- package/legacy/locales/koKR.js +1 -0
- package/legacy/locales/nbNO.js +128 -0
- package/legacy/locales/nlNL.js +1 -0
- package/legacy/locales/plPL.js +1 -0
- package/legacy/locales/ptBR.js +1 -0
- package/legacy/locales/ruRU.js +7 -6
- package/legacy/locales/skSK.js +1 -0
- package/legacy/locales/trTR.js +8 -7
- package/legacy/locales/ukUA.js +1 -0
- package/legacy/locales/viVN.js +1 -0
- package/legacy/locales/zhCN.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -0
- package/legacy/models/gridApiCaches.js +1 -0
- package/legacy/models/params/gridMenuParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/locales/arSD.js +1 -0
- package/locales/bgBG.js +1 -0
- package/locales/csCZ.js +1 -0
- package/locales/daDK.js +1 -0
- package/locales/deDE.js +1 -0
- package/locales/elGR.js +1 -0
- package/locales/esES.js +1 -0
- package/locales/faIR.js +1 -0
- package/locales/fiFI.js +1 -0
- package/locales/frFR.js +1 -0
- package/locales/heIL.js +10 -9
- package/locales/huHU.js +1 -0
- package/locales/itIT.js +1 -0
- package/locales/jaJP.js +25 -24
- package/locales/koKR.js +1 -0
- package/locales/nbNO.d.ts +2 -0
- package/locales/nbNO.js +116 -0
- package/locales/nlNL.js +1 -0
- package/locales/plPL.js +1 -0
- package/locales/ptBR.js +1 -0
- package/locales/ruRU.js +7 -6
- package/locales/skSK.js +1 -0
- package/locales/trTR.js +8 -7
- package/locales/ukUA.js +1 -0
- package/locales/viVN.js +1 -0
- package/locales/zhCN.js +1 -0
- package/models/api/gridCallbackDetails.d.ts +6 -1
- package/models/api/gridCoreApi.d.ts +2 -6
- package/models/api/gridFilterApi.d.ts +8 -1
- package/models/api/gridLocaleTextApi.d.ts +1 -0
- package/models/api/gridRowsMetaApi.d.ts +24 -0
- package/models/api/gridStateApi.d.ts +14 -3
- package/models/colDef/gridColDef.d.ts +4 -4
- package/models/events/gridEventLookup.d.ts +16 -1
- package/models/events/gridEvents.d.ts +3 -1
- package/models/events/gridEvents.js +2 -0
- package/models/gridApiCaches.d.ts +6 -0
- package/models/gridApiCaches.js +1 -0
- package/models/gridIconSlotsComponent.d.ts +5 -0
- package/models/params/gridMenuParams.d.ts +7 -0
- package/models/params/gridMenuParams.js +1 -0
- package/models/params/gridRowParams.d.ts +1 -1
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/models/props/DataGridProps.d.ts +24 -2
- package/modern/DataGrid/DataGrid.js +26 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/modern/colDef/gridNumericColDef.js +1 -1
- package/modern/components/GridRow.js +51 -12
- package/modern/components/cell/GridCell.js +12 -7
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/modern/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/modern/components/containers/GridRootStyles.js +8 -3
- package/modern/components/menu/GridMenu.js +9 -2
- package/modern/components/panel/GridColumnsPanel.js +12 -7
- package/modern/components/panel/GridPanelWrapper.js +3 -3
- package/modern/components/panel/filterPanel/GridFilterForm.js +88 -8
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/modern/components/panel/filterPanel/GridFilterPanel.js +26 -11
- package/modern/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/modern/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +57 -4
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -0
- package/modern/hooks/core/useGridStateInitialization.js +19 -6
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
- package/modern/hooks/features/columns/useGridColumnSpanning.js +1 -1
- package/modern/hooks/features/columns/useGridColumns.js +12 -14
- package/modern/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +10 -3
- package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +9 -3
- package/modern/hooks/features/events/useGridEvents.js +2 -0
- package/modern/hooks/features/filter/gridFilterSelector.js +6 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -6
- package/modern/hooks/features/filter/useGridFilter.js +29 -12
- package/modern/hooks/features/pagination/useGridPage.js +1 -1
- package/modern/hooks/features/pagination/useGridPageSize.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +129 -59
- package/modern/hooks/features/selection/useGridSelection.js +1 -1
- package/modern/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
- package/modern/hooks/features/sorting/useGridSorting.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +65 -11
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +1 -0
- package/modern/locales/bgBG.js +1 -0
- package/modern/locales/csCZ.js +1 -0
- package/modern/locales/daDK.js +1 -0
- package/modern/locales/deDE.js +1 -0
- package/modern/locales/elGR.js +1 -0
- package/modern/locales/esES.js +1 -0
- package/modern/locales/faIR.js +1 -0
- package/modern/locales/fiFI.js +1 -0
- package/modern/locales/frFR.js +1 -0
- package/modern/locales/heIL.js +10 -9
- package/modern/locales/huHU.js +1 -0
- package/modern/locales/itIT.js +1 -0
- package/modern/locales/jaJP.js +25 -24
- package/modern/locales/koKR.js +1 -0
- package/modern/locales/nbNO.js +116 -0
- package/modern/locales/nlNL.js +1 -0
- package/modern/locales/plPL.js +1 -0
- package/modern/locales/ptBR.js +1 -0
- package/modern/locales/ruRU.js +7 -6
- package/modern/locales/skSK.js +1 -0
- package/modern/locales/trTR.js +8 -7
- package/modern/locales/ukUA.js +1 -0
- package/modern/locales/viVN.js +1 -0
- package/modern/locales/zhCN.js +1 -0
- package/modern/models/events/gridEvents.js +2 -0
- package/modern/models/gridApiCaches.js +1 -0
- package/modern/models/params/gridMenuParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/node/DataGrid/DataGrid.js +26 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +4 -2
- package/node/colDef/gridNumericColDef.js +1 -1
- package/node/components/GridRow.js +53 -12
- package/node/components/cell/GridCell.js +12 -7
- package/node/components/columnHeaders/GridColumnHeaderItem.js +9 -6
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
- package/node/components/columnSelection/GridHeaderCheckbox.js +0 -1
- package/node/components/containers/GridRootStyles.js +8 -3
- package/node/components/menu/GridMenu.js +10 -2
- package/node/components/panel/GridColumnsPanel.js +12 -7
- package/node/components/panel/GridPanelWrapper.js +5 -3
- package/node/components/panel/filterPanel/GridFilterForm.js +91 -9
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +0 -1
- package/node/components/panel/filterPanel/GridFilterPanel.js +28 -11
- package/node/components/toolbar/GridToolbarColumnsButton.js +0 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +0 -1
- package/node/components/toolbar/GridToolbarExportContainer.js +0 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +0 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +61 -4
- package/node/constants/defaultGridSlotsComponents.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -0
- package/node/hooks/core/useGridStateInitialization.js +19 -6
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +23 -0
- package/node/hooks/features/columns/useGridColumnSpanning.js +11 -16
- package/node/hooks/features/columns/useGridColumns.js +13 -15
- package/node/hooks/features/dimensions/useGridDimensions.js +9 -8
- package/node/hooks/features/editRows/useGridCellEditing.new.js +11 -4
- package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +10 -4
- package/node/hooks/features/events/useGridEvents.js +2 -0
- package/node/hooks/features/filter/gridFilterSelector.js +9 -2
- package/node/hooks/features/filter/gridFilterUtils.js +4 -5
- package/node/hooks/features/filter/useGridFilter.js +28 -11
- package/node/hooks/features/pagination/useGridPage.js +1 -1
- package/node/hooks/features/pagination/useGridPageSize.js +1 -1
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -69
- package/node/hooks/features/selection/useGridSelection.js +1 -1
- package/node/hooks/features/selection/useGridSelectionPreProcessors.js +7 -5
- package/node/hooks/features/sorting/useGridSorting.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +65 -12
- package/node/index.js +1 -1
- package/node/locales/arSD.js +1 -0
- package/node/locales/bgBG.js +1 -0
- package/node/locales/csCZ.js +1 -0
- package/node/locales/daDK.js +1 -0
- package/node/locales/deDE.js +1 -0
- package/node/locales/elGR.js +1 -0
- package/node/locales/esES.js +1 -0
- package/node/locales/faIR.js +1 -0
- package/node/locales/fiFI.js +1 -0
- package/node/locales/frFR.js +1 -0
- package/node/locales/heIL.js +10 -9
- package/node/locales/huHU.js +1 -0
- package/node/locales/itIT.js +1 -0
- package/node/locales/jaJP.js +25 -24
- package/node/locales/koKR.js +1 -0
- package/node/locales/nbNO.js +126 -0
- package/node/locales/nlNL.js +1 -0
- package/node/locales/plPL.js +1 -0
- package/node/locales/ptBR.js +1 -0
- package/node/locales/ruRU.js +7 -6
- package/node/locales/skSK.js +1 -0
- package/node/locales/trTR.js +8 -7
- package/node/locales/ukUA.js +1 -0
- package/node/locales/viVN.js +1 -0
- package/node/locales/zhCN.js +1 -0
- package/node/models/events/gridEvents.js +2 -0
- package/node/models/gridApiCaches.js +5 -0
- package/node/models/params/gridMenuParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/package.json +6 -5
|
@@ -346,9 +346,17 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
346
346
|
/**
|
|
347
347
|
* Function that sets the row height per row.
|
|
348
348
|
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
349
|
-
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
|
|
349
|
+
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
|
|
350
350
|
*/
|
|
351
351
|
getRowHeight?: (params: GridRowHeightParams) => GridRowHeightReturnValue;
|
|
352
|
+
/**
|
|
353
|
+
* Function that returns the estimated height for a row.
|
|
354
|
+
* Only works if dynamic row height is used.
|
|
355
|
+
* Once the row height is measured this value is discarded.
|
|
356
|
+
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
357
|
+
* @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
|
|
358
|
+
*/
|
|
359
|
+
getEstimatedRowHeight?: (params: GridRowHeightParams) => number | null;
|
|
352
360
|
/**
|
|
353
361
|
* Function that allows to specify the spacing between rows.
|
|
354
362
|
* @param {GridRowSpacingParams} params With all properties from [[GridRowSpacingParams]].
|
|
@@ -578,6 +586,20 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
578
586
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
579
587
|
*/
|
|
580
588
|
onPreferencePanelOpen?: GridEventListener<'preferencePanelOpen'>;
|
|
589
|
+
/**
|
|
590
|
+
* Callback fired when the menu is opened.
|
|
591
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
592
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
593
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
594
|
+
*/
|
|
595
|
+
onMenuOpen?: GridEventListener<'menuOpen'>;
|
|
596
|
+
/**
|
|
597
|
+
* Callback fired when the menu is closed.
|
|
598
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
599
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
600
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
601
|
+
*/
|
|
602
|
+
onMenuClose?: GridEventListener<'menuClose'>;
|
|
581
603
|
/**
|
|
582
604
|
* Set the edit rows model of the grid.
|
|
583
605
|
*/
|
|
@@ -617,7 +639,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
617
639
|
* @param {GridFilterModel} model With all properties from [[GridFilterModel]].
|
|
618
640
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
619
641
|
*/
|
|
620
|
-
onFilterModelChange?: (model: GridFilterModel, details: GridCallbackDetails) => void;
|
|
642
|
+
onFilterModelChange?: (model: GridFilterModel, details: GridCallbackDetails<'filter'>) => void;
|
|
621
643
|
/**
|
|
622
644
|
* Set the selection model of the grid.
|
|
623
645
|
*/
|
|
@@ -229,6 +229,15 @@ DataGridRaw.propTypes = {
|
|
|
229
229
|
*/
|
|
230
230
|
getDetailPanelContent: PropTypes.func,
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Function that returns the estimated height for a row.
|
|
234
|
+
* Only works if dynamic row height is used.
|
|
235
|
+
* Once the row height is measured this value is discarded.
|
|
236
|
+
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
237
|
+
* @returns {number | null} The estimated row height value. If `null` or `undefined` then the default row height, based on the density, is applied.
|
|
238
|
+
*/
|
|
239
|
+
getEstimatedRowHeight: PropTypes.func,
|
|
240
|
+
|
|
232
241
|
/**
|
|
233
242
|
* Function that applies CSS classes dynamically on rows.
|
|
234
243
|
* @param {GridRowClassNameParams} params With all properties from [[GridRowClassNameParams]].
|
|
@@ -239,7 +248,7 @@ DataGridRaw.propTypes = {
|
|
|
239
248
|
/**
|
|
240
249
|
* Function that sets the row height per row.
|
|
241
250
|
* @param {GridRowHeightParams} params With all properties from [[GridRowHeightParams]].
|
|
242
|
-
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied.
|
|
251
|
+
* @returns {GridRowHeightReturnValue} The row height value. If `null` or `undefined` then the default row height is applied. If "auto" then the row height is calculated based on the content.
|
|
243
252
|
*/
|
|
244
253
|
getRowHeight: PropTypes.func,
|
|
245
254
|
|
|
@@ -506,6 +515,22 @@ DataGridRaw.propTypes = {
|
|
|
506
515
|
*/
|
|
507
516
|
onFilterModelChange: PropTypes.func,
|
|
508
517
|
|
|
518
|
+
/**
|
|
519
|
+
* Callback fired when the menu is closed.
|
|
520
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
521
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
522
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
523
|
+
*/
|
|
524
|
+
onMenuClose: PropTypes.func,
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Callback fired when the menu is opened.
|
|
528
|
+
* @param {GridMenuParams} params With all properties from [[GridMenuParams]].
|
|
529
|
+
* @param {MuiEvent<{}>} event The event object.
|
|
530
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
531
|
+
*/
|
|
532
|
+
onMenuOpen: PropTypes.func,
|
|
533
|
+
|
|
509
534
|
/**
|
|
510
535
|
* Callback fired when the current page has changed.
|
|
511
536
|
* @param {number} page Index of the page displayed on the Grid.
|
|
@@ -5,8 +5,9 @@ import { GridHeaderCheckbox } from '../components/columnSelection/GridHeaderChec
|
|
|
5
5
|
import { selectedIdsLookupSelector } from '../hooks/features/selection/gridSelectionSelector';
|
|
6
6
|
import { GRID_BOOLEAN_COL_DEF } from './gridBooleanColDef';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export const GRID_CHECKBOX_SELECTION_FIELD = '__check__';
|
|
8
9
|
export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF, {
|
|
9
|
-
field:
|
|
10
|
+
field: GRID_CHECKBOX_SELECTION_FIELD,
|
|
10
11
|
type: 'checkboxSelection',
|
|
11
12
|
width: 50,
|
|
12
13
|
resizable: false,
|
|
@@ -11,7 +11,7 @@ export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
11
11
|
valueParser: value => value === '' ? null : Number(value),
|
|
12
12
|
valueFormatter: ({
|
|
13
13
|
value
|
|
14
|
-
}) =>
|
|
14
|
+
}) => isNumber(value) ? value.toLocaleString() : value || '',
|
|
15
15
|
filterOperators: getGridNumericOperators(),
|
|
16
16
|
getApplyQuickFilterFn: getGridNumericQuickFilterFn
|
|
17
17
|
});
|
|
@@ -20,6 +20,8 @@ import { findParentElementFromClassName } from '../utils/domUtils';
|
|
|
20
20
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../colDef/gridCheckboxSelectionColDef';
|
|
21
21
|
import { GRID_ACTIONS_COLUMN_TYPE } from '../colDef/gridActionsColDef';
|
|
22
22
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelToggleField';
|
|
23
|
+
import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
|
|
24
|
+
import { gridRowTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
23
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
27
|
|
|
@@ -29,25 +31,24 @@ const useUtilityClasses = ownerState => {
|
|
|
29
31
|
editing,
|
|
30
32
|
selected,
|
|
31
33
|
isLastVisible,
|
|
34
|
+
rowHeight,
|
|
32
35
|
classes
|
|
33
36
|
} = ownerState;
|
|
34
37
|
const slots = {
|
|
35
|
-
root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isLastVisible && 'row--lastVisible']
|
|
38
|
+
root: ['row', selected && 'selected', editable && 'row--editable', editing && 'row--editing', isLastVisible && 'row--lastVisible', rowHeight === 'auto' && 'row--dynamicHeight']
|
|
36
39
|
};
|
|
37
40
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
const EmptyCell = ({
|
|
41
|
-
width
|
|
42
|
-
height
|
|
44
|
+
width
|
|
43
45
|
}) => {
|
|
44
|
-
if (!width
|
|
46
|
+
if (!width) {
|
|
45
47
|
return null;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
const style = {
|
|
49
|
-
width
|
|
50
|
-
height
|
|
51
|
+
width
|
|
51
52
|
};
|
|
52
53
|
return /*#__PURE__*/_jsx("div", {
|
|
53
54
|
className: "MuiDataGrid-cell",
|
|
@@ -82,9 +83,12 @@ function GridRow(props) {
|
|
|
82
83
|
const ariaRowIndex = index + 2; // 1 for the header row and 1 as it's 1-based
|
|
83
84
|
|
|
84
85
|
const apiRef = useGridApiContext();
|
|
86
|
+
const ref = React.useRef(null);
|
|
85
87
|
const rootProps = useGridRootProps();
|
|
86
88
|
const currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
87
89
|
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
90
|
+
const sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
91
|
+
const treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
|
|
88
92
|
const {
|
|
89
93
|
hasScrollX,
|
|
90
94
|
hasScrollY
|
|
@@ -97,9 +101,41 @@ function GridRow(props) {
|
|
|
97
101
|
isLastVisible,
|
|
98
102
|
classes: rootProps.classes,
|
|
99
103
|
editing: apiRef.current.getRowMode(rowId) === GridRowModes.Edit,
|
|
100
|
-
editable: rootProps.editMode === GridEditModes.Row
|
|
104
|
+
editable: rootProps.editMode === GridEditModes.Row,
|
|
105
|
+
rowHeight
|
|
101
106
|
};
|
|
102
107
|
const classes = useUtilityClasses(ownerState);
|
|
108
|
+
React.useLayoutEffect(() => {
|
|
109
|
+
if (rowHeight === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
|
|
110
|
+
// Fallback for IE
|
|
111
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
React.useLayoutEffect(() => {
|
|
115
|
+
if (currentPage.range) {
|
|
116
|
+
// The index prop is relative to the rows from all pages. As example, the index prop of the
|
|
117
|
+
// first row is 5 if pageSize=5 and page=1. However, the index used by the virtualization
|
|
118
|
+
// doesn't care about pagination and considers the rows from the current page only, so the
|
|
119
|
+
// first row always has index=0. We need to subtract the index of the first row to make it
|
|
120
|
+
// compatible with the index used by the virtualization.
|
|
121
|
+
apiRef.current.unstable_setLastMeasuredRowIndex(index - currentPage.range.firstRowIndex);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const rootElement = ref.current;
|
|
125
|
+
const hasFixedHeight = rowHeight !== 'auto';
|
|
126
|
+
|
|
127
|
+
if (!rootElement || hasFixedHeight || typeof ResizeObserver === 'undefined') {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
132
|
+
const [entry] = entries;
|
|
133
|
+
const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
134
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
|
|
135
|
+
});
|
|
136
|
+
resizeObserver.observe(rootElement);
|
|
137
|
+
return () => resizeObserver.disconnect();
|
|
138
|
+
}, [apiRef, currentPage.range, index, rowHeight, rowId]);
|
|
103
139
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
104
140
|
// Ignore portal
|
|
105
141
|
// The target is not an element when triggered by a Select inside the cell
|
|
@@ -157,7 +193,8 @@ function GridRow(props) {
|
|
|
157
193
|
}, [apiRef, onClick, publish, rowId]);
|
|
158
194
|
|
|
159
195
|
const style = _extends({}, styleProp, {
|
|
160
|
-
maxHeight: rowHeight,
|
|
196
|
+
maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
|
|
197
|
+
// max-height doesn't support "auto"
|
|
161
198
|
minHeight: rowHeight
|
|
162
199
|
});
|
|
163
200
|
|
|
@@ -197,6 +234,7 @@ function GridRow(props) {
|
|
|
197
234
|
const showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
|
|
198
235
|
const cellParams = apiRef.current.getCellParams(rowId, column.field);
|
|
199
236
|
const classNames = [];
|
|
237
|
+
const disableDragEvents = rootProps.disableColumnReorder && column.disableReorder || !rootProps.rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
|
|
200
238
|
|
|
201
239
|
if (column.cellClassName) {
|
|
202
240
|
classNames.push(clsx(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName));
|
|
@@ -261,7 +299,8 @@ function GridRow(props) {
|
|
|
261
299
|
hasFocus: hasFocus,
|
|
262
300
|
tabIndex: tabIndex,
|
|
263
301
|
className: clsx(classNames),
|
|
264
|
-
colSpan: colSpan
|
|
302
|
+
colSpan: colSpan,
|
|
303
|
+
disableDragEvents: disableDragEvents
|
|
265
304
|
}, rootProps.componentsProps?.cell, {
|
|
266
305
|
children: content
|
|
267
306
|
}), column.field));
|
|
@@ -270,6 +309,7 @@ function GridRow(props) {
|
|
|
270
309
|
|
|
271
310
|
const emptyCellWidth = containerWidth - columnsTotalWidth;
|
|
272
311
|
return /*#__PURE__*/_jsxs("div", _extends({
|
|
312
|
+
ref: ref,
|
|
273
313
|
"data-id": rowId,
|
|
274
314
|
"data-rowindex": index,
|
|
275
315
|
role: "row",
|
|
@@ -283,8 +323,7 @@ function GridRow(props) {
|
|
|
283
323
|
onMouseLeave: publish('rowMouseLeave', onMouseLeave)
|
|
284
324
|
}, other, {
|
|
285
325
|
children: [cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
|
|
286
|
-
width: emptyCellWidth
|
|
287
|
-
height: rowHeight
|
|
326
|
+
width: emptyCellWidth
|
|
288
327
|
})]
|
|
289
328
|
}));
|
|
290
329
|
}
|
|
@@ -309,7 +348,7 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
309
348
|
lastColumnToRender: PropTypes.number.isRequired,
|
|
310
349
|
renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
311
350
|
row: PropTypes.any.isRequired,
|
|
312
|
-
rowHeight: PropTypes.number.isRequired,
|
|
351
|
+
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
313
352
|
rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
314
353
|
selected: PropTypes.bool.isRequired,
|
|
315
354
|
visibleColumns: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
|
|
3
|
+
const _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onKeyDown", "onDragEnter", "onDragOver"];
|
|
4
4
|
|
|
5
5
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
6
6
|
import * as React from 'react';
|
|
@@ -65,6 +65,7 @@ function GridCell(props) {
|
|
|
65
65
|
className,
|
|
66
66
|
showRightBorder,
|
|
67
67
|
colSpan,
|
|
68
|
+
disableDragEvents,
|
|
68
69
|
onClick,
|
|
69
70
|
onDoubleClick,
|
|
70
71
|
onMouseDown,
|
|
@@ -117,7 +118,8 @@ function GridCell(props) {
|
|
|
117
118
|
minWidth: width,
|
|
118
119
|
maxWidth: width,
|
|
119
120
|
minHeight: height,
|
|
120
|
-
maxHeight: height
|
|
121
|
+
maxHeight: height === 'auto' ? 'none' : height // max-height doesn't support "auto"
|
|
122
|
+
|
|
121
123
|
};
|
|
122
124
|
React.useLayoutEffect(() => {
|
|
123
125
|
if (!hasFocus || cellMode === GridCellModes.Edit) {
|
|
@@ -182,6 +184,10 @@ function GridCell(props) {
|
|
|
182
184
|
return children;
|
|
183
185
|
};
|
|
184
186
|
|
|
187
|
+
const draggableEventHandlers = disableDragEvents ? null : {
|
|
188
|
+
onDragEnter: publish('cellDragEnter', onDragEnter),
|
|
189
|
+
onDragOver: publish('cellDragOver', onDragOver)
|
|
190
|
+
};
|
|
185
191
|
return /*#__PURE__*/_jsx("div", _extends({
|
|
186
192
|
ref: cellRef,
|
|
187
193
|
className: clsx(className, classes.root),
|
|
@@ -196,10 +202,8 @@ function GridCell(props) {
|
|
|
196
202
|
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
197
203
|
onMouseDown: publish('cellMouseDown', onMouseDown),
|
|
198
204
|
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
199
|
-
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
200
|
-
|
|
201
|
-
onDragOver: publish('cellDragOver', onDragOver)
|
|
202
|
-
}, other, {
|
|
205
|
+
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
206
|
+
}, draggableEventHandlers, other, {
|
|
203
207
|
onFocus: handleFocus,
|
|
204
208
|
children: renderChildren()
|
|
205
209
|
}));
|
|
@@ -216,10 +220,11 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
216
220
|
className: PropTypes.string,
|
|
217
221
|
colIndex: PropTypes.number.isRequired,
|
|
218
222
|
colSpan: PropTypes.number,
|
|
223
|
+
disableDragEvents: PropTypes.bool,
|
|
219
224
|
field: PropTypes.string.isRequired,
|
|
220
225
|
formattedValue: PropTypes.any,
|
|
221
226
|
hasFocus: PropTypes.bool,
|
|
222
|
-
height: PropTypes.number.isRequired,
|
|
227
|
+
height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
223
228
|
isEditable: PropTypes.bool,
|
|
224
229
|
onClick: PropTypes.func,
|
|
225
230
|
onDoubleClick: PropTypes.func,
|
|
@@ -68,6 +68,7 @@ function GridColumnHeaderItem(props) {
|
|
|
68
68
|
hasScrollX: false,
|
|
69
69
|
hasScrollY: false
|
|
70
70
|
};
|
|
71
|
+
const isDraggable = React.useMemo(() => !rootProps.disableColumnReorder && !disableReorder && !column.disableReorder, [rootProps.disableColumnReorder, disableReorder, column.disableReorder]);
|
|
71
72
|
let headerComponent = null;
|
|
72
73
|
|
|
73
74
|
if (column.renderHeader) {
|
|
@@ -98,12 +99,12 @@ function GridColumnHeaderItem(props) {
|
|
|
98
99
|
onFocus: publish('columnHeaderFocus'),
|
|
99
100
|
onBlur: publish('columnHeaderBlur')
|
|
100
101
|
};
|
|
101
|
-
const draggableEventHandlers = {
|
|
102
|
+
const draggableEventHandlers = isDraggable ? {
|
|
102
103
|
onDragStart: publish('columnHeaderDragStart'),
|
|
103
104
|
onDragEnter: publish('columnHeaderDragEnter'),
|
|
104
105
|
onDragOver: publish('columnHeaderDragOver'),
|
|
105
106
|
onDragEnd: publish('columnHeaderDragEnd')
|
|
106
|
-
};
|
|
107
|
+
} : null;
|
|
107
108
|
const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
|
|
108
109
|
const showRightBorder = !isLastColumn ? rootProps.showColumnRightBorder : !removeLastBorderRight && !extendRowFullWidth;
|
|
109
110
|
|
|
@@ -164,6 +165,7 @@ function GridColumnHeaderItem(props) {
|
|
|
164
165
|
field: column.field,
|
|
165
166
|
colDef: column
|
|
166
167
|
}) : column.headerClassName;
|
|
168
|
+
const label = column.headerName ?? column.field;
|
|
167
169
|
return /*#__PURE__*/_jsxs("div", _extends({
|
|
168
170
|
ref: headerCellRef,
|
|
169
171
|
className: clsx(classes.root, headerClassName),
|
|
@@ -176,18 +178,19 @@ function GridColumnHeaderItem(props) {
|
|
|
176
178
|
role: "columnheader",
|
|
177
179
|
tabIndex: tabIndex,
|
|
178
180
|
"aria-colindex": colIndex + 1,
|
|
179
|
-
"aria-sort": ariaSort
|
|
181
|
+
"aria-sort": ariaSort,
|
|
182
|
+
"aria-label": column.renderHeader && headerComponent == null ? label : undefined
|
|
180
183
|
}, mouseEventsHandlers, {
|
|
181
184
|
children: [/*#__PURE__*/_jsxs("div", _extends({
|
|
182
185
|
className: classes.draggableContainer,
|
|
183
|
-
draggable:
|
|
186
|
+
draggable: isDraggable
|
|
184
187
|
}, draggableEventHandlers, {
|
|
185
188
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
186
189
|
className: classes.titleContainer,
|
|
187
190
|
children: [/*#__PURE__*/_jsx("div", {
|
|
188
191
|
className: classes.titleContainerContent,
|
|
189
|
-
children: headerComponent
|
|
190
|
-
label:
|
|
192
|
+
children: column.renderHeader ? headerComponent : /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
|
|
193
|
+
label: label,
|
|
191
194
|
description: column.description,
|
|
192
195
|
columnWidth: width
|
|
193
196
|
})
|
|
@@ -165,7 +165,7 @@ export const GridRootStyles = styled('div', {
|
|
|
165
165
|
minWidth: 0,
|
|
166
166
|
flex: 1,
|
|
167
167
|
whiteSpace: 'nowrap',
|
|
168
|
-
|
|
168
|
+
overflowX: 'hidden'
|
|
169
169
|
},
|
|
170
170
|
[`& .${gridClasses.columnHeaderTitleContainerContent}`]: {
|
|
171
171
|
overflow: 'hidden',
|
|
@@ -221,6 +221,9 @@ export const GridRootStyles = styled('div', {
|
|
|
221
221
|
},
|
|
222
222
|
[`&.${gridClasses['columnSeparator--resizing']}`]: {
|
|
223
223
|
color: theme.palette.text.primary
|
|
224
|
+
},
|
|
225
|
+
'& svg': {
|
|
226
|
+
pointerEvents: 'none'
|
|
224
227
|
}
|
|
225
228
|
},
|
|
226
229
|
[`& .${gridClasses.iconSeparator}`]: {
|
|
@@ -274,10 +277,12 @@ export const GridRootStyles = styled('div', {
|
|
|
274
277
|
[`& .${gridClasses.cell}`]: {
|
|
275
278
|
display: 'flex',
|
|
276
279
|
alignItems: 'center',
|
|
277
|
-
overflow: 'hidden',
|
|
278
|
-
whiteSpace: 'nowrap',
|
|
279
280
|
borderBottom: `1px solid ${borderColor}`
|
|
280
281
|
},
|
|
282
|
+
[`& .${gridClasses.row}:not(.${gridClasses['row--dynamicHeight']}) > .${gridClasses.cell}`]: {
|
|
283
|
+
overflow: 'hidden',
|
|
284
|
+
whiteSpace: 'nowrap'
|
|
285
|
+
},
|
|
281
286
|
[`& .${gridClasses.cellContent}`]: {
|
|
282
287
|
overflow: 'hidden',
|
|
283
288
|
textOverflow: 'ellipsis'
|
|
@@ -13,6 +13,7 @@ import { styled } from '@mui/material/styles';
|
|
|
13
13
|
import { HTMLElementType } from '@mui/utils';
|
|
14
14
|
import { getDataGridUtilityClass, gridClasses } from '../../constants/gridClasses';
|
|
15
15
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
16
|
+
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
16
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
18
|
|
|
18
19
|
const useUtilityClasses = ownerState => {
|
|
@@ -54,6 +55,7 @@ const GridMenu = props => {
|
|
|
54
55
|
} = props,
|
|
55
56
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
56
57
|
|
|
58
|
+
const apiRef = useGridApiContext();
|
|
57
59
|
const prevTarget = React.useRef(target);
|
|
58
60
|
const prevOpen = React.useRef(open);
|
|
59
61
|
const rootProps = useGridRootProps();
|
|
@@ -64,11 +66,16 @@ const GridMenu = props => {
|
|
|
64
66
|
React.useEffect(() => {
|
|
65
67
|
if (prevOpen.current && prevTarget.current) {
|
|
66
68
|
prevTarget.current.focus();
|
|
67
|
-
}
|
|
69
|
+
} // Emit menuOpen or menuClose events
|
|
70
|
+
|
|
68
71
|
|
|
72
|
+
const eventName = open ? 'menuOpen' : 'menuClose';
|
|
73
|
+
apiRef.current.publishEvent(eventName, {
|
|
74
|
+
target
|
|
75
|
+
});
|
|
69
76
|
prevOpen.current = open;
|
|
70
77
|
prevTarget.current = target;
|
|
71
|
-
}, [open, target]);
|
|
78
|
+
}, [apiRef, open, target]);
|
|
72
79
|
|
|
73
80
|
const handleExited = popperOnExited => node => {
|
|
74
81
|
if (popperOnExited) {
|
|
@@ -74,8 +74,16 @@ export function GridColumnsPanel(props) {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
const toggleAllColumns = React.useCallback(isVisible => {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
78
|
+
if (isVisible) {
|
|
79
|
+
return apiRef.current.setColumnVisibilityModel({});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.map(col => [col.field, false])));
|
|
83
|
+
} // TODO v6: Remove
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
return apiRef.current.updateColumns(columns.map(col => {
|
|
79
87
|
if (col.hideable !== false) {
|
|
80
88
|
return {
|
|
81
89
|
field: col.field,
|
|
@@ -122,7 +130,6 @@ export function GridColumnsPanel(props) {
|
|
|
122
130
|
checked: columnVisibilityModel[column.field] !== false,
|
|
123
131
|
onClick: toggleColumn,
|
|
124
132
|
name: column.field,
|
|
125
|
-
color: "primary",
|
|
126
133
|
size: "small"
|
|
127
134
|
}, rootProps.componentsProps?.baseSwitch)),
|
|
128
135
|
label: column.headerName || column.field
|
|
@@ -138,13 +145,11 @@ export function GridColumnsPanel(props) {
|
|
|
138
145
|
})
|
|
139
146
|
}), /*#__PURE__*/_jsxs(GridPanelFooter, {
|
|
140
147
|
children: [/*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
141
|
-
onClick: () => toggleAllColumns(false)
|
|
142
|
-
color: "primary"
|
|
148
|
+
onClick: () => toggleAllColumns(false)
|
|
143
149
|
}, rootProps.componentsProps?.baseButton, {
|
|
144
150
|
children: apiRef.current.getLocaleText('columnsPanelHideAllButton')
|
|
145
151
|
})), /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
|
|
146
|
-
onClick: () => toggleAllColumns(true)
|
|
147
|
-
color: "primary"
|
|
152
|
+
onClick: () => toggleAllColumns(true)
|
|
148
153
|
}, rootProps.componentsProps?.baseButton, {
|
|
149
154
|
children: apiRef.current.getLocaleText('columnsPanelShowAllButton')
|
|
150
155
|
}))]
|
|
@@ -35,7 +35,7 @@ const GridPanelWrapperRoot = styled('div', {
|
|
|
35
35
|
|
|
36
36
|
const isEnabled = () => true;
|
|
37
37
|
|
|
38
|
-
function GridPanelWrapper(props) {
|
|
38
|
+
const GridPanelWrapper = /*#__PURE__*/React.forwardRef(function GridPanelWrapper(props, ref) {
|
|
39
39
|
const {
|
|
40
40
|
className
|
|
41
41
|
} = props,
|
|
@@ -51,10 +51,10 @@ function GridPanelWrapper(props) {
|
|
|
51
51
|
disableEnforceFocus: true,
|
|
52
52
|
isEnabled: isEnabled,
|
|
53
53
|
children: /*#__PURE__*/_jsx(GridPanelWrapperRoot, _extends({
|
|
54
|
+
ref: ref,
|
|
54
55
|
tabIndex: -1,
|
|
55
56
|
className: clsx(className, classes.root)
|
|
56
57
|
}, other))
|
|
57
58
|
});
|
|
58
|
-
}
|
|
59
|
-
|
|
59
|
+
});
|
|
60
60
|
export { GridPanelWrapper };
|