@mui/x-data-grid 8.13.0 → 8.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +171 -1
- package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +3 -2
- package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +34 -0
- package/esm/hooks/features/columnGrouping/useGridColumnGrouping.js +1 -34
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +7 -5
- package/esm/hooks/features/dataSource/utils.js +2 -4
- package/esm/hooks/features/rows/useGridRows.js +4 -4
- package/esm/index.js +1 -1
- package/esm/locales/ptBR.js +117 -128
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +3 -2
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +37 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +3 -36
- package/hooks/features/dataSource/useGridDataSourceBase.js +7 -5
- package/hooks/features/dataSource/utils.js +2 -4
- package/hooks/features/rows/useGridRows.js +4 -4
- package/index.js +1 -1
- package/locales/ptBR.js +117 -128
- package/package.json +5 -5
package/esm/locales/ptBR.js
CHANGED
|
@@ -3,10 +3,9 @@ const ptBRGrid = {
|
|
|
3
3
|
// Root
|
|
4
4
|
noRowsLabel: 'Nenhuma linha',
|
|
5
5
|
noResultsOverlayLabel: 'Nenhum resultado encontrado.',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
noColumnsOverlayLabel: 'Nenhuma coluna',
|
|
7
|
+
noColumnsOverlayManageColumns: 'Gerenciar colunas',
|
|
8
|
+
emptyPivotOverlayLabel: 'Adicionar 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',
|
|
@@ -21,7 +20,7 @@ const ptBRGrid = {
|
|
|
21
20
|
toolbarFiltersLabel: 'Exibir filtros',
|
|
22
21
|
toolbarFiltersTooltipHide: 'Ocultar filtros',
|
|
23
22
|
toolbarFiltersTooltipShow: 'Exibir filtros',
|
|
24
|
-
toolbarFiltersTooltipActive: count =>
|
|
23
|
+
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} filtros ativos` : `${count} filtro ativo`,
|
|
25
24
|
// Quick filter toolbar field
|
|
26
25
|
toolbarQuickFilterPlaceholder: 'Procurar…',
|
|
27
26
|
toolbarQuickFilterLabel: 'Procurar',
|
|
@@ -33,14 +32,11 @@ const ptBRGrid = {
|
|
|
33
32
|
toolbarExportPrint: 'Imprimir',
|
|
34
33
|
toolbarExportExcel: 'Baixar como Excel',
|
|
35
34
|
// Toolbar pivot button
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
toolbarPivot: 'Pivotar',
|
|
38
36
|
// Toolbar charts button
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
toolbarCharts: 'Gráficos',
|
|
41
38
|
// Toolbar AI Assistant button
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
toolbarAssistant: 'Assistente de IA',
|
|
44
40
|
// Columns management text
|
|
45
41
|
columnsManagementSearchTitle: 'Buscar',
|
|
46
42
|
columnsManagementNoColumns: 'Nenhuma coluna',
|
|
@@ -102,28 +98,26 @@ const ptBRGrid = {
|
|
|
102
98
|
'headerFilterOperator>=': 'Maior que ou igual a',
|
|
103
99
|
'headerFilterOperator<': 'Menor que',
|
|
104
100
|
'headerFilterOperator<=': 'Menor que ou igual a',
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
108
|
+
columnMenuAriaLabel: columnName => `menu da coluna ${columnName}`,
|
|
114
109
|
columnMenuShowColumns: 'Exibir colunas',
|
|
115
110
|
columnMenuManageColumns: 'Gerir colunas',
|
|
116
111
|
columnMenuFilter: 'Filtrar',
|
|
117
|
-
columnMenuHideColumn: 'Ocultar',
|
|
112
|
+
columnMenuHideColumn: 'Ocultar coluna',
|
|
118
113
|
columnMenuUnsort: 'Desfazer ordenação',
|
|
119
114
|
columnMenuSortAsc: 'Ordenar do menor para o maior',
|
|
120
115
|
columnMenuSortDesc: 'Ordenar do maior para o menor',
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
columnMenuManagePivot: 'Gerenciar pivot',
|
|
117
|
+
columnMenuManageCharts: 'Gerenciar gráficos',
|
|
124
118
|
// Column header text
|
|
125
|
-
columnHeaderFiltersTooltipActive: count =>
|
|
126
|
-
columnHeaderFiltersLabel: 'Exibir
|
|
119
|
+
columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} filtros ativos` : `${count} filtro ativo`,
|
|
120
|
+
columnHeaderFiltersLabel: 'Exibir filtros',
|
|
127
121
|
columnHeaderSortIconLabel: 'Ordenar',
|
|
128
122
|
// Rows selected footer text
|
|
129
123
|
footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} linhas selecionadas` : `${count.toLocaleString()} linha selecionada`,
|
|
@@ -132,9 +126,9 @@ const ptBRGrid = {
|
|
|
132
126
|
// Total visible row amount footer text
|
|
133
127
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} de ${totalCount.toLocaleString()}`,
|
|
134
128
|
// Checkbox selection text
|
|
135
|
-
checkboxSelectionHeaderName: '
|
|
136
|
-
checkboxSelectionSelectAllRows: 'Selecionar todas linhas',
|
|
137
|
-
checkboxSelectionUnselectAllRows: 'Deselecionar todas linhas',
|
|
129
|
+
checkboxSelectionHeaderName: 'Caixa de seleção',
|
|
130
|
+
checkboxSelectionSelectAllRows: 'Selecionar todas as linhas',
|
|
131
|
+
checkboxSelectionUnselectAllRows: 'Deselecionar todas as linhas',
|
|
138
132
|
checkboxSelectionSelectRow: 'Selecionar linha',
|
|
139
133
|
checkboxSelectionUnselectRow: 'Deselecionar linha',
|
|
140
134
|
// Boolean cell text
|
|
@@ -149,7 +143,7 @@ const ptBRGrid = {
|
|
|
149
143
|
// Tree Data
|
|
150
144
|
treeDataGroupingHeaderName: 'Grupo',
|
|
151
145
|
treeDataExpand: 'mostrar filhos',
|
|
152
|
-
treeDataCollapse: '
|
|
146
|
+
treeDataCollapse: 'ocultar filhos',
|
|
153
147
|
// Grouping columns
|
|
154
148
|
groupingColumnHeaderName: 'Grupo',
|
|
155
149
|
groupColumn: name => `Agrupar por ${name}`,
|
|
@@ -157,21 +151,21 @@ const ptBRGrid = {
|
|
|
157
151
|
// Master/detail
|
|
158
152
|
detailPanelToggle: 'Painel de detalhes',
|
|
159
153
|
expandDetailPanel: 'Expandir',
|
|
160
|
-
collapseDetailPanel: '
|
|
154
|
+
collapseDetailPanel: 'Recolher',
|
|
161
155
|
// Pagination
|
|
162
156
|
paginationRowsPerPage: 'Linhas por página:',
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
157
|
+
paginationDisplayedRows: ({
|
|
158
|
+
from,
|
|
159
|
+
to,
|
|
160
|
+
count,
|
|
161
|
+
estimated
|
|
162
|
+
}) => {
|
|
163
|
+
if (!estimated) {
|
|
164
|
+
return `${from}–${to} de ${count !== -1 ? count : `mais de ${to}`}`;
|
|
165
|
+
}
|
|
166
|
+
const estimatedLabel = estimated && estimated > to ? `cerca de ${estimated}` : `mais de ${to}`;
|
|
167
|
+
return `${from}–${to} de ${count !== -1 ? count : estimatedLabel}`;
|
|
168
|
+
},
|
|
175
169
|
paginationItemAriaLabel: type => {
|
|
176
170
|
if (type === 'first') {
|
|
177
171
|
return 'Ir para a primeira página';
|
|
@@ -189,113 +183,108 @@ const ptBRGrid = {
|
|
|
189
183
|
rowReorderingHeaderName: 'Reorganizar linhas',
|
|
190
184
|
// Aggregation
|
|
191
185
|
aggregationMenuItemHeader: 'Agrupar',
|
|
192
|
-
|
|
186
|
+
aggregationFunctionLabelNone: 'nenhum',
|
|
193
187
|
aggregationFunctionLabelSum: 'soma',
|
|
194
188
|
aggregationFunctionLabelAvg: 'média',
|
|
195
189
|
aggregationFunctionLabelMin: 'mín',
|
|
196
190
|
aggregationFunctionLabelMax: 'máx',
|
|
197
191
|
aggregationFunctionLabelSize: 'tamanho',
|
|
198
192
|
// Pivot panel
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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 a parte inferior',
|
|
207
|
+
pivotMenuRows: 'Linhas',
|
|
208
|
+
pivotMenuColumns: 'Colunas',
|
|
209
|
+
pivotMenuValues: 'Valores',
|
|
210
|
+
pivotMenuOptions: 'Opções de campo',
|
|
211
|
+
pivotMenuAddToRows: 'Adicionar às Linhas',
|
|
212
|
+
pivotMenuAddToColumns: 'Adicionar às Colunas',
|
|
213
|
+
pivotMenuAddToValues: 'Adicionar aos Valores',
|
|
214
|
+
pivotMenuRemove: 'Remover',
|
|
215
|
+
pivotDragToRows: 'Arraste aqui para criar linhas',
|
|
216
|
+
pivotDragToColumns: 'Arraste aqui para criar colunas',
|
|
217
|
+
pivotDragToValues: 'Arraste aqui para criar valores',
|
|
218
|
+
pivotYearColumnHeaderName: '(Ano)',
|
|
219
|
+
pivotQuarterColumnHeaderName: '(Trimestre)',
|
|
227
220
|
// Charts configuration panel
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
221
|
+
chartsNoCharts: 'Não há gráficos disponíveis',
|
|
222
|
+
chartsChartNotSelected: 'Selecione um tipo de gráfico para configurar 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 seçã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 a parte inferior',
|
|
241
|
+
chartsMenuOptions: 'Opções de campo',
|
|
242
|
+
chartsMenuRemove: 'Remover',
|
|
243
|
+
chartsDragToDimensions: dimensionLabel => `Arraste aqui para usar a coluna como ${dimensionLabel}`,
|
|
244
|
+
chartsDragToValues: valuesLabel => `Arraste aqui para usar a coluna como ${valuesLabel}`,
|
|
253
245
|
// AI Assistant panel
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
246
|
+
aiAssistantPanelTitle: 'Assistente de IA',
|
|
247
|
+
aiAssistantPanelClose: 'Fechar Assistente de IA',
|
|
248
|
+
aiAssistantPanelNewConversation: 'Nova conversa',
|
|
249
|
+
aiAssistantPanelConversationHistory: 'Histórico de conversas',
|
|
250
|
+
aiAssistantPanelEmptyConversation: 'Sem histórico de prompts',
|
|
251
|
+
aiAssistantSuggestions: 'Sugestões',
|
|
261
252
|
// Prompt field
|
|
262
253
|
promptFieldLabel: 'Prompt',
|
|
263
254
|
promptFieldPlaceholder: 'Digite um prompt…',
|
|
264
255
|
promptFieldPlaceholderWithRecording: 'Digite ou grave um prompt…',
|
|
265
256
|
promptFieldPlaceholderListening: 'Ouvindo o prompt…',
|
|
266
|
-
|
|
257
|
+
promptFieldSpeechRecognitionNotSupported: 'O reconhecimento de fala 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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
262
|
+
promptRerun: 'Executar novamente',
|
|
263
|
+
promptProcessing: 'Processando…',
|
|
264
|
+
promptAppliedChanges: 'Alterações aplicadas',
|
|
276
265
|
// Prompt changes
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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 destes: ${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 destes: ${value}`;
|
|
278
|
+
}
|
|
279
|
+
return `Filtrar onde ${column} ${operator} ${value}`;
|
|
280
|
+
},
|
|
281
|
+
promptChangeSortDescription: (column, direction) => `Classificar por ${column} (${direction})`,
|
|
282
|
+
promptChangePivotEnableLabel: 'Pivotar',
|
|
283
|
+
promptChangePivotEnableDescription: 'Ativar pivotar',
|
|
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})`
|
|
300
289
|
};
|
|
301
290
|
export const ptBR = getGridLocalization(ptBRGrid);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { GridColumnGroupingModel, GridColumnGroup } from "../../../models/gridColumnGrouping.js";
|
|
1
|
+
import { GridColumnGroupingModel, GridColumnNode, GridColumnGroup } from "../../../models/gridColumnGrouping.js";
|
|
2
2
|
import { GridColDef } from "../../../models/colDef/index.js";
|
|
3
|
-
import { GridGroupingStructure } from "./gridColumnGroupsInterfaces.js";
|
|
3
|
+
import { GridColumnGroupLookup, GridGroupingStructure } from "./gridColumnGroupsInterfaces.js";
|
|
4
4
|
type UnwrappedGroupingModel = {
|
|
5
5
|
[key: GridColDef['field']]: GridColumnGroup['groupId'][];
|
|
6
6
|
};
|
|
7
|
+
export declare const createGroupLookup: (columnGroupingModel: GridColumnNode[]) => GridColumnGroupLookup;
|
|
7
8
|
/**
|
|
8
9
|
* This is a function that provide for each column the array of its parents.
|
|
9
10
|
* Parents are ordered from the root to the leaf.
|
|
@@ -1,11 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.unwrapGroupingColumnModel = exports.getColumnGroupsHeaderStructure = void 0;
|
|
7
|
+
exports.unwrapGroupingColumnModel = exports.getColumnGroupsHeaderStructure = exports.createGroupLookup = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
7
10
|
var _gridColumnGrouping = require("../../../models/gridColumnGrouping");
|
|
11
|
+
const _excluded = ["groupId", "children"];
|
|
12
|
+
const createGroupLookup = columnGroupingModel => {
|
|
13
|
+
const groupLookup = {};
|
|
14
|
+
for (let i = 0; i < columnGroupingModel.length; i += 1) {
|
|
15
|
+
const node = columnGroupingModel[i];
|
|
16
|
+
if ((0, _gridColumnGrouping.isLeaf)(node)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
groupId,
|
|
21
|
+
children
|
|
22
|
+
} = node,
|
|
23
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(node, _excluded);
|
|
24
|
+
if (!groupId) {
|
|
25
|
+
throw new Error('MUI X: An element of the columnGroupingModel does not have either `field` or `groupId`.');
|
|
26
|
+
}
|
|
27
|
+
if (process.env.NODE_ENV !== 'production' && !children) {
|
|
28
|
+
console.warn(`MUI X: group groupId=${groupId} has no children.`);
|
|
29
|
+
}
|
|
30
|
+
const groupParam = (0, _extends2.default)({}, other, {
|
|
31
|
+
groupId
|
|
32
|
+
});
|
|
33
|
+
const subTreeLookup = createGroupLookup(children);
|
|
34
|
+
if (subTreeLookup[groupId] !== undefined || groupLookup[groupId] !== undefined) {
|
|
35
|
+
throw new Error(`MUI X: The groupId ${groupId} is used multiple times in the columnGroupingModel.`);
|
|
36
|
+
}
|
|
37
|
+
Object.assign(groupLookup, subTreeLookup);
|
|
38
|
+
groupLookup[groupId] = groupParam;
|
|
39
|
+
}
|
|
40
|
+
return groupLookup;
|
|
41
|
+
};
|
|
42
|
+
|
|
8
43
|
// This is the recurrence function that help writing `unwrapGroupingColumnModel()`
|
|
44
|
+
exports.createGroupLookup = createGroupLookup;
|
|
9
45
|
const recurrentUnwrapGroupingColumnModel = (columnGroupNode, parents, unwrappedGroupingModelToComplete) => {
|
|
10
46
|
if ((0, _gridColumnGrouping.isLeaf)(columnGroupNode)) {
|
|
11
47
|
if (unwrappedGroupingModelToComplete[columnGroupNode.field] !== undefined) {
|
|
@@ -1,52 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.useGridColumnGrouping = exports.columnGroupsStateInitializer = void 0;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
11
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _gridColumnGrouping = require("../../../models/gridColumnGrouping");
|
|
14
12
|
var _gridColumnGroupsSelector = require("./gridColumnGroupsSelector");
|
|
15
13
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
16
14
|
var _gridColumnGroupsUtils = require("./gridColumnGroupsUtils");
|
|
17
15
|
var _useGridEvent = require("../../utils/useGridEvent");
|
|
18
16
|
var _columns = require("../columns");
|
|
19
|
-
const _excluded = ["groupId", "children"];
|
|
20
|
-
const createGroupLookup = columnGroupingModel => {
|
|
21
|
-
const groupLookup = {};
|
|
22
|
-
for (let i = 0; i < columnGroupingModel.length; i += 1) {
|
|
23
|
-
const node = columnGroupingModel[i];
|
|
24
|
-
if ((0, _gridColumnGrouping.isLeaf)(node)) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const {
|
|
28
|
-
groupId,
|
|
29
|
-
children
|
|
30
|
-
} = node,
|
|
31
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(node, _excluded);
|
|
32
|
-
if (!groupId) {
|
|
33
|
-
throw new Error('MUI X: An element of the columnGroupingModel does not have either `field` or `groupId`.');
|
|
34
|
-
}
|
|
35
|
-
if (process.env.NODE_ENV !== 'production' && !children) {
|
|
36
|
-
console.warn(`MUI X: group groupId=${groupId} has no children.`);
|
|
37
|
-
}
|
|
38
|
-
const groupParam = (0, _extends2.default)({}, other, {
|
|
39
|
-
groupId
|
|
40
|
-
});
|
|
41
|
-
const subTreeLookup = createGroupLookup(children);
|
|
42
|
-
if (subTreeLookup[groupId] !== undefined || groupLookup[groupId] !== undefined) {
|
|
43
|
-
throw new Error(`MUI X: The groupId ${groupId} is used multiple times in the columnGroupingModel.`);
|
|
44
|
-
}
|
|
45
|
-
Object.assign(groupLookup, subTreeLookup);
|
|
46
|
-
groupLookup[groupId] = groupParam;
|
|
47
|
-
}
|
|
48
|
-
return groupLookup;
|
|
49
|
-
};
|
|
50
17
|
const columnGroupsStateInitializer = (state, props, apiRef) => {
|
|
51
18
|
apiRef.current.caches.columnGrouping = {
|
|
52
19
|
lastColumnGroupingModel: props.columnGroupingModel
|
|
@@ -56,7 +23,7 @@ const columnGroupsStateInitializer = (state, props, apiRef) => {
|
|
|
56
23
|
}
|
|
57
24
|
const columnFields = (0, _columns.gridColumnFieldsSelector)(apiRef);
|
|
58
25
|
const visibleColumnFields = (0, _columns.gridVisibleColumnFieldsSelector)(apiRef);
|
|
59
|
-
const groupLookup = createGroupLookup(props.columnGroupingModel ?? []);
|
|
26
|
+
const groupLookup = (0, _gridColumnGroupsUtils.createGroupLookup)(props.columnGroupingModel ?? []);
|
|
60
27
|
const unwrappedGroupingModel = (0, _gridColumnGroupsUtils.unwrapGroupingColumnModel)(props.columnGroupingModel ?? []);
|
|
61
28
|
const columnGroupsHeaderStructure = (0, _gridColumnGroupsUtils.getColumnGroupsHeaderStructure)(columnFields, unwrappedGroupingModel, apiRef.current.state.pinnedColumns ?? {});
|
|
62
29
|
const maxDepth = visibleColumnFields.length === 0 ? 0 : Math.max(...visibleColumnFields.map(field => unwrappedGroupingModel[field]?.length ?? 0));
|
|
@@ -111,7 +78,7 @@ const useGridColumnGrouping = (apiRef, props) => {
|
|
|
111
78
|
const pinnedColumns = apiRef.current.getPinnedColumns?.() ?? {};
|
|
112
79
|
const columnFields = (0, _columns.gridColumnFieldsSelector)(apiRef);
|
|
113
80
|
const visibleColumnFields = (0, _columns.gridVisibleColumnFieldsSelector)(apiRef);
|
|
114
|
-
const groupLookup = createGroupLookup(columnGroupingModel ?? []);
|
|
81
|
+
const groupLookup = (0, _gridColumnGroupsUtils.createGroupLookup)(columnGroupingModel ?? []);
|
|
115
82
|
const unwrappedGroupingModel = (0, _gridColumnGroupsUtils.unwrapGroupingColumnModel)(columnGroupingModel ?? []);
|
|
116
83
|
const columnGroupsHeaderStructure = (0, _gridColumnGroupsUtils.getColumnGroupsHeaderStructure)(columnFields, unwrappedGroupingModel, pinnedColumns);
|
|
117
84
|
const maxDepth = visibleColumnFields.length === 0 ? 0 : Math.max(...visibleColumnFields.map(field => unwrappedGroupingModel[field]?.length ?? 0));
|
|
@@ -39,7 +39,10 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
39
39
|
const setStrategyAvailability = React.useCallback(() => {
|
|
40
40
|
apiRef.current.setStrategyAvailability(_strategyProcessing.GridStrategyGroup.DataSource, _utils2.DataSourceRowsUpdateStrategy.Default, props.dataSource ? () => true : () => false);
|
|
41
41
|
}, [apiRef, props.dataSource]);
|
|
42
|
-
const [
|
|
42
|
+
const [currentStrategy, setCurrentStrategy] = React.useState(apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.DataSource));
|
|
43
|
+
const defaultRowsUpdateStrategyActive = React.useMemo(() => {
|
|
44
|
+
return currentStrategy === _utils2.DataSourceRowsUpdateStrategy.Default;
|
|
45
|
+
}, [currentStrategy]);
|
|
43
46
|
const paginationModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationModelSelector);
|
|
44
47
|
const lastRequestId = React.useRef(0);
|
|
45
48
|
const onDataSourceErrorProp = props.onDataSourceError;
|
|
@@ -117,7 +120,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
117
120
|
}
|
|
118
121
|
}, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.dataSource?.getRows, onDataSourceErrorProp, options, props.signature]);
|
|
119
122
|
const handleStrategyActivityChange = React.useCallback(() => {
|
|
120
|
-
|
|
123
|
+
setCurrentStrategy(apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.DataSource));
|
|
121
124
|
}, [apiRef]);
|
|
122
125
|
const handleDataUpdate = React.useCallback(params => {
|
|
123
126
|
if ('error' in params) {
|
|
@@ -190,8 +193,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
190
193
|
React.useEffect(() => {
|
|
191
194
|
// Return early if the proper strategy isn't set yet
|
|
192
195
|
// Context: https://github.com/mui/mui-x/issues/19650
|
|
193
|
-
|
|
194
|
-
if (strategy !== _utils2.DataSourceRowsUpdateStrategy.Default && strategy !== _utils2.DataSourceRowsUpdateStrategy.LazyLoading) {
|
|
196
|
+
if (currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.Default && currentStrategy !== _utils2.DataSourceRowsUpdateStrategy.LazyLoading) {
|
|
195
197
|
return undefined;
|
|
196
198
|
}
|
|
197
199
|
if (props.dataSource) {
|
|
@@ -202,7 +204,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
202
204
|
// ignore the current request on unmount
|
|
203
205
|
lastRequestId.current += 1;
|
|
204
206
|
};
|
|
205
|
-
}, [apiRef, props.dataSource]);
|
|
207
|
+
}, [apiRef, props.dataSource, currentStrategy]);
|
|
206
208
|
return {
|
|
207
209
|
api: {
|
|
208
210
|
public: dataSourceApi
|
|
@@ -66,10 +66,8 @@ class CacheChunkManager {
|
|
|
66
66
|
if (responses.length === 1) {
|
|
67
67
|
return responses[0];
|
|
68
68
|
}
|
|
69
|
-
return responses.reduce((acc, response) => ({
|
|
70
|
-
rows: [...acc.rows, ...response.rows]
|
|
71
|
-
rowCount: response.rowCount,
|
|
72
|
-
pageInfo: response.pageInfo
|
|
69
|
+
return responses.reduce((acc, response) => (0, _extends2.default)({}, response, {
|
|
70
|
+
rows: [...acc.rows, ...response.rows]
|
|
73
71
|
}), {
|
|
74
72
|
rows: [],
|
|
75
73
|
rowCount: 0,
|
|
@@ -113,7 +113,7 @@ const useGridRows = (apiRef, props, configuration) => {
|
|
|
113
113
|
*/
|
|
114
114
|
const setRows = React.useCallback(rows => {
|
|
115
115
|
logger.debug(`Updating all rows, new length ${rows.length}`);
|
|
116
|
-
if ((0, _pivoting.gridPivotActiveSelector)(apiRef)) {
|
|
116
|
+
if (!props.dataSource && (0, _pivoting.gridPivotActiveSelector)(apiRef)) {
|
|
117
117
|
apiRef.current.updateNonPivotRows(rows, false);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
@@ -129,12 +129,12 @@ const useGridRows = (apiRef, props, configuration) => {
|
|
|
129
129
|
cache,
|
|
130
130
|
throttle: true
|
|
131
131
|
});
|
|
132
|
-
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
|
|
132
|
+
}, [logger, props.getRowId, props.dataSource, props.loading, props.rowCount, throttledRowsChange, apiRef]);
|
|
133
133
|
const updateRows = React.useCallback(updates => {
|
|
134
134
|
if (props.signature === _signature.GridSignature.DataGrid && updates.length > 1) {
|
|
135
135
|
throw new Error(['MUI X: You cannot update several rows at once in `apiRef.current.updateRows` on the DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
|
|
136
136
|
}
|
|
137
|
-
if ((0, _pivoting.gridPivotActiveSelector)(apiRef)) {
|
|
137
|
+
if (!props.dataSource && (0, _pivoting.gridPivotActiveSelector)(apiRef)) {
|
|
138
138
|
apiRef.current.updateNonPivotRows(updates);
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
@@ -148,7 +148,7 @@ const useGridRows = (apiRef, props, configuration) => {
|
|
|
148
148
|
cache,
|
|
149
149
|
throttle: true
|
|
150
150
|
});
|
|
151
|
-
}, [props.signature, props.getRowId, throttledRowsChange, apiRef]);
|
|
151
|
+
}, [props.signature, props.dataSource, props.getRowId, throttledRowsChange, apiRef]);
|
|
152
152
|
const updateNestedRows = React.useCallback((updates, groupKeys) => {
|
|
153
153
|
const nonPinnedRowsUpdates = (0, _gridRowsUtils.computeRowsUpdates)(apiRef, updates, props.getRowId);
|
|
154
154
|
const cache = (0, _gridRowsUtils.updateCacheWithNewRows)({
|
package/index.js
CHANGED