@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,64 +0,0 @@
|
|
|
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;
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
});
|
package/lib/hooks/use-events.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
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;
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|
package/lib/hooks/use-layout.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,70 +0,0 @@
|
|
|
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 widget = (passedContainer || container).get('$widget');
|
|
33
|
-
if (!widget) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
var name = widget.name, invoke = widget.invoke;
|
|
37
|
-
invoke('renderState').then(function (renderState) {
|
|
38
|
-
if (isMounted.current) {
|
|
39
|
-
setRenderState(renderState);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
(passedContainer || container)
|
|
43
|
-
.getAsync('actionResolver')
|
|
44
|
-
.then(function (actionResolver) {
|
|
45
|
-
unsubscribe = actionResolver.subscribe(name, function (origin, action) {
|
|
46
|
-
switch (action) {
|
|
47
|
-
case 'close':
|
|
48
|
-
case 'open':
|
|
49
|
-
if (isMounted.current) {
|
|
50
|
-
setRenderState(action === 'open'
|
|
51
|
-
? widget_core_1.WidgetRenderState.open
|
|
52
|
-
: widget_core_1.WidgetRenderState.closed);
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
case 'hide':
|
|
56
|
-
if (isMounted.current) {
|
|
57
|
-
setRenderState(widget_core_1.WidgetRenderState.hidden);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
return function () {
|
|
63
|
-
if (unsubscribe) {
|
|
64
|
-
unsubscribe();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, [isMounted]);
|
|
68
|
-
return renderState;
|
|
69
|
-
};
|
|
70
|
-
exports.default = useRenderState;
|
|
@@ -1,58 +0,0 @@
|
|
|
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 widget = (passedContainer || container).get('$widget');
|
|
34
|
-
if (!widget) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
var events = widget.events;
|
|
38
|
-
var unsubscribe = events.subscribe('router:change', function (e, _a) {
|
|
39
|
-
var routeData = _a.next.routeData;
|
|
40
|
-
if (isMounted.current) {
|
|
41
|
-
var name_1 = routeData.name, params = routeData.params;
|
|
42
|
-
(0, widget_utilities_1.removeNullAndUndefinedValues)(params);
|
|
43
|
-
setRouteData({ name: name_1, params: params });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return unsubscribe;
|
|
47
|
-
}, [isMounted, passedContainer, container]);
|
|
48
|
-
(0, react_1.useEffect)(function () {
|
|
49
|
-
if (router && router.history && isMounted.current) {
|
|
50
|
-
var routeData_1 = router.getRouteData();
|
|
51
|
-
var name_2 = routeData_1.name, params = routeData_1.params;
|
|
52
|
-
(0, widget_utilities_1.removeNullAndUndefinedValues)(params);
|
|
53
|
-
setRouteData({ name: name_2, params: params });
|
|
54
|
-
}
|
|
55
|
-
}, [router, isMounted]);
|
|
56
|
-
return routeData;
|
|
57
|
-
};
|
|
58
|
-
exports.default = useRouteData;
|
package/lib/hooks/use-router.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
package/lib/hooks/use-scroll.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
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");
|
|
@@ -1,38 +0,0 @@
|
|
|
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;
|
package/lib/hooks/use-toggle.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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;
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
});
|