@mui/x-data-grid 8.0.0-alpha.12 → 8.0.0-alpha.13
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 +299 -0
- package/DataGrid/DataGrid.js +31 -22
- package/DataGrid/useDataGridProps.js +1 -1
- package/colDef/gridCheckboxSelectionColDef.js +1 -3
- package/components/GridFooter.js +1 -1
- package/components/GridHeader.js +1 -1
- package/components/GridPagination.js +5 -6
- package/components/GridRowCount.js +4 -5
- package/components/GridScrollArea.js +4 -3
- package/components/GridSelectedRowCount.js +5 -6
- package/components/GridShadowScrollArea.d.ts +8 -0
- package/components/GridShadowScrollArea.js +82 -0
- package/components/cell/GridEditInputCell.js +2 -3
- package/components/columnSelection/GridHeaderCheckbox.js +51 -17
- package/components/columnsManagement/GridColumnsManagement.js +59 -61
- package/components/containers/GridOverlay.js +6 -8
- package/components/containers/GridRoot.js +4 -2
- package/components/containers/GridRootStyles.d.ts +1 -2
- package/components/containers/GridRootStyles.js +77 -100
- package/components/containers/GridToolbarContainer.js +5 -6
- package/components/menu/GridMenu.js +7 -6
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +4 -3
- package/components/panel/GridPanel.js +18 -20
- package/components/panel/GridPanelContent.js +6 -8
- package/components/panel/GridPanelFooter.js +5 -6
- package/components/panel/GridPanelHeader.js +4 -5
- package/components/panel/filterPanel/GridFilterForm.js +13 -20
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +20 -45
- package/components/panel/filterPanel/GridFilterInputValue.js +3 -6
- package/components/toolbar/GridToolbarFilterButton.js +5 -6
- package/components/toolbar/GridToolbarQuickFilter.js +23 -30
- package/components/virtualization/GridVirtualScrollbar.js +8 -5
- package/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/constants/cssVariables.d.ts +294 -0
- package/constants/cssVariables.js +168 -0
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/constants/defaultGridSlotsComponents.js +1 -1
- package/constants/gridClasses.d.ts +13 -0
- package/constants/gridClasses.js +1 -1
- package/context/GridContextProvider.js +4 -1
- package/esm/DataGrid/DataGrid.js +31 -22
- package/esm/DataGrid/useDataGridProps.js +1 -1
- package/esm/colDef/gridCheckboxSelectionColDef.js +1 -3
- package/esm/components/GridFooter.js +2 -2
- package/esm/components/GridHeader.js +1 -1
- package/esm/components/GridPagination.js +5 -6
- package/esm/components/GridRowCount.js +4 -5
- package/esm/components/GridScrollArea.js +2 -1
- package/esm/components/GridSelectedRowCount.js +5 -6
- package/esm/components/GridShadowScrollArea.d.ts +8 -0
- package/esm/components/GridShadowScrollArea.js +74 -0
- package/esm/components/cell/GridEditInputCell.js +2 -3
- package/esm/components/columnSelection/GridHeaderCheckbox.js +51 -17
- package/esm/components/columnsManagement/GridColumnsManagement.js +60 -62
- package/esm/components/containers/GridOverlay.js +6 -8
- package/esm/components/containers/GridRoot.js +4 -2
- package/esm/components/containers/GridRootStyles.d.ts +1 -2
- package/esm/components/containers/GridRootStyles.js +78 -101
- package/esm/components/containers/GridToolbarContainer.js +5 -6
- package/esm/components/menu/GridMenu.js +7 -6
- package/esm/components/menu/columnMenu/GridColumnHeaderMenu.js +2 -1
- package/esm/components/panel/GridPanel.js +18 -20
- package/esm/components/panel/GridPanelContent.js +6 -8
- package/esm/components/panel/GridPanelFooter.js +5 -6
- package/esm/components/panel/GridPanelHeader.js +4 -5
- package/esm/components/panel/filterPanel/GridFilterForm.js +13 -20
- package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/esm/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
- package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
- package/esm/components/panel/filterPanel/GridFilterInputMultipleValue.js +19 -44
- package/esm/components/panel/filterPanel/GridFilterInputValue.js +3 -6
- package/esm/components/toolbar/GridToolbarFilterButton.js +5 -6
- package/esm/components/toolbar/GridToolbarQuickFilter.js +23 -30
- package/esm/components/virtualization/GridVirtualScrollbar.js +3 -1
- package/esm/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/esm/constants/cssVariables.d.ts +294 -0
- package/esm/constants/cssVariables.js +161 -0
- package/esm/constants/dataGridPropsDefaultValues.js +1 -0
- package/esm/constants/defaultGridSlotsComponents.js +2 -2
- package/esm/constants/gridClasses.d.ts +13 -0
- package/esm/constants/gridClasses.js +1 -1
- package/esm/context/GridContextProvider.js +4 -1
- package/esm/hooks/features/clipboard/useGridClipboard.js +3 -2
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/esm/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/esm/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
- package/esm/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
- package/esm/hooks/features/columns/gridColumnsSelector.js +8 -0
- package/esm/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
- package/esm/hooks/features/columns/gridColumnsUtils.js +6 -3
- package/esm/hooks/features/columns/index.d.ts +1 -1
- package/esm/hooks/features/columns/index.js +1 -1
- package/esm/hooks/features/columns/useGridColumns.js +4 -2
- package/esm/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
- package/esm/hooks/features/dataSource/gridDataSourceError.js +32 -0
- package/esm/hooks/features/dataSource/index.d.ts +2 -0
- package/esm/hooks/features/dataSource/index.js +2 -0
- package/esm/hooks/features/dataSource/models.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
- package/esm/hooks/features/dimensions/useGridDimensions.js +11 -10
- package/esm/hooks/features/editing/useGridCellEditing.js +2 -1
- package/esm/hooks/features/editing/useGridRowEditing.js +2 -1
- package/esm/hooks/features/export/utils.js +4 -2
- package/esm/hooks/features/focus/useGridFocus.js +3 -2
- package/esm/hooks/features/index.d.ts +1 -1
- package/esm/hooks/features/index.js +1 -1
- package/esm/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/esm/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +148 -81
- package/esm/hooks/features/rowSelection/utils.d.ts +2 -2
- package/esm/hooks/features/rowSelection/utils.js +11 -11
- package/esm/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
- package/esm/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/esm/hooks/features/rows/gridRowsUtils.js +8 -0
- package/esm/hooks/features/rows/useGridParamsApi.js +2 -8
- package/esm/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
- package/esm/hooks/features/rows/useGridRows.d.ts +2 -2
- package/esm/hooks/features/rows/useGridRows.js +7 -7
- package/esm/hooks/features/virtualization/useGridVirtualScroller.js +5 -9
- package/esm/hooks/utils/useGridSelector.js +4 -1
- package/esm/hooks/utils/useIsSSR.js +4 -1
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/index.js +2 -1
- package/esm/internals/utils/propValidation.js +1 -1
- package/esm/locales/bnBD.d.ts +2 -0
- package/esm/locales/bnBD.js +167 -0
- package/esm/locales/deDE.js +3 -5
- package/esm/locales/huHU.js +10 -13
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/locales/ruRU.js +17 -21
- package/esm/material/index.d.ts +1 -0
- package/esm/material/index.js +164 -49
- package/esm/material/variables.d.ts +5 -0
- package/esm/material/variables.js +89 -0
- package/esm/models/api/gridRowSelectionApi.d.ts +4 -2
- package/esm/models/api/gridSortApi.d.ts +1 -1
- package/esm/models/configuration/gridConfiguration.d.ts +7 -1
- package/esm/models/gridBaseSlots.d.ts +56 -6
- package/esm/models/gridDataSource.d.ts +9 -4
- package/esm/models/gridRowSelectionManager.d.ts +9 -0
- package/esm/models/gridRowSelectionManager.js +36 -0
- package/esm/models/gridRowSelectionModel.d.ts +4 -2
- package/esm/models/gridSlotsComponent.d.ts +7 -27
- package/esm/models/gridSlotsComponentsProps.d.ts +3 -11
- package/esm/models/gridSortModel.d.ts +1 -1
- package/esm/models/index.d.ts +2 -1
- package/esm/models/index.js +2 -3
- package/esm/models/props/DataGridProps.d.ts +22 -17
- package/esm/utils/css/context.d.ts +14 -0
- package/esm/utils/css/context.js +54 -0
- package/esm/utils/index.d.ts +2 -1
- package/esm/utils/index.js +1 -1
- package/hooks/features/clipboard/useGridClipboard.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +28 -27
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
- package/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
- package/hooks/features/columns/gridColumnsSelector.js +9 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
- package/hooks/features/columns/gridColumnsUtils.js +6 -3
- package/hooks/features/columns/index.d.ts +1 -1
- package/hooks/features/columns/index.js +94 -10
- package/hooks/features/columns/useGridColumns.js +4 -2
- package/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
- package/hooks/features/dataSource/gridDataSourceError.js +40 -0
- package/hooks/features/dataSource/index.d.ts +2 -0
- package/hooks/features/dataSource/index.js +25 -0
- package/hooks/features/dataSource/models.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
- package/hooks/features/dimensions/useGridDimensions.js +19 -18
- package/hooks/features/editing/useGridCellEditing.js +10 -9
- package/hooks/features/editing/useGridRowEditing.js +11 -10
- package/hooks/features/export/utils.js +4 -2
- package/hooks/features/focus/useGridFocus.js +8 -7
- package/hooks/features/index.d.ts +1 -1
- package/hooks/features/index.js +11 -28
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
- package/hooks/features/rowSelection/useGridRowSelection.js +146 -79
- package/hooks/features/rowSelection/utils.d.ts +2 -2
- package/hooks/features/rowSelection/utils.js +10 -10
- package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/hooks/features/rows/gridRowsUtils.js +10 -1
- package/hooks/features/rows/useGridParamsApi.js +2 -8
- package/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +7 -7
- package/hooks/features/virtualization/useGridVirtualScroller.js +21 -25
- package/hooks/utils/useGridSelector.js +6 -2
- package/hooks/utils/useIsSSR.js +6 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +15 -0
- package/internals/utils/propValidation.js +1 -1
- package/locales/bnBD.d.ts +2 -0
- package/locales/bnBD.js +173 -0
- package/locales/deDE.js +3 -5
- package/locales/huHU.js +10 -13
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/locales/ruRU.js +17 -21
- package/material/index.d.ts +1 -0
- package/material/index.js +170 -49
- package/material/variables.d.ts +5 -0
- package/material/variables.js +95 -0
- package/models/api/gridRowSelectionApi.d.ts +4 -2
- package/models/api/gridSortApi.d.ts +1 -1
- package/models/configuration/gridConfiguration.d.ts +7 -1
- package/models/gridBaseSlots.d.ts +56 -6
- package/models/gridDataSource.d.ts +9 -4
- package/models/gridRowSelectionManager.d.ts +9 -0
- package/models/gridRowSelectionManager.js +43 -0
- package/models/gridRowSelectionModel.d.ts +4 -2
- package/models/gridSlotsComponent.d.ts +7 -27
- package/models/gridSlotsComponentsProps.d.ts +3 -11
- package/models/gridSortModel.d.ts +1 -1
- package/models/index.d.ts +2 -1
- package/models/index.js +34 -11
- package/models/props/DataGridProps.d.ts +22 -17
- package/modern/DataGrid/DataGrid.js +31 -22
- package/modern/DataGrid/useDataGridProps.js +1 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +1 -3
- package/modern/components/GridFooter.js +2 -2
- package/modern/components/GridHeader.js +1 -1
- package/modern/components/GridPagination.js +5 -6
- package/modern/components/GridRowCount.js +4 -5
- package/modern/components/GridScrollArea.js +2 -1
- package/modern/components/GridSelectedRowCount.js +5 -6
- package/modern/components/GridShadowScrollArea.d.ts +8 -0
- package/modern/components/GridShadowScrollArea.js +74 -0
- package/modern/components/cell/GridEditInputCell.js +2 -3
- package/modern/components/columnSelection/GridHeaderCheckbox.js +51 -17
- package/modern/components/columnsManagement/GridColumnsManagement.js +60 -62
- package/modern/components/containers/GridOverlay.js +6 -8
- package/modern/components/containers/GridRoot.js +4 -2
- package/modern/components/containers/GridRootStyles.d.ts +1 -2
- package/modern/components/containers/GridRootStyles.js +78 -101
- package/modern/components/containers/GridToolbarContainer.js +5 -6
- package/modern/components/menu/GridMenu.js +7 -6
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +2 -1
- package/modern/components/panel/GridPanel.js +18 -20
- package/modern/components/panel/GridPanelContent.js +6 -8
- package/modern/components/panel/GridPanelFooter.js +5 -6
- package/modern/components/panel/GridPanelHeader.js +4 -5
- package/modern/components/panel/filterPanel/GridFilterForm.js +13 -20
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +10 -39
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +19 -44
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +3 -6
- package/modern/components/toolbar/GridToolbarFilterButton.js +5 -6
- package/modern/components/toolbar/GridToolbarQuickFilter.js +23 -30
- package/modern/components/virtualization/GridVirtualScrollbar.js +3 -1
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/modern/constants/cssVariables.d.ts +294 -0
- package/modern/constants/cssVariables.js +161 -0
- package/modern/constants/dataGridPropsDefaultValues.js +1 -0
- package/modern/constants/defaultGridSlotsComponents.js +2 -2
- package/modern/constants/gridClasses.d.ts +13 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/context/GridContextProvider.js +4 -1
- package/modern/hooks/features/clipboard/useGridClipboard.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +2 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -0
- package/modern/hooks/features/columns/gridColumnsSelector.d.ts +7 -0
- package/modern/hooks/features/columns/gridColumnsSelector.js +8 -0
- package/modern/hooks/features/columns/gridColumnsUtils.d.ts +3 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +6 -3
- package/modern/hooks/features/columns/index.d.ts +1 -1
- package/modern/hooks/features/columns/index.js +1 -1
- package/modern/hooks/features/columns/useGridColumns.js +4 -2
- package/modern/hooks/features/dataSource/gridDataSourceError.d.ts +31 -0
- package/modern/hooks/features/dataSource/gridDataSourceError.js +32 -0
- package/modern/hooks/features/dataSource/index.d.ts +2 -0
- package/modern/hooks/features/dataSource/index.js +2 -0
- package/modern/hooks/features/dataSource/models.d.ts +1 -1
- package/modern/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/modern/hooks/features/dataSource/useGridDataSourceBase.js +27 -17
- package/modern/hooks/features/dimensions/useGridDimensions.js +11 -10
- package/modern/hooks/features/editing/useGridCellEditing.js +2 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +2 -1
- package/modern/hooks/features/export/utils.js +4 -2
- package/modern/hooks/features/focus/useGridFocus.js +3 -2
- package/modern/hooks/features/index.d.ts +1 -1
- package/modern/hooks/features/index.js +1 -1
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +27 -7
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +148 -81
- package/modern/hooks/features/rowSelection/utils.d.ts +2 -2
- package/modern/hooks/features/rowSelection/utils.js +11 -11
- package/modern/hooks/features/rows/gridRowsInterfaces.d.ts +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.d.ts +2 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +8 -0
- package/modern/hooks/features/rows/useGridParamsApi.js +2 -8
- package/modern/hooks/features/rows/useGridRowAriaAttributes.js +2 -4
- package/modern/hooks/features/rows/useGridRows.d.ts +2 -2
- package/modern/hooks/features/rows/useGridRows.js +7 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -9
- package/modern/hooks/utils/useGridSelector.js +4 -1
- package/modern/hooks/utils/useIsSSR.js +4 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.d.ts +2 -1
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/locales/bnBD.d.ts +2 -0
- package/modern/locales/bnBD.js +167 -0
- package/modern/locales/deDE.js +3 -5
- package/modern/locales/huHU.js +10 -13
- package/modern/locales/index.d.ts +1 -0
- package/modern/locales/index.js +1 -0
- package/modern/locales/ruRU.js +17 -21
- package/modern/material/index.d.ts +1 -0
- package/modern/material/index.js +164 -49
- package/modern/material/variables.d.ts +5 -0
- package/modern/material/variables.js +89 -0
- package/modern/models/api/gridRowSelectionApi.d.ts +4 -2
- package/modern/models/api/gridSortApi.d.ts +1 -1
- package/modern/models/configuration/gridConfiguration.d.ts +7 -1
- package/modern/models/gridBaseSlots.d.ts +56 -6
- package/modern/models/gridDataSource.d.ts +9 -4
- package/modern/models/gridRowSelectionManager.d.ts +9 -0
- package/modern/models/gridRowSelectionManager.js +36 -0
- package/modern/models/gridRowSelectionModel.d.ts +4 -2
- package/modern/models/gridSlotsComponent.d.ts +7 -27
- package/modern/models/gridSlotsComponentsProps.d.ts +3 -11
- package/modern/models/gridSortModel.d.ts +1 -1
- package/modern/models/index.d.ts +2 -1
- package/modern/models/index.js +2 -3
- package/modern/models/props/DataGridProps.d.ts +22 -17
- package/modern/utils/css/context.d.ts +14 -0
- package/modern/utils/css/context.js +54 -0
- package/modern/utils/index.d.ts +2 -1
- package/modern/utils/index.js +1 -1
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/css/context.d.ts +14 -0
- package/utils/css/context.js +64 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +8 -1
|
@@ -232,7 +232,8 @@ const createColumnsState = ({
|
|
|
232
232
|
columnsToUpsert,
|
|
233
233
|
initialState,
|
|
234
234
|
columnVisibilityModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef),
|
|
235
|
-
keepOnlyColumnsToUpsert = false
|
|
235
|
+
keepOnlyColumnsToUpsert = false,
|
|
236
|
+
updateInitialVisibilityModel = false
|
|
236
237
|
}) => {
|
|
237
238
|
const isInsideStateInitializer = !apiRef.current.state.columns;
|
|
238
239
|
let columnsState;
|
|
@@ -240,7 +241,8 @@ const createColumnsState = ({
|
|
|
240
241
|
columnsState = {
|
|
241
242
|
orderedFields: [],
|
|
242
243
|
lookup: {},
|
|
243
|
-
columnVisibilityModel
|
|
244
|
+
columnVisibilityModel,
|
|
245
|
+
initialColumnVisibilityModel: columnVisibilityModel
|
|
244
246
|
};
|
|
245
247
|
} else {
|
|
246
248
|
const currentState = (0, _gridColumnsSelector.gridColumnsStateSelector)(apiRef);
|
|
@@ -248,7 +250,8 @@ const createColumnsState = ({
|
|
|
248
250
|
orderedFields: keepOnlyColumnsToUpsert ? [] : [...currentState.orderedFields],
|
|
249
251
|
lookup: (0, _extends2.default)({}, currentState.lookup),
|
|
250
252
|
// Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
251
|
-
columnVisibilityModel
|
|
253
|
+
columnVisibilityModel,
|
|
254
|
+
initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
|
|
252
255
|
};
|
|
253
256
|
}
|
|
254
257
|
let columnsToKeep = {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { gridColumnsStateSelector, gridColumnFieldsSelector, gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector, gridPinnedColumnsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridFilterableColumnDefinitionsSelector, gridFilterableColumnLookupSelector, gridHasColSpanSelector } from "./gridColumnsSelector.js";
|
|
2
2
|
export * from "./gridColumnsInterfaces.js";
|
|
@@ -3,20 +3,104 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
gridColumnsStateSelector: true,
|
|
8
|
+
gridColumnFieldsSelector: true,
|
|
9
|
+
gridColumnLookupSelector: true,
|
|
10
|
+
gridColumnVisibilityModelSelector: true,
|
|
11
|
+
gridColumnDefinitionsSelector: true,
|
|
12
|
+
gridVisibleColumnDefinitionsSelector: true,
|
|
13
|
+
gridVisibleColumnFieldsSelector: true,
|
|
14
|
+
gridPinnedColumnsSelector: true,
|
|
15
|
+
gridVisiblePinnedColumnDefinitionsSelector: true,
|
|
16
|
+
gridColumnPositionsSelector: true,
|
|
17
|
+
gridFilterableColumnDefinitionsSelector: true,
|
|
18
|
+
gridFilterableColumnLookupSelector: true,
|
|
19
|
+
gridHasColSpanSelector: true
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "gridColumnDefinitionsSelector", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _gridColumnsSelector.gridColumnDefinitionsSelector;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "gridColumnFieldsSelector", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _gridColumnsSelector.gridColumnFieldsSelector;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "gridColumnLookupSelector", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _gridColumnsSelector.gridColumnLookupSelector;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "gridColumnPositionsSelector", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return _gridColumnsSelector.gridColumnPositionsSelector;
|
|
43
|
+
}
|
|
16
44
|
});
|
|
45
|
+
Object.defineProperty(exports, "gridColumnVisibilityModelSelector", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return _gridColumnsSelector.gridColumnVisibilityModelSelector;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "gridColumnsStateSelector", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _gridColumnsSelector.gridColumnsStateSelector;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "gridFilterableColumnDefinitionsSelector", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () {
|
|
60
|
+
return _gridColumnsSelector.gridFilterableColumnDefinitionsSelector;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "gridFilterableColumnLookupSelector", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () {
|
|
66
|
+
return _gridColumnsSelector.gridFilterableColumnLookupSelector;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "gridHasColSpanSelector", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () {
|
|
72
|
+
return _gridColumnsSelector.gridHasColSpanSelector;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "gridPinnedColumnsSelector", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return _gridColumnsSelector.gridPinnedColumnsSelector;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "gridVisibleColumnDefinitionsSelector", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return _gridColumnsSelector.gridVisibleColumnDefinitionsSelector;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "gridVisibleColumnFieldsSelector", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _gridColumnsSelector.gridVisibleColumnFieldsSelector;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "gridVisiblePinnedColumnDefinitionsSelector", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
var _gridColumnsSelector = require("./gridColumnsSelector");
|
|
17
100
|
var _gridColumnsInterfaces = require("./gridColumnsInterfaces");
|
|
18
101
|
Object.keys(_gridColumnsInterfaces).forEach(function (key) {
|
|
19
102
|
if (key === "default" || key === "__esModule") return;
|
|
103
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
104
|
if (key in exports && exports[key] === _gridColumnsInterfaces[key]) return;
|
|
21
105
|
Object.defineProperty(exports, key, {
|
|
22
106
|
enumerable: true,
|
|
@@ -92,7 +92,8 @@ function useGridColumns(apiRef, props) {
|
|
|
92
92
|
apiRef,
|
|
93
93
|
columnsToUpsert: columns,
|
|
94
94
|
initialState: undefined,
|
|
95
|
-
keepOnlyColumnsToUpsert: false
|
|
95
|
+
keepOnlyColumnsToUpsert: false,
|
|
96
|
+
updateInitialVisibilityModel: true
|
|
96
97
|
});
|
|
97
98
|
setGridColumnsState(columnsState);
|
|
98
99
|
}, [apiRef, setGridColumnsState]);
|
|
@@ -298,7 +299,8 @@ function useGridColumns(apiRef, props) {
|
|
|
298
299
|
initialState: undefined,
|
|
299
300
|
// If the user provides a model, we don't want to set it in the state here because it has it's dedicated `useEffect` which calls `setColumnVisibilityModel`
|
|
300
301
|
columnsToUpsert: props.columns,
|
|
301
|
-
keepOnlyColumnsToUpsert: true
|
|
302
|
+
keepOnlyColumnsToUpsert: true,
|
|
303
|
+
updateInitialVisibilityModel: true
|
|
302
304
|
});
|
|
303
305
|
previousColumnsProp.current = props.columns;
|
|
304
306
|
setGridColumnsState(columnsState);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { GridGetRowsParams, GridUpdateRowParams } from '../../../models/gridDataSource';
|
|
2
|
+
export declare class GridGetRowsError<T extends GridGetRowsParams = GridGetRowsParams> extends Error {
|
|
3
|
+
/**
|
|
4
|
+
* The parameters used in the failed request
|
|
5
|
+
*/
|
|
6
|
+
readonly params: T;
|
|
7
|
+
/**
|
|
8
|
+
* The original error that caused this error
|
|
9
|
+
*/
|
|
10
|
+
readonly cause?: Error;
|
|
11
|
+
constructor(options: {
|
|
12
|
+
message: string;
|
|
13
|
+
params: T;
|
|
14
|
+
cause?: Error;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export declare class GridUpdateRowError extends Error {
|
|
18
|
+
/**
|
|
19
|
+
* The parameters used in the failed request
|
|
20
|
+
*/
|
|
21
|
+
readonly params: GridUpdateRowParams;
|
|
22
|
+
/**
|
|
23
|
+
* The original error that caused this error
|
|
24
|
+
*/
|
|
25
|
+
readonly cause?: Error;
|
|
26
|
+
constructor(options: {
|
|
27
|
+
message: string;
|
|
28
|
+
params: GridUpdateRowParams;
|
|
29
|
+
cause?: Error;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GridUpdateRowError = exports.GridGetRowsError = void 0;
|
|
7
|
+
class GridGetRowsError extends Error {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super(options.message);
|
|
10
|
+
/**
|
|
11
|
+
* The parameters used in the failed request
|
|
12
|
+
*/
|
|
13
|
+
this.params = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* The original error that caused this error
|
|
16
|
+
*/
|
|
17
|
+
this.cause = void 0;
|
|
18
|
+
this.name = 'GridGetRowsError';
|
|
19
|
+
this.params = options.params;
|
|
20
|
+
this.cause = options.cause;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.GridGetRowsError = GridGetRowsError;
|
|
24
|
+
class GridUpdateRowError extends Error {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
super(options.message);
|
|
27
|
+
/**
|
|
28
|
+
* The parameters used in the failed request
|
|
29
|
+
*/
|
|
30
|
+
this.params = void 0;
|
|
31
|
+
/**
|
|
32
|
+
* The original error that caused this error
|
|
33
|
+
*/
|
|
34
|
+
this.cause = void 0;
|
|
35
|
+
this.name = 'GridUpdateRowError';
|
|
36
|
+
this.params = options.params;
|
|
37
|
+
this.cause = options.cause;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.GridUpdateRowError = GridUpdateRowError;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "GridDataSourceCacheDefault", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _cache.GridDataSourceCacheDefault;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "GridGetRowsError", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _gridDataSourceError.GridGetRowsError;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "GridUpdateRowError", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _gridDataSourceError.GridUpdateRowError;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _cache = require("./cache");
|
|
25
|
+
var _gridDataSourceError = require("./gridDataSourceError");
|
|
@@ -8,7 +8,7 @@ import type { DataGridProcessedProps } from '../../../models/props/DataGridProps
|
|
|
8
8
|
import type { GridStrategyProcessor } from '../../core/strategyProcessing';
|
|
9
9
|
import type { GridEventListener } from '../../../models/events';
|
|
10
10
|
import type { GridRowId } from '../../../models';
|
|
11
|
-
export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "
|
|
11
|
+
export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "dataSource" | "dataSourceCache" | "onDataSourceError" | "pageSizeOptions" | "signature">, options?: {
|
|
12
12
|
cacheOptions?: GridDataSourceCacheDefaultConfig;
|
|
13
13
|
fetchRowChildren?: (parents: GridRowId[]) => void;
|
|
14
14
|
clearDataSourceState?: () => void;
|
|
@@ -10,6 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
12
12
|
var _utils = require("@mui/utils");
|
|
13
|
+
var _warning = require("@mui/x-internals/warning");
|
|
13
14
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
14
15
|
var _utils2 = require("../../../utils/utils");
|
|
15
16
|
var _strategyProcessing = require("../../core/strategyProcessing");
|
|
@@ -18,6 +19,7 @@ var _gridPaginationSelector = require("../pagination/gridPaginationSelector");
|
|
|
18
19
|
var _gridDataSourceSelector = require("./gridDataSourceSelector");
|
|
19
20
|
var _utils3 = require("./utils");
|
|
20
21
|
var _cache = require("./cache");
|
|
22
|
+
var _gridDataSourceError = require("./gridDataSourceError");
|
|
21
23
|
const noopCache = {
|
|
22
24
|
clear: () => {},
|
|
23
25
|
get: () => undefined,
|
|
@@ -31,20 +33,20 @@ function getCache(cacheProp, options = {}) {
|
|
|
31
33
|
}
|
|
32
34
|
const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
33
35
|
const setStrategyAvailability = React.useCallback(() => {
|
|
34
|
-
apiRef.current.setStrategyAvailability(_strategyProcessing.GridStrategyGroup.DataSource, _utils3.DataSourceRowsUpdateStrategy.Default, props.
|
|
35
|
-
}, [apiRef, props.
|
|
36
|
+
apiRef.current.setStrategyAvailability(_strategyProcessing.GridStrategyGroup.DataSource, _utils3.DataSourceRowsUpdateStrategy.Default, props.dataSource ? () => true : () => false);
|
|
37
|
+
}, [apiRef, props.dataSource]);
|
|
36
38
|
const [defaultRowsUpdateStrategyActive, setDefaultRowsUpdateStrategyActive] = React.useState(false);
|
|
37
39
|
const paginationModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationModelSelector);
|
|
38
40
|
const lastRequestId = React.useRef(0);
|
|
39
|
-
const
|
|
41
|
+
const onDataSourceErrorProp = props.onDataSourceError;
|
|
40
42
|
const cacheChunkManager = (0, _useLazyRef.default)(() => {
|
|
41
43
|
const sortedPageSizeOptions = props.pageSizeOptions.map(option => typeof option === 'number' ? option : option.value).sort((a, b) => a - b);
|
|
42
44
|
const cacheChunkSize = Math.min(paginationModel.pageSize, sortedPageSizeOptions[0]);
|
|
43
45
|
return new _utils3.CacheChunkManager(cacheChunkSize);
|
|
44
46
|
}).current;
|
|
45
|
-
const [cache, setCache] = React.useState(() => getCache(props.
|
|
47
|
+
const [cache, setCache] = React.useState(() => getCache(props.dataSourceCache, options.cacheOptions));
|
|
46
48
|
const fetchRows = React.useCallback(async (parentId, params) => {
|
|
47
|
-
const getRows = props.
|
|
49
|
+
const getRows = props.dataSource?.getRows;
|
|
48
50
|
if (!getRows) {
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
@@ -82,20 +84,28 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
82
84
|
fetchParams
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
|
-
} catch (
|
|
87
|
+
} catch (originalError) {
|
|
86
88
|
if (lastRequestId.current === requestId) {
|
|
87
89
|
apiRef.current.applyStrategyProcessor('dataSourceRowsUpdate', {
|
|
88
|
-
error:
|
|
90
|
+
error: originalError,
|
|
89
91
|
fetchParams
|
|
90
92
|
});
|
|
91
|
-
|
|
93
|
+
if (typeof onDataSourceErrorProp === 'function') {
|
|
94
|
+
onDataSourceErrorProp(new _gridDataSourceError.GridGetRowsError({
|
|
95
|
+
message: originalError?.message,
|
|
96
|
+
params: fetchParams,
|
|
97
|
+
cause: originalError
|
|
98
|
+
}));
|
|
99
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
100
|
+
(0, _warning.warnOnce)(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `unstable_onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid unstable_onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
101
|
+
}
|
|
92
102
|
}
|
|
93
103
|
} finally {
|
|
94
104
|
if (defaultRowsUpdateStrategyActive && lastRequestId.current === requestId) {
|
|
95
105
|
apiRef.current.setLoading(false);
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
|
-
}, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.
|
|
108
|
+
}, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.dataSource?.getRows, onDataSourceErrorProp, options, props.signature]);
|
|
99
109
|
const handleStrategyActivityChange = React.useCallback(() => {
|
|
100
110
|
setDefaultRowsUpdateStrategyActive(apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.DataSource) === _utils3.DataSourceRowsUpdateStrategy.Default);
|
|
101
111
|
}, [apiRef]);
|
|
@@ -117,7 +127,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
117
127
|
}, true);
|
|
118
128
|
}, [apiRef]);
|
|
119
129
|
const dataSourceApi = {
|
|
120
|
-
|
|
130
|
+
dataSource: {
|
|
121
131
|
fetchRows,
|
|
122
132
|
cache
|
|
123
133
|
}
|
|
@@ -129,18 +139,18 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
129
139
|
isFirstRender.current = false;
|
|
130
140
|
return;
|
|
131
141
|
}
|
|
132
|
-
if (props.
|
|
142
|
+
if (props.dataSourceCache === undefined) {
|
|
133
143
|
return;
|
|
134
144
|
}
|
|
135
|
-
const newCache = getCache(props.
|
|
145
|
+
const newCache = getCache(props.dataSourceCache, options.cacheOptions);
|
|
136
146
|
setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
|
|
137
|
-
}, [props.
|
|
147
|
+
}, [props.dataSourceCache, options.cacheOptions]);
|
|
138
148
|
React.useEffect(() => {
|
|
139
|
-
if (props.
|
|
140
|
-
apiRef.current.
|
|
141
|
-
apiRef.current.
|
|
149
|
+
if (props.dataSource) {
|
|
150
|
+
apiRef.current.dataSource.cache.clear();
|
|
151
|
+
apiRef.current.dataSource.fetchRows();
|
|
142
152
|
}
|
|
143
|
-
}, [apiRef, props.
|
|
153
|
+
}, [apiRef, props.dataSource]);
|
|
144
154
|
return {
|
|
145
155
|
api: {
|
|
146
156
|
public: dataSourceApi
|
|
@@ -9,7 +9,9 @@ exports.dimensionsStateInitializer = void 0;
|
|
|
9
9
|
exports.useGridDimensions = useGridDimensions;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
-
var
|
|
12
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
|
+
var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
|
|
13
15
|
var _throttle = require("@mui/x-internals/throttle");
|
|
14
16
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
15
17
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
@@ -19,7 +21,7 @@ var _columns = require("../columns");
|
|
|
19
21
|
var _gridDimensionsSelectors = require("./gridDimensionsSelectors");
|
|
20
22
|
var _density = require("../density");
|
|
21
23
|
var _virtualization = require("../virtualization");
|
|
22
|
-
var
|
|
24
|
+
var _utils = require("../../utils");
|
|
23
25
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
24
26
|
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
25
27
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
@@ -27,7 +29,7 @@ var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
|
27
29
|
var _dataGridPropsDefaultValues = require("../../../constants/dataGridPropsDefaultValues");
|
|
28
30
|
var _roundToDecimalPlaces = require("../../../utils/roundToDecimalPlaces");
|
|
29
31
|
var _isJSDOM = require("../../../utils/isJSDOM");
|
|
30
|
-
var
|
|
32
|
+
var _utils2 = require("../../../utils/utils");
|
|
31
33
|
const EMPTY_SIZE = {
|
|
32
34
|
width: 0,
|
|
33
35
|
height: 0
|
|
@@ -73,9 +75,9 @@ function useGridDimensions(apiRef, props) {
|
|
|
73
75
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useResizeContainer');
|
|
74
76
|
const errorShown = React.useRef(false);
|
|
75
77
|
const rootDimensionsRef = React.useRef(EMPTY_SIZE);
|
|
76
|
-
const pinnedColumns = (0,
|
|
77
|
-
const densityFactor = (0,
|
|
78
|
-
const columnsTotalWidth = (0,
|
|
78
|
+
const pinnedColumns = (0, _utils.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
|
|
79
|
+
const densityFactor = (0, _utils.useGridSelector)(apiRef, _density.gridDensityFactorSelector);
|
|
80
|
+
const columnsTotalWidth = (0, _utils.useGridSelector)(apiRef, columnsTotalWidthSelector);
|
|
79
81
|
const isFirstSizing = React.useRef(true);
|
|
80
82
|
const {
|
|
81
83
|
rowHeight,
|
|
@@ -119,8 +121,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
119
121
|
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
120
122
|
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
121
123
|
// https://github.com/mui/mui-x/issues/15721
|
|
122
|
-
const
|
|
123
|
-
const scrollbarSize = measureScrollbarSize(rootElement, props.scrollbarSize);
|
|
124
|
+
const scrollbarSize = measureScrollbarSize(apiRef.current.mainElementRef.current, props.scrollbarSize);
|
|
124
125
|
const rowsMeta = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef);
|
|
125
126
|
const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
|
|
126
127
|
const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
|
|
@@ -200,7 +201,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
200
201
|
bottomContainerHeight
|
|
201
202
|
};
|
|
202
203
|
const prevDimensions = apiRef.current.state.dimensions;
|
|
203
|
-
if ((0,
|
|
204
|
+
if ((0, _utils2.isDeepEqual)(prevDimensions, newDimensions)) {
|
|
204
205
|
return;
|
|
205
206
|
}
|
|
206
207
|
setDimensions(newDimensions);
|
|
@@ -209,7 +210,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
209
210
|
}
|
|
210
211
|
apiRef.current.updateRenderContext?.();
|
|
211
212
|
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
212
|
-
const updateDimensionCallback = (0,
|
|
213
|
+
const updateDimensionCallback = (0, _useEventCallback.default)(updateDimensions);
|
|
213
214
|
const debouncedUpdateDimensions = React.useMemo(() => props.resizeThrottleMs > 0 ? (0, _throttle.throttle)(() => {
|
|
214
215
|
updateDimensionCallback();
|
|
215
216
|
apiRef.current.publishEvent('debouncedResize', rootDimensionsRef.current);
|
|
@@ -222,7 +223,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
222
223
|
updateDimensions,
|
|
223
224
|
getViewportPageSize
|
|
224
225
|
};
|
|
225
|
-
(0,
|
|
226
|
+
(0, _useEnhancedEffect.default)(updateDimensions, [updateDimensions]);
|
|
226
227
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, apiPublic, 'public');
|
|
227
228
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, apiPrivate, 'private');
|
|
228
229
|
const handleRootMount = React.useCallback(root => {
|
|
@@ -279,28 +280,28 @@ function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
|
|
|
279
280
|
};
|
|
280
281
|
}
|
|
281
282
|
const scrollbarSizeCache = new WeakMap();
|
|
282
|
-
function measureScrollbarSize(
|
|
283
|
+
function measureScrollbarSize(element, scrollbarSize) {
|
|
283
284
|
if (scrollbarSize !== undefined) {
|
|
284
285
|
return scrollbarSize;
|
|
285
286
|
}
|
|
286
|
-
if (
|
|
287
|
+
if (element === null) {
|
|
287
288
|
return 0;
|
|
288
289
|
}
|
|
289
|
-
const cachedSize = scrollbarSizeCache.get(
|
|
290
|
+
const cachedSize = scrollbarSizeCache.get(element);
|
|
290
291
|
if (cachedSize !== undefined) {
|
|
291
292
|
return cachedSize;
|
|
292
293
|
}
|
|
293
|
-
const doc = (0,
|
|
294
|
+
const doc = (0, _ownerDocument.default)(element);
|
|
294
295
|
const scrollDiv = doc.createElement('div');
|
|
295
296
|
scrollDiv.style.width = '99px';
|
|
296
297
|
scrollDiv.style.height = '99px';
|
|
297
298
|
scrollDiv.style.position = 'absolute';
|
|
298
299
|
scrollDiv.style.overflow = 'scroll';
|
|
299
300
|
scrollDiv.className = 'scrollDiv';
|
|
300
|
-
|
|
301
|
+
element.appendChild(scrollDiv);
|
|
301
302
|
const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
302
|
-
|
|
303
|
-
scrollbarSizeCache.set(
|
|
303
|
+
element.removeChild(scrollDiv);
|
|
304
|
+
scrollbarSizeCache.set(element, size);
|
|
304
305
|
return size;
|
|
305
306
|
}
|
|
306
307
|
function areElementSizesEqual(a, b) {
|
|
@@ -10,7 +10,8 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
10
10
|
var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
-
var
|
|
13
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
14
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
15
|
var _warning = require("@mui/x-internals/warning");
|
|
15
16
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
16
17
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
@@ -18,9 +19,9 @@ var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
|
18
19
|
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
19
20
|
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
20
21
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
21
|
-
var
|
|
22
|
+
var _utils = require("../../../utils/utils");
|
|
22
23
|
var _gridEditCellParams = require("../../../models/params/gridEditCellParams");
|
|
23
|
-
var
|
|
24
|
+
var _utils2 = require("./utils");
|
|
24
25
|
const _excluded = ["id", "field"],
|
|
25
26
|
_excluded2 = ["id", "field"];
|
|
26
27
|
const useGridCellEditing = (apiRef, props) => {
|
|
@@ -186,7 +187,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
186
187
|
const isEditing = editingState[id] && editingState[id][field];
|
|
187
188
|
return isEditing ? _gridEditRowModel.GridCellModes.Edit : _gridEditRowModel.GridCellModes.View;
|
|
188
189
|
}, [apiRef]);
|
|
189
|
-
const updateCellModesModel = (0,
|
|
190
|
+
const updateCellModesModel = (0, _useEventCallback.default)(newModel => {
|
|
190
191
|
const isNewModelDifferentFromProp = newModel !== props.cellModesModel;
|
|
191
192
|
if (onCellModesModelChange && isNewModelDifferentFromProp) {
|
|
192
193
|
onCellModesModelChange(newModel, {
|
|
@@ -248,7 +249,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
248
249
|
mode: _gridEditRowModel.GridCellModes.Edit
|
|
249
250
|
}, other));
|
|
250
251
|
}, [throwIfNotEditable, throwIfNotInMode, updateFieldInCellModesModel]);
|
|
251
|
-
const updateStateToStartCellEditMode = (0,
|
|
252
|
+
const updateStateToStartCellEditMode = (0, _useEventCallback.default)(async params => {
|
|
252
253
|
const {
|
|
253
254
|
id,
|
|
254
255
|
field,
|
|
@@ -258,7 +259,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
258
259
|
const value = apiRef.current.getCellValue(id, field);
|
|
259
260
|
let newValue = value;
|
|
260
261
|
if (deleteValue) {
|
|
261
|
-
newValue = (0,
|
|
262
|
+
newValue = (0, _utils2.getDefaultCellValue)(apiRef.current.getColumn(field));
|
|
262
263
|
} else if (initialValue) {
|
|
263
264
|
newValue = initialValue;
|
|
264
265
|
}
|
|
@@ -299,7 +300,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
299
300
|
mode: _gridEditRowModel.GridCellModes.View
|
|
300
301
|
}, other));
|
|
301
302
|
}, [throwIfNotInMode, updateFieldInCellModesModel]);
|
|
302
|
-
const updateStateToStopCellEditMode = (0,
|
|
303
|
+
const updateStateToStopCellEditMode = (0, _useEventCallback.default)(async params => {
|
|
303
304
|
const {
|
|
304
305
|
id,
|
|
305
306
|
field,
|
|
@@ -448,12 +449,12 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
448
449
|
}, [cellModesModelProp, updateCellModesModel]);
|
|
449
450
|
|
|
450
451
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
451
|
-
(0,
|
|
452
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
452
453
|
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
453
454
|
|
|
454
455
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|
|
455
456
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
456
|
-
prevCellModesModel.current = (0,
|
|
457
|
+
prevCellModesModel.current = (0, _utils.deepClone)(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
457
458
|
|
|
458
459
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
459
460
|
Object.entries(fields).forEach(([field, params]) => {
|