@mui/x-data-grid 6.7.0 → 6.8.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 +77 -15
- package/components/GridColumnHeaders.d.ts +2 -2
- package/components/GridColumnHeaders.js +3 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +23 -69
- package/components/cell/GridCell.d.ts +24 -15
- package/components/cell/GridCell.js +422 -45
- package/components/cell/index.d.ts +2 -1
- package/components/cell/index.js +1 -1
- package/components/containers/GridRootStyles.js +30 -16
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/virtualization/GridVirtualScroller.js +4 -9
- package/components/virtualization/GridVirtualScrollerContent.js +11 -20
- package/constants/defaultGridSlotsComponents.js +6 -2
- package/hooks/core/useGridApiInitialization.js +4 -1
- package/hooks/core/useGridStateInitialization.js +2 -9
- package/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -3
- package/hooks/features/editing/useGridRowEditing.js +14 -6
- package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
- package/hooks/features/filter/gridFilterUtils.js +19 -13
- package/hooks/features/filter/useGridFilter.js +2 -1
- package/hooks/features/focus/useGridFocus.js +9 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
- package/hooks/features/rows/useGridParamsApi.js +7 -15
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
- package/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/useGridSelector.d.ts +3 -1
- package/hooks/utils/useGridSelector.js +37 -6
- package/hooks/utils/useLazyRef.d.ts +2 -0
- package/hooks/utils/useLazyRef.js +9 -0
- package/hooks/utils/useOnMount.d.ts +2 -0
- package/hooks/utils/useOnMount.js +7 -0
- package/index.js +1 -1
- package/legacy/components/GridColumnHeaders.js +3 -1
- package/legacy/components/GridRow.js +25 -69
- package/legacy/components/cell/GridCell.js +425 -46
- package/legacy/components/cell/index.js +1 -1
- package/legacy/components/containers/GridRootStyles.js +20 -17
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/legacy/components/toolbar/GridToolbar.js +2 -2
- package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
- package/legacy/constants/defaultGridSlotsComponents.js +6 -2
- package/legacy/hooks/core/useGridApiInitialization.js +4 -1
- package/legacy/hooks/core/useGridStateInitialization.js +2 -7
- package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
- package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
- package/legacy/hooks/features/filter/useGridFilter.js +2 -1
- package/legacy/hooks/features/focus/useGridFocus.js +9 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +38 -34
- package/legacy/hooks/utils/index.js +1 -1
- package/legacy/hooks/utils/useGridSelector.js +43 -5
- package/legacy/hooks/utils/useLazyRef.js +9 -0
- package/legacy/hooks/utils/useOnMount.js +7 -0
- package/legacy/index.js +1 -1
- package/legacy/locales/elGR.js +70 -79
- package/legacy/utils/Store.js +34 -0
- package/legacy/utils/doesSupportPreventScroll.js +13 -0
- package/legacy/utils/fastMemo.js +5 -0
- package/legacy/utils/fastObjectShallowCompare.js +32 -0
- package/legacy/utils/keyboardUtils.js +4 -2
- package/locales/elGR.js +66 -79
- package/models/api/gridCoreApi.d.ts +6 -0
- package/models/colDef/gridColDef.d.ts +4 -3
- package/models/colDef/gridColType.d.ts +3 -1
- package/models/events/gridEventLookup.d.ts +3 -3
- package/modern/components/GridColumnHeaders.js +3 -1
- package/modern/components/GridRow.js +22 -69
- package/modern/components/cell/GridCell.js +421 -45
- package/modern/components/cell/index.js +1 -1
- package/modern/components/containers/GridRootStyles.js +30 -16
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/virtualization/GridVirtualScroller.js +4 -9
- package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/modern/constants/defaultGridSlotsComponents.js +6 -2
- package/modern/hooks/core/useGridApiInitialization.js +4 -1
- package/modern/hooks/core/useGridStateInitialization.js +2 -9
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
- package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
- package/modern/hooks/features/filter/useGridFilter.js +2 -1
- package/modern/hooks/features/focus/useGridFocus.js +8 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
- package/modern/hooks/utils/index.js +1 -1
- package/modern/hooks/utils/useGridSelector.js +37 -6
- package/modern/hooks/utils/useLazyRef.js +9 -0
- package/modern/hooks/utils/useOnMount.js +7 -0
- package/modern/index.js +1 -1
- package/modern/locales/elGR.js +66 -79
- package/modern/utils/Store.js +24 -0
- package/modern/utils/doesSupportPreventScroll.js +13 -0
- package/modern/utils/fastMemo.js +5 -0
- package/modern/utils/fastObjectShallowCompare.js +32 -0
- package/modern/utils/keyboardUtils.js +4 -2
- package/node/components/GridColumnHeaders.js +4 -2
- package/node/components/GridRow.js +22 -69
- package/node/components/cell/GridCell.js +424 -47
- package/node/components/cell/index.js +17 -10
- package/node/components/containers/GridRootStyles.js +30 -16
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/node/components/toolbar/GridToolbar.js +2 -2
- package/node/components/virtualization/GridVirtualScroller.js +4 -9
- package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/node/constants/defaultGridSlotsComponents.js +4 -1
- package/node/hooks/core/useGridApiInitialization.js +4 -1
- package/node/hooks/core/useGridStateInitialization.js +2 -9
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
- package/node/hooks/features/editing/useGridCellEditing.js +5 -3
- package/node/hooks/features/editing/useGridRowEditing.js +14 -6
- package/node/hooks/features/filter/gridFilterUtils.js +17 -12
- package/node/hooks/features/filter/useGridFilter.js +2 -1
- package/node/hooks/features/focus/useGridFocus.js +8 -4
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/node/hooks/features/rows/useGridParamsApi.js +9 -15
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
- package/node/hooks/utils/index.js +14 -10
- package/node/hooks/utils/useGridSelector.js +41 -7
- package/node/hooks/utils/useLazyRef.js +17 -0
- package/node/hooks/utils/useOnMount.js +15 -0
- package/node/index.js +1 -1
- package/node/locales/elGR.js +66 -79
- package/node/utils/Store.js +31 -0
- package/node/utils/doesSupportPreventScroll.js +19 -0
- package/node/utils/fastMemo.js +13 -0
- package/node/utils/fastObjectShallowCompare.js +38 -0
- package/node/utils/keyboardUtils.js +4 -2
- package/package.json +1 -1
- package/utils/Store.d.ts +11 -0
- package/utils/Store.js +24 -0
- package/utils/doesSupportPreventScroll.d.ts +1 -0
- package/utils/doesSupportPreventScroll.js +13 -0
- package/utils/fastMemo.d.ts +1 -0
- package/utils/fastMemo.js +5 -0
- package/utils/fastObjectShallowCompare.d.ts +1 -0
- package/utils/fastObjectShallowCompare.js +32 -0
- package/utils/keyboardUtils.js +4 -2
|
@@ -1,16 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLazyRef } from './useLazyRef';
|
|
3
|
+
import { useOnMount } from './useOnMount';
|
|
1
4
|
import { buildWarning } from '../../utils/warning';
|
|
5
|
+
import { fastObjectShallowCompare } from '../../utils/fastObjectShallowCompare';
|
|
6
|
+
const stateNotInitializedWarning = buildWarning(['MUI: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
|
|
2
7
|
function isOutputSelector(selector) {
|
|
3
8
|
return selector.acceptsApiRef;
|
|
4
9
|
}
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
function applySelector(apiRef, selector) {
|
|
11
|
+
if (isOutputSelector(selector)) {
|
|
12
|
+
return selector(apiRef);
|
|
13
|
+
}
|
|
14
|
+
return selector(apiRef.current.state);
|
|
15
|
+
}
|
|
16
|
+
const defaultCompare = Object.is;
|
|
17
|
+
export const objectShallowCompare = fastObjectShallowCompare;
|
|
18
|
+
const createRefs = () => ({
|
|
19
|
+
state: null,
|
|
20
|
+
equals: null,
|
|
21
|
+
selector: null
|
|
22
|
+
});
|
|
23
|
+
export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
7
24
|
if (process.env.NODE_ENV !== 'production') {
|
|
8
25
|
if (!apiRef.current.state) {
|
|
9
26
|
stateNotInitializedWarning();
|
|
10
27
|
}
|
|
11
28
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
const refs = useLazyRef(createRefs);
|
|
30
|
+
const didInit = refs.current.selector !== null;
|
|
31
|
+
const [state, setState] = React.useState(
|
|
32
|
+
// We don't use an initialization function to avoid allocations
|
|
33
|
+
didInit ? null : applySelector(apiRef, selector));
|
|
34
|
+
refs.current.state = state;
|
|
35
|
+
refs.current.equals = equals;
|
|
36
|
+
refs.current.selector = selector;
|
|
37
|
+
useOnMount(() => {
|
|
38
|
+
return apiRef.current.store.subscribe(() => {
|
|
39
|
+
const newState = applySelector(apiRef, refs.current.selector);
|
|
40
|
+
if (!refs.current.equals(refs.current.state, newState)) {
|
|
41
|
+
refs.current.state = newState;
|
|
42
|
+
setState(newState);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return state;
|
|
16
47
|
};
|
package/modern/index.js
CHANGED
package/modern/locales/elGR.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { elGR as elGRCore } from '@mui/material/locale';
|
|
1
2
|
import { getGridLocalization } from '../utils/getGridLocalization';
|
|
2
3
|
const elGRGrid = {
|
|
3
4
|
// Root
|
|
@@ -19,17 +20,15 @@ const elGRGrid = {
|
|
|
19
20
|
toolbarFiltersTooltipShow: 'Εμφάνιση φίλτρων',
|
|
20
21
|
toolbarFiltersTooltipActive: count => count !== 1 ? `${count} ενεργά φίλτρα` : `${count} ενεργό φίλτρο`,
|
|
21
22
|
// Quick filter toolbar field
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
toolbarQuickFilterPlaceholder: 'Αναζήτηση…',
|
|
24
|
+
toolbarQuickFilterLabel: 'Αναζήτηση',
|
|
25
|
+
toolbarQuickFilterDeleteIconLabel: 'Καθαρισμός',
|
|
26
26
|
// Export selector toolbar button text
|
|
27
27
|
toolbarExport: 'Εξαγωγή',
|
|
28
28
|
toolbarExportLabel: 'Εξαγωγή',
|
|
29
29
|
toolbarExportCSV: 'Λήψη ως CSV',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
toolbarExportPrint: 'Εκτύπωση',
|
|
31
|
+
toolbarExportExcel: 'Λήψη ως Excel',
|
|
33
32
|
// Columns panel text
|
|
34
33
|
columnsPanelTextFieldLabel: 'Εύρεση στήλης',
|
|
35
34
|
columnsPanelTextFieldPlaceholder: 'Επικεφαλίδα στήλης',
|
|
@@ -38,9 +37,9 @@ const elGRGrid = {
|
|
|
38
37
|
columnsPanelHideAllButton: 'Απόκρυψη όλων',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Προσθήκη φίλτρου',
|
|
41
|
-
|
|
40
|
+
filterPanelRemoveAll: 'Αφαίρεση όλων',
|
|
42
41
|
filterPanelDeleteIconLabel: 'Διαγραφή',
|
|
43
|
-
|
|
42
|
+
filterPanelLogicOperator: 'Λογικός τελεστής',
|
|
44
43
|
filterPanelOperator: 'Τελεστές',
|
|
45
44
|
filterPanelOperatorAnd: 'Καί',
|
|
46
45
|
filterPanelOperatorOr: 'Ή',
|
|
@@ -60,44 +59,41 @@ const elGRGrid = {
|
|
|
60
59
|
filterOperatorOnOrBefore: 'είναι ίσο ή πριν',
|
|
61
60
|
filterOperatorIsEmpty: 'είναι κενό',
|
|
62
61
|
filterOperatorIsNotEmpty: 'δεν είναι κενό',
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
filterOperatorIsAnyOf: 'είναι οποιοδήποτε από',
|
|
63
|
+
'filterOperator=': '=',
|
|
64
|
+
'filterOperator!=': '!=',
|
|
65
|
+
'filterOperator>': '>',
|
|
66
|
+
'filterOperator>=': '>=',
|
|
67
|
+
'filterOperator<': '<',
|
|
68
|
+
'filterOperator<=': '<=',
|
|
71
69
|
// Header filter operators text
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
headerFilterOperatorContains: 'Περιέχει',
|
|
71
|
+
headerFilterOperatorEquals: 'Ισούται',
|
|
72
|
+
headerFilterOperatorStartsWith: 'Ξεκινάει με',
|
|
73
|
+
headerFilterOperatorEndsWith: 'Τελειώνει με',
|
|
74
|
+
headerFilterOperatorIs: 'Είναι',
|
|
75
|
+
headerFilterOperatorNot: 'Δεν είναι',
|
|
76
|
+
headerFilterOperatorAfter: 'Είναι μετά',
|
|
77
|
+
headerFilterOperatorOnOrAfter: 'Είναι ίσο ή μετά',
|
|
78
|
+
headerFilterOperatorBefore: 'Είναι πριν',
|
|
79
|
+
headerFilterOperatorOnOrBefore: 'Είναι ίσο ή πριν',
|
|
80
|
+
headerFilterOperatorIsEmpty: 'Είναι κενό',
|
|
81
|
+
headerFilterOperatorIsNotEmpty: 'Δεν είναι κενό',
|
|
82
|
+
headerFilterOperatorIsAnyOf: 'Είναι οποιοδήποτε από',
|
|
83
|
+
'headerFilterOperator=': 'Ισούται',
|
|
84
|
+
'headerFilterOperator!=': 'Δεν ισούται',
|
|
85
|
+
'headerFilterOperator>': 'Μεγαλύτερο από',
|
|
86
|
+
'headerFilterOperator>=': 'Μεγαλύτερο ή ίσο με',
|
|
87
|
+
'headerFilterOperator<': 'Μικρότερο από',
|
|
88
|
+
'headerFilterOperator<=': 'Μικρότερο ή ίσο με',
|
|
92
89
|
// Filter values text
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
filterValueAny: 'οποιοδήποτε',
|
|
91
|
+
filterValueTrue: 'αληθές',
|
|
92
|
+
filterValueFalse: 'ψευδές',
|
|
97
93
|
// Column menu text
|
|
98
94
|
columnMenuLabel: 'Μενού',
|
|
99
95
|
columnMenuShowColumns: 'Εμφάνιση στηλών',
|
|
100
|
-
|
|
96
|
+
columnMenuManageColumns: 'Διαχείριση στηλών',
|
|
101
97
|
columnMenuFilter: 'Φίλτρο',
|
|
102
98
|
columnMenuHideColumn: 'Απόκρυψη',
|
|
103
99
|
columnMenuUnsort: 'Απενεργοποίηση ταξινόμησης',
|
|
@@ -114,49 +110,40 @@ const elGRGrid = {
|
|
|
114
110
|
// Total visible row amount footer text
|
|
115
111
|
footerTotalVisibleRows: (visibleCount, totalCount) => `${visibleCount.toLocaleString()} από ${totalCount.toLocaleString()}`,
|
|
116
112
|
// Checkbox selection text
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
checkboxSelectionHeaderName: 'Επιλογή πλαισίου ελέγχου',
|
|
114
|
+
checkboxSelectionSelectAllRows: 'Επιλέξτε όλες τις σειρές',
|
|
115
|
+
checkboxSelectionUnselectAllRows: 'Καταργήση επιλογής όλων των σειρών',
|
|
116
|
+
checkboxSelectionSelectRow: 'Επιλογή γραμμής',
|
|
117
|
+
checkboxSelectionUnselectRow: 'Καταργήση επιλογής γραμμής',
|
|
123
118
|
// Boolean cell text
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
booleanCellTrueLabel: 'ναί',
|
|
120
|
+
booleanCellFalseLabel: 'όχι',
|
|
127
121
|
// Actions cell more text
|
|
128
|
-
actionsCellMore: 'περισσότερα'
|
|
129
|
-
|
|
122
|
+
actionsCellMore: 'περισσότερα',
|
|
130
123
|
// Column pinning text
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
pinToLeft: 'Καρφιτσώμα στα αριστερά',
|
|
125
|
+
pinToRight: 'Καρφιτσώμα στα δεξιά',
|
|
126
|
+
unpin: 'Ξεκαρφίτσωμα',
|
|
135
127
|
// Tree Data
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
treeDataGroupingHeaderName: 'Ομαδοποίηση',
|
|
129
|
+
treeDataExpand: 'εμφάνιση περιεχομένων',
|
|
130
|
+
treeDataCollapse: 'απόκρυψη περιεχομένων',
|
|
140
131
|
// Grouping columns
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
132
|
+
groupingColumnHeaderName: 'Ομαδοποίηση',
|
|
133
|
+
groupColumn: name => `Ομαδοποίηση κατά ${name}`,
|
|
134
|
+
unGroupColumn: name => `Διακοπή ομαδοποίησης κατά ${name}`,
|
|
145
135
|
// Master/detail
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
136
|
+
detailPanelToggle: 'Εναλλαγή πίνακα λεπτομερειών',
|
|
137
|
+
expandDetailPanel: 'Ανάπτυξη',
|
|
138
|
+
collapseDetailPanel: 'Σύμπτυξη',
|
|
150
139
|
// Row reordering text
|
|
151
|
-
|
|
152
|
-
|
|
140
|
+
rowReorderingHeaderName: 'Αναδιάταξη γραμμών',
|
|
153
141
|
// Aggregation
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
142
|
+
aggregationMenuItemHeader: 'Συσσωμάτωση',
|
|
143
|
+
aggregationFunctionLabelSum: 'άθροισμα',
|
|
144
|
+
aggregationFunctionLabelAvg: 'μέση τιμή',
|
|
145
|
+
aggregationFunctionLabelMin: 'ελάχιστο',
|
|
146
|
+
aggregationFunctionLabelMax: 'μέγιστο',
|
|
147
|
+
aggregationFunctionLabelSize: 'μέγεθος'
|
|
160
148
|
};
|
|
161
|
-
|
|
162
|
-
export const elGR = getGridLocalization(elGRGrid);
|
|
149
|
+
export const elGR = getGridLocalization(elGRGrid, elGRCore);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class Store {
|
|
2
|
+
static create(value) {
|
|
3
|
+
return new Store(value);
|
|
4
|
+
}
|
|
5
|
+
constructor(_value) {
|
|
6
|
+
this.value = void 0;
|
|
7
|
+
this.listeners = void 0;
|
|
8
|
+
this.subscribe = fn => {
|
|
9
|
+
this.listeners.add(fn);
|
|
10
|
+
return () => {
|
|
11
|
+
this.listeners.delete(fn);
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
this.getSnapshot = () => {
|
|
15
|
+
return this.value;
|
|
16
|
+
};
|
|
17
|
+
this.update = value => {
|
|
18
|
+
this.value = value;
|
|
19
|
+
this.listeners.forEach(l => l(value));
|
|
20
|
+
};
|
|
21
|
+
this.value = _value;
|
|
22
|
+
this.listeners = new Set();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Based on https://stackoverflow.com/a/59518678
|
|
2
|
+
let cachedSupportsPreventScroll;
|
|
3
|
+
export function doesSupportPreventScroll() {
|
|
4
|
+
if (cachedSupportsPreventScroll === undefined) {
|
|
5
|
+
document.createElement('div').focus({
|
|
6
|
+
get preventScroll() {
|
|
7
|
+
cachedSupportsPreventScroll = true;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return cachedSupportsPreventScroll;
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const is = Object.is;
|
|
2
|
+
export function fastObjectShallowCompare(a, b) {
|
|
3
|
+
if (a === b) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if (!(a instanceof Object) || !(b instanceof Object)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
let aLength = 0;
|
|
10
|
+
let bLength = 0;
|
|
11
|
+
|
|
12
|
+
/* eslint-disable no-restricted-syntax */
|
|
13
|
+
/* eslint-disable guard-for-in */
|
|
14
|
+
for (const key in a) {
|
|
15
|
+
aLength += 1;
|
|
16
|
+
if (!is(a[key], b[key])) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (!(key in b)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars */
|
|
25
|
+
for (const _ in b) {
|
|
26
|
+
bLength += 1;
|
|
27
|
+
}
|
|
28
|
+
/* eslint-enable no-restricted-syntax */
|
|
29
|
+
/* eslint-enable guard-for-in */
|
|
30
|
+
|
|
31
|
+
return aLength === bLength;
|
|
32
|
+
}
|
|
@@ -10,11 +10,13 @@ export const isDeleteKeys = key => key === 'Delete' || key === 'Backspace';
|
|
|
10
10
|
|
|
11
11
|
// Non printable keys have a name, e.g. "ArrowRight", see the whole list:
|
|
12
12
|
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
|
13
|
-
//
|
|
13
|
+
// So event.key.length === 1 is often enough.
|
|
14
|
+
//
|
|
15
|
+
// However, we also need to ignore shortcuts, for example: select all:
|
|
14
16
|
// - Windows: Ctrl+A, event.ctrlKey is true
|
|
15
17
|
// - macOS: ⌘ Command+A, event.metaKey is true
|
|
16
18
|
export function isPrintableKey(event) {
|
|
17
|
-
return event.key.length === 1 && event.ctrlKey
|
|
19
|
+
return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
|
|
18
20
|
}
|
|
19
21
|
export const GRID_MULTIPLE_SELECTION_KEYS = ['Meta', 'Control', 'Shift'];
|
|
20
22
|
export const GRID_CELL_EXIT_EDIT_MODE_KEYS = ['Enter', 'Escape', 'Tab'];
|
|
@@ -9,6 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _fastMemo = require("../utils/fastMemo");
|
|
12
13
|
var _useGridColumnHeaders = require("../hooks/features/columnHeaders/useGridColumnHeaders");
|
|
13
14
|
var _GridBaseColumnHeaders = require("./columnHeaders/GridBaseColumnHeaders");
|
|
14
15
|
var _GridColumnHeadersInner = require("./columnHeaders/GridColumnHeadersInner");
|
|
@@ -68,7 +69,6 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnsHead
|
|
|
68
69
|
}))
|
|
69
70
|
}));
|
|
70
71
|
});
|
|
71
|
-
exports.GridColumnHeaders = GridColumnHeaders;
|
|
72
72
|
process.env.NODE_ENV !== "production" ? GridColumnHeaders.propTypes = {
|
|
73
73
|
// ----------------------------- Warning --------------------------------
|
|
74
74
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -108,4 +108,6 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaders.propTypes = {
|
|
|
108
108
|
minColumnIndex: _propTypes.default.number,
|
|
109
109
|
sortColumnLookup: _propTypes.default.object.isRequired,
|
|
110
110
|
visibleColumns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired
|
|
111
|
-
} : void 0;
|
|
111
|
+
} : void 0;
|
|
112
|
+
const MemoizedGridColumnHeaders = (0, _fastMemo.fastMemo)(GridColumnHeaders);
|
|
113
|
+
exports.GridColumnHeaders = MemoizedGridColumnHeaders;
|
|
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
13
|
var _utils = require("@mui/utils");
|
|
14
|
+
var _fastMemo = require("../utils/fastMemo");
|
|
14
15
|
var _gridEditRowModel = require("../models/gridEditRowModel");
|
|
15
16
|
var _useGridApiContext = require("../hooks/utils/useGridApiContext");
|
|
16
17
|
var _gridClasses = require("../constants/gridClasses");
|
|
@@ -26,10 +27,10 @@ var _gridSortingSelector = require("../hooks/features/sorting/gridSortingSelecto
|
|
|
26
27
|
var _gridRowsSelector = require("../hooks/features/rows/gridRowsSelector");
|
|
27
28
|
var _gridColumnGroupsSelector = require("../hooks/features/columnGrouping/gridColumnGroupsSelector");
|
|
28
29
|
var _utils2 = require("../utils/utils");
|
|
30
|
+
var _GridCell = require("./cell/GridCell");
|
|
29
31
|
var _gridEditingSelectors = require("../hooks/features/editing/gridEditingSelectors");
|
|
30
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"]
|
|
32
|
-
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
33
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
|
|
33
34
|
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); }
|
|
34
35
|
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; }
|
|
35
36
|
const useUtilityClasses = ownerState => {
|
|
@@ -75,8 +76,6 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
75
76
|
containerWidth,
|
|
76
77
|
firstColumnToRender,
|
|
77
78
|
isLastVisible = false,
|
|
78
|
-
focusedCell,
|
|
79
|
-
tabbableCell,
|
|
80
79
|
onClick,
|
|
81
80
|
onDoubleClick,
|
|
82
81
|
onMouseEnter,
|
|
@@ -191,78 +190,27 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
191
190
|
const {
|
|
192
191
|
slots,
|
|
193
192
|
slotProps,
|
|
194
|
-
|
|
195
|
-
disableColumnReorder,
|
|
196
|
-
getCellClassName
|
|
193
|
+
disableColumnReorder
|
|
197
194
|
} = rootProps;
|
|
195
|
+
const CellComponent = slots.cell === _GridCell.GridCellV7 ? _GridCell.GridCellV7 : _GridCell.GridCellWrapper;
|
|
198
196
|
const rowReordering = rootProps.rowReordering;
|
|
199
|
-
const
|
|
200
|
-
const getCell = React.useCallback((column, cellProps) => {
|
|
201
|
-
const cellParams = apiRef.current.getCellParams(rowId, column.field);
|
|
202
|
-
const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
|
|
203
|
-
id: rowId,
|
|
204
|
-
field: column.field
|
|
205
|
-
});
|
|
197
|
+
const getCell = (column, cellProps) => {
|
|
206
198
|
const disableDragEvents = disableColumnReorder && column.disableReorder || !rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
|
|
207
|
-
|
|
208
|
-
classNames.push((0, _clsx.default)(typeof column.cellClassName === 'function' ? column.cellClassName(cellParams) : column.cellClassName));
|
|
209
|
-
}
|
|
210
|
-
const editCellState = editRowsState[rowId] ? editRowsState[rowId][column.field] : null;
|
|
211
|
-
let content;
|
|
212
|
-
if (editCellState == null && column.renderCell) {
|
|
213
|
-
content = column.renderCell((0, _extends2.default)({}, cellParams, {
|
|
214
|
-
api: apiRef.current
|
|
215
|
-
}));
|
|
216
|
-
// TODO move to GridCell
|
|
217
|
-
classNames.push((0, _clsx.default)(_gridClasses.gridClasses['cell--withRenderer'], rootClasses?.['cell--withRenderer']));
|
|
218
|
-
}
|
|
219
|
-
if (editCellState != null && column.renderEditCell) {
|
|
220
|
-
const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
|
|
221
|
-
|
|
222
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
223
|
-
const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded2);
|
|
224
|
-
const params = (0, _extends2.default)({}, cellParams, {
|
|
225
|
-
row: updatedRow
|
|
226
|
-
}, editCellStateRest, {
|
|
227
|
-
api: apiRef.current
|
|
228
|
-
});
|
|
229
|
-
content = column.renderEditCell(params);
|
|
230
|
-
// TODO move to GridCell
|
|
231
|
-
classNames.push((0, _clsx.default)(_gridClasses.gridClasses['cell--editing'], rootClasses?.['cell--editing']));
|
|
232
|
-
}
|
|
233
|
-
if (getCellClassName) {
|
|
234
|
-
// TODO move to GridCell
|
|
235
|
-
classNames.push(getCellClassName(cellParams));
|
|
236
|
-
}
|
|
237
|
-
const hasFocus = focusedCell === column.field;
|
|
238
|
-
const tabIndex = tabbableCell === column.field ? 0 : -1;
|
|
239
|
-
const isSelected = apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
|
|
240
|
-
id: rowId,
|
|
241
|
-
field: column.field
|
|
242
|
-
});
|
|
199
|
+
const editCellState = editRowsState[rowId]?.[column.field] ?? null;
|
|
243
200
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CellComponent, (0, _extends2.default)({
|
|
244
|
-
|
|
245
|
-
field: column.field,
|
|
201
|
+
column: column,
|
|
246
202
|
width: cellProps.width,
|
|
247
203
|
rowId: rowId,
|
|
248
204
|
height: rowHeight,
|
|
249
205
|
showRightBorder: cellProps.showRightBorder,
|
|
250
|
-
formattedValue: cellParams.formattedValue,
|
|
251
206
|
align: column.align || 'left',
|
|
252
|
-
cellMode: cellParams.cellMode,
|
|
253
207
|
colIndex: cellProps.indexRelativeToAllColumns,
|
|
254
|
-
isEditable: cellParams.isEditable,
|
|
255
|
-
isSelected: isSelected,
|
|
256
|
-
hasFocus: hasFocus,
|
|
257
|
-
tabIndex: tabIndex,
|
|
258
|
-
className: (0, _clsx.default)(classNames),
|
|
259
208
|
colSpan: cellProps.colSpan,
|
|
260
|
-
disableDragEvents: disableDragEvents
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
|
|
209
|
+
disableDragEvents: disableDragEvents,
|
|
210
|
+
editCellState: editCellState
|
|
211
|
+
}, slotProps?.cell), column.field);
|
|
212
|
+
};
|
|
213
|
+
const sizes = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _extends2.default)({}, apiRef.current.unstable_getRowInternalSizes(rowId)), _useGridSelector.objectShallowCompare);
|
|
266
214
|
let minHeight = rowHeight;
|
|
267
215
|
if (minHeight === 'auto' && sizes) {
|
|
268
216
|
let numberOfBaseSizes = 0;
|
|
@@ -311,7 +259,11 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
311
259
|
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
312
260
|
}
|
|
313
261
|
const randomNumber = (0, _utils2.randomNumberBetween)(10000, 20, 80);
|
|
314
|
-
const
|
|
262
|
+
const rowNode = apiRef.current.getRowNode(rowId);
|
|
263
|
+
if (!rowNode) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const rowType = rowNode.type;
|
|
315
267
|
const cells = [];
|
|
316
268
|
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
317
269
|
const column = renderedColumns[i];
|
|
@@ -335,7 +287,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
335
287
|
width
|
|
336
288
|
} = cellColSpanInfo.cellProps;
|
|
337
289
|
const contentWidth = Math.round(randomNumber());
|
|
338
|
-
cells.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
290
|
+
cells.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(slots.skeletonCell, {
|
|
339
291
|
width: width,
|
|
340
292
|
contentWidth: contentWidth,
|
|
341
293
|
field: column.field,
|
|
@@ -366,7 +318,6 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
366
318
|
})]
|
|
367
319
|
}));
|
|
368
320
|
});
|
|
369
|
-
exports.GridRow = GridRow;
|
|
370
321
|
process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
371
322
|
// ----------------------------- Warning --------------------------------
|
|
372
323
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -402,4 +353,6 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
402
353
|
*/
|
|
403
354
|
tabbableCell: _propTypes.default.string,
|
|
404
355
|
visibleColumns: _propTypes.default.arrayOf(_propTypes.default.object)
|
|
405
|
-
} : void 0;
|
|
356
|
+
} : void 0;
|
|
357
|
+
const MemoizedGridRow = (0, _fastMemo.fastMemo)(GridRow);
|
|
358
|
+
exports.GridRow = MemoizedGridRow;
|