@mui/x-data-grid 5.17.8 → 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 +37 -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 +2 -1
- package/components/panel/GridColumnsPanel.js +24 -5
- package/hooks/core/useGridApiInitialization.js +2 -0
- package/hooks/features/rows/useGridRows.js +6 -3
- 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 +24 -4
- package/legacy/hooks/core/useGridApiInitialization.js +2 -0
- package/legacy/hooks/features/rows/useGridRows.js +6 -3
- package/legacy/index.js +1 -1
- package/legacy/locales/bgBG.js +1 -1
- package/legacy/utils/createSelector.js +8 -2
- package/locales/bgBG.js +1 -1
- 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 +24 -5
- package/modern/hooks/core/useGridApiInitialization.js +2 -0
- package/modern/hooks/features/rows/useGridRows.js +6 -3
- package/modern/index.js +1 -1
- package/modern/locales/bgBG.js +1 -1
- 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 +24 -5
- package/node/hooks/core/useGridApiInitialization.js +3 -0
- package/node/hooks/features/rows/useGridRows.js +6 -3
- package/node/index.js +1 -1
- package/node/locales/bgBG.js +1 -1
- 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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,43 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.17.9
|
|
7
|
+
|
|
8
|
+
_Oct 28, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- ⚡ Fix memory leak during unmount of the DataGrid (#6579) @cherniavskii
|
|
13
|
+
- 🎁 Allow to disable the autofocus of the search field when opening the column visibility panel (#6630) @e-cloud
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
|
|
16
|
+
### `@mui/x-data-grid@v5.17.9` / `@mui/x-data-grid-pro@v5.17.9` / `@mui/x-data-grid-premium@v5.17.9`
|
|
17
|
+
|
|
18
|
+
#### Changes
|
|
19
|
+
|
|
20
|
+
- [DataGrid] Allow to disable autofocusing the search field in the columns panel (#6630) @e-cloud
|
|
21
|
+
- [DataGrid] Fix `setRows` method not persisting new rows data after `loading` prop change (#6637) @cherniavskii
|
|
22
|
+
- [DataGrid] Fix memory leak on grid unmount (#6579) @cherniavskii
|
|
23
|
+
- [l10n] Improve Bulgarian (bg-BG) locale (#6635) @AtanasVA
|
|
24
|
+
|
|
25
|
+
### `@mui/x-date-pickers@v5.0.6` / `@mui/x-date-pickers-pro@v5.0.6`
|
|
26
|
+
|
|
27
|
+
#### Changes
|
|
28
|
+
|
|
29
|
+
- [pickers] Ignore milliseconds in mask logic (#6618) @alexfauquette
|
|
30
|
+
- [pickers] Update input when `inputFormat` is modified (#6617) @alexfauquette
|
|
31
|
+
|
|
32
|
+
### Docs
|
|
33
|
+
|
|
34
|
+
- [docs] Add token to redirect feedbacks on slack (#6592) @alexfauquette
|
|
35
|
+
- [docs] Disable translations (#6639) @cherniavskii
|
|
36
|
+
- [docs] Fix code edit for when v6 will be stable (#6600) @oliviertassinari
|
|
37
|
+
- [docs] Fix typo in DataGrid demo page (#6632) (#6634) @LukasTy
|
|
38
|
+
|
|
39
|
+
### Core
|
|
40
|
+
|
|
41
|
+
- [core] Upgrade monorepo (#6570) @cherniavskii
|
|
42
|
+
|
|
6
43
|
## 5.17.8
|
|
7
44
|
|
|
8
45
|
_Oct 20, 2022_
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -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.
|
|
@@ -149,7 +149,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
149
149
|
/**
|
|
150
150
|
* The row model of the row that the current cell belongs to.
|
|
151
151
|
*/
|
|
152
|
-
row: PropTypes.
|
|
152
|
+
row: PropTypes.any.isRequired,
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* The node of the row that the current cell belongs to.
|
|
@@ -203,7 +203,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
203
203
|
/**
|
|
204
204
|
* The row model of the row that the current cell belongs to.
|
|
205
205
|
*/
|
|
206
|
-
row: PropTypes.
|
|
206
|
+
row: PropTypes.any.isRequired,
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* The node of the row that the current cell belongs to.
|
|
@@ -179,7 +179,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
179
179
|
/**
|
|
180
180
|
* The row model of the row that the current cell belongs to.
|
|
181
181
|
*/
|
|
182
|
-
row: PropTypes.
|
|
182
|
+
row: PropTypes.any,
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* The node of the row that the current cell belongs to.
|
|
@@ -252,7 +252,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
252
252
|
/**
|
|
253
253
|
* The row model of the row that the current cell belongs to.
|
|
254
254
|
*/
|
|
255
|
-
row: PropTypes.
|
|
255
|
+
row: PropTypes.any.isRequired,
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
258
|
* The node of the row that the current cell belongs to.
|
|
@@ -174,7 +174,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
174
174
|
/**
|
|
175
175
|
* The row model of the row that the current cell belongs to.
|
|
176
176
|
*/
|
|
177
|
-
row: PropTypes.
|
|
177
|
+
row: PropTypes.any.isRequired,
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
* The node of the row that the current cell belongs to.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GridPanelWrapperProps } from './GridPanelWrapper';
|
|
3
|
-
import { GridStateColDef } from '../../models/colDef/gridColDef';
|
|
3
|
+
import type { GridStateColDef } from '../../models/colDef/gridColDef';
|
|
4
4
|
export interface GridColumnsPanelProps extends GridPanelWrapperProps {
|
|
5
5
|
sort?: 'asc' | 'desc';
|
|
6
6
|
searchPredicate?: (column: GridStateColDef, searchValue: string) => boolean;
|
|
7
|
+
autoFocusSearchField?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare function GridColumnsPanel(props: GridColumnsPanelProps): JSX.Element;
|
|
9
10
|
declare namespace GridColumnsPanel {
|
|
@@ -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", "searchPredicate"];
|
|
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';
|
|
@@ -79,7 +79,8 @@ function GridColumnsPanel(props) {
|
|
|
79
79
|
|
|
80
80
|
const {
|
|
81
81
|
sort,
|
|
82
|
-
searchPredicate = defaultSearchPredicate
|
|
82
|
+
searchPredicate = defaultSearchPredicate,
|
|
83
|
+
autoFocusSearchField = true
|
|
83
84
|
} = props,
|
|
84
85
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
85
86
|
|
|
@@ -135,9 +136,25 @@ function GridColumnsPanel(props) {
|
|
|
135
136
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
136
137
|
return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
|
|
137
138
|
}, [sortedColumns, searchValue, searchPredicate]);
|
|
139
|
+
const firstSwitchRef = React.useRef(null);
|
|
138
140
|
React.useEffect(() => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
if (autoFocusSearchField) {
|
|
142
|
+
searchInputRef.current.focus();
|
|
143
|
+
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
144
|
+
firstSwitchRef.current.focus();
|
|
145
|
+
}
|
|
146
|
+
}, [autoFocusSearchField]);
|
|
147
|
+
let firstHideableColumnFound = false;
|
|
148
|
+
|
|
149
|
+
const isFirstHideableColumn = column => {
|
|
150
|
+
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
151
|
+
firstHideableColumnFound = true;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return false;
|
|
156
|
+
};
|
|
157
|
+
|
|
141
158
|
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
142
159
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
143
160
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
@@ -163,7 +180,8 @@ function GridColumnsPanel(props) {
|
|
|
163
180
|
checked: columnVisibilityModel[column.field] !== false,
|
|
164
181
|
onClick: toggleColumn,
|
|
165
182
|
name: column.field,
|
|
166
|
-
size: "small"
|
|
183
|
+
size: "small",
|
|
184
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
167
185
|
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSwitch)),
|
|
168
186
|
label: column.headerName || column.field
|
|
169
187
|
}), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
|
|
@@ -196,6 +214,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
196
214
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
197
215
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
198
216
|
// ----------------------------------------------------------------------
|
|
217
|
+
autoFocusSearchField: PropTypes.bool,
|
|
199
218
|
searchPredicate: PropTypes.func,
|
|
200
219
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
201
220
|
} : void 0;
|
|
@@ -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]);
|
|
@@ -92,13 +92,16 @@ export const useGridRows = (apiRef, props) => {
|
|
|
92
92
|
|
|
93
93
|
const setRows = React.useCallback(rows => {
|
|
94
94
|
logger.debug(`Updating all rows, new length ${rows.length}`);
|
|
95
|
-
|
|
95
|
+
const cache = createRowsInternalCache({
|
|
96
96
|
rows,
|
|
97
97
|
getRowId: props.getRowId,
|
|
98
98
|
loading: props.loading,
|
|
99
99
|
rowCount: props.rowCount
|
|
100
|
-
})
|
|
101
|
-
|
|
100
|
+
});
|
|
101
|
+
const prevCache = apiRef.current.unstable_caches.rows;
|
|
102
|
+
cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
|
|
103
|
+
throttledRowsChange(cache, true);
|
|
104
|
+
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
|
|
102
105
|
const updateRows = React.useCallback(updates => {
|
|
103
106
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
104
107
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
package/index.js
CHANGED
|
@@ -723,7 +723,7 @@ DataGridRaw.propTypes = {
|
|
|
723
723
|
/**
|
|
724
724
|
* Set of rows of type [[GridRowsProp]].
|
|
725
725
|
*/
|
|
726
|
-
rows: PropTypes.
|
|
726
|
+
rows: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
727
727
|
|
|
728
728
|
/**
|
|
729
729
|
* Sets the type of space between rows added by `getRowSpacing`.
|
|
@@ -297,7 +297,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
297
297
|
/**
|
|
298
298
|
* The row model of the row that the current cell belongs to.
|
|
299
299
|
*/
|
|
300
|
-
row: PropTypes.
|
|
300
|
+
row: PropTypes.any.isRequired,
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
303
|
* The node of the row that the current cell belongs to.
|
|
@@ -120,7 +120,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
120
120
|
/**
|
|
121
121
|
* The row model of the row that the current cell belongs to.
|
|
122
122
|
*/
|
|
123
|
-
row: PropTypes.
|
|
123
|
+
row: PropTypes.any.isRequired,
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* The node of the row that the current cell belongs to.
|
|
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
189
189
|
/**
|
|
190
190
|
* The row model of the row that the current cell belongs to.
|
|
191
191
|
*/
|
|
192
|
-
row: PropTypes.
|
|
192
|
+
row: PropTypes.any.isRequired,
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
195
|
* The node of the row that the current cell belongs to.
|
|
@@ -240,7 +240,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
240
240
|
/**
|
|
241
241
|
* The row model of the row that the current cell belongs to.
|
|
242
242
|
*/
|
|
243
|
-
row: PropTypes.
|
|
243
|
+
row: PropTypes.any.isRequired,
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
246
|
* The node of the row that the current cell belongs to.
|
|
@@ -219,7 +219,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
219
219
|
/**
|
|
220
220
|
* The row model of the row that the current cell belongs to.
|
|
221
221
|
*/
|
|
222
|
-
row: PropTypes.
|
|
222
|
+
row: PropTypes.any,
|
|
223
223
|
|
|
224
224
|
/**
|
|
225
225
|
* The node of the row that the current cell belongs to.
|
|
@@ -309,7 +309,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
309
309
|
/**
|
|
310
310
|
* The row model of the row that the current cell belongs to.
|
|
311
311
|
*/
|
|
312
|
-
row: PropTypes.
|
|
312
|
+
row: PropTypes.any.isRequired,
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
315
|
* The node of the row that the current cell belongs to.
|
|
@@ -177,7 +177,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
177
177
|
/**
|
|
178
178
|
* The row model of the row that the current cell belongs to.
|
|
179
179
|
*/
|
|
180
|
-
row: PropTypes.
|
|
180
|
+
row: PropTypes.any.isRequired,
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
183
|
* The node of the row that the current cell belongs to.
|
|
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
var _excluded = ["sort", "searchPredicate"];
|
|
6
|
+
var _excluded = ["sort", "searchPredicate", "autoFocusSearchField"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
@@ -92,6 +92,8 @@ function GridColumnsPanel(props) {
|
|
|
92
92
|
var sort = props.sort,
|
|
93
93
|
_props$searchPredicat = props.searchPredicate,
|
|
94
94
|
searchPredicate = _props$searchPredicat === void 0 ? defaultSearchPredicate : _props$searchPredicat,
|
|
95
|
+
_props$autoFocusSearc = props.autoFocusSearchField,
|
|
96
|
+
autoFocusSearchField = _props$autoFocusSearc === void 0 ? true : _props$autoFocusSearc,
|
|
95
97
|
other = _objectWithoutProperties(props, _excluded);
|
|
96
98
|
|
|
97
99
|
var sortedColumns = React.useMemo(function () {
|
|
@@ -155,9 +157,25 @@ function GridColumnsPanel(props) {
|
|
|
155
157
|
return searchPredicate(column, searchValueToCheck);
|
|
156
158
|
});
|
|
157
159
|
}, [sortedColumns, searchValue, searchPredicate]);
|
|
160
|
+
var firstSwitchRef = React.useRef(null);
|
|
158
161
|
React.useEffect(function () {
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
if (autoFocusSearchField) {
|
|
163
|
+
searchInputRef.current.focus();
|
|
164
|
+
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
165
|
+
firstSwitchRef.current.focus();
|
|
166
|
+
}
|
|
167
|
+
}, [autoFocusSearchField]);
|
|
168
|
+
var firstHideableColumnFound = false;
|
|
169
|
+
|
|
170
|
+
var isFirstHideableColumn = function isFirstHideableColumn(column) {
|
|
171
|
+
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
172
|
+
firstHideableColumnFound = true;
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return false;
|
|
177
|
+
};
|
|
178
|
+
|
|
161
179
|
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
162
180
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
163
181
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
@@ -183,7 +201,8 @@ function GridColumnsPanel(props) {
|
|
|
183
201
|
checked: columnVisibilityModel[column.field] !== false,
|
|
184
202
|
onClick: toggleColumn,
|
|
185
203
|
name: column.field,
|
|
186
|
-
size: "small"
|
|
204
|
+
size: "small",
|
|
205
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
187
206
|
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSwitch)),
|
|
188
207
|
label: column.headerName || column.field
|
|
189
208
|
}), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
|
|
@@ -220,6 +239,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
220
239
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
221
240
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
222
241
|
// ----------------------------------------------------------------------
|
|
242
|
+
autoFocusSearchField: PropTypes.bool,
|
|
223
243
|
searchPredicate: PropTypes.func,
|
|
224
244
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
225
245
|
} : void 0;
|
|
@@ -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
|
var isSyntheticEvent = function isSyntheticEvent(event) {
|
|
7
8
|
return event.isPropagationStopped !== undefined;
|
|
@@ -62,6 +63,7 @@ export function useGridApiInitialization(inputApiRef, props) {
|
|
|
62
63
|
React.useEffect(function () {
|
|
63
64
|
var api = apiRef.current;
|
|
64
65
|
return function () {
|
|
66
|
+
unstable_resetCreateSelectorCache(api.instanceId);
|
|
65
67
|
api.publishEvent('unmount');
|
|
66
68
|
};
|
|
67
69
|
}, [apiRef]);
|
|
@@ -98,13 +98,16 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
98
98
|
|
|
99
99
|
var setRows = React.useCallback(function (rows) {
|
|
100
100
|
logger.debug("Updating all rows, new length ".concat(rows.length));
|
|
101
|
-
|
|
101
|
+
var cache = createRowsInternalCache({
|
|
102
102
|
rows: rows,
|
|
103
103
|
getRowId: props.getRowId,
|
|
104
104
|
loading: props.loading,
|
|
105
105
|
rowCount: props.rowCount
|
|
106
|
-
})
|
|
107
|
-
|
|
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]);
|
|
108
111
|
var updateRows = React.useCallback(function (updates) {
|
|
109
112
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
110
113
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
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());
|
|
@@ -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
|
|
@@ -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", "searchPredicate"];
|
|
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';
|
|
@@ -77,7 +77,8 @@ function GridColumnsPanel(props) {
|
|
|
77
77
|
|
|
78
78
|
const {
|
|
79
79
|
sort,
|
|
80
|
-
searchPredicate = defaultSearchPredicate
|
|
80
|
+
searchPredicate = defaultSearchPredicate,
|
|
81
|
+
autoFocusSearchField = true
|
|
81
82
|
} = props,
|
|
82
83
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
83
84
|
|
|
@@ -133,9 +134,25 @@ function GridColumnsPanel(props) {
|
|
|
133
134
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
134
135
|
return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
|
|
135
136
|
}, [sortedColumns, searchValue, searchPredicate]);
|
|
137
|
+
const firstSwitchRef = React.useRef(null);
|
|
136
138
|
React.useEffect(() => {
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
|
|
139
156
|
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
140
157
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
141
158
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
@@ -158,7 +175,8 @@ function GridColumnsPanel(props) {
|
|
|
158
175
|
checked: columnVisibilityModel[column.field] !== false,
|
|
159
176
|
onClick: toggleColumn,
|
|
160
177
|
name: column.field,
|
|
161
|
-
size: "small"
|
|
178
|
+
size: "small",
|
|
179
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
162
180
|
}, rootProps.componentsProps?.baseSwitch)),
|
|
163
181
|
label: column.headerName || column.field
|
|
164
182
|
}), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
|
|
@@ -190,6 +208,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
190
208
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
191
209
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
192
210
|
// ----------------------------------------------------------------------
|
|
211
|
+
autoFocusSearchField: PropTypes.bool,
|
|
193
212
|
searchPredicate: PropTypes.func,
|
|
194
213
|
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
195
214
|
} : void 0;
|
|
@@ -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]);
|
|
@@ -88,13 +88,16 @@ export const useGridRows = (apiRef, props) => {
|
|
|
88
88
|
|
|
89
89
|
const setRows = React.useCallback(rows => {
|
|
90
90
|
logger.debug(`Updating all rows, new length ${rows.length}`);
|
|
91
|
-
|
|
91
|
+
const cache = createRowsInternalCache({
|
|
92
92
|
rows,
|
|
93
93
|
getRowId: props.getRowId,
|
|
94
94
|
loading: props.loading,
|
|
95
95
|
rowCount: props.rowCount
|
|
96
|
-
})
|
|
97
|
-
|
|
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]);
|
|
98
101
|
const updateRows = React.useCallback(updates => {
|
|
99
102
|
if (props.signature === GridSignature.DataGrid && updates.length > 1) {
|
|
100
103
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
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
|
|
@@ -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
|
};
|
|
@@ -744,7 +744,7 @@ DataGridRaw.propTypes = {
|
|
|
744
744
|
/**
|
|
745
745
|
* Set of rows of type [[GridRowsProp]].
|
|
746
746
|
*/
|
|
747
|
-
rows: _propTypes.default.
|
|
747
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
748
748
|
|
|
749
749
|
/**
|
|
750
750
|
* Sets the type of space between rows added by `getRowSpacing`.
|
|
@@ -285,7 +285,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
|
|
|
285
285
|
/**
|
|
286
286
|
* The row model of the row that the current cell belongs to.
|
|
287
287
|
*/
|
|
288
|
-
row: _propTypes.default.
|
|
288
|
+
row: _propTypes.default.any.isRequired,
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
291
|
* The node of the row that the current cell belongs to.
|
|
@@ -131,7 +131,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
131
131
|
/**
|
|
132
132
|
* The row model of the row that the current cell belongs to.
|
|
133
133
|
*/
|
|
134
|
-
row: _propTypes.default.
|
|
134
|
+
row: _propTypes.default.any.isRequired,
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* The node of the row that the current cell belongs to.
|
|
@@ -173,7 +173,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
173
173
|
/**
|
|
174
174
|
* The row model of the row that the current cell belongs to.
|
|
175
175
|
*/
|
|
176
|
-
row: _propTypes.default.
|
|
176
|
+
row: _propTypes.default.any.isRequired,
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* The node of the row that the current cell belongs to.
|
|
@@ -229,7 +229,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
229
229
|
/**
|
|
230
230
|
* The row model of the row that the current cell belongs to.
|
|
231
231
|
*/
|
|
232
|
-
row: _propTypes.default.
|
|
232
|
+
row: _propTypes.default.any.isRequired,
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* The node of the row that the current cell belongs to.
|
|
@@ -205,7 +205,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
205
205
|
/**
|
|
206
206
|
* The row model of the row that the current cell belongs to.
|
|
207
207
|
*/
|
|
208
|
-
row: _propTypes.default.
|
|
208
|
+
row: _propTypes.default.any,
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
211
|
* The node of the row that the current cell belongs to.
|
|
@@ -276,7 +276,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
276
276
|
/**
|
|
277
277
|
* The row model of the row that the current cell belongs to.
|
|
278
278
|
*/
|
|
279
|
-
row: _propTypes.default.
|
|
279
|
+
row: _propTypes.default.any.isRequired,
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
282
|
* The node of the row that the current cell belongs to.
|
|
@@ -198,7 +198,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
198
198
|
/**
|
|
199
199
|
* The row model of the row that the current cell belongs to.
|
|
200
200
|
*/
|
|
201
|
-
row: _propTypes.default.
|
|
201
|
+
row: _propTypes.default.any.isRequired,
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* The node of the row that the current cell belongs to.
|
|
@@ -49,7 +49,7 @@ var _gridClasses = require("../../constants/gridClasses");
|
|
|
49
49
|
|
|
50
50
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
51
51
|
|
|
52
|
-
const _excluded = ["sort", "searchPredicate"];
|
|
52
|
+
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField"];
|
|
53
53
|
|
|
54
54
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
55
55
|
|
|
@@ -111,7 +111,8 @@ function GridColumnsPanel(props) {
|
|
|
111
111
|
const classes = useUtilityClasses(ownerState);
|
|
112
112
|
const {
|
|
113
113
|
sort,
|
|
114
|
-
searchPredicate = defaultSearchPredicate
|
|
114
|
+
searchPredicate = defaultSearchPredicate,
|
|
115
|
+
autoFocusSearchField = true
|
|
115
116
|
} = props,
|
|
116
117
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
117
118
|
const sortedColumns = React.useMemo(() => {
|
|
@@ -166,9 +167,25 @@ function GridColumnsPanel(props) {
|
|
|
166
167
|
const searchValueToCheck = searchValue.toLowerCase();
|
|
167
168
|
return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
|
|
168
169
|
}, [sortedColumns, searchValue, searchPredicate]);
|
|
170
|
+
const firstSwitchRef = React.useRef(null);
|
|
169
171
|
React.useEffect(() => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
if (autoFocusSearchField) {
|
|
173
|
+
searchInputRef.current.focus();
|
|
174
|
+
} else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
|
|
175
|
+
firstSwitchRef.current.focus();
|
|
176
|
+
}
|
|
177
|
+
}, [autoFocusSearchField]);
|
|
178
|
+
let firstHideableColumnFound = false;
|
|
179
|
+
|
|
180
|
+
const isFirstHideableColumn = column => {
|
|
181
|
+
if (firstHideableColumnFound === false && column.hideable !== false) {
|
|
182
|
+
firstHideableColumnFound = true;
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return false;
|
|
187
|
+
};
|
|
188
|
+
|
|
172
189
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelWrapper.GridPanelWrapper, (0, _extends2.default)({}, other, {
|
|
173
190
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelHeader.GridPanelHeader, {
|
|
174
191
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.components.BaseTextField, (0, _extends2.default)({
|
|
@@ -194,7 +211,8 @@ function GridColumnsPanel(props) {
|
|
|
194
211
|
checked: columnVisibilityModel[column.field] !== false,
|
|
195
212
|
onClick: toggleColumn,
|
|
196
213
|
name: column.field,
|
|
197
|
-
size: "small"
|
|
214
|
+
size: "small",
|
|
215
|
+
inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
|
|
198
216
|
}, (_rootProps$components2 = rootProps.componentsProps) == null ? void 0 : _rootProps$components2.baseSwitch)),
|
|
199
217
|
label: column.headerName || column.field
|
|
200
218
|
}), !rootProps.disableColumnReorder && _envConstants.GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridIconButtonRoot, {
|
|
@@ -227,6 +245,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
227
245
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
228
246
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
229
247
|
// ----------------------------------------------------------------------
|
|
248
|
+
autoFocusSearchField: _propTypes.default.bool,
|
|
230
249
|
searchPredicate: _propTypes.default.func,
|
|
231
250
|
sort: _propTypes.default.oneOf(['asc', 'desc'])
|
|
232
251
|
} : void 0;
|
|
@@ -13,6 +13,8 @@ var _useGridApiEventHandler = require("../utils/useGridApiEventHandler");
|
|
|
13
13
|
|
|
14
14
|
var _EventManager = require("../../utils/EventManager");
|
|
15
15
|
|
|
16
|
+
var _createSelector = require("../../utils/createSelector");
|
|
17
|
+
|
|
16
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
19
|
|
|
18
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -68,6 +70,7 @@ function useGridApiInitialization(inputApiRef, props) {
|
|
|
68
70
|
React.useEffect(() => {
|
|
69
71
|
const api = apiRef.current;
|
|
70
72
|
return () => {
|
|
73
|
+
(0, _createSelector.unstable_resetCreateSelectorCache)(api.instanceId);
|
|
71
74
|
api.publishEvent('unmount');
|
|
72
75
|
};
|
|
73
76
|
}, [apiRef]);
|
|
@@ -119,13 +119,16 @@ const useGridRows = (apiRef, props) => {
|
|
|
119
119
|
|
|
120
120
|
const setRows = React.useCallback(rows => {
|
|
121
121
|
logger.debug(`Updating all rows, new length ${rows.length}`);
|
|
122
|
-
|
|
122
|
+
const cache = (0, _gridRowsUtils.createRowsInternalCache)({
|
|
123
123
|
rows,
|
|
124
124
|
getRowId: props.getRowId,
|
|
125
125
|
loading: props.loading,
|
|
126
126
|
rowCount: props.rowCount
|
|
127
|
-
})
|
|
128
|
-
|
|
127
|
+
});
|
|
128
|
+
const prevCache = apiRef.current.unstable_caches.rows;
|
|
129
|
+
cache.rowsBeforePartialUpdates = prevCache.rowsBeforePartialUpdates;
|
|
130
|
+
throttledRowsChange(cache, true);
|
|
131
|
+
}, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
|
|
129
132
|
const updateRows = React.useCallback(updates => {
|
|
130
133
|
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && updates.length > 1) {
|
|
131
134
|
// TODO: Add test with direct call to `apiRef.current.updateRows` in DataGrid after enabling the `apiRef` on the free plan.
|
package/node/index.js
CHANGED
package/node/locales/bgBG.js
CHANGED
|
@@ -89,7 +89,7 @@ const bgBGGrid = {
|
|
|
89
89
|
// Rows selected footer text
|
|
90
90
|
footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} избрани редове` : `${count.toLocaleString()} избран ред`,
|
|
91
91
|
// Total row amount footer text
|
|
92
|
-
footerTotalRows: 'Общо
|
|
92
|
+
footerTotalRows: 'Общо Редове:',
|
|
93
93
|
// Total visible row amount footer text
|
|
94
94
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} от ${totalCount.toLocaleString()}`,
|
|
95
95
|
// Checkbox selection text
|
|
@@ -64,8 +64,14 @@ const createSelector = (...args) => {
|
|
|
64
64
|
|
|
65
65
|
exports.createSelector = createSelector;
|
|
66
66
|
|
|
67
|
-
const unstable_resetCreateSelectorCache =
|
|
68
|
-
|
|
67
|
+
const unstable_resetCreateSelectorCache = cacheKey => {
|
|
68
|
+
if (typeof cacheKey !== 'undefined') {
|
|
69
|
+
if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
|
|
70
|
+
delete cacheContainer.cache[cacheKey];
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
cacheContainer.cache = null;
|
|
74
|
+
}
|
|
69
75
|
};
|
|
70
76
|
|
|
71
77
|
exports.unstable_resetCreateSelectorCache = unstable_resetCreateSelectorCache;
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Selector, SelectorResultArray } from 'reselect';
|
|
3
|
+
declare type CacheKey = number | string;
|
|
3
4
|
export interface OutputSelector<State, Result> {
|
|
4
5
|
(apiRef: React.MutableRefObject<{
|
|
5
6
|
state: State;
|
|
@@ -18,5 +19,5 @@ declare type StateFromSelectorList<Selectors extends readonly any[]> = Selectors
|
|
|
18
19
|
declare type SelectorArgs<Selectors extends ReadonlyArray<Selector<any>>, Result> = [selectors: [...Selectors], combiner: (...args: SelectorResultArray<Selectors>) => Result] | [...Selectors, (...args: SelectorResultArray<Selectors>) => Result];
|
|
19
20
|
declare type CreateSelectorFunction = <Selectors extends ReadonlyArray<Selector<any>>, Result>(...items: SelectorArgs<Selectors, Result>) => OutputSelector<StateFromSelectorList<Selectors>, Result>;
|
|
20
21
|
export declare const createSelector: CreateSelectorFunction;
|
|
21
|
-
export declare const unstable_resetCreateSelectorCache: () => void;
|
|
22
|
+
export declare const unstable_resetCreateSelectorCache: (cacheKey?: CacheKey) => void;
|
|
22
23
|
export {};
|
package/utils/createSelector.js
CHANGED
|
@@ -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
|
};
|