@mui/x-data-grid 7.20.0 → 7.21.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 +120 -31
- package/DataGrid/DataGrid.js +1 -0
- package/DataGrid/index.d.ts +0 -1
- package/DataGrid/index.js +1 -2
- package/DataGrid/useDataGridComponent.js +4 -1
- package/DataGrid/useDataGridProps.d.ts +1 -5
- package/DataGrid/useDataGridProps.js +3 -62
- package/components/GridPagination.js +1 -0
- package/components/GridRow.js +25 -36
- package/components/base/GridOverlays.js +8 -0
- package/components/containers/GridRootStyles.js +1 -0
- package/components/menu/columnMenu/GridColumnMenu.js +32 -0
- package/components/toolbar/GridToolbarExport.d.ts +9 -3
- package/components/toolbar/GridToolbarExport.js +55 -3
- package/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/components/virtualization/GridVirtualScroller.js +2 -2
- package/constants/dataGridPropsDefaultValues.d.ts +5 -0
- package/constants/dataGridPropsDefaultValues.js +60 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
- package/hooks/features/clipboard/useGridClipboard.js +2 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.js +3 -0
- package/hooks/features/dimensions/useGridDimensions.js +4 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
- package/hooks/features/listView/gridListViewSelectors.d.ts +5 -0
- package/hooks/features/listView/gridListViewSelectors.js +4 -0
- package/hooks/features/listView/useGridListView.d.ts +10 -0
- package/hooks/features/listView/useGridListView.js +54 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +11 -2
- package/hooks/features/rowSelection/utils.js +1 -1
- package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +16 -0
- package/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +3 -0
- package/hooks/features/rows/gridRowsUtils.js +14 -1
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/hooks/features/rows/useGridParamsApi.js +4 -3
- package/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.js +3 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
- package/hooks/utils/useGridApiMethod.js +2 -1
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/models/api/gridRowsMetaApi.d.ts +15 -14
- package/models/colDef/gridColDef.d.ts +6 -0
- package/models/colDef/index.d.ts +1 -1
- package/models/gridApiCaches.d.ts +2 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +14 -3
- package/modern/DataGrid/DataGrid.js +1 -0
- package/modern/DataGrid/index.js +1 -2
- package/modern/DataGrid/useDataGridComponent.js +4 -1
- package/modern/DataGrid/useDataGridProps.js +3 -62
- package/modern/components/GridPagination.js +1 -0
- package/modern/components/GridRow.js +25 -36
- package/modern/components/base/GridOverlays.js +8 -0
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/menu/columnMenu/GridColumnMenu.js +32 -0
- package/modern/components/toolbar/GridToolbarExport.js +55 -3
- package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/modern/components/virtualization/GridVirtualScroller.js +2 -2
- package/modern/constants/dataGridPropsDefaultValues.js +60 -0
- package/modern/hooks/features/clipboard/useGridClipboard.js +2 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +3 -0
- package/modern/hooks/features/dimensions/useGridDimensions.js +4 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
- package/modern/hooks/features/listView/gridListViewSelectors.js +4 -0
- package/modern/hooks/features/listView/useGridListView.js +54 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +11 -2
- package/modern/hooks/features/rowSelection/utils.js +1 -1
- package/modern/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +14 -1
- package/modern/hooks/features/rows/useGridParamsApi.js +4 -3
- package/modern/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/modern/hooks/features/scroll/useGridScroll.js +3 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
- package/modern/hooks/utils/useGridApiMethod.js +2 -1
- package/modern/index.js +2 -1
- package/modern/internals/index.js +2 -1
- package/modern/utils/ResizeObserver.js +10 -0
- package/modern/utils/keyboardUtils.js +12 -4
- package/node/DataGrid/DataGrid.js +1 -0
- package/node/DataGrid/index.js +1 -12
- package/node/DataGrid/useDataGridComponent.js +4 -1
- package/node/DataGrid/useDataGridProps.js +6 -65
- package/node/components/GridPagination.js +1 -0
- package/node/components/GridRow.js +25 -36
- package/node/components/base/GridOverlays.js +8 -0
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/menu/columnMenu/GridColumnMenu.js +32 -0
- package/node/components/toolbar/GridToolbarExport.js +52 -0
- package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/node/components/virtualization/GridVirtualScroller.js +2 -2
- package/node/constants/dataGridPropsDefaultValues.js +66 -0
- package/node/hooks/features/clipboard/useGridClipboard.js +2 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/node/hooks/features/columns/gridColumnsUtils.js +3 -0
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -1
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
- package/node/hooks/features/listView/gridListViewSelectors.js +11 -0
- package/node/hooks/features/listView/useGridListView.js +64 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +11 -2
- package/node/hooks/features/rowSelection/utils.js +1 -1
- package/node/hooks/features/rows/gridRowsMetaInterfaces.js +5 -0
- package/node/hooks/features/rows/gridRowsUtils.js +16 -2
- package/node/hooks/features/rows/useGridParamsApi.js +4 -3
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -154
- package/node/hooks/features/scroll/useGridScroll.js +3 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
- package/node/hooks/utils/useGridApiMethod.js +3 -1
- package/node/index.js +13 -1
- package/node/internals/index.js +22 -0
- package/node/utils/ResizeObserver.js +16 -0
- package/node/utils/keyboardUtils.js +15 -5
- package/package.json +2 -2
- package/utils/ResizeObserver.d.ts +4 -0
- package/utils/ResizeObserver.js +10 -0
- package/utils/keyboardUtils.d.ts +1 -0
- package/utils/keyboardUtils.js +12 -4
|
@@ -8,8 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useGridRowsMeta = exports.rowsMetaStateInitializer = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var
|
|
11
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
12
|
+
var _ResizeObserver = require("../../../utils/ResizeObserver");
|
|
12
13
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
14
|
+
var _utils = require("../../../utils/utils");
|
|
13
15
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
14
16
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
15
17
|
var _densitySelector = require("../density/densitySelector");
|
|
@@ -18,139 +20,121 @@ var _gridPaginationSelector = require("../pagination/gridPaginationSelector");
|
|
|
18
20
|
var _gridSortingSelector = require("../sorting/gridSortingSelector");
|
|
19
21
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
20
22
|
var _gridRowsSelector = require("./gridRowsSelector");
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
+
var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
|
|
24
|
+
var _gridRowsUtils = require("./gridRowsUtils");
|
|
25
|
+
/* eslint-disable no-underscore-dangle */
|
|
23
26
|
|
|
24
|
-
const rowsMetaStateInitializer = state
|
|
25
|
-
rowsMeta
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return rowHeightProp;
|
|
35
|
-
}
|
|
36
|
-
if (process.env.NODE_ENV !== 'production' && !warnedOnceInvalidRowHeight && typeof rowHeightProp !== 'undefined' && rowHeightProp !== null) {
|
|
37
|
-
console.warn(warningMessage);
|
|
38
|
-
warnedOnceInvalidRowHeight = true;
|
|
39
|
-
}
|
|
40
|
-
return defaultRowHeight;
|
|
27
|
+
const rowsMetaStateInitializer = (state, props, apiRef) => {
|
|
28
|
+
apiRef.current.caches.rowsMeta = {
|
|
29
|
+
heights: new Map()
|
|
30
|
+
};
|
|
31
|
+
return (0, _extends2.default)({}, state, {
|
|
32
|
+
rowsMeta: {
|
|
33
|
+
currentPageTotalHeight: 0,
|
|
34
|
+
positions: []
|
|
35
|
+
}
|
|
36
|
+
});
|
|
41
37
|
};
|
|
42
|
-
const rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
|
|
43
|
-
const getRowHeightWarning = [`MUI X: The \`getRowHeight\` prop should return a number greater than 0 or 'auto'.`, `The default value will be used instead.`].join('\n');
|
|
44
38
|
|
|
45
39
|
/**
|
|
46
40
|
* @requires useGridPageSize (method)
|
|
47
41
|
* @requires useGridPage (method)
|
|
48
42
|
*/
|
|
43
|
+
exports.rowsMetaStateInitializer = rowsMetaStateInitializer;
|
|
49
44
|
const useGridRowsMeta = (apiRef, props) => {
|
|
50
45
|
const {
|
|
51
46
|
getRowHeight: getRowHeightProp,
|
|
52
47
|
getRowSpacing,
|
|
53
48
|
getEstimatedRowHeight
|
|
54
49
|
} = props;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
// Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
|
|
50
|
+
const heightCache = apiRef.current.caches.rowsMeta.heights;
|
|
58
51
|
const lastMeasuredRowIndex = React.useRef(-1);
|
|
59
52
|
const hasRowWithAutoHeight = React.useRef(false);
|
|
53
|
+
const isHeightMetaValid = React.useRef(false);
|
|
60
54
|
const densityFactor = (0, _useGridSelector.useGridSelector)(apiRef, _densitySelector.gridDensityFactorSelector);
|
|
61
55
|
const filterModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterModelSelector);
|
|
62
56
|
const paginationState = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationSelector);
|
|
63
57
|
const sortModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridSortingSelector.gridSortModelSelector);
|
|
64
58
|
const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
|
|
65
59
|
const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
60
|
+
const rowHeight = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state).rowHeight);
|
|
61
|
+
const getRowHeightEntry = rowId => {
|
|
62
|
+
let entry = heightCache.get(rowId);
|
|
63
|
+
if (entry === undefined) {
|
|
64
|
+
entry = {
|
|
65
|
+
content: rowHeight,
|
|
66
|
+
spacingTop: 0,
|
|
67
|
+
spacingBottom: 0,
|
|
68
|
+
detail: 0,
|
|
69
|
+
autoHeight: false,
|
|
70
|
+
needsFirstMeasurement: true
|
|
71
|
+
};
|
|
72
|
+
heightCache.set(rowId, entry);
|
|
73
|
+
}
|
|
74
|
+
return entry;
|
|
75
|
+
};
|
|
76
|
+
const processHeightEntry = React.useCallback(row => {
|
|
77
|
+
// HACK: rowHeight trails behind the most up-to-date value just enough to
|
|
78
|
+
// mess the initial rowsMeta hydration :/
|
|
79
|
+
const baseRowHeight = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state).rowHeight;
|
|
80
|
+
(0, _utils.eslintUseValue)(rowHeight);
|
|
81
|
+
const entry = apiRef.current.getRowHeightEntry(row.id);
|
|
82
|
+
if (!getRowHeightProp) {
|
|
83
|
+
entry.content = baseRowHeight;
|
|
84
|
+
entry.needsFirstMeasurement = false;
|
|
85
|
+
} else {
|
|
86
|
+
const rowHeightFromUser = getRowHeightProp((0, _extends2.default)({}, row, {
|
|
87
|
+
densityFactor
|
|
88
|
+
}));
|
|
89
|
+
if (rowHeightFromUser === 'auto') {
|
|
90
|
+
if (entry.needsFirstMeasurement) {
|
|
91
|
+
const estimatedRowHeight = getEstimatedRowHeight ? getEstimatedRowHeight((0, _extends2.default)({}, row, {
|
|
92
|
+
densityFactor
|
|
93
|
+
})) : baseRowHeight;
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
} else {
|
|
104
|
-
baseRowHeight = existingBaseRowHeight;
|
|
105
|
-
}
|
|
106
|
-
hasRowWithAutoHeight.current = true;
|
|
107
|
-
rowsHeightLookup.current[row.id].autoHeight = true;
|
|
108
|
-
} else {
|
|
109
|
-
// Default back to base rowHeight if getRowHeight returns invalid value.
|
|
110
|
-
baseRowHeight = getValidRowHeight(rowHeightFromUser, rowHeight, getRowHeightWarning);
|
|
111
|
-
rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
|
|
112
|
-
rowsHeightLookup.current[row.id].autoHeight = false;
|
|
95
|
+
// If the row was not measured yet use the estimated row height
|
|
96
|
+
entry.content = estimatedRowHeight ?? baseRowHeight;
|
|
113
97
|
}
|
|
98
|
+
hasRowWithAutoHeight.current = true;
|
|
99
|
+
entry.autoHeight = true;
|
|
114
100
|
} else {
|
|
115
|
-
|
|
101
|
+
// Default back to base rowHeight if getRowHeight returns invalid value.
|
|
102
|
+
entry.content = (0, _gridRowsUtils.getValidRowHeight)(rowHeightFromUser, baseRowHeight, _gridRowsUtils.getRowHeightWarning);
|
|
103
|
+
entry.needsFirstMeasurement = false;
|
|
104
|
+
entry.autoHeight = false;
|
|
116
105
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
106
|
+
}
|
|
107
|
+
if (getRowSpacing) {
|
|
108
|
+
const indexRelativeToCurrentPage = apiRef.current.getRowIndexRelativeToVisibleRows(row.id);
|
|
109
|
+
const spacing = getRowSpacing((0, _extends2.default)({}, row, {
|
|
110
|
+
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
111
|
+
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
|
|
112
|
+
indexRelativeToCurrentPage
|
|
113
|
+
}));
|
|
114
|
+
entry.spacingTop = spacing.top ?? 0;
|
|
115
|
+
entry.spacingBottom = spacing.bottom ?? 0;
|
|
116
|
+
} else {
|
|
117
|
+
entry.spacingTop = 0;
|
|
118
|
+
entry.spacingBottom = 0;
|
|
119
|
+
}
|
|
120
|
+
apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row);
|
|
121
|
+
return entry;
|
|
122
|
+
}, [apiRef, currentPage.rows.length, getRowHeightProp, getEstimatedRowHeight, rowHeight, getRowSpacing, densityFactor]);
|
|
123
|
+
const hydrateRowsMeta = React.useCallback(() => {
|
|
124
|
+
hasRowWithAutoHeight.current = false;
|
|
125
|
+
pinnedRows.top.forEach(processHeightEntry);
|
|
126
|
+
pinnedRows.bottom.forEach(processHeightEntry);
|
|
134
127
|
const positions = [];
|
|
135
128
|
const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
|
|
136
129
|
positions.push(acc);
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
for (const key in processedSizes) {
|
|
141
|
-
const value = processedSizes[key];
|
|
142
|
-
if (key !== 'baseCenter') {
|
|
143
|
-
otherSizes += value;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return acc + processedSizes.baseCenter + otherSizes;
|
|
130
|
+
const entry = processHeightEntry(row);
|
|
131
|
+
const total = entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
|
|
132
|
+
return acc + total;
|
|
147
133
|
}, 0);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
calculateRowProcessedSizes(row);
|
|
153
|
-
});
|
|
134
|
+
if (!hasRowWithAutoHeight.current) {
|
|
135
|
+
// No row has height=auto, so all rows are already measured
|
|
136
|
+
lastMeasuredRowIndex.current = Infinity;
|
|
137
|
+
}
|
|
154
138
|
apiRef.current.setState(state => {
|
|
155
139
|
return (0, _extends2.default)({}, state, {
|
|
156
140
|
rowsMeta: {
|
|
@@ -159,70 +143,68 @@ const useGridRowsMeta = (apiRef, props) => {
|
|
|
159
143
|
}
|
|
160
144
|
});
|
|
161
145
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}, [hydrateRowsMeta]);
|
|
179
|
-
const debouncedHydrateRowsMeta = React.useMemo(() => (0, _utils.unstable_debounce)(hydrateRowsMeta, props.rowPositionsDebounceMs), [hydrateRowsMeta, props.rowPositionsDebounceMs]);
|
|
180
|
-
const storeMeasuredRowHeight = React.useCallback((id, height) => {
|
|
181
|
-
if (!rowsHeightLookup.current[id] || !rowsHeightLookup.current[id].autoHeight) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Only trigger hydration if the value is different, otherwise we trigger a loop
|
|
186
|
-
const needsHydration = rowsHeightLookup.current[id].sizes.baseCenter !== height;
|
|
187
|
-
rowsHeightLookup.current[id].needsFirstMeasurement = false;
|
|
188
|
-
rowsHeightLookup.current[id].sizes.baseCenter = height;
|
|
189
|
-
if (needsHydration) {
|
|
190
|
-
debouncedHydrateRowsMeta();
|
|
191
|
-
}
|
|
192
|
-
}, [debouncedHydrateRowsMeta]);
|
|
193
|
-
const rowHasAutoHeight = React.useCallback(id => {
|
|
194
|
-
return rowsHeightLookup.current[id]?.autoHeight || false;
|
|
195
|
-
}, []);
|
|
196
|
-
const getLastMeasuredRowIndex = React.useCallback(() => {
|
|
146
|
+
isHeightMetaValid.current = true;
|
|
147
|
+
}, [apiRef, pinnedRows, currentPage.rows, processHeightEntry]);
|
|
148
|
+
const getRowHeight = rowId => {
|
|
149
|
+
return heightCache.get(rowId)?.content ?? rowHeight;
|
|
150
|
+
};
|
|
151
|
+
const storeRowHeightMeasurement = (id, height) => {
|
|
152
|
+
const entry = apiRef.current.getRowHeightEntry(id);
|
|
153
|
+
const didChange = entry.content !== height;
|
|
154
|
+
entry.needsFirstMeasurement = false;
|
|
155
|
+
entry.content = height;
|
|
156
|
+
isHeightMetaValid.current && (isHeightMetaValid.current = !didChange);
|
|
157
|
+
};
|
|
158
|
+
const rowHasAutoHeight = id => {
|
|
159
|
+
return heightCache.get(id)?.autoHeight ?? false;
|
|
160
|
+
};
|
|
161
|
+
const getLastMeasuredRowIndex = () => {
|
|
197
162
|
return lastMeasuredRowIndex.current;
|
|
198
|
-
}
|
|
199
|
-
const setLastMeasuredRowIndex =
|
|
163
|
+
};
|
|
164
|
+
const setLastMeasuredRowIndex = index => {
|
|
200
165
|
if (hasRowWithAutoHeight.current && index > lastMeasuredRowIndex.current) {
|
|
201
166
|
lastMeasuredRowIndex.current = index;
|
|
202
167
|
}
|
|
203
|
-
}
|
|
204
|
-
const resetRowHeights =
|
|
205
|
-
|
|
168
|
+
};
|
|
169
|
+
const resetRowHeights = () => {
|
|
170
|
+
heightCache.clear();
|
|
206
171
|
hydrateRowsMeta();
|
|
207
|
-
}
|
|
172
|
+
};
|
|
173
|
+
const resizeObserver = (0, _useLazyRef.default)(() => new _ResizeObserver.ResizeObserver(entries => {
|
|
174
|
+
for (let i = 0; i < entries.length; i += 1) {
|
|
175
|
+
const entry = entries[i];
|
|
176
|
+
const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
177
|
+
const rowId = entry.target.__mui_id;
|
|
178
|
+
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
|
|
179
|
+
}
|
|
180
|
+
if (!isHeightMetaValid.current) {
|
|
181
|
+
apiRef.current.requestPipeProcessorsApplication('rowHeight');
|
|
182
|
+
}
|
|
183
|
+
})).current;
|
|
184
|
+
const observeRowHeight = (element, rowId) => {
|
|
185
|
+
element.__mui_id = rowId;
|
|
186
|
+
resizeObserver.observe(element);
|
|
187
|
+
return () => resizeObserver.unobserve(element);
|
|
188
|
+
};
|
|
189
|
+
(0, _pipeProcessing.useGridRegisterPipeApplier)(apiRef, 'rowHeight', hydrateRowsMeta);
|
|
208
190
|
|
|
209
191
|
// The effect is used to build the rows meta data - currentPageTotalHeight and positions.
|
|
210
192
|
// Because of variable row height this is needed for the virtualization
|
|
211
193
|
React.useEffect(() => {
|
|
212
194
|
hydrateRowsMeta();
|
|
213
|
-
}, [
|
|
214
|
-
(0, _pipeProcessing.useGridRegisterPipeApplier)(apiRef, 'rowHeight', hydrateRowsMeta);
|
|
195
|
+
}, [filterModel, paginationState, sortModel, hydrateRowsMeta]);
|
|
215
196
|
const rowsMetaApi = {
|
|
216
|
-
unstable_setLastMeasuredRowIndex: setLastMeasuredRowIndex,
|
|
217
197
|
unstable_getRowHeight: getRowHeight,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
unstable_storeRowHeightMeasurement: storeMeasuredRowHeight,
|
|
198
|
+
unstable_setLastMeasuredRowIndex: setLastMeasuredRowIndex,
|
|
199
|
+
unstable_storeRowHeightMeasurement: storeRowHeightMeasurement,
|
|
221
200
|
resetRowHeights
|
|
222
201
|
};
|
|
223
202
|
const rowsMetaPrivateApi = {
|
|
224
|
-
|
|
225
|
-
|
|
203
|
+
hydrateRowsMeta,
|
|
204
|
+
observeRowHeight,
|
|
205
|
+
rowHasAutoHeight,
|
|
206
|
+
getRowHeightEntry,
|
|
207
|
+
getLastMeasuredRowIndex
|
|
226
208
|
};
|
|
227
209
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, rowsMetaApi, 'public');
|
|
228
210
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, rowsMetaPrivateApi, 'private');
|
|
@@ -16,6 +16,7 @@ var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
|
16
16
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
17
17
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
18
18
|
var _dimensions = require("../dimensions");
|
|
19
|
+
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
19
20
|
// Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
|
|
20
21
|
// Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
21
22
|
function scrollIntoView(dimensions) {
|
|
@@ -59,7 +60,7 @@ const useGridScroll = (apiRef, props) => {
|
|
|
59
60
|
const scrollToIndexes = React.useCallback(params => {
|
|
60
61
|
const dimensions = (0, _dimensions.gridDimensionsSelector)(apiRef.current.state);
|
|
61
62
|
const totalRowCount = (0, _gridRowsSelector.gridRowCountSelector)(apiRef);
|
|
62
|
-
const visibleColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
63
|
+
const visibleColumns = props.unstable_listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
63
64
|
const scrollToHeader = params.rowIndex == null;
|
|
64
65
|
if (!scrollToHeader && totalRowCount === 0 || visibleColumns.length === 0) {
|
|
65
66
|
return false;
|
|
@@ -106,7 +107,7 @@ const useGridScroll = (apiRef, props) => {
|
|
|
106
107
|
return true;
|
|
107
108
|
}
|
|
108
109
|
return false;
|
|
109
|
-
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows]);
|
|
110
|
+
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows, props.unstable_listView]);
|
|
110
111
|
const scroll = React.useCallback(params => {
|
|
111
112
|
if (virtualScrollerRef.current && virtualScrollbarHorizontalRef.current && params.left !== undefined && colRef.current) {
|
|
112
113
|
const direction = isRtl ? -1 : 1;
|
|
@@ -36,6 +36,7 @@ var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
|
36
36
|
var _gridVirtualizationSelectors = require("./gridVirtualizationSelectors");
|
|
37
37
|
var _useGridVirtualization = require("./useGridVirtualization");
|
|
38
38
|
var _gridRowSpanningSelectors = require("../rows/gridRowSpanningSelectors");
|
|
39
|
+
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
39
40
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
40
41
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
41
42
|
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
@@ -66,13 +67,20 @@ try {
|
|
|
66
67
|
const useGridVirtualScroller = () => {
|
|
67
68
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
68
69
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
69
|
-
const
|
|
70
|
+
const {
|
|
71
|
+
unstable_listView: listView
|
|
72
|
+
} = rootProps;
|
|
73
|
+
const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, () => listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef));
|
|
70
74
|
const enabledForRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationRowEnabledSelector) && !isJSDOM;
|
|
71
75
|
const enabledForColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationColumnEnabledSelector) && !isJSDOM;
|
|
72
76
|
const dimensions = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridDimensionsSelector);
|
|
73
77
|
const outerSize = dimensions.viewportOuterSize;
|
|
74
78
|
const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
|
|
75
|
-
const
|
|
79
|
+
const pinnedColumnDefinitions = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector);
|
|
80
|
+
const pinnedColumns = listView ? {
|
|
81
|
+
left: [],
|
|
82
|
+
right: []
|
|
83
|
+
} : pinnedColumnDefinitions;
|
|
76
84
|
const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
|
|
77
85
|
const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
|
|
78
86
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
@@ -139,7 +147,7 @@ const useGridVirtualScroller = () => {
|
|
|
139
147
|
}
|
|
140
148
|
previousContextScrollPosition.current = scrollPosition.current;
|
|
141
149
|
}, [apiRef, dimensions.isReady]);
|
|
142
|
-
const triggerUpdateRenderContext = () => {
|
|
150
|
+
const triggerUpdateRenderContext = (0, _utils.unstable_useEventCallback)(() => {
|
|
143
151
|
const newScroll = {
|
|
144
152
|
top: scrollerRef.current.scrollTop,
|
|
145
153
|
left: scrollerRef.current.scrollLeft
|
|
@@ -187,7 +195,7 @@ const useGridVirtualScroller = () => {
|
|
|
187
195
|
});
|
|
188
196
|
scrollTimeout.start(1000, triggerUpdateRenderContext);
|
|
189
197
|
return nextRenderContext;
|
|
190
|
-
};
|
|
198
|
+
});
|
|
191
199
|
const forceUpdateRenderContext = () => {
|
|
192
200
|
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
193
201
|
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
@@ -373,11 +381,11 @@ const useGridVirtualScroller = () => {
|
|
|
373
381
|
});
|
|
374
382
|
return rows;
|
|
375
383
|
};
|
|
376
|
-
const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth
|
|
384
|
+
const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth > outerSize.width;
|
|
377
385
|
const scrollerStyle = React.useMemo(() => ({
|
|
378
|
-
overflowX: !needsHorizontalScrollbar ? 'hidden' : undefined,
|
|
386
|
+
overflowX: !needsHorizontalScrollbar || listView ? 'hidden' : undefined,
|
|
379
387
|
overflowY: rootProps.autoHeight ? 'hidden' : undefined
|
|
380
|
-
}), [needsHorizontalScrollbar, rootProps.autoHeight]);
|
|
388
|
+
}), [needsHorizontalScrollbar, rootProps.autoHeight, listView]);
|
|
381
389
|
const contentSize = React.useMemo(() => {
|
|
382
390
|
const size = {
|
|
383
391
|
width: needsHorizontalScrollbar ? columnsTotalWidth : 'auto',
|
|
@@ -404,6 +412,11 @@ const useGridVirtualScroller = () => {
|
|
|
404
412
|
scrollerRef.current.scrollTop = 0;
|
|
405
413
|
}
|
|
406
414
|
}, [enabledForColumns, enabledForRows, gridRootRef, scrollerRef]);
|
|
415
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
416
|
+
if (listView) {
|
|
417
|
+
scrollerRef.current.scrollLeft = 0;
|
|
418
|
+
}
|
|
419
|
+
}, [listView, scrollerRef]);
|
|
407
420
|
(0, _useRunOnce.useRunOnce)(outerSize.width !== 0, () => {
|
|
408
421
|
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
409
422
|
const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
@@ -459,7 +472,7 @@ exports.useGridVirtualScroller = useGridVirtualScroller;
|
|
|
459
472
|
function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
460
473
|
const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
|
|
461
474
|
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, rootProps);
|
|
462
|
-
const visibleColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
475
|
+
const visibleColumns = rootProps.unstable_listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
463
476
|
const hiddenCellsOriginMap = (0, _gridRowSpanningSelectors.gridRowSpanningHiddenCellsOriginMapSelector)(apiRef);
|
|
464
477
|
const lastRowId = apiRef.current.state.rows.dataRowIds.at(-1);
|
|
465
478
|
const lastColumn = visibleColumns.at(-1);
|
|
@@ -482,7 +495,8 @@ function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
|
482
495
|
range: currentPage.range,
|
|
483
496
|
pinnedColumns: (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef),
|
|
484
497
|
visibleColumns,
|
|
485
|
-
hiddenCellsOriginMap
|
|
498
|
+
hiddenCellsOriginMap,
|
|
499
|
+
listView: rootProps.unstable_listView ?? false
|
|
486
500
|
};
|
|
487
501
|
}
|
|
488
502
|
function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.useGridApiMethod = useGridApiMethod;
|
|
8
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
9
11
|
function useGridApiMethod(privateApiRef, apiMethods, visibility) {
|
|
10
12
|
const isFirstRender = React.useRef(true);
|
|
11
|
-
|
|
13
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
12
14
|
isFirstRender.current = false;
|
|
13
15
|
privateApiRef.current.register(visibility, apiMethods);
|
|
14
16
|
}, [privateApiRef, visibility, apiMethods]);
|
package/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-data-grid v7.
|
|
2
|
+
* @mui/x-data-grid v7.21.0
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -100,6 +100,18 @@ Object.keys(_constants).forEach(function (key) {
|
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
|
+
var _dataGridPropsDefaultValues = require("./constants/dataGridPropsDefaultValues");
|
|
104
|
+
Object.keys(_dataGridPropsDefaultValues).forEach(function (key) {
|
|
105
|
+
if (key === "default" || key === "__esModule") return;
|
|
106
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
107
|
+
if (key in exports && exports[key] === _dataGridPropsDefaultValues[key]) return;
|
|
108
|
+
Object.defineProperty(exports, key, {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _dataGridPropsDefaultValues[key];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
103
115
|
var _hooks = require("./hooks");
|
|
104
116
|
Object.keys(_hooks).forEach(function (key) {
|
|
105
117
|
if (key === "default" || key === "__esModule") return;
|
package/node/internals/index.js
CHANGED
|
@@ -81,6 +81,8 @@ var _exportNames = {
|
|
|
81
81
|
useGridColumnResize: true,
|
|
82
82
|
columnResizeStateInitializer: true,
|
|
83
83
|
ROW_SELECTION_PROPAGATION_DEFAULT: true,
|
|
84
|
+
useGridListView: true,
|
|
85
|
+
listViewStateInitializer: true,
|
|
84
86
|
useTimeout: true,
|
|
85
87
|
useGridVisibleRows: true,
|
|
86
88
|
getVisibleRows: true,
|
|
@@ -97,6 +99,7 @@ var _exportNames = {
|
|
|
97
99
|
isEventTargetInPortal: true,
|
|
98
100
|
isNavigationKey: true,
|
|
99
101
|
isPasteShortcut: true,
|
|
102
|
+
isCopyShortcut: true,
|
|
100
103
|
exportAs: true,
|
|
101
104
|
useGridPrivateApiContext: true,
|
|
102
105
|
serializeCellValue: true
|
|
@@ -359,6 +362,12 @@ Object.defineProperty(exports, "headerFilteringStateInitializer", {
|
|
|
359
362
|
return _useGridHeaderFiltering.headerFilteringStateInitializer;
|
|
360
363
|
}
|
|
361
364
|
});
|
|
365
|
+
Object.defineProperty(exports, "isCopyShortcut", {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function () {
|
|
368
|
+
return _keyboardUtils.isCopyShortcut;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
362
371
|
Object.defineProperty(exports, "isEventTargetInPortal", {
|
|
363
372
|
enumerable: true,
|
|
364
373
|
get: function () {
|
|
@@ -383,6 +392,12 @@ Object.defineProperty(exports, "isSingleSelectColDef", {
|
|
|
383
392
|
return _filterPanelUtils.isSingleSelectColDef;
|
|
384
393
|
}
|
|
385
394
|
});
|
|
395
|
+
Object.defineProperty(exports, "listViewStateInitializer", {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: function () {
|
|
398
|
+
return _useGridListView.listViewStateInitializer;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
386
401
|
Object.defineProperty(exports, "paginationStateInitializer", {
|
|
387
402
|
enumerable: true,
|
|
388
403
|
get: function () {
|
|
@@ -551,6 +566,12 @@ Object.defineProperty(exports, "useGridKeyboardNavigation", {
|
|
|
551
566
|
return _useGridKeyboardNavigation.useGridKeyboardNavigation;
|
|
552
567
|
}
|
|
553
568
|
});
|
|
569
|
+
Object.defineProperty(exports, "useGridListView", {
|
|
570
|
+
enumerable: true,
|
|
571
|
+
get: function () {
|
|
572
|
+
return _useGridListView.useGridListView;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
554
575
|
Object.defineProperty(exports, "useGridPagination", {
|
|
555
576
|
enumerable: true,
|
|
556
577
|
get: function () {
|
|
@@ -775,6 +796,7 @@ Object.keys(_virtualization).forEach(function (key) {
|
|
|
775
796
|
});
|
|
776
797
|
var _useGridColumnResize = require("../hooks/features/columnResize/useGridColumnResize");
|
|
777
798
|
var _utils = require("../hooks/features/rowSelection/utils");
|
|
799
|
+
var _useGridListView = require("../hooks/features/listView/useGridListView");
|
|
778
800
|
var _useTimeout = require("../hooks/utils/useTimeout");
|
|
779
801
|
var _useGridVisibleRows = require("../hooks/utils/useGridVisibleRows");
|
|
780
802
|
var _useGridInitializeState = require("../hooks/utils/useGridInitializeState");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ResizeObserver = void 0;
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* HACK: Minimal shim to get jsdom to work.
|
|
11
|
+
*/
|
|
12
|
+
const ResizeObserver = exports.ResizeObserver = typeof globalThis.ResizeObserver !== 'undefined' ? globalThis.ResizeObserver : class ResizeObserver {
|
|
13
|
+
observe() {}
|
|
14
|
+
unobserve() {}
|
|
15
|
+
disconnect() {}
|
|
16
|
+
};
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
|
|
7
|
+
exports.isCopyShortcut = isCopyShortcut;
|
|
8
|
+
exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = void 0;
|
|
7
9
|
exports.isPasteShortcut = isPasteShortcut;
|
|
8
10
|
exports.isPrintableKey = isPrintableKey;
|
|
9
11
|
// Non printable keys have a name, for example "ArrowRight", see the whole list:
|
|
@@ -37,8 +39,16 @@ const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
|
|
|
37
39
|
// However, maybe it's overkill to fix, so let's be lazy.
|
|
38
40
|
exports.isHideMenuKey = isHideMenuKey;
|
|
39
41
|
function isPasteShortcut(event) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
return (event.ctrlKey || event.metaKey) &&
|
|
43
|
+
// We can't use event.code === 'KeyV' as event.code assumes a QWERTY keyboard layout,
|
|
44
|
+
// for example, it would be another letter on a Dvorak physical keyboard.
|
|
45
|
+
// We can't use event.key === 'v' as event.key is not stable with key modifiers and keyboard layouts,
|
|
46
|
+
// for example, it would be ה on a Hebrew keyboard layout.
|
|
47
|
+
// https://github.com/w3c/uievents/issues/377 could be a long-term solution
|
|
48
|
+
String.fromCharCode(event.keyCode) === 'V' && !event.shiftKey && !event.altKey;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Checks if the keyboard event corresponds to the copy shortcut (CTRL+C or CMD+C) across different localization keyboards.
|
|
52
|
+
function isCopyShortcut(event) {
|
|
53
|
+
return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'C' && !event.shiftKey && !event.altKey;
|
|
44
54
|
}
|