@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
|
@@ -218,7 +218,8 @@ export const createColumnsState = ({
|
|
|
218
218
|
columnsToUpsert,
|
|
219
219
|
initialState,
|
|
220
220
|
columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef),
|
|
221
|
-
keepOnlyColumnsToUpsert = false
|
|
221
|
+
keepOnlyColumnsToUpsert = false,
|
|
222
|
+
updateInitialVisibilityModel = false
|
|
222
223
|
}) => {
|
|
223
224
|
const isInsideStateInitializer = !apiRef.current.state.columns;
|
|
224
225
|
let columnsState;
|
|
@@ -226,7 +227,8 @@ export const createColumnsState = ({
|
|
|
226
227
|
columnsState = {
|
|
227
228
|
orderedFields: [],
|
|
228
229
|
lookup: {},
|
|
229
|
-
columnVisibilityModel
|
|
230
|
+
columnVisibilityModel,
|
|
231
|
+
initialColumnVisibilityModel: columnVisibilityModel
|
|
230
232
|
};
|
|
231
233
|
} else {
|
|
232
234
|
const currentState = gridColumnsStateSelector(apiRef);
|
|
@@ -234,7 +236,8 @@ export const createColumnsState = ({
|
|
|
234
236
|
orderedFields: keepOnlyColumnsToUpsert ? [] : [...currentState.orderedFields],
|
|
235
237
|
lookup: _extends({}, currentState.lookup),
|
|
236
238
|
// Will be cleaned later if keepOnlyColumnsToUpsert=true
|
|
237
|
-
columnVisibilityModel
|
|
239
|
+
columnVisibilityModel,
|
|
240
|
+
initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
|
|
238
241
|
};
|
|
239
242
|
}
|
|
240
243
|
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";
|
|
@@ -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";
|
|
@@ -82,7 +82,8 @@ export function useGridColumns(apiRef, props) {
|
|
|
82
82
|
apiRef,
|
|
83
83
|
columnsToUpsert: columns,
|
|
84
84
|
initialState: undefined,
|
|
85
|
-
keepOnlyColumnsToUpsert: false
|
|
85
|
+
keepOnlyColumnsToUpsert: false,
|
|
86
|
+
updateInitialVisibilityModel: true
|
|
86
87
|
});
|
|
87
88
|
setGridColumnsState(columnsState);
|
|
88
89
|
}, [apiRef, setGridColumnsState]);
|
|
@@ -288,7 +289,8 @@ export function useGridColumns(apiRef, props) {
|
|
|
288
289
|
initialState: undefined,
|
|
289
290
|
// 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`
|
|
290
291
|
columnsToUpsert: props.columns,
|
|
291
|
-
keepOnlyColumnsToUpsert: true
|
|
292
|
+
keepOnlyColumnsToUpsert: true,
|
|
293
|
+
updateInitialVisibilityModel: true
|
|
292
294
|
});
|
|
293
295
|
previousColumnsProp.current = props.columns;
|
|
294
296
|
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,32 @@
|
|
|
1
|
+
export class GridGetRowsError extends Error {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
super(options.message);
|
|
4
|
+
/**
|
|
5
|
+
* The parameters used in the failed request
|
|
6
|
+
*/
|
|
7
|
+
this.params = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* The original error that caused this error
|
|
10
|
+
*/
|
|
11
|
+
this.cause = void 0;
|
|
12
|
+
this.name = 'GridGetRowsError';
|
|
13
|
+
this.params = options.params;
|
|
14
|
+
this.cause = options.cause;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class GridUpdateRowError extends Error {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super(options.message);
|
|
20
|
+
/**
|
|
21
|
+
* The parameters used in the failed request
|
|
22
|
+
*/
|
|
23
|
+
this.params = void 0;
|
|
24
|
+
/**
|
|
25
|
+
* The original error that caused this error
|
|
26
|
+
*/
|
|
27
|
+
this.cause = void 0;
|
|
28
|
+
this.name = 'GridUpdateRowError';
|
|
29
|
+
this.params = options.params;
|
|
30
|
+
this.cause = options.cause;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
4
|
import { unstable_debounce as debounce } from '@mui/utils';
|
|
5
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
5
6
|
import { GRID_ROOT_GROUP_ID } from "../rows/gridRowsUtils.js";
|
|
6
7
|
import { runIf } from "../../../utils/utils.js";
|
|
7
8
|
import { GridStrategyGroup } from "../../core/strategyProcessing/index.js";
|
|
@@ -10,6 +11,7 @@ import { gridPaginationModelSelector } from "../pagination/gridPaginationSelecto
|
|
|
10
11
|
import { gridGetRowsParamsSelector } from "./gridDataSourceSelector.js";
|
|
11
12
|
import { CacheChunkManager, DataSourceRowsUpdateStrategy } from "./utils.js";
|
|
12
13
|
import { GridDataSourceCacheDefault } from "./cache.js";
|
|
14
|
+
import { GridGetRowsError } from "./gridDataSourceError.js";
|
|
13
15
|
const noopCache = {
|
|
14
16
|
clear: () => {},
|
|
15
17
|
get: () => undefined,
|
|
@@ -23,20 +25,20 @@ function getCache(cacheProp, options = {}) {
|
|
|
23
25
|
}
|
|
24
26
|
export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
25
27
|
const setStrategyAvailability = React.useCallback(() => {
|
|
26
|
-
apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, DataSourceRowsUpdateStrategy.Default, props.
|
|
27
|
-
}, [apiRef, props.
|
|
28
|
+
apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, DataSourceRowsUpdateStrategy.Default, props.dataSource ? () => true : () => false);
|
|
29
|
+
}, [apiRef, props.dataSource]);
|
|
28
30
|
const [defaultRowsUpdateStrategyActive, setDefaultRowsUpdateStrategyActive] = React.useState(false);
|
|
29
31
|
const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
|
|
30
32
|
const lastRequestId = React.useRef(0);
|
|
31
|
-
const
|
|
33
|
+
const onDataSourceErrorProp = props.onDataSourceError;
|
|
32
34
|
const cacheChunkManager = useLazyRef(() => {
|
|
33
35
|
const sortedPageSizeOptions = props.pageSizeOptions.map(option => typeof option === 'number' ? option : option.value).sort((a, b) => a - b);
|
|
34
36
|
const cacheChunkSize = Math.min(paginationModel.pageSize, sortedPageSizeOptions[0]);
|
|
35
37
|
return new CacheChunkManager(cacheChunkSize);
|
|
36
38
|
}).current;
|
|
37
|
-
const [cache, setCache] = React.useState(() => getCache(props.
|
|
39
|
+
const [cache, setCache] = React.useState(() => getCache(props.dataSourceCache, options.cacheOptions));
|
|
38
40
|
const fetchRows = React.useCallback(async (parentId, params) => {
|
|
39
|
-
const getRows = props.
|
|
41
|
+
const getRows = props.dataSource?.getRows;
|
|
40
42
|
if (!getRows) {
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
@@ -74,20 +76,28 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
74
76
|
fetchParams
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
|
-
} catch (
|
|
79
|
+
} catch (originalError) {
|
|
78
80
|
if (lastRequestId.current === requestId) {
|
|
79
81
|
apiRef.current.applyStrategyProcessor('dataSourceRowsUpdate', {
|
|
80
|
-
error:
|
|
82
|
+
error: originalError,
|
|
81
83
|
fetchParams
|
|
82
84
|
});
|
|
83
|
-
|
|
85
|
+
if (typeof onDataSourceErrorProp === 'function') {
|
|
86
|
+
onDataSourceErrorProp(new GridGetRowsError({
|
|
87
|
+
message: originalError?.message,
|
|
88
|
+
params: fetchParams,
|
|
89
|
+
cause: originalError
|
|
90
|
+
}));
|
|
91
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
92
|
+
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');
|
|
93
|
+
}
|
|
84
94
|
}
|
|
85
95
|
} finally {
|
|
86
96
|
if (defaultRowsUpdateStrategyActive && lastRequestId.current === requestId) {
|
|
87
97
|
apiRef.current.setLoading(false);
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
|
-
}, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.
|
|
100
|
+
}, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.dataSource?.getRows, onDataSourceErrorProp, options, props.signature]);
|
|
91
101
|
const handleStrategyActivityChange = React.useCallback(() => {
|
|
92
102
|
setDefaultRowsUpdateStrategyActive(apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource) === DataSourceRowsUpdateStrategy.Default);
|
|
93
103
|
}, [apiRef]);
|
|
@@ -109,7 +119,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
109
119
|
}, true);
|
|
110
120
|
}, [apiRef]);
|
|
111
121
|
const dataSourceApi = {
|
|
112
|
-
|
|
122
|
+
dataSource: {
|
|
113
123
|
fetchRows,
|
|
114
124
|
cache
|
|
115
125
|
}
|
|
@@ -121,18 +131,18 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
121
131
|
isFirstRender.current = false;
|
|
122
132
|
return;
|
|
123
133
|
}
|
|
124
|
-
if (props.
|
|
134
|
+
if (props.dataSourceCache === undefined) {
|
|
125
135
|
return;
|
|
126
136
|
}
|
|
127
|
-
const newCache = getCache(props.
|
|
137
|
+
const newCache = getCache(props.dataSourceCache, options.cacheOptions);
|
|
128
138
|
setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
|
|
129
|
-
}, [props.
|
|
139
|
+
}, [props.dataSourceCache, options.cacheOptions]);
|
|
130
140
|
React.useEffect(() => {
|
|
131
|
-
if (props.
|
|
132
|
-
apiRef.current.
|
|
133
|
-
apiRef.current.
|
|
141
|
+
if (props.dataSource) {
|
|
142
|
+
apiRef.current.dataSource.cache.clear();
|
|
143
|
+
apiRef.current.dataSource.fetchRows();
|
|
134
144
|
}
|
|
135
|
-
}, [apiRef, props.
|
|
145
|
+
}, [apiRef, props.dataSource]);
|
|
136
146
|
return {
|
|
137
147
|
api: {
|
|
138
148
|
public: dataSourceApi
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
|
+
import ownerDocument from '@mui/utils/ownerDocument';
|
|
4
6
|
import { throttle } from '@mui/x-internals/throttle';
|
|
5
7
|
import { useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
6
8
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
@@ -109,8 +111,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
109
111
|
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
110
112
|
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
111
113
|
// https://github.com/mui/mui-x/issues/15721
|
|
112
|
-
const
|
|
113
|
-
const scrollbarSize = measureScrollbarSize(rootElement, props.scrollbarSize);
|
|
114
|
+
const scrollbarSize = measureScrollbarSize(apiRef.current.mainElementRef.current, props.scrollbarSize);
|
|
114
115
|
const rowsMeta = gridRowsMetaSelector(apiRef);
|
|
115
116
|
const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
|
|
116
117
|
const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
|
|
@@ -269,28 +270,28 @@ function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
|
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
272
|
const scrollbarSizeCache = new WeakMap();
|
|
272
|
-
function measureScrollbarSize(
|
|
273
|
+
function measureScrollbarSize(element, scrollbarSize) {
|
|
273
274
|
if (scrollbarSize !== undefined) {
|
|
274
275
|
return scrollbarSize;
|
|
275
276
|
}
|
|
276
|
-
if (
|
|
277
|
+
if (element === null) {
|
|
277
278
|
return 0;
|
|
278
279
|
}
|
|
279
|
-
const cachedSize = scrollbarSizeCache.get(
|
|
280
|
+
const cachedSize = scrollbarSizeCache.get(element);
|
|
280
281
|
if (cachedSize !== undefined) {
|
|
281
282
|
return cachedSize;
|
|
282
283
|
}
|
|
283
|
-
const doc = ownerDocument(
|
|
284
|
+
const doc = ownerDocument(element);
|
|
284
285
|
const scrollDiv = doc.createElement('div');
|
|
285
286
|
scrollDiv.style.width = '99px';
|
|
286
287
|
scrollDiv.style.height = '99px';
|
|
287
288
|
scrollDiv.style.position = 'absolute';
|
|
288
289
|
scrollDiv.style.overflow = 'scroll';
|
|
289
290
|
scrollDiv.className = 'scrollDiv';
|
|
290
|
-
|
|
291
|
+
element.appendChild(scrollDiv);
|
|
291
292
|
const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
292
|
-
|
|
293
|
-
scrollbarSizeCache.set(
|
|
293
|
+
element.removeChild(scrollDiv);
|
|
294
|
+
scrollbarSizeCache.set(element, size);
|
|
294
295
|
return size;
|
|
295
296
|
}
|
|
296
297
|
function areElementSizesEqual(a, b) {
|
|
@@ -4,7 +4,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
const _excluded = ["id", "field"],
|
|
5
5
|
_excluded2 = ["id", "field"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import
|
|
7
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
8
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
9
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
9
10
|
import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
10
11
|
import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
@@ -4,7 +4,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
const _excluded = ["id"],
|
|
5
5
|
_excluded2 = ["id"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import
|
|
7
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
8
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
9
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
9
10
|
import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
10
11
|
import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from "../columns/index.js";
|
|
2
2
|
import { gridFilteredSortedRowIdsSelector } from "../filter/index.js";
|
|
3
3
|
import { gridPinnedRowsSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
4
|
+
import { gridRowSelectionCountSelector, gridRowSelectionIdsSelector } from "../rowSelection/gridRowSelectionSelector.js";
|
|
4
5
|
export const getColumnsToExport = ({
|
|
5
6
|
apiRef,
|
|
6
7
|
options
|
|
@@ -23,14 +24,15 @@ export const defaultGetRowsToExport = ({
|
|
|
23
24
|
}) => {
|
|
24
25
|
const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
25
26
|
const rowTree = gridRowTreeSelector(apiRef);
|
|
26
|
-
const
|
|
27
|
+
const selectedRowsCount = gridRowSelectionCountSelector(apiRef);
|
|
27
28
|
const bodyRows = filteredSortedRowIds.filter(id => rowTree[id].type !== 'footer');
|
|
28
29
|
const pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
29
30
|
const topPinnedRowsIds = pinnedRows?.top?.map(row => row.id) || [];
|
|
30
31
|
const bottomPinnedRowsIds = pinnedRows?.bottom?.map(row => row.id) || [];
|
|
31
32
|
bodyRows.unshift(...topPinnedRowsIds);
|
|
32
33
|
bodyRows.push(...bottomPinnedRowsIds);
|
|
33
|
-
if (
|
|
34
|
+
if (selectedRowsCount > 0) {
|
|
35
|
+
const selectedRows = gridRowSelectionIdsSelector(apiRef);
|
|
34
36
|
return bodyRows.filter(id => selectedRows.has(id));
|
|
35
37
|
}
|
|
36
38
|
return bodyRows;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
|
+
import ownerDocument from '@mui/utils/ownerDocument';
|
|
4
5
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
5
6
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
6
7
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
@@ -346,7 +347,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
346
347
|
}));
|
|
347
348
|
}
|
|
348
349
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
349
|
-
const handlePaginationModelChange =
|
|
350
|
+
const handlePaginationModelChange = useEventCallback(() => {
|
|
350
351
|
const currentFocusedCell = gridFocusCellSelector(apiRef);
|
|
351
352
|
if (!currentFocusedCell) {
|
|
352
353
|
return;
|
|
@@ -16,4 +16,4 @@ export * from "./dimensions/index.js";
|
|
|
16
16
|
export * from "./statePersistence/index.js";
|
|
17
17
|
export * from "./headerFiltering/index.js";
|
|
18
18
|
export * from "./virtualization/index.js";
|
|
19
|
-
export
|
|
19
|
+
export * from "./dataSource/index.js";
|
|
@@ -17,4 +17,4 @@ export * from "./dimensions/index.js";
|
|
|
17
17
|
export * from "./statePersistence/index.js";
|
|
18
18
|
export * from "./headerFiltering/index.js";
|
|
19
19
|
export * from "./virtualization/index.js";
|
|
20
|
-
export
|
|
20
|
+
export * from "./dataSource/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
|
|
2
2
|
import { GridRowId } from "../../../models/gridRows.js";
|
|
3
3
|
export declare const gridRowSelectionStateSelector: import("../../..").OutputSelector<GridStateCommunity, unknown, import("../../..").GridRowSelectionModel>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
4
|
+
export declare const gridRowSelectionManagerSelector: import("../../..").OutputSelector<GridStateCommunity, import("../../..").GridRowSelectionModel, import("../../../models/gridRowSelectionManager").RowSelectionManager>;
|
|
5
|
+
export declare const gridRowSelectionCountSelector: import("../../..").OutputSelector<GridStateCommunity, number, number>;
|
|
6
|
+
export declare const gridRowSelectionIdsSelector: import("../../..").OutputSelector<GridStateCommunity, GridRowId[], Map<GridRowId, import("../../..").GridValidRowModel>>;
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { createSelector, createRootSelector, createSelectorMemoized } from "../../../utils/createSelector.js";
|
|
2
|
-
import { gridRowsLookupSelector } from "../rows/gridRowsSelector.js";
|
|
2
|
+
import { gridDataRowIdsSelector, gridRowsLookupSelector } from "../rows/gridRowsSelector.js";
|
|
3
|
+
import { gridFilteredRowCountSelector } from "../filter/gridFilterSelector.js";
|
|
4
|
+
import { createRowSelectionManager } from "../../../models/gridRowSelectionManager.js";
|
|
3
5
|
export const gridRowSelectionStateSelector = createRootSelector(state => state.rowSelection);
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export const gridRowSelectionManagerSelector = createSelectorMemoized(gridRowSelectionStateSelector, createRowSelectionManager);
|
|
7
|
+
export const gridRowSelectionCountSelector = createSelector(gridRowSelectionStateSelector, gridFilteredRowCountSelector, (selection, filteredRowCount) => {
|
|
8
|
+
if (selection.type === 'include') {
|
|
9
|
+
return selection.ids.size;
|
|
10
|
+
}
|
|
11
|
+
// In exclude selection, all rows are selectable.
|
|
12
|
+
return filteredRowCount - selection.ids.size;
|
|
13
|
+
});
|
|
14
|
+
export const gridRowSelectionIdsSelector = createSelectorMemoized(gridRowSelectionStateSelector, gridRowsLookupSelector, gridDataRowIdsSelector, (selectionModel, rowsLookup, rowIds) => {
|
|
15
|
+
const map = new Map();
|
|
16
|
+
if (selectionModel.type === 'include') {
|
|
17
|
+
for (const id of selectionModel.ids) {
|
|
18
|
+
map.set(id, rowsLookup[id]);
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
for (let i = 0; i < rowIds.length; i += 1) {
|
|
22
|
+
const id = rowIds[i];
|
|
23
|
+
if (!selectionModel.ids.has(id)) {
|
|
24
|
+
map.set(id, rowsLookup[id]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return map;
|
|
29
|
+
});
|