@elliemae/ds-shared 2.2.0-next.3 → 2.3.0-alpha.1
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 +55 -35
- package/cjs/Animations/BaseAnimation.js.map +7 -0
- package/cjs/Animations/Grow.js +54 -41
- package/cjs/Animations/Grow.js.map +7 -0
- package/cjs/Animations/GrowRight.js +63 -41
- package/cjs/Animations/GrowRight.js.map +7 -0
- package/cjs/Animations/GrowVertical.js +47 -7
- package/cjs/Animations/GrowVertical.js.map +7 -0
- package/cjs/CheckableGroup.js +67 -65
- package/cjs/CheckableGroup.js.map +7 -0
- package/cjs/DeferRenderAfterComputation.js +48 -24
- package/cjs/DeferRenderAfterComputation.js.map +7 -0
- package/cjs/FocusGroup/FocusGrid.js +108 -143
- package/cjs/FocusGroup/FocusGrid.js.map +7 -0
- package/cjs/FocusGroup/FocusGroup.js +88 -147
- package/cjs/FocusGroup/FocusGroup.js.map +7 -0
- package/cjs/FocusGroup/FocusGroupContext.js +38 -11
- package/cjs/FocusGroup/FocusGroupContext.js.map +7 -0
- package/cjs/FocusGroup/FocusGroupManager.js +56 -47
- package/cjs/FocusGroup/FocusGroupManager.js.map +7 -0
- package/cjs/FocusGroup/focusGroupManagerHoc.js +52 -42
- package/cjs/FocusGroup/focusGroupManagerHoc.js.map +7 -0
- package/cjs/FocusGroup/index.js +47 -21
- package/cjs/FocusGroup/index.js.map +7 -0
- package/cjs/FocusGroup/useFocusGroupItem.js +59 -51
- package/cjs/FocusGroup/useFocusGroupItem.js.map +7 -0
- package/cjs/FocusGroup/utils/getNextCellPosition.js +47 -27
- package/cjs/FocusGroup/utils/getNextCellPosition.js.map +7 -0
- package/cjs/GroupContext/Group.js +64 -73
- package/cjs/GroupContext/Group.js.map +7 -0
- package/cjs/GroupContext/GroupContext.js +36 -13
- package/cjs/GroupContext/GroupContext.js.map +7 -0
- package/cjs/GroupContext/GroupItem.js +39 -21
- package/cjs/GroupContext/GroupItem.js.map +7 -0
- package/cjs/GroupContext/index.js +39 -13
- package/cjs/GroupContext/index.js.map +7 -0
- package/cjs/ScrollSync/ScrollSync.js +60 -75
- package/cjs/ScrollSync/ScrollSync.js.map +7 -0
- package/cjs/ScrollSync/ScrollSyncPane.js +52 -60
- package/cjs/ScrollSync/ScrollSyncPane.js.map +7 -0
- package/cjs/ScrollSync/ScrollSyncProvider.js +103 -50
- package/cjs/ScrollSync/ScrollSyncProvider.js.map +7 -0
- package/cjs/ScrollSync/index.js +37 -11
- package/cjs/ScrollSync/index.js.map +7 -0
- package/cjs/ScrollSync/useScrollSync.js +38 -7
- package/cjs/ScrollSync/useScrollSync.js.map +7 -0
- package/cjs/constants.js +65 -46
- package/cjs/constants.js.map +7 -0
- package/cjs/createDataInstance/createInstancePlugin.js +41 -29
- package/cjs/createDataInstance/createInstancePlugin.js.map +7 -0
- package/cjs/createDataInstance/createInstanceRef.js +66 -71
- package/cjs/createDataInstance/createInstanceRef.js.map +7 -0
- package/cjs/createDataInstance/utils.js +76 -100
- package/cjs/createDataInstance/utils.js.map +7 -0
- package/cjs/defer-render-hoc/index.js +48 -41
- package/cjs/defer-render-hoc/index.js.map +7 -0
- package/cjs/dimsum.config.js +38 -6
- package/cjs/dimsum.config.js.map +7 -0
- package/cjs/index.js +40 -17
- package/cjs/index.js.map +7 -0
- package/cjs/prop-types.js +106 -49
- package/cjs/prop-types.js.map +7 -0
- package/cjs/react-spring/index.js +28 -14
- package/cjs/react-spring/index.js.map +7 -0
- package/cjs/react-spring/renderprops.js +28 -14
- package/cjs/react-spring/renderprops.js.map +7 -0
- package/cjs/toolbar/ToolbarProvider.js +82 -94
- package/cjs/toolbar/ToolbarProvider.js.map +7 -0
- package/cjs/useDataGrid/VolatileRowsListener.js +38 -13
- package/cjs/useDataGrid/VolatileRowsListener.js.map +7 -0
- package/cjs/useDataGrid/index.js +36 -7
- package/cjs/useDataGrid/index.js.map +7 -0
- package/cjs/useDataGrid/initColumnDefinition.js +105 -110
- package/cjs/useDataGrid/initColumnDefinition.js.map +7 -0
- package/cjs/useDataGrid/useDataGrid.js +122 -148
- package/cjs/useDataGrid/useDataGrid.js.map +7 -0
- package/cjs/useDataList/index.js +36 -7
- package/cjs/useDataList/index.js.map +7 -0
- package/cjs/useDataList/recordIterator.js +42 -18
- package/cjs/useDataList/recordIterator.js.map +7 -0
- package/cjs/useDataList/useDataList.js +74 -83
- package/cjs/useDataList/useDataList.js.map +7 -0
- package/cjs/utils.js +71 -80
- package/cjs/utils.js.map +7 -0
- package/cjs/virtualization/AutoHeightList.js +62 -54
- package/cjs/virtualization/AutoHeightList.js.map +7 -0
- package/cjs/virtualization/FluidHeightList.js +42 -48
- package/cjs/virtualization/FluidHeightList.js.map +7 -0
- package/cjs/virtualization/index.js +48 -20
- package/cjs/virtualization/index.js.map +7 -0
- package/esm/Animations/BaseAnimation.js +26 -29
- package/esm/Animations/BaseAnimation.js.map +7 -0
- package/esm/Animations/Grow.js +25 -35
- package/esm/Animations/Grow.js.map +7 -0
- package/esm/Animations/GrowRight.js +34 -35
- package/esm/Animations/GrowRight.js.map +7 -0
- package/esm/Animations/GrowVertical.js +29 -4
- package/esm/Animations/GrowVertical.js.map +7 -0
- package/esm/CheckableGroup.js +35 -52
- package/esm/CheckableGroup.js.map +7 -0
- package/esm/DeferRenderAfterComputation.js +16 -15
- package/esm/DeferRenderAfterComputation.js.map +7 -0
- package/esm/FocusGroup/FocusGrid.js +64 -117
- package/esm/FocusGroup/FocusGrid.js.map +7 -0
- package/esm/FocusGroup/FocusGroup.js +56 -137
- package/esm/FocusGroup/FocusGroup.js.map +7 -0
- package/esm/FocusGroup/FocusGroupContext.js +9 -5
- package/esm/FocusGroup/FocusGroupContext.js.map +7 -0
- package/esm/FocusGroup/FocusGroupManager.js +24 -38
- package/esm/FocusGroup/FocusGroupManager.js.map +7 -0
- package/esm/FocusGroup/focusGroupManagerHoc.js +24 -36
- package/esm/FocusGroup/focusGroupManagerHoc.js.map +7 -0
- package/esm/FocusGroup/index.js +18 -6
- package/esm/FocusGroup/index.js.map +7 -0
- package/esm/FocusGroup/useFocusGroupItem.js +28 -40
- package/esm/FocusGroup/useFocusGroupItem.js.map +7 -0
- package/esm/FocusGroup/utils/getNextCellPosition.js +18 -25
- package/esm/FocusGroup/utils/getNextCellPosition.js.map +7 -0
- package/esm/GroupContext/Group.js +34 -66
- package/esm/GroupContext/Group.js.map +7 -0
- package/esm/GroupContext/GroupContext.js +7 -5
- package/esm/GroupContext/GroupContext.js.map +7 -0
- package/esm/GroupContext/GroupItem.js +10 -15
- package/esm/GroupContext/GroupItem.js.map +7 -0
- package/esm/GroupContext/index.js +10 -3
- package/esm/GroupContext/index.js.map +7 -0
- package/esm/ScrollSync/ScrollSync.js +30 -64
- package/esm/ScrollSync/ScrollSync.js.map +7 -0
- package/esm/ScrollSync/ScrollSyncPane.js +22 -52
- package/esm/ScrollSync/ScrollSyncPane.js.map +7 -0
- package/esm/ScrollSync/ScrollSyncProvider.js +74 -42
- package/esm/ScrollSync/ScrollSyncProvider.js.map +7 -0
- package/esm/ScrollSync/index.js +8 -2
- package/esm/ScrollSync/index.js.map +7 -0
- package/esm/ScrollSync/useScrollSync.js +9 -5
- package/esm/ScrollSync/useScrollSync.js.map +7 -0
- package/esm/constants.js +37 -28
- package/esm/constants.js.map +7 -0
- package/esm/createDataInstance/createInstancePlugin.js +12 -23
- package/esm/createDataInstance/createInstancePlugin.js.map +7 -0
- package/esm/createDataInstance/createInstanceRef.js +36 -59
- package/esm/createDataInstance/createInstanceRef.js.map +7 -0
- package/esm/createDataInstance/utils.js +48 -85
- package/esm/createDataInstance/utils.js.map +7 -0
- package/esm/defer-render-hoc/index.js +17 -31
- package/esm/defer-render-hoc/index.js.map +7 -0
- package/esm/dimsum.config.js +9 -4
- package/esm/dimsum.config.js.map +7 -0
- package/esm/index.js +11 -5
- package/esm/index.js.map +7 -0
- package/esm/prop-types.js +75 -31
- package/esm/prop-types.js.map +7 -0
- package/esm/react-spring/index.js +3 -1
- package/esm/react-spring/index.js.map +7 -0
- package/esm/react-spring/renderprops.js +3 -1
- package/esm/react-spring/renderprops.js.map +7 -0
- package/esm/toolbar/ToolbarProvider.js +45 -74
- package/esm/toolbar/ToolbarProvider.js.map +7 -0
- package/esm/useDataGrid/VolatileRowsListener.js +9 -11
- package/esm/useDataGrid/VolatileRowsListener.js.map +7 -0
- package/esm/useDataGrid/index.js +7 -1
- package/esm/useDataGrid/index.js.map +7 -0
- package/esm/useDataGrid/initColumnDefinition.js +78 -94
- package/esm/useDataGrid/initColumnDefinition.js.map +7 -0
- package/esm/useDataGrid/useDataGrid.js +82 -99
- package/esm/useDataGrid/useDataGrid.js.map +7 -0
- package/esm/useDataList/index.js +7 -1
- package/esm/useDataList/index.js.map +7 -0
- package/esm/useDataList/recordIterator.js +13 -14
- package/esm/useDataList/recordIterator.js.map +7 -0
- package/esm/useDataList/useDataList.js +44 -67
- package/esm/useDataList/useDataList.js.map +7 -0
- package/esm/utils.js +42 -59
- package/esm/utils.js.map +7 -0
- package/esm/virtualization/AutoHeightList.js +28 -40
- package/esm/virtualization/AutoHeightList.js.map +7 -0
- package/esm/virtualization/FluidHeightList.js +14 -38
- package/esm/virtualization/FluidHeightList.js.map +7 -0
- package/esm/virtualization/index.js +19 -16
- package/esm/virtualization/index.js.map +7 -0
- package/package.json +3 -3
- package/types/Animations/BaseAnimation.d.ts +1 -0
- package/types/Animations/Grow.d.ts +1 -0
- package/types/Animations/GrowRight.d.ts +1 -0
- package/types/CheckableGroup.d.ts +1 -0
- package/types/DeferRenderAfterComputation.d.ts +3 -2
- package/types/FocusGroup/FocusGrid.d.ts +5 -3
- package/types/FocusGroup/FocusGroup.d.ts +3 -1
- package/types/FocusGroup/FocusGroupContext.d.ts +3 -2
- package/types/FocusGroup/FocusGroupManager.d.ts +3 -1
- package/types/FocusGroup/focusGroupManagerHoc.d.ts +3 -1
- package/types/FocusGroup/index.d.ts +6 -6
- package/types/FocusGroup/useFocusGroupItem.d.ts +3 -1
- package/types/FocusGroup/utils/getNextCellPosition.d.ts +3 -1
- package/types/GroupContext/Group.d.ts +1 -0
- package/types/GroupContext/GroupItem.d.ts +1 -0
- package/types/GroupContext/index.d.ts +3 -3
- package/types/ScrollSync/ScrollSync.d.ts +4 -2
- package/types/ScrollSync/ScrollSyncPane.d.ts +2 -2
- package/types/ScrollSync/index.d.ts +2 -2
- package/types/ScrollSync/useScrollSync.d.ts +6 -5
- package/types/createDataInstance/createInstancePlugin.d.ts +2 -1
- package/types/createDataInstance/createInstanceRef.d.ts +3 -1
- package/types/dimsum.config.d.ts +3 -2
- package/types/index.d.ts +2 -2
- package/types/toolbar/ToolbarProvider.d.ts +3 -8
- package/types/useDataGrid/VolatileRowsListener.d.ts +3 -1
- package/types/useDataGrid/index.d.ts +1 -1
- package/types/useDataGrid/initColumnDefinition.d.ts +2 -1
- package/types/useDataGrid/useDataGrid.d.ts +3 -2
- package/types/useDataList/index.d.ts +1 -1
- package/types/useDataList/useDataList.d.ts +3 -2
|
@@ -1,93 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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 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"));
|
|
23
36
|
const defaultOptions = {
|
|
24
|
-
orientation:
|
|
37
|
+
orientation: "vertical"
|
|
25
38
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (dsUtilities.isFunction(fun)) {
|
|
39
|
+
const safeCallAction = (e, fun, ...args) => {
|
|
40
|
+
if ((0, import_ds_utilities.isFunction)(fun)) {
|
|
29
41
|
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
42
|
fun(...args);
|
|
36
43
|
}
|
|
37
44
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
45
|
+
const registerHotkeys = (hotKeys = {}, params, getContainer = () => document) => {
|
|
46
|
+
Object.keys(hotKeys).forEach((hotkey) => {
|
|
47
|
+
const { options, handler, allowDocumentHandler = false } = hotKeys[hotkey];
|
|
48
|
+
const parameterizedHandler = (e) => {
|
|
49
|
+
const handlerParams = (0, import_ds_utilities.isFunction)(params) ? params() : params;
|
|
50
|
+
if (!allowDocumentHandler && handlerParams.item !== document.activeElement)
|
|
51
|
+
return;
|
|
53
52
|
e.preventDefault();
|
|
54
53
|
handler(handlerParams);
|
|
55
54
|
};
|
|
56
|
-
|
|
57
|
-
hotkeys__default["default"](hotkey, _objectSpread({
|
|
58
|
-
element: getContainer()
|
|
59
|
-
}, options), parameterizedHandler);
|
|
55
|
+
(0, import_hotkeys_js.default)(hotkey, { element: getContainer(), ...options }, parameterizedHandler);
|
|
60
56
|
});
|
|
61
57
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Object.keys(hotKeys).forEach(hotkey => {
|
|
66
|
-
hotkeys__default["default"].unbind(hotkey);
|
|
58
|
+
const unregisterHotKeys = (hotKeys = {}) => {
|
|
59
|
+
Object.keys(hotKeys).forEach((hotkey) => {
|
|
60
|
+
import_hotkeys_js.default.unbind(hotkey);
|
|
67
61
|
});
|
|
68
62
|
};
|
|
69
|
-
|
|
70
63
|
const noop = () => null;
|
|
71
|
-
|
|
72
64
|
class FocusGroup {
|
|
73
|
-
constructor() {
|
|
74
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
+
constructor(options = {}) {
|
|
75
66
|
this.items = [];
|
|
76
|
-
this.options =
|
|
77
|
-
const {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, options.keyBindings);
|
|
67
|
+
this.options = { ...defaultOptions, ...options };
|
|
68
|
+
const { orientation } = this.options;
|
|
69
|
+
this.keyBindings = {
|
|
70
|
+
ArrowUp: orientation !== "horizontal" && "previous",
|
|
71
|
+
ArrowRight: orientation !== "vertical" && "next",
|
|
72
|
+
ArrowDown: orientation !== "horizontal" && "next",
|
|
73
|
+
ArrowLeft: orientation !== "vertical" && "previous",
|
|
74
|
+
Home: "first",
|
|
75
|
+
End: "last",
|
|
76
|
+
PageUp: "first",
|
|
77
|
+
PageDown: "last",
|
|
78
|
+
Escape: "exit",
|
|
79
|
+
...options.keyBindings
|
|
80
|
+
};
|
|
91
81
|
this.currentFocusedItem = null;
|
|
92
82
|
this.currIndex = null;
|
|
93
83
|
this.mapActions = {
|
|
@@ -109,200 +99,151 @@ class FocusGroup {
|
|
|
109
99
|
this.focusCurrent = this.focusCurrent.bind(this);
|
|
110
100
|
this.getHotKeysParams = this.getHotKeysParams.bind(this);
|
|
111
101
|
}
|
|
112
|
-
|
|
113
102
|
getHotKeysParams() {
|
|
114
103
|
const item = this.currentFocusedItem;
|
|
115
|
-
const {
|
|
116
|
-
index
|
|
117
|
-
} = dsUtilities.get(item, ['dataset'], {});
|
|
104
|
+
const { index } = (0, import_ds_utilities.get)(item, ["dataset"], {});
|
|
118
105
|
return {
|
|
119
106
|
item,
|
|
120
107
|
index
|
|
121
108
|
};
|
|
122
109
|
}
|
|
123
|
-
|
|
124
110
|
activate() {
|
|
125
|
-
const {
|
|
126
|
-
|
|
127
|
-
} = this.options;
|
|
128
|
-
document.addEventListener('keydown', this.handleKeyDown, true);
|
|
111
|
+
const { getContainer } = this.options;
|
|
112
|
+
document.addEventListener("keydown", this.handleKeyDown, true);
|
|
129
113
|
registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);
|
|
130
114
|
}
|
|
131
|
-
|
|
132
115
|
deactivate() {
|
|
133
|
-
document.removeEventListener(
|
|
116
|
+
document.removeEventListener("keydown", this.handleKeyDown, true);
|
|
134
117
|
unregisterHotKeys(this.options.hotKeys);
|
|
135
118
|
}
|
|
136
|
-
|
|
137
119
|
handleKeyDown(e) {
|
|
138
|
-
if (!this.isGroupActive())
|
|
120
|
+
if (!this.isGroupActive())
|
|
121
|
+
return;
|
|
139
122
|
this.executeActionByEvent(e);
|
|
140
123
|
}
|
|
141
|
-
|
|
142
124
|
executeActionByEvent(e) {
|
|
143
125
|
const actions = Array.isArray(this.keyBindings[e.key]) ? this.keyBindings[e.key] : [this.keyBindings[e.key]];
|
|
144
|
-
return actions.map(action => typeof action ===
|
|
126
|
+
return actions.map((action) => typeof action === "string" ? safeCallAction(e, this.mapActions[action]) : safeCallAction(e, action));
|
|
145
127
|
}
|
|
146
|
-
|
|
147
|
-
|
|
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);
|
|
128
|
+
register(node, props = {}) {
|
|
129
|
+
const afterIndex = this.items.findIndex((item) => item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING);
|
|
150
130
|
node.specialOnFocus = props.onFocus || noop;
|
|
151
131
|
node.specialOnBlur = props.onBlur || noop;
|
|
152
|
-
|
|
153
132
|
node.onclick = () => this.focusItem(node);
|
|
154
|
-
|
|
155
133
|
node.onfocus = () => {
|
|
156
134
|
this.focusItem(node);
|
|
157
135
|
};
|
|
158
|
-
|
|
159
136
|
if (afterIndex === -1) {
|
|
160
137
|
this.items.push(node);
|
|
161
138
|
} else {
|
|
162
139
|
this.items.splice(afterIndex, 0, node);
|
|
163
140
|
}
|
|
164
141
|
}
|
|
165
|
-
|
|
166
142
|
unregister(node) {
|
|
167
143
|
const index = this.getItemIndexByNode(node);
|
|
168
|
-
if (index > -1)
|
|
144
|
+
if (index > -1)
|
|
145
|
+
this.items.splice(index, 1);
|
|
169
146
|
}
|
|
170
|
-
|
|
171
147
|
exit() {
|
|
172
|
-
const {
|
|
173
|
-
onExitFocusGroup
|
|
174
|
-
} = this.options;
|
|
148
|
+
const { onExitFocusGroup } = this.options;
|
|
175
149
|
onExitFocusGroup();
|
|
176
150
|
}
|
|
177
|
-
|
|
178
151
|
focusItem(node) {
|
|
179
152
|
if (this.currentFocusedItem && this.currentFocusedItem !== node) {
|
|
180
153
|
this.currentFocusedItem.specialOnBlur();
|
|
181
|
-
this.currentFocusedItem.setAttribute(
|
|
154
|
+
this.currentFocusedItem.setAttribute("tabindex", -1);
|
|
182
155
|
}
|
|
183
|
-
|
|
184
|
-
|
|
156
|
+
if (!node)
|
|
157
|
+
return;
|
|
185
158
|
this.currentFocusedItem = node;
|
|
186
|
-
node.setAttribute(
|
|
159
|
+
node.setAttribute("tabindex", 0);
|
|
187
160
|
node.focus();
|
|
188
161
|
node.specialOnFocus();
|
|
189
162
|
}
|
|
190
|
-
|
|
191
163
|
focusNext() {
|
|
192
164
|
const item = this.getNextItem();
|
|
193
165
|
this.focusItem(item);
|
|
194
166
|
}
|
|
195
|
-
|
|
196
167
|
focusByNode(node) {
|
|
197
168
|
const index = this.getItemIndexByNode(node);
|
|
198
169
|
this.focusByIndex(index);
|
|
199
170
|
}
|
|
200
|
-
|
|
201
171
|
focusByIndex(index) {
|
|
202
172
|
const item = this.getItemByIndex(index);
|
|
203
173
|
this.focusItem(item);
|
|
204
174
|
}
|
|
205
|
-
|
|
206
175
|
focusPrevious() {
|
|
207
176
|
const prevItem = this.getPreviousItem();
|
|
208
177
|
this.focusItem(prevItem);
|
|
209
178
|
}
|
|
210
|
-
|
|
211
179
|
focusFirst() {
|
|
212
180
|
const item = this.getFirstItem();
|
|
213
181
|
this.focusItem(item);
|
|
214
182
|
}
|
|
215
|
-
|
|
216
183
|
focusLast() {
|
|
217
184
|
const item = this.getLastItem();
|
|
218
185
|
this.focusItem(item);
|
|
219
186
|
}
|
|
220
|
-
|
|
221
187
|
focusCurrent() {
|
|
222
188
|
this.focusItem(this.currentFocusedItem);
|
|
223
189
|
}
|
|
224
|
-
|
|
225
190
|
focusNextGroup() {
|
|
226
|
-
const {
|
|
227
|
-
onFocusNextGroup
|
|
228
|
-
} = this.options;
|
|
191
|
+
const { onFocusNextGroup } = this.options;
|
|
229
192
|
this.exit();
|
|
230
193
|
onFocusNextGroup();
|
|
231
194
|
}
|
|
232
|
-
|
|
233
195
|
focusPreviousGroup() {
|
|
234
|
-
const {
|
|
235
|
-
onFocusPreviousGroup
|
|
236
|
-
} = this.options;
|
|
196
|
+
const { onFocusPreviousGroup } = this.options;
|
|
237
197
|
this.exit();
|
|
238
198
|
onFocusPreviousGroup();
|
|
239
199
|
}
|
|
240
|
-
|
|
241
200
|
getNextItem() {
|
|
242
|
-
const {
|
|
243
|
-
loop
|
|
244
|
-
} = this.options;
|
|
201
|
+
const { loop } = this.options;
|
|
245
202
|
const currentIndex = this.getFocusedIndex();
|
|
246
203
|
const supposedNextIndex = currentIndex + 1;
|
|
247
|
-
|
|
248
204
|
if (!this.checkCanFocusNext(supposedNextIndex)) {
|
|
249
205
|
return loop ? this.getFirstItem() : this.focusNextGroup();
|
|
250
206
|
}
|
|
251
|
-
|
|
252
207
|
return this.getItemByIndex(supposedNextIndex);
|
|
253
208
|
}
|
|
254
|
-
|
|
255
209
|
getPreviousItem() {
|
|
256
|
-
const {
|
|
257
|
-
loop
|
|
258
|
-
} = this.options;
|
|
210
|
+
const { loop } = this.options;
|
|
259
211
|
const currentIndex = this.getFocusedIndex();
|
|
260
212
|
const supposedPrevIndex = currentIndex - 1;
|
|
261
|
-
|
|
262
213
|
if (!this.checkCanFocusPrev(supposedPrevIndex)) {
|
|
263
214
|
return loop ? this.getLastItem() : this.focusPreviousGroup();
|
|
264
215
|
}
|
|
265
|
-
|
|
266
216
|
return this.getItemByIndex(supposedPrevIndex);
|
|
267
217
|
}
|
|
268
|
-
|
|
269
218
|
checkCanFocusNext(index) {
|
|
270
219
|
return this.items.length > index;
|
|
271
220
|
}
|
|
272
|
-
|
|
273
221
|
checkCanFocusPrev(index) {
|
|
274
222
|
return index >= 0;
|
|
275
223
|
}
|
|
276
|
-
|
|
277
224
|
getItemByIndex(index) {
|
|
278
225
|
return this.items[index];
|
|
279
226
|
}
|
|
280
|
-
|
|
281
227
|
getItemIndexByNode(node) {
|
|
282
|
-
return this.items.findIndex(item => item === node);
|
|
228
|
+
return this.items.findIndex((item) => item === node);
|
|
283
229
|
}
|
|
284
|
-
|
|
285
230
|
getFocusedIndex() {
|
|
286
231
|
return this.getItemIndexByNode(document.activeElement);
|
|
287
232
|
}
|
|
288
|
-
|
|
289
233
|
getFocusedItem() {
|
|
290
234
|
const index = this.getFocusedIndex();
|
|
291
235
|
return index > -1 && this.items[index];
|
|
292
236
|
}
|
|
293
|
-
|
|
294
237
|
isGroupActive() {
|
|
295
238
|
return this.getFocusedIndex() !== -1;
|
|
296
239
|
}
|
|
297
|
-
|
|
298
240
|
getFirstItem() {
|
|
299
241
|
return !!this.items.length && this.items[0];
|
|
300
242
|
}
|
|
301
|
-
|
|
302
243
|
getLastItem() {
|
|
303
244
|
return !!this.items.length && this.items[this.items.length - 1];
|
|
304
245
|
}
|
|
305
|
-
|
|
306
246
|
}
|
|
307
|
-
|
|
308
|
-
module.exports =
|
|
247
|
+
var FocusGroup_default = FocusGroup;
|
|
248
|
+
module.exports = __toCommonJS(FocusGroup_exports);
|
|
249
|
+
//# sourceMappingURL=FocusGroup.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/FocusGroup/FocusGroup.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-param-reassign */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\nimport { isFunction, get } from '@elliemae/ds-utilities';\nimport hotkeys from 'hotkeys-js';\n\nconst defaultOptions = {\n orientation: 'vertical',\n};\n\nconst safeCallAction = (e, fun, ...args) => {\n if (isFunction(fun)) {\n e.preventDefault();\n fun(...args);\n }\n};\n\nconst registerHotkeys = (\n hotKeys = {},\n params,\n getContainer = () => document,\n) => {\n Object.keys(hotKeys).forEach((hotkey) => {\n const { options, handler, allowDocumentHandler = false } = hotKeys[hotkey];\n const parameterizedHandler = (e) => {\n const handlerParams = isFunction(params) ? params() : params;\n if (\n !allowDocumentHandler &&\n handlerParams.item !== document.activeElement\n )\n return;\n e.preventDefault();\n handler(handlerParams);\n };\n hotkeys(\n hotkey,\n { element: getContainer(), ...options },\n parameterizedHandler,\n );\n });\n};\n\nconst unregisterHotKeys = (hotKeys = {}) => {\n Object.keys(hotKeys).forEach((hotkey) => {\n hotkeys.unbind(hotkey);\n });\n};\n\nconst noop = () => null;\n\nclass FocusGroup {\n items = [];\n\n constructor(options = {}) {\n this.options = { ...defaultOptions, ...options };\n\n const { orientation } = this.options;\n\n this.keyBindings = {\n ArrowUp: orientation !== 'horizontal' && 'previous',\n ArrowRight: orientation !== 'vertical' && 'next',\n ArrowDown: orientation !== 'horizontal' && 'next',\n ArrowLeft: orientation !== 'vertical' && 'previous',\n Home: 'first',\n End: 'last',\n PageUp: 'first',\n PageDown: 'last',\n Escape: 'exit',\n ...options.keyBindings,\n };\n\n this.currentFocusedItem = null;\n this.currIndex = null;\n\n this.mapActions = {\n previous: this.focusPrevious.bind(this),\n next: this.focusNext.bind(this),\n first: this.focusFirst.bind(this),\n last: this.focusLast.bind(this),\n exit: this.exit.bind(this),\n enter: () => null,\n };\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.register = this.register.bind(this);\n this.focusFirst = this.focusFirst.bind(this);\n this.focusLast = this.focusLast.bind(this);\n this.isGroupActive = this.isGroupActive.bind(this);\n this.focusNext = this.focusNext.bind(this);\n this.focusPrevious = this.focusPrevious.bind(this);\n this.focusItem = this.focusItem.bind(this);\n this.focusCurrent = this.focusCurrent.bind(this);\n this.getHotKeysParams = this.getHotKeysParams.bind(this);\n }\n\n getHotKeysParams() {\n const item = this.currentFocusedItem;\n const { index } = get(item, ['dataset'], {});\n return {\n item,\n index,\n };\n }\n\n activate() {\n const { getContainer } = this.options;\n document.addEventListener('keydown', this.handleKeyDown, true);\n registerHotkeys(this.options.hotKeys, this.getHotKeysParams, getContainer);\n }\n\n deactivate() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n unregisterHotKeys(this.options.hotKeys);\n }\n\n handleKeyDown(e) {\n if (!this.isGroupActive()) return;\n this.executeActionByEvent(e);\n }\n\n executeActionByEvent(e) {\n const actions = Array.isArray(this.keyBindings[e.key])\n ? this.keyBindings[e.key]\n : [this.keyBindings[e.key]];\n return actions.map((action) =>\n typeof action === 'string'\n ? safeCallAction(e, this.mapActions[action])\n : safeCallAction(e, action),\n );\n }\n\n register(node, props = {}) {\n const afterIndex = this.items.findIndex(\n (item) =>\n item.compareDocumentPosition(node) === Node.DOCUMENT_POSITION_PRECEDING,\n );\n node.specialOnFocus = props.onFocus || noop;\n node.specialOnBlur = props.onBlur || noop;\n node.onclick = () => this.focusItem(node);\n node.onfocus = () => {\n this.focusItem(node);\n };\n if (afterIndex === -1) {\n this.items.push(node);\n } else {\n this.items.splice(afterIndex, 0, node);\n }\n }\n\n unregister(node) {\n const index = this.getItemIndexByNode(node);\n if (index > -1) this.items.splice(index, 1);\n }\n\n exit() {\n const { onExitFocusGroup } = this.options;\n onExitFocusGroup();\n }\n\n focusItem(node) {\n if (this.currentFocusedItem && this.currentFocusedItem !== node) {\n this.currentFocusedItem.specialOnBlur();\n this.currentFocusedItem.setAttribute('tabindex', -1);\n }\n if (!node) return;\n this.currentFocusedItem = node;\n node.setAttribute('tabindex', 0);\n node.focus();\n node.specialOnFocus();\n }\n\n focusNext() {\n const item = this.getNextItem();\n this.focusItem(item);\n }\n\n focusByNode(node) {\n const index = this.getItemIndexByNode(node);\n this.focusByIndex(index);\n }\n\n focusByIndex(index) {\n const item = this.getItemByIndex(index);\n this.focusItem(item);\n }\n\n focusPrevious() {\n const prevItem = this.getPreviousItem();\n this.focusItem(prevItem);\n }\n\n focusFirst() {\n const item = this.getFirstItem();\n this.focusItem(item);\n }\n\n focusLast() {\n const item = this.getLastItem();\n this.focusItem(item);\n }\n\n focusCurrent() {\n this.focusItem(this.currentFocusedItem);\n }\n\n focusNextGroup() {\n const { onFocusNextGroup } = this.options;\n this.exit();\n onFocusNextGroup();\n }\n\n focusPreviousGroup() {\n const { onFocusPreviousGroup } = this.options;\n this.exit();\n onFocusPreviousGroup();\n }\n\n getNextItem() {\n const { loop } = this.options;\n const currentIndex = this.getFocusedIndex();\n const supposedNextIndex = currentIndex + 1;\n if (!this.checkCanFocusNext(supposedNextIndex)) {\n return loop ? this.getFirstItem() : this.focusNextGroup();\n }\n return this.getItemByIndex(supposedNextIndex);\n }\n\n getPreviousItem() {\n const { loop } = this.options;\n const currentIndex = this.getFocusedIndex();\n const supposedPrevIndex = currentIndex - 1;\n if (!this.checkCanFocusPrev(supposedPrevIndex)) {\n return loop ? this.getLastItem() : this.focusPreviousGroup();\n }\n return this.getItemByIndex(supposedPrevIndex);\n }\n\n checkCanFocusNext(index) {\n return this.items.length > index;\n }\n\n checkCanFocusPrev(index) {\n return index >= 0;\n }\n\n getItemByIndex(index) {\n return this.items[index];\n }\n\n getItemIndexByNode(node) {\n return this.items.findIndex((item) => item === node);\n }\n\n getFocusedIndex() {\n return this.getItemIndexByNode(document.activeElement);\n }\n\n getFocusedItem() {\n const index = this.getFocusedIndex();\n return index > -1 && this.items[index];\n }\n\n isGroupActive() {\n return this.getFocusedIndex() !== -1;\n }\n\n getFirstItem() {\n return !!this.items.length && this.items[0];\n }\n\n getLastItem() {\n return !!this.items.length && this.items[this.items.length - 1];\n }\n}\n\nexport { FocusGroup };\nexport default FocusGroup;", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,0BAAgC;AAChC,wBAAoB;AAEpB,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA;AAGf,MAAM,iBAAiB,CAAC,GAAG,QAAQ,SAAS;AAC1C,MAAI,oCAAW,MAAM;AACnB,MAAE;AACF,QAAI,GAAG;AAAA;AAAA;AAIX,MAAM,kBAAkB,CACtB,UAAU,IACV,QACA,eAAe,MAAM,aAClB;AACH,SAAO,KAAK,SAAS,QAAQ,CAAC,WAAW;AACvC,UAAM,EAAE,SAAS,SAAS,uBAAuB,UAAU,QAAQ;AACnE,UAAM,uBAAuB,CAAC,MAAM;AAClC,YAAM,gBAAgB,oCAAW,UAAU,WAAW;AACtD,UACE,CAAC,wBACD,cAAc,SAAS,SAAS;AAEhC;AACF,QAAE;AACF,cAAQ;AAAA;AAEV,mCACE,QACA,EAAE,SAAS,mBAAmB,WAC9B;AAAA;AAAA;AAKN,MAAM,oBAAoB,CAAC,UAAU,OAAO;AAC1C,SAAO,KAAK,SAAS,QAAQ,CAAC,WAAW;AACvC,8BAAQ,OAAO;AAAA;AAAA;AAInB,MAAM,OAAO,MAAM;AAEnB,iBAAiB;AAAA,EAGf,YAAY,UAAU,IAAI;AAF1B,iBA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M;AAAA;AAAA,EAGpB,mBAAmB,MAAM;AACvB,WAAO,KAAK,MAAM,UAAU,CAAC,SAAS,SAAS;AAAA;AAAA,EAGjD,kBAAkB;AAChB,WAAO,KAAK,mBAAmB,SAAS;AAAA;AAAA,EAG1C,iBAAiB;AACf,UAAM,QAAQ,KAAK;AACnB,WAAO,QAAQ,MAAM,KAAK,MAAM;AAAA;AAAA,EAGlC,gBAAgB;AACd,WAAO,KAAK,sBAAsB;AAAA;AAAA,EAGpC,eAAe;AACb,WAAO,CAAC,CAAC,KAAK,MAAM,UAAU,KAAK,MAAM;AAAA;AAAA,EAG3C,cAAc;AACZ,WAAO,CAAC,CAAC,KAAK,MAAM,UAAU,KAAK,MAAM,KAAK,MAAM,SAAS;AAAA;AAAA;AAKjE,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/FocusGroup/FocusGroupContext.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\n\nconst FocusGroupContext = React.createContext();\nexport { FocusGroupContext };\nexport default FocusGroupContext;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAElB,MAAM,oBAAoB,qBAAM;AAEhC,IAAO,4BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,22 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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 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");
|
|
13
39
|
const noop = () => null;
|
|
14
|
-
|
|
15
|
-
class FocusGroupProvider extends React.Component {
|
|
40
|
+
class FocusGroupProvider extends import_react.Component {
|
|
16
41
|
constructor(props) {
|
|
17
42
|
super(props);
|
|
18
43
|
this.activated = false;
|
|
19
|
-
this.focusGroup = new FocusGroup(props);
|
|
44
|
+
this.focusGroup = new import_FocusGroup.FocusGroup(props);
|
|
20
45
|
props.onFocusGroupSet(this);
|
|
21
46
|
this.actions = {
|
|
22
47
|
activate: this.activate.bind(this),
|
|
@@ -33,75 +58,58 @@ class FocusGroupProvider extends React.Component {
|
|
|
33
58
|
focusPrevious: this.focusGroup.focusPrevious
|
|
34
59
|
};
|
|
35
60
|
}
|
|
36
|
-
|
|
37
61
|
componentDidMount() {
|
|
38
|
-
const {
|
|
39
|
-
autoFocusOnMount
|
|
40
|
-
} = this.props;
|
|
62
|
+
const { autoFocusOnMount } = this.props;
|
|
41
63
|
this.activate();
|
|
42
|
-
|
|
43
64
|
if (autoFocusOnMount) {
|
|
44
65
|
setTimeout(() => {
|
|
45
66
|
this.actions.focusFirst();
|
|
46
67
|
}, 0);
|
|
47
68
|
}
|
|
48
69
|
}
|
|
49
|
-
|
|
50
70
|
componentWillUnmount() {
|
|
51
71
|
this.deactivate();
|
|
52
72
|
}
|
|
53
|
-
|
|
54
73
|
activate() {
|
|
55
|
-
const {
|
|
56
|
-
onActivate
|
|
57
|
-
} = this.props;
|
|
74
|
+
const { onActivate } = this.props;
|
|
58
75
|
this.focusGroup.activate();
|
|
59
76
|
this.activated = true;
|
|
60
|
-
if (
|
|
77
|
+
if ((0, import_ds_utilities.isFunction)(onActivate))
|
|
78
|
+
onActivate();
|
|
61
79
|
}
|
|
62
|
-
|
|
63
80
|
deactivate() {
|
|
64
|
-
const {
|
|
65
|
-
onExitFocusGroup
|
|
66
|
-
} = this.props;
|
|
81
|
+
const { onExitFocusGroup } = this.props;
|
|
67
82
|
this.activated = false;
|
|
68
83
|
this.focusGroup.deactivate();
|
|
69
|
-
|
|
70
|
-
if (dsUtilities.isFunction(onExitFocusGroup)) {
|
|
84
|
+
if ((0, import_ds_utilities.isFunction)(onExitFocusGroup)) {
|
|
71
85
|
onExitFocusGroup();
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
|
-
|
|
75
88
|
register(item) {
|
|
76
89
|
this.focusGroup.register(item);
|
|
77
90
|
}
|
|
78
|
-
|
|
79
91
|
unregister(item) {
|
|
80
92
|
this.focusGroup.unregister(item);
|
|
81
93
|
}
|
|
82
|
-
|
|
83
94
|
focusItemByIndex(index) {
|
|
84
|
-
if (!this.activated)
|
|
95
|
+
if (!this.activated)
|
|
96
|
+
this.activate();
|
|
85
97
|
setTimeout(() => {
|
|
86
98
|
this.focusGroup.focusByIndex(index);
|
|
87
99
|
}, 200);
|
|
88
100
|
}
|
|
89
|
-
|
|
90
101
|
focusItemByNode(node) {
|
|
91
|
-
if (!this.activated)
|
|
102
|
+
if (!this.activated)
|
|
103
|
+
this.activate();
|
|
92
104
|
const index = this.focusGroup.getItemIndexByNode(node);
|
|
93
105
|
this.focusItemByIndex(index);
|
|
94
106
|
}
|
|
95
|
-
|
|
96
107
|
render() {
|
|
97
|
-
const {
|
|
98
|
-
|
|
99
|
-
} = this.props;
|
|
100
|
-
return /*#__PURE__*/_jsx__default["default"](FocusGroupContext.Provider, {
|
|
108
|
+
const { children } = this.props;
|
|
109
|
+
return /* @__PURE__ */ import_react.default.createElement(import_FocusGroupContext.FocusGroupContext.Provider, {
|
|
101
110
|
value: this.actions
|
|
102
|
-
},
|
|
111
|
+
}, children);
|
|
103
112
|
}
|
|
104
|
-
|
|
105
113
|
}
|
|
106
114
|
FocusGroupProvider.defaultProps = {
|
|
107
115
|
exitWhenNoPrevious: false,
|
|
@@ -113,5 +121,6 @@ FocusGroupProvider.defaultProps = {
|
|
|
113
121
|
onFocusNextGroup: noop,
|
|
114
122
|
onFocusGroupSet: noop
|
|
115
123
|
};
|
|
116
|
-
|
|
117
|
-
module.exports =
|
|
124
|
+
var FocusGroupManager_default = FocusGroupProvider;
|
|
125
|
+
module.exports = __toCommonJS(FocusGroupManager_exports);
|
|
126
|
+
//# sourceMappingURL=FocusGroupManager.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/FocusGroup/FocusGroupManager.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { Component, useEffect } from 'react';\nimport { isFunction } from '@elliemae/ds-utilities';\nimport { FocusGroup } from './FocusGroup';\nimport { FocusGroupContext } from './FocusGroupContext';\n\nconst noop = () => null;\n\nclass FocusGroupProvider extends Component {\n activated = false;\n\n static defaultProps = {\n exitWhenNoPrevious: false,\n exitWhenNoNext: false,\n keyBindings: {},\n onFocus: noop,\n onExitFocusGroup: noop,\n onFocusPreviousGroup: noop,\n onFocusNextGroup: noop,\n onFocusGroupSet: noop,\n };\n\n constructor(props) {\n super(props);\n\n this.focusGroup = new FocusGroup(props);\n\n props.onFocusGroupSet(this);\n\n this.actions = {\n activate: this.activate.bind(this),\n deactivate: this.deactivate.bind(this),\n register: this.focusGroup.register,\n unregister: this.unregister.bind(this),\n focusFirst: this.focusGroup.focusFirst,\n focusLast: this.focusGroup.focusLast,\n focusItemByIndex: this.focusItemByIndex.bind(this),\n focusItemByNode: this.focusItemByNode.bind(this),\n focus: this.focusGroup.focusCurrent,\n isGroupActive: this.focusGroup.isGroupActive,\n focusNext: this.focusGroup.focusNext,\n focusPrevious: this.focusGroup.focusPrevious,\n };\n }\n\n componentDidMount() {\n const { autoFocusOnMount } = this.props;\n\n this.activate();\n\n if (autoFocusOnMount) {\n setTimeout(() => {\n this.actions.focusFirst();\n }, 0);\n }\n }\n\n componentWillUnmount() {\n this.deactivate();\n }\n\n activate() {\n const { onActivate } = this.props;\n this.focusGroup.activate();\n this.activated = true;\n if (isFunction(onActivate)) onActivate();\n }\n\n deactivate() {\n const { onExitFocusGroup } = this.props;\n this.activated = false;\n this.focusGroup.deactivate();\n if (isFunction(onExitFocusGroup)) {\n onExitFocusGroup();\n }\n }\n\n register(item) {\n this.focusGroup.register(item);\n }\n\n unregister(item) {\n this.focusGroup.unregister(item);\n }\n\n focusItemByIndex(index) {\n if (!this.activated) this.activate();\n setTimeout(() => {\n this.focusGroup.focusByIndex(index);\n }, 200);\n }\n\n focusItemByNode(node) {\n if (!this.activated) this.activate();\n const index = this.focusGroup.getItemIndexByNode(node);\n this.focusItemByIndex(index);\n }\n\n render() {\n const { children } = this.props;\n return (\n <FocusGroupContext.Provider value={this.actions}>\n {children}\n </FocusGroupContext.Provider>\n );\n }\n}\n\nexport { FocusGroupProvider, FocusGroupProvider as FocusGroupManager };\nexport default FocusGroupProvider;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4C;AAC5C,0BAA2B;AAC3B,wBAA2B;AAC3B,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