@mui/x-data-grid 5.17.7 → 5.17.9
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 +67 -0
- package/DataGrid/DataGrid.js +1 -1
- package/components/cell/GridActionsCell.js +1 -1
- package/components/cell/GridBooleanCell.js +1 -1
- package/components/cell/GridEditBooleanCell.js +1 -1
- package/components/cell/GridEditDateCell.js +1 -1
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/components/panel/GridColumnsPanel.d.ts +3 -0
- package/components/panel/GridColumnsPanel.js +32 -7
- package/hooks/core/useGridApiInitialization.js +2 -0
- package/hooks/features/rows/gridRowsState.d.ts +1 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +3 -1
- package/hooks/features/rows/useGridRows.js +30 -9
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +1 -1
- package/legacy/components/cell/GridActionsCell.js +1 -1
- package/legacy/components/cell/GridBooleanCell.js +1 -1
- package/legacy/components/cell/GridEditBooleanCell.js +1 -1
- package/legacy/components/cell/GridEditDateCell.js +1 -1
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/legacy/components/panel/GridColumnsPanel.js +33 -6
- package/legacy/hooks/core/useGridApiInitialization.js +2 -0
- package/legacy/hooks/features/rows/gridRowsUtils.js +3 -1
- package/legacy/hooks/features/rows/useGridRows.js +32 -9
- package/legacy/index.js +1 -1
- package/legacy/locales/bgBG.js +1 -1
- package/legacy/locales/trTR.js +17 -17
- package/legacy/utils/createSelector.js +8 -2
- package/locales/bgBG.js +1 -1
- package/locales/trTR.js +17 -17
- package/modern/DataGrid/DataGrid.js +1 -1
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridBooleanCell.js +1 -1
- package/modern/components/cell/GridEditBooleanCell.js +1 -1
- package/modern/components/cell/GridEditDateCell.js +1 -1
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/modern/components/panel/GridColumnsPanel.js +32 -7
- package/modern/hooks/core/useGridApiInitialization.js +2 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +3 -1
- package/modern/hooks/features/rows/useGridRows.js +30 -9
- package/modern/index.js +1 -1
- package/modern/locales/bgBG.js +1 -1
- package/modern/locales/trTR.js +17 -17
- package/modern/utils/createSelector.js +8 -2
- package/node/DataGrid/DataGrid.js +1 -1
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridBooleanCell.js +1 -1
- package/node/components/cell/GridEditBooleanCell.js +1 -1
- package/node/components/cell/GridEditDateCell.js +1 -1
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/panel/GridColumnsPanel.js +32 -7
- package/node/hooks/core/useGridApiInitialization.js +3 -0
- package/node/hooks/features/rows/gridRowsUtils.js +3 -1
- package/node/hooks/features/rows/useGridRows.js +30 -9
- package/node/index.js +1 -1
- package/node/locales/bgBG.js +1 -1
- package/node/locales/trTR.js +17 -17
- package/node/utils/createSelector.js +8 -2
- package/package.json +1 -1
- package/utils/createSelector.d.ts +2 -1
- package/utils/createSelector.js +8 -2
|
@@ -16,7 +16,8 @@ export var rowsStateInitializer = function rowsStateInitializer(state, props, ap
|
|
|
16
16
|
apiRef.current.unstable_caches.rows = createRowsInternalCache({
|
|
17
17
|
rows: props.rows,
|
|
18
18
|
getRowId: props.getRowId,
|
|
19
|
-
loading: props.loading
|
|
19
|
+
loading: props.loading,
|
|
20
|
+
rowCount: props.rowCount
|
|
20
21
|
});
|
|
21
22
|
return _extends({}, state, {
|
|
22
23
|
rows: getRowsStateFromCache({
|
|
@@ -97,12 +98,16 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
97
98
|
|
|
98
99
|
var setRows = React.useCallback(function (rows) {
|
|
99
100
|
logger.debug("Updating all rows, new length ".concat(rows.length));
|
|
100
|
-
|
|
101
|
+
var cache = createRowsInternalCache({
|
|
101
102
|
rows: rows,
|
|
102
103
|
getRowId: props.getRowId,
|
|
103
|
-
loading: props.loading
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
loading: props.loading,
|
|
105
|
+
rowCount: props.rowCount
|
|
106
|
+
});
|
|
107
|
+
var prevCache = apiRef.current.unstable_caches.rows;
|
|
108
|
+
cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
|
|
109
|
+
throttledRowsChange(cache, true);
|
|
110
|
+
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
|
|
106
111
|
var updateRows = React.useCallback(function (updates) {
|
|
107
112
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
108
113
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
|
@@ -125,6 +130,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
125
130
|
var newCache = {
|
|
126
131
|
rowsBeforePartialUpdates: prevCache.rowsBeforePartialUpdates,
|
|
127
132
|
loadingPropBeforePartialUpdates: prevCache.loadingPropBeforePartialUpdates,
|
|
133
|
+
rowCountPropBeforePartialUpdates: prevCache.rowCountPropBeforePartialUpdates,
|
|
128
134
|
idRowsLookup: _extends({}, prevCache.idRowsLookup),
|
|
129
135
|
idToIdLookup: _extends({}, prevCache.idToIdLookup),
|
|
130
136
|
ids: _toConsumableArray(prevCache.ids)
|
|
@@ -265,6 +271,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
265
271
|
})
|
|
266
272
|
});
|
|
267
273
|
});
|
|
274
|
+
apiRef.current.unstable_caches.rows.ids = updatedRows;
|
|
268
275
|
apiRef.current.publishEvent('rowsSet');
|
|
269
276
|
}, [apiRef, logger]);
|
|
270
277
|
var replaceRows = React.useCallback(function (firstRowToRender, newRows) {
|
|
@@ -363,12 +370,13 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
363
370
|
cache = createRowsInternalCache({
|
|
364
371
|
rows: props.rows,
|
|
365
372
|
getRowId: props.getRowId,
|
|
366
|
-
loading: props.loading
|
|
373
|
+
loading: props.loading,
|
|
374
|
+
rowCount: props.rowCount
|
|
367
375
|
});
|
|
368
376
|
}
|
|
369
377
|
|
|
370
378
|
throttledRowsChange(cache, false);
|
|
371
|
-
}, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
|
|
379
|
+
}, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
372
380
|
var handleStrategyProcessorChange = React.useCallback(function (methodName) {
|
|
373
381
|
if (methodName === 'rowTreeCreation') {
|
|
374
382
|
groupRows();
|
|
@@ -419,7 +427,8 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
419
427
|
}
|
|
420
428
|
|
|
421
429
|
var areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
|
|
422
|
-
var isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
430
|
+
var isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
431
|
+
var isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
|
|
423
432
|
|
|
424
433
|
if (areNewRowsAlreadyInState) {
|
|
425
434
|
// If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
|
|
@@ -435,6 +444,19 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
435
444
|
apiRef.current.forceUpdate();
|
|
436
445
|
}
|
|
437
446
|
|
|
447
|
+
if (!isNewRowCountAlreadyInState) {
|
|
448
|
+
apiRef.current.setState(function (state) {
|
|
449
|
+
return _extends({}, state, {
|
|
450
|
+
rows: _extends({}, state.rows, {
|
|
451
|
+
totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
|
|
452
|
+
totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
|
|
453
|
+
})
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
|
|
457
|
+
apiRef.current.forceUpdate();
|
|
458
|
+
}
|
|
459
|
+
|
|
438
460
|
return;
|
|
439
461
|
}
|
|
440
462
|
|
|
@@ -442,7 +464,8 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
442
464
|
throttledRowsChange(createRowsInternalCache({
|
|
443
465
|
rows: props.rows,
|
|
444
466
|
getRowId: props.getRowId,
|
|
445
|
-
loading: props.loading
|
|
467
|
+
loading: props.loading,
|
|
468
|
+
rowCount: props.rowCount
|
|
446
469
|
}), false);
|
|
447
470
|
}, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
|
|
448
471
|
};
|
package/legacy/index.js
CHANGED
package/legacy/locales/bgBG.js
CHANGED
|
@@ -86,7 +86,7 @@ var bgBGGrid = {
|
|
|
86
86
|
return count !== 1 ? "".concat(count.toLocaleString(), " \u0438\u0437\u0431\u0440\u0430\u043D\u0438 \u0440\u0435\u0434\u043E\u0432\u0435") : "".concat(count.toLocaleString(), " \u0438\u0437\u0431\u0440\u0430\u043D \u0440\u0435\u0434");
|
|
87
87
|
},
|
|
88
88
|
// Total row amount footer text
|
|
89
|
-
footerTotalRows: 'Общо
|
|
89
|
+
footerTotalRows: 'Общо Редове:',
|
|
90
90
|
// Total visible row amount footer text
|
|
91
91
|
footerTotalVisibleRows: function footerTotalVisibleRows(visibleCount, totalCount) {
|
|
92
92
|
return "".concat(visibleCount.toLocaleString(), " \u043E\u0442 ").concat(totalCount.toLocaleString());
|
package/legacy/locales/trTR.js
CHANGED
|
@@ -41,7 +41,7 @@ var trTRGrid = {
|
|
|
41
41
|
// Filter panel text
|
|
42
42
|
filterPanelAddFilter: 'Filtre Ekle',
|
|
43
43
|
filterPanelDeleteIconLabel: 'Kaldır',
|
|
44
|
-
|
|
44
|
+
filterPanelLinkOperator: 'Mantıksal operatörler',
|
|
45
45
|
filterPanelOperators: 'Operatör',
|
|
46
46
|
// TODO v6: rename to filterPanelOperator
|
|
47
47
|
filterPanelOperatorAnd: 'Ve',
|
|
@@ -93,13 +93,13 @@ var trTRGrid = {
|
|
|
93
93
|
},
|
|
94
94
|
// Checkbox selection text
|
|
95
95
|
checkboxSelectionHeaderName: 'Seçim',
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
checkboxSelectionSelectAllRows: 'Tüm satırları seç',
|
|
97
|
+
checkboxSelectionUnselectAllRows: 'Tüm satırların seçimini kaldır',
|
|
98
|
+
checkboxSelectionSelectRow: 'Satırı seç',
|
|
99
|
+
checkboxSelectionUnselectRow: 'Satır seçimini bırak',
|
|
100
100
|
// Boolean cell text
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
booleanCellTrueLabel: 'Evet',
|
|
102
|
+
booleanCellFalseLabel: 'Hayır',
|
|
103
103
|
// Actions cell more text
|
|
104
104
|
actionsCellMore: 'daha fazla',
|
|
105
105
|
// Column pinning text
|
|
@@ -119,17 +119,17 @@ var trTRGrid = {
|
|
|
119
119
|
return "".concat(name, " i\xE7in gruplamay\u0131 kald\u0131r");
|
|
120
120
|
},
|
|
121
121
|
// Master/detail
|
|
122
|
-
|
|
122
|
+
detailPanelToggle: 'Detay görünümüne geçiş',
|
|
123
123
|
expandDetailPanel: 'Genişlet',
|
|
124
|
-
collapseDetailPanel: 'Gizle'
|
|
125
|
-
//
|
|
124
|
+
collapseDetailPanel: 'Gizle',
|
|
125
|
+
// Row reordering text
|
|
126
|
+
rowReorderingHeaderName: 'Satırı yeniden sırala',
|
|
126
127
|
// Aggregation
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
128
|
+
aggregationMenuItemHeader: 'Toplama',
|
|
129
|
+
aggregationFunctionLabelSum: 'top',
|
|
130
|
+
aggregationFunctionLabelAvg: 'ort',
|
|
131
|
+
aggregationFunctionLabelMin: 'min',
|
|
132
|
+
aggregationFunctionLabelMax: 'maks',
|
|
133
|
+
aggregationFunctionLabelSize: 'boyut'
|
|
134
134
|
};
|
|
135
135
|
export var trTR = getGridLocalization(trTRGrid, trTRCore);
|
|
@@ -58,6 +58,12 @@ export var createSelector = function createSelector() {
|
|
|
58
58
|
return selector;
|
|
59
59
|
}; // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
60
60
|
|
|
61
|
-
export var unstable_resetCreateSelectorCache = function unstable_resetCreateSelectorCache() {
|
|
62
|
-
|
|
61
|
+
export var unstable_resetCreateSelectorCache = function unstable_resetCreateSelectorCache(cacheKey) {
|
|
62
|
+
if (typeof cacheKey !== 'undefined') {
|
|
63
|
+
if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
|
|
64
|
+
delete cacheContainer.cache[cacheKey];
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
cacheContainer.cache = null;
|
|
68
|
+
}
|
|
63
69
|
};
|
package/locales/bgBG.js
CHANGED
|
@@ -80,7 +80,7 @@ const bgBGGrid = {
|
|
|
80
80
|
// Rows selected footer text
|
|
81
81
|
footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} избрани редове` : `${count.toLocaleString()} избран ред`,
|
|
82
82
|
// Total row amount footer text
|
|
83
|
-
footerTotalRows: 'Общо
|
|
83
|
+
footerTotalRows: 'Общо Редове:',
|
|
84
84
|
// Total visible row amount footer text
|
|
85
85
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} от ${totalCount.toLocaleString()}`,
|
|
86
86
|
// Checkbox selection text
|
package/locales/trTR.js
CHANGED
|
@@ -39,7 +39,7 @@ const trTRGrid = {
|
|
|
39
39
|
// Filter panel text
|
|
40
40
|
filterPanelAddFilter: 'Filtre Ekle',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Kaldır',
|
|
42
|
-
|
|
42
|
+
filterPanelLinkOperator: 'Mantıksal operatörler',
|
|
43
43
|
filterPanelOperators: 'Operatör',
|
|
44
44
|
// TODO v6: rename to filterPanelOperator
|
|
45
45
|
filterPanelOperatorAnd: 'Ve',
|
|
@@ -85,13 +85,13 @@ const trTRGrid = {
|
|
|
85
85
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} / ${totalCount.toLocaleString()}`,
|
|
86
86
|
// Checkbox selection text
|
|
87
87
|
checkboxSelectionHeaderName: 'Seçim',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
checkboxSelectionSelectAllRows: 'Tüm satırları seç',
|
|
89
|
+
checkboxSelectionUnselectAllRows: 'Tüm satırların seçimini kaldır',
|
|
90
|
+
checkboxSelectionSelectRow: 'Satırı seç',
|
|
91
|
+
checkboxSelectionUnselectRow: 'Satır seçimini bırak',
|
|
92
92
|
// Boolean cell text
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
booleanCellTrueLabel: 'Evet',
|
|
94
|
+
booleanCellFalseLabel: 'Hayır',
|
|
95
95
|
// Actions cell more text
|
|
96
96
|
actionsCellMore: 'daha fazla',
|
|
97
97
|
// Column pinning text
|
|
@@ -107,17 +107,17 @@ const trTRGrid = {
|
|
|
107
107
|
groupColumn: name => `${name} için grupla`,
|
|
108
108
|
unGroupColumn: name => `${name} için gruplamayı kaldır`,
|
|
109
109
|
// Master/detail
|
|
110
|
-
|
|
110
|
+
detailPanelToggle: 'Detay görünümüne geçiş',
|
|
111
111
|
expandDetailPanel: 'Genişlet',
|
|
112
|
-
collapseDetailPanel: 'Gizle'
|
|
113
|
-
//
|
|
112
|
+
collapseDetailPanel: 'Gizle',
|
|
113
|
+
// Row reordering text
|
|
114
|
+
rowReorderingHeaderName: 'Satırı yeniden sırala',
|
|
114
115
|
// Aggregation
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
aggregationMenuItemHeader: 'Toplama',
|
|
117
|
+
aggregationFunctionLabelSum: 'top',
|
|
118
|
+
aggregationFunctionLabelAvg: 'ort',
|
|
119
|
+
aggregationFunctionLabelMin: 'min',
|
|
120
|
+
aggregationFunctionLabelMax: 'maks',
|
|
121
|
+
aggregationFunctionLabelSize: 'boyut'
|
|
122
122
|
};
|
|
123
123
|
export const trTR = getGridLocalization(trTRGrid, trTRCore);
|
|
@@ -721,7 +721,7 @@ DataGridRaw.propTypes = {
|
|
|
721
721
|
/**
|
|
722
722
|
* Set of rows of type [[GridRowsProp]].
|
|
723
723
|
*/
|
|
724
|
-
rows: PropTypes.
|
|
724
|
+
rows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
725
725
|
|
|
726
726
|
/**
|
|
727
727
|
* Sets the type of space between rows added by `getRowSpacing`.
|
|
@@ -261,7 +261,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
261
261
|
/**
|
|
262
262
|
* The row model of the row that the current cell belongs to.
|
|
263
263
|
*/
|
|
264
|
-
row: PropTypes.
|
|
264
|
+
row: PropTypes.any.isRequired,
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
267
|
* The node of the row that the current cell belongs to.
|
|
@@ -110,7 +110,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
110
110
|
/**
|
|
111
111
|
* The row model of the row that the current cell belongs to.
|
|
112
112
|
*/
|
|
113
|
-
row: PropTypes.
|
|
113
|
+
row: PropTypes.any.isRequired,
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* The node of the row that the current cell belongs to.
|
|
@@ -147,7 +147,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
147
147
|
/**
|
|
148
148
|
* The row model of the row that the current cell belongs to.
|
|
149
149
|
*/
|
|
150
|
-
row: PropTypes.
|
|
150
|
+
row: PropTypes.any.isRequired,
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* The node of the row that the current cell belongs to.
|
|
@@ -201,7 +201,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
201
201
|
/**
|
|
202
202
|
* The row model of the row that the current cell belongs to.
|
|
203
203
|
*/
|
|
204
|
-
row: PropTypes.
|
|
204
|
+
row: PropTypes.any.isRequired,
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
207
|
* The node of the row that the current cell belongs to.
|
|
@@ -175,7 +175,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
175
175
|
/**
|
|
176
176
|
* The row model of the row that the current cell belongs to.
|
|
177
177
|
*/
|
|
178
|
-
row: PropTypes.
|
|
178
|
+
row: PropTypes.any,
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* The node of the row that the current cell belongs to.
|
|
@@ -246,7 +246,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
246
246
|
/**
|
|
247
247
|
* The row model of the row that the current cell belongs to.
|
|
248
248
|
*/
|
|
249
|
-
row: PropTypes.
|
|
249
|
+
row: PropTypes.any.isRequired,
|
|
250
250
|
|
|
251
251
|
/**
|
|
252
252
|
* The node of the row that the current cell belongs to.
|
|
@@ -170,7 +170,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
170
170
|
/**
|
|
171
171
|
* The row model of the row that the current cell belongs to.
|
|
172
172
|
*/
|
|
173
|
-
row: PropTypes.
|
|
173
|
+
row: PropTypes.any.isRequired,
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
176
|
* The node of the row that the current cell belongs to.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["sort"];
|
|
3
|
+
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
@@ -59,6 +59,10 @@ const GridIconButtonRoot = styled(IconButton)({
|
|
|
59
59
|
});
|
|
60
60
|
const collator = new Intl.Collator();
|
|
61
61
|
|
|
62
|
+
const defaultSearchPredicate = (column, searchValue) => {
|
|
63
|
+
return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
|
|
64
|
+
};
|
|
65
|
+
|
|
62
66
|
function GridColumnsPanel(props) {
|
|
63
67
|
const apiRef = useGridApiContext();
|
|
64
68
|
const searchInputRef = React.useRef(null);
|
|
@@ -72,7 +76,9 @@ function GridColumnsPanel(props) {
|
|
|
72
76
|
const classes = useUtilityClasses(ownerState);
|
|
73
77
|
|
|
74
78
|
const {
|
|
75
|
-
sort
|
|
79
|
+
sort,
|
|
80
|
+
searchPredicate = defaultSearchPredicate,
|
|
81
|
+
autoFocusSearchField = true
|
|
76
82
|
} = props,
|
|
77
83
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
78
84
|
|
|
@@ -126,11 +132,27 @@ function GridColumnsPanel(props) {
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
129
|
-
return sortedColumns.filter(column => (column
|
|
130
|
-
}, [sortedColumns, searchValue]);
|
|
135
|
+
return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
|
|
136
|
+
}, [sortedColumns, searchValue, searchPredicate]);
|
|
137
|
+
const firstSwitchRef = React.useRef(null);
|
|
131
138
|
React.useEffect(() => {
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
if (autoFocusSearchField) {
|
|
140
|
+
searchInputRef.current.focus();
|
|
141
|
+
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
142
|
+
firstSwitchRef.current.focus();
|
|
143
|
+
}
|
|
144
|
+
}, [autoFocusSearchField]);
|
|
145
|
+
let firstHideableColumnFound = false;
|
|
146
|
+
|
|
147
|
+
const isFirstHideableColumn = column => {
|
|
148
|
+
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
149
|
+
firstHideableColumnFound = true;
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return false;
|
|
154
|
+
};
|
|
155
|
+
|
|
134
156
|
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
135
157
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
136
158
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
@@ -153,7 +175,8 @@ function GridColumnsPanel(props) {
|
|
|
153
175
|
checked: columnVisibilityModel[column.field] !== false,
|
|
154
176
|
onClick: toggleColumn,
|
|
155
177
|
name: column.field,
|
|
156
|
-
size: "small"
|
|
178
|
+
size: "small",
|
|
179
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
157
180
|
}, rootProps.componentsProps?.baseSwitch)),
|
|
158
181
|
label: column.headerName || column.field
|
|
159
182
|
}), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
|
|
@@ -185,6 +208,8 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
185
208
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
186
209
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
187
210
|
// ----------------------------------------------------------------------
|
|
211
|
+
autoFocusSearchField: PropTypes.bool,
|
|
212
|
+
searchPredicate: PropTypes.func,
|
|
188
213
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
189
214
|
} : void 0;
|
|
190
215
|
export { GridColumnsPanel };
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { useGridApiMethod } from '../utils/useGridApiMethod';
|
|
3
3
|
import { GridSignature } from '../utils/useGridApiEventHandler';
|
|
4
4
|
import { EventManager } from '../../utils/EventManager';
|
|
5
|
+
import { unstable_resetCreateSelectorCache } from '../../utils/createSelector';
|
|
5
6
|
|
|
6
7
|
const isSyntheticEvent = event => {
|
|
7
8
|
return event.isPropagationStopped !== undefined;
|
|
@@ -53,6 +54,7 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
53
54
|
React.useEffect(() => {
|
|
54
55
|
const api = apiRef.current;
|
|
55
56
|
return () => {
|
|
57
|
+
unstable_resetCreateSelectorCache(api.instanceId);
|
|
56
58
|
api.publishEvent('unmount');
|
|
57
59
|
};
|
|
58
60
|
}, [apiRef]);
|
|
@@ -22,11 +22,13 @@ export const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) =>
|
|
|
22
22
|
export const createRowsInternalCache = ({
|
|
23
23
|
rows,
|
|
24
24
|
getRowId,
|
|
25
|
-
loading
|
|
25
|
+
loading,
|
|
26
|
+
rowCount
|
|
26
27
|
}) => {
|
|
27
28
|
const cache = {
|
|
28
29
|
rowsBeforePartialUpdates: rows,
|
|
29
30
|
loadingPropBeforePartialUpdates: loading,
|
|
31
|
+
rowCountPropBeforePartialUpdates: rowCount,
|
|
30
32
|
idRowsLookup: {},
|
|
31
33
|
idToIdLookup: {},
|
|
32
34
|
ids: []
|
|
@@ -13,7 +13,8 @@ export const rowsStateInitializer = (state, props, apiRef) => {
|
|
|
13
13
|
apiRef.current.unstable_caches.rows = createRowsInternalCache({
|
|
14
14
|
rows: props.rows,
|
|
15
15
|
getRowId: props.getRowId,
|
|
16
|
-
loading: props.loading
|
|
16
|
+
loading: props.loading,
|
|
17
|
+
rowCount: props.rowCount
|
|
17
18
|
});
|
|
18
19
|
return _extends({}, state, {
|
|
19
20
|
rows: getRowsStateFromCache({
|
|
@@ -87,12 +88,16 @@ export const useGridRows = (apiRef, props) => {
|
|
|
87
88
|
|
|
88
89
|
const setRows = React.useCallback(rows => {
|
|
89
90
|
logger.debug(`Updating all rows, new length ${rows.length}`);
|
|
90
|
-
|
|
91
|
+
const cache = createRowsInternalCache({
|
|
91
92
|
rows,
|
|
92
93
|
getRowId: props.getRowId,
|
|
93
|
-
loading: props.loading
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
loading: props.loading,
|
|
95
|
+
rowCount: props.rowCount
|
|
96
|
+
});
|
|
97
|
+
const prevCache = apiRef.current.unstable_caches.rows;
|
|
98
|
+
cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
|
|
99
|
+
throttledRowsChange(cache, true);
|
|
100
|
+
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
|
|
96
101
|
const updateRows = React.useCallback(updates => {
|
|
97
102
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
98
103
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
|
@@ -115,6 +120,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
115
120
|
const newCache = {
|
|
116
121
|
rowsBeforePartialUpdates: prevCache.rowsBeforePartialUpdates,
|
|
117
122
|
loadingPropBeforePartialUpdates: prevCache.loadingPropBeforePartialUpdates,
|
|
123
|
+
rowCountPropBeforePartialUpdates: prevCache.rowCountPropBeforePartialUpdates,
|
|
118
124
|
idRowsLookup: _extends({}, prevCache.idRowsLookup),
|
|
119
125
|
idToIdLookup: _extends({}, prevCache.idToIdLookup),
|
|
120
126
|
ids: [...prevCache.ids]
|
|
@@ -233,6 +239,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
233
239
|
ids: updatedRows
|
|
234
240
|
})
|
|
235
241
|
}));
|
|
242
|
+
apiRef.current.unstable_caches.rows.ids = updatedRows;
|
|
236
243
|
apiRef.current.publishEvent('rowsSet');
|
|
237
244
|
}, [apiRef, logger]);
|
|
238
245
|
const replaceRows = React.useCallback((firstRowToRender, newRows) => {
|
|
@@ -324,12 +331,13 @@ export const useGridRows = (apiRef, props) => {
|
|
|
324
331
|
cache = createRowsInternalCache({
|
|
325
332
|
rows: props.rows,
|
|
326
333
|
getRowId: props.getRowId,
|
|
327
|
-
loading: props.loading
|
|
334
|
+
loading: props.loading,
|
|
335
|
+
rowCount: props.rowCount
|
|
328
336
|
});
|
|
329
337
|
}
|
|
330
338
|
|
|
331
339
|
throttledRowsChange(cache, false);
|
|
332
|
-
}, [logger, apiRef, props.rows, props.getRowId, props.loading, throttledRowsChange]);
|
|
340
|
+
}, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
333
341
|
const handleStrategyProcessorChange = React.useCallback(methodName => {
|
|
334
342
|
if (methodName === 'rowTreeCreation') {
|
|
335
343
|
groupRows();
|
|
@@ -378,7 +386,8 @@ export const useGridRows = (apiRef, props) => {
|
|
|
378
386
|
}
|
|
379
387
|
|
|
380
388
|
const areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
|
|
381
|
-
const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
389
|
+
const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading;
|
|
390
|
+
const isNewRowCountAlreadyInState = apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates === props.rowCount; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
|
|
382
391
|
|
|
383
392
|
if (areNewRowsAlreadyInState) {
|
|
384
393
|
// If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
|
|
@@ -392,6 +401,17 @@ export const useGridRows = (apiRef, props) => {
|
|
|
392
401
|
apiRef.current.forceUpdate();
|
|
393
402
|
}
|
|
394
403
|
|
|
404
|
+
if (!isNewRowCountAlreadyInState) {
|
|
405
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
406
|
+
rows: _extends({}, state.rows, {
|
|
407
|
+
totalRowCount: Math.max(props.rowCount || 0, state.rows.totalRowCount),
|
|
408
|
+
totalTopLevelRowCount: Math.max(props.rowCount || 0, state.rows.totalTopLevelRowCount)
|
|
409
|
+
})
|
|
410
|
+
}));
|
|
411
|
+
apiRef.current.unstable_caches.rows.rowCountPropBeforePartialUpdates = props.rowCount;
|
|
412
|
+
apiRef.current.forceUpdate();
|
|
413
|
+
}
|
|
414
|
+
|
|
395
415
|
return;
|
|
396
416
|
}
|
|
397
417
|
|
|
@@ -399,7 +419,8 @@ export const useGridRows = (apiRef, props) => {
|
|
|
399
419
|
throttledRowsChange(createRowsInternalCache({
|
|
400
420
|
rows: props.rows,
|
|
401
421
|
getRowId: props.getRowId,
|
|
402
|
-
loading: props.loading
|
|
422
|
+
loading: props.loading,
|
|
423
|
+
rowCount: props.rowCount
|
|
403
424
|
}), false);
|
|
404
425
|
}, [props.rows, props.rowCount, props.getRowId, props.loading, logger, throttledRowsChange, apiRef]);
|
|
405
426
|
};
|
package/modern/index.js
CHANGED
package/modern/locales/bgBG.js
CHANGED
|
@@ -80,7 +80,7 @@ const bgBGGrid = {
|
|
|
80
80
|
// Rows selected footer text
|
|
81
81
|
footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} избрани редове` : `${count.toLocaleString()} избран ред`,
|
|
82
82
|
// Total row amount footer text
|
|
83
|
-
footerTotalRows: 'Общо
|
|
83
|
+
footerTotalRows: 'Общо Редове:',
|
|
84
84
|
// Total visible row amount footer text
|
|
85
85
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} от ${totalCount.toLocaleString()}`,
|
|
86
86
|
// Checkbox selection text
|
package/modern/locales/trTR.js
CHANGED
|
@@ -39,7 +39,7 @@ const trTRGrid = {
|
|
|
39
39
|
// Filter panel text
|
|
40
40
|
filterPanelAddFilter: 'Filtre Ekle',
|
|
41
41
|
filterPanelDeleteIconLabel: 'Kaldır',
|
|
42
|
-
|
|
42
|
+
filterPanelLinkOperator: 'Mantıksal operatörler',
|
|
43
43
|
filterPanelOperators: 'Operatör',
|
|
44
44
|
// TODO v6: rename to filterPanelOperator
|
|
45
45
|
filterPanelOperatorAnd: 'Ve',
|
|
@@ -85,13 +85,13 @@ const trTRGrid = {
|
|
|
85
85
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} / ${totalCount.toLocaleString()}`,
|
|
86
86
|
// Checkbox selection text
|
|
87
87
|
checkboxSelectionHeaderName: 'Seçim',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
checkboxSelectionSelectAllRows: 'Tüm satırları seç',
|
|
89
|
+
checkboxSelectionUnselectAllRows: 'Tüm satırların seçimini kaldır',
|
|
90
|
+
checkboxSelectionSelectRow: 'Satırı seç',
|
|
91
|
+
checkboxSelectionUnselectRow: 'Satır seçimini bırak',
|
|
92
92
|
// Boolean cell text
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
booleanCellTrueLabel: 'Evet',
|
|
94
|
+
booleanCellFalseLabel: 'Hayır',
|
|
95
95
|
// Actions cell more text
|
|
96
96
|
actionsCellMore: 'daha fazla',
|
|
97
97
|
// Column pinning text
|
|
@@ -107,17 +107,17 @@ const trTRGrid = {
|
|
|
107
107
|
groupColumn: name => `${name} için grupla`,
|
|
108
108
|
unGroupColumn: name => `${name} için gruplamayı kaldır`,
|
|
109
109
|
// Master/detail
|
|
110
|
-
|
|
110
|
+
detailPanelToggle: 'Detay görünümüne geçiş',
|
|
111
111
|
expandDetailPanel: 'Genişlet',
|
|
112
|
-
collapseDetailPanel: 'Gizle'
|
|
113
|
-
//
|
|
112
|
+
collapseDetailPanel: 'Gizle',
|
|
113
|
+
// Row reordering text
|
|
114
|
+
rowReorderingHeaderName: 'Satırı yeniden sırala',
|
|
114
115
|
// Aggregation
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
aggregationMenuItemHeader: 'Toplama',
|
|
117
|
+
aggregationFunctionLabelSum: 'top',
|
|
118
|
+
aggregationFunctionLabelAvg: 'ort',
|
|
119
|
+
aggregationFunctionLabelMin: 'min',
|
|
120
|
+
aggregationFunctionLabelMax: 'maks',
|
|
121
|
+
aggregationFunctionLabelSize: 'boyut'
|
|
122
122
|
};
|
|
123
123
|
export const trTR = getGridLocalization(trTRGrid, trTRCore);
|
|
@@ -51,6 +51,12 @@ export const createSelector = (...args) => {
|
|
|
51
51
|
return selector;
|
|
52
52
|
}; // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
53
53
|
|
|
54
|
-
export const unstable_resetCreateSelectorCache =
|
|
55
|
-
|
|
54
|
+
export const unstable_resetCreateSelectorCache = cacheKey => {
|
|
55
|
+
if (typeof cacheKey !== 'undefined') {
|
|
56
|
+
if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
|
|
57
|
+
delete cacheContainer.cache[cacheKey];
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
cacheContainer.cache = null;
|
|
61
|
+
}
|
|
56
62
|
};
|