@mui/x-data-grid 7.26.0 → 7.27.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 +62 -0
- package/DataGrid/DataGrid.js +6 -0
- package/DataGrid/useDataGridComponent.js +1 -1
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/hooks/features/pagination/useGridPaginationModel.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +44 -0
- package/hooks/utils/useGridNativeEventListener.d.ts +0 -1
- package/hooks/utils/useGridNativeEventListener.js +12 -22
- package/index.js +1 -1
- package/locales/plPL.js +31 -35
- package/locales/ukUA.js +9 -10
- package/models/props/DataGridProps.d.ts +6 -0
- package/modern/DataGrid/DataGrid.js +6 -0
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/constants/dataGridPropsDefaultValues.js +1 -0
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/modern/hooks/features/pagination/useGridPaginationModel.js +44 -0
- package/modern/hooks/utils/useGridNativeEventListener.js +12 -22
- package/modern/index.js +1 -1
- package/modern/locales/plPL.js +31 -35
- package/modern/locales/ukUA.js +9 -10
- package/node/DataGrid/DataGrid.js +6 -0
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/constants/dataGridPropsDefaultValues.js +1 -0
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/node/hooks/features/pagination/useGridPaginationModel.js +44 -0
- package/node/hooks/utils/useGridNativeEventListener.js +12 -23
- package/node/index.js +1 -1
- package/node/locales/plPL.js +31 -35
- package/node/locales/ukUA.js +9 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
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
|
+
## 7.27.0
|
|
7
|
+
|
|
8
|
+
_Feb 17, 2025_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- ⚡ Improve Data Grid Excel export serialization performance
|
|
13
|
+
- 🐞 Bugfixes
|
|
14
|
+
- 🌍 Improve Polish (pl-PL) and Ukrainian (uk-UA) locale on the Data Grid
|
|
15
|
+
|
|
16
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
17
|
+
@pawelkula, @Neonin.
|
|
18
|
+
Following are all team members who have contributed to this release:
|
|
19
|
+
@cherniavskii, @JCQuintas, @oliviertassinari, @arminmeh and @LukasTy
|
|
20
|
+
|
|
21
|
+
### Data Grid
|
|
22
|
+
|
|
23
|
+
#### `@mui/x-data-grid@7.27.0`
|
|
24
|
+
|
|
25
|
+
- [DataGrid] Add `resetPageOnSortFilter` prop that resets the page after sorting and filtering (#16580) @arminmeh
|
|
26
|
+
- [DataGrid] Avoid `undefined` value for pagination `rowCount` (#16558) @cherniavskii
|
|
27
|
+
- [l10n] Improve Polish (pl-PL) locale (#16594) @pawelkula
|
|
28
|
+
- [l10n] Improve Ukrainian (uk-UA) locale (#16593) @Neonin
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-pro@7.27.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid@7.27.0`.
|
|
33
|
+
|
|
34
|
+
#### `@mui/x-data-grid-premium@7.27.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
35
|
+
|
|
36
|
+
Same changes as in `@mui/x-data-grid-pro@7.27.0`, plus:
|
|
37
|
+
|
|
38
|
+
- [DataGridPremium] Fix Excel export Web Worker demo not working in dev mode (#16532) @cherniavskii
|
|
39
|
+
- [DataGridPremium] Improve Excel export serialization performance (#16545) @cherniavskii
|
|
40
|
+
- [DataGridPremium] Namespace Excel export worker (#16539) @oliviertassinari
|
|
41
|
+
|
|
42
|
+
### Date and Time Pickers
|
|
43
|
+
|
|
44
|
+
#### `@mui/x-date-pickers@7.27.0`
|
|
45
|
+
|
|
46
|
+
Internal changes.
|
|
47
|
+
|
|
48
|
+
#### `@mui/x-date-pickers-pro@7.27.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
49
|
+
|
|
50
|
+
Same changes as in `@mui/x-date-pickers@7.27.0`, plus:
|
|
51
|
+
|
|
52
|
+
- [DateRangePicker] Avoid unnecessary field section focusing (#16569) @LukasTy
|
|
53
|
+
|
|
54
|
+
### Charts
|
|
55
|
+
|
|
56
|
+
#### `@mui/x-charts@7.27.0`
|
|
57
|
+
|
|
58
|
+
Internal changes.
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-charts-pro@7.27.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
61
|
+
|
|
62
|
+
- [charts-pro] Fix automatic type overloads (#16579) @JCQuintas
|
|
63
|
+
|
|
64
|
+
### Core
|
|
65
|
+
|
|
66
|
+
- [test] Fix Data Grid data source error test on React 18 (#16565) @arminmeh
|
|
67
|
+
|
|
6
68
|
## 7.26.0
|
|
7
69
|
|
|
8
70
|
_Feb 7, 2025_
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -661,6 +661,12 @@ DataGridRaw.propTypes = {
|
|
|
661
661
|
* @returns {Promise<R> | R} The final values to update the row.
|
|
662
662
|
*/
|
|
663
663
|
processRowUpdate: PropTypes.func,
|
|
664
|
+
/**
|
|
665
|
+
* If `true`, the page is set to 0 after each sorting or filtering.
|
|
666
|
+
* This prop will be removed in the next major version and resetting the page will become the default behavior.
|
|
667
|
+
* @default false
|
|
668
|
+
*/
|
|
669
|
+
resetPageOnSortFilter: PropTypes.bool,
|
|
664
670
|
/**
|
|
665
671
|
* The milliseconds throttle delay for resizing the grid.
|
|
666
672
|
* @default 60
|
|
@@ -43,8 +43,8 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
43
43
|
*/
|
|
44
44
|
useGridInitializeState(rowSelectionStateInitializer, apiRef, props);
|
|
45
45
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
46
|
-
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
47
46
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
47
|
+
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
48
48
|
useGridInitializeState(editingStateInitializer, apiRef, props);
|
|
49
49
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
50
50
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
@@ -91,6 +91,6 @@ export const useGridClipboard = (apiRef, props) => {
|
|
|
91
91
|
apiRef.current.publishEvent('clipboardCopy', textToCopy);
|
|
92
92
|
}
|
|
93
93
|
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
94
|
-
useGridNativeEventListener(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
|
|
94
|
+
useGridNativeEventListener(apiRef, () => apiRef.current.rootElementRef.current, 'keydown', handleCopy);
|
|
95
95
|
useGridApiOptionHandler(apiRef, 'clipboardCopy', props.onClipboardCopy);
|
|
96
96
|
};
|
|
@@ -8,4 +8,4 @@ export declare const getDerivedPaginationModel: (paginationState: GridPagination
|
|
|
8
8
|
* @requires useGridFilter (state)
|
|
9
9
|
* @requires useGridDimensions (event) - can be after
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridPaginationModel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight">) => void;
|
|
11
|
+
export declare const useGridPaginationModel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight" | "resetPageOnSortFilter">) => void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { gridFilterModelSelector, gridFilterActiveItemsSelector } from "../filter/gridFilterSelector.js";
|
|
3
4
|
import { gridDensityFactorSelector } from "../density/index.js";
|
|
4
5
|
import { useGridLogger, useGridSelector, useGridApiMethod, useGridApiEventHandler } from "../../utils/index.js";
|
|
6
|
+
import { isDeepEqual, runIf } from "../../../utils/utils.js";
|
|
5
7
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
6
8
|
import { gridPageCountSelector, gridPaginationModelSelector } from "./gridPaginationSelector.js";
|
|
7
9
|
import { getPageCount, defaultPageSize, throwIfPageSizeExceedsTheLimit, getDefaultGridPaginationModel, getValidPage } from "./gridPaginationUtils.js";
|
|
@@ -31,6 +33,7 @@ export const getDerivedPaginationModel = (paginationState, signature, pagination
|
|
|
31
33
|
export const useGridPaginationModel = (apiRef, props) => {
|
|
32
34
|
const logger = useGridLogger(apiRef, 'useGridPaginationModel');
|
|
33
35
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
36
|
+
const previousFilterModel = React.useRef(gridFilterModelSelector(apiRef));
|
|
34
37
|
const rowHeight = Math.floor(props.rowHeight * densityFactor);
|
|
35
38
|
apiRef.current.registerControlState({
|
|
36
39
|
stateId: 'paginationModel',
|
|
@@ -143,14 +146,55 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
149
|
+
if (paginationModel.page === 0) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
146
152
|
const pageCount = gridPageCountSelector(apiRef);
|
|
147
153
|
if (paginationModel.page > pageCount - 1) {
|
|
148
154
|
apiRef.current.setPage(Math.max(0, pageCount - 1));
|
|
149
155
|
}
|
|
150
156
|
}, [apiRef]);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Goes to the first row of the grid
|
|
160
|
+
*/
|
|
161
|
+
const navigateToStart = React.useCallback(() => {
|
|
162
|
+
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
163
|
+
if (paginationModel.page !== 0) {
|
|
164
|
+
apiRef.current.setPage(0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// If the page was not changed it might be needed to scroll to the top
|
|
168
|
+
const scrollPosition = apiRef.current.getScrollPosition();
|
|
169
|
+
if (scrollPosition.top !== 0) {
|
|
170
|
+
apiRef.current.scroll({
|
|
171
|
+
top: 0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, [apiRef]);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Resets the page only if the active items or quick filter has changed from the last time.
|
|
178
|
+
* This is to avoid resetting the page when the filter model is changed
|
|
179
|
+
* because of and update of the operator from an item that does not have the value
|
|
180
|
+
* or reseting when the filter panel is just opened
|
|
181
|
+
*/
|
|
182
|
+
const handleFilterModelChange = React.useCallback(filterModel => {
|
|
183
|
+
const currentActiveFilters = _extends({}, filterModel, {
|
|
184
|
+
// replace items with the active items
|
|
185
|
+
items: gridFilterActiveItemsSelector(apiRef)
|
|
186
|
+
});
|
|
187
|
+
if (isDeepEqual(currentActiveFilters, previousFilterModel.current)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
previousFilterModel.current = currentActiveFilters;
|
|
191
|
+
navigateToStart();
|
|
192
|
+
}, [apiRef, navigateToStart]);
|
|
151
193
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
152
194
|
useGridApiEventHandler(apiRef, 'paginationModelChange', handlePaginationModelChange);
|
|
153
195
|
useGridApiEventHandler(apiRef, 'rowCountChange', handleRowCountChange);
|
|
196
|
+
useGridApiEventHandler(apiRef, 'sortModelChange', runIf(props.resetPageOnSortFilter, navigateToStart));
|
|
197
|
+
useGridApiEventHandler(apiRef, 'filterModelChange', runIf(props.resetPageOnSortFilter, handleFilterModelChange));
|
|
154
198
|
|
|
155
199
|
/**
|
|
156
200
|
* EFFECTS
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
3
2
|
import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
4
3
|
export declare const useGridNativeEventListener: <PrivateApi extends GridPrivateApiCommon, K extends keyof HTMLElementEventMap>(apiRef: RefObject<PrivateApi>, ref: React.RefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: (event: HTMLElementEventMap[K]) => any, options?: AddEventListenerOptions) => void;
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { isFunction } from "../../utils/utils.js";
|
|
3
1
|
import { useGridLogger } from "./useGridLogger.js";
|
|
2
|
+
import { useGridApiOptionHandler } from "./useGridApiEventHandler.js";
|
|
4
3
|
export const useGridNativeEventListener = (apiRef, ref, eventName, handler, options) => {
|
|
5
4
|
const logger = useGridLogger(apiRef, 'useNativeEventListener');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return handlerRef.current && handlerRef.current(event);
|
|
11
|
-
}, []);
|
|
12
|
-
React.useEffect(() => {
|
|
13
|
-
handlerRef.current = handler;
|
|
14
|
-
}, [handler]);
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (targetElement && eventName && !added) {
|
|
17
|
-
logger.debug(`Binding native ${eventName} event`);
|
|
18
|
-
targetElement.addEventListener(eventName, wrapHandler, options);
|
|
19
|
-
setAdded(true);
|
|
20
|
-
const unsubscribe = () => {
|
|
21
|
-
logger.debug(`Clearing native ${eventName} event`);
|
|
22
|
-
targetElement.removeEventListener(eventName, wrapHandler, options);
|
|
23
|
-
};
|
|
24
|
-
apiRef.current.subscribeEvent('unmount', unsubscribe);
|
|
5
|
+
useGridApiOptionHandler(apiRef, 'rootMount', () => {
|
|
6
|
+
const targetElement = typeof ref === 'function' ? ref() : ref.current;
|
|
7
|
+
if (!targetElement || !eventName || !handler) {
|
|
8
|
+
return undefined;
|
|
25
9
|
}
|
|
26
|
-
|
|
10
|
+
logger.debug(`Binding native ${eventName} event`);
|
|
11
|
+
targetElement.addEventListener(eventName, handler, options);
|
|
12
|
+
return () => {
|
|
13
|
+
logger.debug(`Clearing native ${eventName} event`);
|
|
14
|
+
targetElement.removeEventListener(eventName, handler, options);
|
|
15
|
+
};
|
|
16
|
+
});
|
|
27
17
|
};
|
package/index.js
CHANGED
package/locales/plPL.js
CHANGED
|
@@ -30,12 +30,11 @@ const plPLGrid = {
|
|
|
30
30
|
toolbarExportPrint: 'Drukuj',
|
|
31
31
|
toolbarExportExcel: 'Pobierz jako plik Excel',
|
|
32
32
|
// Columns management text
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
columnsManagementSearchTitle: 'Szukaj',
|
|
34
|
+
columnsManagementNoColumns: 'Brak kolumn',
|
|
35
|
+
columnsManagementShowHideAllText: 'Wyświetl/Ukryj wszystkie',
|
|
36
|
+
columnsManagementReset: 'Resetuj',
|
|
37
|
+
columnsManagementDeleteIconLabel: 'Wyczyść',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Dodaj filtr',
|
|
41
40
|
filterPanelRemoveAll: 'Usuń wszystkie',
|
|
@@ -63,13 +62,12 @@ const plPLGrid = {
|
|
|
63
62
|
filterOperatorIsEmpty: 'jest pusty',
|
|
64
63
|
filterOperatorIsNotEmpty: 'nie jest pusty',
|
|
65
64
|
filterOperatorIsAnyOf: 'jest jednym z',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
'filterOperator=': 'równa się',
|
|
66
|
+
'filterOperator!=': 'nie równa się',
|
|
67
|
+
'filterOperator>': 'większy niż',
|
|
68
|
+
'filterOperator>=': 'większy lub równy',
|
|
69
|
+
'filterOperator<': 'mniejszy niż',
|
|
70
|
+
'filterOperator<=': 'mniejszy lub równy',
|
|
73
71
|
// Header filter operators text
|
|
74
72
|
headerFilterOperatorContains: 'Zawiera',
|
|
75
73
|
// headerFilterOperatorDoesNotContain: 'Does not contain',
|
|
@@ -79,20 +77,19 @@ const plPLGrid = {
|
|
|
79
77
|
headerFilterOperatorEndsWith: 'Kończy się na',
|
|
80
78
|
// headerFilterOperatorIs: 'Is',
|
|
81
79
|
headerFilterOperatorNot: 'Niepuste',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
headerFilterOperatorAfter: 'Jest po',
|
|
81
|
+
headerFilterOperatorOnOrAfter: 'Jest w lub po',
|
|
82
|
+
headerFilterOperatorBefore: 'Jest przed',
|
|
83
|
+
headerFilterOperatorOnOrBefore: 'Jest w lub przed',
|
|
84
|
+
headerFilterOperatorIsEmpty: 'Jest pusty',
|
|
85
|
+
headerFilterOperatorIsNotEmpty: 'Nie jest pusty',
|
|
86
|
+
headerFilterOperatorIsAnyOf: 'Is any of',
|
|
87
|
+
'headerFilterOperator=': 'Równa się',
|
|
88
|
+
'headerFilterOperator!=': 'Nie równa się',
|
|
89
|
+
'headerFilterOperator>': 'Większy niż',
|
|
90
|
+
'headerFilterOperator>=': 'Większy lub równy',
|
|
91
|
+
'headerFilterOperator<': 'Mniejszy niż',
|
|
92
|
+
'headerFilterOperator<=': 'Mniejszy lub równy',
|
|
96
93
|
// Filter values text
|
|
97
94
|
filterValueAny: 'dowolny',
|
|
98
95
|
filterValueTrue: 'prawda',
|
|
@@ -144,14 +141,13 @@ const plPLGrid = {
|
|
|
144
141
|
expandDetailPanel: 'Rozwiń',
|
|
145
142
|
collapseDetailPanel: 'Zwiń',
|
|
146
143
|
// Row reordering text
|
|
147
|
-
rowReorderingHeaderName: 'Porządkowanie wierszy'
|
|
148
|
-
|
|
144
|
+
rowReorderingHeaderName: 'Porządkowanie wierszy',
|
|
149
145
|
// Aggregation
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
aggregationMenuItemHeader: 'Agregacja',
|
|
147
|
+
aggregationFunctionLabelSum: 'suma',
|
|
148
|
+
aggregationFunctionLabelAvg: 'średnia',
|
|
149
|
+
aggregationFunctionLabelMin: 'minimum',
|
|
150
|
+
aggregationFunctionLabelMax: 'maximum',
|
|
151
|
+
aggregationFunctionLabelSize: 'rozmiar'
|
|
156
152
|
};
|
|
157
153
|
export const plPL = getGridLocalization(plPLGrid, plPLCore);
|
package/locales/ukUA.js
CHANGED
|
@@ -45,12 +45,11 @@ const ukUAGrid = {
|
|
|
45
45
|
toolbarExportPrint: 'Друк',
|
|
46
46
|
toolbarExportExcel: 'Завантажити у форматі Excel',
|
|
47
47
|
// Columns management text
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
columnsManagementSearchTitle: 'Пошук',
|
|
49
|
+
columnsManagementNoColumns: 'Немає стовпців',
|
|
50
|
+
columnsManagementShowHideAllText: 'Показати/Приховати всі',
|
|
51
|
+
columnsManagementReset: 'Скинути',
|
|
52
|
+
columnsManagementDeleteIconLabel: 'Очистити',
|
|
54
53
|
// Filter panel text
|
|
55
54
|
filterPanelAddFilter: 'Додати фільтр',
|
|
56
55
|
filterPanelRemoveAll: 'Видалити всі',
|
|
@@ -64,9 +63,9 @@ const ukUAGrid = {
|
|
|
64
63
|
filterPanelInputPlaceholder: 'Значення фільтра',
|
|
65
64
|
// Filter operators text
|
|
66
65
|
filterOperatorContains: 'містить',
|
|
67
|
-
|
|
66
|
+
filterOperatorDoesNotContain: 'не містить',
|
|
68
67
|
filterOperatorEquals: 'дорівнює',
|
|
69
|
-
|
|
68
|
+
filterOperatorDoesNotEqual: 'не дорівнює',
|
|
70
69
|
filterOperatorStartsWith: 'починається з',
|
|
71
70
|
filterOperatorEndsWith: 'закінчується на',
|
|
72
71
|
filterOperatorIs: 'дорівнює',
|
|
@@ -86,9 +85,9 @@ const ukUAGrid = {
|
|
|
86
85
|
'filterOperator<=': '<=',
|
|
87
86
|
// Header filter operators text
|
|
88
87
|
headerFilterOperatorContains: 'Містить',
|
|
89
|
-
|
|
88
|
+
headerFilterOperatorDoesNotContain: 'Не містить',
|
|
90
89
|
headerFilterOperatorEquals: 'Дорівнює',
|
|
91
|
-
|
|
90
|
+
headerFilterOperatorDoesNotEqual: 'Не дорівнює',
|
|
92
91
|
headerFilterOperatorStartsWith: 'Починається з',
|
|
93
92
|
headerFilterOperatorEndsWith: 'Закінчується на',
|
|
94
93
|
headerFilterOperatorIs: 'Дорівнює',
|
|
@@ -267,6 +267,12 @@ export interface DataGridPropsWithDefaultValues<R extends GridValidRowModel = an
|
|
|
267
267
|
* @default "client"
|
|
268
268
|
*/
|
|
269
269
|
paginationMode: GridFeatureMode;
|
|
270
|
+
/**
|
|
271
|
+
* If `true`, the page is set to 0 after each sorting or filtering.
|
|
272
|
+
* This prop will be removed in the next major version and resetting the page will become the default behavior.
|
|
273
|
+
* @default false
|
|
274
|
+
*/
|
|
275
|
+
resetPageOnSortFilter: boolean;
|
|
270
276
|
/**
|
|
271
277
|
* Set of rows of type [[GridRowsProp]].
|
|
272
278
|
* @default []
|
|
@@ -661,6 +661,12 @@ DataGridRaw.propTypes = {
|
|
|
661
661
|
* @returns {Promise<R> | R} The final values to update the row.
|
|
662
662
|
*/
|
|
663
663
|
processRowUpdate: PropTypes.func,
|
|
664
|
+
/**
|
|
665
|
+
* If `true`, the page is set to 0 after each sorting or filtering.
|
|
666
|
+
* This prop will be removed in the next major version and resetting the page will become the default behavior.
|
|
667
|
+
* @default false
|
|
668
|
+
*/
|
|
669
|
+
resetPageOnSortFilter: PropTypes.bool,
|
|
664
670
|
/**
|
|
665
671
|
* The milliseconds throttle delay for resizing the grid.
|
|
666
672
|
* @default 60
|
|
@@ -43,8 +43,8 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
43
43
|
*/
|
|
44
44
|
useGridInitializeState(rowSelectionStateInitializer, apiRef, props);
|
|
45
45
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
46
|
-
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
47
46
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
47
|
+
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
48
48
|
useGridInitializeState(editingStateInitializer, apiRef, props);
|
|
49
49
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
50
50
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
@@ -91,6 +91,6 @@ export const useGridClipboard = (apiRef, props) => {
|
|
|
91
91
|
apiRef.current.publishEvent('clipboardCopy', textToCopy);
|
|
92
92
|
}
|
|
93
93
|
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
94
|
-
useGridNativeEventListener(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
|
|
94
|
+
useGridNativeEventListener(apiRef, () => apiRef.current.rootElementRef.current, 'keydown', handleCopy);
|
|
95
95
|
useGridApiOptionHandler(apiRef, 'clipboardCopy', props.onClipboardCopy);
|
|
96
96
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { gridFilterModelSelector, gridFilterActiveItemsSelector } from "../filter/gridFilterSelector.js";
|
|
3
4
|
import { gridDensityFactorSelector } from "../density/index.js";
|
|
4
5
|
import { useGridLogger, useGridSelector, useGridApiMethod, useGridApiEventHandler } from "../../utils/index.js";
|
|
6
|
+
import { isDeepEqual, runIf } from "../../../utils/utils.js";
|
|
5
7
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
6
8
|
import { gridPageCountSelector, gridPaginationModelSelector } from "./gridPaginationSelector.js";
|
|
7
9
|
import { getPageCount, defaultPageSize, throwIfPageSizeExceedsTheLimit, getDefaultGridPaginationModel, getValidPage } from "./gridPaginationUtils.js";
|
|
@@ -31,6 +33,7 @@ export const getDerivedPaginationModel = (paginationState, signature, pagination
|
|
|
31
33
|
export const useGridPaginationModel = (apiRef, props) => {
|
|
32
34
|
const logger = useGridLogger(apiRef, 'useGridPaginationModel');
|
|
33
35
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
36
|
+
const previousFilterModel = React.useRef(gridFilterModelSelector(apiRef));
|
|
34
37
|
const rowHeight = Math.floor(props.rowHeight * densityFactor);
|
|
35
38
|
apiRef.current.registerControlState({
|
|
36
39
|
stateId: 'paginationModel',
|
|
@@ -143,14 +146,55 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
149
|
+
if (paginationModel.page === 0) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
146
152
|
const pageCount = gridPageCountSelector(apiRef);
|
|
147
153
|
if (paginationModel.page > pageCount - 1) {
|
|
148
154
|
apiRef.current.setPage(Math.max(0, pageCount - 1));
|
|
149
155
|
}
|
|
150
156
|
}, [apiRef]);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Goes to the first row of the grid
|
|
160
|
+
*/
|
|
161
|
+
const navigateToStart = React.useCallback(() => {
|
|
162
|
+
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
163
|
+
if (paginationModel.page !== 0) {
|
|
164
|
+
apiRef.current.setPage(0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// If the page was not changed it might be needed to scroll to the top
|
|
168
|
+
const scrollPosition = apiRef.current.getScrollPosition();
|
|
169
|
+
if (scrollPosition.top !== 0) {
|
|
170
|
+
apiRef.current.scroll({
|
|
171
|
+
top: 0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, [apiRef]);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Resets the page only if the active items or quick filter has changed from the last time.
|
|
178
|
+
* This is to avoid resetting the page when the filter model is changed
|
|
179
|
+
* because of and update of the operator from an item that does not have the value
|
|
180
|
+
* or reseting when the filter panel is just opened
|
|
181
|
+
*/
|
|
182
|
+
const handleFilterModelChange = React.useCallback(filterModel => {
|
|
183
|
+
const currentActiveFilters = _extends({}, filterModel, {
|
|
184
|
+
// replace items with the active items
|
|
185
|
+
items: gridFilterActiveItemsSelector(apiRef)
|
|
186
|
+
});
|
|
187
|
+
if (isDeepEqual(currentActiveFilters, previousFilterModel.current)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
previousFilterModel.current = currentActiveFilters;
|
|
191
|
+
navigateToStart();
|
|
192
|
+
}, [apiRef, navigateToStart]);
|
|
151
193
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
152
194
|
useGridApiEventHandler(apiRef, 'paginationModelChange', handlePaginationModelChange);
|
|
153
195
|
useGridApiEventHandler(apiRef, 'rowCountChange', handleRowCountChange);
|
|
196
|
+
useGridApiEventHandler(apiRef, 'sortModelChange', runIf(props.resetPageOnSortFilter, navigateToStart));
|
|
197
|
+
useGridApiEventHandler(apiRef, 'filterModelChange', runIf(props.resetPageOnSortFilter, handleFilterModelChange));
|
|
154
198
|
|
|
155
199
|
/**
|
|
156
200
|
* EFFECTS
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { isFunction } from "../../utils/utils.js";
|
|
3
1
|
import { useGridLogger } from "./useGridLogger.js";
|
|
2
|
+
import { useGridApiOptionHandler } from "./useGridApiEventHandler.js";
|
|
4
3
|
export const useGridNativeEventListener = (apiRef, ref, eventName, handler, options) => {
|
|
5
4
|
const logger = useGridLogger(apiRef, 'useNativeEventListener');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return handlerRef.current && handlerRef.current(event);
|
|
11
|
-
}, []);
|
|
12
|
-
React.useEffect(() => {
|
|
13
|
-
handlerRef.current = handler;
|
|
14
|
-
}, [handler]);
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (targetElement && eventName && !added) {
|
|
17
|
-
logger.debug(`Binding native ${eventName} event`);
|
|
18
|
-
targetElement.addEventListener(eventName, wrapHandler, options);
|
|
19
|
-
setAdded(true);
|
|
20
|
-
const unsubscribe = () => {
|
|
21
|
-
logger.debug(`Clearing native ${eventName} event`);
|
|
22
|
-
targetElement.removeEventListener(eventName, wrapHandler, options);
|
|
23
|
-
};
|
|
24
|
-
apiRef.current.subscribeEvent('unmount', unsubscribe);
|
|
5
|
+
useGridApiOptionHandler(apiRef, 'rootMount', () => {
|
|
6
|
+
const targetElement = typeof ref === 'function' ? ref() : ref.current;
|
|
7
|
+
if (!targetElement || !eventName || !handler) {
|
|
8
|
+
return undefined;
|
|
25
9
|
}
|
|
26
|
-
|
|
10
|
+
logger.debug(`Binding native ${eventName} event`);
|
|
11
|
+
targetElement.addEventListener(eventName, handler, options);
|
|
12
|
+
return () => {
|
|
13
|
+
logger.debug(`Clearing native ${eventName} event`);
|
|
14
|
+
targetElement.removeEventListener(eventName, handler, options);
|
|
15
|
+
};
|
|
16
|
+
});
|
|
27
17
|
};
|
package/modern/index.js
CHANGED
package/modern/locales/plPL.js
CHANGED
|
@@ -30,12 +30,11 @@ const plPLGrid = {
|
|
|
30
30
|
toolbarExportPrint: 'Drukuj',
|
|
31
31
|
toolbarExportExcel: 'Pobierz jako plik Excel',
|
|
32
32
|
// Columns management text
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
columnsManagementSearchTitle: 'Szukaj',
|
|
34
|
+
columnsManagementNoColumns: 'Brak kolumn',
|
|
35
|
+
columnsManagementShowHideAllText: 'Wyświetl/Ukryj wszystkie',
|
|
36
|
+
columnsManagementReset: 'Resetuj',
|
|
37
|
+
columnsManagementDeleteIconLabel: 'Wyczyść',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Dodaj filtr',
|
|
41
40
|
filterPanelRemoveAll: 'Usuń wszystkie',
|
|
@@ -63,13 +62,12 @@ const plPLGrid = {
|
|
|
63
62
|
filterOperatorIsEmpty: 'jest pusty',
|
|
64
63
|
filterOperatorIsNotEmpty: 'nie jest pusty',
|
|
65
64
|
filterOperatorIsAnyOf: 'jest jednym z',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
'filterOperator=': 'równa się',
|
|
66
|
+
'filterOperator!=': 'nie równa się',
|
|
67
|
+
'filterOperator>': 'większy niż',
|
|
68
|
+
'filterOperator>=': 'większy lub równy',
|
|
69
|
+
'filterOperator<': 'mniejszy niż',
|
|
70
|
+
'filterOperator<=': 'mniejszy lub równy',
|
|
73
71
|
// Header filter operators text
|
|
74
72
|
headerFilterOperatorContains: 'Zawiera',
|
|
75
73
|
// headerFilterOperatorDoesNotContain: 'Does not contain',
|
|
@@ -79,20 +77,19 @@ const plPLGrid = {
|
|
|
79
77
|
headerFilterOperatorEndsWith: 'Kończy się na',
|
|
80
78
|
// headerFilterOperatorIs: 'Is',
|
|
81
79
|
headerFilterOperatorNot: 'Niepuste',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
headerFilterOperatorAfter: 'Jest po',
|
|
81
|
+
headerFilterOperatorOnOrAfter: 'Jest w lub po',
|
|
82
|
+
headerFilterOperatorBefore: 'Jest przed',
|
|
83
|
+
headerFilterOperatorOnOrBefore: 'Jest w lub przed',
|
|
84
|
+
headerFilterOperatorIsEmpty: 'Jest pusty',
|
|
85
|
+
headerFilterOperatorIsNotEmpty: 'Nie jest pusty',
|
|
86
|
+
headerFilterOperatorIsAnyOf: 'Is any of',
|
|
87
|
+
'headerFilterOperator=': 'Równa się',
|
|
88
|
+
'headerFilterOperator!=': 'Nie równa się',
|
|
89
|
+
'headerFilterOperator>': 'Większy niż',
|
|
90
|
+
'headerFilterOperator>=': 'Większy lub równy',
|
|
91
|
+
'headerFilterOperator<': 'Mniejszy niż',
|
|
92
|
+
'headerFilterOperator<=': 'Mniejszy lub równy',
|
|
96
93
|
// Filter values text
|
|
97
94
|
filterValueAny: 'dowolny',
|
|
98
95
|
filterValueTrue: 'prawda',
|
|
@@ -144,14 +141,13 @@ const plPLGrid = {
|
|
|
144
141
|
expandDetailPanel: 'Rozwiń',
|
|
145
142
|
collapseDetailPanel: 'Zwiń',
|
|
146
143
|
// Row reordering text
|
|
147
|
-
rowReorderingHeaderName: 'Porządkowanie wierszy'
|
|
148
|
-
|
|
144
|
+
rowReorderingHeaderName: 'Porządkowanie wierszy',
|
|
149
145
|
// Aggregation
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
146
|
+
aggregationMenuItemHeader: 'Agregacja',
|
|
147
|
+
aggregationFunctionLabelSum: 'suma',
|
|
148
|
+
aggregationFunctionLabelAvg: 'średnia',
|
|
149
|
+
aggregationFunctionLabelMin: 'minimum',
|
|
150
|
+
aggregationFunctionLabelMax: 'maximum',
|
|
151
|
+
aggregationFunctionLabelSize: 'rozmiar'
|
|
156
152
|
};
|
|
157
153
|
export const plPL = getGridLocalization(plPLGrid, plPLCore);
|
package/modern/locales/ukUA.js
CHANGED
|
@@ -45,12 +45,11 @@ const ukUAGrid = {
|
|
|
45
45
|
toolbarExportPrint: 'Друк',
|
|
46
46
|
toolbarExportExcel: 'Завантажити у форматі Excel',
|
|
47
47
|
// Columns management text
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
columnsManagementSearchTitle: 'Пошук',
|
|
49
|
+
columnsManagementNoColumns: 'Немає стовпців',
|
|
50
|
+
columnsManagementShowHideAllText: 'Показати/Приховати всі',
|
|
51
|
+
columnsManagementReset: 'Скинути',
|
|
52
|
+
columnsManagementDeleteIconLabel: 'Очистити',
|
|
54
53
|
// Filter panel text
|
|
55
54
|
filterPanelAddFilter: 'Додати фільтр',
|
|
56
55
|
filterPanelRemoveAll: 'Видалити всі',
|
|
@@ -64,9 +63,9 @@ const ukUAGrid = {
|
|
|
64
63
|
filterPanelInputPlaceholder: 'Значення фільтра',
|
|
65
64
|
// Filter operators text
|
|
66
65
|
filterOperatorContains: 'містить',
|
|
67
|
-
|
|
66
|
+
filterOperatorDoesNotContain: 'не містить',
|
|
68
67
|
filterOperatorEquals: 'дорівнює',
|
|
69
|
-
|
|
68
|
+
filterOperatorDoesNotEqual: 'не дорівнює',
|
|
70
69
|
filterOperatorStartsWith: 'починається з',
|
|
71
70
|
filterOperatorEndsWith: 'закінчується на',
|
|
72
71
|
filterOperatorIs: 'дорівнює',
|
|
@@ -86,9 +85,9 @@ const ukUAGrid = {
|
|
|
86
85
|
'filterOperator<=': '<=',
|
|
87
86
|
// Header filter operators text
|
|
88
87
|
headerFilterOperatorContains: 'Містить',
|
|
89
|
-
|
|
88
|
+
headerFilterOperatorDoesNotContain: 'Не містить',
|
|
90
89
|
headerFilterOperatorEquals: 'Дорівнює',
|
|
91
|
-
|
|
90
|
+
headerFilterOperatorDoesNotEqual: 'Не дорівнює',
|
|
92
91
|
headerFilterOperatorStartsWith: 'Починається з',
|
|
93
92
|
headerFilterOperatorEndsWith: 'Закінчується на',
|
|
94
93
|
headerFilterOperatorIs: 'Дорівнює',
|
|
@@ -668,6 +668,12 @@ DataGridRaw.propTypes = {
|
|
|
668
668
|
* @returns {Promise<R> | R} The final values to update the row.
|
|
669
669
|
*/
|
|
670
670
|
processRowUpdate: _propTypes.default.func,
|
|
671
|
+
/**
|
|
672
|
+
* If `true`, the page is set to 0 after each sorting or filtering.
|
|
673
|
+
* This prop will be removed in the next major version and resetting the page will become the default behavior.
|
|
674
|
+
* @default false
|
|
675
|
+
*/
|
|
676
|
+
resetPageOnSortFilter: _propTypes.default.bool,
|
|
671
677
|
/**
|
|
672
678
|
* The milliseconds throttle delay for resizing the grid.
|
|
673
679
|
* @default 60
|
|
@@ -49,8 +49,8 @@ const useDataGridComponent = (inputApiRef, props) => {
|
|
|
49
49
|
*/
|
|
50
50
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridRowSelection.rowSelectionStateInitializer, apiRef, props);
|
|
51
51
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridColumns.columnsStateInitializer, apiRef, props);
|
|
52
|
-
(0, _useGridInitializeState.useGridInitializeState)(_useGridPagination.paginationStateInitializer, apiRef, props);
|
|
53
52
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridRows.rowsStateInitializer, apiRef, props);
|
|
53
|
+
(0, _useGridInitializeState.useGridInitializeState)(_useGridPagination.paginationStateInitializer, apiRef, props);
|
|
54
54
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridEditing.editingStateInitializer, apiRef, props);
|
|
55
55
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridFocus.focusStateInitializer, apiRef, props);
|
|
56
56
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridSorting.sortingStateInitializer, apiRef, props);
|
|
@@ -50,6 +50,7 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
|
|
|
50
50
|
pageSizeOptions: [25, 50, 100],
|
|
51
51
|
pagination: false,
|
|
52
52
|
paginationMode: 'client',
|
|
53
|
+
resetPageOnSortFilter: false,
|
|
53
54
|
resizeThrottleMs: 60,
|
|
54
55
|
rowBufferPx: 150,
|
|
55
56
|
rowHeight: 52,
|
|
@@ -98,7 +98,7 @@ const useGridClipboard = (apiRef, props) => {
|
|
|
98
98
|
apiRef.current.publishEvent('clipboardCopy', textToCopy);
|
|
99
99
|
}
|
|
100
100
|
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
101
|
-
(0, _utils.useGridNativeEventListener)(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
|
|
101
|
+
(0, _utils.useGridNativeEventListener)(apiRef, () => apiRef.current.rootElementRef.current, 'keydown', handleCopy);
|
|
102
102
|
(0, _utils.useGridApiOptionHandler)(apiRef, 'clipboardCopy', props.onClipboardCopy);
|
|
103
103
|
};
|
|
104
104
|
exports.useGridClipboard = useGridClipboard;
|
|
@@ -8,8 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useGridPaginationModel = exports.getDerivedPaginationModel = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
11
12
|
var _density = require("../density");
|
|
12
13
|
var _utils = require("../../utils");
|
|
14
|
+
var _utils2 = require("../../../utils/utils");
|
|
13
15
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
14
16
|
var _gridPaginationSelector = require("./gridPaginationSelector");
|
|
15
17
|
var _gridPaginationUtils = require("./gridPaginationUtils");
|
|
@@ -40,6 +42,7 @@ exports.getDerivedPaginationModel = getDerivedPaginationModel;
|
|
|
40
42
|
const useGridPaginationModel = (apiRef, props) => {
|
|
41
43
|
const logger = (0, _utils.useGridLogger)(apiRef, 'useGridPaginationModel');
|
|
42
44
|
const densityFactor = (0, _utils.useGridSelector)(apiRef, _density.gridDensityFactorSelector);
|
|
45
|
+
const previousFilterModel = React.useRef((0, _gridFilterSelector.gridFilterModelSelector)(apiRef));
|
|
43
46
|
const rowHeight = Math.floor(props.rowHeight * densityFactor);
|
|
44
47
|
apiRef.current.registerControlState({
|
|
45
48
|
stateId: 'paginationModel',
|
|
@@ -152,14 +155,55 @@ const useGridPaginationModel = (apiRef, props) => {
|
|
|
152
155
|
return;
|
|
153
156
|
}
|
|
154
157
|
const paginationModel = (0, _gridPaginationSelector.gridPaginationModelSelector)(apiRef);
|
|
158
|
+
if (paginationModel.page === 0) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
155
161
|
const pageCount = (0, _gridPaginationSelector.gridPageCountSelector)(apiRef);
|
|
156
162
|
if (paginationModel.page > pageCount - 1) {
|
|
157
163
|
apiRef.current.setPage(Math.max(0, pageCount - 1));
|
|
158
164
|
}
|
|
159
165
|
}, [apiRef]);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Goes to the first row of the grid
|
|
169
|
+
*/
|
|
170
|
+
const navigateToStart = React.useCallback(() => {
|
|
171
|
+
const paginationModel = (0, _gridPaginationSelector.gridPaginationModelSelector)(apiRef);
|
|
172
|
+
if (paginationModel.page !== 0) {
|
|
173
|
+
apiRef.current.setPage(0);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// If the page was not changed it might be needed to scroll to the top
|
|
177
|
+
const scrollPosition = apiRef.current.getScrollPosition();
|
|
178
|
+
if (scrollPosition.top !== 0) {
|
|
179
|
+
apiRef.current.scroll({
|
|
180
|
+
top: 0
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}, [apiRef]);
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Resets the page only if the active items or quick filter has changed from the last time.
|
|
187
|
+
* This is to avoid resetting the page when the filter model is changed
|
|
188
|
+
* because of and update of the operator from an item that does not have the value
|
|
189
|
+
* or reseting when the filter panel is just opened
|
|
190
|
+
*/
|
|
191
|
+
const handleFilterModelChange = React.useCallback(filterModel => {
|
|
192
|
+
const currentActiveFilters = (0, _extends2.default)({}, filterModel, {
|
|
193
|
+
// replace items with the active items
|
|
194
|
+
items: (0, _gridFilterSelector.gridFilterActiveItemsSelector)(apiRef)
|
|
195
|
+
});
|
|
196
|
+
if ((0, _utils2.isDeepEqual)(currentActiveFilters, previousFilterModel.current)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
previousFilterModel.current = currentActiveFilters;
|
|
200
|
+
navigateToStart();
|
|
201
|
+
}, [apiRef, navigateToStart]);
|
|
160
202
|
(0, _utils.useGridApiEventHandler)(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
161
203
|
(0, _utils.useGridApiEventHandler)(apiRef, 'paginationModelChange', handlePaginationModelChange);
|
|
162
204
|
(0, _utils.useGridApiEventHandler)(apiRef, 'rowCountChange', handleRowCountChange);
|
|
205
|
+
(0, _utils.useGridApiEventHandler)(apiRef, 'sortModelChange', (0, _utils2.runIf)(props.resetPageOnSortFilter, navigateToStart));
|
|
206
|
+
(0, _utils.useGridApiEventHandler)(apiRef, 'filterModelChange', (0, _utils2.runIf)(props.resetPageOnSortFilter, handleFilterModelChange));
|
|
163
207
|
|
|
164
208
|
/**
|
|
165
209
|
* EFFECTS
|
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.useGridNativeEventListener = void 0;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _utils = require("../../utils/utils");
|
|
10
7
|
var _useGridLogger = require("./useGridLogger");
|
|
8
|
+
var _useGridApiEventHandler = require("./useGridApiEventHandler");
|
|
11
9
|
const useGridNativeEventListener = (apiRef, ref, eventName, handler, options) => {
|
|
12
10
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useNativeEventListener');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return handlerRef.current && handlerRef.current(event);
|
|
18
|
-
}, []);
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
handlerRef.current = handler;
|
|
21
|
-
}, [handler]);
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
if (targetElement && eventName && !added) {
|
|
24
|
-
logger.debug(`Binding native ${eventName} event`);
|
|
25
|
-
targetElement.addEventListener(eventName, wrapHandler, options);
|
|
26
|
-
setAdded(true);
|
|
27
|
-
const unsubscribe = () => {
|
|
28
|
-
logger.debug(`Clearing native ${eventName} event`);
|
|
29
|
-
targetElement.removeEventListener(eventName, wrapHandler, options);
|
|
30
|
-
};
|
|
31
|
-
apiRef.current.subscribeEvent('unmount', unsubscribe);
|
|
11
|
+
(0, _useGridApiEventHandler.useGridApiOptionHandler)(apiRef, 'rootMount', () => {
|
|
12
|
+
const targetElement = typeof ref === 'function' ? ref() : ref.current;
|
|
13
|
+
if (!targetElement || !eventName || !handler) {
|
|
14
|
+
return undefined;
|
|
32
15
|
}
|
|
33
|
-
|
|
16
|
+
logger.debug(`Binding native ${eventName} event`);
|
|
17
|
+
targetElement.addEventListener(eventName, handler, options);
|
|
18
|
+
return () => {
|
|
19
|
+
logger.debug(`Clearing native ${eventName} event`);
|
|
20
|
+
targetElement.removeEventListener(eventName, handler, options);
|
|
21
|
+
};
|
|
22
|
+
});
|
|
34
23
|
};
|
|
35
24
|
exports.useGridNativeEventListener = useGridNativeEventListener;
|
package/node/index.js
CHANGED
package/node/locales/plPL.js
CHANGED
|
@@ -36,12 +36,11 @@ const plPLGrid = {
|
|
|
36
36
|
toolbarExportPrint: 'Drukuj',
|
|
37
37
|
toolbarExportExcel: 'Pobierz jako plik Excel',
|
|
38
38
|
// Columns management text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
columnsManagementSearchTitle: 'Szukaj',
|
|
40
|
+
columnsManagementNoColumns: 'Brak kolumn',
|
|
41
|
+
columnsManagementShowHideAllText: 'Wyświetl/Ukryj wszystkie',
|
|
42
|
+
columnsManagementReset: 'Resetuj',
|
|
43
|
+
columnsManagementDeleteIconLabel: 'Wyczyść',
|
|
45
44
|
// Filter panel text
|
|
46
45
|
filterPanelAddFilter: 'Dodaj filtr',
|
|
47
46
|
filterPanelRemoveAll: 'Usuń wszystkie',
|
|
@@ -69,13 +68,12 @@ const plPLGrid = {
|
|
|
69
68
|
filterOperatorIsEmpty: 'jest pusty',
|
|
70
69
|
filterOperatorIsNotEmpty: 'nie jest pusty',
|
|
71
70
|
filterOperatorIsAnyOf: 'jest jednym z',
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
'filterOperator=': 'równa się',
|
|
72
|
+
'filterOperator!=': 'nie równa się',
|
|
73
|
+
'filterOperator>': 'większy niż',
|
|
74
|
+
'filterOperator>=': 'większy lub równy',
|
|
75
|
+
'filterOperator<': 'mniejszy niż',
|
|
76
|
+
'filterOperator<=': 'mniejszy lub równy',
|
|
79
77
|
// Header filter operators text
|
|
80
78
|
headerFilterOperatorContains: 'Zawiera',
|
|
81
79
|
// headerFilterOperatorDoesNotContain: 'Does not contain',
|
|
@@ -85,20 +83,19 @@ const plPLGrid = {
|
|
|
85
83
|
headerFilterOperatorEndsWith: 'Kończy się na',
|
|
86
84
|
// headerFilterOperatorIs: 'Is',
|
|
87
85
|
headerFilterOperatorNot: 'Niepuste',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
headerFilterOperatorAfter: 'Jest po',
|
|
87
|
+
headerFilterOperatorOnOrAfter: 'Jest w lub po',
|
|
88
|
+
headerFilterOperatorBefore: 'Jest przed',
|
|
89
|
+
headerFilterOperatorOnOrBefore: 'Jest w lub przed',
|
|
90
|
+
headerFilterOperatorIsEmpty: 'Jest pusty',
|
|
91
|
+
headerFilterOperatorIsNotEmpty: 'Nie jest pusty',
|
|
92
|
+
headerFilterOperatorIsAnyOf: 'Is any of',
|
|
93
|
+
'headerFilterOperator=': 'Równa się',
|
|
94
|
+
'headerFilterOperator!=': 'Nie równa się',
|
|
95
|
+
'headerFilterOperator>': 'Większy niż',
|
|
96
|
+
'headerFilterOperator>=': 'Większy lub równy',
|
|
97
|
+
'headerFilterOperator<': 'Mniejszy niż',
|
|
98
|
+
'headerFilterOperator<=': 'Mniejszy lub równy',
|
|
102
99
|
// Filter values text
|
|
103
100
|
filterValueAny: 'dowolny',
|
|
104
101
|
filterValueTrue: 'prawda',
|
|
@@ -150,14 +147,13 @@ const plPLGrid = {
|
|
|
150
147
|
expandDetailPanel: 'Rozwiń',
|
|
151
148
|
collapseDetailPanel: 'Zwiń',
|
|
152
149
|
// Row reordering text
|
|
153
|
-
rowReorderingHeaderName: 'Porządkowanie wierszy'
|
|
154
|
-
|
|
150
|
+
rowReorderingHeaderName: 'Porządkowanie wierszy',
|
|
155
151
|
// Aggregation
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
aggregationMenuItemHeader: 'Agregacja',
|
|
153
|
+
aggregationFunctionLabelSum: 'suma',
|
|
154
|
+
aggregationFunctionLabelAvg: 'średnia',
|
|
155
|
+
aggregationFunctionLabelMin: 'minimum',
|
|
156
|
+
aggregationFunctionLabelMax: 'maximum',
|
|
157
|
+
aggregationFunctionLabelSize: 'rozmiar'
|
|
162
158
|
};
|
|
163
159
|
const plPL = exports.plPL = (0, _getGridLocalization.getGridLocalization)(plPLGrid, _locale.plPL);
|
package/node/locales/ukUA.js
CHANGED
|
@@ -51,12 +51,11 @@ const ukUAGrid = {
|
|
|
51
51
|
toolbarExportPrint: 'Друк',
|
|
52
52
|
toolbarExportExcel: 'Завантажити у форматі Excel',
|
|
53
53
|
// Columns management text
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
columnsManagementSearchTitle: 'Пошук',
|
|
55
|
+
columnsManagementNoColumns: 'Немає стовпців',
|
|
56
|
+
columnsManagementShowHideAllText: 'Показати/Приховати всі',
|
|
57
|
+
columnsManagementReset: 'Скинути',
|
|
58
|
+
columnsManagementDeleteIconLabel: 'Очистити',
|
|
60
59
|
// Filter panel text
|
|
61
60
|
filterPanelAddFilter: 'Додати фільтр',
|
|
62
61
|
filterPanelRemoveAll: 'Видалити всі',
|
|
@@ -70,9 +69,9 @@ const ukUAGrid = {
|
|
|
70
69
|
filterPanelInputPlaceholder: 'Значення фільтра',
|
|
71
70
|
// Filter operators text
|
|
72
71
|
filterOperatorContains: 'містить',
|
|
73
|
-
|
|
72
|
+
filterOperatorDoesNotContain: 'не містить',
|
|
74
73
|
filterOperatorEquals: 'дорівнює',
|
|
75
|
-
|
|
74
|
+
filterOperatorDoesNotEqual: 'не дорівнює',
|
|
76
75
|
filterOperatorStartsWith: 'починається з',
|
|
77
76
|
filterOperatorEndsWith: 'закінчується на',
|
|
78
77
|
filterOperatorIs: 'дорівнює',
|
|
@@ -92,9 +91,9 @@ const ukUAGrid = {
|
|
|
92
91
|
'filterOperator<=': '<=',
|
|
93
92
|
// Header filter operators text
|
|
94
93
|
headerFilterOperatorContains: 'Містить',
|
|
95
|
-
|
|
94
|
+
headerFilterOperatorDoesNotContain: 'Не містить',
|
|
96
95
|
headerFilterOperatorEquals: 'Дорівнює',
|
|
97
|
-
|
|
96
|
+
headerFilterOperatorDoesNotEqual: 'Не дорівнює',
|
|
98
97
|
headerFilterOperatorStartsWith: 'Починається з',
|
|
99
98
|
headerFilterOperatorEndsWith: 'Закінчується на',
|
|
100
99
|
headerFilterOperatorIs: 'Дорівнює',
|