@telia-ace/widget-ui 1.0.0
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/LICENSE.txt +6 -0
- package/README.md +3 -0
- package/lib/components/anchor-link.d.ts +4 -0
- package/lib/components/anchor-link.js +7 -0
- package/lib/components/button.d.ts +4 -0
- package/lib/components/button.js +64 -0
- package/lib/components/checkbox.d.ts +7 -0
- package/lib/components/checkbox.js +39 -0
- package/lib/components/drawer/drawer.d.ts +21 -0
- package/lib/components/drawer/drawer.js +150 -0
- package/lib/components/drawer/index.d.ts +3 -0
- package/lib/components/drawer/index.js +29 -0
- package/lib/components/dropdown/dropdown.d.ts +9 -0
- package/lib/components/dropdown/dropdown.js +155 -0
- package/lib/components/dropdown/index.d.ts +4 -0
- package/lib/components/dropdown/index.js +10 -0
- package/lib/components/dropdown/use-position.d.ts +5 -0
- package/lib/components/dropdown/use-position.js +57 -0
- package/lib/components/empty.d.ts +4 -0
- package/lib/components/empty.js +40 -0
- package/lib/components/grid.d.ts +7 -0
- package/lib/components/grid.js +64 -0
- package/lib/components/html.d.ts +12 -0
- package/lib/components/html.js +78 -0
- package/lib/components/icon.d.ts +7 -0
- package/lib/components/icon.js +35 -0
- package/lib/components/index.d.ts +58 -0
- package/lib/components/index.js +69 -0
- package/lib/components/input.d.ts +10 -0
- package/lib/components/input.js +94 -0
- package/lib/components/item-list.d.ts +10 -0
- package/lib/components/item-list.js +62 -0
- package/lib/components/item-tree.d.ts +13 -0
- package/lib/components/item-tree.js +55 -0
- package/lib/components/lightbox.d.ts +6 -0
- package/lib/components/lightbox.js +92 -0
- package/lib/components/link.d.ts +11 -0
- package/lib/components/link.js +99 -0
- package/lib/components/list.d.ts +9 -0
- package/lib/components/list.js +56 -0
- package/lib/components/modal/confirm.d.ts +12 -0
- package/lib/components/modal/confirm.js +61 -0
- package/lib/components/modal/index.d.ts +4 -0
- package/lib/components/modal/index.js +10 -0
- package/lib/components/modal/modal.d.ts +10 -0
- package/lib/components/modal/modal.js +127 -0
- package/lib/components/not-found.d.ts +9 -0
- package/lib/components/not-found.js +55 -0
- package/lib/components/overlay.d.ts +8 -0
- package/lib/components/overlay.js +73 -0
- package/lib/components/paragraph.d.ts +11 -0
- package/lib/components/paragraph.js +66 -0
- package/lib/components/portal.d.ts +7 -0
- package/lib/components/portal.js +61 -0
- package/lib/components/route-link.d.ts +11 -0
- package/lib/components/route-link.js +115 -0
- package/lib/components/symbol-badge.d.ts +15 -0
- package/lib/components/symbol-badge.js +197 -0
- package/lib/components/tab-stop.d.ts +18 -0
- package/lib/components/tab-stop.js +100 -0
- package/lib/components/text-link.d.ts +8 -0
- package/lib/components/text-link.js +62 -0
- package/lib/components/text.d.ts +4 -0
- package/lib/components/text.js +35 -0
- package/lib/components/timestamp.d.ts +13 -0
- package/lib/components/timestamp.js +39 -0
- package/lib/components/tooltip.d.ts +8 -0
- package/lib/components/tooltip.js +127 -0
- package/lib/components/transition-component.d.ts +30 -0
- package/lib/components/transition-component.js +77 -0
- package/lib/components/typography.d.ts +9 -0
- package/lib/components/typography.js +43 -0
- package/lib/components/widget-link.d.ts +10 -0
- package/lib/components/widget-link.js +116 -0
- package/lib/contexts/index.d.ts +9 -0
- package/lib/contexts/index.js +15 -0
- package/lib/create-react-component.d.ts +11 -0
- package/lib/create-react-component.js +18 -0
- package/lib/hooks/index.d.ts +27 -0
- package/lib/hooks/index.js +58 -0
- package/lib/hooks/use-action.d.ts +4 -0
- package/lib/hooks/use-action.js +21 -0
- package/lib/hooks/use-children.d.ts +4 -0
- package/lib/hooks/use-children.js +70 -0
- package/lib/hooks/use-columns.d.ts +2 -0
- package/lib/hooks/use-columns.js +6 -0
- package/lib/hooks/use-component-descriptor.d.ts +2 -0
- package/lib/hooks/use-component-descriptor.js +6 -0
- package/lib/hooks/use-component-node.d.ts +6 -0
- package/lib/hooks/use-component-node.js +37 -0
- package/lib/hooks/use-component-platform.d.ts +4 -0
- package/lib/hooks/use-component-platform.js +39 -0
- package/lib/hooks/use-component.d.ts +3 -0
- package/lib/hooks/use-component.js +57 -0
- package/lib/hooks/use-container.d.ts +2 -0
- package/lib/hooks/use-container.js +6 -0
- package/lib/hooks/use-context.d.ts +3 -0
- package/lib/hooks/use-context.js +50 -0
- package/lib/hooks/use-dispatch.d.ts +3 -0
- package/lib/hooks/use-dispatch.js +64 -0
- package/lib/hooks/use-event-listener.d.ts +2 -0
- package/lib/hooks/use-event-listener.js +21 -0
- package/lib/hooks/use-events.d.ts +3 -0
- package/lib/hooks/use-events.js +12 -0
- package/lib/hooks/use-is-mounted.d.ts +3 -0
- package/lib/hooks/use-is-mounted.js +14 -0
- package/lib/hooks/use-key-press.d.ts +2 -0
- package/lib/hooks/use-key-press.js +46 -0
- package/lib/hooks/use-layout.d.ts +3 -0
- package/lib/hooks/use-layout.js +50 -0
- package/lib/hooks/use-previous.d.ts +2 -0
- package/lib/hooks/use-previous.js +11 -0
- package/lib/hooks/use-properties.d.ts +6 -0
- package/lib/hooks/use-properties.js +9 -0
- package/lib/hooks/use-render-state.d.ts +4 -0
- package/lib/hooks/use-render-state.js +66 -0
- package/lib/hooks/use-route-data.d.ts +4 -0
- package/lib/hooks/use-route-data.js +54 -0
- package/lib/hooks/use-router.d.ts +3 -0
- package/lib/hooks/use-router.js +9 -0
- package/lib/hooks/use-scroll.d.ts +2 -0
- package/lib/hooks/use-scroll.js +71 -0
- package/lib/hooks/use-settings.d.ts +3 -0
- package/lib/hooks/use-settings.js +38 -0
- package/lib/hooks/use-toggle.d.ts +2 -0
- package/lib/hooks/use-toggle.js +28 -0
- package/lib/hooks/use-transition-end.d.ts +2 -0
- package/lib/hooks/use-transition-end.js +62 -0
- package/lib/hooks/use-unique-menu.d.ts +2 -0
- package/lib/hooks/use-unique-menu.js +15 -0
- package/lib/hooks/use-widget-event.d.ts +3 -0
- package/lib/hooks/use-widget-event.js +21 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +92 -0
- package/lib/styles.d.ts +19 -0
- package/lib/styles.js +53 -0
- package/lib/utils/animations.d.ts +18 -0
- package/lib/utils/animations.js +104 -0
- package/lib/utils/browser.d.ts +12 -0
- package/lib/utils/browser.js +54 -0
- package/lib/utils/convert-to-string-attributes.d.ts +2 -0
- package/lib/utils/convert-to-string-attributes.js +23 -0
- package/lib/utils/create-empty-component.d.ts +4 -0
- package/lib/utils/create-empty-component.js +25 -0
- package/lib/utils/embedded-link-mapper.d.ts +4 -0
- package/lib/utils/embedded-link-mapper.js +62 -0
- package/lib/utils/filter-css-props.d.ts +8 -0
- package/lib/utils/filter-css-props.js +28 -0
- package/lib/utils/generic-hash-link.d.ts +8 -0
- package/lib/utils/generic-hash-link.js +70 -0
- package/lib/utils/heading-styles.d.ts +1 -0
- package/lib/utils/heading-styles.js +48 -0
- package/lib/utils/index.d.ts +12 -0
- package/lib/utils/index.js +28 -0
- package/lib/utils/process-html-string.d.ts +4 -0
- package/lib/utils/process-html-string.js +16 -0
- package/lib/utils/render-instructions.d.ts +8 -0
- package/lib/utils/render-instructions.js +19 -0
- package/lib-esm/components/anchor-link.d.ts +4 -0
- package/lib-esm/components/anchor-link.js +5 -0
- package/lib-esm/components/button.d.ts +4 -0
- package/lib-esm/components/button.js +36 -0
- package/lib-esm/components/checkbox.d.ts +7 -0
- package/lib-esm/components/checkbox.js +34 -0
- package/lib-esm/components/drawer/drawer.d.ts +21 -0
- package/lib-esm/components/drawer/drawer.js +121 -0
- package/lib-esm/components/drawer/index.d.ts +3 -0
- package/lib-esm/components/drawer/index.js +3 -0
- package/lib-esm/components/dropdown/dropdown.d.ts +9 -0
- package/lib-esm/components/dropdown/dropdown.js +127 -0
- package/lib-esm/components/dropdown/index.d.ts +4 -0
- package/lib-esm/components/dropdown/index.js +3 -0
- package/lib-esm/components/dropdown/use-position.d.ts +5 -0
- package/lib-esm/components/dropdown/use-position.js +53 -0
- package/lib-esm/components/empty.d.ts +4 -0
- package/lib-esm/components/empty.js +35 -0
- package/lib-esm/components/grid.d.ts +7 -0
- package/lib-esm/components/grid.js +36 -0
- package/lib-esm/components/html.d.ts +12 -0
- package/lib-esm/components/html.js +53 -0
- package/lib-esm/components/icon.d.ts +7 -0
- package/lib-esm/components/icon.js +30 -0
- package/lib-esm/components/index.d.ts +58 -0
- package/lib-esm/components/index.js +30 -0
- package/lib-esm/components/input.d.ts +10 -0
- package/lib-esm/components/input.js +69 -0
- package/lib-esm/components/item-list.d.ts +10 -0
- package/lib-esm/components/item-list.js +34 -0
- package/lib-esm/components/item-tree.d.ts +13 -0
- package/lib-esm/components/item-tree.js +50 -0
- package/lib-esm/components/lightbox.d.ts +6 -0
- package/lib-esm/components/lightbox.js +64 -0
- package/lib-esm/components/link.d.ts +11 -0
- package/lib-esm/components/link.js +71 -0
- package/lib-esm/components/list.d.ts +9 -0
- package/lib-esm/components/list.js +31 -0
- package/lib-esm/components/modal/confirm.d.ts +12 -0
- package/lib-esm/components/modal/confirm.js +33 -0
- package/lib-esm/components/modal/index.d.ts +4 -0
- package/lib-esm/components/modal/index.js +3 -0
- package/lib-esm/components/modal/modal.d.ts +10 -0
- package/lib-esm/components/modal/modal.js +99 -0
- package/lib-esm/components/not-found.d.ts +9 -0
- package/lib-esm/components/not-found.js +27 -0
- package/lib-esm/components/overlay.d.ts +8 -0
- package/lib-esm/components/overlay.js +45 -0
- package/lib-esm/components/paragraph.d.ts +11 -0
- package/lib-esm/components/paragraph.js +38 -0
- package/lib-esm/components/portal.d.ts +7 -0
- package/lib-esm/components/portal.js +36 -0
- package/lib-esm/components/route-link.d.ts +11 -0
- package/lib-esm/components/route-link.js +90 -0
- package/lib-esm/components/symbol-badge.d.ts +15 -0
- package/lib-esm/components/symbol-badge.js +192 -0
- package/lib-esm/components/tab-stop.d.ts +18 -0
- package/lib-esm/components/tab-stop.js +75 -0
- package/lib-esm/components/text-link.d.ts +8 -0
- package/lib-esm/components/text-link.js +34 -0
- package/lib-esm/components/text.d.ts +4 -0
- package/lib-esm/components/text.js +30 -0
- package/lib-esm/components/timestamp.d.ts +13 -0
- package/lib-esm/components/timestamp.js +33 -0
- package/lib-esm/components/tooltip.d.ts +8 -0
- package/lib-esm/components/tooltip.js +99 -0
- package/lib-esm/components/transition-component.d.ts +30 -0
- package/lib-esm/components/transition-component.js +72 -0
- package/lib-esm/components/typography.d.ts +9 -0
- package/lib-esm/components/typography.js +38 -0
- package/lib-esm/components/widget-link.d.ts +10 -0
- package/lib-esm/components/widget-link.js +88 -0
- package/lib-esm/contexts/index.d.ts +9 -0
- package/lib-esm/contexts/index.js +12 -0
- package/lib-esm/create-react-component.d.ts +11 -0
- package/lib-esm/create-react-component.js +16 -0
- package/lib-esm/hooks/index.d.ts +27 -0
- package/lib-esm/hooks/index.js +26 -0
- package/lib-esm/hooks/use-action.d.ts +4 -0
- package/lib-esm/hooks/use-action.js +14 -0
- package/lib-esm/hooks/use-children.d.ts +4 -0
- package/lib-esm/hooks/use-children.js +65 -0
- package/lib-esm/hooks/use-columns.d.ts +2 -0
- package/lib-esm/hooks/use-columns.js +4 -0
- package/lib-esm/hooks/use-component-descriptor.d.ts +2 -0
- package/lib-esm/hooks/use-component-descriptor.js +4 -0
- package/lib-esm/hooks/use-component-node.d.ts +6 -0
- package/lib-esm/hooks/use-component-node.js +35 -0
- package/lib-esm/hooks/use-component-platform.d.ts +4 -0
- package/lib-esm/hooks/use-component-platform.js +34 -0
- package/lib-esm/hooks/use-component.d.ts +3 -0
- package/lib-esm/hooks/use-component.js +52 -0
- package/lib-esm/hooks/use-container.d.ts +2 -0
- package/lib-esm/hooks/use-container.js +4 -0
- package/lib-esm/hooks/use-context.d.ts +3 -0
- package/lib-esm/hooks/use-context.js +45 -0
- package/lib-esm/hooks/use-dispatch.d.ts +3 -0
- package/lib-esm/hooks/use-dispatch.js +59 -0
- package/lib-esm/hooks/use-event-listener.d.ts +2 -0
- package/lib-esm/hooks/use-event-listener.js +19 -0
- package/lib-esm/hooks/use-events.d.ts +3 -0
- package/lib-esm/hooks/use-events.js +7 -0
- package/lib-esm/hooks/use-is-mounted.d.ts +3 -0
- package/lib-esm/hooks/use-is-mounted.js +12 -0
- package/lib-esm/hooks/use-key-press.d.ts +2 -0
- package/lib-esm/hooks/use-key-press.js +41 -0
- package/lib-esm/hooks/use-layout.d.ts +3 -0
- package/lib-esm/hooks/use-layout.js +45 -0
- package/lib-esm/hooks/use-previous.d.ts +2 -0
- package/lib-esm/hooks/use-previous.js +9 -0
- package/lib-esm/hooks/use-properties.d.ts +6 -0
- package/lib-esm/hooks/use-properties.js +7 -0
- package/lib-esm/hooks/use-render-state.d.ts +4 -0
- package/lib-esm/hooks/use-render-state.js +61 -0
- package/lib-esm/hooks/use-route-data.d.ts +4 -0
- package/lib-esm/hooks/use-route-data.js +49 -0
- package/lib-esm/hooks/use-router.d.ts +3 -0
- package/lib-esm/hooks/use-router.js +7 -0
- package/lib-esm/hooks/use-scroll.d.ts +2 -0
- package/lib-esm/hooks/use-scroll.js +66 -0
- package/lib-esm/hooks/use-settings.d.ts +3 -0
- package/lib-esm/hooks/use-settings.js +33 -0
- package/lib-esm/hooks/use-toggle.d.ts +2 -0
- package/lib-esm/hooks/use-toggle.js +26 -0
- package/lib-esm/hooks/use-transition-end.d.ts +2 -0
- package/lib-esm/hooks/use-transition-end.js +60 -0
- package/lib-esm/hooks/use-unique-menu.d.ts +2 -0
- package/lib-esm/hooks/use-unique-menu.js +10 -0
- package/lib-esm/hooks/use-widget-event.d.ts +3 -0
- package/lib-esm/hooks/use-widget-event.js +16 -0
- package/lib-esm/index.d.ts +9 -0
- package/lib-esm/index.js +7 -0
- package/lib-esm/styles.d.ts +19 -0
- package/lib-esm/styles.js +26 -0
- package/lib-esm/utils/animations.d.ts +18 -0
- package/lib-esm/utils/animations.js +101 -0
- package/lib-esm/utils/browser.d.ts +12 -0
- package/lib-esm/utils/browser.js +51 -0
- package/lib-esm/utils/convert-to-string-attributes.d.ts +2 -0
- package/lib-esm/utils/convert-to-string-attributes.js +21 -0
- package/lib-esm/utils/create-empty-component.d.ts +4 -0
- package/lib-esm/utils/create-empty-component.js +20 -0
- package/lib-esm/utils/embedded-link-mapper.d.ts +4 -0
- package/lib-esm/utils/embedded-link-mapper.js +57 -0
- package/lib-esm/utils/filter-css-props.d.ts +8 -0
- package/lib-esm/utils/filter-css-props.js +25 -0
- package/lib-esm/utils/generic-hash-link.d.ts +8 -0
- package/lib-esm/utils/generic-hash-link.js +63 -0
- package/lib-esm/utils/heading-styles.d.ts +1 -0
- package/lib-esm/utils/heading-styles.js +44 -0
- package/lib-esm/utils/index.d.ts +12 -0
- package/lib-esm/utils/index.js +10 -0
- package/lib-esm/utils/process-html-string.d.ts +4 -0
- package/lib-esm/utils/process-html-string.js +10 -0
- package/lib-esm/utils/render-instructions.d.ts +8 -0
- package/lib-esm/utils/render-instructions.js +12 -0
- package/package.json +47 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var widget_core_1 = require("@telia-ace/widget-core");
|
|
23
|
+
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
24
|
+
var react_1 = require("react");
|
|
25
|
+
var use_component_descriptor_1 = __importDefault(require("./use-component-descriptor"));
|
|
26
|
+
var use_component_platform_1 = __importDefault(require("./use-component-platform"));
|
|
27
|
+
var useDispatch = function () {
|
|
28
|
+
var components = (0, use_component_platform_1.default)();
|
|
29
|
+
var descriptor = (0, use_component_descriptor_1.default)();
|
|
30
|
+
var _a = __read((0, react_1.useState)([]), 2), queue = _a[0], setQueue = _a[1];
|
|
31
|
+
var _b = __read((0, react_1.useState)(), 2), actions = _b[0], setActions = _b[1];
|
|
32
|
+
(0, react_1.useEffect)(function () {
|
|
33
|
+
if (components && descriptor) {
|
|
34
|
+
var component = new widget_core_1.ComponentQuery(components).withId(descriptor.id);
|
|
35
|
+
var actions_1 = components.actions(component, descriptor.type || (0, widget_utilities_1.uuid)());
|
|
36
|
+
setActions(actions_1);
|
|
37
|
+
// process the queue and set it to null
|
|
38
|
+
if (queue !== null) {
|
|
39
|
+
queue.forEach(function (item) {
|
|
40
|
+
actions_1
|
|
41
|
+
.dispatch(item.key, item.data)
|
|
42
|
+
.then(function (value) { return item.resolve(value); })
|
|
43
|
+
.catch(function (reason) { return item.reject(reason); });
|
|
44
|
+
});
|
|
45
|
+
setQueue(null);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [components, descriptor.id]);
|
|
49
|
+
return function (key, data) {
|
|
50
|
+
if (queue !== null) {
|
|
51
|
+
// if queue is available the actions controller is not yet created
|
|
52
|
+
return new Promise(function (resolve, reject) {
|
|
53
|
+
queue.push({
|
|
54
|
+
key: key,
|
|
55
|
+
data: data,
|
|
56
|
+
resolve: resolve,
|
|
57
|
+
reject: reject,
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return actions.dispatch(key, data);
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.default = useDispatch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
exports.default = (function (eventName, handler, element, condition) {
|
|
5
|
+
if (element === void 0) { element = window; }
|
|
6
|
+
if (condition === void 0) { condition = function () { return true; }; }
|
|
7
|
+
var savedHandler = (0, react_1.useRef)(function () { });
|
|
8
|
+
(0, react_1.useEffect)(function () {
|
|
9
|
+
savedHandler.current = handler;
|
|
10
|
+
}, [handler]);
|
|
11
|
+
(0, react_1.useEffect)(function () {
|
|
12
|
+
var isSupported = element && condition();
|
|
13
|
+
if (!isSupported)
|
|
14
|
+
return;
|
|
15
|
+
var eventListener = function (event) { return savedHandler.current(event); };
|
|
16
|
+
element.addEventListener(eventName, eventListener);
|
|
17
|
+
return function () {
|
|
18
|
+
element.removeEventListener(eventName, eventListener);
|
|
19
|
+
};
|
|
20
|
+
}, [eventName, element]);
|
|
21
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var use_container_1 = __importDefault(require("./use-container"));
|
|
7
|
+
var useEvents = function (passedContainer) {
|
|
8
|
+
var container = (0, use_container_1.default)();
|
|
9
|
+
var events = (passedContainer || container).get('$widget').events;
|
|
10
|
+
return events;
|
|
11
|
+
};
|
|
12
|
+
exports.default = useEvents;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
var useIsMounted = function () {
|
|
5
|
+
var isMounted = (0, react_1.useRef)(false);
|
|
6
|
+
(0, react_1.useEffect)(function () {
|
|
7
|
+
isMounted.current = true;
|
|
8
|
+
return function () {
|
|
9
|
+
isMounted.current = false;
|
|
10
|
+
};
|
|
11
|
+
}, []);
|
|
12
|
+
return isMounted;
|
|
13
|
+
};
|
|
14
|
+
exports.default = useIsMounted;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var react_1 = require("react");
|
|
23
|
+
var use_event_listener_1 = __importDefault(require("./use-event-listener"));
|
|
24
|
+
var useKeyPress = function (targetKey, action) {
|
|
25
|
+
// State for keeping track of whether key is pressed
|
|
26
|
+
var _a = __read((0, react_1.useState)(false), 2), keyPressed = _a[0], setKeyPressed = _a[1];
|
|
27
|
+
var onKeyDown = (0, react_1.useCallback)(function (event) {
|
|
28
|
+
var key = event.key;
|
|
29
|
+
if (key === targetKey) {
|
|
30
|
+
setKeyPressed(true);
|
|
31
|
+
if (action) {
|
|
32
|
+
action(event);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}, [setKeyPressed, action]);
|
|
36
|
+
var onKeyUp = (0, react_1.useCallback)(function (_a) {
|
|
37
|
+
var key = _a.key;
|
|
38
|
+
if (key === targetKey) {
|
|
39
|
+
setKeyPressed(false);
|
|
40
|
+
}
|
|
41
|
+
}, [setKeyPressed]);
|
|
42
|
+
(0, use_event_listener_1.default)('keydown', onKeyDown, window);
|
|
43
|
+
(0, use_event_listener_1.default)('keyup', onKeyUp, window);
|
|
44
|
+
return keyPressed;
|
|
45
|
+
};
|
|
46
|
+
exports.default = useKeyPress;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var react_1 = require("react");
|
|
23
|
+
var use_component_node_1 = __importDefault(require("./use-component-node"));
|
|
24
|
+
var use_component_platform_1 = __importDefault(require("./use-component-platform"));
|
|
25
|
+
var use_is_mounted_1 = __importDefault(require("./use-is-mounted"));
|
|
26
|
+
var useLayout = function (id) {
|
|
27
|
+
var node = (0, use_component_node_1.default)(id);
|
|
28
|
+
var components = (0, use_component_platform_1.default)();
|
|
29
|
+
var _a = __read((0, react_1.useState)({}), 2), layout = _a[0], setLayout = _a[1];
|
|
30
|
+
var isMounted = (0, use_is_mounted_1.default)();
|
|
31
|
+
(0, react_1.useEffect)(function () {
|
|
32
|
+
if (node && isMounted.current) {
|
|
33
|
+
setLayout(node.attributes.layout);
|
|
34
|
+
}
|
|
35
|
+
}, [node, isMounted]);
|
|
36
|
+
(0, react_1.useEffect)(function () {
|
|
37
|
+
if (components) {
|
|
38
|
+
var unsubscribe_1 = components.events.subscribe('components:layout-changed', function (event, data) {
|
|
39
|
+
if (node === data.node && isMounted.current) {
|
|
40
|
+
setLayout(data.node.attributes.layout);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return function () {
|
|
44
|
+
unsubscribe_1();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}, [components, isMounted]);
|
|
48
|
+
return layout;
|
|
49
|
+
};
|
|
50
|
+
exports.default = useLayout;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
var usePrevious = function (value) {
|
|
5
|
+
var ref = (0, react_1.useRef)();
|
|
6
|
+
(0, react_1.useEffect)(function () {
|
|
7
|
+
ref.current = value;
|
|
8
|
+
});
|
|
9
|
+
return ref.current;
|
|
10
|
+
};
|
|
11
|
+
exports.default = usePrevious;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
var contexts_1 = require("../contexts");
|
|
5
|
+
var useProperties = function () {
|
|
6
|
+
var properties = (0, react_1.useContext)(contexts_1.ComponentPropertyContext);
|
|
7
|
+
return properties;
|
|
8
|
+
};
|
|
9
|
+
exports.default = useProperties;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var widget_core_1 = require("@telia-ace/widget-core");
|
|
23
|
+
var react_1 = require("react");
|
|
24
|
+
var use_container_1 = __importDefault(require("./use-container"));
|
|
25
|
+
var use_is_mounted_1 = __importDefault(require("./use-is-mounted"));
|
|
26
|
+
var useRenderState = function (passedContainer) {
|
|
27
|
+
var _a = __read((0, react_1.useState)(), 2), renderState = _a[0], setRenderState = _a[1];
|
|
28
|
+
var container = (0, use_container_1.default)();
|
|
29
|
+
var isMounted = (0, use_is_mounted_1.default)();
|
|
30
|
+
(0, react_1.useEffect)(function () {
|
|
31
|
+
var unsubscribe;
|
|
32
|
+
var _a = (passedContainer || container).get('$widget'), name = _a.name, invoke = _a.invoke;
|
|
33
|
+
invoke('renderState').then(function (renderState) {
|
|
34
|
+
if (isMounted.current) {
|
|
35
|
+
setRenderState(renderState);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
(passedContainer || container)
|
|
39
|
+
.getAsync('actionResolver')
|
|
40
|
+
.then(function (actionResolver) {
|
|
41
|
+
unsubscribe = actionResolver.subscribe(name, function (origin, action) {
|
|
42
|
+
switch (action) {
|
|
43
|
+
case 'close':
|
|
44
|
+
case 'open':
|
|
45
|
+
if (isMounted.current) {
|
|
46
|
+
setRenderState(action === 'open'
|
|
47
|
+
? widget_core_1.WidgetRenderState.open
|
|
48
|
+
: widget_core_1.WidgetRenderState.closed);
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case 'hide':
|
|
52
|
+
if (isMounted.current) {
|
|
53
|
+
setRenderState(widget_core_1.WidgetRenderState.hidden);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return function () {
|
|
59
|
+
if (unsubscribe) {
|
|
60
|
+
unsubscribe();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}, [isMounted]);
|
|
64
|
+
return renderState;
|
|
65
|
+
};
|
|
66
|
+
exports.default = useRenderState;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
23
|
+
var react_1 = require("react");
|
|
24
|
+
var use_container_1 = __importDefault(require("./use-container"));
|
|
25
|
+
var use_is_mounted_1 = __importDefault(require("./use-is-mounted"));
|
|
26
|
+
var use_router_1 = __importDefault(require("./use-router"));
|
|
27
|
+
var useRouteData = function (passedContainer) {
|
|
28
|
+
var container = (0, use_container_1.default)();
|
|
29
|
+
var router = (0, use_router_1.default)();
|
|
30
|
+
var _a = __read((0, react_1.useState)({ name: '', params: {} }), 2), routeData = _a[0], setRouteData = _a[1];
|
|
31
|
+
var isMounted = (0, use_is_mounted_1.default)();
|
|
32
|
+
(0, react_1.useEffect)(function () {
|
|
33
|
+
var events = (passedContainer || container).get('$widget').events;
|
|
34
|
+
var unsubscribe = events.subscribe('router:change', function (e, _a) {
|
|
35
|
+
var routeData = _a.next.routeData;
|
|
36
|
+
if (isMounted.current) {
|
|
37
|
+
var name_1 = routeData.name, params = routeData.params;
|
|
38
|
+
(0, widget_utilities_1.removeNullAndUndefinedValues)(params);
|
|
39
|
+
setRouteData({ name: name_1, params: params });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return unsubscribe;
|
|
43
|
+
}, [isMounted]);
|
|
44
|
+
(0, react_1.useEffect)(function () {
|
|
45
|
+
if (router && router.history && isMounted.current) {
|
|
46
|
+
var routeData_1 = router.getRouteData();
|
|
47
|
+
var name_2 = routeData_1.name, params = routeData_1.params;
|
|
48
|
+
(0, widget_utilities_1.removeNullAndUndefinedValues)(params);
|
|
49
|
+
setRouteData({ name: name_2, params: params });
|
|
50
|
+
}
|
|
51
|
+
}, [router, isMounted]);
|
|
52
|
+
return routeData;
|
|
53
|
+
};
|
|
54
|
+
exports.default = useRouteData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
var contexts_1 = require("../contexts");
|
|
5
|
+
var useRouter = function () {
|
|
6
|
+
var router = (0, react_1.useContext)(contexts_1.RoutingContext);
|
|
7
|
+
return router;
|
|
8
|
+
};
|
|
9
|
+
exports.default = useRouter;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = require("react");
|
|
7
|
+
var utils_1 = require("../utils");
|
|
8
|
+
var use_event_listener_1 = __importDefault(require("./use-event-listener"));
|
|
9
|
+
exports.default = (function (scrollable) {
|
|
10
|
+
var elem = (0, react_1.useRef)();
|
|
11
|
+
var previousY = (0, react_1.useRef)(0);
|
|
12
|
+
var timeoutId;
|
|
13
|
+
var onScroll = (0, react_1.useCallback)(function () {
|
|
14
|
+
var _a;
|
|
15
|
+
(_a = elem.current) === null || _a === void 0 ? void 0 : _a.classList.add('humany-scrolling');
|
|
16
|
+
clearTimeout(timeoutId);
|
|
17
|
+
timeoutId = setTimeout(function () {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = elem.current) === null || _a === void 0 ? void 0 : _a.classList.remove('humany-scrolling');
|
|
20
|
+
}, 500);
|
|
21
|
+
}, [elem]);
|
|
22
|
+
var onTouchStart = (0, react_1.useCallback)(function (event) {
|
|
23
|
+
previousY.current = event.touches[0].clientY;
|
|
24
|
+
}, [elem]);
|
|
25
|
+
var traverseScrollable = function (element) {
|
|
26
|
+
if (isScrollable(element)) {
|
|
27
|
+
if (element === elem.current) {
|
|
28
|
+
return element;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (element.parentElement) {
|
|
33
|
+
return traverseScrollable(element.parentElement);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
var isScrollable = function (element) {
|
|
38
|
+
return (element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight);
|
|
39
|
+
};
|
|
40
|
+
var onTouchMove = (0, react_1.useCallback)(function (event) {
|
|
41
|
+
if (!event.cancelable) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
var top = event.touches[0].clientY;
|
|
45
|
+
var firstScrollable = traverseScrollable(event.target);
|
|
46
|
+
if (!firstScrollable) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var scrollTop = firstScrollable.scrollTop;
|
|
50
|
+
var direction = previousY.current - top < 0 ? 'up' : 'down';
|
|
51
|
+
var isAtTop = scrollTop <= 0 && direction === 'up';
|
|
52
|
+
var isAtBottom = scrollTop >= firstScrollable.scrollHeight - firstScrollable.offsetHeight &&
|
|
53
|
+
direction === 'down';
|
|
54
|
+
if (isAtTop || isAtBottom) {
|
|
55
|
+
// Don't scroll up if already at top,
|
|
56
|
+
// and don't scroll down if bottom has been reached
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
previousY.current = top;
|
|
60
|
+
}, [elem, previousY]);
|
|
61
|
+
(0, use_event_listener_1.default)('scroll', onScroll, elem.current, function () { return elem.current && scrollable; });
|
|
62
|
+
// This will prevent scrolling causing browser
|
|
63
|
+
// to freeze on Safari / Chrome on iOS
|
|
64
|
+
(0, use_event_listener_1.default)('touchstart', onTouchStart, elem.current, function () { return elem.current && scrollable; });
|
|
65
|
+
(0, use_event_listener_1.default)('touchmove', onTouchMove, elem.current, function () { return elem.current && scrollable; });
|
|
66
|
+
if (!scrollable) {
|
|
67
|
+
return ['', elem];
|
|
68
|
+
}
|
|
69
|
+
return [styling, elem];
|
|
70
|
+
});
|
|
71
|
+
var styling = "\n overflow-y: ".concat((0, utils_1.browser)() === utils_1.Browsers.Chrome || (0, utils_1.browser)() === utils_1.Browsers.EdgeChromium ? 'overlay' : 'auto', ";\n overflow-x: hidden;\n -ms-overflow-style: none; /* IE 10+ */\n scrollbar-width: thin; /* Firefox */\n scrollbar-color: transparent transparent; /* Firefox */\n\n ::-webkit-scrollbar {\n width: 3px !important;\n background-color: transparent;\n border-left: none;\n }\n ::-webkit-scrollbar-thumb {\n background-color: transparent;\n }\n ::-webkit-scrollbar-track {\n -webkit-box-shadow: none !important;\n background-color: transparent;\n }\n &.humany-scrolling {\n scrollbar-color: #7F7F7F transparent;\n scrollbar-width: thin; /* Firefox */\n -ms-overflow-style: none; /* IE 10+ */\n\n ::-webkit-scrollbar-thumb {\n background-color: #7F7F7F;\n }\n }\n");
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var react_1 = require("react");
|
|
23
|
+
var use_container_1 = __importDefault(require("./use-container"));
|
|
24
|
+
var use_is_mounted_1 = __importDefault(require("./use-is-mounted"));
|
|
25
|
+
var useSettings = function () {
|
|
26
|
+
var _a = __read((0, react_1.useState)(null), 2), settings = _a[0], setSettings = _a[1];
|
|
27
|
+
var container = (0, use_container_1.default)();
|
|
28
|
+
var isMounted = (0, use_is_mounted_1.default)();
|
|
29
|
+
(0, react_1.useEffect)(function () {
|
|
30
|
+
container.get('settings').then(function (settings) {
|
|
31
|
+
if (isMounted.current) {
|
|
32
|
+
setSettings(settings);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}, [isMounted]);
|
|
36
|
+
return settings;
|
|
37
|
+
};
|
|
38
|
+
exports.default = useSettings;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var react_1 = require("react");
|
|
20
|
+
var useToggle = function (initialValue) {
|
|
21
|
+
if (initialValue === void 0) { initialValue = false; }
|
|
22
|
+
var _a = __read((0, react_1.useState)(initialValue), 2), value = _a[0], setValue = _a[1];
|
|
23
|
+
var toggle = (0, react_1.useCallback)(function (forced) {
|
|
24
|
+
setValue(typeof forced === 'boolean' ? forced : function (v) { return !v; });
|
|
25
|
+
}, []);
|
|
26
|
+
return [value, toggle];
|
|
27
|
+
};
|
|
28
|
+
exports.default = useToggle;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var react_1 = require("react");
|
|
20
|
+
var _1 = require(".");
|
|
21
|
+
exports.default = (function (handler) {
|
|
22
|
+
var container = (0, _1.useContainer)();
|
|
23
|
+
var components = (0, _1.useComponentPlatform)();
|
|
24
|
+
var widgetDOMElement = container.get('widgetDOMElement');
|
|
25
|
+
var _a = __read((0, react_1.useState)(null), 2), viewDOMElement = _a[0], setViewDOMElement = _a[1];
|
|
26
|
+
var _b = __read((0, react_1.useState)(null), 2), rootDOMElement = _b[0], setRootDOMElement = _b[1];
|
|
27
|
+
var isMounted = (0, _1.useIsMounted)();
|
|
28
|
+
(0, react_1.useEffect)(function () {
|
|
29
|
+
if (components && isMounted.current) {
|
|
30
|
+
var rootArea = components.nodes.all.find(function (n) { return n.name === 'root-area'; });
|
|
31
|
+
var view = components.nodes.all.find(function (n) { return n.type === 'view'; });
|
|
32
|
+
if (!(view === null || view === void 0 ? void 0 : view.attributes.properties.animation) &&
|
|
33
|
+
!(rootArea === null || rootArea === void 0 ? void 0 : rootArea.attributes.properties.animation)) {
|
|
34
|
+
// if view and root does not use animations, call handler on render
|
|
35
|
+
handler();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// else add elements to state for transitionend-event handling
|
|
39
|
+
var getElement = function (id) {
|
|
40
|
+
if (id === void 0) { id = ''; }
|
|
41
|
+
return widgetDOMElement === null || widgetDOMElement === void 0 ? void 0 : widgetDOMElement.querySelector("[data-node-id=\"".concat(id, "\"]"));
|
|
42
|
+
};
|
|
43
|
+
var viewDOMElement_1 = getElement(view === null || view === void 0 ? void 0 : view.id);
|
|
44
|
+
if (viewDOMElement_1) {
|
|
45
|
+
setViewDOMElement(viewDOMElement_1);
|
|
46
|
+
}
|
|
47
|
+
var rootDOMElement_1 = getElement(rootArea === null || rootArea === void 0 ? void 0 : rootArea.id);
|
|
48
|
+
if (rootDOMElement_1) {
|
|
49
|
+
setRootDOMElement(rootDOMElement_1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [components, container, isMounted]);
|
|
54
|
+
var eventListener = (0, react_1.useCallback)(function (event) {
|
|
55
|
+
if (isMounted.current &&
|
|
56
|
+
(event.target === viewDOMElement || event.target === rootDOMElement)) {
|
|
57
|
+
handler();
|
|
58
|
+
}
|
|
59
|
+
}, [handler, isMounted, viewDOMElement, rootDOMElement]);
|
|
60
|
+
(0, _1.useEventListener)('transitionend', eventListener, viewDOMElement);
|
|
61
|
+
(0, _1.useEventListener)('transitionend', eventListener, rootDOMElement);
|
|
62
|
+
});
|