@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.
Files changed (153) hide show
  1. package/CHANGELOG.md +77 -15
  2. package/components/GridColumnHeaders.d.ts +2 -2
  3. package/components/GridColumnHeaders.js +3 -1
  4. package/components/GridRow.d.ts +2 -2
  5. package/components/GridRow.js +23 -69
  6. package/components/cell/GridCell.d.ts +24 -15
  7. package/components/cell/GridCell.js +422 -45
  8. package/components/cell/index.d.ts +2 -1
  9. package/components/cell/index.js +1 -1
  10. package/components/containers/GridRootStyles.js +30 -16
  11. package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  12. package/components/toolbar/GridToolbar.js +2 -2
  13. package/components/virtualization/GridVirtualScroller.js +4 -9
  14. package/components/virtualization/GridVirtualScrollerContent.js +11 -20
  15. package/constants/defaultGridSlotsComponents.js +6 -2
  16. package/hooks/core/useGridApiInitialization.js +4 -1
  17. package/hooks/core/useGridStateInitialization.js +2 -9
  18. package/hooks/features/clipboard/useGridClipboard.js +1 -4
  19. package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
  20. package/hooks/features/editing/useGridCellEditing.js +5 -3
  21. package/hooks/features/editing/useGridRowEditing.js +14 -6
  22. package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
  23. package/hooks/features/filter/gridFilterUtils.js +19 -13
  24. package/hooks/features/filter/useGridFilter.js +2 -1
  25. package/hooks/features/focus/useGridFocus.js +9 -4
  26. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  27. package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
  28. package/hooks/features/rows/useGridParamsApi.js +7 -15
  29. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
  30. package/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
  31. package/hooks/utils/index.d.ts +1 -1
  32. package/hooks/utils/index.js +1 -1
  33. package/hooks/utils/useGridSelector.d.ts +3 -1
  34. package/hooks/utils/useGridSelector.js +37 -6
  35. package/hooks/utils/useLazyRef.d.ts +2 -0
  36. package/hooks/utils/useLazyRef.js +9 -0
  37. package/hooks/utils/useOnMount.d.ts +2 -0
  38. package/hooks/utils/useOnMount.js +7 -0
  39. package/index.js +1 -1
  40. package/legacy/components/GridColumnHeaders.js +3 -1
  41. package/legacy/components/GridRow.js +25 -69
  42. package/legacy/components/cell/GridCell.js +425 -46
  43. package/legacy/components/cell/index.js +1 -1
  44. package/legacy/components/containers/GridRootStyles.js +20 -17
  45. package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  46. package/legacy/components/toolbar/GridToolbar.js +2 -2
  47. package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
  48. package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
  49. package/legacy/constants/defaultGridSlotsComponents.js +6 -2
  50. package/legacy/hooks/core/useGridApiInitialization.js +4 -1
  51. package/legacy/hooks/core/useGridStateInitialization.js +2 -7
  52. package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
  53. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
  54. package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
  55. package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
  56. package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
  57. package/legacy/hooks/features/filter/useGridFilter.js +2 -1
  58. package/legacy/hooks/features/focus/useGridFocus.js +9 -4
  59. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  60. package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
  61. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +38 -34
  62. package/legacy/hooks/utils/index.js +1 -1
  63. package/legacy/hooks/utils/useGridSelector.js +43 -5
  64. package/legacy/hooks/utils/useLazyRef.js +9 -0
  65. package/legacy/hooks/utils/useOnMount.js +7 -0
  66. package/legacy/index.js +1 -1
  67. package/legacy/locales/elGR.js +70 -79
  68. package/legacy/utils/Store.js +34 -0
  69. package/legacy/utils/doesSupportPreventScroll.js +13 -0
  70. package/legacy/utils/fastMemo.js +5 -0
  71. package/legacy/utils/fastObjectShallowCompare.js +32 -0
  72. package/legacy/utils/keyboardUtils.js +4 -2
  73. package/locales/elGR.js +66 -79
  74. package/models/api/gridCoreApi.d.ts +6 -0
  75. package/models/colDef/gridColDef.d.ts +4 -3
  76. package/models/colDef/gridColType.d.ts +3 -1
  77. package/models/events/gridEventLookup.d.ts +3 -3
  78. package/modern/components/GridColumnHeaders.js +3 -1
  79. package/modern/components/GridRow.js +22 -69
  80. package/modern/components/cell/GridCell.js +421 -45
  81. package/modern/components/cell/index.js +1 -1
  82. package/modern/components/containers/GridRootStyles.js +30 -16
  83. package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  84. package/modern/components/toolbar/GridToolbar.js +2 -2
  85. package/modern/components/virtualization/GridVirtualScroller.js +4 -9
  86. package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
  87. package/modern/constants/defaultGridSlotsComponents.js +6 -2
  88. package/modern/hooks/core/useGridApiInitialization.js +4 -1
  89. package/modern/hooks/core/useGridStateInitialization.js +2 -9
  90. package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
  91. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
  92. package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
  93. package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
  94. package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
  95. package/modern/hooks/features/filter/useGridFilter.js +2 -1
  96. package/modern/hooks/features/focus/useGridFocus.js +8 -4
  97. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  98. package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
  99. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +40 -38
  100. package/modern/hooks/utils/index.js +1 -1
  101. package/modern/hooks/utils/useGridSelector.js +37 -6
  102. package/modern/hooks/utils/useLazyRef.js +9 -0
  103. package/modern/hooks/utils/useOnMount.js +7 -0
  104. package/modern/index.js +1 -1
  105. package/modern/locales/elGR.js +66 -79
  106. package/modern/utils/Store.js +24 -0
  107. package/modern/utils/doesSupportPreventScroll.js +13 -0
  108. package/modern/utils/fastMemo.js +5 -0
  109. package/modern/utils/fastObjectShallowCompare.js +32 -0
  110. package/modern/utils/keyboardUtils.js +4 -2
  111. package/node/components/GridColumnHeaders.js +4 -2
  112. package/node/components/GridRow.js +22 -69
  113. package/node/components/cell/GridCell.js +424 -47
  114. package/node/components/cell/index.js +17 -10
  115. package/node/components/containers/GridRootStyles.js +30 -16
  116. package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
  117. package/node/components/toolbar/GridToolbar.js +2 -2
  118. package/node/components/virtualization/GridVirtualScroller.js +4 -9
  119. package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
  120. package/node/constants/defaultGridSlotsComponents.js +4 -1
  121. package/node/hooks/core/useGridApiInitialization.js +4 -1
  122. package/node/hooks/core/useGridStateInitialization.js +2 -9
  123. package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
  124. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
  125. package/node/hooks/features/editing/useGridCellEditing.js +5 -3
  126. package/node/hooks/features/editing/useGridRowEditing.js +14 -6
  127. package/node/hooks/features/filter/gridFilterUtils.js +17 -12
  128. package/node/hooks/features/filter/useGridFilter.js +2 -1
  129. package/node/hooks/features/focus/useGridFocus.js +8 -4
  130. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
  131. package/node/hooks/features/rows/useGridParamsApi.js +9 -15
  132. package/node/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
  133. package/node/hooks/utils/index.js +14 -10
  134. package/node/hooks/utils/useGridSelector.js +41 -7
  135. package/node/hooks/utils/useLazyRef.js +17 -0
  136. package/node/hooks/utils/useOnMount.js +15 -0
  137. package/node/index.js +1 -1
  138. package/node/locales/elGR.js +66 -79
  139. package/node/utils/Store.js +31 -0
  140. package/node/utils/doesSupportPreventScroll.js +19 -0
  141. package/node/utils/fastMemo.js +13 -0
  142. package/node/utils/fastObjectShallowCompare.js +38 -0
  143. package/node/utils/keyboardUtils.js +4 -2
  144. package/package.json +1 -1
  145. package/utils/Store.d.ts +11 -0
  146. package/utils/Store.js +24 -0
  147. package/utils/doesSupportPreventScroll.d.ts +1 -0
  148. package/utils/doesSupportPreventScroll.js +13 -0
  149. package/utils/fastMemo.d.ts +1 -0
  150. package/utils/fastMemo.js +5 -0
  151. package/utils/fastObjectShallowCompare.d.ts +1 -0
  152. package/utils/fastObjectShallowCompare.js +32 -0
  153. 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
- 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.']);
6
- export const useGridSelector = (apiRef, selector) => {
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
- if (isOutputSelector(selector)) {
13
- return selector(apiRef);
14
- }
15
- return selector(apiRef.current.state);
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
  };
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ const UNINITIALIZED = {};
3
+ export function useLazyRef(init, initArg) {
4
+ const ref = React.useRef(UNINITIALIZED);
5
+ if (ref.current === UNINITIALIZED) {
6
+ ref.current = init(initArg);
7
+ }
8
+ return ref;
9
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ const EMPTY = [];
3
+ export function useOnMount(fn) {
4
+ /* eslint-disable react-hooks/exhaustive-deps */
5
+ React.useEffect(fn, EMPTY);
6
+ /* eslint-enable react-hooks/exhaustive-deps */
7
+ }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.7.0
2
+ * @mui/x-data-grid v6.8.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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
- // toolbarQuickFilterPlaceholder: 'Search…',
23
- // toolbarQuickFilterLabel: 'Search',
24
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
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
- // toolbarExportPrint: 'Print',
31
- // toolbarExportExcel: 'Download as Excel',
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
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Αφαίρεση όλων',
42
41
  filterPanelDeleteIconLabel: 'Διαγραφή',
43
- // filterPanelLogicOperator: 'Logic operator',
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
- // filterOperatorIsAnyOf: 'is any of',
64
- // 'filterOperator=': '=',
65
- // 'filterOperator!=': '!=',
66
- // 'filterOperator>': '>',
67
- // 'filterOperator>=': '>=',
68
- // 'filterOperator<': '<',
69
- // 'filterOperator<=': '<=',
70
-
62
+ filterOperatorIsAnyOf: 'είναι οποιοδήποτε από',
63
+ 'filterOperator=': '=',
64
+ 'filterOperator!=': '!=',
65
+ 'filterOperator>': '>',
66
+ 'filterOperator>=': '>=',
67
+ 'filterOperator<': '<',
68
+ 'filterOperator<=': '<=',
71
69
  // Header filter operators text
72
- // headerFilterOperatorContains: 'Contains',
73
- // headerFilterOperatorEquals: 'Equals',
74
- // headerFilterOperatorStartsWith: 'Starts with',
75
- // headerFilterOperatorEndsWith: 'Ends with',
76
- // headerFilterOperatorIs: 'Is',
77
- // headerFilterOperatorNot: 'Is not',
78
- // headerFilterOperatorAfter: 'Is after',
79
- // headerFilterOperatorOnOrAfter: 'Is on or after',
80
- // headerFilterOperatorBefore: 'Is before',
81
- // headerFilterOperatorOnOrBefore: 'Is on or before',
82
- // headerFilterOperatorIsEmpty: 'Is empty',
83
- // headerFilterOperatorIsNotEmpty: 'Is not empty',
84
- // headerFilterOperatorIsAnyOf: 'Is any of',
85
- // 'headerFilterOperator=': 'Equals',
86
- // 'headerFilterOperator!=': 'Not equals',
87
- // 'headerFilterOperator>': 'Greater than',
88
- // 'headerFilterOperator>=': 'Greater than or equal to',
89
- // 'headerFilterOperator<': 'Less than',
90
- // 'headerFilterOperator<=': 'Less than or equal to',
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
- // filterValueAny: 'any',
94
- // filterValueTrue: 'true',
95
- // filterValueFalse: 'false',
96
-
90
+ filterValueAny: 'οποιοδήποτε',
91
+ filterValueTrue: 'αληθές',
92
+ filterValueFalse: 'ψευδές',
97
93
  // Column menu text
98
94
  columnMenuLabel: 'Μενού',
99
95
  columnMenuShowColumns: 'Εμφάνιση στηλών',
100
- // columnMenuManageColumns: 'Manage columns',
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
- // checkboxSelectionHeaderName: 'Checkbox selection',
118
- // checkboxSelectionSelectAllRows: 'Select all rows',
119
- // checkboxSelectionUnselectAllRows: 'Unselect all rows',
120
- // checkboxSelectionSelectRow: 'Select row',
121
- // checkboxSelectionUnselectRow: 'Unselect row',
122
-
113
+ checkboxSelectionHeaderName: 'Επιλογή πλαισίου ελέγχου',
114
+ checkboxSelectionSelectAllRows: 'Επιλέξτε όλες τις σειρές',
115
+ checkboxSelectionUnselectAllRows: 'Καταργήση επιλογής όλων των σειρών',
116
+ checkboxSelectionSelectRow: 'Επιλογή γραμμής',
117
+ checkboxSelectionUnselectRow: 'Καταργήση επιλογής γραμμής',
123
118
  // Boolean cell text
124
- // booleanCellTrueLabel: 'yes',
125
- // booleanCellFalseLabel: 'no',
126
-
119
+ booleanCellTrueLabel: 'ναί',
120
+ booleanCellFalseLabel: 'όχι',
127
121
  // Actions cell more text
128
- actionsCellMore: 'περισσότερα'
129
-
122
+ actionsCellMore: 'περισσότερα',
130
123
  // Column pinning text
131
- // pinToLeft: 'Pin to left',
132
- // pinToRight: 'Pin to right',
133
- // unpin: 'Unpin',
134
-
124
+ pinToLeft: 'Καρφιτσώμα στα αριστερά',
125
+ pinToRight: 'Καρφιτσώμα στα δεξιά',
126
+ unpin: 'Ξεκαρφίτσωμα',
135
127
  // Tree Data
136
- // treeDataGroupingHeaderName: 'Group',
137
- // treeDataExpand: 'see children',
138
- // treeDataCollapse: 'hide children',
139
-
128
+ treeDataGroupingHeaderName: 'Ομαδοποίηση',
129
+ treeDataExpand: 'εμφάνιση περιεχομένων',
130
+ treeDataCollapse: 'απόκρυψη περιεχομένων',
140
131
  // Grouping columns
141
- // groupingColumnHeaderName: 'Group',
142
- // groupColumn: name => `Group by ${name}`,
143
- // unGroupColumn: name => `Stop grouping by ${name}`,
144
-
132
+ groupingColumnHeaderName: 'Ομαδοποίηση',
133
+ groupColumn: name => `Ομαδοποίηση κατά ${name}`,
134
+ unGroupColumn: name => `Διακοπή ομαδοποίησης κατά ${name}`,
145
135
  // Master/detail
146
- // detailPanelToggle: 'Detail panel toggle',
147
- // expandDetailPanel: 'Expand',
148
- // collapseDetailPanel: 'Collapse',
149
-
136
+ detailPanelToggle: 'Εναλλαγή πίνακα λεπτομερειών',
137
+ expandDetailPanel: 'Ανάπτυξη',
138
+ collapseDetailPanel: 'Σύμπτυξη',
150
139
  // Row reordering text
151
- // rowReorderingHeaderName: 'Row reordering',
152
-
140
+ rowReorderingHeaderName: 'Αναδιάταξη γραμμών',
153
141
  // Aggregation
154
- // aggregationMenuItemHeader: 'Aggregation',
155
- // aggregationFunctionLabelSum: 'sum',
156
- // aggregationFunctionLabelAvg: 'avg',
157
- // aggregationFunctionLabelMin: 'min',
158
- // aggregationFunctionLabelMax: 'max',
159
- // aggregationFunctionLabelSize: 'size',
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,5 @@
1
+ import * as React from 'react';
2
+ import { fastObjectShallowCompare } from './fastObjectShallowCompare';
3
+ export function fastMemo(component) {
4
+ return /*#__PURE__*/React.memo(component, fastObjectShallowCompare);
5
+ }
@@ -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
- // We need to ignore shortcuts, for example: select all:
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 === false && event.metaKey === false;
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
- classes: rootClasses,
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 CellComponent = slots.cell;
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
- if (column.cellClassName) {
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
- value: cellParams.value,
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
- }, slotProps?.cell, {
262
- children: content
263
- }), column.field);
264
- }, [apiRef, rowId, disableColumnReorder, rowReordering, sortModel.length, treeDepth, editRowsState, getCellClassName, focusedCell, tabbableCell, CellComponent, rowHeight, slotProps?.cell, rootClasses]);
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 rowType = apiRef.current.getRowNode(rowId).type;
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)(rootProps.slots.skeletonCell, {
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;