@mui/x-data-grid 7.19.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 +224 -43
- package/DataGrid/DataGrid.js +8 -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/columnHeaders/GridColumnHeaderItem.js +1 -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/core/useGridRefs.js +4 -0
- 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 +6 -4
- package/hooks/features/editing/useGridCellEditing.js +3 -1
- package/hooks/features/editing/useGridRowEditing.js +3 -1
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +1 -0
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- 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 +6 -6
- 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 +15 -2
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/hooks/features/rows/useGridParamsApi.js +4 -3
- package/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.js +10 -5
- package/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
- package/hooks/utils/useGridApiContext.js +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.js +1 -1
- package/hooks/utils/useGridApiMethod.js +2 -1
- package/hooks/utils/useGridConfiguration.js +1 -1
- package/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/index.d.ts +3 -2
- package/index.js +4 -3
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/joy/icons.js +0 -1
- package/locales/jaJP.js +4 -4
- package/models/api/gridApiCommunity.d.ts +1 -1
- package/models/api/gridCoreApi.d.ts +9 -1
- package/models/api/gridFilterApi.d.ts +1 -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/events/gridEventLookup.d.ts +7 -0
- package/models/gridApiCaches.d.ts +2 -0
- package/models/gridStateCommunity.d.ts +4 -2
- package/models/props/DataGridProps.d.ts +37 -17
- package/modern/DataGrid/DataGrid.js +8 -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/columnHeaders/GridColumnHeaderItem.js +1 -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/core/useGridRefs.js +4 -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 +6 -4
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +3 -1
- package/modern/hooks/features/events/useGridEvents.js +1 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- 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 +6 -6
- package/modern/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +15 -2
- package/modern/hooks/features/rows/useGridParamsApi.js +4 -3
- package/modern/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/modern/hooks/features/scroll/useGridScroll.js +10 -5
- package/modern/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
- package/modern/hooks/utils/useGridApiContext.js +1 -1
- package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
- package/modern/hooks/utils/useGridApiMethod.js +2 -1
- package/modern/hooks/utils/useGridConfiguration.js +1 -1
- package/modern/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/modern/index.js +4 -3
- package/modern/internals/index.js +2 -1
- package/modern/joy/icons.js +0 -1
- package/modern/locales/jaJP.js +4 -4
- package/modern/utils/ResizeObserver.js +10 -0
- package/modern/utils/domUtils.js +1 -1
- package/modern/utils/keyboardUtils.js +12 -4
- package/node/DataGrid/DataGrid.js +8 -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/columnHeaders/GridColumnHeaderItem.js +1 -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/core/useGridRefs.js +4 -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 +5 -3
- package/node/hooks/features/editing/useGridCellEditing.js +3 -1
- package/node/hooks/features/editing/useGridRowEditing.js +3 -1
- package/node/hooks/features/events/useGridEvents.js +1 -0
- package/node/hooks/features/filter/gridFilterUtils.js +1 -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 +6 -6
- package/node/hooks/features/rows/gridRowsMetaInterfaces.js +5 -0
- package/node/hooks/features/rows/gridRowsUtils.js +17 -3
- package/node/hooks/features/rows/useGridParamsApi.js +4 -3
- package/node/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -154
- package/node/hooks/features/scroll/useGridScroll.js +10 -5
- package/node/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
- package/node/hooks/utils/useGridApiContext.js +1 -1
- package/node/hooks/utils/useGridApiEventHandler.js +1 -1
- package/node/hooks/utils/useGridApiMethod.js +3 -1
- package/node/hooks/utils/useGridConfiguration.js +1 -1
- package/node/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/node/index.js +13 -1
- package/node/internals/index.js +22 -0
- package/node/joy/icons.js +0 -1
- package/node/locales/jaJP.js +4 -4
- package/node/utils/ResizeObserver.js +16 -0
- package/node/utils/domUtils.js +1 -1
- package/node/utils/keyboardUtils.js +15 -5
- package/package.json +4 -4
- package/utils/ResizeObserver.d.ts +4 -0
- package/utils/ResizeObserver.js +10 -0
- package/utils/domUtils.js +1 -1
- package/utils/keyboardUtils.d.ts +1 -0
- package/utils/keyboardUtils.js +12 -4
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");
|
package/node/joy/icons.js
CHANGED
|
@@ -42,7 +42,6 @@ function createSvgIcon(path, displayName) {
|
|
|
42
42
|
} = _ref,
|
|
43
43
|
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
44
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SvgIcon.default, (0, _extends2.default)({
|
|
45
|
-
"data-testid": `${displayName}Icon`,
|
|
46
45
|
ref: ref,
|
|
47
46
|
fill: "none",
|
|
48
47
|
stroke: "currentColor",
|
package/node/locales/jaJP.js
CHANGED
|
@@ -53,9 +53,9 @@ const jaJPGrid = {
|
|
|
53
53
|
filterPanelInputPlaceholder: '値を入力…',
|
|
54
54
|
// Filter operators text
|
|
55
55
|
filterOperatorContains: '...を含む',
|
|
56
|
-
|
|
56
|
+
filterOperatorDoesNotContain: '...を含まない',
|
|
57
57
|
filterOperatorEquals: '...に等しい',
|
|
58
|
-
|
|
58
|
+
filterOperatorDoesNotEqual: '...に等しくない',
|
|
59
59
|
filterOperatorStartsWith: '...で始まる',
|
|
60
60
|
filterOperatorEndsWith: '...で終わる',
|
|
61
61
|
filterOperatorIs: '...である',
|
|
@@ -75,9 +75,9 @@ const jaJPGrid = {
|
|
|
75
75
|
'filterOperator<=': '<=',
|
|
76
76
|
// Header filter operators text
|
|
77
77
|
headerFilterOperatorContains: '含む',
|
|
78
|
-
|
|
78
|
+
headerFilterOperatorDoesNotContain: '含まない',
|
|
79
79
|
headerFilterOperatorEquals: '等しい',
|
|
80
|
-
|
|
80
|
+
headerFilterOperatorDoesNotEqual: '等しくない',
|
|
81
81
|
headerFilterOperatorStartsWith: 'で始まる',
|
|
82
82
|
headerFilterOperatorEndsWith: 'で終わる',
|
|
83
83
|
headerFilterOperatorIs: 'である',
|
|
@@ -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
|
+
};
|
package/node/utils/domUtils.js
CHANGED
|
@@ -213,7 +213,7 @@ function findGridCells(api, field) {
|
|
|
213
213
|
}
|
|
214
214
|
function queryRows(api) {
|
|
215
215
|
return api.virtualScrollerRef.current.querySelectorAll(
|
|
216
|
-
// Use > to ignore rows from nested
|
|
216
|
+
// Use > to ignore rows from nested Data Grids (for example in detail panel)
|
|
217
217
|
`:scope > div > div > .${_gridClasses.gridClasses.row}`);
|
|
218
218
|
}
|
|
219
219
|
function parseCellColIndex(col) {
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.21.0",
|
|
4
4
|
"description": "The Community plan edition of the Data Grid components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"directory": "packages/x-data-grid"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.25.
|
|
41
|
-
"@mui/utils": "^5.16.6",
|
|
40
|
+
"@babel/runtime": "^7.25.7",
|
|
41
|
+
"@mui/utils": "^5.16.6 || ^6.0.0",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"prop-types": "^15.8.1",
|
|
44
44
|
"reselect": "^5.1.1",
|
|
45
|
-
"@mui/x-internals": "7.
|
|
45
|
+
"@mui/x-internals": "7.21.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@emotion/react": "^11.9.0",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HACK: Minimal shim to get jsdom to work.
|
|
5
|
+
*/
|
|
6
|
+
export const ResizeObserver = typeof globalThis.ResizeObserver !== 'undefined' ? globalThis.ResizeObserver : class ResizeObserver {
|
|
7
|
+
observe() {}
|
|
8
|
+
unobserve() {}
|
|
9
|
+
disconnect() {}
|
|
10
|
+
};
|
package/utils/domUtils.js
CHANGED
|
@@ -187,7 +187,7 @@ export function findGridCells(api, field) {
|
|
|
187
187
|
}
|
|
188
188
|
function queryRows(api) {
|
|
189
189
|
return api.virtualScrollerRef.current.querySelectorAll(
|
|
190
|
-
// Use > to ignore rows from nested
|
|
190
|
+
// Use > to ignore rows from nested Data Grids (for example in detail panel)
|
|
191
191
|
`:scope > div > div > .${gridClasses.row}`);
|
|
192
192
|
}
|
|
193
193
|
function parseCellColIndex(col) {
|
package/utils/keyboardUtils.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare const isNavigationKey: (key: string) => boolean;
|
|
|
11
11
|
export declare const isKeyboardEvent: (event: any) => event is React.KeyboardEvent<HTMLElement>;
|
|
12
12
|
export declare const isHideMenuKey: (key: React.KeyboardEvent["key"]) => key is "Tab" | "Escape";
|
|
13
13
|
export declare function isPasteShortcut(event: React.KeyboardEvent): boolean;
|
|
14
|
+
export declare function isCopyShortcut(event: KeyboardEvent): boolean;
|
package/utils/keyboardUtils.js
CHANGED
|
@@ -22,8 +22,16 @@ export const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
|
|
|
22
22
|
// In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
|
|
23
23
|
// However, maybe it's overkill to fix, so let's be lazy.
|
|
24
24
|
export function isPasteShortcut(event) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
return (event.ctrlKey || event.metaKey) &&
|
|
26
|
+
// We can't use event.code === 'KeyV' as event.code assumes a QWERTY keyboard layout,
|
|
27
|
+
// for example, it would be another letter on a Dvorak physical keyboard.
|
|
28
|
+
// We can't use event.key === 'v' as event.key is not stable with key modifiers and keyboard layouts,
|
|
29
|
+
// for example, it would be ה on a Hebrew keyboard layout.
|
|
30
|
+
// https://github.com/w3c/uievents/issues/377 could be a long-term solution
|
|
31
|
+
String.fromCharCode(event.keyCode) === 'V' && !event.shiftKey && !event.altKey;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Checks if the keyboard event corresponds to the copy shortcut (CTRL+C or CMD+C) across different localization keyboards.
|
|
35
|
+
export function isCopyShortcut(event) {
|
|
36
|
+
return (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'C' && !event.shiftKey && !event.altKey;
|
|
29
37
|
}
|