@mui/x-data-grid 6.7.0 → 6.9.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 +145 -5541
- package/components/GridColumnHeaders.d.ts +2 -2
- package/components/GridColumnHeaders.js +3 -1
- package/components/GridPagination.d.ts +2 -2
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +33 -79
- package/components/cell/GridCell.d.ts +24 -15
- package/components/cell/GridCell.js +422 -45
- package/components/cell/GridEditInputCell.js +9 -9
- 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/panel/GridPanel.d.ts +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/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/hooks/features/editing/useGridCellEditing.js +5 -3
- package/hooks/features/editing/useGridRowEditing.js +14 -6
- package/hooks/features/filter/gridFilterSelector.js +8 -8
- 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/pagination/gridPaginationSelector.js +4 -4
- package/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/hooks/features/rows/gridRowsSelector.js +3 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
- package/hooks/features/rows/useGridParamsApi.js +7 -15
- package/hooks/features/sorting/gridSortingSelector.js +3 -3
- 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/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/GridColumnHeaders.js +3 -1
- package/legacy/components/GridRow.js +35 -79
- package/legacy/components/cell/GridCell.js +425 -46
- package/legacy/components/cell/GridEditInputCell.js +9 -9
- 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/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/legacy/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
- package/legacy/hooks/features/filter/gridFilterSelector.js +8 -8
- 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/pagination/gridPaginationSelector.js +4 -4
- package/legacy/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -3
- package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
- package/legacy/hooks/features/sorting/gridSortingSelector.js +3 -3
- 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/internals/index.js +1 -1
- package/legacy/locales/elGR.js +70 -79
- package/legacy/locales/ptBR.js +12 -13
- package/legacy/utils/Store.js +34 -0
- package/legacy/utils/createSelector.js +74 -6
- 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/locales/ptBR.js +12 -13
- 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 +32 -79
- package/modern/components/cell/GridCell.js +421 -45
- package/modern/components/cell/GridEditInputCell.js +9 -9
- 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/columnGrouping/gridColumnGroupsSelector.js +4 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/modern/hooks/features/columns/gridColumnsSelector.js +7 -7
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
- package/modern/hooks/features/filter/gridFilterSelector.js +8 -8
- 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/pagination/gridPaginationSelector.js +4 -4
- package/modern/hooks/features/rowSelection/gridRowSelectionSelector.js +3 -3
- package/modern/hooks/features/rows/gridRowsSelector.js +3 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
- package/modern/hooks/features/sorting/gridSortingSelector.js +3 -3
- 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/internals/index.js +1 -1
- package/modern/locales/elGR.js +66 -79
- package/modern/locales/ptBR.js +12 -13
- package/modern/utils/Store.js +24 -0
- package/modern/utils/createSelector.js +74 -6
- 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 +32 -79
- package/node/components/cell/GridCell.js +424 -47
- package/node/components/cell/GridEditInputCell.js +9 -9
- 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/columnGrouping/gridColumnGroupsSelector.js +3 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
- package/node/hooks/features/columns/gridColumnsSelector.js +6 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +6 -12
- package/node/hooks/features/editing/useGridCellEditing.js +5 -3
- package/node/hooks/features/editing/useGridRowEditing.js +14 -6
- package/node/hooks/features/filter/gridFilterSelector.js +7 -7
- 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/pagination/gridPaginationSelector.js +3 -3
- package/node/hooks/features/rowSelection/gridRowSelectionSelector.js +2 -2
- package/node/hooks/features/rows/gridRowsSelector.js +2 -2
- package/node/hooks/features/rows/useGridParamsApi.js +9 -15
- package/node/hooks/features/sorting/gridSortingSelector.js +2 -2
- 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/internals/index.js +7 -0
- package/node/locales/elGR.js +66 -79
- package/node/locales/ptBR.js +12 -13
- package/node/utils/Store.js +31 -0
- package/node/utils/createSelector.js +77 -8
- 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 +2 -2
- package/utils/Store.d.ts +11 -0
- package/utils/Store.js +24 -0
- package/utils/createSelector.d.ts +1 -0
- package/utils/createSelector.js +74 -6
- 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
package/utils/createSelector.js
CHANGED
|
@@ -4,15 +4,83 @@ const cacheContainer = {
|
|
|
4
4
|
cache: new WeakMap()
|
|
5
5
|
};
|
|
6
6
|
const missingInstanceIdWarning = buildWarning(['MUI: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g `mySelector(state, apiRef.current.instanceId)`.']);
|
|
7
|
-
|
|
7
|
+
function checkIsAPIRef(value) {
|
|
8
|
+
return 'current' in value && 'instanceId' in value.current;
|
|
9
|
+
}
|
|
10
|
+
const DEFAULT_INSTANCE_ID = {
|
|
11
|
+
id: 'default'
|
|
12
|
+
};
|
|
13
|
+
export const createSelector = (a, b, c, d, e, f, ...rest) => {
|
|
14
|
+
if (rest.length > 0) {
|
|
15
|
+
throw new Error('Unsupported number of selectors');
|
|
16
|
+
}
|
|
17
|
+
let selector;
|
|
18
|
+
if (a && b && c && d && e && f) {
|
|
19
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
20
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
21
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
22
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
23
|
+
const va = a(state, instanceId);
|
|
24
|
+
const vb = b(state, instanceId);
|
|
25
|
+
const vc = c(state, instanceId);
|
|
26
|
+
const vd = d(state, instanceId);
|
|
27
|
+
const ve = e(state, instanceId);
|
|
28
|
+
return f(va, vb, vc, vd, ve);
|
|
29
|
+
};
|
|
30
|
+
} else if (a && b && c && d && e) {
|
|
31
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
32
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
33
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
34
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
35
|
+
const va = a(state, instanceId);
|
|
36
|
+
const vb = b(state, instanceId);
|
|
37
|
+
const vc = c(state, instanceId);
|
|
38
|
+
const vd = d(state, instanceId);
|
|
39
|
+
return e(va, vb, vc, vd);
|
|
40
|
+
};
|
|
41
|
+
} else if (a && b && c && d) {
|
|
42
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
43
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
44
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
45
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
46
|
+
const va = a(state, instanceId);
|
|
47
|
+
const vb = b(state, instanceId);
|
|
48
|
+
const vc = c(state, instanceId);
|
|
49
|
+
return d(va, vb, vc);
|
|
50
|
+
};
|
|
51
|
+
} else if (a && b && c) {
|
|
52
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
53
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
54
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
55
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
56
|
+
const va = a(state, instanceId);
|
|
57
|
+
const vb = b(state, instanceId);
|
|
58
|
+
return c(va, vb);
|
|
59
|
+
};
|
|
60
|
+
} else if (a && b) {
|
|
61
|
+
selector = (stateOrApiRef, instanceIdParam) => {
|
|
62
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
63
|
+
const instanceId = instanceIdParam != null ? instanceIdParam : isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID;
|
|
64
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
65
|
+
const va = a(state, instanceId);
|
|
66
|
+
return b(va);
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
throw new Error('Missing arguments');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// We use this property to detect if the selector was created with createSelector
|
|
73
|
+
// or it's only a simple function the receives the state and returns part of it.
|
|
74
|
+
selector.acceptsApiRef = true;
|
|
75
|
+
return selector;
|
|
76
|
+
};
|
|
77
|
+
export const createSelectorMemoized = (...args) => {
|
|
8
78
|
const selector = (...selectorArgs) => {
|
|
9
79
|
var _cache$get, _cache$get3;
|
|
10
80
|
const [stateOrApiRef, instanceId] = selectorArgs;
|
|
11
|
-
const
|
|
12
|
-
const cacheKey =
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
81
|
+
const isAPIRef = checkIsAPIRef(stateOrApiRef);
|
|
82
|
+
const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId != null ? instanceId : DEFAULT_INSTANCE_ID;
|
|
83
|
+
const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
16
84
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
85
|
if (cacheKey.id === 'default') {
|
|
18
86
|
missingInstanceIdWarning();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function doesSupportPreventScroll(): boolean;
|
|
@@ -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 @@
|
|
|
1
|
+
export declare function fastMemo<T>(component: T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fastObjectShallowCompare<T extends Record<string, any> | null>(a: T, b: T): boolean;
|
|
@@ -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
|
+
}
|
package/utils/keyboardUtils.js
CHANGED
|
@@ -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'];
|