@mui/x-data-grid 8.0.0-beta.1 → 8.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/DataGrid/DataGrid.js +2 -0
  3. package/components/GridRow.js +3 -8
  4. package/components/GridShadowScrollArea.js +43 -35
  5. package/components/cell/GridBooleanCell.d.ts +1 -2
  6. package/components/cell/GridEditSingleSelectCell.d.ts +4 -4
  7. package/components/cell/GridEditSingleSelectCell.js +1 -1
  8. package/components/containers/GridToolbarContainer.js +5 -3
  9. package/components/quickFilter/QuickFilter.d.ts +26 -3
  10. package/components/quickFilter/QuickFilter.js +103 -19
  11. package/components/quickFilter/QuickFilterClear.js +10 -4
  12. package/components/quickFilter/QuickFilterContext.d.ts +4 -1
  13. package/components/quickFilter/QuickFilterControl.js +36 -10
  14. package/components/quickFilter/QuickFilterTrigger.d.ts +28 -0
  15. package/components/quickFilter/QuickFilterTrigger.js +211 -0
  16. package/components/quickFilter/index.d.ts +2 -1
  17. package/components/quickFilter/index.js +11 -0
  18. package/components/toolbar/GridToolbarColumnsButton.d.ts +3 -4
  19. package/components/toolbar/GridToolbarDensitySelector.d.ts +3 -4
  20. package/components/toolbar/GridToolbarExport.d.ts +3 -4
  21. package/components/toolbar/GridToolbarExportContainer.d.ts +3 -4
  22. package/components/toolbar/GridToolbarFilterButton.d.ts +4 -6
  23. package/components/toolbar/GridToolbarFilterButton.js +1 -4
  24. package/components/toolbar/GridToolbarQuickFilter.js +101 -41
  25. package/components/toolbarV8/GridToolbar.js +22 -19
  26. package/components/toolbarV8/Toolbar.d.ts +1 -1
  27. package/components/toolbarV8/Toolbar.js +76 -23
  28. package/components/toolbarV8/ToolbarButton.js +34 -14
  29. package/components/toolbarV8/ToolbarContext.d.ts +4 -2
  30. package/constants/gridClasses.d.ts +12 -0
  31. package/constants/gridClasses.js +1 -1
  32. package/esm/DataGrid/DataGrid.js +2 -0
  33. package/esm/components/GridRow.js +4 -9
  34. package/esm/components/GridShadowScrollArea.js +43 -35
  35. package/esm/components/cell/GridBooleanCell.d.ts +1 -2
  36. package/esm/components/cell/GridEditSingleSelectCell.d.ts +4 -4
  37. package/esm/components/cell/GridEditSingleSelectCell.js +1 -1
  38. package/esm/components/containers/GridToolbarContainer.js +5 -3
  39. package/esm/components/quickFilter/QuickFilter.d.ts +26 -3
  40. package/esm/components/quickFilter/QuickFilter.js +101 -17
  41. package/esm/components/quickFilter/QuickFilterClear.js +10 -4
  42. package/esm/components/quickFilter/QuickFilterContext.d.ts +4 -1
  43. package/esm/components/quickFilter/QuickFilterControl.js +36 -10
  44. package/esm/components/quickFilter/QuickFilterTrigger.d.ts +28 -0
  45. package/esm/components/quickFilter/QuickFilterTrigger.js +204 -0
  46. package/esm/components/quickFilter/index.d.ts +2 -1
  47. package/esm/components/quickFilter/index.js +2 -1
  48. package/esm/components/toolbar/GridToolbarColumnsButton.d.ts +3 -4
  49. package/esm/components/toolbar/GridToolbarDensitySelector.d.ts +3 -4
  50. package/esm/components/toolbar/GridToolbarExport.d.ts +3 -4
  51. package/esm/components/toolbar/GridToolbarExportContainer.d.ts +3 -4
  52. package/esm/components/toolbar/GridToolbarFilterButton.d.ts +4 -6
  53. package/esm/components/toolbar/GridToolbarFilterButton.js +1 -4
  54. package/esm/components/toolbar/GridToolbarQuickFilter.js +102 -44
  55. package/esm/components/toolbarV8/GridToolbar.js +22 -19
  56. package/esm/components/toolbarV8/Toolbar.d.ts +1 -1
  57. package/esm/components/toolbarV8/Toolbar.js +75 -22
  58. package/esm/components/toolbarV8/ToolbarButton.js +34 -14
  59. package/esm/components/toolbarV8/ToolbarContext.d.ts +4 -2
  60. package/esm/constants/gridClasses.d.ts +12 -0
  61. package/esm/constants/gridClasses.js +1 -1
  62. package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +1 -1
  63. package/esm/hooks/features/columns/useGridColumns.js +0 -1
  64. package/esm/hooks/features/dimensions/useGridDimensions.js +1 -1
  65. package/esm/hooks/features/filter/useGridFilter.js +1 -1
  66. package/esm/hooks/features/pagination/useGridPaginationModel.js +1 -1
  67. package/esm/hooks/features/virtualization/useGridVirtualScroller.js +12 -1
  68. package/esm/index.js +1 -1
  69. package/esm/locales/deDE.js +13 -13
  70. package/esm/models/props/DataGridProps.d.ts +6 -2
  71. package/esm/utils/utils.d.ts +0 -27
  72. package/esm/utils/utils.js +0 -122
  73. package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +2 -2
  74. package/hooks/features/columns/useGridColumns.js +0 -1
  75. package/hooks/features/dimensions/useGridDimensions.js +2 -2
  76. package/hooks/features/filter/useGridFilter.js +3 -3
  77. package/hooks/features/pagination/useGridPaginationModel.js +2 -2
  78. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -0
  79. package/index.js +1 -1
  80. package/locales/deDE.js +13 -13
  81. package/models/props/DataGridProps.d.ts +6 -2
  82. package/modern/DataGrid/DataGrid.js +2 -0
  83. package/modern/components/GridRow.js +4 -9
  84. package/modern/components/GridShadowScrollArea.js +43 -35
  85. package/modern/components/cell/GridBooleanCell.d.ts +1 -2
  86. package/modern/components/cell/GridEditSingleSelectCell.d.ts +4 -4
  87. package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
  88. package/modern/components/containers/GridToolbarContainer.js +5 -3
  89. package/modern/components/quickFilter/QuickFilter.d.ts +26 -3
  90. package/modern/components/quickFilter/QuickFilter.js +101 -17
  91. package/modern/components/quickFilter/QuickFilterClear.js +10 -4
  92. package/modern/components/quickFilter/QuickFilterContext.d.ts +4 -1
  93. package/modern/components/quickFilter/QuickFilterControl.js +36 -10
  94. package/modern/components/quickFilter/QuickFilterTrigger.d.ts +28 -0
  95. package/modern/components/quickFilter/QuickFilterTrigger.js +204 -0
  96. package/modern/components/quickFilter/index.d.ts +2 -1
  97. package/modern/components/quickFilter/index.js +2 -1
  98. package/modern/components/toolbar/GridToolbarColumnsButton.d.ts +3 -4
  99. package/modern/components/toolbar/GridToolbarDensitySelector.d.ts +3 -4
  100. package/modern/components/toolbar/GridToolbarExport.d.ts +3 -4
  101. package/modern/components/toolbar/GridToolbarExportContainer.d.ts +3 -4
  102. package/modern/components/toolbar/GridToolbarFilterButton.d.ts +4 -6
  103. package/modern/components/toolbar/GridToolbarFilterButton.js +1 -4
  104. package/modern/components/toolbar/GridToolbarQuickFilter.js +102 -44
  105. package/modern/components/toolbarV8/GridToolbar.js +22 -19
  106. package/modern/components/toolbarV8/Toolbar.d.ts +1 -1
  107. package/modern/components/toolbarV8/Toolbar.js +75 -22
  108. package/modern/components/toolbarV8/ToolbarButton.js +34 -14
  109. package/modern/components/toolbarV8/ToolbarContext.d.ts +4 -2
  110. package/modern/constants/gridClasses.d.ts +12 -0
  111. package/modern/constants/gridClasses.js +1 -1
  112. package/modern/hooks/features/columnGrouping/gridColumnGroupsUtils.js +1 -1
  113. package/modern/hooks/features/columns/useGridColumns.js +0 -1
  114. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
  115. package/modern/hooks/features/filter/useGridFilter.js +1 -1
  116. package/modern/hooks/features/pagination/useGridPaginationModel.js +1 -1
  117. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +12 -1
  118. package/modern/index.js +1 -1
  119. package/modern/locales/deDE.js +13 -13
  120. package/modern/models/props/DataGridProps.d.ts +6 -2
  121. package/modern/utils/utils.d.ts +0 -27
  122. package/modern/utils/utils.js +0 -122
  123. package/package.json +2 -2
  124. package/tsconfig.build.tsbuildinfo +1 -1
  125. package/utils/utils.d.ts +0 -27
  126. package/utils/utils.js +0 -123
@@ -1,19 +1,25 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["render", "className", "parser", "formatter", "debounceMs", "defaultExpanded", "expanded", "onExpandedChange"];
1
4
  import * as React from 'react';
2
5
  import PropTypes from 'prop-types';
3
6
  import { unstable_debounce as debounce } from '@mui/utils';
7
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
8
+ import useId from '@mui/utils/useId';
9
+ import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
4
10
  import { QuickFilterContext } from "./QuickFilterContext.js";
11
+ import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
5
12
  import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
6
13
  import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
7
14
  import { gridQuickFilterValuesSelector } from "../../hooks/features/filter/index.js";
8
15
  import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
9
- import { isDeepEqual } from "../../utils/utils.js";
10
16
  import { jsx as _jsx } from "react/jsx-runtime";
11
17
  const DEFAULT_PARSER = searchText => searchText.split(' ').filter(word => word !== '');
12
18
  const DEFAULT_FORMATTER = values => values.join(' ');
13
19
 
14
20
  /**
15
21
  * The top level Quick Filter component that provides context to child components.
16
- * It does not render any DOM elements.
22
+ * It renders a `<div />` element.
17
23
  *
18
24
  * Demos:
19
25
  *
@@ -26,16 +32,38 @@ const DEFAULT_FORMATTER = values => values.join(' ');
26
32
  function QuickFilter(props) {
27
33
  const rootProps = useGridRootProps();
28
34
  const {
29
- parser = DEFAULT_PARSER,
30
- formatter = DEFAULT_FORMATTER,
31
- debounceMs = rootProps.filterDebounceMs,
32
- children
33
- } = props;
35
+ render,
36
+ className,
37
+ parser = DEFAULT_PARSER,
38
+ formatter = DEFAULT_FORMATTER,
39
+ debounceMs = rootProps.filterDebounceMs,
40
+ defaultExpanded,
41
+ expanded,
42
+ onExpandedChange
43
+ } = props,
44
+ other = _objectWithoutPropertiesLoose(props, _excluded);
34
45
  const apiRef = useGridApiContext();
35
46
  const controlRef = React.useRef(null);
36
47
  const triggerRef = React.useRef(null);
37
48
  const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
38
49
  const [value, setValue] = React.useState(formatter(quickFilterValues ?? []));
50
+ const [internalExpanded, setInternalExpanded] = React.useState(defaultExpanded ?? value.length > 0);
51
+ const expandedValue = expanded ?? internalExpanded;
52
+ const state = React.useMemo(() => ({
53
+ value,
54
+ expanded: expandedValue
55
+ }), [value, expandedValue]);
56
+ const resolvedClassName = typeof className === 'function' ? className(state) : className;
57
+ const ref = React.useRef(null);
58
+ const controlId = useId();
59
+ const handleExpandedChange = React.useCallback(newExpanded => {
60
+ if (onExpandedChange) {
61
+ onExpandedChange(newExpanded);
62
+ }
63
+ if (expanded === undefined) {
64
+ setInternalExpanded(newExpanded);
65
+ }
66
+ }, [onExpandedChange, expanded]);
39
67
  const prevQuickFilterValuesRef = React.useRef(quickFilterValues);
40
68
  React.useEffect(() => {
41
69
  if (!isDeepEqual(prevQuickFilterValuesRef.current, quickFilterValues)) {
@@ -46,6 +74,31 @@ function QuickFilter(props) {
46
74
  setValue(prevSearchValue => isDeepEqual(parser(prevSearchValue), quickFilterValues) ? prevSearchValue : formatter(quickFilterValues ?? []));
47
75
  }
48
76
  }, [quickFilterValues, formatter, parser]);
77
+ const isFirstRender = React.useRef(true);
78
+ const previousExpandedValue = React.useRef(expandedValue);
79
+ React.useEffect(() => {
80
+ if (isFirstRender.current) {
81
+ isFirstRender.current = false;
82
+ return;
83
+ }
84
+
85
+ // Ensure the expanded state has actually changed before focusing
86
+ if (previousExpandedValue.current !== expandedValue) {
87
+ if (expandedValue) {
88
+ // Ensures the focus does not interupt CSS transitions and animations on the control
89
+ requestAnimationFrame(() => {
90
+ controlRef.current?.focus({
91
+ preventScroll: true
92
+ });
93
+ });
94
+ } else {
95
+ triggerRef.current?.focus({
96
+ preventScroll: true
97
+ });
98
+ }
99
+ previousExpandedValue.current = expandedValue;
100
+ }
101
+ }, [expandedValue]);
49
102
  const setQuickFilterValueDebounced = React.useMemo(() => debounce(newValue => {
50
103
  const newQuickFilterValues = parser(newValue);
51
104
  prevQuickFilterValuesRef.current = newQuickFilterValues;
@@ -57,7 +110,7 @@ function QuickFilter(props) {
57
110
  setValue(newValue);
58
111
  setQuickFilterValueDebounced(newValue);
59
112
  }, [setQuickFilterValueDebounced]);
60
- const handleClear = React.useCallback(() => {
113
+ const handleClearValue = React.useCallback(() => {
61
114
  setValue('');
62
115
  apiRef.current.setQuickFilterValues([]);
63
116
  controlRef.current?.focus();
@@ -65,15 +118,25 @@ function QuickFilter(props) {
65
118
  const contextValue = React.useMemo(() => ({
66
119
  controlRef,
67
120
  triggerRef,
68
- state: {
69
- value
70
- },
71
- clearValue: handleClear,
72
- onValueChange: handleValueChange
73
- }), [value, handleValueChange, handleClear]);
121
+ state,
122
+ controlId,
123
+ clearValue: handleClearValue,
124
+ onValueChange: handleValueChange,
125
+ onExpandedChange: handleExpandedChange
126
+ }), [controlId, state, handleValueChange, handleClearValue, handleExpandedChange]);
127
+ useEnhancedEffect(() => {
128
+ if (ref.current && triggerRef.current) {
129
+ ref.current.style.setProperty('--trigger-width', `${triggerRef.current?.offsetWidth}px`);
130
+ }
131
+ }, []);
132
+ const element = useGridComponentRenderer('div', render, _extends({
133
+ className: resolvedClassName
134
+ }, other, {
135
+ ref
136
+ }), state);
74
137
  return /*#__PURE__*/_jsx(QuickFilterContext.Provider, {
75
138
  value: contextValue,
76
- children: children
139
+ children: element
77
140
  });
78
141
  }
79
142
  process.env.NODE_ENV !== "production" ? QuickFilter.propTypes = {
@@ -81,12 +144,24 @@ process.env.NODE_ENV !== "production" ? QuickFilter.propTypes = {
81
144
  // | These PropTypes are generated from the TypeScript type definitions |
82
145
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
83
146
  // ----------------------------------------------------------------------
84
- children: PropTypes.node,
147
+ /**
148
+ * Override or extend the styles applied to the component.
149
+ */
150
+ className: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
85
151
  /**
86
152
  * The debounce time in milliseconds.
87
153
  * @default 150
88
154
  */
89
155
  debounceMs: PropTypes.number,
156
+ /**
157
+ * The default expanded state of the quick filter control.
158
+ * @default false
159
+ */
160
+ defaultExpanded: PropTypes.bool,
161
+ /**
162
+ * The expanded state of the quick filter control.
163
+ */
164
+ expanded: PropTypes.bool,
90
165
  /**
91
166
  * Function responsible for formatting values of quick filter in a string when the model is modified
92
167
  * @param {any[]} values The new values passed to the quick filter model
@@ -94,12 +169,21 @@ process.env.NODE_ENV !== "production" ? QuickFilter.propTypes = {
94
169
  * @default (values: string[]) => values.join(' ')
95
170
  */
96
171
  formatter: PropTypes.func,
172
+ /**
173
+ * Callback function that is called when the quick filter input is expanded or collapsed.
174
+ * @param {boolean} expanded The new expanded state of the quick filter control
175
+ */
176
+ onExpandedChange: PropTypes.func,
97
177
  /**
98
178
  * Function responsible for parsing text input in an array of independent values for quick filtering.
99
179
  * @param {string} input The value entered by the user
100
180
  * @returns {any[]} The array of value on which quick filter is applied
101
181
  * @default (searchText: string) => searchText.split(' ').filter((word) => word !== '')
102
182
  */
103
- parser: PropTypes.func
183
+ parser: PropTypes.func,
184
+ /**
185
+ * A function to customize rendering of the component.
186
+ */
187
+ render: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
104
188
  } : void 0;
105
189
  export { QuickFilter };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["render", "className"];
3
+ const _excluded = ["render", "className", "onClick"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { forwardRef } from '@mui/x-internals/forwardRef';
@@ -23,7 +23,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
23
23
  const QuickFilterClear = forwardRef(function QuickFilterClear(props, ref) {
24
24
  const {
25
25
  render,
26
- className
26
+ className,
27
+ onClick
27
28
  } = props,
28
29
  other = _objectWithoutPropertiesLoose(props, _excluded);
29
30
  const rootProps = useGridRootProps();
@@ -32,10 +33,15 @@ const QuickFilterClear = forwardRef(function QuickFilterClear(props, ref) {
32
33
  clearValue
33
34
  } = useQuickFilterContext();
34
35
  const resolvedClassName = typeof className === 'function' ? className(state) : className;
36
+ const handleClick = event => {
37
+ clearValue();
38
+ onClick?.(event);
39
+ };
35
40
  const element = useGridComponentRenderer(rootProps.slots.baseIconButton, render, _extends({}, rootProps.slotProps?.baseIconButton, {
36
- onClick: clearValue,
37
- className: resolvedClassName
41
+ className: resolvedClassName,
42
+ tabIndex: -1
38
43
  }, other, {
44
+ onClick: handleClick,
39
45
  ref
40
46
  }), state);
41
47
  return /*#__PURE__*/_jsx(React.Fragment, {
@@ -1,13 +1,16 @@
1
1
  import * as React from 'react';
2
2
  export interface QuickFilterState {
3
3
  value: string;
4
+ expanded: boolean;
4
5
  }
5
6
  export interface QuickFilterContextValue {
6
7
  state: QuickFilterState;
8
+ controlId: string | undefined;
7
9
  controlRef: React.RefObject<HTMLInputElement | null>;
8
10
  triggerRef: React.RefObject<HTMLButtonElement | null>;
9
- onValueChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
10
11
  clearValue: () => void;
12
+ onValueChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
13
+ onExpandedChange: (expanded: boolean) => void;
11
14
  }
12
15
  export declare const QuickFilterContext: React.Context<QuickFilterContextValue | undefined>;
13
16
  export declare function useQuickFilterContext(): QuickFilterContextValue;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["render", "className"];
3
+ const _excluded = ["render", "className", "slotProps", "onKeyDown", "onChange"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { unstable_useForkRef as useForkRef } from '@mui/utils';
@@ -24,35 +24,61 @@ import { jsx as _jsx } from "react/jsx-runtime";
24
24
  const QuickFilterControl = forwardRef(function QuickFilterControl(props, ref) {
25
25
  const {
26
26
  render,
27
- className
27
+ className,
28
+ slotProps,
29
+ onKeyDown,
30
+ onChange
28
31
  } = props,
29
32
  other = _objectWithoutPropertiesLoose(props, _excluded);
30
33
  const rootProps = useGridRootProps();
31
34
  const {
32
35
  state,
36
+ controlId,
33
37
  controlRef,
34
38
  onValueChange,
39
+ onExpandedChange,
35
40
  clearValue
36
41
  } = useQuickFilterContext();
37
42
  const resolvedClassName = typeof className === 'function' ? className(state) : className;
38
43
  const handleRef = useForkRef(controlRef, ref);
39
44
  const handleKeyDown = event => {
40
45
  if (event.key === 'Escape') {
41
- clearValue();
46
+ if (state.value === '') {
47
+ onExpandedChange(false);
48
+ } else {
49
+ clearValue();
50
+ }
42
51
  }
43
- props.onKeyDown?.(event);
52
+ onKeyDown?.(event);
53
+ };
54
+ const handleBlur = event => {
55
+ if (state.value === '') {
56
+ onExpandedChange(false);
57
+ }
58
+ slotProps?.htmlInput?.onBlur?.(event);
59
+ };
60
+ const handleChange = event => {
61
+ if (!state.expanded) {
62
+ onExpandedChange(true);
63
+ }
64
+ onValueChange(event);
65
+ onChange?.(event);
44
66
  };
45
67
  const element = useGridComponentRenderer(rootProps.slots.baseTextField, render, _extends({}, rootProps.slotProps?.baseTextField, {
46
68
  slotProps: _extends({
47
69
  htmlInput: _extends({
48
- role: 'searchbox'
49
- }, props.slotProps?.htmlInput)
50
- }, props.slotProps),
70
+ role: 'searchbox',
71
+ id: controlId,
72
+ tabIndex: state.expanded ? undefined : -1
73
+ }, slotProps?.htmlInput, {
74
+ onBlur: handleBlur
75
+ })
76
+ }, slotProps),
51
77
  value: state.value,
52
- className: resolvedClassName,
53
- onChange: onValueChange,
54
- onKeyDown: handleKeyDown
78
+ className: resolvedClassName
55
79
  }, other, {
80
+ onChange: handleChange,
81
+ onKeyDown: handleKeyDown,
56
82
  ref: handleRef
57
83
  }), state);
58
84
  return /*#__PURE__*/_jsx(React.Fragment, {
@@ -0,0 +1,28 @@
1
+ import * as React from 'react';
2
+ import { RenderProp } from "../../hooks/utils/useGridComponentRenderer.js";
3
+ import type { GridSlotProps } from '../../models';
4
+ import { QuickFilterState } from "./QuickFilterContext.js";
5
+ export type QuickFilterTriggerProps = Omit<GridSlotProps['baseButton'], 'className'> & {
6
+ /**
7
+ * A function to customize rendering of the component.
8
+ */
9
+ render?: RenderProp<GridSlotProps['baseButton'], QuickFilterState>;
10
+ /**
11
+ * Override or extend the styles applied to the component.
12
+ */
13
+ className?: string | ((state: QuickFilterState) => string);
14
+ };
15
+ /**
16
+ * A button that expands/collapses the quick filter.
17
+ * It renders the `baseButton` slot.
18
+ *
19
+ * Demos:
20
+ *
21
+ * - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
22
+ *
23
+ * API:
24
+ *
25
+ * - [QuickFilterTrigger API](https://mui.com/x/api/data-grid/quick-filter-trigger/)
26
+ */
27
+ declare const QuickFilterTrigger: React.ForwardRefExoticComponent<QuickFilterTriggerProps> | React.ForwardRefExoticComponent<Omit<QuickFilterTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
28
+ export { QuickFilterTrigger };
@@ -0,0 +1,204 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["render", "className", "onClick"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { forwardRef } from '@mui/x-internals/forwardRef';
7
+ import { unstable_useForkRef as useForkRef } from '@mui/utils';
8
+ import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
9
+ import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
10
+ import { useQuickFilterContext } from "./QuickFilterContext.js";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ /**
13
+ * A button that expands/collapses the quick filter.
14
+ * It renders the `baseButton` slot.
15
+ *
16
+ * Demos:
17
+ *
18
+ * - [Quick Filter](https://mui.com/x/react-data-grid/components/quick-filter/)
19
+ *
20
+ * API:
21
+ *
22
+ * - [QuickFilterTrigger API](https://mui.com/x/api/data-grid/quick-filter-trigger/)
23
+ */
24
+ const QuickFilterTrigger = forwardRef(function QuickFilterTrigger(props, ref) {
25
+ const {
26
+ render,
27
+ className,
28
+ onClick
29
+ } = props,
30
+ other = _objectWithoutPropertiesLoose(props, _excluded);
31
+ const rootProps = useGridRootProps();
32
+ const {
33
+ state,
34
+ controlId,
35
+ onExpandedChange,
36
+ triggerRef
37
+ } = useQuickFilterContext();
38
+ const resolvedClassName = typeof className === 'function' ? className(state) : className;
39
+ const handleRef = useForkRef(triggerRef, ref);
40
+ const handleClick = event => {
41
+ onExpandedChange(!state.expanded);
42
+ onClick?.(event);
43
+ };
44
+ const element = useGridComponentRenderer(rootProps.slots.baseButton, render, _extends({}, rootProps.slotProps?.baseButton, {
45
+ className: resolvedClassName,
46
+ 'aria-controls': controlId,
47
+ 'aria-expanded': state.expanded
48
+ }, other, {
49
+ onClick: handleClick,
50
+ ref: handleRef
51
+ }), state);
52
+ return /*#__PURE__*/_jsx(React.Fragment, {
53
+ children: element
54
+ });
55
+ });
56
+ process.env.NODE_ENV !== "production" ? QuickFilterTrigger.propTypes = {
57
+ // ----------------------------- Warning --------------------------------
58
+ // | These PropTypes are generated from the TypeScript type definitions |
59
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
60
+ // ----------------------------------------------------------------------
61
+ /**
62
+ * A ref for imperative actions.
63
+ * It currently only supports `focusVisible()` action.
64
+ */
65
+ action: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
66
+ current: PropTypes.shape({
67
+ focusVisible: PropTypes.func.isRequired
68
+ })
69
+ })]),
70
+ /**
71
+ * If `true`, the ripples are centered.
72
+ * They won't start at the cursor interaction position.
73
+ * @default false
74
+ */
75
+ centerRipple: PropTypes.bool,
76
+ /**
77
+ * Override or extend the styles applied to the component.
78
+ */
79
+ className: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
80
+ /**
81
+ * The color of the component.
82
+ * It supports both default and custom theme colors, which can be added as shown in the
83
+ * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
84
+ * @default 'primary'
85
+ */
86
+ color: PropTypes.oneOf(['error', 'info', 'inherit', 'primary', 'secondary', 'success', 'warning']),
87
+ component: PropTypes.elementType,
88
+ /**
89
+ * If `true`, the component is disabled.
90
+ */
91
+ disabled: PropTypes.bool,
92
+ /**
93
+ * If `true`, no elevation is used.
94
+ * @default false
95
+ */
96
+ disableElevation: PropTypes.bool,
97
+ /**
98
+ * If `true`, the keyboard focus ripple is disabled.
99
+ * @default false
100
+ */
101
+ disableFocusRipple: PropTypes.bool,
102
+ /**
103
+ * If `true`, the ripple effect is disabled.
104
+ *
105
+ * ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
106
+ * to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
107
+ * @default false
108
+ */
109
+ disableRipple: PropTypes.bool,
110
+ /**
111
+ * If `true`, the touch ripple effect is disabled.
112
+ * @default false
113
+ */
114
+ disableTouchRipple: PropTypes.bool,
115
+ /**
116
+ * Element placed after the children.
117
+ */
118
+ endIcon: PropTypes.node,
119
+ /**
120
+ * If `true`, the base button will have a keyboard focus ripple.
121
+ * @default false
122
+ */
123
+ focusRipple: PropTypes.bool,
124
+ /**
125
+ * This prop can help identify which element has keyboard focus.
126
+ * The class name will be applied when the element gains the focus through keyboard interaction.
127
+ * It's a polyfill for the [CSS :focus-visible selector](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo).
128
+ * The rationale for using this feature [is explained here](https://github.com/WICG/focus-visible/blob/HEAD/explainer.md).
129
+ * A [polyfill can be used](https://github.com/WICG/focus-visible) to apply a `focus-visible` class to other components
130
+ * if needed.
131
+ */
132
+ focusVisibleClassName: PropTypes.string,
133
+ /**
134
+ * If `true`, the button will take up the full width of its container.
135
+ * @default false
136
+ */
137
+ fullWidth: PropTypes.bool,
138
+ /**
139
+ * The URL to link to when the button is clicked.
140
+ * If defined, an `a` element will be used as the root node.
141
+ */
142
+ href: PropTypes.string,
143
+ /**
144
+ * The component used to render a link when the `href` prop is provided.
145
+ * @default 'a'
146
+ */
147
+ LinkComponent: PropTypes.elementType,
148
+ /**
149
+ * If `true`, the loading indicator is visible and the button is disabled.
150
+ * If `true | false`, the loading wrapper is always rendered before the children to prevent [Google Translation Crash](https://github.com/mui/material-ui/issues/27853).
151
+ * @default null
152
+ */
153
+ loading: PropTypes.bool,
154
+ /**
155
+ * Element placed before the children if the button is in loading state.
156
+ * The node should contain an element with `role="progressbar"` with an accessible name.
157
+ * By default, it renders a `CircularProgress` that is labeled by the button itself.
158
+ * @default <CircularProgress color="inherit" size={16} />
159
+ */
160
+ loadingIndicator: PropTypes.node,
161
+ /**
162
+ * The loading indicator can be positioned on the start, end, or the center of the button.
163
+ * @default 'center'
164
+ */
165
+ loadingPosition: PropTypes.oneOf(['center', 'end', 'start']),
166
+ /**
167
+ * Callback fired when the component is focused with a keyboard.
168
+ * We trigger a `onFocus` callback too.
169
+ */
170
+ onFocusVisible: PropTypes.func,
171
+ /**
172
+ * A function to customize rendering of the component.
173
+ */
174
+ render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
175
+ /**
176
+ * The size of the component.
177
+ * `small` is equivalent to the dense button styling.
178
+ */
179
+ size: PropTypes.oneOf(['large', 'medium', 'small']),
180
+ /**
181
+ * Element placed before the children.
182
+ */
183
+ startIcon: PropTypes.node,
184
+ style: PropTypes.object,
185
+ /**
186
+ * The system prop that allows defining system overrides as well as additional CSS styles.
187
+ */
188
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
189
+ tabIndex: PropTypes.number,
190
+ /**
191
+ * Props applied to the `TouchRipple` element.
192
+ */
193
+ TouchRippleProps: PropTypes.object,
194
+ /**
195
+ * A ref that points to the `TouchRipple` element.
196
+ */
197
+ touchRippleRef: PropTypes.any,
198
+ /**
199
+ * The variant to use.
200
+ * @default 'text'
201
+ */
202
+ variant: PropTypes.oneOf(['contained', 'outlined', 'text'])
203
+ } : void 0;
204
+ export { QuickFilterTrigger };
@@ -1,3 +1,4 @@
1
1
  export * from "./QuickFilter.js";
2
2
  export * from "./QuickFilterControl.js";
3
- export * from "./QuickFilterClear.js";
3
+ export * from "./QuickFilterClear.js";
4
+ export * from "./QuickFilterTrigger.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./QuickFilter.js";
2
2
  export * from "./QuickFilterControl.js";
3
- export * from "./QuickFilterClear.js";
3
+ export * from "./QuickFilterClear.js";
4
+ export * from "./QuickFilterTrigger.js";
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import { ButtonProps } from '@mui/material/Button';
3
- import { TooltipProps } from '@mui/material/Tooltip';
2
+ import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
4
3
  interface GridToolbarColumnsButtonProps {
5
4
  /**
6
5
  * The props used for each slot inside.
7
6
  * @default {}
8
7
  */
9
8
  slotProps?: {
10
- button?: Partial<ButtonProps>;
11
- tooltip?: Partial<TooltipProps>;
9
+ button?: Partial<GridSlotProps['baseButton']>;
10
+ tooltip?: Partial<GridSlotProps['baseTooltip']>;
12
11
  };
13
12
  }
14
13
  declare const GridToolbarColumnsButton: React.ForwardRefExoticComponent<GridToolbarColumnsButtonProps> | React.ForwardRefExoticComponent<GridToolbarColumnsButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import { ButtonProps } from '@mui/material/Button';
3
- import { TooltipProps } from '@mui/material/Tooltip';
2
+ import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
4
3
  interface GridToolbarDensitySelectorProps {
5
4
  /**
6
5
  * The props used for each slot inside.
7
6
  * @default {}
8
7
  */
9
8
  slotProps?: {
10
- button?: Partial<ButtonProps>;
11
- tooltip?: Partial<TooltipProps>;
9
+ button?: Partial<GridSlotProps['baseButton']>;
10
+ tooltip?: Partial<GridSlotProps['baseTooltip']>;
12
11
  };
13
12
  }
14
13
  declare const GridToolbarDensitySelector: React.ForwardRefExoticComponent<GridToolbarDensitySelectorProps> | React.ForwardRefExoticComponent<GridToolbarDensitySelectorProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ButtonProps } from '@mui/material/Button';
3
- import { TooltipProps } from '@mui/material/Tooltip';
2
+ import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
4
3
  import { GridCsvExportOptions, GridPrintExportOptions } from "../../models/gridExport.js";
5
4
  export interface GridExportDisplayOptions {
6
5
  /**
@@ -23,8 +22,8 @@ export interface GridToolbarExportProps {
23
22
  * @default {}
24
23
  */
25
24
  slotProps?: {
26
- button?: Partial<ButtonProps>;
27
- tooltip?: Partial<TooltipProps>;
25
+ button?: Partial<GridSlotProps['baseButton']>;
26
+ tooltip?: Partial<GridSlotProps['baseTooltip']>;
28
27
  };
29
28
  [x: `data-${string}`]: string;
30
29
  }
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import { ButtonProps } from '@mui/material/Button';
3
- import { TooltipProps } from '@mui/material/Tooltip';
2
+ import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
4
3
  interface GridToolbarExportContainerProps {
5
4
  /**
6
5
  * The props used for each slot inside.
7
6
  * @default {}
8
7
  */
9
8
  slotProps?: {
10
- button?: Partial<ButtonProps>;
11
- tooltip?: Partial<TooltipProps>;
9
+ button?: Partial<GridSlotProps['baseButton']>;
10
+ tooltip?: Partial<GridSlotProps['baseTooltip']>;
12
11
  };
13
12
  }
14
13
  declare const GridToolbarExportContainer: React.ForwardRefExoticComponent<React.PropsWithChildren<GridToolbarExportContainerProps>> | React.ForwardRefExoticComponent<GridToolbarExportContainerProps & {
@@ -1,16 +1,14 @@
1
1
  import * as React from 'react';
2
- import { ButtonProps } from '@mui/material/Button';
3
- import { TooltipProps } from '@mui/material/Tooltip';
4
- import { BadgeProps } from "../../models/gridBaseSlots.js";
2
+ import type { GridSlotProps } from '../../models/gridSlotsComponentsProps';
5
3
  export interface GridToolbarFilterButtonProps {
6
4
  /**
7
5
  * The props used for each slot inside.
8
6
  * @default {}
9
7
  */
10
8
  slotProps?: {
11
- button?: Partial<ButtonProps>;
12
- tooltip?: Partial<TooltipProps>;
13
- badge?: Partial<BadgeProps>;
9
+ button?: Partial<GridSlotProps['baseButton']>;
10
+ tooltip?: Partial<GridSlotProps['baseTooltip']>;
11
+ badge?: Partial<GridSlotProps['baseBadge']>;
14
12
  };
15
13
  }
16
14
  declare const GridToolbarFilterButton: React.ForwardRefExoticComponent<GridToolbarFilterButtonProps> | React.ForwardRefExoticComponent<GridToolbarFilterButtonProps & React.RefAttributes<HTMLButtonElement>>;