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