@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,83 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var FocusGroup_exports = {};
|
|
29
|
-
__export(FocusGroup_exports, {
|
|
30
|
-
FocusGroup: () => FocusGroup,
|
|
31
|
-
default: () => FocusGroup_default
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
35
|
-
var import_hotkeys_js = __toESM(require("hotkeys-js"));
|
|
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; }
|
|
36
23
|
const defaultOptions = {
|
|
37
|
-
orientation:
|
|
24
|
+
orientation: 'vertical'
|
|
38
25
|
};
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
|
|
27
|
+
const safeCallAction = function (e, fun) {
|
|
28
|
+
if (dsUtilities.isFunction(fun)) {
|
|
41
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
|
+
|
|
42
35
|
fun(...args);
|
|
43
36
|
}
|
|
44
37
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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;
|
|
52
53
|
e.preventDefault();
|
|
53
54
|
handler(handlerParams);
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
|
|
57
|
+
hotkeys__default["default"](hotkey, _objectSpread({
|
|
58
|
+
element: getContainer()
|
|
59
|
+
}, options), parameterizedHandler);
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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);
|
|
61
67
|
});
|
|
62
68
|
};
|
|
69
|
+
|
|
63
70
|
const noop = () => null;
|
|
71
|
+
|
|
64
72
|
class FocusGroup {
|
|
65
|
-
constructor(
|
|
73
|
+
constructor() {
|
|
74
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
66
75
|
this.items = [];
|
|
67
|
-
this.options = {
|
|
68
|
-
const {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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);
|
|
81
91
|
this.currentFocusedItem = null;
|
|
82
92
|
this.currIndex = null;
|
|
83
93
|
this.mapActions = {
|
|
@@ -99,151 +109,200 @@ class FocusGroup {
|
|
|
99
109
|
this.focusCurrent = this.focusCurrent.bind(this);
|
|
100
110
|
this.getHotKeysParams = this.getHotKeysParams.bind(this);
|
|
101
111
|
}
|
|
112
|
+
|
|
102
113
|
getHotKeysParams() {
|
|
103
114
|
const item = this.currentFocusedItem;
|
|
104
|
-
const {
|
|
115
|
+
const {
|
|
116
|
+
index
|
|
117
|
+
} = dsUtilities.get(item, ['dataset'], {});
|
|
105
118
|
return {
|
|
106
119
|
item,
|
|
107
120
|
index
|
|
108
121
|
};
|
|
109
122
|
}
|
|
123
|
+
|
|
110
124
|
activate() {
|
|
111
|
-
const {
|
|
112
|
-
|
|
125
|
+
const {
|
|
126
|
+
getContainer
|
|
127
|
+
} = this.options;
|
|
128
|
+
document.addEventListener('keydown', this.handleKeyDown, true);
|
|
113
129
|
registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);
|
|
114
130
|
}
|
|
131
|
+
|
|
115
132
|
deactivate() {
|
|
116
|
-
document.removeEventListener(
|
|
133
|
+
document.removeEventListener('keydown', this.handleKeyDown, true);
|
|
117
134
|
unregisterHotKeys(this.options.hotKeys);
|
|
118
135
|
}
|
|
136
|
+
|
|
119
137
|
handleKeyDown(e) {
|
|
120
|
-
if (!this.isGroupActive())
|
|
121
|
-
return;
|
|
138
|
+
if (!this.isGroupActive()) return;
|
|
122
139
|
this.executeActionByEvent(e);
|
|
123
140
|
}
|
|
141
|
+
|
|
124
142
|
executeActionByEvent(e) {
|
|
125
143
|
const actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];
|
|
126
|
-
return actions.map(
|
|
144
|
+
return actions.map(action => typeof action === 'string' ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action));
|
|
127
145
|
}
|
|
128
|
-
|
|
129
|
-
|
|
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);
|
|
130
150
|
node.specialOnFocus = props.onFocus || noop;
|
|
131
151
|
node.specialOnBlur = props.onBlur || noop;
|
|
152
|
+
|
|
132
153
|
node.onclick = () => this.focusItem(node);
|
|
154
|
+
|
|
133
155
|
node.onfocus = () => {
|
|
134
156
|
this.focusItem(node);
|
|
135
157
|
};
|
|
158
|
+
|
|
136
159
|
if (afterIndex === -1) {
|
|
137
160
|
this.items.push(node);
|
|
138
161
|
} else {
|
|
139
162
|
this.items.splice(afterIndex, 0, node);
|
|
140
163
|
}
|
|
141
164
|
}
|
|
165
|
+
|
|
142
166
|
unregister(node) {
|
|
143
167
|
const index = this.getItemIndexByNode(node);
|
|
144
|
-
if (index > -1)
|
|
145
|
-
this.items.splice(index, 1);
|
|
168
|
+
if (index > -1) this.items.splice(index, 1);
|
|
146
169
|
}
|
|
170
|
+
|
|
147
171
|
exit() {
|
|
148
|
-
const {
|
|
172
|
+
const {
|
|
173
|
+
onExitFocusGroup
|
|
174
|
+
} = this.options;
|
|
149
175
|
onExitFocusGroup();
|
|
150
176
|
}
|
|
177
|
+
|
|
151
178
|
focusItem(node) {
|
|
152
179
|
if (this.currentFocusedItem && this.currentFocusedItem !== node) {
|
|
153
180
|
this.currentFocusedItem.specialOnBlur();
|
|
154
|
-
this.currentFocusedItem.setAttribute(
|
|
181
|
+
this.currentFocusedItem.setAttribute('tabindex', -1);
|
|
155
182
|
}
|
|
156
|
-
|
|
157
|
-
|
|
183
|
+
|
|
184
|
+
if (!node) return;
|
|
158
185
|
this.currentFocusedItem = node;
|
|
159
|
-
node.setAttribute(
|
|
186
|
+
node.setAttribute('tabindex', 0);
|
|
160
187
|
node.focus();
|
|
161
188
|
node.specialOnFocus();
|
|
162
189
|
}
|
|
190
|
+
|
|
163
191
|
focusNext() {
|
|
164
192
|
const item = this.getNextItem();
|
|
165
193
|
this.focusItem(item);
|
|
166
194
|
}
|
|
195
|
+
|
|
167
196
|
focusByNode(node) {
|
|
168
197
|
const index = this.getItemIndexByNode(node);
|
|
169
198
|
this.focusByIndex(index);
|
|
170
199
|
}
|
|
200
|
+
|
|
171
201
|
focusByIndex(index) {
|
|
172
202
|
const item = this.getItemByIndex(index);
|
|
173
203
|
this.focusItem(item);
|
|
174
204
|
}
|
|
205
|
+
|
|
175
206
|
focusPrevious() {
|
|
176
207
|
const prevItem = this.getPreviousItem();
|
|
177
208
|
this.focusItem(prevItem);
|
|
178
209
|
}
|
|
210
|
+
|
|
179
211
|
focusFirst() {
|
|
180
212
|
const item = this.getFirstItem();
|
|
181
213
|
this.focusItem(item);
|
|
182
214
|
}
|
|
215
|
+
|
|
183
216
|
focusLast() {
|
|
184
217
|
const item = this.getLastItem();
|
|
185
218
|
this.focusItem(item);
|
|
186
219
|
}
|
|
220
|
+
|
|
187
221
|
focusCurrent() {
|
|
188
222
|
this.focusItem(this.currentFocusedItem);
|
|
189
223
|
}
|
|
224
|
+
|
|
190
225
|
focusNextGroup() {
|
|
191
|
-
const {
|
|
226
|
+
const {
|
|
227
|
+
onFocusNextGroup
|
|
228
|
+
} = this.options;
|
|
192
229
|
this.exit();
|
|
193
230
|
onFocusNextGroup();
|
|
194
231
|
}
|
|
232
|
+
|
|
195
233
|
focusPreviousGroup() {
|
|
196
|
-
const {
|
|
234
|
+
const {
|
|
235
|
+
onFocusPreviousGroup
|
|
236
|
+
} = this.options;
|
|
197
237
|
this.exit();
|
|
198
238
|
onFocusPreviousGroup();
|
|
199
239
|
}
|
|
240
|
+
|
|
200
241
|
getNextItem() {
|
|
201
|
-
const {
|
|
242
|
+
const {
|
|
243
|
+
loop
|
|
244
|
+
} = this.options;
|
|
202
245
|
const currentIndex = this.getFocusedIndex();
|
|
203
246
|
const supposedNextIndex = currentIndex + 1;
|
|
247
|
+
|
|
204
248
|
if (!this.checkCanFocusNext(supposedNextIndex)) {
|
|
205
249
|
return loop ? this.getFirstItem() : this.focusNextGroup();
|
|
206
250
|
}
|
|
251
|
+
|
|
207
252
|
return this.getItemByIndex(supposedNextIndex);
|
|
208
253
|
}
|
|
254
|
+
|
|
209
255
|
getPreviousItem() {
|
|
210
|
-
const {
|
|
256
|
+
const {
|
|
257
|
+
loop
|
|
258
|
+
} = this.options;
|
|
211
259
|
const currentIndex = this.getFocusedIndex();
|
|
212
260
|
const supposedPrevIndex = currentIndex - 1;
|
|
261
|
+
|
|
213
262
|
if (!this.checkCanFocusPrev(supposedPrevIndex)) {
|
|
214
263
|
return loop ? this.getLastItem() : this.focusPreviousGroup();
|
|
215
264
|
}
|
|
265
|
+
|
|
216
266
|
return this.getItemByIndex(supposedPrevIndex);
|
|
217
267
|
}
|
|
268
|
+
|
|
218
269
|
checkCanFocusNext(index) {
|
|
219
270
|
return this.items.length > index;
|
|
220
271
|
}
|
|
272
|
+
|
|
221
273
|
checkCanFocusPrev(index) {
|
|
222
274
|
return index >= 0;
|
|
223
275
|
}
|
|
276
|
+
|
|
224
277
|
getItemByIndex(index) {
|
|
225
278
|
return this.items[index];
|
|
226
279
|
}
|
|
280
|
+
|
|
227
281
|
getItemIndexByNode(node) {
|
|
228
|
-
return this.items.findIndex(
|
|
282
|
+
return this.items.findIndex(item => item === node);
|
|
229
283
|
}
|
|
284
|
+
|
|
230
285
|
getFocusedIndex() {
|
|
231
286
|
return this.getItemIndexByNode(document.activeElement);
|
|
232
287
|
}
|
|
288
|
+
|
|
233
289
|
getFocusedItem() {
|
|
234
290
|
const index = this.getFocusedIndex();
|
|
235
291
|
return index > -1 && this.items[index];
|
|
236
292
|
}
|
|
293
|
+
|
|
237
294
|
isGroupActive() {
|
|
238
295
|
return this.getFocusedIndex() !== -1;
|
|
239
296
|
}
|
|
297
|
+
|
|
240
298
|
getFirstItem() {
|
|
241
299
|
return !!this.items.length && this.items[0];
|
|
242
300
|
}
|
|
301
|
+
|
|
243
302
|
getLastItem() {
|
|
244
303
|
return !!this.items.length && this.items[this.items.length - 1];
|
|
245
304
|
}
|
|
305
|
+
|
|
246
306
|
}
|
|
247
|
-
|
|
248
|
-
module.exports =
|
|
249
|
-
//# sourceMappingURL=FocusGroup.js.map
|
|
307
|
+
|
|
308
|
+
module.exports = FocusGroup;
|
|
@@ -1,38 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var FocusGroupContext_exports = {};
|
|
29
|
-
__export(FocusGroupContext_exports, {
|
|
30
|
-
FocusGroupContext: () => FocusGroupContext,
|
|
31
|
-
default: () => FocusGroupContext_default
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
const FocusGroupContext = import_react.default.createContext();
|
|
36
|
-
var FocusGroupContext_default = FocusGroupContext;
|
|
37
|
-
module.exports = __toCommonJS(FocusGroupContext_exports);
|
|
38
|
-
//# sourceMappingURL=FocusGroupContext.js.map
|
|
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,47 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var FocusGroupManager_exports = {};
|
|
29
|
-
__export(FocusGroupManager_exports, {
|
|
30
|
-
FocusGroupManager: () => FocusGroupProvider,
|
|
31
|
-
FocusGroupProvider: () => FocusGroupProvider,
|
|
32
|
-
default: () => FocusGroupManager_default
|
|
33
|
-
});
|
|
34
|
-
var React = __toESM(require("react"));
|
|
35
|
-
var import_react = __toESM(require("react"));
|
|
36
|
-
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
37
|
-
var import_FocusGroup = require("./FocusGroup");
|
|
38
|
-
var import_FocusGroupContext = require("./FocusGroupContext");
|
|
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
|
+
|
|
39
13
|
const noop = () => null;
|
|
40
|
-
|
|
14
|
+
|
|
15
|
+
class FocusGroupProvider extends React.Component {
|
|
41
16
|
constructor(props) {
|
|
42
17
|
super(props);
|
|
43
18
|
this.activated = false;
|
|
44
|
-
this.focusGroup = new
|
|
19
|
+
this.focusGroup = new FocusGroup(props);
|
|
45
20
|
props.onFocusGroupSet(this);
|
|
46
21
|
this.actions = {
|
|
47
22
|
activate: this.activate.bind(this),
|
|
@@ -58,58 +33,75 @@ class FocusGroupProvider extends import_react.Component {
|
|
|
58
33
|
focusPrevious: this.focusGroup.focusPrevious
|
|
59
34
|
};
|
|
60
35
|
}
|
|
36
|
+
|
|
61
37
|
componentDidMount() {
|
|
62
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
autoFocusOnMount
|
|
40
|
+
} = this.props;
|
|
63
41
|
this.activate();
|
|
42
|
+
|
|
64
43
|
if (autoFocusOnMount) {
|
|
65
44
|
setTimeout(() => {
|
|
66
45
|
this.actions.focusFirst();
|
|
67
46
|
}, 0);
|
|
68
47
|
}
|
|
69
48
|
}
|
|
49
|
+
|
|
70
50
|
componentWillUnmount() {
|
|
71
51
|
this.deactivate();
|
|
72
52
|
}
|
|
53
|
+
|
|
73
54
|
activate() {
|
|
74
|
-
const {
|
|
55
|
+
const {
|
|
56
|
+
onActivate
|
|
57
|
+
} = this.props;
|
|
75
58
|
this.focusGroup.activate();
|
|
76
59
|
this.activated = true;
|
|
77
|
-
if (
|
|
78
|
-
onActivate();
|
|
60
|
+
if (dsUtilities.isFunction(onActivate)) onActivate();
|
|
79
61
|
}
|
|
62
|
+
|
|
80
63
|
deactivate() {
|
|
81
|
-
const {
|
|
64
|
+
const {
|
|
65
|
+
onExitFocusGroup
|
|
66
|
+
} = this.props;
|
|
82
67
|
this.activated = false;
|
|
83
68
|
this.focusGroup.deactivate();
|
|
84
|
-
|
|
69
|
+
|
|
70
|
+
if (dsUtilities.isFunction(onExitFocusGroup)) {
|
|
85
71
|
onExitFocusGroup();
|
|
86
72
|
}
|
|
87
73
|
}
|
|
74
|
+
|
|
88
75
|
register(item) {
|
|
89
76
|
this.focusGroup.register(item);
|
|
90
77
|
}
|
|
78
|
+
|
|
91
79
|
unregister(item) {
|
|
92
80
|
this.focusGroup.unregister(item);
|
|
93
81
|
}
|
|
82
|
+
|
|
94
83
|
focusItemByIndex(index) {
|
|
95
|
-
if (!this.activated)
|
|
96
|
-
this.activate();
|
|
84
|
+
if (!this.activated) this.activate();
|
|
97
85
|
setTimeout(() => {
|
|
98
86
|
this.focusGroup.focusByIndex(index);
|
|
99
87
|
}, 200);
|
|
100
88
|
}
|
|
89
|
+
|
|
101
90
|
focusItemByNode(node) {
|
|
102
|
-
if (!this.activated)
|
|
103
|
-
this.activate();
|
|
91
|
+
if (!this.activated) this.activate();
|
|
104
92
|
const index = this.focusGroup.getItemIndexByNode(node);
|
|
105
93
|
this.focusItemByIndex(index);
|
|
106
94
|
}
|
|
95
|
+
|
|
107
96
|
render() {
|
|
108
|
-
const {
|
|
109
|
-
|
|
97
|
+
const {
|
|
98
|
+
children
|
|
99
|
+
} = this.props;
|
|
100
|
+
return /*#__PURE__*/_jsx__default["default"](FocusGroupContext.Provider, {
|
|
110
101
|
value: this.actions
|
|
111
|
-
}, children);
|
|
102
|
+
}, void 0, children);
|
|
112
103
|
}
|
|
104
|
+
|
|
113
105
|
}
|
|
114
106
|
FocusGroupProvider.defaultProps = {
|
|
115
107
|
exitWhenNoPrevious: false,
|
|
@@ -121,6 +113,5 @@ FocusGroupProvider.defaultProps = {
|
|
|
121
113
|
onFocusNextGroup: noop,
|
|
122
114
|
onFocusGroupSet: noop
|
|
123
115
|
};
|
|
124
|
-
|
|
125
|
-
module.exports =
|
|
126
|
-
//# sourceMappingURL=FocusGroupManager.js.map
|
|
116
|
+
|
|
117
|
+
module.exports = FocusGroupProvider;
|