@elliemae/ds-shared 1.60.0 → 2.0.0-alpha.12
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 +19 -27
- package/cjs/Animations/Grow.js +17 -22
- package/cjs/Animations/GrowRight.js +17 -23
- package/cjs/Animations/GrowVertical.js +3 -2
- package/cjs/CheckableGroup.js +40 -46
- package/cjs/DeferRenderAfterComputation.js +12 -21
- package/cjs/FocusGroup/FocusGrid.js +91 -92
- package/cjs/FocusGroup/FocusGroup.js +225 -262
- package/cjs/FocusGroup/FocusGroupContext.js +1 -2
- package/cjs/FocusGroup/FocusGroupManager.js +88 -126
- package/cjs/FocusGroup/focusGroupManagerHoc.js +28 -27
- package/cjs/FocusGroup/index.js +14 -28
- package/cjs/FocusGroup/useFocusGroupItem.js +27 -24
- package/cjs/FocusGroup/utils/getNextCellPosition.js +14 -15
- package/cjs/GroupContext/Group.js +81 -103
- package/cjs/GroupContext/GroupContext.js +1 -2
- package/cjs/GroupContext/GroupItem.js +12 -10
- package/cjs/GroupContext/index.js +6 -15
- package/cjs/ScrollSync/ScrollSync.js +90 -112
- package/cjs/ScrollSync/ScrollSyncPane.js +58 -90
- package/cjs/ScrollSync/ScrollSyncProvider.js +36 -26
- package/cjs/ScrollSync/index.js +4 -13
- package/cjs/ScrollSync/useScrollSync.js +0 -1
- package/cjs/constants.js +43 -4
- package/cjs/createDataInstance/createInstancePlugin.js +11 -10
- package/cjs/createDataInstance/createInstanceRef.js +41 -42
- package/cjs/createDataInstance/utils.js +56 -58
- package/cjs/defer-render-hoc/index.js +26 -61
- package/cjs/dimsum.config.js +7 -0
- package/cjs/index.js +10 -20
- package/cjs/prop-types.js +59 -0
- package/cjs/react-spring/index.js +3 -6
- package/cjs/react-spring/renderprops.js +3 -6
- package/cjs/toolbar/ToolbarProvider.js +65 -77
- package/cjs/useDataGrid/VolatileRowsListener.js +13 -27
- package/cjs/useDataGrid/index.js +2 -17
- package/cjs/useDataGrid/initColumnDefinition.js +46 -47
- package/cjs/useDataGrid/useDataGrid.js +104 -144
- package/cjs/useDataList/index.js +2 -15
- package/cjs/useDataList/recordIterator.js +9 -10
- package/cjs/useDataList/useDataList.js +51 -59
- package/cjs/utils.js +46 -59
- package/cjs/virtualization/AutoHeightList.js +31 -22
- package/cjs/virtualization/FluidHeightList.js +26 -12
- package/cjs/virtualization/index.js +12 -17
- package/esm/Animations/BaseAnimation.js +18 -26
- package/esm/Animations/Grow.js +15 -20
- package/esm/Animations/GrowRight.js +15 -21
- package/esm/Animations/GrowVertical.js +3 -2
- package/esm/CheckableGroup.js +38 -42
- package/esm/DeferRenderAfterComputation.js +12 -20
- package/esm/FocusGroup/FocusGrid.js +87 -89
- package/esm/FocusGroup/FocusGroup.js +222 -257
- package/esm/FocusGroup/FocusGroupContext.js +0 -1
- package/esm/FocusGroup/FocusGroupManager.js +82 -114
- package/esm/FocusGroup/focusGroupManagerHoc.js +24 -22
- package/esm/FocusGroup/index.js +0 -14
- package/esm/FocusGroup/useFocusGroupItem.js +25 -22
- package/esm/FocusGroup/utils/getNextCellPosition.js +14 -15
- package/esm/GroupContext/Group.js +80 -95
- package/esm/GroupContext/GroupContext.js +1 -2
- package/esm/GroupContext/GroupItem.js +10 -8
- package/esm/GroupContext/index.js +0 -9
- package/esm/ScrollSync/ScrollSync.js +88 -105
- package/esm/ScrollSync/ScrollSyncPane.js +56 -83
- package/esm/ScrollSync/ScrollSyncProvider.js +35 -26
- package/esm/ScrollSync/index.js +0 -9
- package/esm/ScrollSync/useScrollSync.js +0 -1
- package/esm/constants.js +31 -5
- package/esm/createDataInstance/createInstancePlugin.js +10 -8
- package/esm/createDataInstance/createInstanceRef.js +36 -36
- package/esm/createDataInstance/utils.js +55 -57
- package/esm/defer-render-hoc/index.js +25 -55
- package/esm/dimsum.config.js +5 -0
- package/esm/index.js +0 -10
- package/esm/prop-types.js +43 -0
- package/esm/react-spring/index.js +1 -2
- package/esm/react-spring/renderprops.js +1 -2
- package/esm/toolbar/ToolbarProvider.js +60 -71
- package/esm/useDataGrid/VolatileRowsListener.js +14 -23
- package/esm/useDataGrid/index.js +0 -15
- package/esm/useDataGrid/initColumnDefinition.js +43 -43
- package/esm/useDataGrid/useDataGrid.js +90 -127
- package/esm/useDataList/index.js +0 -13
- package/esm/useDataList/recordIterator.js +9 -10
- package/esm/useDataList/useDataList.js +39 -46
- package/esm/utils.js +44 -57
- package/esm/virtualization/AutoHeightList.js +28 -18
- package/esm/virtualization/FluidHeightList.js +24 -10
- package/esm/virtualization/index.js +6 -11
- package/package.json +201 -8
- package/types/Animations/BaseAnimation.d.ts +12 -0
- package/types/Animations/Grow.d.ts +11 -0
- package/types/Animations/GrowRight.d.ts +11 -0
- package/types/Animations/GrowVertical.d.ts +1 -0
- package/types/CheckableGroup.d.ts +20 -0
- package/types/DeferRenderAfterComputation.d.ts +6 -0
- package/types/FocusGroup/FocusGrid.d.ts +10 -0
- package/types/FocusGroup/FocusGroup.d.ts +36 -0
- package/types/FocusGroup/FocusGroupContext.d.ts +3 -0
- package/types/FocusGroup/FocusGroupManager.d.ts +24 -0
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +7 -0
- package/types/FocusGroup/index.d.ts +6 -0
- package/types/FocusGroup/useFocusGroupItem.d.ts +2 -0
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +12 -0
- package/types/GroupContext/Group.d.ts +14 -0
- package/types/GroupContext/GroupContext.d.ts +2 -0
- package/types/GroupContext/GroupItem.d.ts +5 -0
- package/types/GroupContext/index.d.ts +3 -0
- package/types/ScrollSync/ScrollSync.d.ts +21 -0
- package/types/ScrollSync/ScrollSyncPane.d.ts +3 -0
- package/types/ScrollSync/ScrollSyncProvider.d.ts +12 -0
- package/types/ScrollSync/index.d.ts +2 -0
- package/types/ScrollSync/useScrollSync.d.ts +6 -0
- package/types/constants.d.ts +30 -0
- package/types/createDataInstance/createInstancePlugin.d.ts +1 -0
- package/types/createDataInstance/createInstanceRef.d.ts +12 -0
- package/types/createDataInstance/tests/createInstanceRef.test.d.ts +0 -0
- package/types/createDataInstance/utils.d.ts +9 -0
- package/types/dimsum.config.d.ts +4 -0
- package/types/index.d.ts +2 -0
- package/types/prop-types.d.ts +41 -0
- package/types/react-spring/index.d.ts +1 -0
- package/types/react-spring/renderprops.d.ts +1 -0
- package/types/toolbar/ToolbarProvider.d.ts +10 -0
- package/types/useDataGrid/VolatileRowsListener.d.ts +5 -0
- package/types/useDataGrid/index.d.ts +1 -0
- package/types/useDataGrid/initColumnDefinition.d.ts +5 -0
- package/types/useDataGrid/useDataGrid.d.ts +8 -0
- package/types/useDataList/index.d.ts +1 -0
- package/types/useDataList/recordIterator.d.ts +1 -0
- package/types/useDataList/useDataList.d.ts +13 -0
- package/types/utils.d.ts +22 -0
- package/types/virtualization/AutoHeightList.d.ts +2 -0
- package/types/virtualization/FluidHeightList.d.ts +2 -0
- package/types/virtualization/index.d.ts +9 -0
- package/Animations/BaseAnimation/package.json +0 -10
- package/Animations/Grow/package.json +0 -10
- package/Animations/GrowRight/package.json +0 -10
- package/Animations/GrowVertical/package.json +0 -10
- package/CheckableGroup/package.json +0 -10
- package/DeferRenderAfterComputation/package.json +0 -10
- package/FocusGroup/FocusGrid/package.json +0 -10
- package/FocusGroup/FocusGroup/package.json +0 -10
- package/FocusGroup/FocusGroupContext/package.json +0 -10
- package/FocusGroup/FocusGroupManager/package.json +0 -10
- package/FocusGroup/focusGroupManagerHoc/package.json +0 -10
- package/FocusGroup/package.json +0 -10
- package/FocusGroup/useFocusGroupItem/package.json +0 -10
- package/FocusGroup/utils/getNextCellPosition/package.json +0 -10
- package/GroupContext/Group/package.json +0 -10
- package/GroupContext/GroupContext/package.json +0 -10
- package/GroupContext/GroupItem/package.json +0 -10
- package/GroupContext/package.json +0 -10
- package/ScrollSync/ScrollSync/package.json +0 -10
- package/ScrollSync/ScrollSyncPane/package.json +0 -10
- package/ScrollSync/ScrollSyncProvider/package.json +0 -10
- package/ScrollSync/package.json +0 -10
- package/ScrollSync/useScrollSync/package.json +0 -10
- package/cjs/Animations/BaseAnimation.js.map +0 -1
- package/cjs/Animations/Grow.js.map +0 -1
- package/cjs/Animations/GrowRight.js.map +0 -1
- package/cjs/Animations/GrowVertical.js.map +0 -1
- package/cjs/CheckableGroup.js.map +0 -1
- package/cjs/DeferRenderAfterComputation.js.map +0 -1
- package/cjs/FocusGroup/FocusGrid.js.map +0 -1
- package/cjs/FocusGroup/FocusGroup.js.map +0 -1
- package/cjs/FocusGroup/FocusGroupContext.js.map +0 -1
- package/cjs/FocusGroup/FocusGroupManager.js.map +0 -1
- package/cjs/FocusGroup/focusGroupManagerHoc.js.map +0 -1
- package/cjs/FocusGroup/index.js.map +0 -1
- package/cjs/FocusGroup/useFocusGroupItem.js.map +0 -1
- package/cjs/FocusGroup/utils/getNextCellPosition.js.map +0 -1
- package/cjs/GroupContext/Group.js.map +0 -1
- package/cjs/GroupContext/GroupContext.js.map +0 -1
- package/cjs/GroupContext/GroupItem.js.map +0 -1
- package/cjs/GroupContext/index.js.map +0 -1
- package/cjs/ScrollSync/ScrollSync.js.map +0 -1
- package/cjs/ScrollSync/ScrollSyncPane.js.map +0 -1
- package/cjs/ScrollSync/ScrollSyncProvider.js.map +0 -1
- package/cjs/ScrollSync/index.js.map +0 -1
- package/cjs/ScrollSync/useScrollSync.js.map +0 -1
- package/cjs/constants.js.map +0 -1
- package/cjs/createDataInstance/createInstancePlugin.js.map +0 -1
- package/cjs/createDataInstance/createInstanceRef.js.map +0 -1
- package/cjs/createDataInstance/utils.js.map +0 -1
- package/cjs/defer-render-hoc/index.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/react-spring/index.js.map +0 -1
- package/cjs/react-spring/renderprops.js.map +0 -1
- package/cjs/toolbar/ToolbarProvider.js.map +0 -1
- package/cjs/useDataGrid/VolatileRowsListener.js.map +0 -1
- package/cjs/useDataGrid/index.js.map +0 -1
- package/cjs/useDataGrid/initColumnDefinition.js.map +0 -1
- package/cjs/useDataGrid/useDataGrid.js.map +0 -1
- package/cjs/useDataList/index.js.map +0 -1
- package/cjs/useDataList/recordIterator.js.map +0 -1
- package/cjs/useDataList/useDataList.js.map +0 -1
- package/cjs/utils.js.map +0 -1
- package/cjs/virtualization/AutoHeightList.js.map +0 -1
- package/cjs/virtualization/FluidHeightList.js.map +0 -1
- package/cjs/virtualization/index.js.map +0 -1
- package/constants/package.json +0 -10
- package/createDataInstance/createInstancePlugin/package.json +0 -10
- package/createDataInstance/createInstanceRef/package.json +0 -10
- package/createDataInstance/utils/package.json +0 -10
- package/defer-render-hoc/package.json +0 -10
- package/esm/Animations/BaseAnimation.js.map +0 -1
- package/esm/Animations/Grow.js.map +0 -1
- package/esm/Animations/GrowRight.js.map +0 -1
- package/esm/Animations/GrowVertical.js.map +0 -1
- package/esm/CheckableGroup.js.map +0 -1
- package/esm/DeferRenderAfterComputation.js.map +0 -1
- package/esm/FocusGroup/FocusGrid.js.map +0 -1
- package/esm/FocusGroup/FocusGroup.js.map +0 -1
- package/esm/FocusGroup/FocusGroupContext.js.map +0 -1
- package/esm/FocusGroup/FocusGroupManager.js.map +0 -1
- package/esm/FocusGroup/focusGroupManagerHoc.js.map +0 -1
- package/esm/FocusGroup/index.js.map +0 -1
- package/esm/FocusGroup/useFocusGroupItem.js.map +0 -1
- package/esm/FocusGroup/utils/getNextCellPosition.js.map +0 -1
- package/esm/GroupContext/Group.js.map +0 -1
- package/esm/GroupContext/GroupContext.js.map +0 -1
- package/esm/GroupContext/GroupItem.js.map +0 -1
- package/esm/GroupContext/index.js.map +0 -1
- package/esm/ScrollSync/ScrollSync.js.map +0 -1
- package/esm/ScrollSync/ScrollSyncPane.js.map +0 -1
- package/esm/ScrollSync/ScrollSyncProvider.js.map +0 -1
- package/esm/ScrollSync/index.js.map +0 -1
- package/esm/ScrollSync/useScrollSync.js.map +0 -1
- package/esm/constants.js.map +0 -1
- package/esm/createDataInstance/createInstancePlugin.js.map +0 -1
- package/esm/createDataInstance/createInstanceRef.js.map +0 -1
- package/esm/createDataInstance/utils.js.map +0 -1
- package/esm/defer-render-hoc/index.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/react-spring/index.js.map +0 -1
- package/esm/react-spring/renderprops.js.map +0 -1
- package/esm/toolbar/ToolbarProvider.js.map +0 -1
- package/esm/useDataGrid/VolatileRowsListener.js.map +0 -1
- package/esm/useDataGrid/index.js.map +0 -1
- package/esm/useDataGrid/initColumnDefinition.js.map +0 -1
- package/esm/useDataGrid/useDataGrid.js.map +0 -1
- package/esm/useDataList/index.js.map +0 -1
- package/esm/useDataList/recordIterator.js.map +0 -1
- package/esm/useDataList/useDataList.js.map +0 -1
- package/esm/utils.js.map +0 -1
- package/esm/virtualization/AutoHeightList.js.map +0 -1
- package/esm/virtualization/FluidHeightList.js.map +0 -1
- package/esm/virtualization/index.js.map +0 -1
- package/react-spring/package.json +0 -10
- package/react-spring/renderprops/package.json +0 -10
- package/toolbar/ToolbarProvider/package.json +0 -10
- package/useDataGrid/VolatileRowsListener/package.json +0 -10
- package/useDataGrid/initColumnDefinition/package.json +0 -10
- package/useDataGrid/package.json +0 -10
- package/useDataGrid/useDataGrid/package.json +0 -10
- package/useDataList/package.json +0 -10
- package/useDataList/recordIterator/package.json +0 -10
- package/useDataList/useDataList/package.json +0 -10
- package/utils/package.json +0 -10
- package/virtualization/AutoHeightList/package.json +0 -10
- package/virtualization/FluidHeightList/package.json +0 -10
- package/virtualization/package.json +0 -10
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
4
|
-
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
5
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');
|
|
6
12
|
var dsUtilities = require('@elliemae/ds-utilities');
|
|
7
13
|
var hotkeys = require('hotkeys-js');
|
|
8
14
|
|
|
9
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
16
|
|
|
11
|
-
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
12
|
-
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
13
17
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
14
18
|
var hotkeys__default = /*#__PURE__*/_interopDefaultLegacy(hotkeys);
|
|
15
19
|
|
|
16
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
21
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default[
|
|
19
|
-
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
+
const defaultOptions = {
|
|
20
24
|
orientation: 'vertical'
|
|
21
25
|
};
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
const safeCallAction = function (e, fun) {
|
|
24
28
|
if (dsUtilities.isFunction(fun)) {
|
|
25
29
|
e.preventDefault();
|
|
26
30
|
|
|
@@ -28,56 +32,51 @@ var safeCallAction = function safeCallAction(e, fun) {
|
|
|
28
32
|
args[_key - 2] = arguments[_key];
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
fun
|
|
35
|
+
fun(...args);
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var parameterizedHandler = function parameterizedHandler(e) {
|
|
49
|
-
var handlerParams = dsUtilities.isFunction(params) ? params() : params;
|
|
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;
|
|
50
52
|
if (!allowDocumentHandler && handlerParams.item !== document.activeElement) return;
|
|
51
53
|
e.preventDefault();
|
|
52
54
|
handler(handlerParams);
|
|
53
55
|
};
|
|
54
56
|
|
|
55
|
-
hotkeys__default[
|
|
57
|
+
hotkeys__default["default"](hotkey, _objectSpread({
|
|
56
58
|
element: getContainer()
|
|
57
59
|
}, options), parameterizedHandler);
|
|
58
60
|
});
|
|
59
61
|
};
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Object.keys(hotKeys).forEach(
|
|
64
|
-
hotkeys__default[
|
|
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);
|
|
65
67
|
});
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
return null;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
var FocusGroup = /*#__PURE__*/function () {
|
|
73
|
-
function FocusGroup() {
|
|
74
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
|
-
|
|
76
|
-
_classCallCheck__default['default'](this, FocusGroup);
|
|
70
|
+
const noop = () => null;
|
|
77
71
|
|
|
72
|
+
class FocusGroup {
|
|
73
|
+
constructor() {
|
|
74
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
78
75
|
this.items = [];
|
|
79
76
|
this.options = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
80
|
-
|
|
77
|
+
const {
|
|
78
|
+
orientation
|
|
79
|
+
} = this.options;
|
|
81
80
|
this.keyBindings = _objectSpread({
|
|
82
81
|
ArrowUp: orientation !== 'horizontal' && 'previous',
|
|
83
82
|
ArrowRight: orientation !== 'vertical' && 'next',
|
|
@@ -97,9 +96,7 @@ var FocusGroup = /*#__PURE__*/function () {
|
|
|
97
96
|
first: this.focusFirst.bind(this),
|
|
98
97
|
last: this.focusLast.bind(this),
|
|
99
98
|
exit: this.exit.bind(this),
|
|
100
|
-
enter:
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
99
|
+
enter: () => null
|
|
103
100
|
};
|
|
104
101
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
105
102
|
this.register = this.register.bind(this);
|
|
@@ -113,233 +110,199 @@ var FocusGroup = /*#__PURE__*/function () {
|
|
|
113
110
|
this.getHotKeysParams = this.getHotKeysParams.bind(this);
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
getHotKeysParams() {
|
|
114
|
+
const item = this.currentFocusedItem;
|
|
115
|
+
const {
|
|
116
|
+
index
|
|
117
|
+
} = dsUtilities.get(item, ['dataset'], {});
|
|
118
|
+
return {
|
|
119
|
+
item,
|
|
120
|
+
index
|
|
121
|
+
};
|
|
122
|
+
}
|
|
120
123
|
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
}
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return typeof action === 'string' ? safeCallAction(e, _this.mapActions[action]) : safeCallAction(e, action);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
|
-
key: "register",
|
|
160
|
-
value: function register(node) {
|
|
161
|
-
var _this2 = this;
|
|
162
|
-
|
|
163
|
-
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
164
|
-
var afterIndex = this.items.findIndex(function (item) {
|
|
165
|
-
return item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING;
|
|
166
|
-
});
|
|
167
|
-
node.specialOnFocus = props.onFocus || noop;
|
|
168
|
-
node.specialOnBlur = props.onBlur || noop;
|
|
169
|
-
|
|
170
|
-
node.onclick = function () {
|
|
171
|
-
return _this2.focusItem(node);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
node.onfocus = function () {
|
|
175
|
-
_this2.focusItem(node);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
if (afterIndex === -1) {
|
|
179
|
-
this.items.push(node);
|
|
180
|
-
} else {
|
|
181
|
-
this.items.splice(afterIndex, 0, node);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "unregister",
|
|
186
|
-
value: function unregister(node) {
|
|
187
|
-
var index = this.getItemIndexByNode(node);
|
|
188
|
-
if (index > -1) this.items.splice(index, 1);
|
|
189
|
-
}
|
|
190
|
-
}, {
|
|
191
|
-
key: "exit",
|
|
192
|
-
value: function exit() {
|
|
193
|
-
var onExitFocusGroup = this.options.onExitFocusGroup;
|
|
194
|
-
onExitFocusGroup();
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "focusItem",
|
|
198
|
-
value: function focusItem(node) {
|
|
199
|
-
if (this.currentFocusedItem && this.currentFocusedItem !== node) {
|
|
200
|
-
this.currentFocusedItem.specialOnBlur();
|
|
201
|
-
this.currentFocusedItem.setAttribute('tabindex', -1);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (!node) return;
|
|
205
|
-
this.currentFocusedItem = node;
|
|
206
|
-
node.setAttribute('tabindex', 0);
|
|
207
|
-
node.focus();
|
|
208
|
-
node.specialOnFocus();
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
key: "focusNext",
|
|
212
|
-
value: function focusNext() {
|
|
213
|
-
var item = this.getNextItem();
|
|
214
|
-
this.focusItem(item);
|
|
215
|
-
}
|
|
216
|
-
}, {
|
|
217
|
-
key: "focusByNode",
|
|
218
|
-
value: function focusByNode(node) {
|
|
219
|
-
var index = this.getItemIndexByNode(node);
|
|
220
|
-
this.focusByIndex(index);
|
|
221
|
-
}
|
|
222
|
-
}, {
|
|
223
|
-
key: "focusByIndex",
|
|
224
|
-
value: function focusByIndex(index) {
|
|
225
|
-
var item = this.getItemByIndex(index);
|
|
226
|
-
this.focusItem(item);
|
|
227
|
-
}
|
|
228
|
-
}, {
|
|
229
|
-
key: "focusPrevious",
|
|
230
|
-
value: function focusPrevious() {
|
|
231
|
-
var prevItem = this.getPreviousItem();
|
|
232
|
-
this.focusItem(prevItem);
|
|
233
|
-
}
|
|
234
|
-
}, {
|
|
235
|
-
key: "focusFirst",
|
|
236
|
-
value: function focusFirst() {
|
|
237
|
-
var item = this.getFirstItem();
|
|
238
|
-
this.focusItem(item);
|
|
239
|
-
}
|
|
240
|
-
}, {
|
|
241
|
-
key: "focusLast",
|
|
242
|
-
value: function focusLast() {
|
|
243
|
-
var item = this.getLastItem();
|
|
244
|
-
this.focusItem(item);
|
|
245
|
-
}
|
|
246
|
-
}, {
|
|
247
|
-
key: "focusCurrent",
|
|
248
|
-
value: function focusCurrent() {
|
|
249
|
-
this.focusItem(this.currentFocusedItem);
|
|
250
|
-
}
|
|
251
|
-
}, {
|
|
252
|
-
key: "focusNextGroup",
|
|
253
|
-
value: function focusNextGroup() {
|
|
254
|
-
var onFocusNextGroup = this.options.onFocusNextGroup;
|
|
255
|
-
this.exit();
|
|
256
|
-
onFocusNextGroup();
|
|
257
|
-
}
|
|
258
|
-
}, {
|
|
259
|
-
key: "focusPreviousGroup",
|
|
260
|
-
value: function focusPreviousGroup() {
|
|
261
|
-
var onFocusPreviousGroup = this.options.onFocusPreviousGroup;
|
|
262
|
-
this.exit();
|
|
263
|
-
onFocusPreviousGroup();
|
|
264
|
-
}
|
|
265
|
-
}, {
|
|
266
|
-
key: "getNextItem",
|
|
267
|
-
value: function getNextItem() {
|
|
268
|
-
var loop = this.options.loop;
|
|
269
|
-
var currentIndex = this.getFocusedIndex();
|
|
270
|
-
var supposedNextIndex = currentIndex + 1;
|
|
271
|
-
|
|
272
|
-
if (!this.checkCanFocusNext(supposedNextIndex)) {
|
|
273
|
-
return loop ? this.getFirstItem() : this.focusNextGroup();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return this.getItemByIndex(supposedNextIndex);
|
|
277
|
-
}
|
|
278
|
-
}, {
|
|
279
|
-
key: "getPreviousItem",
|
|
280
|
-
value: function getPreviousItem() {
|
|
281
|
-
var loop = this.options.loop;
|
|
282
|
-
var currentIndex = this.getFocusedIndex();
|
|
283
|
-
var supposedPrevIndex = currentIndex - 1;
|
|
284
|
-
|
|
285
|
-
if (!this.checkCanFocusPrev(supposedPrevIndex)) {
|
|
286
|
-
return loop ? this.getLastItem() : this.focusPreviousGroup();
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return this.getItemByIndex(supposedPrevIndex);
|
|
290
|
-
}
|
|
291
|
-
}, {
|
|
292
|
-
key: "checkCanFocusNext",
|
|
293
|
-
value: function checkCanFocusNext(index) {
|
|
294
|
-
return this.items.length > index;
|
|
295
|
-
}
|
|
296
|
-
}, {
|
|
297
|
-
key: "checkCanFocusPrev",
|
|
298
|
-
value: function checkCanFocusPrev(index) {
|
|
299
|
-
return index >= 0;
|
|
300
|
-
}
|
|
301
|
-
}, {
|
|
302
|
-
key: "getItemByIndex",
|
|
303
|
-
value: function getItemByIndex(index) {
|
|
304
|
-
return this.items[index];
|
|
305
|
-
}
|
|
306
|
-
}, {
|
|
307
|
-
key: "getItemIndexByNode",
|
|
308
|
-
value: function getItemIndexByNode(node) {
|
|
309
|
-
return this.items.findIndex(function (item) {
|
|
310
|
-
return item === node;
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}, {
|
|
314
|
-
key: "getFocusedIndex",
|
|
315
|
-
value: function getFocusedIndex() {
|
|
316
|
-
return this.getItemIndexByNode(document.activeElement);
|
|
317
|
-
}
|
|
318
|
-
}, {
|
|
319
|
-
key: "getFocusedItem",
|
|
320
|
-
value: function getFocusedItem() {
|
|
321
|
-
var index = this.getFocusedIndex();
|
|
322
|
-
return index > -1 && this.items[index];
|
|
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);
|
|
323
163
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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);
|
|
328
182
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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();
|
|
333
250
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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();
|
|
338
264
|
}
|
|
339
|
-
}]);
|
|
340
265
|
|
|
341
|
-
|
|
342
|
-
}
|
|
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
|
+
}
|
|
343
307
|
|
|
344
308
|
module.exports = FocusGroup;
|
|
345
|
-
//# sourceMappingURL=FocusGroup.js.map
|
|
@@ -6,7 +6,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
6
6
|
|
|
7
7
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
8
8
|
|
|
9
|
-
var FocusGroupContext = /*#__PURE__*/React__default[
|
|
9
|
+
var FocusGroupContext = /*#__PURE__*/React__default["default"].createContext();
|
|
10
10
|
|
|
11
11
|
module.exports = FocusGroupContext;
|
|
12
|
-
//# sourceMappingURL=FocusGroupContext.js.map
|