@elliemae/ds-shared 2.2.0-alpha.4 → 3.0.0-next.2
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/cjs/Animations/BaseAnimation.js +35 -55
- package/cjs/Animations/Grow.js +41 -54
- package/cjs/Animations/GrowRight.js +41 -63
- package/cjs/Animations/GrowVertical.js +7 -47
- package/cjs/CheckableGroup.js +65 -67
- package/cjs/DeferRenderAfterComputation.js +24 -48
- package/cjs/FocusGroup/FocusGrid.js +143 -108
- package/cjs/FocusGroup/FocusGroup.js +147 -88
- package/cjs/FocusGroup/FocusGroupContext.js +11 -38
- package/cjs/FocusGroup/FocusGroupManager.js +47 -56
- package/cjs/FocusGroup/focusGroupManagerHoc.js +42 -52
- package/cjs/FocusGroup/index.js +21 -47
- package/cjs/FocusGroup/useFocusGroupItem.js +51 -59
- package/cjs/FocusGroup/utils/getNextCellPosition.js +27 -47
- package/cjs/GroupContext/Group.js +73 -64
- package/cjs/GroupContext/GroupContext.js +13 -36
- package/cjs/GroupContext/GroupItem.js +21 -39
- package/cjs/GroupContext/index.js +13 -39
- package/cjs/ScrollSync/ScrollSync.js +75 -60
- package/cjs/ScrollSync/ScrollSyncPane.js +60 -52
- package/cjs/ScrollSync/ScrollSyncProvider.js +50 -103
- package/cjs/ScrollSync/index.js +11 -37
- package/cjs/ScrollSync/useScrollSync.js +7 -38
- package/cjs/constants.js +46 -65
- package/cjs/createDataInstance/createInstancePlugin.js +29 -41
- package/cjs/createDataInstance/createInstanceRef.js +71 -66
- package/cjs/createDataInstance/utils.js +100 -76
- package/cjs/defer-render-hoc/index.js +41 -48
- package/cjs/dimsum.config.js +6 -38
- package/cjs/index.js +17 -40
- package/cjs/prop-types.js +49 -106
- package/cjs/react-spring/index.js +14 -28
- package/cjs/react-spring/renderprops.js +14 -28
- package/cjs/toolbar/ToolbarProvider.js +94 -82
- package/cjs/useDataGrid/VolatileRowsListener.js +13 -38
- package/cjs/useDataGrid/index.js +7 -36
- package/cjs/useDataGrid/initColumnDefinition.js +110 -105
- package/cjs/useDataGrid/useDataGrid.js +148 -122
- package/cjs/useDataList/index.js +7 -36
- package/cjs/useDataList/recordIterator.js +18 -42
- package/cjs/useDataList/useDataList.js +83 -74
- package/cjs/utils.js +80 -71
- package/cjs/virtualization/AutoHeightList.js +54 -62
- package/cjs/virtualization/FluidHeightList.js +48 -42
- package/cjs/virtualization/index.js +20 -48
- package/esm/Animations/BaseAnimation.js +29 -26
- package/esm/Animations/Grow.js +35 -25
- package/esm/Animations/GrowRight.js +35 -34
- package/esm/Animations/GrowVertical.js +4 -29
- package/esm/CheckableGroup.js +52 -35
- package/esm/DeferRenderAfterComputation.js +15 -16
- package/esm/FocusGroup/FocusGrid.js +117 -64
- package/esm/FocusGroup/FocusGroup.js +137 -56
- package/esm/FocusGroup/FocusGroupContext.js +5 -9
- package/esm/FocusGroup/FocusGroupManager.js +38 -24
- package/esm/FocusGroup/focusGroupManagerHoc.js +36 -24
- package/esm/FocusGroup/index.js +6 -18
- package/esm/FocusGroup/useFocusGroupItem.js +40 -28
- package/esm/FocusGroup/utils/getNextCellPosition.js +25 -18
- package/esm/GroupContext/Group.js +66 -34
- package/esm/GroupContext/GroupContext.js +5 -7
- package/esm/GroupContext/GroupItem.js +15 -10
- package/esm/GroupContext/index.js +3 -10
- package/esm/ScrollSync/ScrollSync.js +64 -30
- package/esm/ScrollSync/ScrollSyncPane.js +52 -22
- package/esm/ScrollSync/ScrollSyncProvider.js +42 -74
- package/esm/ScrollSync/index.js +2 -8
- package/esm/ScrollSync/useScrollSync.js +5 -9
- package/esm/constants.js +28 -37
- package/esm/createDataInstance/createInstancePlugin.js +23 -12
- package/esm/createDataInstance/createInstanceRef.js +59 -36
- package/esm/createDataInstance/utils.js +85 -48
- package/esm/defer-render-hoc/index.js +31 -17
- package/esm/dimsum.config.js +4 -9
- package/esm/index.js +5 -11
- package/esm/prop-types.js +31 -75
- package/esm/react-spring/index.js +1 -3
- package/esm/react-spring/renderprops.js +1 -3
- package/esm/toolbar/ToolbarProvider.js +74 -45
- package/esm/useDataGrid/VolatileRowsListener.js +11 -9
- package/esm/useDataGrid/index.js +1 -7
- package/esm/useDataGrid/initColumnDefinition.js +94 -78
- package/esm/useDataGrid/useDataGrid.js +99 -82
- package/esm/useDataList/index.js +1 -7
- package/esm/useDataList/recordIterator.js +14 -13
- package/esm/useDataList/useDataList.js +67 -44
- package/esm/utils.js +59 -42
- package/esm/virtualization/AutoHeightList.js +40 -28
- package/esm/virtualization/FluidHeightList.js +38 -14
- package/esm/virtualization/index.js +16 -19
- package/package.json +3 -3
- package/types/Animations/BaseAnimation.d.ts +0 -1
- package/types/Animations/Grow.d.ts +0 -1
- package/types/Animations/GrowRight.d.ts +0 -1
- package/types/CheckableGroup.d.ts +0 -1
- package/types/DeferRenderAfterComputation.d.ts +2 -3
- package/types/FocusGroup/FocusGrid.d.ts +3 -5
- package/types/FocusGroup/FocusGroup.d.ts +1 -3
- package/types/FocusGroup/FocusGroupContext.d.ts +2 -3
- package/types/FocusGroup/FocusGroupManager.d.ts +1 -3
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +1 -3
- package/types/FocusGroup/index.d.ts +6 -6
- package/types/FocusGroup/useFocusGroupItem.d.ts +1 -3
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +1 -3
- package/types/GroupContext/Group.d.ts +0 -1
- package/types/GroupContext/GroupItem.d.ts +0 -1
- package/types/GroupContext/index.d.ts +3 -3
- package/types/ScrollSync/ScrollSync.d.ts +2 -4
- package/types/ScrollSync/ScrollSyncPane.d.ts +2 -2
- package/types/ScrollSync/index.d.ts +2 -2
- package/types/ScrollSync/useScrollSync.d.ts +5 -6
- package/types/createDataInstance/createInstancePlugin.d.ts +1 -2
- package/types/createDataInstance/createInstanceRef.d.ts +1 -3
- package/types/dimsum.config.d.ts +2 -3
- package/types/index.d.ts +2 -2
- package/types/toolbar/ToolbarProvider.d.ts +8 -3
- package/types/useDataGrid/VolatileRowsListener.d.ts +1 -3
- package/types/useDataGrid/index.d.ts +1 -1
- package/types/useDataGrid/initColumnDefinition.d.ts +1 -2
- package/types/useDataGrid/useDataGrid.d.ts +2 -3
- package/types/useDataList/index.d.ts +1 -1
- package/types/useDataList/useDataList.d.ts +2 -3
- package/cjs/Animations/BaseAnimation.js.map +0 -7
- package/cjs/Animations/Grow.js.map +0 -7
- package/cjs/Animations/GrowRight.js.map +0 -7
- package/cjs/Animations/GrowVertical.js.map +0 -7
- package/cjs/CheckableGroup.js.map +0 -7
- package/cjs/DeferRenderAfterComputation.js.map +0 -7
- package/cjs/FocusGroup/FocusGrid.js.map +0 -7
- package/cjs/FocusGroup/FocusGroup.js.map +0 -7
- package/cjs/FocusGroup/FocusGroupContext.js.map +0 -7
- package/cjs/FocusGroup/FocusGroupManager.js.map +0 -7
- package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/cjs/FocusGroup/index.js.map +0 -7
- package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/cjs/GroupContext/Group.js.map +0 -7
- package/cjs/GroupContext/GroupContext.js.map +0 -7
- package/cjs/GroupContext/GroupItem.js.map +0 -7
- package/cjs/GroupContext/index.js.map +0 -7
- package/cjs/ScrollSync/ScrollSync.js.map +0 -7
- package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/cjs/ScrollSync/index.js.map +0 -7
- package/cjs/ScrollSync/useScrollSync.js.map +0 -7
- package/cjs/constants.js.map +0 -7
- package/cjs/createDataInstance/createInstancePlugin.js.map +0 -7
- package/cjs/createDataInstance/createInstanceRef.js.map +0 -7
- package/cjs/createDataInstance/utils.js.map +0 -7
- package/cjs/defer-render-hoc/index.js.map +0 -7
- package/cjs/dimsum.config.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/prop-types.js.map +0 -7
- package/cjs/react-spring/index.js.map +0 -7
- package/cjs/react-spring/renderprops.js.map +0 -7
- package/cjs/toolbar/ToolbarProvider.js.map +0 -7
- package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/cjs/useDataGrid/index.js.map +0 -7
- package/cjs/useDataGrid/initColumnDefinition.js.map +0 -7
- package/cjs/useDataGrid/useDataGrid.js.map +0 -7
- package/cjs/useDataList/index.js.map +0 -7
- package/cjs/useDataList/recordIterator.js.map +0 -7
- package/cjs/useDataList/useDataList.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/cjs/virtualization/AutoHeightList.js.map +0 -7
- package/cjs/virtualization/FluidHeightList.js.map +0 -7
- package/cjs/virtualization/index.js.map +0 -7
- package/esm/Animations/BaseAnimation.js.map +0 -7
- package/esm/Animations/Grow.js.map +0 -7
- package/esm/Animations/GrowRight.js.map +0 -7
- package/esm/Animations/GrowVertical.js.map +0 -7
- package/esm/CheckableGroup.js.map +0 -7
- package/esm/DeferRenderAfterComputation.js.map +0 -7
- package/esm/FocusGroup/FocusGrid.js.map +0 -7
- package/esm/FocusGroup/FocusGroup.js.map +0 -7
- package/esm/FocusGroup/FocusGroupContext.js.map +0 -7
- package/esm/FocusGroup/FocusGroupManager.js.map +0 -7
- package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -7
- package/esm/FocusGroup/index.js.map +0 -7
- package/esm/FocusGroup/useFocusGroupItem.js.map +0 -7
- package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -7
- package/esm/GroupContext/Group.js.map +0 -7
- package/esm/GroupContext/GroupContext.js.map +0 -7
- package/esm/GroupContext/GroupItem.js.map +0 -7
- package/esm/GroupContext/index.js.map +0 -7
- package/esm/ScrollSync/ScrollSync.js.map +0 -7
- package/esm/ScrollSync/ScrollSyncPane.js.map +0 -7
- package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -7
- package/esm/ScrollSync/index.js.map +0 -7
- package/esm/ScrollSync/useScrollSync.js.map +0 -7
- package/esm/constants.js.map +0 -7
- package/esm/createDataInstance/createInstancePlugin.js.map +0 -7
- package/esm/createDataInstance/createInstanceRef.js.map +0 -7
- package/esm/createDataInstance/utils.js.map +0 -7
- package/esm/defer-render-hoc/index.js.map +0 -7
- package/esm/dimsum.config.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/prop-types.js.map +0 -7
- package/esm/react-spring/index.js.map +0 -7
- package/esm/react-spring/renderprops.js.map +0 -7
- package/esm/toolbar/ToolbarProvider.js.map +0 -7
- package/esm/useDataGrid/VolatileRowsListener.js.map +0 -7
- package/esm/useDataGrid/index.js.map +0 -7
- package/esm/useDataGrid/initColumnDefinition.js.map +0 -7
- package/esm/useDataGrid/useDataGrid.js.map +0 -7
- package/esm/useDataList/index.js.map +0 -7
- package/esm/useDataList/recordIterator.js.map +0 -7
- package/esm/useDataList/useDataList.js.map +0 -7
- package/esm/utils.js.map +0 -7
- package/esm/virtualization/AutoHeightList.js.map +0 -7
- package/esm/virtualization/FluidHeightList.js.map +0 -7
- package/esm/virtualization/index.js.map +0 -7
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Object.keys(hotKeys).forEach((key) => {
|
|
44
|
-
const { handler, options } = hotKeys[key];
|
|
45
|
-
(0, import_ds_utilities.useHotkeys)({
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
14
|
+
var getNextCellPosition = require('./utils/getNextCellPosition.js');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
const FocusGridContext = /*#__PURE__*/React.createContext();
|
|
26
|
+
const {
|
|
27
|
+
Provider
|
|
28
|
+
} = FocusGridContext;
|
|
29
|
+
|
|
30
|
+
const preventDefault = e => e.preventDefault();
|
|
31
|
+
|
|
32
|
+
function registerHotKeysHooks(hotKeys, _ref) {
|
|
33
|
+
let {
|
|
34
|
+
focusedRow,
|
|
35
|
+
focusedCell
|
|
36
|
+
} = _ref;
|
|
37
|
+
Object.keys(hotKeys).forEach(key => {
|
|
38
|
+
const {
|
|
39
|
+
handler,
|
|
40
|
+
options
|
|
41
|
+
} = hotKeys[key];
|
|
42
|
+
dsUtilities.useHotkeys({
|
|
46
43
|
keys: key,
|
|
47
|
-
handler:
|
|
44
|
+
handler: e => {
|
|
48
45
|
e.preventDefault();
|
|
49
46
|
handler({
|
|
50
47
|
rowIndex: focusedRow.current,
|
|
@@ -54,59 +51,76 @@ function registerHotKeysHooks(hotKeys, { focusedRow, focusedCell }) {
|
|
|
54
51
|
options
|
|
55
52
|
});
|
|
56
53
|
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
54
|
+
} // eslint-disable-next-line max-statements
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function FocusGridProvider(_ref2) {
|
|
58
|
+
let {
|
|
59
|
+
shouldWrapRows = false,
|
|
60
|
+
shouldWrapCells = false,
|
|
61
|
+
shouldRefocus = true,
|
|
62
|
+
children,
|
|
63
|
+
keyBindings,
|
|
64
|
+
hotKeys
|
|
65
|
+
} = _ref2;
|
|
66
|
+
const focusedRow = React.useRef();
|
|
67
|
+
const focusedCell = React.useRef();
|
|
68
|
+
const grid = React.useRef([]);
|
|
69
|
+
const containerRef = React.useRef(document);
|
|
70
|
+
const child = React__default["default"].Children.only(children);
|
|
71
|
+
const decoratedChild = /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
72
|
+
innerRef: dsUtilities.mergeRefs(child.props.innerRef, containerRef)
|
|
73
73
|
});
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
const getNode = _ref3 => {
|
|
76
|
+
let {
|
|
77
|
+
rowIndex,
|
|
78
|
+
cellIndex
|
|
79
|
+
} = _ref3;
|
|
80
|
+
return dsUtilities.get(grid.current, [rowIndex, cellIndex]);
|
|
81
|
+
};
|
|
82
|
+
|
|
75
83
|
const register = (node, rowIndex, columnIndex) => {
|
|
76
|
-
if (!node)
|
|
77
|
-
|
|
84
|
+
if (!node) return;
|
|
85
|
+
|
|
78
86
|
if (!Array.isArray(grid.current[rowIndex])) {
|
|
79
87
|
grid.current[rowIndex] = [];
|
|
80
88
|
}
|
|
89
|
+
|
|
81
90
|
if (rowIndex === 0 && columnIndex === 0) {
|
|
82
|
-
node.setAttribute(
|
|
91
|
+
node.setAttribute('tabindex', 0);
|
|
83
92
|
} else {
|
|
84
|
-
node.setAttribute(
|
|
93
|
+
node.setAttribute('tabindex', -1);
|
|
85
94
|
}
|
|
95
|
+
|
|
86
96
|
node.onfocus = () => {
|
|
87
97
|
const prevNode = getNode({
|
|
88
98
|
rowIndex: focusedRow.current,
|
|
89
99
|
cellIndex: focusedCell.current
|
|
90
100
|
});
|
|
91
|
-
if (prevNode)
|
|
92
|
-
|
|
93
|
-
node.setAttribute("tabindex", 0);
|
|
101
|
+
if (prevNode) prevNode.setAttribute('tabindex', -1);
|
|
102
|
+
node.setAttribute('tabindex', 0);
|
|
94
103
|
focusedRow.current = rowIndex;
|
|
95
104
|
focusedCell.current = columnIndex;
|
|
96
105
|
};
|
|
106
|
+
|
|
97
107
|
grid.current[rowIndex][columnIndex] = node;
|
|
98
108
|
};
|
|
99
|
-
|
|
109
|
+
|
|
110
|
+
React.useEffect(() => {
|
|
100
111
|
if (shouldRefocus) {
|
|
101
112
|
const rowIndex = focusedRow.current;
|
|
102
113
|
const cellIndex = focusedCell.current;
|
|
103
|
-
const node =
|
|
104
|
-
if (node)
|
|
105
|
-
node.focus();
|
|
114
|
+
const node = dsUtilities.get(grid.current, [rowIndex, cellIndex]);
|
|
115
|
+
if (node) node.focus();
|
|
106
116
|
}
|
|
107
117
|
});
|
|
118
|
+
|
|
108
119
|
const focusNextCell = (directionY, directionX, position) => {
|
|
109
|
-
const {
|
|
120
|
+
const {
|
|
121
|
+
rowIndex,
|
|
122
|
+
cellIndex
|
|
123
|
+
} = position || getNextCellPosition({
|
|
110
124
|
grid: grid.current,
|
|
111
125
|
currentCell: focusedCell.current,
|
|
112
126
|
currentRow: focusedRow.current,
|
|
@@ -115,66 +129,87 @@ const FocusGridProvider = ({
|
|
|
115
129
|
shouldWrapCells,
|
|
116
130
|
shouldWrapRows
|
|
117
131
|
});
|
|
118
|
-
const node = getNode({
|
|
132
|
+
const node = getNode({
|
|
133
|
+
rowIndex,
|
|
134
|
+
cellIndex
|
|
135
|
+
}); // can focus
|
|
136
|
+
|
|
119
137
|
if (node) {
|
|
120
138
|
node.focus();
|
|
121
139
|
focusedRow.current = rowIndex;
|
|
122
140
|
focusedCell.current = cellIndex;
|
|
123
141
|
}
|
|
124
142
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
|
|
144
|
+
registerHotKeysHooks(hotKeys, {
|
|
145
|
+
focusedCell,
|
|
146
|
+
focusedRow
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const defaultKeyBindings = _objectSpread({
|
|
150
|
+
ArrowUp: dsUtilities.runAll(preventDefault, () => focusNextCell(-1, 0)),
|
|
151
|
+
ArrowRight: dsUtilities.runAll(preventDefault, () => focusNextCell(0, 1)),
|
|
152
|
+
ArrowDown: dsUtilities.runAll(preventDefault, () => focusNextCell(1, 0)),
|
|
153
|
+
ArrowLeft: dsUtilities.runAll(preventDefault, () => focusNextCell(0, -1)),
|
|
154
|
+
Home: dsUtilities.runAll(preventDefault, e => {
|
|
132
155
|
let rowIndex = focusedRow.current;
|
|
156
|
+
|
|
133
157
|
if (e.ctrlKey) {
|
|
134
158
|
rowIndex = 0;
|
|
135
159
|
}
|
|
136
|
-
|
|
160
|
+
|
|
161
|
+
focusNextCell(0, 0, {
|
|
162
|
+
rowIndex,
|
|
163
|
+
cellIndex: 0
|
|
164
|
+
});
|
|
137
165
|
}),
|
|
138
|
-
End:
|
|
166
|
+
End: dsUtilities.runAll(preventDefault, e => {
|
|
139
167
|
let rowIndex = focusedRow.current;
|
|
168
|
+
|
|
140
169
|
if (e.ctrlKey) {
|
|
141
170
|
rowIndex = grid.current.length - 1;
|
|
142
171
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
172
|
+
|
|
173
|
+
focusNextCell(0, 0, {
|
|
174
|
+
rowIndex,
|
|
175
|
+
cellIndex: grid.current[0].length - 1
|
|
176
|
+
});
|
|
177
|
+
})
|
|
178
|
+
}, keyBindings);
|
|
179
|
+
|
|
180
|
+
const nextKeyBindings = dsUtilities.isFunction(keyBindings) ? keyBindings({
|
|
148
181
|
defaultBindings: defaultKeyBindings,
|
|
149
182
|
rowIndex: focusedRow.current,
|
|
150
183
|
cellIndex: focusedCell.current
|
|
151
|
-
}) : {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
}) : _objectSpread(_objectSpread({}, defaultKeyBindings), keyBindings);
|
|
185
|
+
|
|
186
|
+
const onKeyDown = e => {
|
|
187
|
+
if (e.target.tagName.toLowerCase() === 'input') return;
|
|
155
188
|
const action = nextKeyBindings[e.key];
|
|
156
|
-
if (
|
|
157
|
-
action(e);
|
|
189
|
+
if (dsUtilities.isFunction(action)) action(e);
|
|
158
190
|
};
|
|
159
|
-
|
|
160
|
-
|
|
191
|
+
|
|
192
|
+
const activate = container => {
|
|
193
|
+
container.addEventListener('keydown', onKeyDown, true);
|
|
161
194
|
};
|
|
162
|
-
|
|
163
|
-
|
|
195
|
+
|
|
196
|
+
const deactivate = container => {
|
|
197
|
+
container.removeEventListener('keydown', onKeyDown, true);
|
|
164
198
|
};
|
|
165
|
-
|
|
199
|
+
|
|
200
|
+
React.useEffect(() => {
|
|
166
201
|
activate(containerRef.current);
|
|
167
202
|
return () => {
|
|
168
203
|
deactivate(containerRef.current);
|
|
169
204
|
};
|
|
170
205
|
}, []);
|
|
171
|
-
const valueProvider =
|
|
206
|
+
const valueProvider = React.useMemo(() => ({
|
|
172
207
|
register
|
|
173
208
|
}), []);
|
|
174
|
-
return
|
|
209
|
+
return /*#__PURE__*/_jsx__default["default"](Provider, {
|
|
175
210
|
value: valueProvider
|
|
176
|
-
}, decoratedChild);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
211
|
+
}, void 0, decoratedChild);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
exports.FocusGridContext = FocusGridContext;
|
|
215
|
+
exports["default"] = FocusGridProvider;
|