@mui/x-data-grid-premium 8.0.0-alpha.0 → 8.0.0-alpha.10

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 (157) hide show
  1. package/CHANGELOG.md +2215 -119
  2. package/DataGridPremium/DataGridPremium.js +40 -40
  3. package/DataGridPremium/useDataGridPremiumComponent.d.ts +2 -2
  4. package/DataGridPremium/useDataGridPremiumComponent.js +4 -2
  5. package/DataGridPremium/useDataGridPremiumProps.js +5 -3
  6. package/README.md +3 -3
  7. package/components/GridAggregationHeader.js +6 -1
  8. package/components/GridColumnMenuAggregationItem.js +77 -49
  9. package/components/GridColumnMenuRowGroupItem.js +5 -11
  10. package/components/GridColumnMenuRowUngroupItem.js +10 -19
  11. package/components/GridDataSourceGroupingCriteriaCell.js +1 -2
  12. package/components/GridPremiumColumnMenu.d.ts +1 -1
  13. package/components/GridPremiumColumnMenu.js +5 -5
  14. package/components/index.d.ts +1 -0
  15. package/components/index.js +12 -0
  16. package/components/promptControl/GridToolbarPromptControl.d.ts +26 -0
  17. package/components/promptControl/GridToolbarPromptControl.js +220 -0
  18. package/components/promptControl/RecordButton.d.ts +16 -0
  19. package/components/promptControl/RecordButton.js +119 -0
  20. package/components/promptControl/index.d.ts +1 -0
  21. package/components/promptControl/index.js +12 -0
  22. package/esm/DataGridPremium/DataGridPremium.js +42 -42
  23. package/esm/DataGridPremium/useDataGridPremiumComponent.js +5 -3
  24. package/esm/DataGridPremium/useDataGridPremiumProps.js +6 -4
  25. package/esm/components/GridAggregationHeader.js +6 -1
  26. package/esm/components/GridColumnMenuAggregationItem.js +75 -47
  27. package/esm/components/GridColumnMenuRowGroupItem.js +6 -11
  28. package/esm/components/GridColumnMenuRowUngroupItem.js +11 -19
  29. package/esm/components/GridDataSourceGroupingCriteriaCell.js +1 -2
  30. package/esm/components/GridPremiumColumnMenu.js +5 -5
  31. package/esm/components/index.js +1 -0
  32. package/esm/components/promptControl/GridToolbarPromptControl.js +213 -0
  33. package/esm/components/promptControl/RecordButton.js +111 -0
  34. package/esm/components/promptControl/index.js +1 -0
  35. package/esm/hooks/features/aggregation/createAggregationLookup.js +52 -55
  36. package/esm/hooks/features/aggregation/gridAggregationUtils.js +17 -13
  37. package/esm/hooks/features/aggregation/index.js +0 -1
  38. package/esm/hooks/features/aggregation/useGridAggregation.js +22 -10
  39. package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +8 -14
  40. package/esm/hooks/features/cellSelection/useGridCellSelection.js +5 -6
  41. package/esm/hooks/features/clipboard/useGridClipboardImport.js +1 -1
  42. package/esm/hooks/features/dataSource/cache.js +3 -0
  43. package/esm/hooks/features/dataSource/models.js +1 -0
  44. package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +53 -0
  45. package/esm/hooks/features/index.js +2 -1
  46. package/esm/hooks/features/promptControl/api.js +22 -0
  47. package/esm/hooks/features/promptControl/index.js +1 -0
  48. package/esm/hooks/features/promptControl/types.js +1 -0
  49. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +5 -1
  50. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +2 -2
  51. package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +2 -2
  52. package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
  53. package/esm/hooks/utils/useGridAriaAttributes.js +1 -3
  54. package/esm/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
  55. package/esm/material/icons.js +7 -1
  56. package/esm/material/index.js +4 -2
  57. package/esm/utils/releaseInfo.js +1 -1
  58. package/hooks/features/aggregation/createAggregationLookup.d.ts +7 -6
  59. package/hooks/features/aggregation/createAggregationLookup.js +52 -55
  60. package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +18 -5
  61. package/hooks/features/aggregation/gridAggregationSelectors.d.ts +2 -2
  62. package/hooks/features/aggregation/gridAggregationUtils.d.ts +12 -13
  63. package/hooks/features/aggregation/gridAggregationUtils.js +17 -13
  64. package/hooks/features/aggregation/index.d.ts +1 -1
  65. package/hooks/features/aggregation/index.js +0 -12
  66. package/hooks/features/aggregation/useGridAggregation.d.ts +2 -2
  67. package/hooks/features/aggregation/useGridAggregation.js +22 -10
  68. package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +2 -2
  69. package/hooks/features/aggregation/useGridAggregationPreProcessors.js +8 -14
  70. package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +4 -2
  71. package/hooks/features/cellSelection/gridCellSelectionInterfaces.d.ts +3 -3
  72. package/hooks/features/cellSelection/useGridCellSelection.d.ts +2 -2
  73. package/hooks/features/cellSelection/useGridCellSelection.js +4 -5
  74. package/hooks/features/clipboard/useGridClipboardImport.d.ts +2 -2
  75. package/hooks/features/clipboard/useGridClipboardImport.js +1 -1
  76. package/hooks/features/dataSource/cache.d.ts +2 -0
  77. package/hooks/features/dataSource/cache.js +9 -0
  78. package/hooks/features/dataSource/models.d.ts +47 -0
  79. package/hooks/features/dataSource/models.js +5 -0
  80. package/hooks/features/dataSource/useGridDataSourcePremium.d.ts +4 -0
  81. package/hooks/features/dataSource/useGridDataSourcePremium.js +62 -0
  82. package/hooks/features/export/serializer/excelSerializer.d.ts +3 -2
  83. package/hooks/features/export/useGridExcelExport.d.ts +2 -2
  84. package/hooks/features/index.d.ts +1 -0
  85. package/hooks/features/index.js +11 -0
  86. package/hooks/features/promptControl/api.d.ts +2 -0
  87. package/hooks/features/promptControl/api.js +28 -0
  88. package/hooks/features/promptControl/index.d.ts +2 -0
  89. package/hooks/features/promptControl/index.js +12 -0
  90. package/hooks/features/promptControl/types.d.ts +25 -0
  91. package/hooks/features/promptControl/types.js +5 -0
  92. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +2 -2
  93. package/hooks/features/rowGrouping/createGroupingColDef.js +5 -1
  94. package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +2 -2
  95. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +4 -4
  96. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +1 -1
  97. package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +2 -2
  98. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +2 -2
  99. package/hooks/features/rowGrouping/useGridRowGrouping.js +1 -1
  100. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +2 -2
  101. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
  102. package/hooks/utils/useGridApiContext.d.ts +1 -1
  103. package/hooks/utils/useGridApiRef.d.ts +3 -1
  104. package/hooks/utils/useGridAriaAttributes.js +1 -3
  105. package/hooks/utils/useGridPrivateApiContext.d.ts +1 -1
  106. package/hooks/utils/useKeepGroupedColumnsHidden.d.ts +2 -2
  107. package/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
  108. package/index.d.ts +2 -0
  109. package/index.js +1 -1
  110. package/material/icons.d.ts +6 -0
  111. package/material/icons.js +8 -2
  112. package/material/index.d.ts +2 -0
  113. package/material/index.js +3 -1
  114. package/models/dataGridPremiumProps.d.ts +8 -12
  115. package/models/gridApiPremium.d.ts +5 -3
  116. package/models/gridGroupingValueGetter.d.ts +2 -1
  117. package/models/gridPastedValueParser.d.ts +2 -1
  118. package/models/gridPremiumIconSlotsComponent.d.ts +10 -0
  119. package/modern/DataGridPremium/DataGridPremium.js +42 -42
  120. package/modern/DataGridPremium/useDataGridPremiumComponent.js +5 -3
  121. package/modern/DataGridPremium/useDataGridPremiumProps.js +6 -4
  122. package/modern/components/GridAggregationHeader.js +6 -1
  123. package/modern/components/GridColumnMenuAggregationItem.js +75 -47
  124. package/modern/components/GridColumnMenuRowGroupItem.js +6 -11
  125. package/modern/components/GridColumnMenuRowUngroupItem.js +11 -19
  126. package/modern/components/GridDataSourceGroupingCriteriaCell.js +1 -2
  127. package/modern/components/GridPremiumColumnMenu.js +5 -5
  128. package/modern/components/index.js +1 -0
  129. package/modern/components/promptControl/GridToolbarPromptControl.js +213 -0
  130. package/modern/components/promptControl/RecordButton.js +111 -0
  131. package/modern/components/promptControl/index.js +1 -0
  132. package/modern/hooks/features/aggregation/createAggregationLookup.js +52 -55
  133. package/modern/hooks/features/aggregation/gridAggregationUtils.js +17 -13
  134. package/modern/hooks/features/aggregation/index.js +0 -1
  135. package/modern/hooks/features/aggregation/useGridAggregation.js +22 -10
  136. package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +8 -14
  137. package/modern/hooks/features/cellSelection/useGridCellSelection.js +5 -6
  138. package/modern/hooks/features/clipboard/useGridClipboardImport.js +1 -1
  139. package/modern/hooks/features/dataSource/cache.js +3 -0
  140. package/modern/hooks/features/dataSource/models.js +1 -0
  141. package/modern/hooks/features/dataSource/useGridDataSourcePremium.js +53 -0
  142. package/modern/hooks/features/index.js +2 -1
  143. package/modern/hooks/features/promptControl/api.js +22 -0
  144. package/modern/hooks/features/promptControl/index.js +1 -0
  145. package/modern/hooks/features/promptControl/types.js +1 -0
  146. package/modern/hooks/features/rowGrouping/createGroupingColDef.js +5 -1
  147. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +2 -2
  148. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +2 -2
  149. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
  150. package/modern/hooks/utils/useGridAriaAttributes.js +1 -3
  151. package/modern/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
  152. package/modern/index.js +1 -1
  153. package/modern/material/icons.js +7 -1
  154. package/modern/material/index.js +4 -2
  155. package/modern/utils/releaseInfo.js +1 -1
  156. package/package.json +8 -8
  157. package/utils/releaseInfo.js +1 -1
@@ -48,4 +48,16 @@ Object.keys(_GridColumnMenuAggregationItem).forEach(function (key) {
48
48
  }
49
49
  });
50
50
  });
51
+ var _promptControl = require("./promptControl");
52
+ Object.keys(_promptControl).forEach(function (key) {
53
+ if (key === "default" || key === "__esModule") return;
54
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
55
+ if (key in exports && exports[key] === _promptControl[key]) return;
56
+ Object.defineProperty(exports, key, {
57
+ enumerable: true,
58
+ get: function () {
59
+ return _promptControl[key];
60
+ }
61
+ });
62
+ });
51
63
  var _GridPremiumColumnMenu = require("./GridPremiumColumnMenu");
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { PromptResponse } from '../../hooks/features/promptControl/types';
3
+ type GridToolbarPromptControlProps = {
4
+ /**
5
+ * Called when the new prompt is ready to be processed.
6
+ * Provides the prompt and the data context and expects the grid state updates to be returned.
7
+ * @param {string} context The context of the prompt
8
+ * @param {string} query The query to process
9
+ * @returns {Promise<PromptResponse>} The grid state updates
10
+ */
11
+ onPrompt: (context: string, query: string) => Promise<PromptResponse>;
12
+ /**
13
+ * Allow taking couple of random cell values from each column to improve the prompt context.
14
+ * If allowed, samples are taken from different rows.
15
+ * If not allowed, the column examples are used.
16
+ * @default false
17
+ */
18
+ allowDataSampling?: boolean;
19
+ /**
20
+ * The BCP 47 language tag to use for the speech recognition.
21
+ * @default HTML lang attribute value or the user agent's language setting
22
+ */
23
+ lang?: string;
24
+ };
25
+ declare function GridToolbarPromptControl(props: GridToolbarPromptControlProps): React.JSX.Element;
26
+ export { GridToolbarPromptControl };
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.GridToolbarPromptControl = GridToolbarPromptControl;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _styles = require("@mui/material/styles");
12
+ var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
13
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
14
+ var _xDataGrid = require("@mui/x-data-grid");
15
+ var _internals = require("@mui/x-data-grid/internals");
16
+ var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
17
+ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
18
+ var _RecordButton = require("./RecordButton");
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ const supportsSpeechRecognition = !!_RecordButton.BrowserSpeechRecognition;
21
+ const useUtilityClasses = ownerState => {
22
+ const {
23
+ classes,
24
+ recording
25
+ } = ownerState;
26
+ const slots = {
27
+ root: ['toolbarPromptControl', recording && 'toolbarPromptControl--recording'],
28
+ recordingIndicator: ['toolbarPromptControlRecordingIndicator'],
29
+ recordButton: ['toolbarPromptControlRecordButton'],
30
+ sendButton: ['toolbarPromptControlSendButton']
31
+ };
32
+ return (0, _composeClasses.default)(slots, _xDataGrid.getDataGridUtilityClass, classes);
33
+ };
34
+ const GridToolbarPromptControlRoot = (0, _styles.styled)('div', {
35
+ name: 'MuiDataGrid',
36
+ slot: 'ToolbarPromptControl',
37
+ overridesResolver: (props, styles) => {
38
+ const {
39
+ ownerState
40
+ } = props;
41
+ return [styles.toolbarPromptControl, ownerState.recording && styles['toolbarPromptControl--recording']];
42
+ }
43
+ })({
44
+ flex: 1,
45
+ display: 'flex',
46
+ flexDirection: 'row'
47
+ });
48
+ function sampleData(apiRef) {
49
+ const columns = (0, _xDataGrid.gridColumnDefinitionsSelector)(apiRef);
50
+ const rows = Object.values((0, _xDataGrid.gridRowsLookupSelector)(apiRef));
51
+ const columnExamples = {};
52
+ columns.forEach(column => {
53
+ columnExamples[column.field] = Array.from({
54
+ length: Math.min(5, rows.length)
55
+ }).map(() => {
56
+ const row = rows[Math.floor(Math.random() * rows.length)];
57
+ if (column.valueGetter) {
58
+ return column.valueGetter(row[column.field], row, column, apiRef);
59
+ }
60
+ return row[column.field];
61
+ });
62
+ });
63
+ return columnExamples;
64
+ }
65
+ function generateContext(apiRef, examples) {
66
+ const columns = (0, _xDataGrid.gridColumnDefinitionsSelector)(apiRef);
67
+ const columnsContext = columns.map(column => ({
68
+ field: column.field,
69
+ description: column.description ?? null,
70
+ examples: examples?.[column.field] ?? column.unstable_examples ?? [],
71
+ type: column.type ?? 'string',
72
+ allowedOperators: column.filterOperators?.map(operator => operator.value) ?? []
73
+ }));
74
+ return `The columns are described by the following JSON:\n${JSON.stringify(columnsContext)}`;
75
+ }
76
+ function GridToolbarPromptControl(props) {
77
+ const apiRef = (0, _useGridApiContext.useGridApiContext)();
78
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
79
+ const {
80
+ onPrompt,
81
+ lang,
82
+ allowDataSampling = false
83
+ } = props;
84
+ const [isLoading, setLoading] = React.useState(false);
85
+ const [error, setError] = React.useState(null);
86
+ const [isRecording, setRecording] = React.useState(false);
87
+ const [query, setQuery] = React.useState('');
88
+ const ownerState = {
89
+ classes: rootProps.classes,
90
+ recording: isRecording
91
+ };
92
+ const classes = useUtilityClasses(ownerState);
93
+ const examplesFromData = React.useMemo(() => allowDataSampling ? sampleData(apiRef) : undefined, [apiRef, allowDataSampling]);
94
+ const processPrompt = React.useCallback(() => {
95
+ const context = generateContext(apiRef, examplesFromData);
96
+ const columnsByField = (0, _xDataGrid.gridColumnLookupSelector)(apiRef);
97
+ setLoading(true);
98
+ setError(null);
99
+ apiRef.current.setLoading(true);
100
+ onPrompt(context, query).then(result => {
101
+ const interestColumns = [];
102
+ apiRef.current.setFilterModel({
103
+ items: result.filters.map((filter, index) => {
104
+ const item = {
105
+ id: index,
106
+ field: filter.column,
107
+ operator: filter.operator,
108
+ value: filter.value
109
+ };
110
+ const column = columnsByField[filter.column];
111
+ if (column.type === 'singleSelect') {
112
+ const options = (0, _internals.getValueOptions)(column) ?? [];
113
+ const found = options.find(option => typeof option === 'object' && option.label === filter.value);
114
+ if (found) {
115
+ item.value = found.value;
116
+ }
117
+ }
118
+ return item;
119
+ }),
120
+ logicOperator: result.filterOperator ?? _xDataGrid.GridLogicOperator.And,
121
+ quickFilterValues: []
122
+ });
123
+ apiRef.current.setRowGroupingModel(result.grouping.map(g => g.column));
124
+ apiRef.current.setAggregationModel(result.aggregation);
125
+ apiRef.current.setSortModel(result.sorting.map(s => ({
126
+ field: s.column,
127
+ sort: s.direction
128
+ })));
129
+ const rows = (0, _internals.getVisibleRows)(apiRef, rootProps);
130
+ const selectedRowIds = result.select === -1 ? [] : rows.rows.slice(0, result.select).map(r => {
131
+ return apiRef.current.getRowId(r);
132
+ });
133
+ apiRef.current.setRowSelectionModel(selectedRowIds);
134
+ const columns = apiRef.current.getAllColumns();
135
+ const targetIndex = Number(columns.find(c => c.field === _xDataGrid.GRID_CHECKBOX_SELECTION_FIELD) !== undefined) + Number(result.grouping.length);
136
+ interestColumns.push(...Object.keys(result.aggregation));
137
+ interestColumns.push(...result.filters.map(f => f.column));
138
+ interestColumns.reverse().forEach(c => apiRef.current.setColumnIndex(c, targetIndex));
139
+ }).catch(_ => {
140
+ setError(apiRef.current.getLocaleText('toolbarPromptControlErrorMessage'));
141
+ }).finally(() => {
142
+ setLoading(false);
143
+ apiRef.current.setState(state => (0, _extends2.default)({}, state, {
144
+ rows: (0, _extends2.default)({}, state.rows, {
145
+ loading: false
146
+ })
147
+ }));
148
+ });
149
+ }, [apiRef, rootProps, onPrompt, examplesFromData, query]);
150
+ const handleChange = (0, _useEventCallback.default)(event => {
151
+ setQuery(event.target.value);
152
+ });
153
+ const handleKeyDown = (0, _useEventCallback.default)(event => {
154
+ if (event.code === 'Enter') {
155
+ processPrompt();
156
+ }
157
+ });
158
+ const handleDone = (0, _useEventCallback.default)(value => {
159
+ setQuery(value);
160
+ if (value) {
161
+ processPrompt();
162
+ }
163
+ });
164
+ const placeholder = supportsSpeechRecognition ? apiRef.current.getLocaleText('toolbarPromptControlWithRecordingPlaceholder') : apiRef.current.getLocaleText('toolbarPromptControlPlaceholder');
165
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridToolbarPromptControlRoot, {
166
+ ownerState: ownerState,
167
+ className: classes.root,
168
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, {
169
+ placeholder: isRecording ? apiRef.current.getLocaleText('toolbarPromptControlRecordingPlaceholder') : placeholder,
170
+ "aria-label": apiRef.current.getLocaleText('toolbarPromptControlLabel'),
171
+ disabled: isLoading,
172
+ value: query,
173
+ style: {
174
+ flex: 1
175
+ },
176
+ onChange: handleChange,
177
+ size: "small",
178
+ onKeyDown: handleKeyDown,
179
+ error: !!error,
180
+ helperText: error,
181
+ slotProps: {
182
+ input: {
183
+ startAdornment: supportsSpeechRecognition && /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputAdornment, {
184
+ position: "start",
185
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RecordButton.RecordButton, {
186
+ className: classes.recordButton,
187
+ lang: lang,
188
+ recording: isRecording,
189
+ setRecording: setRecording,
190
+ disabled: isLoading,
191
+ onUpdate: setQuery,
192
+ onDone: handleDone,
193
+ onError: setError
194
+ })
195
+ }),
196
+ endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputAdornment, {
197
+ position: "end",
198
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, {
199
+ title: apiRef.current.getLocaleText('toolbarPromptControlSendActionLabel'),
200
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
201
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, {
202
+ className: classes.sendButton,
203
+ disabled: isLoading || isRecording || query === '',
204
+ color: "primary",
205
+ onClick: processPrompt,
206
+ size: "small",
207
+ "aria-label": apiRef.current.getLocaleText('toolbarPromptControlSendActionAriaLabel'),
208
+ edge: "end",
209
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.toolbarPromptSendIcon, {
210
+ fontSize: "small"
211
+ })
212
+ })
213
+ })
214
+ })
215
+ })
216
+ }
217
+ }
218
+ })
219
+ });
220
+ }
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ export declare const BrowserSpeechRecognition: any;
3
+ type SpeechRecognitionOptions = {
4
+ onUpdate: (value: string) => void;
5
+ onDone: (value: string) => void;
6
+ onError: (error: string) => void;
7
+ };
8
+ interface RecordButtonProps extends SpeechRecognitionOptions {
9
+ disabled: boolean;
10
+ lang?: string;
11
+ recording: boolean;
12
+ setRecording: (value: boolean) => void;
13
+ className: string;
14
+ }
15
+ declare function RecordButton(props: RecordButtonProps): React.JSX.Element;
16
+ export { RecordButton };
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.BrowserSpeechRecognition = void 0;
9
+ exports.RecordButton = RecordButton;
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _useTimeout = require("@mui/utils/useTimeout");
12
+ var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
13
+ var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
14
+ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ const BrowserSpeechRecognition = exports.BrowserSpeechRecognition = globalThis.SpeechRecognition || globalThis.webkitSpeechRecognition;
17
+ function RecordButton(props) {
18
+ const apiRef = (0, _useGridApiContext.useGridApiContext)();
19
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
20
+ const {
21
+ lang,
22
+ recording,
23
+ setRecording,
24
+ disabled,
25
+ className,
26
+ onDone,
27
+ onUpdate,
28
+ onError
29
+ } = props;
30
+ const buttonRef = React.useRef(null);
31
+ const recognition = (0, _useLazyRef.default)(() => {
32
+ if (!BrowserSpeechRecognition) {
33
+ return {
34
+ start: () => {},
35
+ abort: () => {}
36
+ };
37
+ }
38
+ const timeout = new _useTimeout.Timeout();
39
+ const instance = new BrowserSpeechRecognition();
40
+ instance.continuous = true;
41
+ instance.interimResults = true;
42
+ instance.lang = lang;
43
+ let finalResult = '';
44
+ let interimResult = '';
45
+ function start(options) {
46
+ if (recording) {
47
+ return;
48
+ }
49
+ setRecording(true);
50
+ instance.onresult = event => {
51
+ finalResult = '';
52
+ interimResult = '';
53
+ if (typeof event.results === 'undefined') {
54
+ instance.stop();
55
+ return;
56
+ }
57
+ for (let i = event.resultIndex; i < event.results.length; i += 1) {
58
+ if (event.results[i].isFinal) {
59
+ finalResult += event.results[i][0].transcript;
60
+ } else {
61
+ interimResult += event.results[i][0].transcript;
62
+ }
63
+ }
64
+ if (finalResult === '') {
65
+ options.onUpdate(interimResult);
66
+ }
67
+ timeout.start(1000, () => instance.stop());
68
+ };
69
+ instance.onsoundend = () => {
70
+ instance.stop();
71
+ };
72
+ instance.onend = () => {
73
+ options.onDone(finalResult);
74
+ setRecording(false);
75
+ };
76
+ instance.onerror = error => {
77
+ options.onError(error.message);
78
+ instance.stop();
79
+ setRecording(false);
80
+ };
81
+ instance.start();
82
+ }
83
+ function abort() {
84
+ instance.abort();
85
+ }
86
+ return {
87
+ start,
88
+ abort
89
+ };
90
+ }).current;
91
+ const handleClick = () => {
92
+ if (!recording) {
93
+ recognition.start({
94
+ onDone,
95
+ onUpdate,
96
+ onError
97
+ });
98
+ return;
99
+ }
100
+ recognition.abort();
101
+ };
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, {
103
+ title: recording ? apiRef.current.getLocaleText('toolbarPromptControlRecordButtonActiveLabel') : apiRef.current.getLocaleText('toolbarPromptControlRecordButtonDefaultLabel'),
104
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
105
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, {
106
+ color: recording ? 'primary' : 'default',
107
+ className: className,
108
+ disabled: disabled,
109
+ onClick: handleClick,
110
+ ref: buttonRef,
111
+ size: "small",
112
+ edge: "start",
113
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.toolbarPromptRecordIcon, {
114
+ fontSize: "small"
115
+ })
116
+ })
117
+ })
118
+ });
119
+ }
@@ -0,0 +1 @@
1
+ export { GridToolbarPromptControl as Unstable_GridToolbarPromptControl } from './GridToolbarPromptControl';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Unstable_GridToolbarPromptControl", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _GridToolbarPromptControl.GridToolbarPromptControl;
10
+ }
11
+ });
12
+ var _GridToolbarPromptControl = require("./GridToolbarPromptControl");
@@ -4,14 +4,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useLicenseVerifier, Watermark } from '@mui/x-license';
7
- import { GridBody, GridFooterPlaceholder, GridHeader, GridRoot, GridContextProvider } from '@mui/x-data-grid-pro';
7
+ import { GridRoot, GridContextProvider } from '@mui/x-data-grid-pro';
8
8
  import { propValidatorsDataGrid, propValidatorsDataGridPro, validateProps } from '@mui/x-data-grid-pro/internals';
9
+ import { forwardRef } from '@mui/x-internals/forwardRef';
9
10
  import { useDataGridPremiumComponent } from "./useDataGridPremiumComponent.js";
10
11
  import { useDataGridPremiumProps } from "./useDataGridPremiumProps.js";
11
12
  import { getReleaseInfo } from "../utils/releaseInfo.js";
12
13
  import { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
13
14
  import { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
15
16
  const configuration = {
16
17
  hooks: {
17
18
  useGridAriaAttributes,
@@ -23,7 +24,7 @@ let dataGridPremiumPropValidators;
23
24
  if (process.env.NODE_ENV !== 'production') {
24
25
  dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
25
26
  }
26
- const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremium(inProps, ref) {
27
+ const DataGridPremiumRaw = forwardRef(function DataGridPremium(inProps, ref) {
27
28
  const props = useDataGridPremiumProps(inProps);
28
29
  const privateApiRef = useDataGridPremiumComponent(props.apiRef, props);
29
30
  useLicenseVerifier('x-data-grid-premium', releaseInfo);
@@ -34,18 +35,16 @@ const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremiu
34
35
  privateApiRef: privateApiRef,
35
36
  configuration: configuration,
36
37
  props: props,
37
- children: /*#__PURE__*/_jsxs(GridRoot, _extends({
38
+ children: /*#__PURE__*/_jsx(GridRoot, _extends({
38
39
  className: props.className,
39
40
  style: props.style,
40
- sx: props.sx,
41
- ref: ref
42
- }, props.forwardedProps, {
43
- children: [/*#__PURE__*/_jsx(GridHeader, {}), /*#__PURE__*/_jsx(GridBody, {
44
- children: /*#__PURE__*/_jsx(Watermark, {
45
- packageName: "x-data-grid-premium",
46
- releaseInfo: releaseInfo
47
- })
48
- }), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
41
+ sx: props.sx
42
+ }, props.slotProps?.root, {
43
+ ref: ref,
44
+ children: /*#__PURE__*/_jsx(Watermark, {
45
+ packageName: "x-data-grid-premium",
46
+ releaseInfo: releaseInfo
47
+ })
49
48
  }))
50
49
  });
51
50
  });
@@ -56,7 +55,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
56
55
  // ----------------------------------------------------------------------
57
56
  /**
58
57
  * Aggregation functions available on the grid.
59
- * @default GRID_AGGREGATION_FUNCTIONS
58
+ * @default GRID_AGGREGATION_FUNCTIONS when `unstable_dataSource` is not provided, `{}` when `unstable_dataSource` is provided
60
59
  */
61
60
  aggregationFunctions: PropTypes.object,
62
61
  /**
@@ -74,7 +73,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
74
73
  * The ref object that allows grid manipulation. Can be instantiated with `useGridApiRef()`.
75
74
  */
76
75
  apiRef: PropTypes.shape({
77
- current: PropTypes.object.isRequired
76
+ current: PropTypes.object
78
77
  }),
79
78
  /**
80
79
  * The label of the Data Grid.
@@ -109,6 +108,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
109
108
  */
110
109
  autosizeOptions: PropTypes.shape({
111
110
  columns: PropTypes.arrayOf(PropTypes.string),
111
+ disableColumnVirtualization: PropTypes.bool,
112
112
  expand: PropTypes.bool,
113
113
  includeHeaders: PropTypes.bool,
114
114
  includeOutliers: PropTypes.bool,
@@ -186,7 +186,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
186
186
  /**
187
187
  * The row ids to show the detail panel.
188
188
  */
189
- detailPanelExpandedRowIds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired),
189
+ detailPanelExpandedRowIds: PropTypes /* @typescript-to-proptypes-ignore */.instanceOf(Set),
190
190
  /**
191
191
  * If `true`, aggregation is disabled.
192
192
  * @default false
@@ -304,7 +304,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
304
304
  * For each feature, if the flag is not explicitly set to `true`, then the feature is fully disabled, and neither property nor method calls will have any effect.
305
305
  */
306
306
  experimentalFeatures: PropTypes.shape({
307
- ariaV8: PropTypes.bool,
308
307
  warnIfFocusStateIsNotSynced: PropTypes.bool
309
308
  }),
310
309
  /**
@@ -333,11 +332,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
333
332
  quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
334
333
  quickFilterValues: PropTypes.array
335
334
  }),
336
- /**
337
- * Forwarded props for the Data Grid root element.
338
- * @ignore - do not document.
339
- */
340
- forwardedProps: PropTypes.object,
341
335
  /**
342
336
  * Determines the position of an aggregated value.
343
337
  * @param {GridGroupNode} groupNode The current group.
@@ -452,14 +446,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
452
446
  clipboardExport: PropTypes.bool,
453
447
  csvExport: PropTypes.bool
454
448
  }), PropTypes.bool]),
455
- /**
456
- * If `select`, a group header checkbox in indeterminate state (like "Select All" checkbox)
457
- * will select all the rows under it.
458
- * If `deselect`, it will deselect all the rows under it.
459
- * Works only if `checkboxSelection` is enabled.
460
- * @default "deselect"
461
- */
462
- indeterminateCheckboxAction: PropTypes.oneOf(['deselect', 'select']),
463
449
  /**
464
450
  * The initial state of the DataGridPremium.
465
451
  * The data in it is set in the state on initialization but isn't controlled.
@@ -927,14 +913,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
927
913
  * Controls the modes of the rows.
928
914
  */
929
915
  rowModesModel: PropTypes.object,
930
- /**
931
- * The milliseconds delay to wait after measuring the row height before recalculating row positions.
932
- * Setting it to a lower value could be useful when using dynamic row height,
933
- * but might reduce performance when displaying a large number of rows.
934
- * @default 166
935
- * @deprecated
936
- */
937
- rowPositionsDebounceMs: PropTypes.number,
938
916
  /**
939
917
  * If `true`, the reordering of rows is enabled.
940
918
  * @default false
@@ -964,7 +942,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
964
942
  * - Deselecting a descendant of a selected parent deselects the parent automatically.
965
943
  *
966
944
  * Works with tree data and row grouping on the client-side only.
967
- * @default { parents: false, descendants: false }
945
+ * @default { parents: true, descendants: true }
968
946
  */
969
947
  rowSelectionPropagation: PropTypes.shape({
970
948
  descendants: PropTypes.bool,
@@ -974,7 +952,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
974
952
  * Loading rows can be processed on the server or client-side.
975
953
  * Set it to 'client' if you would like enable infnite loading.
976
954
  * Set it to 'server' if you would like to enable lazy loading.
977
- * * @default "client"
955
+ * @default "client"
978
956
  */
979
957
  rowsLoadingMode: PropTypes.oneOf(['client', 'server']),
980
958
  /**
@@ -982,12 +960,18 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
982
960
  * @default "margin"
983
961
  */
984
962
  rowSpacingType: PropTypes.oneOf(['border', 'margin']),
963
+ /**
964
+ * If `true`, the Data Grid will auto span the cells over the rows having the same value.
965
+ * @default false
966
+ */
967
+ rowSpanning: PropTypes.bool,
985
968
  /**
986
969
  * Override the height/width of the Data Grid inner scrollbar.
987
970
  */
988
971
  scrollbarSize: PropTypes.number,
989
972
  /**
990
973
  * Set the area in `px` at the bottom of the grid viewport where onRowsScrollEnd is called.
974
+ * If combined with `unstable_lazyLoading`, it defines the area where the next data request is triggered.
991
975
  * @default 80
992
976
  */
993
977
  scrollEndThreshold: PropTypes.number,
@@ -1051,6 +1035,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
1051
1035
  */
1052
1036
  treeData: PropTypes.bool,
1053
1037
  unstable_dataSource: PropTypes.shape({
1038
+ getAggregatedValue: PropTypes.func,
1054
1039
  getChildrenCount: PropTypes.func,
1055
1040
  getGroupKey: PropTypes.func,
1056
1041
  getRows: PropTypes.func.isRequired,
@@ -1061,6 +1046,18 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
1061
1046
  get: PropTypes.func.isRequired,
1062
1047
  set: PropTypes.func.isRequired
1063
1048
  }),
1049
+ /**
1050
+ * Used together with `unstable_dataSource` to enable lazy loading.
1051
+ * If enabled, the grid stops adding `paginationModel` to the data requests (`getRows`)
1052
+ * and starts sending `start` and `end` values depending on the loading mode and the scroll position.
1053
+ * @default false
1054
+ */
1055
+ unstable_lazyLoading: PropTypes.bool,
1056
+ /**
1057
+ * If positive, the Data Grid will throttle data source requests on rendered rows interval change.
1058
+ * @default 500
1059
+ */
1060
+ unstable_lazyLoadingRequestThrottleMs: PropTypes.number,
1064
1061
  /**
1065
1062
  * Definition of the column rendered when the `unstable_listView` prop is enabled.
1066
1063
  */
@@ -1078,10 +1075,13 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
1078
1075
  unstable_listView: PropTypes.bool,
1079
1076
  unstable_onDataSourceError: PropTypes.func,
1080
1077
  /**
1081
- * If `true`, the Data Grid will auto span the cells over the rows having the same value.
1078
+ * If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
1079
+ * By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.
1080
+ * For datasets with a large number of columns, this can cause performance issues.
1081
+ * The downside of enabling this prop is that the row height will be estimated based the cells that are currently rendered, which can cause row height change when scrolling horizontally.
1082
1082
  * @default false
1083
1083
  */
1084
- unstable_rowSpanning: PropTypes.bool
1084
+ virtualizeColumnsWithAutoRowHeight: PropTypes.bool
1085
1085
  } : void 0;
1086
1086
  /**
1087
1087
  * Demos: