@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.
Files changed (188) hide show
  1. package/CHANGELOG.md +249 -1
  2. package/DataGrid/DataGrid.js +7 -0
  3. package/DataGrid/DataGrid.mjs +7 -0
  4. package/components/GridColumnSortButton.d.mts +1 -1
  5. package/components/GridColumnSortButton.d.ts +1 -1
  6. package/components/GridColumnUnsortedIcon.d.mts +2 -1
  7. package/components/GridColumnUnsortedIcon.d.ts +2 -1
  8. package/components/GridHeader.d.mts +2 -1
  9. package/components/GridHeader.d.ts +2 -1
  10. package/components/GridHeaders.d.mts +1 -1
  11. package/components/GridHeaders.d.ts +1 -1
  12. package/components/GridPagination.d.mts +2 -1
  13. package/components/GridPagination.d.ts +2 -1
  14. package/components/GridRowDragAndDropOverlay.d.mts +1 -1
  15. package/components/GridRowDragAndDropOverlay.d.ts +1 -1
  16. package/components/GridScrollArea.d.mts +2 -1
  17. package/components/GridScrollArea.d.ts +2 -1
  18. package/components/GridScrollShadows.d.mts +2 -1
  19. package/components/GridScrollShadows.d.ts +2 -1
  20. package/components/GridScrollbarFillerCell.d.mts +1 -1
  21. package/components/GridScrollbarFillerCell.d.ts +1 -1
  22. package/components/base/GridFooterPlaceholder.d.mts +1 -1
  23. package/components/base/GridFooterPlaceholder.d.ts +1 -1
  24. package/components/base/GridFooterPlaceholder.js +1 -1
  25. package/components/base/GridFooterPlaceholder.mjs +1 -1
  26. package/components/base/GridOverlays.d.mts +1 -1
  27. package/components/base/GridOverlays.d.ts +1 -1
  28. package/components/cell/GridActionsCell.d.mts +2 -2
  29. package/components/cell/GridActionsCell.d.ts +2 -2
  30. package/components/cell/GridActionsCellItem.js +1 -58
  31. package/components/cell/GridActionsCellItem.mjs +1 -58
  32. package/components/cell/GridBooleanCell.d.mts +1 -1
  33. package/components/cell/GridBooleanCell.d.ts +1 -1
  34. package/components/cell/GridEditBooleanCell.d.mts +2 -2
  35. package/components/cell/GridEditBooleanCell.d.ts +2 -2
  36. package/components/cell/GridEditDateCell.d.mts +2 -2
  37. package/components/cell/GridEditDateCell.d.ts +2 -2
  38. package/components/cell/GridEditInputCell.d.mts +1 -1
  39. package/components/cell/GridEditInputCell.d.ts +1 -1
  40. package/components/cell/GridEditLongTextCell.d.mts +2 -2
  41. package/components/cell/GridEditLongTextCell.d.ts +2 -2
  42. package/components/cell/GridEditSingleSelectCell.d.mts +3 -2
  43. package/components/cell/GridEditSingleSelectCell.d.ts +3 -2
  44. package/components/cell/GridFooterCell.d.mts +1 -1
  45. package/components/cell/GridFooterCell.d.ts +1 -1
  46. package/components/cell/GridLongTextCell.d.mts +2 -2
  47. package/components/cell/GridLongTextCell.d.ts +2 -2
  48. package/components/cell/GridSkeletonCell.d.mts +1 -1
  49. package/components/cell/GridSkeletonCell.d.ts +1 -1
  50. package/components/columnHeaders/ColumnHeaderMenuIcon.d.mts +1 -1
  51. package/components/columnHeaders/ColumnHeaderMenuIcon.d.ts +1 -1
  52. package/components/columnHeaders/GridColumnGroupHeader.d.mts +1 -1
  53. package/components/columnHeaders/GridColumnGroupHeader.d.ts +1 -1
  54. package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.mts +1 -1
  55. package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +1 -1
  56. package/components/columnHeaders/GridColumnHeaderItem.d.mts +1 -1
  57. package/components/columnHeaders/GridColumnHeaderItem.d.ts +1 -1
  58. package/components/columnHeaders/GridColumnHeaderSeparator.d.mts +1 -1
  59. package/components/columnHeaders/GridColumnHeaderSeparator.d.ts +1 -1
  60. package/components/columnHeaders/GridColumnHeaderSortIcon.d.mts +1 -1
  61. package/components/columnHeaders/GridColumnHeaderSortIcon.d.ts +1 -1
  62. package/components/columnHeaders/GridColumnHeaderTitle.d.mts +1 -1
  63. package/components/columnHeaders/GridColumnHeaderTitle.d.ts +1 -1
  64. package/components/columnsManagement/GridColumnsManagement.d.mts +2 -1
  65. package/components/columnsManagement/GridColumnsManagement.d.ts +2 -1
  66. package/components/menu/GridMenu.d.mts +1 -1
  67. package/components/menu/GridMenu.d.ts +1 -1
  68. package/components/menu/columnMenu/GridColumnHeaderMenu.d.mts +1 -1
  69. package/components/menu/columnMenu/GridColumnHeaderMenu.d.ts +1 -1
  70. package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.d.mts +2 -1
  71. package/components/menu/columnMenu/menuItems/GridColumnMenuColumnsItem.d.ts +2 -1
  72. package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.d.mts +2 -1
  73. package/components/menu/columnMenu/menuItems/GridColumnMenuFilterItem.d.ts +2 -1
  74. package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.d.mts +2 -1
  75. package/components/menu/columnMenu/menuItems/GridColumnMenuHideItem.d.ts +2 -1
  76. package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.d.mts +2 -1
  77. package/components/menu/columnMenu/menuItems/GridColumnMenuManageItem.d.ts +2 -1
  78. package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.d.mts +2 -1
  79. package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.d.ts +2 -1
  80. package/components/panel/GridColumnsPanel.d.mts +1 -1
  81. package/components/panel/GridColumnsPanel.d.ts +1 -1
  82. package/components/panel/GridPanelContent.d.mts +1 -1
  83. package/components/panel/GridPanelContent.d.ts +1 -1
  84. package/components/panel/GridPanelContext.d.mts +1 -1
  85. package/components/panel/GridPanelContext.d.ts +1 -1
  86. package/components/panel/GridPanelFooter.d.mts +1 -1
  87. package/components/panel/GridPanelFooter.d.ts +1 -1
  88. package/components/panel/GridPanelHeader.d.mts +1 -1
  89. package/components/panel/GridPanelHeader.d.ts +1 -1
  90. package/components/panel/GridPreferencesPanel.d.mts +1 -1
  91. package/components/panel/GridPreferencesPanel.d.ts +1 -1
  92. package/components/panel/filterPanel/GridFilterForm.d.mts +1 -98
  93. package/components/panel/filterPanel/GridFilterForm.d.ts +1 -98
  94. package/components/panel/filterPanel/GridFilterForm.js +9 -355
  95. package/components/panel/filterPanel/GridFilterForm.mjs +8 -354
  96. package/components/panel/filterPanel/GridFilterFormBase.d.mts +119 -0
  97. package/components/panel/filterPanel/GridFilterFormBase.d.ts +119 -0
  98. package/components/panel/filterPanel/GridFilterFormBase.js +497 -0
  99. package/components/panel/filterPanel/GridFilterFormBase.mjs +491 -0
  100. package/components/panel/filterPanel/GridFilterInputBoolean.d.mts +2 -1
  101. package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +2 -1
  102. package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -1
  103. package/components/panel/filterPanel/GridFilterInputBoolean.mjs +6 -1
  104. package/components/panel/filterPanel/GridFilterInputDate.d.mts +2 -1
  105. package/components/panel/filterPanel/GridFilterInputDate.d.ts +2 -1
  106. package/components/panel/filterPanel/GridFilterInputDate.js +21 -9
  107. package/components/panel/filterPanel/GridFilterInputDate.mjs +21 -9
  108. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.mts +2 -1
  109. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -1
  110. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -1
  111. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.mjs +6 -1
  112. package/components/panel/filterPanel/GridFilterInputMultipleValue.d.mts +2 -1
  113. package/components/panel/filterPanel/GridFilterInputMultipleValue.d.ts +2 -1
  114. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +6 -1
  115. package/components/panel/filterPanel/GridFilterInputMultipleValue.mjs +6 -1
  116. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.mts +2 -1
  117. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +2 -1
  118. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -1
  119. package/components/panel/filterPanel/GridFilterInputSingleSelect.mjs +6 -1
  120. package/components/panel/filterPanel/GridFilterInputValue.d.mts +2 -1
  121. package/components/panel/filterPanel/GridFilterInputValue.d.ts +2 -1
  122. package/components/panel/filterPanel/GridFilterInputValue.js +19 -8
  123. package/components/panel/filterPanel/GridFilterInputValue.mjs +19 -8
  124. package/components/panel/filterPanel/GridFilterPanel.d.mts +3 -40
  125. package/components/panel/filterPanel/GridFilterPanel.d.ts +3 -40
  126. package/components/panel/filterPanel/GridFilterPanel.js +19 -174
  127. package/components/panel/filterPanel/GridFilterPanel.mjs +14 -173
  128. package/components/panel/filterPanel/GridFilterPanelBase.d.mts +79 -0
  129. package/components/panel/filterPanel/GridFilterPanelBase.d.ts +79 -0
  130. package/components/panel/filterPanel/GridFilterPanelBase.js +304 -0
  131. package/components/panel/filterPanel/GridFilterPanelBase.mjs +297 -0
  132. package/components/panel/filterPanel/index.d.mts +3 -1
  133. package/components/panel/filterPanel/index.d.ts +3 -1
  134. package/components/panel/filterPanel/index.js +9 -1
  135. package/components/panel/filterPanel/index.mjs +3 -0
  136. package/components/quickFilter/QuickFilter.d.mts +1 -1
  137. package/components/quickFilter/QuickFilter.d.ts +1 -1
  138. package/components/toolbar/GridToolbarExport.d.mts +2 -2
  139. package/components/toolbar/GridToolbarExport.d.ts +2 -2
  140. package/components/toolbar/GridToolbarQuickFilter.d.mts +1 -1
  141. package/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
  142. package/components/toolbarV8/GridToolbar.d.mts +3 -3
  143. package/components/toolbarV8/GridToolbar.d.ts +3 -3
  144. package/components/virtualization/GridBottomContainer.d.mts +1 -1
  145. package/components/virtualization/GridBottomContainer.d.ts +1 -1
  146. package/components/virtualization/GridTopContainer.d.mts +1 -1
  147. package/components/virtualization/GridTopContainer.d.ts +1 -1
  148. package/components/virtualization/GridVirtualScroller.d.mts +1 -1
  149. package/components/virtualization/GridVirtualScroller.d.ts +1 -1
  150. package/components/virtualization/GridVirtualScrollerFiller.d.mts +2 -1
  151. package/components/virtualization/GridVirtualScrollerFiller.d.ts +2 -1
  152. package/constants/dataGridPropsDefaultValues.js +1 -0
  153. package/constants/dataGridPropsDefaultValues.mjs +1 -0
  154. package/context/GridContextProvider.d.mts +1 -1
  155. package/context/GridContextProvider.d.ts +1 -1
  156. package/hooks/features/columnHeaders/useGridColumnHeaders.d.mts +2 -2
  157. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +2 -2
  158. package/hooks/features/dataSource/useGridDataSourceBase.d.mts +1 -1
  159. package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
  160. package/hooks/features/dataSource/useGridDataSourceBase.js +39 -10
  161. package/hooks/features/dataSource/useGridDataSourceBase.mjs +39 -10
  162. package/hooks/features/editing/useGridCellEditing.js +14 -7
  163. package/hooks/features/editing/useGridCellEditing.mjs +14 -7
  164. package/hooks/features/filter/gridFilterUtils.d.mts +12 -0
  165. package/hooks/features/filter/gridFilterUtils.d.ts +12 -0
  166. package/hooks/features/filter/gridFilterUtils.js +56 -1
  167. package/hooks/features/filter/gridFilterUtils.mjs +52 -0
  168. package/hooks/features/filter/useGridFilter.js +4 -35
  169. package/hooks/features/filter/useGridFilter.mjs +5 -36
  170. package/hooks/features/rows/gridRowsUtils.js +1 -1
  171. package/hooks/features/rows/gridRowsUtils.mjs +1 -1
  172. package/hooks/utils/useGridEvent.js +1 -1
  173. package/hooks/utils/useGridEvent.mjs +1 -1
  174. package/index.js +1 -1
  175. package/index.mjs +1 -1
  176. package/internals/demo/TailwindDemoContainer.d.mts +1 -1
  177. package/internals/demo/TailwindDemoContainer.d.ts +1 -1
  178. package/locales/jaJP.js +4 -5
  179. package/locales/jaJP.mjs +4 -5
  180. package/models/gridFilterInputComponent.d.mts +5 -0
  181. package/models/gridFilterInputComponent.d.ts +5 -0
  182. package/models/gridSlotsComponentsProps.d.mts +1 -1
  183. package/models/gridSlotsComponentsProps.d.ts +1 -1
  184. package/models/props/DataGridProps.d.mts +7 -0
  185. package/models/props/DataGridProps.d.ts +7 -0
  186. package/package.json +4 -4
  187. package/utils/css/context.d.mts +3 -3
  188. package/utils/css/context.d.ts +3 -3
@@ -16,4 +16,4 @@ export declare function GridPanelContextProvider({
16
16
  children
17
17
  }: {
18
18
  children: React.ReactNode;
19
- }): import("react/jsx-runtime").JSX.Element;
19
+ }): React.JSX.Element;
@@ -16,4 +16,4 @@ export declare function GridPanelContextProvider({
16
16
  children
17
17
  }: {
18
18
  children: React.ReactNode;
19
- }): import("react/jsx-runtime").JSX.Element;
19
+ }): React.JSX.Element;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import type { SxProps, Theme } from '@mui/material/styles';
3
3
  declare function GridPanelFooter(props: React.HTMLAttributes<HTMLDivElement> & {
4
4
  sx?: SxProps<Theme>;
5
- }): import("react/jsx-runtime").JSX.Element;
5
+ }): React.JSX.Element;
6
6
  declare namespace GridPanelFooter {
7
7
  var propTypes: any;
8
8
  }
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import type { SxProps, Theme } from '@mui/material/styles';
3
3
  declare function GridPanelFooter(props: React.HTMLAttributes<HTMLDivElement> & {
4
4
  sx?: SxProps<Theme>;
5
- }): import("react/jsx-runtime").JSX.Element;
5
+ }): React.JSX.Element;
6
6
  declare namespace GridPanelFooter {
7
7
  var propTypes: any;
8
8
  }
@@ -5,7 +5,7 @@ import type { SxProps, Theme } from '@mui/system';
5
5
  */
6
6
  declare function GridPanelHeader(props: React.HTMLAttributes<HTMLDivElement> & {
7
7
  sx?: SxProps<Theme>;
8
- }): import("react/jsx-runtime").JSX.Element;
8
+ }): React.JSX.Element;
9
9
  declare namespace GridPanelHeader {
10
10
  var propTypes: any;
11
11
  }
@@ -5,7 +5,7 @@ import type { SxProps, Theme } from '@mui/system';
5
5
  */
6
6
  declare function GridPanelHeader(props: React.HTMLAttributes<HTMLDivElement> & {
7
7
  sx?: SxProps<Theme>;
8
- }): import("react/jsx-runtime").JSX.Element;
8
+ }): React.JSX.Element;
9
9
  declare namespace GridPanelHeader {
10
10
  var propTypes: any;
11
11
  }
@@ -1 +1 @@
1
- export declare function GridPreferencesPanel(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function GridPreferencesPanel(): import("react").JSX.Element;
@@ -1 +1 @@
1
- export declare function GridPreferencesPanel(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function GridPreferencesPanel(): import("react").JSX.Element;
@@ -1,102 +1,5 @@
1
1
  import * as React from 'react';
2
- import { GridLogicOperator } from "../../../models/gridFilterItem.mjs";
3
- import type { GridFilterItem } from "../../../models/gridFilterItem.mjs";
4
- import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridColDef.mjs";
5
- export interface FilterColumnsArgs {
6
- field: GridColDef['field'];
7
- columns: GridStateColDef[];
8
- currentFilters: GridFilterItem[];
9
- }
10
- export interface GridFilterFormProps {
11
- /**
12
- * The [[GridFilterItem]] representing this form.
13
- */
14
- item: GridFilterItem;
15
- /**
16
- * If `true`, the logic operator field is rendered.
17
- * The field will be invisible if `showMultiFilterOperators` is also `true`.
18
- */
19
- hasMultipleFilters: boolean;
20
- /**
21
- * If `true`, the logic operator field is visible.
22
- */
23
- showMultiFilterOperators?: boolean;
24
- /**
25
- * If `true`, disables the logic operator field but still renders it.
26
- */
27
- disableMultiFilterOperator?: boolean;
28
- /**
29
- * A ref allowing to set imperative focus.
30
- * It can be passed to the el
31
- */
32
- focusElementRef?: React.Ref<any>;
33
- /**
34
- * Callback called when the operator, column field or value is changed.
35
- * @param {GridFilterItem} item The updated [[GridFilterItem]].
36
- */
37
- applyFilterChanges: (item: GridFilterItem) => void;
38
- /**
39
- * Callback called when the logic operator is changed.
40
- * @param {GridLogicOperator} operator The new logic operator.
41
- */
42
- applyMultiFilterOperatorChanges: (operator: GridLogicOperator) => void;
43
- /**
44
- * Callback called when the delete button is clicked.
45
- * @param {GridFilterItem} item The deleted [[GridFilterItem]].
46
- */
47
- deleteFilter: (item: GridFilterItem) => void;
48
- /**
49
- * Allows to filter the columns displayed in the filter form.
50
- * @param {FilterColumnsArgs} args The columns of the grid and name of field.
51
- * @returns {GridColDef['field'][]} The filtered fields array.
52
- */
53
- filterColumns?: (args: FilterColumnsArgs) => GridColDef['field'][];
54
- /**
55
- * Sets the available logic operators.
56
- * @default [GridLogicOperator.And, GridLogicOperator.Or]
57
- */
58
- logicOperators?: GridLogicOperator[];
59
- /**
60
- * Changes how the options in the columns selector should be ordered.
61
- * If not specified, the order is derived from the `columns` prop.
62
- */
63
- columnsSort?: 'asc' | 'desc';
64
- /**
65
- * Props passed to the delete icon.
66
- * @default {}
67
- */
68
- deleteIconProps?: any;
69
- /**
70
- * Props passed to the logic operator input component.
71
- * @default {}
72
- */
73
- logicOperatorInputProps?: any;
74
- /**
75
- * Props passed to the operator input component.
76
- * @default {}
77
- */
78
- operatorInputProps?: any;
79
- /**
80
- * Props passed to the column input component.
81
- * @default {}
82
- */
83
- columnInputProps?: any;
84
- /**
85
- * `true` if the filter is disabled/read only.
86
- * i.e. `colDef.fiterable = false` but passed in `filterModel`
87
- * @default false
88
- */
89
- readOnly?: boolean;
90
- /**
91
- * Props passed to the value input component.
92
- * @default {}
93
- */
94
- valueInputProps?: any;
95
- /**
96
- * @ignore - do not document.
97
- */
98
- children?: React.ReactNode;
99
- }
2
+ import type { GridFilterFormProps } from "./GridFilterFormBase.mjs";
100
3
  declare const GridFilterForm: React.ForwardRefExoticComponent<GridFilterFormProps> | React.ForwardRefExoticComponent<GridFilterFormProps & React.RefAttributes<HTMLDivElement>>;
101
4
  /**
102
5
  * Demos:
@@ -1,102 +1,5 @@
1
1
  import * as React from 'react';
2
- import { GridLogicOperator } from "../../../models/gridFilterItem.js";
3
- import type { GridFilterItem } from "../../../models/gridFilterItem.js";
4
- import type { GridColDef, GridStateColDef } from "../../../models/colDef/gridColDef.js";
5
- export interface FilterColumnsArgs {
6
- field: GridColDef['field'];
7
- columns: GridStateColDef[];
8
- currentFilters: GridFilterItem[];
9
- }
10
- export interface GridFilterFormProps {
11
- /**
12
- * The [[GridFilterItem]] representing this form.
13
- */
14
- item: GridFilterItem;
15
- /**
16
- * If `true`, the logic operator field is rendered.
17
- * The field will be invisible if `showMultiFilterOperators` is also `true`.
18
- */
19
- hasMultipleFilters: boolean;
20
- /**
21
- * If `true`, the logic operator field is visible.
22
- */
23
- showMultiFilterOperators?: boolean;
24
- /**
25
- * If `true`, disables the logic operator field but still renders it.
26
- */
27
- disableMultiFilterOperator?: boolean;
28
- /**
29
- * A ref allowing to set imperative focus.
30
- * It can be passed to the el
31
- */
32
- focusElementRef?: React.Ref<any>;
33
- /**
34
- * Callback called when the operator, column field or value is changed.
35
- * @param {GridFilterItem} item The updated [[GridFilterItem]].
36
- */
37
- applyFilterChanges: (item: GridFilterItem) => void;
38
- /**
39
- * Callback called when the logic operator is changed.
40
- * @param {GridLogicOperator} operator The new logic operator.
41
- */
42
- applyMultiFilterOperatorChanges: (operator: GridLogicOperator) => void;
43
- /**
44
- * Callback called when the delete button is clicked.
45
- * @param {GridFilterItem} item The deleted [[GridFilterItem]].
46
- */
47
- deleteFilter: (item: GridFilterItem) => void;
48
- /**
49
- * Allows to filter the columns displayed in the filter form.
50
- * @param {FilterColumnsArgs} args The columns of the grid and name of field.
51
- * @returns {GridColDef['field'][]} The filtered fields array.
52
- */
53
- filterColumns?: (args: FilterColumnsArgs) => GridColDef['field'][];
54
- /**
55
- * Sets the available logic operators.
56
- * @default [GridLogicOperator.And, GridLogicOperator.Or]
57
- */
58
- logicOperators?: GridLogicOperator[];
59
- /**
60
- * Changes how the options in the columns selector should be ordered.
61
- * If not specified, the order is derived from the `columns` prop.
62
- */
63
- columnsSort?: 'asc' | 'desc';
64
- /**
65
- * Props passed to the delete icon.
66
- * @default {}
67
- */
68
- deleteIconProps?: any;
69
- /**
70
- * Props passed to the logic operator input component.
71
- * @default {}
72
- */
73
- logicOperatorInputProps?: any;
74
- /**
75
- * Props passed to the operator input component.
76
- * @default {}
77
- */
78
- operatorInputProps?: any;
79
- /**
80
- * Props passed to the column input component.
81
- * @default {}
82
- */
83
- columnInputProps?: any;
84
- /**
85
- * `true` if the filter is disabled/read only.
86
- * i.e. `colDef.fiterable = false` but passed in `filterModel`
87
- * @default false
88
- */
89
- readOnly?: boolean;
90
- /**
91
- * Props passed to the value input component.
92
- * @default {}
93
- */
94
- valueInputProps?: any;
95
- /**
96
- * @ignore - do not document.
97
- */
98
- children?: React.ReactNode;
99
- }
2
+ import type { GridFilterFormProps } from "./GridFilterFormBase.js";
100
3
  declare const GridFilterForm: React.ForwardRefExoticComponent<GridFilterFormProps> | React.ForwardRefExoticComponent<GridFilterFormProps & React.RefAttributes<HTMLDivElement>>;
101
4
  /**
102
5
  * Demos:
@@ -1,374 +1,28 @@
1
1
  "use strict";
2
2
  'use client';
3
3
 
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.GridFilterForm = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
- var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
13
- var _react = _interopRequireWildcard(require("react"));
14
- var React = _react;
11
+ var React = _interopRequireWildcard(require("react"));
15
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
16
- var _clsx = _interopRequireDefault(require("clsx"));
17
- var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
18
- var _useId = _interopRequireDefault(require("@mui/utils/useId"));
19
- var _capitalize = _interopRequireDefault(require("@mui/utils/capitalize"));
20
- var _styles = require("@mui/material/styles");
21
13
  var _forwardRef = require("@mui/x-internals/forwardRef");
22
- var _cssVariables = require("../../../constants/cssVariables");
23
- var _gridColumnsSelector = require("../../../hooks/features/columns/gridColumnsSelector");
24
- var _gridFilterSelector = require("../../../hooks/features/filter/gridFilterSelector");
25
- var _useGridSelector = require("../../../hooks/utils/useGridSelector");
26
- var _gridFilterItem = require("../../../models/gridFilterItem");
27
14
  var _useGridApiContext = require("../../../hooks/utils/useGridApiContext");
28
- var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
29
- var _gridClasses = require("../../../constants/gridClasses");
30
- var _filterPanelUtils = require("./filterPanelUtils");
31
- var _pivoting = require("../../../hooks/features/pivoting");
15
+ var _useGridSelector = require("../../../hooks/utils/useGridSelector");
16
+ var _gridFilterSelector = require("../../../hooks/features/filter/gridFilterSelector");
17
+ var _GridFilterFormBase = require("./GridFilterFormBase");
32
18
  var _jsxRuntime = require("react/jsx-runtime");
33
- const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "logicOperators", "columnsSort", "filterColumns", "deleteIconProps", "logicOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "readOnly", "children"],
34
- _excluded2 = ["InputComponentProps"];
35
- const useUtilityClasses = ownerState => {
36
- const {
37
- classes
38
- } = ownerState;
39
- const slots = {
40
- root: ['filterForm'],
41
- deleteIcon: ['filterFormDeleteIcon'],
42
- logicOperatorInput: ['filterFormLogicOperatorInput'],
43
- columnInput: ['filterFormColumnInput'],
44
- operatorInput: ['filterFormOperatorInput'],
45
- valueInput: ['filterFormValueInput']
46
- };
47
- return (0, _composeClasses.default)(slots, _gridClasses.getDataGridUtilityClass, classes);
48
- };
49
- const GridFilterFormRoot = (0, _styles.styled)('div', {
50
- name: 'MuiDataGrid',
51
- slot: 'FilterForm'
52
- })({
53
- display: 'flex',
54
- gap: _cssVariables.vars.spacing(1.5)
55
- });
56
- const FilterFormDeleteIcon = (0, _styles.styled)('div', {
57
- name: 'MuiDataGrid',
58
- slot: 'FilterFormDeleteIcon'
59
- })({
60
- flexShrink: 0,
61
- display: 'flex',
62
- justifyContent: 'center',
63
- alignItems: 'center'
64
- });
65
- const FilterFormLogicOperatorInput = (0, _styles.styled)('div', {
66
- name: 'MuiDataGrid',
67
- slot: 'FilterFormLogicOperatorInput'
68
- })({
69
- minWidth: 75,
70
- justifyContent: 'end'
71
- });
72
- const FilterFormColumnInput = (0, _styles.styled)('div', {
73
- name: 'MuiDataGrid',
74
- slot: 'FilterFormColumnInput'
75
- })({
76
- width: 150
77
- });
78
- const FilterFormOperatorInput = (0, _styles.styled)('div', {
79
- name: 'MuiDataGrid',
80
- slot: 'FilterFormOperatorInput'
81
- })({
82
- width: 150
83
- });
84
- const FilterFormValueInput = (0, _styles.styled)('div', {
85
- name: 'MuiDataGrid',
86
- slot: 'FilterFormValueInput'
87
- })({
88
- width: 190
89
- });
90
- const getLogicOperatorLocaleKey = logicOperator => {
91
- switch (logicOperator) {
92
- case _gridFilterItem.GridLogicOperator.And:
93
- return 'filterPanelOperatorAnd';
94
- case _gridFilterItem.GridLogicOperator.Or:
95
- return 'filterPanelOperatorOr';
96
- default:
97
- throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: Invalid `logicOperator` property in the `GridFilterPanel`.' : (0, _formatErrorMessage2.default)(71));
98
- }
99
- };
100
- const getColumnLabel = col => col.headerName || col.field;
101
- const collator = new Intl.Collator();
102
19
  const GridFilterForm = exports.GridFilterForm = (0, _forwardRef.forwardRef)(function GridFilterForm(props, ref) {
103
- const {
104
- item,
105
- hasMultipleFilters,
106
- deleteFilter,
107
- applyFilterChanges,
108
- showMultiFilterOperators,
109
- disableMultiFilterOperator,
110
- applyMultiFilterOperatorChanges,
111
- focusElementRef,
112
- logicOperators = [_gridFilterItem.GridLogicOperator.And, _gridFilterItem.GridLogicOperator.Or],
113
- columnsSort,
114
- filterColumns,
115
- deleteIconProps = {},
116
- logicOperatorInputProps = {},
117
- operatorInputProps = {},
118
- columnInputProps = {},
119
- valueInputProps = {},
120
- readOnly
121
- } = props,
122
- other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
123
20
  const apiRef = (0, _useGridApiContext.useGridApiContext)();
124
- const columnLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnLookupSelector);
125
- const filterableColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridFilterableColumnDefinitionsSelector);
126
21
  const filterModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterModelSelector);
127
- const columnSelectId = (0, _useId.default)();
128
- const columnSelectLabelId = (0, _useId.default)();
129
- const operatorSelectId = (0, _useId.default)();
130
- const operatorSelectLabelId = (0, _useId.default)();
131
- const rootProps = (0, _useGridRootProps.useGridRootProps)();
132
- const classes = useUtilityClasses(rootProps);
133
- const valueRef = React.useRef(null);
134
- const filterSelectorRef = React.useRef(null);
135
- const multiFilterOperator = filterModel.logicOperator ?? _gridFilterItem.GridLogicOperator.And;
136
- const hasLogicOperatorColumn = hasMultipleFilters && logicOperators.length > 0;
137
- const baseSelectProps = rootProps.slotProps?.baseSelect || {};
138
- const isBaseSelectNative = baseSelectProps.native ?? false;
139
- const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
140
- const {
141
- InputComponentProps
142
- } = valueInputProps,
143
- valueInputPropsOther = (0, _objectWithoutPropertiesLoose2.default)(valueInputProps, _excluded2);
144
- const pivotActive = (0, _useGridSelector.useGridSelector)(apiRef, _pivoting.gridPivotActiveSelector);
145
- const initialColumns = (0, _useGridSelector.useGridSelector)(apiRef, _pivoting.gridPivotInitialColumnsSelector);
146
- const {
147
- filteredColumns,
148
- selectedField
149
- } = React.useMemo(() => {
150
- let itemField = item.field;
151
-
152
- // Yields a valid value if the current filter belongs to a column that is not filterable
153
- const selectedNonFilterableColumn = columnLookup[item.field].filterable === false ? columnLookup[item.field] : null;
154
- if (selectedNonFilterableColumn) {
155
- return {
156
- filteredColumns: [selectedNonFilterableColumn],
157
- selectedField: itemField
158
- };
159
- }
160
- if (pivotActive) {
161
- return {
162
- filteredColumns: filterableColumns.filter(column => initialColumns.get(column.field) !== undefined),
163
- selectedField: itemField
164
- };
165
- }
166
- if (filterColumns === undefined || typeof filterColumns !== 'function') {
167
- return {
168
- filteredColumns: filterableColumns,
169
- selectedField: itemField
170
- };
171
- }
172
- const filteredFields = filterColumns({
173
- field: item.field,
174
- columns: filterableColumns,
175
- currentFilters: filterModel?.items || []
176
- });
177
- return {
178
- filteredColumns: filterableColumns.filter(column => {
179
- const isFieldIncluded = filteredFields.includes(column.field);
180
- if (column.field === item.field && !isFieldIncluded) {
181
- itemField = undefined;
182
- }
183
- return isFieldIncluded;
184
- }),
185
- selectedField: itemField
186
- };
187
- }, [item.field, columnLookup, pivotActive, filterColumns, filterableColumns, filterModel?.items, initialColumns]);
188
- const sortedFilteredColumns = React.useMemo(() => {
189
- switch (columnsSort) {
190
- case 'asc':
191
- return filteredColumns.sort((a, b) => collator.compare(getColumnLabel(a), getColumnLabel(b)));
192
- case 'desc':
193
- return filteredColumns.sort((a, b) => -collator.compare(getColumnLabel(a), getColumnLabel(b)));
194
- default:
195
- return filteredColumns;
196
- }
197
- }, [filteredColumns, columnsSort]);
198
- const currentColumn = item.field ? apiRef.current.getColumn(item.field) : null;
199
- const currentOperator = React.useMemo(() => {
200
- if (!item.operator || !currentColumn) {
201
- return null;
202
- }
203
- return currentColumn.filterOperators?.find(operator => operator.value === item.operator);
204
- }, [item, currentColumn]);
205
- const changeColumn = React.useCallback(event => {
206
- const field = event.target.value;
207
- const column = apiRef.current.getColumn(field);
208
- if (column.field === currentColumn.field) {
209
- // column did not change
210
- return;
211
- }
212
-
213
- // try to keep the same operator when column change
214
- const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
215
-
216
- // Erase filter value if the input component or filtered column type is modified
217
- const eraseFilterValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent || column.type !== currentColumn.type;
218
- let filterValue = eraseFilterValue ? undefined : item.value;
219
-
220
- // Check filter value against the new valueOptions
221
- if (column.type === 'singleSelect' && filterValue !== undefined) {
222
- const colDef = column;
223
- const valueOptions = (0, _filterPanelUtils.getValueOptions)(colDef);
224
- if (Array.isArray(filterValue)) {
225
- filterValue = filterValue.filter(val => {
226
- return (
227
- // Only keep values that are in the new value options
228
- (0, _filterPanelUtils.getValueFromValueOptions)(val, valueOptions, colDef?.getOptionValue) !== undefined
229
- );
230
- });
231
- } else if ((0, _filterPanelUtils.getValueFromValueOptions)(item.value, valueOptions, colDef?.getOptionValue) === undefined) {
232
- // Reset the filter value if it is not in the new value options
233
- filterValue = undefined;
234
- }
235
- }
236
- applyFilterChanges((0, _extends2.default)({}, item, {
237
- field,
238
- operator: newOperator.value,
239
- value: filterValue
240
- }));
241
- }, [apiRef, applyFilterChanges, item, currentColumn, currentOperator]);
242
- const changeOperator = React.useCallback(event => {
243
- const operator = event.target.value;
244
- const newOperator = currentColumn?.filterOperators.find(op => op.value === operator);
245
- const eraseItemValue = !newOperator?.InputComponent || newOperator?.InputComponent !== currentOperator?.InputComponent;
246
- applyFilterChanges((0, _extends2.default)({}, item, {
247
- operator,
248
- value: eraseItemValue ? undefined : item.value
249
- }));
250
- }, [applyFilterChanges, item, currentColumn, currentOperator]);
251
- const changeLogicOperator = React.useCallback(event => {
252
- const logicOperator = event.target.value === _gridFilterItem.GridLogicOperator.And.toString() ? _gridFilterItem.GridLogicOperator.And : _gridFilterItem.GridLogicOperator.Or;
253
- applyMultiFilterOperatorChanges(logicOperator);
254
- }, [applyMultiFilterOperatorChanges]);
255
- const handleDeleteFilter = () => {
256
- deleteFilter(item);
257
- };
258
- React.useImperativeHandle(focusElementRef, () => ({
259
- focus: () => {
260
- if (currentOperator?.InputComponent) {
261
- valueRef?.current?.focus();
262
- } else {
263
- filterSelectorRef.current.focus();
264
- }
265
- }
266
- }), [currentOperator]);
267
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridFilterFormRoot, (0, _extends2.default)({
268
- className: classes.root,
269
- "data-id": item.id,
270
- ownerState: rootProps
271
- }, other, {
272
- ref: ref,
273
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormDeleteIcon, (0, _extends2.default)({}, deleteIconProps, {
274
- className: (0, _clsx.default)(classes.deleteIcon, deleteIconProps.className),
275
- ownerState: rootProps,
276
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
277
- "aria-label": apiRef.current.getLocaleText('filterPanelDeleteIconLabel'),
278
- title: apiRef.current.getLocaleText('filterPanelDeleteIconLabel'),
279
- onClick: handleDeleteFilter,
280
- size: "small",
281
- disabled: readOnly
282
- }, rootProps.slotProps?.baseIconButton, {
283
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.filterPanelDeleteIcon, {
284
- fontSize: "small"
285
- })
286
- }))
287
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormLogicOperatorInput, (0, _extends2.default)({
288
- as: rootProps.slots.baseSelect,
289
- sx: [hasLogicOperatorColumn ? {
290
- display: 'flex'
291
- } : {
292
- display: 'none'
293
- }, showMultiFilterOperators ? {
294
- visibility: 'visible'
295
- } : {
296
- visibility: 'hidden'
297
- }, logicOperatorInputProps.sx],
298
- className: (0, _clsx.default)(classes.logicOperatorInput, logicOperatorInputProps.className),
299
- ownerState: rootProps
300
- }, logicOperatorInputProps, {
301
- size: "small",
302
- slotProps: {
303
- htmlInput: {
304
- 'aria-label': apiRef.current.getLocaleText('filterPanelLogicOperator')
305
- }
306
- },
307
- value: multiFilterOperator ?? '',
308
- onChange: changeLogicOperator,
309
- disabled: !!disableMultiFilterOperator || logicOperators.length === 1,
310
- native: isBaseSelectNative
311
- }, rootProps.slotProps?.baseSelect, {
312
- children: logicOperators.map(logicOperator => /*#__PURE__*/(0, _react.createElement)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
313
- native: isBaseSelectNative,
314
- key: logicOperator.toString(),
315
- value: logicOperator.toString()
316
- }), apiRef.current.getLocaleText(getLogicOperatorLocaleKey(logicOperator))))
317
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormColumnInput, (0, _extends2.default)({
318
- as: rootProps.slots.baseSelect
319
- }, columnInputProps, {
320
- className: (0, _clsx.default)(classes.columnInput, columnInputProps.className),
321
- ownerState: rootProps,
322
- size: "small",
323
- labelId: columnSelectLabelId,
324
- id: columnSelectId,
325
- label: apiRef.current.getLocaleText('filterPanelColumn'),
326
- value: selectedField ?? '',
327
- onChange: changeColumn,
328
- native: isBaseSelectNative,
329
- disabled: readOnly
330
- }, rootProps.slotProps?.baseSelect, {
331
- children: sortedFilteredColumns.map(col => /*#__PURE__*/(0, _react.createElement)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
332
- native: isBaseSelectNative,
333
- key: col.field,
334
- value: col.field
335
- }), getColumnLabel(col)))
336
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormOperatorInput, (0, _extends2.default)({
337
- as: rootProps.slots.baseSelect,
338
- size: "small"
339
- }, operatorInputProps, {
340
- className: (0, _clsx.default)(classes.operatorInput, operatorInputProps.className),
341
- ownerState: rootProps,
342
- labelId: operatorSelectLabelId,
343
- label: apiRef.current.getLocaleText('filterPanelOperator'),
344
- id: operatorSelectId,
345
- value: item.operator,
346
- onChange: changeOperator,
347
- native: isBaseSelectNative,
348
- inputRef: filterSelectorRef,
349
- disabled: readOnly
350
- }, rootProps.slotProps?.baseSelect, {
351
- children: currentColumn?.filterOperators?.map(operator => /*#__PURE__*/(0, _react.createElement)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
352
- native: isBaseSelectNative,
353
- key: operator.value,
354
- value: operator.value
355
- }), operator.label || apiRef.current.getLocaleText(`filterOperator${(0, _capitalize.default)(operator.value)}`)))
356
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(FilterFormValueInput, (0, _extends2.default)({}, valueInputPropsOther, {
357
- className: (0, _clsx.default)(classes.valueInput, valueInputPropsOther.className),
358
- ownerState: rootProps,
359
- children: currentOperator?.InputComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(currentOperator.InputComponent, (0, _extends2.default)({
360
- apiRef: apiRef,
361
- item: item,
362
- applyValue: applyFilterChanges,
363
- focusElementRef: valueRef,
364
- disabled: readOnly,
365
- slotProps: {
366
- root: {
367
- size: 'small'
368
- }
369
- }
370
- }, currentOperator.InputComponentProps, InputComponentProps), item.field) : null
371
- }))]
22
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridFilterFormBase.GridFilterFormBase, (0, _extends2.default)({
23
+ filterModel: filterModel
24
+ }, props, {
25
+ ref: ref
372
26
  }));
373
27
  });
374
28
  if (process.env.NODE_ENV !== "production") GridFilterForm.displayName = "GridFilterForm";