@mui/x-data-grid 9.7.0 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +249 -1
- package/DataGrid/DataGrid.js +7 -0
- package/DataGrid/DataGrid.mjs +7 -0
- package/components/GridColumnSortButton.d.mts +1 -1
- package/components/GridColumnSortButton.d.ts +1 -1
- package/components/GridColumnUnsortedIcon.d.mts +2 -1
- package/components/GridColumnUnsortedIcon.d.ts +2 -1
- package/components/GridHeader.d.mts +2 -1
- package/components/GridHeader.d.ts +2 -1
- package/components/GridHeaders.d.mts +1 -1
- package/components/GridHeaders.d.ts +1 -1
- package/components/GridPagination.d.mts +2 -1
- package/components/GridPagination.d.ts +2 -1
- package/components/GridRowDragAndDropOverlay.d.mts +1 -1
- package/components/GridRowDragAndDropOverlay.d.ts +1 -1
- package/components/GridScrollArea.d.mts +2 -1
- package/components/GridScrollArea.d.ts +2 -1
- package/components/GridScrollShadows.d.mts +2 -1
- package/components/GridScrollShadows.d.ts +2 -1
- package/components/GridScrollbarFillerCell.d.mts +1 -1
- package/components/GridScrollbarFillerCell.d.ts +1 -1
- package/components/base/GridFooterPlaceholder.d.mts +1 -1
- package/components/base/GridFooterPlaceholder.d.ts +1 -1
- package/components/base/GridFooterPlaceholder.js +1 -1
- package/components/base/GridFooterPlaceholder.mjs +1 -1
- package/components/base/GridOverlays.d.mts +1 -1
- package/components/base/GridOverlays.d.ts +1 -1
- package/components/cell/GridActionsCell.d.mts +2 -2
- package/components/cell/GridActionsCell.d.ts +2 -2
- package/components/cell/GridActionsCellItem.js +1 -58
- package/components/cell/GridActionsCellItem.mjs +1 -58
- package/components/cell/GridBooleanCell.d.mts +1 -1
- package/components/cell/GridBooleanCell.d.ts +1 -1
- package/components/cell/GridEditBooleanCell.d.mts +2 -2
- package/components/cell/GridEditBooleanCell.d.ts +2 -2
- package/components/cell/GridEditDateCell.d.mts +2 -2
- package/components/cell/GridEditDateCell.d.ts +2 -2
- package/components/cell/GridEditInputCell.d.mts +1 -1
- package/components/cell/GridEditInputCell.d.ts +1 -1
- package/components/cell/GridEditLongTextCell.d.mts +2 -2
- package/components/cell/GridEditLongTextCell.d.ts +2 -2
- package/components/cell/GridEditSingleSelectCell.d.mts +3 -2
- package/components/cell/GridEditSingleSelectCell.d.ts +3 -2
- package/components/cell/GridFooterCell.d.mts +1 -1
- package/components/cell/GridFooterCell.d.ts +1 -1
- package/components/cell/GridLongTextCell.d.mts +2 -2
- package/components/cell/GridLongTextCell.d.ts +2 -2
- package/components/cell/GridSkeletonCell.d.mts +1 -1
- package/components/cell/GridSkeletonCell.d.ts +1 -1
- package/components/columnHeaders/ColumnHeaderMenuIcon.d.mts +1 -1
- package/components/columnHeaders/ColumnHeaderMenuIcon.d.ts +1 -1
- package/components/columnHeaders/GridColumnGroupHeader.d.mts +1 -1
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderSeparator.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderSortIcon.d.ts +1 -1
- package/components/columnHeaders/GridColumnHeaderTitle.d.mts +1 -1
- package/components/columnHeaders/GridColumnHeaderTitle.d.ts +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.mts +2 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +2 -1
- package/components/menu/GridMenu.d.mts +1 -1
- package/components/menu/GridMenu.d.ts +1 -1
- package/components/menu/columnMenu/GridColumnHeaderMenu.d.mts +1 -1
- package/components/menu/columnMenu/GridColumnHeaderMenu.d.ts +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.d.ts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.d.mts +2 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.d.ts +2 -1
- package/components/panel/GridColumnsPanel.d.mts +1 -1
- package/components/panel/GridColumnsPanel.d.ts +1 -1
- package/components/panel/GridPanelContent.d.mts +1 -1
- package/components/panel/GridPanelContent.d.ts +1 -1
- package/components/panel/GridPanelContext.d.mts +1 -1
- package/components/panel/GridPanelContext.d.ts +1 -1
- package/components/panel/GridPanelFooter.d.mts +1 -1
- package/components/panel/GridPanelFooter.d.ts +1 -1
- package/components/panel/GridPanelHeader.d.mts +1 -1
- package/components/panel/GridPanelHeader.d.ts +1 -1
- package/components/panel/GridPreferencesPanel.d.mts +1 -1
- package/components/panel/GridPreferencesPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterForm.d.mts +1 -98
- package/components/panel/filterPanel/GridFilterForm.d.ts +1 -98
- package/components/panel/filterPanel/GridFilterForm.js +9 -355
- package/components/panel/filterPanel/GridFilterForm.mjs +8 -354
- package/components/panel/filterPanel/GridFilterFormBase.d.mts +119 -0
- package/components/panel/filterPanel/GridFilterFormBase.d.ts +119 -0
- package/components/panel/filterPanel/GridFilterFormBase.js +497 -0
- package/components/panel/filterPanel/GridFilterFormBase.mjs +491 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputDate.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +21 -9
- package/components/panel/filterPanel/GridFilterInputDate.mjs +21 -9
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +6 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +6 -1
- package/components/panel/filterPanel/GridFilterInputValue.d.mts +2 -1
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +19 -8
- package/components/panel/filterPanel/GridFilterInputValue.mjs +19 -8
- package/components/panel/filterPanel/GridFilterPanel.d.mts +3 -40
- package/components/panel/filterPanel/GridFilterPanel.d.ts +3 -40
- package/components/panel/filterPanel/GridFilterPanel.js +19 -174
- package/components/panel/filterPanel/GridFilterPanel.mjs +14 -173
- package/components/panel/filterPanel/GridFilterPanelBase.d.mts +79 -0
- package/components/panel/filterPanel/GridFilterPanelBase.d.ts +79 -0
- package/components/panel/filterPanel/GridFilterPanelBase.js +304 -0
- package/components/panel/filterPanel/GridFilterPanelBase.mjs +297 -0
- package/components/panel/filterPanel/index.d.mts +3 -1
- package/components/panel/filterPanel/index.d.ts +3 -1
- package/components/panel/filterPanel/index.js +9 -1
- package/components/panel/filterPanel/index.mjs +3 -0
- package/components/quickFilter/QuickFilter.d.mts +1 -1
- package/components/quickFilter/QuickFilter.d.ts +1 -1
- package/components/toolbar/GridToolbarExport.d.mts +2 -2
- package/components/toolbar/GridToolbarExport.d.ts +2 -2
- package/components/toolbar/GridToolbarQuickFilter.d.mts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
- package/components/toolbarV8/GridToolbar.d.mts +3 -3
- package/components/toolbarV8/GridToolbar.d.ts +3 -3
- package/components/virtualization/GridBottomContainer.d.mts +1 -1
- package/components/virtualization/GridBottomContainer.d.ts +1 -1
- package/components/virtualization/GridTopContainer.d.mts +1 -1
- package/components/virtualization/GridTopContainer.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.d.mts +1 -1
- package/components/virtualization/GridVirtualScroller.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollerFiller.d.mts +2 -1
- package/components/virtualization/GridVirtualScrollerFiller.d.ts +2 -1
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/constants/dataGridPropsDefaultValues.mjs +1 -0
- package/context/GridContextProvider.d.mts +1 -1
- package/context/GridContextProvider.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.mts +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +2 -2
- package/hooks/features/dataSource/useGridDataSourceBase.d.mts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourceBase.js +39 -10
- package/hooks/features/dataSource/useGridDataSourceBase.mjs +39 -10
- package/hooks/features/editing/useGridCellEditing.js +14 -7
- package/hooks/features/editing/useGridCellEditing.mjs +14 -7
- package/hooks/features/filter/gridFilterUtils.d.mts +12 -0
- package/hooks/features/filter/gridFilterUtils.d.ts +12 -0
- package/hooks/features/filter/gridFilterUtils.js +56 -1
- package/hooks/features/filter/gridFilterUtils.mjs +52 -0
- package/hooks/features/filter/useGridFilter.js +4 -35
- package/hooks/features/filter/useGridFilter.mjs +5 -36
- package/hooks/features/rows/gridRowsUtils.js +1 -1
- package/hooks/features/rows/gridRowsUtils.mjs +1 -1
- package/hooks/utils/useGridEvent.js +1 -1
- package/hooks/utils/useGridEvent.mjs +1 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/demo/TailwindDemoContainer.d.mts +1 -1
- package/internals/demo/TailwindDemoContainer.d.ts +1 -1
- package/locales/jaJP.js +4 -5
- package/locales/jaJP.mjs +4 -5
- package/models/gridFilterInputComponent.d.mts +5 -0
- package/models/gridFilterInputComponent.d.ts +5 -0
- package/models/gridSlotsComponentsProps.d.mts +1 -1
- package/models/gridSlotsComponentsProps.d.ts +1 -1
- package/models/props/DataGridProps.d.mts +7 -0
- package/models/props/DataGridProps.d.ts +7 -0
- package/package.json +4 -4
- package/utils/css/context.d.mts +3 -3
- package/utils/css/context.d.ts +3 -3
|
@@ -57,7 +57,7 @@ export type QuickFilterProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'class
|
|
|
57
57
|
*
|
|
58
58
|
* - [QuickFilter API](https://mui.com/x/api/data-grid/quick-filter/)
|
|
59
59
|
*/
|
|
60
|
-
declare function QuickFilter(props: QuickFilterProps):
|
|
60
|
+
declare function QuickFilter(props: QuickFilterProps): React.JSX.Element;
|
|
61
61
|
declare namespace QuickFilter {
|
|
62
62
|
var propTypes: any;
|
|
63
63
|
}
|
|
@@ -57,7 +57,7 @@ export type QuickFilterProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'class
|
|
|
57
57
|
*
|
|
58
58
|
* - [QuickFilter API](https://mui.com/x/api/data-grid/quick-filter/)
|
|
59
59
|
*/
|
|
60
|
-
declare function QuickFilter(props: QuickFilterProps):
|
|
60
|
+
declare function QuickFilter(props: QuickFilterProps): React.JSX.Element;
|
|
61
61
|
declare namespace QuickFilter {
|
|
62
62
|
var propTypes: any;
|
|
63
63
|
}
|
|
@@ -27,11 +27,11 @@ export interface GridToolbarExportProps {
|
|
|
27
27
|
};
|
|
28
28
|
[x: `data-${string}`]: string;
|
|
29
29
|
}
|
|
30
|
-
declare function GridCsvExportMenuItem(props: GridCsvExportMenuItemProps):
|
|
30
|
+
declare function GridCsvExportMenuItem(props: GridCsvExportMenuItemProps): React.JSX.Element;
|
|
31
31
|
declare namespace GridCsvExportMenuItem {
|
|
32
32
|
var propTypes: any;
|
|
33
33
|
}
|
|
34
|
-
declare function GridPrintExportMenuItem(props: GridPrintExportMenuItemProps):
|
|
34
|
+
declare function GridPrintExportMenuItem(props: GridPrintExportMenuItemProps): React.JSX.Element;
|
|
35
35
|
declare namespace GridPrintExportMenuItem {
|
|
36
36
|
var propTypes: any;
|
|
37
37
|
}
|
|
@@ -27,11 +27,11 @@ export interface GridToolbarExportProps {
|
|
|
27
27
|
};
|
|
28
28
|
[x: `data-${string}`]: string;
|
|
29
29
|
}
|
|
30
|
-
declare function GridCsvExportMenuItem(props: GridCsvExportMenuItemProps):
|
|
30
|
+
declare function GridCsvExportMenuItem(props: GridCsvExportMenuItemProps): React.JSX.Element;
|
|
31
31
|
declare namespace GridCsvExportMenuItem {
|
|
32
32
|
var propTypes: any;
|
|
33
33
|
}
|
|
34
|
-
declare function GridPrintExportMenuItem(props: GridPrintExportMenuItemProps):
|
|
34
|
+
declare function GridPrintExportMenuItem(props: GridPrintExportMenuItemProps): React.JSX.Element;
|
|
35
35
|
declare namespace GridPrintExportMenuItem {
|
|
36
36
|
var propTypes: any;
|
|
37
37
|
}
|
|
@@ -30,7 +30,7 @@ export type GridToolbarQuickFilterProps = {
|
|
|
30
30
|
/**
|
|
31
31
|
* @deprecated Use the {@link https://mui.com/x/react-data-grid/components/quick-filter/ Quick Filter} component instead. This component will be removed in a future major release.
|
|
32
32
|
*/
|
|
33
|
-
declare function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps): import("react
|
|
33
|
+
declare function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps): import("react").JSX.Element;
|
|
34
34
|
declare namespace GridToolbarQuickFilter {
|
|
35
35
|
var propTypes: any;
|
|
36
36
|
}
|
|
@@ -30,7 +30,7 @@ export type GridToolbarQuickFilterProps = {
|
|
|
30
30
|
/**
|
|
31
31
|
* @deprecated Use the {@link https://mui.com/x/react-data-grid/components/quick-filter/ Quick Filter} component instead. This component will be removed in a future major release.
|
|
32
32
|
*/
|
|
33
|
-
declare function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps): import("react
|
|
33
|
+
declare function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps): import("react").JSX.Element;
|
|
34
34
|
declare namespace GridToolbarQuickFilter {
|
|
35
35
|
var propTypes: any;
|
|
36
36
|
}
|
|
@@ -5,12 +5,12 @@ interface GridToolbarInternalProps {
|
|
|
5
5
|
additionalExportMenuItems?: (onMenuItemClick: () => void) => React.ReactNode;
|
|
6
6
|
}
|
|
7
7
|
export type GridToolbarProps = GridSlotProps['toolbar'] & GridToolbarInternalProps;
|
|
8
|
-
declare function GridToolbarDivider(props: GridSlotProps['baseDivider']):
|
|
8
|
+
declare function GridToolbarDivider(props: GridSlotProps['baseDivider']): React.JSX.Element;
|
|
9
9
|
declare namespace GridToolbarDivider {
|
|
10
10
|
var propTypes: any;
|
|
11
11
|
}
|
|
12
|
-
declare function GridToolbarLabel(props: React.HTMLAttributes<HTMLSpanElement>):
|
|
13
|
-
declare function GridToolbar(props: GridToolbarProps):
|
|
12
|
+
declare function GridToolbarLabel(props: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
|
|
13
|
+
declare function GridToolbar(props: GridToolbarProps): React.JSX.Element;
|
|
14
14
|
declare namespace GridToolbar {
|
|
15
15
|
var propTypes: any;
|
|
16
16
|
}
|
|
@@ -5,12 +5,12 @@ interface GridToolbarInternalProps {
|
|
|
5
5
|
additionalExportMenuItems?: (onMenuItemClick: () => void) => React.ReactNode;
|
|
6
6
|
}
|
|
7
7
|
export type GridToolbarProps = GridSlotProps['toolbar'] & GridToolbarInternalProps;
|
|
8
|
-
declare function GridToolbarDivider(props: GridSlotProps['baseDivider']):
|
|
8
|
+
declare function GridToolbarDivider(props: GridSlotProps['baseDivider']): React.JSX.Element;
|
|
9
9
|
declare namespace GridToolbarDivider {
|
|
10
10
|
var propTypes: any;
|
|
11
11
|
}
|
|
12
|
-
declare function GridToolbarLabel(props: React.HTMLAttributes<HTMLSpanElement>):
|
|
13
|
-
declare function GridToolbar(props: GridToolbarProps):
|
|
12
|
+
declare function GridToolbarLabel(props: React.HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
|
|
13
|
+
declare function GridToolbar(props: GridToolbarProps): React.JSX.Element;
|
|
14
14
|
declare namespace GridToolbar {
|
|
15
15
|
var propTypes: any;
|
|
16
16
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export type GridBottomContainerProps = React.PropsWithChildren;
|
|
3
|
-
export declare function GridBottomContainer(props: GridBottomContainerProps):
|
|
3
|
+
export declare function GridBottomContainer(props: GridBottomContainerProps): React.JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export type GridBottomContainerProps = React.PropsWithChildren;
|
|
3
|
-
export declare function GridBottomContainer(props: GridBottomContainerProps):
|
|
3
|
+
export declare function GridBottomContainer(props: GridBottomContainerProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare function GridTopContainer(props: React.PropsWithChildren):
|
|
2
|
+
export declare function GridTopContainer(props: React.PropsWithChildren): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare function GridTopContainer(props: React.PropsWithChildren):
|
|
2
|
+
export declare function GridTopContainer(props: React.PropsWithChildren): React.JSX.Element;
|
|
@@ -2,5 +2,5 @@ import * as React from 'react';
|
|
|
2
2
|
export interface GridVirtualScrollerProps {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
}
|
|
5
|
-
declare function GridVirtualScroller(props: GridVirtualScrollerProps):
|
|
5
|
+
declare function GridVirtualScroller(props: GridVirtualScrollerProps): React.JSX.Element;
|
|
6
6
|
export { GridVirtualScroller };
|
|
@@ -2,5 +2,5 @@ import * as React from 'react';
|
|
|
2
2
|
export interface GridVirtualScrollerProps {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
}
|
|
5
|
-
declare function GridVirtualScroller(props: GridVirtualScrollerProps):
|
|
5
|
+
declare function GridVirtualScroller(props: GridVirtualScrollerProps): React.JSX.Element;
|
|
6
6
|
export { GridVirtualScroller };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
type Props = {
|
|
2
3
|
/** The number of rows */
|
|
3
4
|
rowsLength: number;
|
|
4
5
|
};
|
|
5
6
|
declare function GridVirtualScrollerFiller({
|
|
6
7
|
rowsLength
|
|
7
|
-
}: Props):
|
|
8
|
+
}: Props): React.JSX.Element | null;
|
|
8
9
|
declare const Memoized: typeof GridVirtualScrollerFiller;
|
|
9
10
|
export { Memoized as GridVirtualScrollerFiller };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
type Props = {
|
|
2
3
|
/** The number of rows */
|
|
3
4
|
rowsLength: number;
|
|
4
5
|
};
|
|
5
6
|
declare function GridVirtualScrollerFiller({
|
|
6
7
|
rowsLength
|
|
7
|
-
}: Props):
|
|
8
|
+
}: Props): React.JSX.Element | null;
|
|
8
9
|
declare const Memoized: typeof GridVirtualScrollerFiller;
|
|
9
10
|
export { Memoized as GridVirtualScrollerFiller };
|
|
@@ -30,6 +30,7 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
|
|
|
30
30
|
disableMultipleColumnsFiltering: false,
|
|
31
31
|
disableMultipleColumnsSorting: false,
|
|
32
32
|
disableMultipleRowSelection: false,
|
|
33
|
+
dataSourceKeepPreviousData: false,
|
|
33
34
|
dataSourceRevalidateMs: 0,
|
|
34
35
|
disableRowSelectionOnClick: false,
|
|
35
36
|
disableRowSelectionExcludeModel: false,
|
|
@@ -24,6 +24,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
24
24
|
disableMultipleColumnsFiltering: false,
|
|
25
25
|
disableMultipleColumnsSorting: false,
|
|
26
26
|
disableMultipleRowSelection: false,
|
|
27
|
+
dataSourceKeepPreviousData: false,
|
|
27
28
|
dataSourceRevalidateMs: 0,
|
|
28
29
|
disableRowSelectionOnClick: false,
|
|
29
30
|
disableRowSelectionExcludeModel: false,
|
|
@@ -49,8 +49,8 @@ export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) =>
|
|
|
49
49
|
};
|
|
50
50
|
visibleColumns: GridStateColDef[];
|
|
51
51
|
columnPositions: number[];
|
|
52
|
-
getFillers: (params: GetHeadersParams | undefined, children: React.ReactNode, leftOverflow: number, borderBottom?: boolean) =>
|
|
53
|
-
getColumnHeadersRow: () =>
|
|
52
|
+
getFillers: (params: GetHeadersParams | undefined, children: React.ReactNode, leftOverflow: number, borderBottom?: boolean) => React.JSX.Element;
|
|
53
|
+
getColumnHeadersRow: () => React.JSX.Element;
|
|
54
54
|
getColumnsToRender: (params?: GetHeadersParams) => {
|
|
55
55
|
renderedColumns: GridStateColDef[];
|
|
56
56
|
firstColumnToRender: number;
|
|
@@ -49,8 +49,8 @@ export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) =>
|
|
|
49
49
|
};
|
|
50
50
|
visibleColumns: GridStateColDef[];
|
|
51
51
|
columnPositions: number[];
|
|
52
|
-
getFillers: (params: GetHeadersParams | undefined, children: React.ReactNode, leftOverflow: number, borderBottom?: boolean) =>
|
|
53
|
-
getColumnHeadersRow: () =>
|
|
52
|
+
getFillers: (params: GetHeadersParams | undefined, children: React.ReactNode, leftOverflow: number, borderBottom?: boolean) => React.JSX.Element;
|
|
53
|
+
getColumnHeadersRow: () => React.JSX.Element;
|
|
54
54
|
getColumnsToRender: (params?: GetHeadersParams) => {
|
|
55
55
|
renderedColumns: GridStateColDef[];
|
|
56
56
|
firstColumnToRender: number;
|
|
@@ -7,7 +7,7 @@ import type { DataGridProcessedProps } from "../../../models/props/DataGridProps
|
|
|
7
7
|
import type { GridStrategyProcessor } from "../../core/strategyProcessing/index.mjs";
|
|
8
8
|
import type { GridEventListener } from "../../../models/events/index.mjs";
|
|
9
9
|
import type { GridRowId } from "../../../models/gridRows.mjs";
|
|
10
|
-
export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "dataSource" | "dataSourceCache" | "onDataSourceError" | "pageSizeOptions" | "pagination" | "signature" | "dataSourceRevalidateMs">, options?: GridDataSourceBaseOptions) => {
|
|
10
|
+
export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "dataSource" | "dataSourceCache" | "dataSourceKeepPreviousData" | "onDataSourceError" | "pageSizeOptions" | "pagination" | "signature" | "dataSourceRevalidateMs">, options?: GridDataSourceBaseOptions) => {
|
|
11
11
|
api: {
|
|
12
12
|
public: GridDataSourceApi;
|
|
13
13
|
};
|
|
@@ -7,7 +7,7 @@ import type { DataGridProcessedProps } from "../../../models/props/DataGridProps
|
|
|
7
7
|
import type { GridStrategyProcessor } from "../../core/strategyProcessing/index.js";
|
|
8
8
|
import type { GridEventListener } from "../../../models/events/index.js";
|
|
9
9
|
import type { GridRowId } from "../../../models/gridRows.js";
|
|
10
|
-
export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "dataSource" | "dataSourceCache" | "onDataSourceError" | "pageSizeOptions" | "pagination" | "signature" | "dataSourceRevalidateMs">, options?: GridDataSourceBaseOptions) => {
|
|
10
|
+
export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity>(apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, "dataSource" | "dataSourceCache" | "dataSourceKeepPreviousData" | "onDataSourceError" | "pageSizeOptions" | "pagination" | "signature" | "dataSourceRevalidateMs">, options?: GridDataSourceBaseOptions) => {
|
|
11
11
|
api: {
|
|
12
12
|
public: GridDataSourceApi;
|
|
13
13
|
};
|
|
@@ -209,6 +209,11 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
209
209
|
});
|
|
210
210
|
const handleDataUpdate = React.useCallback(params => {
|
|
211
211
|
if ('error' in params) {
|
|
212
|
+
// Reset the rows on error, even with `dataSourceKeepPreviousData`. The previous
|
|
213
|
+
// rows belong to the previous query while the pagination/sorting/filtering controls
|
|
214
|
+
// already reflect the failed request, so keeping them would present stale data as if
|
|
215
|
+
// it satisfied the new query. This matches TanStack Query, where `keepPreviousData`
|
|
216
|
+
// clears the placeholder once the query settles with an error.
|
|
212
217
|
apiRef.current.setRows([]);
|
|
213
218
|
return;
|
|
214
219
|
}
|
|
@@ -265,17 +270,26 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
265
270
|
};
|
|
266
271
|
const debouncedFetchRows = React.useMemo(() => (0, _debounce.default)(fetchRows, 0), [fetchRows]);
|
|
267
272
|
const handleFetchRowsOnParamsChange = React.useCallback(() => {
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
// would
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
apiRef.current.
|
|
273
|
+
// `dataSourceKeepPreviousData` only applies to the flat `Default` strategy. For
|
|
274
|
+
// `GroupedData` (tree data / row grouping), skipping the synchronous `setRows([])`
|
|
275
|
+
// would leave the existing tree merged on top of the new response and render rows
|
|
276
|
+
// in stale sort order (https://github.com/mui/mui-x/pull/21619).
|
|
277
|
+
// This handler is only wired up when a standard strategy is active via the `runIf`
|
|
278
|
+
// guards on the returned `events` object.
|
|
279
|
+
const activeStrategy = apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.DataSource);
|
|
280
|
+
const keepPreviousData = props.dataSourceKeepPreviousData && activeStrategy === _utils2.DataSourceRowsUpdateStrategy.Default;
|
|
281
|
+
if (!keepPreviousData) {
|
|
282
|
+
// Clear the rows first and immediately mark the grid as loading so the overlay
|
|
283
|
+
// selector never observes the intermediate `rows=[] && loading=false` state that
|
|
284
|
+
// would otherwise pick `noRowsOverlay`. Order matters: `setRows([])` rebuilds
|
|
285
|
+
// `state.rows` from `props.loading`, so the `setLoading(true)` call must come after
|
|
286
|
+
// it to survive the rebuild.
|
|
287
|
+
apiRef.current.setRows([]);
|
|
288
|
+
}
|
|
275
289
|
apiRef.current.setLoading(true);
|
|
276
290
|
stopPolling();
|
|
277
291
|
debouncedFetchRows();
|
|
278
|
-
}, [apiRef, stopPolling, debouncedFetchRows]);
|
|
292
|
+
}, [apiRef, props.dataSourceKeepPreviousData, stopPolling, debouncedFetchRows]);
|
|
279
293
|
const isFirstRender = React.useRef(true);
|
|
280
294
|
React.useEffect(() => {
|
|
281
295
|
if (isFirstRender.current) {
|
|
@@ -307,7 +321,14 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
307
321
|
}
|
|
308
322
|
if (props.dataSource) {
|
|
309
323
|
stopPolling();
|
|
310
|
-
|
|
324
|
+
// `dataSourceKeepPreviousData` only applies to the flat `Default` strategy (mirroring
|
|
325
|
+
// `handleFetchRowsOnParamsChange`). Keep the previous rows visible when the `dataSource`
|
|
326
|
+
// reference changes so the feature isn't silently defeated for a non-memoized
|
|
327
|
+
// `dataSource`. Other strategies must still reset the rows to keep their order consistent
|
|
328
|
+
// with the new response (https://github.com/mui/mui-x/pull/21619).
|
|
329
|
+
if (!props.dataSourceKeepPreviousData || currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.Default) {
|
|
330
|
+
apiRef.current.setRows([]);
|
|
331
|
+
}
|
|
311
332
|
apiRef.current.dataSource.cache.clear();
|
|
312
333
|
apiRef.current.dataSource.fetchRows();
|
|
313
334
|
}
|
|
@@ -315,7 +336,15 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
315
336
|
// ignore the current request on unmount
|
|
316
337
|
lastRequestId.current += 1;
|
|
317
338
|
};
|
|
318
|
-
}, [apiRef, props.dataSource, currentStrategy, stopPolling]);
|
|
339
|
+
}, [apiRef, props.dataSource, props.dataSourceKeepPreviousData, currentStrategy, stopPolling]);
|
|
340
|
+
React.useEffect(() => {
|
|
341
|
+
// `dataSourceKeepPreviousData` is a no-op for tree data and row grouping: those
|
|
342
|
+
// strategies always reset the rows on refetch to keep their order consistent with the
|
|
343
|
+
// response. Warn so the limitation is discoverable at runtime, not only in the docs.
|
|
344
|
+
if (process.env.NODE_ENV !== 'production' && props.dataSourceKeepPreviousData && (currentStrategy === _utils2.DataSourceRowsUpdateStrategy.GroupedData || currentStrategy === _utils2.DataSourceRowsUpdateStrategy.LazyLoadedGroupedData)) {
|
|
345
|
+
(0, _warning.warnOnce)(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.']);
|
|
346
|
+
}
|
|
347
|
+
}, [props.dataSourceKeepPreviousData, currentStrategy]);
|
|
319
348
|
return {
|
|
320
349
|
api: {
|
|
321
350
|
public: dataSourceApi
|
|
@@ -202,6 +202,11 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
202
202
|
});
|
|
203
203
|
const handleDataUpdate = React.useCallback(params => {
|
|
204
204
|
if ('error' in params) {
|
|
205
|
+
// Reset the rows on error, even with `dataSourceKeepPreviousData`. The previous
|
|
206
|
+
// rows belong to the previous query while the pagination/sorting/filtering controls
|
|
207
|
+
// already reflect the failed request, so keeping them would present stale data as if
|
|
208
|
+
// it satisfied the new query. This matches TanStack Query, where `keepPreviousData`
|
|
209
|
+
// clears the placeholder once the query settles with an error.
|
|
205
210
|
apiRef.current.setRows([]);
|
|
206
211
|
return;
|
|
207
212
|
}
|
|
@@ -258,17 +263,26 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
258
263
|
};
|
|
259
264
|
const debouncedFetchRows = React.useMemo(() => debounce(fetchRows, 0), [fetchRows]);
|
|
260
265
|
const handleFetchRowsOnParamsChange = React.useCallback(() => {
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
// would
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
apiRef.current.
|
|
266
|
+
// `dataSourceKeepPreviousData` only applies to the flat `Default` strategy. For
|
|
267
|
+
// `GroupedData` (tree data / row grouping), skipping the synchronous `setRows([])`
|
|
268
|
+
// would leave the existing tree merged on top of the new response and render rows
|
|
269
|
+
// in stale sort order (https://github.com/mui/mui-x/pull/21619).
|
|
270
|
+
// This handler is only wired up when a standard strategy is active via the `runIf`
|
|
271
|
+
// guards on the returned `events` object.
|
|
272
|
+
const activeStrategy = apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource);
|
|
273
|
+
const keepPreviousData = props.dataSourceKeepPreviousData && activeStrategy === DataSourceRowsUpdateStrategy.Default;
|
|
274
|
+
if (!keepPreviousData) {
|
|
275
|
+
// Clear the rows first and immediately mark the grid as loading so the overlay
|
|
276
|
+
// selector never observes the intermediate `rows=[] && loading=false` state that
|
|
277
|
+
// would otherwise pick `noRowsOverlay`. Order matters: `setRows([])` rebuilds
|
|
278
|
+
// `state.rows` from `props.loading`, so the `setLoading(true)` call must come after
|
|
279
|
+
// it to survive the rebuild.
|
|
280
|
+
apiRef.current.setRows([]);
|
|
281
|
+
}
|
|
268
282
|
apiRef.current.setLoading(true);
|
|
269
283
|
stopPolling();
|
|
270
284
|
debouncedFetchRows();
|
|
271
|
-
}, [apiRef, stopPolling, debouncedFetchRows]);
|
|
285
|
+
}, [apiRef, props.dataSourceKeepPreviousData, stopPolling, debouncedFetchRows]);
|
|
272
286
|
const isFirstRender = React.useRef(true);
|
|
273
287
|
React.useEffect(() => {
|
|
274
288
|
if (isFirstRender.current) {
|
|
@@ -300,7 +314,14 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
300
314
|
}
|
|
301
315
|
if (props.dataSource) {
|
|
302
316
|
stopPolling();
|
|
303
|
-
|
|
317
|
+
// `dataSourceKeepPreviousData` only applies to the flat `Default` strategy (mirroring
|
|
318
|
+
// `handleFetchRowsOnParamsChange`). Keep the previous rows visible when the `dataSource`
|
|
319
|
+
// reference changes so the feature isn't silently defeated for a non-memoized
|
|
320
|
+
// `dataSource`. Other strategies must still reset the rows to keep their order consistent
|
|
321
|
+
// with the new response (https://github.com/mui/mui-x/pull/21619).
|
|
322
|
+
if (!props.dataSourceKeepPreviousData || currentStrategy !== DataSourceRowsUpdateStrategy.Default) {
|
|
323
|
+
apiRef.current.setRows([]);
|
|
324
|
+
}
|
|
304
325
|
apiRef.current.dataSource.cache.clear();
|
|
305
326
|
apiRef.current.dataSource.fetchRows();
|
|
306
327
|
}
|
|
@@ -308,7 +329,15 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
308
329
|
// ignore the current request on unmount
|
|
309
330
|
lastRequestId.current += 1;
|
|
310
331
|
};
|
|
311
|
-
}, [apiRef, props.dataSource, currentStrategy, stopPolling]);
|
|
332
|
+
}, [apiRef, props.dataSource, props.dataSourceKeepPreviousData, currentStrategy, stopPolling]);
|
|
333
|
+
React.useEffect(() => {
|
|
334
|
+
// `dataSourceKeepPreviousData` is a no-op for tree data and row grouping: those
|
|
335
|
+
// strategies always reset the rows on refetch to keep their order consistent with the
|
|
336
|
+
// response. Warn so the limitation is discoverable at runtime, not only in the docs.
|
|
337
|
+
if (process.env.NODE_ENV !== 'production' && props.dataSourceKeepPreviousData && (currentStrategy === DataSourceRowsUpdateStrategy.GroupedData || currentStrategy === DataSourceRowsUpdateStrategy.LazyLoadedGroupedData)) {
|
|
338
|
+
warnOnce(['MUI X: The `dataSourceKeepPreviousData` prop only applies to flat data.', 'It is ignored when tree data or row grouping is enabled, because the rows are always reset on refetch to keep their order consistent with the response.', 'For more details, see https://mui.com/x/react-data-grid/server-side-data/#keep-previous-data-while-fetching.']);
|
|
339
|
+
}
|
|
340
|
+
}, [props.dataSourceKeepPreviousData, currentStrategy]);
|
|
312
341
|
return {
|
|
313
342
|
api: {
|
|
314
343
|
public: dataSourceApi
|
|
@@ -366,11 +366,14 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
366
366
|
}
|
|
367
367
|
} else if (processRowUpdate) {
|
|
368
368
|
const handleError = errorThrown => {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
mode
|
|
373
|
-
|
|
369
|
+
// The row might have been deleted
|
|
370
|
+
if (prevCellModesModel.current[id]?.[field]) {
|
|
371
|
+
prevCellModesModel.current[id][field].mode = _gridEditRowModel.GridCellModes.Edit;
|
|
372
|
+
// Revert the mode in the cellModesModel prop back to "edit"
|
|
373
|
+
updateFieldInCellModesModel(id, field, {
|
|
374
|
+
mode: _gridEditRowModel.GridCellModes.Edit
|
|
375
|
+
});
|
|
376
|
+
}
|
|
374
377
|
if (onProcessRowUpdateError) {
|
|
375
378
|
onProcessRowUpdateError(errorThrown);
|
|
376
379
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
@@ -381,14 +384,18 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
381
384
|
Promise.resolve(processRowUpdate(rowUpdate, row, {
|
|
382
385
|
rowId: id
|
|
383
386
|
})).then(finalRowUpdate => {
|
|
384
|
-
apiRef.current.
|
|
387
|
+
if (apiRef.current.getRow(id)) {
|
|
388
|
+
apiRef.current.updateRows([finalRowUpdate]);
|
|
389
|
+
}
|
|
385
390
|
finishCellEditMode();
|
|
386
391
|
}).catch(handleError);
|
|
387
392
|
} catch (errorThrown) {
|
|
388
393
|
handleError(errorThrown);
|
|
389
394
|
}
|
|
390
395
|
} else {
|
|
391
|
-
apiRef.current.
|
|
396
|
+
if (apiRef.current.getRow(id)) {
|
|
397
|
+
apiRef.current.updateRows([rowUpdate]);
|
|
398
|
+
}
|
|
392
399
|
finishCellEditMode();
|
|
393
400
|
}
|
|
394
401
|
});
|
|
@@ -359,11 +359,14 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
359
359
|
}
|
|
360
360
|
} else if (processRowUpdate) {
|
|
361
361
|
const handleError = errorThrown => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
mode
|
|
366
|
-
|
|
362
|
+
// The row might have been deleted
|
|
363
|
+
if (prevCellModesModel.current[id]?.[field]) {
|
|
364
|
+
prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
|
|
365
|
+
// Revert the mode in the cellModesModel prop back to "edit"
|
|
366
|
+
updateFieldInCellModesModel(id, field, {
|
|
367
|
+
mode: GridCellModes.Edit
|
|
368
|
+
});
|
|
369
|
+
}
|
|
367
370
|
if (onProcessRowUpdateError) {
|
|
368
371
|
onProcessRowUpdateError(errorThrown);
|
|
369
372
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
@@ -374,14 +377,18 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
374
377
|
Promise.resolve(processRowUpdate(rowUpdate, row, {
|
|
375
378
|
rowId: id
|
|
376
379
|
})).then(finalRowUpdate => {
|
|
377
|
-
apiRef.current.
|
|
380
|
+
if (apiRef.current.getRow(id)) {
|
|
381
|
+
apiRef.current.updateRows([finalRowUpdate]);
|
|
382
|
+
}
|
|
378
383
|
finishCellEditMode();
|
|
379
384
|
}).catch(handleError);
|
|
380
385
|
} catch (errorThrown) {
|
|
381
386
|
handleError(errorThrown);
|
|
382
387
|
}
|
|
383
388
|
} else {
|
|
384
|
-
apiRef.current.
|
|
389
|
+
if (apiRef.current.getRow(id)) {
|
|
390
|
+
apiRef.current.updateRows([rowUpdate]);
|
|
391
|
+
}
|
|
385
392
|
finishCellEditMode();
|
|
386
393
|
}
|
|
387
394
|
});
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridLogicOperator } from "../../../models/index.mjs";
|
|
2
3
|
import type { GridColDef, GridFilterItem, GridFilterModel, GridRowModel } from "../../../models/index.mjs";
|
|
3
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
|
|
4
5
|
import type { GridStateCommunity } from "../../../models/gridStateCommunity.mjs";
|
|
5
6
|
import type { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from "./gridFilterState.mjs";
|
|
7
|
+
/**
|
|
8
|
+
* Pure helpers computing a new filter model from an existing one.
|
|
9
|
+
* Shared by the imperative `apiRef` methods (`useGridFilter`) and the controlled
|
|
10
|
+
* filter panel (`GridFilterPanelBase`) so both paths produce identical models.
|
|
11
|
+
* Each helper returns the same model reference when nothing changes, so callers
|
|
12
|
+
* relying on referential equality can skip no-op updates.
|
|
13
|
+
*/
|
|
14
|
+
export declare const upsertFilterItemInModel: (model: GridFilterModel, item: GridFilterItem) => GridFilterModel;
|
|
15
|
+
export declare const upsertFilterItemsInModel: (model: GridFilterModel, itemsToUpsert: GridFilterItem[]) => GridFilterModel;
|
|
16
|
+
export declare const deleteFilterItemFromModel: (model: GridFilterModel, itemToDelete: GridFilterItem) => GridFilterModel;
|
|
17
|
+
export declare const setFilterLogicOperatorInModel: (model: GridFilterModel, logicOperator: GridLogicOperator) => GridFilterModel;
|
|
6
18
|
/**
|
|
7
19
|
* Adds default values to the optional fields of a filter items.
|
|
8
20
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridLogicOperator } from "../../../models/index.js";
|
|
2
3
|
import type { GridColDef, GridFilterItem, GridFilterModel, GridRowModel } from "../../../models/index.js";
|
|
3
4
|
import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
5
|
import type { GridStateCommunity } from "../../../models/gridStateCommunity.js";
|
|
5
6
|
import type { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from "./gridFilterState.js";
|
|
7
|
+
/**
|
|
8
|
+
* Pure helpers computing a new filter model from an existing one.
|
|
9
|
+
* Shared by the imperative `apiRef` methods (`useGridFilter`) and the controlled
|
|
10
|
+
* filter panel (`GridFilterPanelBase`) so both paths produce identical models.
|
|
11
|
+
* Each helper returns the same model reference when nothing changes, so callers
|
|
12
|
+
* relying on referential equality can skip no-op updates.
|
|
13
|
+
*/
|
|
14
|
+
export declare const upsertFilterItemInModel: (model: GridFilterModel, item: GridFilterItem) => GridFilterModel;
|
|
15
|
+
export declare const upsertFilterItemsInModel: (model: GridFilterModel, itemsToUpsert: GridFilterItem[]) => GridFilterModel;
|
|
16
|
+
export declare const deleteFilterItemFromModel: (model: GridFilterModel, itemToDelete: GridFilterItem) => GridFilterModel;
|
|
17
|
+
export declare const setFilterLogicOperatorInModel: (model: GridFilterModel, logicOperator: GridLogicOperator) => GridFilterModel;
|
|
6
18
|
/**
|
|
7
19
|
* Adds default values to the optional fields of a filter items.
|
|
8
20
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.shouldQuickFilterExcludeHiddenColumns = exports.sanitizeFilterModel = exports.removeDiacritics = exports.passFilterLogic = exports.mergeStateWithFilterModel = exports.cleanFilterItem = exports.buildAggregatedFilterApplier = void 0;
|
|
7
|
+
exports.upsertFilterItemsInModel = exports.upsertFilterItemInModel = exports.shouldQuickFilterExcludeHiddenColumns = exports.setFilterLogicOperatorInModel = exports.sanitizeFilterModel = exports.removeDiacritics = exports.passFilterLogic = exports.mergeStateWithFilterModel = exports.deleteFilterItemFromModel = exports.cleanFilterItem = exports.buildAggregatedFilterApplier = void 0;
|
|
8
8
|
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _warning = require("@mui/x-internals/warning");
|
|
@@ -12,6 +12,61 @@ var _models = require("../../../models");
|
|
|
12
12
|
var _gridFilterState = require("./gridFilterState");
|
|
13
13
|
var _getPublicApiRef = require("../../../utils/getPublicApiRef");
|
|
14
14
|
var _columns = require("../columns");
|
|
15
|
+
/**
|
|
16
|
+
* Pure helpers computing a new filter model from an existing one.
|
|
17
|
+
* Shared by the imperative `apiRef` methods (`useGridFilter`) and the controlled
|
|
18
|
+
* filter panel (`GridFilterPanelBase`) so both paths produce identical models.
|
|
19
|
+
* Each helper returns the same model reference when nothing changes, so callers
|
|
20
|
+
* relying on referential equality can skip no-op updates.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const upsertFilterItemInModel = (model, item) => {
|
|
24
|
+
const items = [...model.items];
|
|
25
|
+
const itemIndex = items.findIndex(filterItem => filterItem.id === item.id);
|
|
26
|
+
if (itemIndex === -1) {
|
|
27
|
+
items.push(item);
|
|
28
|
+
} else {
|
|
29
|
+
items[itemIndex] = item;
|
|
30
|
+
}
|
|
31
|
+
return (0, _extends2.default)({}, model, {
|
|
32
|
+
items
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.upsertFilterItemInModel = upsertFilterItemInModel;
|
|
36
|
+
const upsertFilterItemsInModel = (model, itemsToUpsert) => {
|
|
37
|
+
const items = [...model.items];
|
|
38
|
+
itemsToUpsert.forEach(item => {
|
|
39
|
+
const itemIndex = items.findIndex(filterItem => filterItem.id === item.id);
|
|
40
|
+
if (itemIndex === -1) {
|
|
41
|
+
items.push(item);
|
|
42
|
+
} else {
|
|
43
|
+
items[itemIndex] = item;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return (0, _extends2.default)({}, model, {
|
|
47
|
+
items
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
exports.upsertFilterItemsInModel = upsertFilterItemsInModel;
|
|
51
|
+
const deleteFilterItemFromModel = (model, itemToDelete) => {
|
|
52
|
+
const items = model.items.filter(item => item.id !== itemToDelete.id);
|
|
53
|
+
if (items.length === model.items.length) {
|
|
54
|
+
return model;
|
|
55
|
+
}
|
|
56
|
+
return (0, _extends2.default)({}, model, {
|
|
57
|
+
items
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.deleteFilterItemFromModel = deleteFilterItemFromModel;
|
|
61
|
+
const setFilterLogicOperatorInModel = (model, logicOperator) => {
|
|
62
|
+
if (model.logicOperator === logicOperator) {
|
|
63
|
+
return model;
|
|
64
|
+
}
|
|
65
|
+
return (0, _extends2.default)({}, model, {
|
|
66
|
+
logicOperator
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
exports.setFilterLogicOperatorInModel = setFilterLogicOperatorInModel;
|
|
15
70
|
let hasEval;
|
|
16
71
|
function getHasEval() {
|
|
17
72
|
if (hasEval !== undefined) {
|