@mui/x-data-grid 8.22.0 → 8.23.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 (64) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/colDef/gridBooleanColDef.js +0 -1
  3. package/colDef/gridDateOperators.js +6 -6
  4. package/components/cell/GridBooleanCell.js +9 -1
  5. package/components/cell/GridFooterCell.d.ts +9 -0
  6. package/components/cell/GridFooterCell.js +54 -0
  7. package/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
  8. package/components/containers/GridRootStyles.js +4 -0
  9. package/esm/colDef/gridBooleanColDef.js +0 -1
  10. package/esm/colDef/gridDateOperators.js +6 -6
  11. package/esm/components/cell/GridBooleanCell.js +9 -1
  12. package/esm/components/cell/GridFooterCell.d.ts +9 -0
  13. package/esm/components/cell/GridFooterCell.js +48 -0
  14. package/esm/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
  15. package/esm/components/containers/GridRootStyles.js +4 -0
  16. package/esm/hooks/core/useGridProps.js +2 -1
  17. package/esm/hooks/features/columnResize/gridColumnResizeApi.d.ts +7 -0
  18. package/esm/hooks/features/columnResize/gridColumnResizeApi.js +1 -0
  19. package/esm/hooks/features/columnResize/useGridColumnResize.js +29 -2
  20. package/esm/hooks/features/columns/gridColumnsUtils.js +12 -7
  21. package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +3 -3
  22. package/esm/hooks/features/editing/useGridCellEditing.js +1 -0
  23. package/esm/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
  24. package/esm/hooks/features/pagination/gridPaginationSelector.js +3 -0
  25. package/esm/hooks/features/rowSelection/useGridRowSelection.js +17 -15
  26. package/esm/hooks/features/rowSelection/utils.js +36 -9
  27. package/esm/hooks/features/rows/useGridRowSpanning.js +1 -0
  28. package/esm/index.js +1 -1
  29. package/esm/internals/index.d.ts +2 -0
  30. package/esm/internals/index.js +1 -0
  31. package/esm/locales/ptPT.d.ts +2 -1
  32. package/esm/locales/ptPT.js +114 -125
  33. package/esm/locales/svSE.js +2 -2
  34. package/esm/models/gridAggregation.d.ts +18 -0
  35. package/esm/models/gridAggregation.js +1 -0
  36. package/esm/utils/domUtils.d.ts +1 -0
  37. package/esm/utils/domUtils.js +4 -0
  38. package/esm/utils/utils.d.ts +1 -1
  39. package/esm/utils/utils.js +2 -2
  40. package/hooks/core/useGridProps.js +2 -1
  41. package/hooks/features/columnResize/gridColumnResizeApi.d.ts +7 -0
  42. package/hooks/features/columnResize/gridColumnResizeApi.js +1 -0
  43. package/hooks/features/columnResize/useGridColumnResize.js +28 -1
  44. package/hooks/features/columns/gridColumnsUtils.js +12 -7
  45. package/hooks/features/dataSource/useGridDataSourceBase.d.ts +3 -3
  46. package/hooks/features/editing/useGridCellEditing.js +1 -0
  47. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -1
  48. package/hooks/features/pagination/gridPaginationSelector.js +3 -0
  49. package/hooks/features/rowSelection/useGridRowSelection.js +17 -15
  50. package/hooks/features/rowSelection/utils.js +36 -9
  51. package/hooks/features/rows/useGridRowSpanning.js +1 -0
  52. package/index.js +1 -1
  53. package/internals/index.d.ts +2 -0
  54. package/internals/index.js +8 -0
  55. package/locales/ptPT.d.ts +2 -1
  56. package/locales/ptPT.js +114 -125
  57. package/locales/svSE.js +2 -2
  58. package/models/gridAggregation.d.ts +18 -0
  59. package/models/gridAggregation.js +5 -0
  60. package/package.json +3 -3
  61. package/utils/domUtils.d.ts +1 -0
  62. package/utils/domUtils.js +5 -0
  63. package/utils/utils.d.ts +1 -1
  64. package/utils/utils.js +2 -2
@@ -3,10 +3,9 @@ const ptPTGrid = {
3
3
  // Root
4
4
  noRowsLabel: 'Nenhuma linha',
5
5
  noResultsOverlayLabel: 'Nenhum resultado encontrado.',
6
- // noColumnsOverlayLabel: 'No columns',
7
- // noColumnsOverlayManageColumns: 'Manage columns',
8
- // emptyPivotOverlayLabel: 'Add fields to rows, columns, and values to create a pivot table',
9
-
6
+ noColumnsOverlayLabel: 'Sem colunas',
7
+ noColumnsOverlayManageColumns: 'Gerir colunas',
8
+ emptyPivotOverlayLabel: 'Adicione campos às linhas, colunas e valores para criar uma tabela dinâmica',
10
9
  // Density selector toolbar button text
11
10
  toolbarDensity: 'Densidade',
12
11
  toolbarDensityLabel: 'Densidade',
@@ -33,14 +32,11 @@ const ptPTGrid = {
33
32
  toolbarExportPrint: 'Imprimir',
34
33
  toolbarExportExcel: 'Descarregar como Excel',
35
34
  // Toolbar pivot button
36
- // toolbarPivot: 'Pivot',
37
-
35
+ toolbarPivot: 'Pivot',
38
36
  // Toolbar charts button
39
- // toolbarCharts: 'Charts',
40
-
37
+ toolbarCharts: 'Gráficos',
41
38
  // Toolbar AI Assistant button
42
- // toolbarAssistant: 'AI Assistant',
43
-
39
+ toolbarAssistant: 'Assistente de IA',
44
40
  // Columns management text
45
41
  columnsManagementSearchTitle: 'Procurar',
46
42
  columnsManagementNoColumns: 'Sem colunas',
@@ -99,18 +95,17 @@ const ptPTGrid = {
99
95
  'headerFilterOperator=': 'É igual a',
100
96
  'headerFilterOperator!=': 'Não é igual',
101
97
  'headerFilterOperator>': 'Maior que',
102
- 'headerFilterOperator>=': 'Melhor que ou igual a',
98
+ 'headerFilterOperator>=': 'Maior que ou igual a',
103
99
  'headerFilterOperator<': 'Menor que',
104
- 'headerFilterOperator<=': 'Menos que ou igual a',
105
- // headerFilterClear: 'Clear filter',
106
-
100
+ 'headerFilterOperator<=': 'Menor que ou igual a',
101
+ headerFilterClear: 'Limpar filtro',
107
102
  // Filter values text
108
103
  filterValueAny: 'qualquer',
109
104
  filterValueTrue: 'verdadeiro',
110
105
  filterValueFalse: 'falso',
111
106
  // Column menu text
112
107
  columnMenuLabel: 'Menu',
113
- // columnMenuAriaLabel: (columnName: string) => `${columnName} column menu`,
108
+ columnMenuAriaLabel: columnName => `Menu da coluna ${columnName}`,
114
109
  columnMenuShowColumns: 'Mostrar colunas',
115
110
  columnMenuManageColumns: 'Gerir colunas',
116
111
  columnMenuFilter: 'Filtro',
@@ -118,9 +113,8 @@ const ptPTGrid = {
118
113
  columnMenuUnsort: 'Desclassificar',
119
114
  columnMenuSortAsc: 'Classificar por ordem crescente',
120
115
  columnMenuSortDesc: 'Classificar por ordem decrescente',
121
- // columnMenuManagePivot: 'Manage pivot',
122
- // columnMenuManageCharts: 'Manage charts',
123
-
116
+ columnMenuManagePivot: 'Gerir pivot',
117
+ columnMenuManageCharts: 'Gerir gráficos',
124
118
  // Column header text
125
119
  columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} filtros ativos` : `${count} filtro ativo`,
126
120
  columnHeaderFiltersLabel: 'Mostrar filtros',
@@ -160,18 +154,18 @@ const ptPTGrid = {
160
154
  collapseDetailPanel: 'Colapsar',
161
155
  // Pagination
162
156
  paginationRowsPerPage: 'Linhas por página:',
163
- // paginationDisplayedRows: ({
164
- // from,
165
- // to,
166
- // count,
167
- // estimated
168
- // }) => {
169
- // if (!estimated) {
170
- // return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
171
- // }
172
- // const estimatedLabel = estimated && estimated > to ? `around ${estimated}` : `more than ${to}`;
173
- // return `${from}–${to} of ${count !== -1 ? count : estimatedLabel}`;
174
- // },
157
+ paginationDisplayedRows: ({
158
+ from,
159
+ to,
160
+ count,
161
+ estimated
162
+ }) => {
163
+ if (!estimated) {
164
+ return `${from}–${to} de ${count !== -1 ? count : `mais do que ${to}`}`;
165
+ }
166
+ const estimatedLabel = estimated && estimated > to ? `cerca de ${estimated}` : `mais do que ${to}`;
167
+ return `${from}–${to} de ${count !== -1 ? count : estimatedLabel}`;
168
+ },
175
169
  paginationItemAriaLabel: type => {
176
170
  if (type === 'first') {
177
171
  return 'Primeira página';
@@ -189,114 +183,109 @@ const ptPTGrid = {
189
183
  rowReorderingHeaderName: 'Reordenação de linhas',
190
184
  // Aggregation
191
185
  aggregationMenuItemHeader: 'Agregação',
192
- // aggregationFunctionLabelNone: 'none',
186
+ aggregationFunctionLabelNone: 'nenhuma',
193
187
  aggregationFunctionLabelSum: 'soma',
194
188
  aggregationFunctionLabelAvg: 'média',
195
189
  aggregationFunctionLabelMin: 'min',
196
190
  aggregationFunctionLabelMax: 'máx.',
197
191
  aggregationFunctionLabelSize: 'tamanho',
198
192
  // Pivot panel
199
- // pivotToggleLabel: 'Pivot',
200
- // pivotRows: 'Rows',
201
- // pivotColumns: 'Columns',
202
- // pivotValues: 'Values',
203
- // pivotCloseButton: 'Close pivot settings',
204
- // pivotSearchButton: 'Search fields',
205
- // pivotSearchControlPlaceholder: 'Search fields',
206
- // pivotSearchControlLabel: 'Search fields',
207
- // pivotSearchControlClear: 'Clear search',
208
- // pivotNoFields: 'No fields',
209
- // pivotMenuMoveUp: 'Move up',
210
- // pivotMenuMoveDown: 'Move down',
211
- // pivotMenuMoveToTop: 'Move to top',
212
- // pivotMenuMoveToBottom: 'Move to bottom',
213
- // pivotMenuRows: 'Rows',
214
- // pivotMenuColumns: 'Columns',
215
- // pivotMenuValues: 'Values',
216
- // pivotMenuOptions: 'Field options',
217
- // pivotMenuAddToRows: 'Add to Rows',
218
- // pivotMenuAddToColumns: 'Add to Columns',
219
- // pivotMenuAddToValues: 'Add to Values',
220
- // pivotMenuRemove: 'Remove',
221
- // pivotDragToRows: 'Drag here to create rows',
222
- // pivotDragToColumns: 'Drag here to create columns',
223
- // pivotDragToValues: 'Drag here to create values',
224
- // pivotYearColumnHeaderName: '(Year)',
225
- // pivotQuarterColumnHeaderName: '(Quarter)',
226
-
193
+ pivotToggleLabel: 'Pivot',
194
+ pivotRows: 'Linhas',
195
+ pivotColumns: 'Colunas',
196
+ pivotValues: 'Valores',
197
+ pivotCloseButton: 'Fechar configurações de pivot',
198
+ pivotSearchButton: 'Pesquisar campos',
199
+ pivotSearchControlPlaceholder: 'Pesquisar campos',
200
+ pivotSearchControlLabel: 'Pesquisar campos',
201
+ pivotSearchControlClear: 'Limpar pesquisa',
202
+ pivotNoFields: 'Nenhum campo',
203
+ pivotMenuMoveUp: 'Mover para cima',
204
+ pivotMenuMoveDown: 'Mover para baixo',
205
+ pivotMenuMoveToTop: 'Mover para o topo',
206
+ pivotMenuMoveToBottom: 'Mover para o fundo',
207
+ pivotMenuRows: 'Linhas',
208
+ pivotMenuColumns: 'Colunas',
209
+ pivotMenuValues: 'Valores',
210
+ pivotMenuOptions: 'Opções do campo',
211
+ pivotMenuAddToRows: 'Adicionar às Linhas',
212
+ pivotMenuAddToColumns: 'Adicionar às Colunas',
213
+ pivotMenuAddToValues: 'Adicionar aos Valores',
214
+ pivotMenuRemove: 'Remover',
215
+ pivotDragToRows: 'Arraste para aqui para criar linhas',
216
+ pivotDragToColumns: 'Arraste para aqui para criar colunas',
217
+ pivotDragToValues: 'Arraste para aqui para criar valores',
218
+ pivotYearColumnHeaderName: '(Ano)',
219
+ pivotQuarterColumnHeaderName: '(Trimestre)',
227
220
  // Charts configuration panel
228
- // chartsNoCharts: 'There are no charts available',
229
- // chartsChartNotSelected: 'Select a chart type to configure its options',
230
- // chartsTabChart: 'Chart',
231
- // chartsTabFields: 'Fields',
232
- // chartsTabCustomize: 'Customize',
233
- // chartsCloseButton: 'Close charts configuration',
234
- // chartsSyncButtonLabel: 'Sync chart',
235
- // chartsSearchPlaceholder: 'Search fields',
236
- // chartsSearchLabel: 'Search fields',
237
- // chartsSearchClear: 'Clear search',
238
- // chartsNoFields: 'No fields',
239
- // chartsFieldBlocked: 'This field cannot be added to any section',
240
- // chartsCategories: 'Categories',
241
- // chartsSeries: 'Series',
242
- // chartsMenuAddToDimensions: (dimensionLabel: string) => `Add to ${dimensionLabel}`,
243
- // chartsMenuAddToValues: (valuesLabel: string) => `Add to ${valuesLabel}`,
244
- // chartsMenuMoveUp: 'Move up',
245
- // chartsMenuMoveDown: 'Move down',
246
- // chartsMenuMoveToTop: 'Move to top',
247
- // chartsMenuMoveToBottom: 'Move to bottom',
248
- // chartsMenuOptions: 'Field options',
249
- // chartsMenuRemove: 'Remove',
250
- // chartsDragToDimensions: (dimensionLabel: string) => `Drag here to use column as ${dimensionLabel}`,
251
- // chartsDragToValues: (valuesLabel: string) => `Drag here to use column as ${valuesLabel}`,
252
-
221
+ chartsNoCharts: 'Não gráficos disponíveis',
222
+ chartsChartNotSelected: 'Selecione um tipo de gráfico para configurar as suas opções',
223
+ chartsTabChart: 'Gráfico',
224
+ chartsTabFields: 'Campos',
225
+ chartsTabCustomize: 'Personalizar',
226
+ chartsCloseButton: 'Fechar configuração de gráficos',
227
+ chartsSyncButtonLabel: 'Sincronizar gráfico',
228
+ chartsSearchPlaceholder: 'Pesquisar campos',
229
+ chartsSearchLabel: 'Pesquisar campos',
230
+ chartsSearchClear: 'Limpar pesquisa',
231
+ chartsNoFields: 'Nenhum campo',
232
+ chartsFieldBlocked: 'Este campo não pode ser adicionado a nenhuma secção',
233
+ chartsCategories: 'Categorias',
234
+ chartsSeries: 'Séries',
235
+ chartsMenuAddToDimensions: dimensionLabel => `Adicionar a ${dimensionLabel}`,
236
+ chartsMenuAddToValues: valuesLabel => `Adicionar a ${valuesLabel}`,
237
+ chartsMenuMoveUp: 'Mover para cima',
238
+ chartsMenuMoveDown: 'Mover para baixo',
239
+ chartsMenuMoveToTop: 'Mover para o topo',
240
+ chartsMenuMoveToBottom: 'Mover para o fundo',
241
+ chartsMenuOptions: 'Opções do campo',
242
+ chartsMenuRemove: 'Remover',
243
+ chartsDragToDimensions: dimensionLabel => `Arraste para aqui para usar a coluna como ${dimensionLabel}`,
244
+ chartsDragToValues: valuesLabel => `Arraste para aqui para usar a coluna como ${valuesLabel}`,
253
245
  // AI Assistant panel
254
- // aiAssistantPanelTitle: 'AI Assistant',
255
- // aiAssistantPanelClose: 'Close AI Assistant',
256
- // aiAssistantPanelNewConversation: 'New conversation',
257
- // aiAssistantPanelConversationHistory: 'Conversation history',
258
- // aiAssistantPanelEmptyConversation: 'No prompt history',
259
- // aiAssistantSuggestions: 'Suggestions',
260
-
246
+ aiAssistantPanelTitle: 'Assistente de IA',
247
+ aiAssistantPanelClose: 'Fechar Assistente de IA',
248
+ aiAssistantPanelNewConversation: 'Nova conversa',
249
+ aiAssistantPanelConversationHistory: 'Histórico de conversas',
250
+ aiAssistantPanelEmptyConversation: 'Nenhum histórico de prompts',
251
+ aiAssistantSuggestions: 'Sugestões',
261
252
  // Prompt field
262
253
  promptFieldLabel: 'Prompt',
263
- promptFieldPlaceholder: 'Digite um prompt',
264
- promptFieldPlaceholderWithRecording: 'Digite ou grave um prompt',
265
- promptFieldPlaceholderListening: 'Ouvindo o prompt',
266
- // promptFieldSpeechRecognitionNotSupported: 'Speech recognition is not supported in this browser',
254
+ promptFieldPlaceholder: 'Digite um prompt',
255
+ promptFieldPlaceholderWithRecording: 'Digite ou grave um prompt',
256
+ promptFieldPlaceholderListening: 'Ouvindo o prompt',
257
+ promptFieldSpeechRecognitionNotSupported: 'Reconhecimento de voz não é suportado neste navegador',
267
258
  promptFieldSend: 'Enviar',
268
259
  promptFieldRecord: 'Gravar',
269
- promptFieldStopRecording: 'Parar gravação'
270
-
260
+ promptFieldStopRecording: 'Parar gravação',
271
261
  // Prompt
272
- // promptRerun: 'Run again',
273
- // promptProcessing: 'Processing…',
274
- // promptAppliedChanges: 'Applied changes',
275
-
262
+ promptRerun: 'Executar novamente',
263
+ promptProcessing: 'Processando…',
264
+ promptAppliedChanges: 'Alterações aplicadas',
276
265
  // Prompt changes
277
- // promptChangeGroupDescription: (column: string) => `Group by ${column}`,
278
- // promptChangeAggregationLabel: (column: string, aggregation: string) => `${column} (${aggregation})`,
279
- // promptChangeAggregationDescription: (column: string, aggregation: string) => `Aggregate ${column} (${aggregation})`,
280
- // promptChangeFilterLabel: (column: string, operator: string, value: string) => {
281
- // if (operator === 'is any of') {
282
- // return `${column} is any of: ${value}`;
283
- // }
284
- // return `${column} ${operator} ${value}`;
285
- // },
286
- // promptChangeFilterDescription: (column: string, operator: string, value: string) => {
287
- // if (operator === 'is any of') {
288
- // return `Filter where ${column} is any of: ${value}`;
289
- // }
290
- // return `Filter where ${column} ${operator} ${value}`;
291
- // },
292
- // promptChangeSortDescription: (column: string, direction: string) => `Sort by ${column} (${direction})`,
293
- // promptChangePivotEnableLabel: 'Pivot',
294
- // promptChangePivotEnableDescription: 'Enable pivot',
295
- // promptChangePivotColumnsLabel: (count: number) => `Columns (${count})`,
296
- // promptChangePivotColumnsDescription: (column: string, direction: string) => `${column}${direction ? ` (${direction})` : ''}`,
297
- // promptChangePivotRowsLabel: (count: number) => `Rows (${count})`,
298
- // promptChangePivotValuesLabel: (count: number) => `Values (${count})`,
299
- // promptChangePivotValuesDescription: (column: string, aggregation: string) => `${column} (${aggregation})`,
300
- // promptChangeChartsLabel: (dimensionsCount: number, valuesCount: number) => `Dimensions (${dimensionsCount}), Values (${valuesCount})`,
266
+ promptChangeGroupDescription: column => `Agrupar por ${column}`,
267
+ promptChangeAggregationLabel: (column, aggregation) => `${column} (${aggregation})`,
268
+ promptChangeAggregationDescription: (column, aggregation) => `Agregar ${column} (${aggregation})`,
269
+ promptChangeFilterLabel: (column, operator, value) => {
270
+ if (operator === 'is any of') {
271
+ return `${column} é um de: ${value}`;
272
+ }
273
+ return `${column} ${operator} ${value}`;
274
+ },
275
+ promptChangeFilterDescription: (column, operator, value) => {
276
+ if (operator === 'is any of') {
277
+ return `Filtrar onde ${column} é um de: ${value}`;
278
+ }
279
+ return `Filtrar onde ${column} ${operator} ${value}`;
280
+ },
281
+ promptChangeSortDescription: (column, direction) => `Ordenar por ${column} (${direction})`,
282
+ promptChangePivotEnableLabel: 'Pivot',
283
+ promptChangePivotEnableDescription: 'Ativar pivot',
284
+ promptChangePivotColumnsLabel: count => `Colunas (${count})`,
285
+ promptChangePivotColumnsDescription: (column, direction) => `${column}${direction ? ` (${direction})` : ''}`,
286
+ promptChangePivotRowsLabel: count => `Linhas (${count})`,
287
+ promptChangePivotValuesLabel: count => `Valores (${count})`,
288
+ promptChangePivotValuesDescription: (column, aggregation) => `${column} (${aggregation})`,
289
+ promptChangeChartsLabel: (dimensionsCount, valuesCount) => `Dimensões (${dimensionsCount}), Valores (${valuesCount})`
301
290
  };
302
291
  export const ptPT = getGridLocalization(ptPTGrid);
@@ -3,8 +3,8 @@ const svSEGrid = {
3
3
  // Root
4
4
  noRowsLabel: 'Inga rader',
5
5
  noResultsOverlayLabel: 'Inga resultat funna.',
6
- // noColumnsOverlayLabel: 'No columns',
7
- // noColumnsOverlayManageColumns: 'Manage columns',
6
+ noColumnsOverlayLabel: 'Inga kolumner',
7
+ noColumnsOverlayManageColumns: 'Hantera kolumner',
8
8
  // emptyPivotOverlayLabel: 'Add fields to rows, columns, and values to create a pivot table',
9
9
 
10
10
  // Density selector toolbar button text
@@ -0,0 +1,18 @@
1
+ export type GridAggregationPosition = 'inline' | 'footer';
2
+ export interface GridAggregationCellMeta {
3
+ /**
4
+ * If `true`, the current aggregated value has the same unit as the value of the other cells of this row.
5
+ * For instance, "min" / "max" aggregation have the same unit as the other cells.
6
+ * If `false`, the current aggregated value has another unit or not unit.
7
+ * For instance, "size" aggregation has no unit.
8
+ */
9
+ hasCellUnit: boolean;
10
+ /**
11
+ * Name of the aggregation function currently applied on this cell.
12
+ */
13
+ aggregationFunctionName: string;
14
+ /**
15
+ * Position of the aggregated value.
16
+ */
17
+ position: GridAggregationPosition;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -26,4 +26,5 @@ export declare function findRightPinnedCellsBeforeCol(api: GridPrivateApiCommuni
26
26
  export declare function findLeftPinnedHeadersAfterCol(api: GridPrivateApiCommunity, col: HTMLElement, isRtl: boolean): HTMLElement[];
27
27
  export declare function findRightPinnedHeadersBeforeCol(api: GridPrivateApiCommunity, col: HTMLElement, isRtl: boolean): HTMLElement[];
28
28
  export declare function findGridHeader(api: GridPrivateApiCommunity, field: string): Element | null;
29
+ export declare function findGridHeaderFilter(api: GridPrivateApiCommunity, field: string): Element | null;
29
30
  export declare function findGridCells(api: GridPrivateApiCommunity, field: string): Element[];
@@ -186,6 +186,10 @@ export function findGridHeader(api, field) {
186
186
  const headers = api.columnHeadersContainerRef.current;
187
187
  return headers.querySelector(`:scope > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="columnheader"]`);
188
188
  }
189
+ export function findGridHeaderFilter(api, field) {
190
+ const headers = api.columnHeadersContainerRef.current;
191
+ return headers.querySelector(`:scope > .${gridClasses.headerFilterRow} > [data-field="${escapeOperandAttributeSelector(field)}"]`);
192
+ }
189
193
  export function findGridCells(api, field) {
190
194
  const container = api.virtualScrollerRef.current;
191
195
  return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="gridcell"]`));
@@ -27,4 +27,4 @@ export declare function deepClone(obj: Record<string, any>): any;
27
27
  * that hint disables checks on all values instead of just one.
28
28
  */
29
29
  export declare function eslintUseValue(_: any): void;
30
- export declare const runIf: (condition: boolean, fn: Function) => (params: unknown) => void;
30
+ export declare const runIf: (condition: boolean, fn: Function) => (...params: unknown[]) => void;
@@ -75,8 +75,8 @@ export function deepClone(obj) {
75
75
  * that hint disables checks on all values instead of just one.
76
76
  */
77
77
  export function eslintUseValue(_) {}
78
- export const runIf = (condition, fn) => params => {
78
+ export const runIf = (condition, fn) => (...params) => {
79
79
  if (condition) {
80
- fn(params);
80
+ fn(...params);
81
81
  }
82
82
  };
@@ -14,7 +14,8 @@ const propsStateInitializer = (state, props) => {
14
14
  props: {
15
15
  listView: props.listView,
16
16
  getRowId: props.getRowId,
17
- isCellEditable: props.isCellEditable
17
+ isCellEditable: props.isCellEditable,
18
+ isRowSelectable: props.isRowSelectable
18
19
  }
19
20
  });
20
21
  };
@@ -1,6 +1,7 @@
1
1
  import type { GridColDef } from "../../../models/colDef/gridColDef.js";
2
2
  export declare const DEFAULT_GRID_AUTOSIZE_OPTIONS: {
3
3
  includeHeaders: boolean;
4
+ includeHeaderFilters: boolean;
4
5
  includeOutliers: boolean;
5
6
  outliersFactor: number;
6
7
  expand: boolean;
@@ -16,6 +17,12 @@ export type GridAutosizeOptions = {
16
17
  * @default false
17
18
  */
18
19
  includeHeaders?: boolean;
20
+ /**
21
+ * If true, include header filter widths in the calculation.
22
+ * Only applies when header filters are enabled.
23
+ * @default false
24
+ */
25
+ includeHeaderFilters?: boolean;
19
26
  /**
20
27
  * If true, width outliers will be ignored.
21
28
  * @default false
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.DEFAULT_GRID_AUTOSIZE_OPTIONS = void 0;
7
7
  const DEFAULT_GRID_AUTOSIZE_OPTIONS = exports.DEFAULT_GRID_AUTOSIZE_OPTIONS = {
8
8
  includeHeaders: true,
9
+ includeHeaderFilters: false,
9
10
  includeOutliers: false,
10
11
  outliersFactor: 1.5,
11
12
  expand: false,
@@ -24,6 +24,8 @@ var _useTimeout = require("../../utils/useTimeout");
24
24
  var _gridColumnsInterfaces = require("../columns/gridColumnsInterfaces");
25
25
  var _columns = require("../columns");
26
26
  var _dimensions = require("../dimensions");
27
+ var _headerFiltering = require("../headerFiltering");
28
+ var _columnResizeSelector = require("./columnResizeSelector");
27
29
  function trackFinger(event, currentTouchId) {
28
30
  if (currentTouchId !== undefined && event.changedTouches) {
29
31
  for (let i = 0; i < event.changedTouches.length; i += 1) {
@@ -140,6 +142,7 @@ function extractColumnWidths(apiRef, options, columns) {
140
142
  const widthByField = {};
141
143
  const root = apiRef.current.rootElementRef.current;
142
144
  root.classList.add(_gridClasses.gridClasses.autosizing);
145
+ const includeHeaderFilters = options.includeHeaderFilters && (0, _headerFiltering.gridHeaderFilteringEnabledSelector)(apiRef);
143
146
  columns.forEach(column => {
144
147
  const cells = (0, _domUtils.findGridCells)(apiRef.current, column.field);
145
148
  const widths = cells.map(cell => {
@@ -170,6 +173,16 @@ function extractColumnWidths(apiRef, options, columns) {
170
173
  filteredWidths.push(width);
171
174
  }
172
175
  }
176
+ if (includeHeaderFilters) {
177
+ const headerFilter = (0, _domUtils.findGridHeaderFilter)(apiRef.current, column.field);
178
+ if (headerFilter) {
179
+ const style = window.getComputedStyle(headerFilter, null);
180
+ const paddingWidth = parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
181
+ const contentWidth = headerFilter.scrollWidth;
182
+ const width = contentWidth + paddingWidth;
183
+ filteredWidths.push(width);
184
+ }
185
+ }
173
186
  const hasColumnMin = column.minWidth !== -Infinity && column.minWidth !== undefined;
174
187
  const hasColumnMax = column.maxWidth !== Infinity && column.maxWidth !== undefined;
175
188
  const min = hasColumnMin ? column.minWidth : 0;
@@ -328,6 +341,11 @@ const useGridColumnResize = (apiRef, props) => {
328
341
  apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
329
342
  });
330
343
  };
344
+ const setCellElementsRef = () => {
345
+ if (refs.columnHeaderElement) {
346
+ refs.cellElements = (0, _domUtils.findGridCellElementsFromCol)(refs.columnHeaderElement, apiRef.current);
347
+ }
348
+ };
331
349
  const storeReferences = (colDef, separator, xStart) => {
332
350
  const root = apiRef.current.rootElementRef.current;
333
351
  refs.initialColWidth = colDef.computedWidth;
@@ -339,7 +357,7 @@ const useGridColumnResize = (apiRef, props) => {
339
357
  refs.headerFilterElement = headerFilterElement;
340
358
  }
341
359
  refs.groupHeaderElements = (0, _domUtils.findGroupHeaderElementsFromField)(apiRef.current.columnHeadersContainerRef?.current, colDef.field);
342
- refs.cellElements = (0, _domUtils.findGridCellElementsFromCol)(refs.columnHeaderElement, apiRef.current);
360
+ setCellElementsRef();
343
361
  refs.fillerLeft = (0, _domUtils.findGridElement)(apiRef.current, isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft');
344
362
  refs.fillerRight = (0, _domUtils.findGridElement)(apiRef.current, isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight');
345
363
  const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
@@ -586,6 +604,15 @@ const useGridColumnResize = (apiRef, props) => {
586
604
  (0, _utils.useGridEvent)(apiRef, 'columnResizeStart', handleResizeStart);
587
605
  (0, _utils.useGridEvent)(apiRef, 'columnSeparatorMouseDown', handleColumnResizeMouseDown);
588
606
  (0, _utils.useGridEvent)(apiRef, 'columnSeparatorDoubleClick', handleColumnSeparatorDoubleClick);
607
+ (0, _utils.useGridEvent)(apiRef, 'rowsSet', () => {
608
+ // if the user is still resizing the column, update the cell references included in the resize action
609
+ if ((0, _columnResizeSelector.gridResizingColumnFieldSelector)(apiRef) !== '') {
610
+ // wait until the rows are in the DOM
611
+ requestAnimationFrame(() => {
612
+ setCellElementsRef();
613
+ });
614
+ }
615
+ });
589
616
  (0, _utils.useGridEventPriority)(apiRef, 'columnResize', props.onColumnResize);
590
617
  (0, _utils.useGridEventPriority)(apiRef, 'columnWidthChange', props.onColumnWidthChange);
591
618
  };
@@ -251,8 +251,7 @@ const createColumnsState = ({
251
251
  const currentState = (0, _gridColumnsSelector.gridColumnsStateSelector)(apiRef);
252
252
  columnsState = {
253
253
  orderedFields: keepOnlyColumnsToUpsert ? [] : [...currentState.orderedFields],
254
- lookup: (0, _extends2.default)({}, currentState.lookup),
255
- // Will be cleaned later if keepOnlyColumnsToUpsert=true
254
+ lookup: keepOnlyColumnsToUpsert ? {} : (0, _extends2.default)({}, currentState.lookup),
256
255
  columnVisibilityModel,
257
256
  initialColumnVisibilityModel: updateInitialVisibilityModel ? columnVisibilityModel : currentState.initialColumnVisibilityModel
258
257
  };
@@ -265,12 +264,10 @@ const createColumnsState = ({
265
264
  }
266
265
  }
267
266
  }
268
- const columnsToUpsertLookup = {};
269
267
  columnsToUpsert.forEach(newColumn => {
270
268
  const {
271
269
  field
272
270
  } = newColumn;
273
- columnsToUpsertLookup[field] = true;
274
271
  columnsToKeep[field] = true;
275
272
  let existingState = columnsState.lookup[field];
276
273
  if (existingState == null) {
@@ -298,9 +295,17 @@ const createColumnsState = ({
298
295
  }
299
296
  }
300
297
  });
301
- columnsState.lookup[field] = (0, _resolveProps.default)(existingState, (0, _extends2.default)({}, getDefaultColTypeDef(newColumn.type), newColumn, {
302
- hasBeenResized
303
- }));
298
+ const mergedProps = (0, _extends2.default)({}, getDefaultColTypeDef(newColumn.type), {
299
+ hasBeenResized,
300
+ field
301
+ });
302
+ let key;
303
+ for (key in newColumn) {
304
+ if (newColumn[key] !== undefined && key !== 'field') {
305
+ mergedProps[key] = newColumn[key];
306
+ }
307
+ }
308
+ columnsState.lookup[field] = (0, _resolveProps.default)(existingState, mergedProps);
304
309
  });
305
310
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
306
311
  Object.keys(columnsState.lookup).forEach(field => {
@@ -21,8 +21,8 @@ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity
21
21
  cache: GridDataSourceCache;
22
22
  events: {
23
23
  strategyAvailabilityChange: GridEventListener<"strategyAvailabilityChange">;
24
- sortModelChange: (params: unknown) => void;
25
- filterModelChange: (params: unknown) => void;
26
- paginationModelChange: (params: unknown) => void;
24
+ sortModelChange: (...params: unknown[]) => void;
25
+ filterModelChange: (...params: unknown[]) => void;
26
+ paginationModelChange: (...params: unknown[]) => void;
27
27
  };
28
28
  };
@@ -114,6 +114,7 @@ const useGridCellEditing = (apiRef, props) => {
114
114
  reason = _gridEditCellParams.GridCellEditStartReasons.pasteKeyDown;
115
115
  } else if (event.key === 'Enter') {
116
116
  reason = _gridEditCellParams.GridCellEditStartReasons.enterKeyDown;
117
+ event.preventDefault();
117
118
  } else if (event.key === 'Backspace' || event.key === 'Delete') {
118
119
  reason = _gridEditCellParams.GridCellEditStartReasons.deleteKeyDown;
119
120
  }
@@ -113,7 +113,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
113
113
  // There is one exception for the checkBoxHeader
114
114
  return;
115
115
  }
116
- if (!(0, _keyboardUtils.isNavigationKey)(event.key) && event.key !== 'Tab') {
116
+ if (!(0, _keyboardUtils.isNavigationKey)(event.key) && event.key !== 'Tab' && event.key !== 'Enter') {
117
117
  return;
118
118
  }
119
119
 
@@ -66,6 +66,9 @@ const gridPaginationRowRangeSelector = exports.gridPaginationRowRangeSelector =
66
66
  if (!clientSidePaginationEnabled) {
67
67
  return null;
68
68
  }
69
+ if (!visibleSortedRowEntries || visibleSortedRowEntries.length === 0) {
70
+ return null;
71
+ }
69
72
  const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
70
73
  const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
71
74
  const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);