@elliemae/ds-shared 3.0.0-next.0 → 3.0.0-next.4
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/dist/cjs/Animations/BaseAnimation.js +56 -0
- package/dist/cjs/Animations/BaseAnimation.js.map +7 -0
- package/dist/cjs/Animations/Grow.js +55 -0
- package/dist/cjs/Animations/Grow.js.map +7 -0
- package/dist/cjs/Animations/GrowRight.js +64 -0
- package/dist/cjs/Animations/GrowRight.js.map +7 -0
- package/dist/cjs/Animations/GrowVertical.js +47 -0
- package/dist/cjs/Animations/GrowVertical.js.map +7 -0
- package/dist/cjs/CheckableGroup.js +92 -0
- package/dist/cjs/CheckableGroup.js.map +7 -0
- package/dist/cjs/DeferRenderAfterComputation.js +52 -0
- package/dist/cjs/DeferRenderAfterComputation.js.map +7 -0
- package/dist/cjs/FocusGroup/FocusGrid.js +193 -0
- package/dist/cjs/FocusGroup/FocusGrid.js.map +7 -0
- package/dist/cjs/FocusGroup/FocusGroup.js +262 -0
- package/dist/cjs/FocusGroup/FocusGroup.js.map +7 -0
- package/dist/cjs/FocusGroup/FocusGroupContext.js +38 -0
- package/dist/cjs/FocusGroup/FocusGroupContext.js.map +7 -0
- package/dist/cjs/FocusGroup/FocusGroupManager.js +126 -0
- package/dist/cjs/FocusGroup/FocusGroupManager.js.map +7 -0
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js +82 -0
- package/dist/cjs/FocusGroup/focusGroupManagerHoc.js.map +7 -0
- package/dist/cjs/FocusGroup/index.js +47 -0
- package/dist/cjs/FocusGroup/index.js.map +7 -0
- package/dist/cjs/FocusGroup/useFocusGroupItem.js +81 -0
- package/dist/cjs/FocusGroup/useFocusGroupItem.js.map +7 -0
- package/dist/cjs/FocusGroup/utils/getNextCellPosition.js +80 -0
- package/dist/cjs/FocusGroup/utils/getNextCellPosition.js.map +7 -0
- package/dist/cjs/GroupContext/Group.js +115 -0
- package/dist/cjs/GroupContext/Group.js.map +7 -0
- package/dist/cjs/GroupContext/GroupContext.js +36 -0
- package/dist/cjs/GroupContext/GroupContext.js.map +7 -0
- package/dist/cjs/GroupContext/GroupItem.js +40 -0
- package/dist/cjs/GroupContext/GroupItem.js.map +7 -0
- package/dist/cjs/GroupContext/index.js +39 -0
- package/dist/cjs/GroupContext/index.js.map +7 -0
- package/dist/cjs/ScrollSync/ScrollSync.js +138 -0
- package/dist/cjs/ScrollSync/ScrollSync.js.map +7 -0
- package/dist/cjs/ScrollSync/ScrollSyncPane.js +89 -0
- package/dist/cjs/ScrollSync/ScrollSyncPane.js.map +7 -0
- package/dist/cjs/ScrollSync/ScrollSyncProvider.js +120 -0
- package/dist/cjs/ScrollSync/ScrollSyncProvider.js.map +7 -0
- package/dist/cjs/ScrollSync/index.js +37 -0
- package/dist/cjs/ScrollSync/index.js.map +7 -0
- package/dist/cjs/ScrollSync/useScrollSync.js +41 -0
- package/dist/cjs/ScrollSync/useScrollSync.js.map +7 -0
- package/dist/cjs/constants.js +70 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/createDataInstance/createInstancePlugin.js +62 -0
- package/dist/cjs/createDataInstance/createInstancePlugin.js.map +7 -0
- package/dist/cjs/createDataInstance/createInstanceRef.js +124 -0
- package/dist/cjs/createDataInstance/createInstanceRef.js.map +7 -0
- package/dist/cjs/createDataInstance/utils.js +104 -0
- package/dist/cjs/createDataInstance/utils.js.map +7 -0
- package/dist/cjs/defer-render-hoc/index.js +68 -0
- package/dist/cjs/defer-render-hoc/index.js.map +7 -0
- package/dist/cjs/dimsum.config.js +39 -0
- package/dist/cjs/dimsum.config.js.map +7 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/prop-types.js +116 -0
- package/dist/cjs/prop-types.js.map +7 -0
- package/dist/cjs/react-spring/index.js +28 -0
- package/dist/cjs/react-spring/index.js.map +7 -0
- package/dist/cjs/react-spring/renderprops.js +28 -0
- package/dist/cjs/react-spring/renderprops.js.map +7 -0
- package/dist/cjs/toolbar/ToolbarProvider.js +126 -0
- package/dist/cjs/toolbar/ToolbarProvider.js.map +7 -0
- package/dist/cjs/useDataGrid/VolatileRowsListener.js +49 -0
- package/dist/cjs/useDataGrid/VolatileRowsListener.js.map +7 -0
- package/dist/cjs/useDataGrid/index.js +36 -0
- package/dist/cjs/useDataGrid/index.js.map +7 -0
- package/dist/cjs/useDataGrid/initColumnDefinition.js +147 -0
- package/dist/cjs/useDataGrid/initColumnDefinition.js.map +7 -0
- package/dist/cjs/useDataGrid/useDataGrid.js +216 -0
- package/dist/cjs/useDataGrid/useDataGrid.js.map +7 -0
- package/dist/cjs/useDataList/index.js +36 -0
- package/dist/cjs/useDataList/index.js.map +7 -0
- package/dist/cjs/useDataList/recordIterator.js +55 -0
- package/dist/cjs/useDataList/recordIterator.js.map +7 -0
- package/dist/cjs/useDataList/useDataList.js +126 -0
- package/dist/cjs/useDataList/useDataList.js.map +7 -0
- package/dist/cjs/utils.js +123 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/cjs/virtualization/AutoHeightList.js +106 -0
- package/dist/cjs/virtualization/AutoHeightList.js.map +7 -0
- package/dist/cjs/virtualization/FluidHeightList.js +74 -0
- package/dist/cjs/virtualization/FluidHeightList.js.map +7 -0
- package/dist/cjs/virtualization/index.js +50 -0
- package/dist/cjs/virtualization/index.js.map +7 -0
- package/dist/esm/Animations/BaseAnimation.js +27 -0
- package/dist/esm/Animations/BaseAnimation.js.map +7 -0
- package/dist/esm/Animations/Grow.js +26 -0
- package/dist/esm/Animations/Grow.js.map +7 -0
- package/dist/esm/Animations/GrowRight.js +35 -0
- package/dist/esm/Animations/GrowRight.js.map +7 -0
- package/dist/esm/Animations/GrowVertical.js +29 -0
- package/dist/esm/Animations/GrowVertical.js.map +7 -0
- package/dist/esm/CheckableGroup.js +65 -0
- package/dist/esm/CheckableGroup.js.map +7 -0
- package/dist/esm/DeferRenderAfterComputation.js +23 -0
- package/dist/esm/DeferRenderAfterComputation.js.map +7 -0
- package/dist/esm/FocusGroup/FocusGrid.js +166 -0
- package/dist/esm/FocusGroup/FocusGrid.js.map +7 -0
- package/{esm → dist/esm}/FocusGroup/FocusGroup.js +70 -136
- package/dist/esm/FocusGroup/FocusGroup.js.map +7 -0
- package/dist/esm/FocusGroup/FocusGroupContext.js +9 -0
- package/dist/esm/FocusGroup/FocusGroupContext.js.map +7 -0
- package/{esm → dist/esm}/FocusGroup/FocusGroupManager.js +24 -38
- package/dist/esm/FocusGroup/FocusGroupManager.js.map +7 -0
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js +55 -0
- package/dist/esm/FocusGroup/focusGroupManagerHoc.js.map +7 -0
- package/dist/esm/FocusGroup/index.js +18 -0
- package/dist/esm/FocusGroup/index.js.map +7 -0
- package/dist/esm/FocusGroup/useFocusGroupItem.js +53 -0
- package/dist/esm/FocusGroup/useFocusGroupItem.js.map +7 -0
- package/{esm → dist/esm}/FocusGroup/utils/getNextCellPosition.js +18 -25
- package/dist/esm/FocusGroup/utils/getNextCellPosition.js.map +7 -0
- package/dist/esm/GroupContext/Group.js +86 -0
- package/dist/esm/GroupContext/Group.js.map +7 -0
- package/dist/esm/GroupContext/GroupContext.js +7 -0
- package/dist/esm/GroupContext/GroupContext.js.map +7 -0
- package/dist/esm/GroupContext/GroupItem.js +11 -0
- package/dist/esm/GroupContext/GroupItem.js.map +7 -0
- package/dist/esm/GroupContext/index.js +10 -0
- package/dist/esm/GroupContext/index.js.map +7 -0
- package/{esm → dist/esm}/ScrollSync/ScrollSync.js +30 -64
- package/dist/esm/ScrollSync/ScrollSync.js.map +7 -0
- package/dist/esm/ScrollSync/ScrollSyncPane.js +62 -0
- package/dist/esm/ScrollSync/ScrollSyncPane.js.map +7 -0
- package/dist/esm/ScrollSync/ScrollSyncProvider.js +91 -0
- package/dist/esm/ScrollSync/ScrollSyncProvider.js.map +7 -0
- package/dist/esm/ScrollSync/index.js +8 -0
- package/dist/esm/ScrollSync/index.js.map +7 -0
- package/dist/esm/ScrollSync/useScrollSync.js +12 -0
- package/dist/esm/ScrollSync/useScrollSync.js.map +7 -0
- package/dist/esm/constants.js +41 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/createDataInstance/createInstancePlugin.js +35 -0
- package/dist/esm/createDataInstance/createInstancePlugin.js.map +7 -0
- package/dist/esm/createDataInstance/createInstanceRef.js +101 -0
- package/dist/esm/createDataInstance/createInstanceRef.js.map +7 -0
- package/dist/esm/createDataInstance/utils.js +77 -0
- package/dist/esm/createDataInstance/utils.js.map +7 -0
- package/dist/esm/defer-render-hoc/index.js +41 -0
- package/dist/esm/defer-render-hoc/index.js.map +7 -0
- package/dist/esm/dimsum.config.js +10 -0
- package/dist/esm/dimsum.config.js.map +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/prop-types.js +87 -0
- package/dist/esm/prop-types.js.map +7 -0
- package/dist/esm/react-spring/index.js +3 -0
- package/dist/esm/react-spring/index.js.map +7 -0
- package/dist/esm/react-spring/renderprops.js +3 -0
- package/dist/esm/react-spring/renderprops.js.map +7 -0
- package/dist/esm/toolbar/ToolbarProvider.js +99 -0
- package/dist/esm/toolbar/ToolbarProvider.js.map +7 -0
- package/dist/esm/useDataGrid/VolatileRowsListener.js +20 -0
- package/dist/esm/useDataGrid/VolatileRowsListener.js.map +7 -0
- package/dist/esm/useDataGrid/index.js +7 -0
- package/dist/esm/useDataGrid/index.js.map +7 -0
- package/dist/esm/useDataGrid/initColumnDefinition.js +126 -0
- package/dist/esm/useDataGrid/initColumnDefinition.js.map +7 -0
- package/dist/esm/useDataGrid/useDataGrid.js +201 -0
- package/dist/esm/useDataGrid/useDataGrid.js.map +7 -0
- package/dist/esm/useDataList/index.js +7 -0
- package/dist/esm/useDataList/index.js.map +7 -0
- package/dist/esm/useDataList/recordIterator.js +26 -0
- package/dist/esm/useDataList/recordIterator.js.map +7 -0
- package/dist/esm/useDataList/useDataList.js +102 -0
- package/dist/esm/useDataList/useDataList.js.map +7 -0
- package/dist/esm/utils.js +96 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/esm/virtualization/AutoHeightList.js +79 -0
- package/dist/esm/virtualization/AutoHeightList.js.map +7 -0
- package/dist/esm/virtualization/FluidHeightList.js +47 -0
- package/dist/esm/virtualization/FluidHeightList.js.map +7 -0
- package/dist/esm/virtualization/index.js +21 -0
- package/dist/esm/virtualization/index.js.map +7 -0
- package/package.json +116 -107
- package/cjs/Animations/BaseAnimation.js +0 -36
- package/cjs/Animations/Grow.js +0 -42
- package/cjs/Animations/GrowRight.js +0 -42
- package/cjs/Animations/GrowVertical.js +0 -7
- package/cjs/CheckableGroup.js +0 -74
- package/cjs/DeferRenderAfterComputation.js +0 -28
- package/cjs/FocusGroup/FocusGrid.js +0 -215
- package/cjs/FocusGroup/FocusGroup.js +0 -308
- package/cjs/FocusGroup/FocusGroupContext.js +0 -11
- package/cjs/FocusGroup/FocusGroupManager.js +0 -117
- package/cjs/FocusGroup/focusGroupManagerHoc.js +0 -44
- package/cjs/FocusGroup/index.js +0 -21
- package/cjs/FocusGroup/useFocusGroupItem.js +0 -59
- package/cjs/FocusGroup/utils/getNextCellPosition.js +0 -60
- package/cjs/GroupContext/Group.js +0 -124
- package/cjs/GroupContext/GroupContext.js +0 -13
- package/cjs/GroupContext/GroupItem.js +0 -22
- package/cjs/GroupContext/index.js +0 -13
- package/cjs/ScrollSync/ScrollSync.js +0 -153
- package/cjs/ScrollSync/ScrollSyncPane.js +0 -81
- package/cjs/ScrollSync/ScrollSyncProvider.js +0 -67
- package/cjs/ScrollSync/index.js +0 -11
- package/cjs/ScrollSync/useScrollSync.js +0 -10
- package/cjs/constants.js +0 -51
- package/cjs/createDataInstance/createInstancePlugin.js +0 -36
- package/cjs/createDataInstance/createInstanceRef.js +0 -97
- package/cjs/createDataInstance/utils.js +0 -123
- package/cjs/defer-render-hoc/index.js +0 -49
- package/cjs/dimsum.config.js +0 -7
- package/cjs/index.js +0 -17
- package/cjs/prop-types.js +0 -59
- package/cjs/react-spring/index.js +0 -14
- package/cjs/react-spring/renderprops.js +0 -14
- package/cjs/toolbar/ToolbarProvider.js +0 -123
- package/cjs/useDataGrid/VolatileRowsListener.js +0 -24
- package/cjs/useDataGrid/index.js +0 -7
- package/cjs/useDataGrid/initColumnDefinition.js +0 -146
- package/cjs/useDataGrid/useDataGrid.js +0 -220
- package/cjs/useDataList/index.js +0 -7
- package/cjs/useDataList/recordIterator.js +0 -31
- package/cjs/useDataList/useDataList.js +0 -102
- package/cjs/utils.js +0 -116
- package/cjs/virtualization/AutoHeightList.js +0 -61
- package/cjs/virtualization/FluidHeightList.js +0 -49
- package/cjs/virtualization/index.js +0 -22
- package/esm/Animations/BaseAnimation.js +0 -30
- package/esm/Animations/Grow.js +0 -36
- package/esm/Animations/GrowRight.js +0 -36
- package/esm/Animations/GrowVertical.js +0 -4
- package/esm/CheckableGroup.js +0 -64
- package/esm/DeferRenderAfterComputation.js +0 -22
- package/esm/FocusGroup/FocusGrid.js +0 -204
- package/esm/FocusGroup/FocusGroupContext.js +0 -5
- package/esm/FocusGroup/focusGroupManagerHoc.js +0 -37
- package/esm/FocusGroup/index.js +0 -6
- package/esm/FocusGroup/useFocusGroupItem.js +0 -50
- package/esm/GroupContext/Group.js +0 -118
- package/esm/GroupContext/GroupContext.js +0 -5
- package/esm/GroupContext/GroupItem.js +0 -16
- package/esm/GroupContext/index.js +0 -3
- package/esm/ScrollSync/ScrollSyncPane.js +0 -74
- package/esm/ScrollSync/ScrollSyncProvider.js +0 -59
- package/esm/ScrollSync/index.js +0 -2
- package/esm/ScrollSync/useScrollSync.js +0 -8
- package/esm/constants.js +0 -32
- package/esm/createDataInstance/createInstancePlugin.js +0 -30
- package/esm/createDataInstance/createInstanceRef.js +0 -90
- package/esm/createDataInstance/utils.js +0 -107
- package/esm/defer-render-hoc/index.js +0 -41
- package/esm/dimsum.config.js +0 -5
- package/esm/index.js +0 -5
- package/esm/prop-types.js +0 -43
- package/esm/react-spring/index.js +0 -1
- package/esm/react-spring/renderprops.js +0 -1
- package/esm/toolbar/ToolbarProvider.js +0 -111
- package/esm/useDataGrid/VolatileRowsListener.js +0 -22
- package/esm/useDataGrid/index.js +0 -1
- package/esm/useDataGrid/initColumnDefinition.js +0 -134
- package/esm/useDataGrid/useDataGrid.js +0 -194
- package/esm/useDataList/index.js +0 -1
- package/esm/useDataList/recordIterator.js +0 -27
- package/esm/useDataList/useDataList.js +0 -90
- package/esm/utils.js +0 -95
- package/esm/virtualization/AutoHeightList.js +0 -52
- package/esm/virtualization/FluidHeightList.js +0 -38
- package/esm/virtualization/index.js +0 -18
- package/types/Animations/BaseAnimation.d.ts +0 -12
- package/types/Animations/Grow.d.ts +0 -11
- package/types/Animations/GrowRight.d.ts +0 -11
- package/types/Animations/GrowVertical.d.ts +0 -1
- package/types/CheckableGroup.d.ts +0 -20
- package/types/DeferRenderAfterComputation.d.ts +0 -6
- package/types/FocusGroup/FocusGrid.d.ts +0 -10
- package/types/FocusGroup/FocusGroup.d.ts +0 -36
- package/types/FocusGroup/FocusGroupContext.d.ts +0 -3
- package/types/FocusGroup/FocusGroupManager.d.ts +0 -24
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +0 -7
- package/types/FocusGroup/index.d.ts +0 -6
- package/types/FocusGroup/useFocusGroupItem.d.ts +0 -2
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +0 -12
- package/types/GroupContext/Group.d.ts +0 -14
- package/types/GroupContext/GroupContext.d.ts +0 -2
- package/types/GroupContext/GroupItem.d.ts +0 -5
- package/types/GroupContext/index.d.ts +0 -3
- package/types/ScrollSync/ScrollSync.d.ts +0 -21
- package/types/ScrollSync/ScrollSyncPane.d.ts +0 -3
- package/types/ScrollSync/ScrollSyncProvider.d.ts +0 -12
- package/types/ScrollSync/index.d.ts +0 -2
- package/types/ScrollSync/useScrollSync.d.ts +0 -6
- package/types/constants.d.ts +0 -30
- package/types/createDataInstance/createInstancePlugin.d.ts +0 -1
- package/types/createDataInstance/createInstanceRef.d.ts +0 -12
- package/types/createDataInstance/tests/createInstanceRef.test.d.ts +0 -0
- package/types/createDataInstance/utils.d.ts +0 -9
- package/types/dimsum.config.d.ts +0 -4
- package/types/index.d.ts +0 -2
- package/types/prop-types.d.ts +0 -41
- package/types/react-spring/index.d.ts +0 -1
- package/types/react-spring/renderprops.d.ts +0 -1
- package/types/toolbar/ToolbarProvider.d.ts +0 -10
- package/types/useDataGrid/VolatileRowsListener.d.ts +0 -5
- package/types/useDataGrid/index.d.ts +0 -1
- package/types/useDataGrid/initColumnDefinition.d.ts +0 -5
- package/types/useDataGrid/useDataGrid.d.ts +0 -8
- package/types/useDataList/index.d.ts +0 -1
- package/types/useDataList/recordIterator.d.ts +0 -1
- package/types/useDataList/useDataList.d.ts +0 -13
- package/types/utils.d.ts +0 -22
- package/types/virtualization/AutoHeightList.d.ts +0 -2
- package/types/virtualization/FluidHeightList.d.ts +0 -2
- package/types/virtualization/index.d.ts +0 -9
|
@@ -1,215 +0,0 @@
|
|
|
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({
|
|
43
|
-
keys: key,
|
|
44
|
-
handler: e => {
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
handler({
|
|
47
|
-
rowIndex: focusedRow.current,
|
|
48
|
-
cellIndex: focusedCell.current
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
options
|
|
52
|
-
});
|
|
53
|
-
});
|
|
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
|
-
});
|
|
74
|
-
|
|
75
|
-
const getNode = _ref3 => {
|
|
76
|
-
let {
|
|
77
|
-
rowIndex,
|
|
78
|
-
cellIndex
|
|
79
|
-
} = _ref3;
|
|
80
|
-
return dsUtilities.get(grid.current, [rowIndex, cellIndex]);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const register = (node, rowIndex, columnIndex) => {
|
|
84
|
-
if (!node) return;
|
|
85
|
-
|
|
86
|
-
if (!Array.isArray(grid.current[rowIndex])) {
|
|
87
|
-
grid.current[rowIndex] = [];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (rowIndex === 0 && columnIndex === 0) {
|
|
91
|
-
node.setAttribute('tabindex', 0);
|
|
92
|
-
} else {
|
|
93
|
-
node.setAttribute('tabindex', -1);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
node.onfocus = () => {
|
|
97
|
-
const prevNode = getNode({
|
|
98
|
-
rowIndex: focusedRow.current,
|
|
99
|
-
cellIndex: focusedCell.current
|
|
100
|
-
});
|
|
101
|
-
if (prevNode) prevNode.setAttribute('tabindex', -1);
|
|
102
|
-
node.setAttribute('tabindex', 0);
|
|
103
|
-
focusedRow.current = rowIndex;
|
|
104
|
-
focusedCell.current = columnIndex;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
grid.current[rowIndex][columnIndex] = node;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
React.useEffect(() => {
|
|
111
|
-
if (shouldRefocus) {
|
|
112
|
-
const rowIndex = focusedRow.current;
|
|
113
|
-
const cellIndex = focusedCell.current;
|
|
114
|
-
const node = dsUtilities.get(grid.current, [rowIndex, cellIndex]);
|
|
115
|
-
if (node) node.focus();
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const focusNextCell = (directionY, directionX, position) => {
|
|
120
|
-
const {
|
|
121
|
-
rowIndex,
|
|
122
|
-
cellIndex
|
|
123
|
-
} = position || getNextCellPosition({
|
|
124
|
-
grid: grid.current,
|
|
125
|
-
currentCell: focusedCell.current,
|
|
126
|
-
currentRow: focusedRow.current,
|
|
127
|
-
directionX,
|
|
128
|
-
directionY,
|
|
129
|
-
shouldWrapCells,
|
|
130
|
-
shouldWrapRows
|
|
131
|
-
});
|
|
132
|
-
const node = getNode({
|
|
133
|
-
rowIndex,
|
|
134
|
-
cellIndex
|
|
135
|
-
}); // can focus
|
|
136
|
-
|
|
137
|
-
if (node) {
|
|
138
|
-
node.focus();
|
|
139
|
-
focusedRow.current = rowIndex;
|
|
140
|
-
focusedCell.current = cellIndex;
|
|
141
|
-
}
|
|
142
|
-
};
|
|
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 => {
|
|
155
|
-
let rowIndex = focusedRow.current;
|
|
156
|
-
|
|
157
|
-
if (e.ctrlKey) {
|
|
158
|
-
rowIndex = 0;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
focusNextCell(0, 0, {
|
|
162
|
-
rowIndex,
|
|
163
|
-
cellIndex: 0
|
|
164
|
-
});
|
|
165
|
-
}),
|
|
166
|
-
End: dsUtilities.runAll(preventDefault, e => {
|
|
167
|
-
let rowIndex = focusedRow.current;
|
|
168
|
-
|
|
169
|
-
if (e.ctrlKey) {
|
|
170
|
-
rowIndex = grid.current.length - 1;
|
|
171
|
-
}
|
|
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({
|
|
181
|
-
defaultBindings: defaultKeyBindings,
|
|
182
|
-
rowIndex: focusedRow.current,
|
|
183
|
-
cellIndex: focusedCell.current
|
|
184
|
-
}) : _objectSpread(_objectSpread({}, defaultKeyBindings), keyBindings);
|
|
185
|
-
|
|
186
|
-
const onKeyDown = e => {
|
|
187
|
-
if (e.target.tagName.toLowerCase() === 'input') return;
|
|
188
|
-
const action = nextKeyBindings[e.key];
|
|
189
|
-
if (dsUtilities.isFunction(action)) action(e);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const activate = container => {
|
|
193
|
-
container.addEventListener('keydown', onKeyDown, true);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const deactivate = container => {
|
|
197
|
-
container.removeEventListener('keydown', onKeyDown, true);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
React.useEffect(() => {
|
|
201
|
-
activate(containerRef.current);
|
|
202
|
-
return () => {
|
|
203
|
-
deactivate(containerRef.current);
|
|
204
|
-
};
|
|
205
|
-
}, []);
|
|
206
|
-
const valueProvider = React.useMemo(() => ({
|
|
207
|
-
register
|
|
208
|
-
}), []);
|
|
209
|
-
return /*#__PURE__*/_jsx__default["default"](Provider, {
|
|
210
|
-
value: valueProvider
|
|
211
|
-
}, void 0, decoratedChild);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
exports.FocusGridContext = FocusGridContext;
|
|
215
|
-
exports["default"] = FocusGridProvider;
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
|
13
|
-
var hotkeys = require('hotkeys-js');
|
|
14
|
-
|
|
15
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
-
|
|
17
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
18
|
-
var hotkeys__default = /*#__PURE__*/_interopDefaultLegacy(hotkeys);
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
const defaultOptions = {
|
|
24
|
-
orientation: 'vertical'
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const safeCallAction = function (e, fun) {
|
|
28
|
-
if (dsUtilities.isFunction(fun)) {
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
|
|
31
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
32
|
-
args[_key - 2] = arguments[_key];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
fun(...args);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const registerHotkeys = function () {
|
|
40
|
-
let hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
41
|
-
let params = arguments.length > 1 ? arguments[1] : undefined;
|
|
42
|
-
let getContainer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => document;
|
|
43
|
-
Object.keys(hotKeys).forEach(hotkey => {
|
|
44
|
-
const {
|
|
45
|
-
options,
|
|
46
|
-
handler,
|
|
47
|
-
allowDocumentHandler = false
|
|
48
|
-
} = hotKeys[hotkey];
|
|
49
|
-
|
|
50
|
-
const parameterizedHandler = e => {
|
|
51
|
-
const handlerParams = dsUtilities.isFunction(params) ? params() : params;
|
|
52
|
-
if (!allowDocumentHandler && handlerParams.item !== document.activeElement) return;
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
handler(handlerParams);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
hotkeys__default["default"](hotkey, _objectSpread({
|
|
58
|
-
element: getContainer()
|
|
59
|
-
}, options), parameterizedHandler);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const unregisterHotKeys = function () {
|
|
64
|
-
let hotKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
-
Object.keys(hotKeys).forEach(hotkey => {
|
|
66
|
-
hotkeys__default["default"].unbind(hotkey);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const noop = () => null;
|
|
71
|
-
|
|
72
|
-
class FocusGroup {
|
|
73
|
-
constructor() {
|
|
74
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
|
-
this.items = [];
|
|
76
|
-
this.options = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
77
|
-
const {
|
|
78
|
-
orientation
|
|
79
|
-
} = this.options;
|
|
80
|
-
this.keyBindings = _objectSpread({
|
|
81
|
-
ArrowUp: orientation !== 'horizontal' && 'previous',
|
|
82
|
-
ArrowRight: orientation !== 'vertical' && 'next',
|
|
83
|
-
ArrowDown: orientation !== 'horizontal' && 'next',
|
|
84
|
-
ArrowLeft: orientation !== 'vertical' && 'previous',
|
|
85
|
-
Home: 'first',
|
|
86
|
-
End: 'last',
|
|
87
|
-
PageUp: 'first',
|
|
88
|
-
PageDown: 'last',
|
|
89
|
-
Escape: 'exit'
|
|
90
|
-
}, options.keyBindings);
|
|
91
|
-
this.currentFocusedItem = null;
|
|
92
|
-
this.currIndex = null;
|
|
93
|
-
this.mapActions = {
|
|
94
|
-
previous: this.focusPrevious.bind(this),
|
|
95
|
-
next: this.focusNext.bind(this),
|
|
96
|
-
first: this.focusFirst.bind(this),
|
|
97
|
-
last: this.focusLast.bind(this),
|
|
98
|
-
exit: this.exit.bind(this),
|
|
99
|
-
enter: () => null
|
|
100
|
-
};
|
|
101
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
102
|
-
this.register = this.register.bind(this);
|
|
103
|
-
this.focusFirst = this.focusFirst.bind(this);
|
|
104
|
-
this.focusLast = this.focusLast.bind(this);
|
|
105
|
-
this.isGroupActive = this.isGroupActive.bind(this);
|
|
106
|
-
this.focusNext = this.focusNext.bind(this);
|
|
107
|
-
this.focusPrevious = this.focusPrevious.bind(this);
|
|
108
|
-
this.focusItem = this.focusItem.bind(this);
|
|
109
|
-
this.focusCurrent = this.focusCurrent.bind(this);
|
|
110
|
-
this.getHotKeysParams = this.getHotKeysParams.bind(this);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getHotKeysParams() {
|
|
114
|
-
const item = this.currentFocusedItem;
|
|
115
|
-
const {
|
|
116
|
-
index
|
|
117
|
-
} = dsUtilities.get(item, ['dataset'], {});
|
|
118
|
-
return {
|
|
119
|
-
item,
|
|
120
|
-
index
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
activate() {
|
|
125
|
-
const {
|
|
126
|
-
getContainer
|
|
127
|
-
} = this.options;
|
|
128
|
-
document.addEventListener('keydown', this.handleKeyDown, true);
|
|
129
|
-
registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
deactivate() {
|
|
133
|
-
document.removeEventListener('keydown', this.handleKeyDown, true);
|
|
134
|
-
unregisterHotKeys(this.options.hotKeys);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
handleKeyDown(e) {
|
|
138
|
-
if (!this.isGroupActive()) return;
|
|
139
|
-
this.executeActionByEvent(e);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
executeActionByEvent(e) {
|
|
143
|
-
const actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];
|
|
144
|
-
return actions.map(action => typeof action === 'string' ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
register(node) {
|
|
148
|
-
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
149
|
-
const afterIndex = this.items.findIndex(item => item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING);
|
|
150
|
-
node.specialOnFocus = props.onFocus || noop;
|
|
151
|
-
node.specialOnBlur = props.onBlur || noop;
|
|
152
|
-
|
|
153
|
-
node.onclick = () => this.focusItem(node);
|
|
154
|
-
|
|
155
|
-
node.onfocus = () => {
|
|
156
|
-
this.focusItem(node);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
if (afterIndex === -1) {
|
|
160
|
-
this.items.push(node);
|
|
161
|
-
} else {
|
|
162
|
-
this.items.splice(afterIndex, 0, node);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
unregister(node) {
|
|
167
|
-
const index = this.getItemIndexByNode(node);
|
|
168
|
-
if (index > -1) this.items.splice(index, 1);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
exit() {
|
|
172
|
-
const {
|
|
173
|
-
onExitFocusGroup
|
|
174
|
-
} = this.options;
|
|
175
|
-
onExitFocusGroup();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
focusItem(node) {
|
|
179
|
-
if (this.currentFocusedItem && this.currentFocusedItem !== node) {
|
|
180
|
-
this.currentFocusedItem.specialOnBlur();
|
|
181
|
-
this.currentFocusedItem.setAttribute('tabindex', -1);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (!node) return;
|
|
185
|
-
this.currentFocusedItem = node;
|
|
186
|
-
node.setAttribute('tabindex', 0);
|
|
187
|
-
node.focus();
|
|
188
|
-
node.specialOnFocus();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
focusNext() {
|
|
192
|
-
const item = this.getNextItem();
|
|
193
|
-
this.focusItem(item);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
focusByNode(node) {
|
|
197
|
-
const index = this.getItemIndexByNode(node);
|
|
198
|
-
this.focusByIndex(index);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
focusByIndex(index) {
|
|
202
|
-
const item = this.getItemByIndex(index);
|
|
203
|
-
this.focusItem(item);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
focusPrevious() {
|
|
207
|
-
const prevItem = this.getPreviousItem();
|
|
208
|
-
this.focusItem(prevItem);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
focusFirst() {
|
|
212
|
-
const item = this.getFirstItem();
|
|
213
|
-
this.focusItem(item);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
focusLast() {
|
|
217
|
-
const item = this.getLastItem();
|
|
218
|
-
this.focusItem(item);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
focusCurrent() {
|
|
222
|
-
this.focusItem(this.currentFocusedItem);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
focusNextGroup() {
|
|
226
|
-
const {
|
|
227
|
-
onFocusNextGroup
|
|
228
|
-
} = this.options;
|
|
229
|
-
this.exit();
|
|
230
|
-
onFocusNextGroup();
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
focusPreviousGroup() {
|
|
234
|
-
const {
|
|
235
|
-
onFocusPreviousGroup
|
|
236
|
-
} = this.options;
|
|
237
|
-
this.exit();
|
|
238
|
-
onFocusPreviousGroup();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
getNextItem() {
|
|
242
|
-
const {
|
|
243
|
-
loop
|
|
244
|
-
} = this.options;
|
|
245
|
-
const currentIndex = this.getFocusedIndex();
|
|
246
|
-
const supposedNextIndex = currentIndex + 1;
|
|
247
|
-
|
|
248
|
-
if (!this.checkCanFocusNext(supposedNextIndex)) {
|
|
249
|
-
return loop ? this.getFirstItem() : this.focusNextGroup();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return this.getItemByIndex(supposedNextIndex);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
getPreviousItem() {
|
|
256
|
-
const {
|
|
257
|
-
loop
|
|
258
|
-
} = this.options;
|
|
259
|
-
const currentIndex = this.getFocusedIndex();
|
|
260
|
-
const supposedPrevIndex = currentIndex - 1;
|
|
261
|
-
|
|
262
|
-
if (!this.checkCanFocusPrev(supposedPrevIndex)) {
|
|
263
|
-
return loop ? this.getLastItem() : this.focusPreviousGroup();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return this.getItemByIndex(supposedPrevIndex);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
checkCanFocusNext(index) {
|
|
270
|
-
return this.items.length > index;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
checkCanFocusPrev(index) {
|
|
274
|
-
return index >= 0;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
getItemByIndex(index) {
|
|
278
|
-
return this.items[index];
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
getItemIndexByNode(node) {
|
|
282
|
-
return this.items.findIndex(item => item === node);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
getFocusedIndex() {
|
|
286
|
-
return this.getItemIndexByNode(document.activeElement);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
getFocusedItem() {
|
|
290
|
-
const index = this.getFocusedIndex();
|
|
291
|
-
return index > -1 && this.items[index];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
isGroupActive() {
|
|
295
|
-
return this.getFocusedIndex() !== -1;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
getFirstItem() {
|
|
299
|
-
return !!this.items.length && this.items[0];
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
getLastItem() {
|
|
303
|
-
return !!this.items.length && this.items[this.items.length - 1];
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
module.exports = FocusGroup;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
-
|
|
7
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
8
|
-
|
|
9
|
-
var FocusGroupContext = /*#__PURE__*/React__default["default"].createContext();
|
|
10
|
-
|
|
11
|
-
module.exports = FocusGroupContext;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
|
6
|
-
var FocusGroup = require('./FocusGroup.js');
|
|
7
|
-
var FocusGroupContext = require('./FocusGroupContext.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
12
|
-
|
|
13
|
-
const noop = () => null;
|
|
14
|
-
|
|
15
|
-
class FocusGroupProvider extends React.Component {
|
|
16
|
-
constructor(props) {
|
|
17
|
-
super(props);
|
|
18
|
-
this.activated = false;
|
|
19
|
-
this.focusGroup = new FocusGroup(props);
|
|
20
|
-
props.onFocusGroupSet(this);
|
|
21
|
-
this.actions = {
|
|
22
|
-
activate: this.activate.bind(this),
|
|
23
|
-
deactivate: this.deactivate.bind(this),
|
|
24
|
-
register: this.focusGroup.register,
|
|
25
|
-
unregister: this.unregister.bind(this),
|
|
26
|
-
focusFirst: this.focusGroup.focusFirst,
|
|
27
|
-
focusLast: this.focusGroup.focusLast,
|
|
28
|
-
focusItemByIndex: this.focusItemByIndex.bind(this),
|
|
29
|
-
focusItemByNode: this.focusItemByNode.bind(this),
|
|
30
|
-
focus: this.focusGroup.focusCurrent,
|
|
31
|
-
isGroupActive: this.focusGroup.isGroupActive,
|
|
32
|
-
focusNext: this.focusGroup.focusNext,
|
|
33
|
-
focusPrevious: this.focusGroup.focusPrevious
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
componentDidMount() {
|
|
38
|
-
const {
|
|
39
|
-
autoFocusOnMount
|
|
40
|
-
} = this.props;
|
|
41
|
-
this.activate();
|
|
42
|
-
|
|
43
|
-
if (autoFocusOnMount) {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
this.actions.focusFirst();
|
|
46
|
-
}, 0);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
componentWillUnmount() {
|
|
51
|
-
this.deactivate();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
activate() {
|
|
55
|
-
const {
|
|
56
|
-
onActivate
|
|
57
|
-
} = this.props;
|
|
58
|
-
this.focusGroup.activate();
|
|
59
|
-
this.activated = true;
|
|
60
|
-
if (dsUtilities.isFunction(onActivate)) onActivate();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
deactivate() {
|
|
64
|
-
const {
|
|
65
|
-
onExitFocusGroup
|
|
66
|
-
} = this.props;
|
|
67
|
-
this.activated = false;
|
|
68
|
-
this.focusGroup.deactivate();
|
|
69
|
-
|
|
70
|
-
if (dsUtilities.isFunction(onExitFocusGroup)) {
|
|
71
|
-
onExitFocusGroup();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
register(item) {
|
|
76
|
-
this.focusGroup.register(item);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
unregister(item) {
|
|
80
|
-
this.focusGroup.unregister(item);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
focusItemByIndex(index) {
|
|
84
|
-
if (!this.activated) this.activate();
|
|
85
|
-
setTimeout(() => {
|
|
86
|
-
this.focusGroup.focusByIndex(index);
|
|
87
|
-
}, 200);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
focusItemByNode(node) {
|
|
91
|
-
if (!this.activated) this.activate();
|
|
92
|
-
const index = this.focusGroup.getItemIndexByNode(node);
|
|
93
|
-
this.focusItemByIndex(index);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
render() {
|
|
97
|
-
const {
|
|
98
|
-
children
|
|
99
|
-
} = this.props;
|
|
100
|
-
return /*#__PURE__*/_jsx__default["default"](FocusGroupContext.Provider, {
|
|
101
|
-
value: this.actions
|
|
102
|
-
}, void 0, children);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
FocusGroupProvider.defaultProps = {
|
|
107
|
-
exitWhenNoPrevious: false,
|
|
108
|
-
exitWhenNoNext: false,
|
|
109
|
-
keyBindings: {},
|
|
110
|
-
onFocus: noop,
|
|
111
|
-
onExitFocusGroup: noop,
|
|
112
|
-
onFocusPreviousGroup: noop,
|
|
113
|
-
onFocusNextGroup: noop,
|
|
114
|
-
onFocusGroupSet: noop
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
module.exports = FocusGroupProvider;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
4
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
9
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
10
|
-
require('react');
|
|
11
|
-
var FocusGroupManager = require('./FocusGroupManager.js');
|
|
12
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
17
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
18
|
-
|
|
19
|
-
const _excluded = ["onExitFocusGroup", "onFocusPrevGroup", "focusKeyBindings"];
|
|
20
|
-
|
|
21
|
-
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; }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
function FocusGroupHoc(WrappedComponent) {
|
|
25
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
-
return _ref => {
|
|
27
|
-
let {
|
|
28
|
-
onExitFocusGroup,
|
|
29
|
-
onFocusPrevGroup,
|
|
30
|
-
focusKeyBindings
|
|
31
|
-
} = _ref,
|
|
32
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
33
|
-
|
|
34
|
-
return /*#__PURE__*/jsxRuntime.jsx(FocusGroupManager, _objectSpread(_objectSpread({
|
|
35
|
-
keyBindings: focusKeyBindings,
|
|
36
|
-
onExitFocusGroup: onExitFocusGroup,
|
|
37
|
-
onFocusPrevGroup: onFocusPrevGroup
|
|
38
|
-
}, options), {}, {
|
|
39
|
-
children: /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _objectSpread(_objectSpread({}, props), options))
|
|
40
|
-
}));
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = FocusGroupHoc;
|