@telia-ace/widget-ui 1.0.8 → 1.0.11

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.
Files changed (317) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +3 -3
  3. package/{lib-esm → dist}/components/anchor-link.d.ts +4 -4
  4. package/{lib → dist}/components/button.d.ts +4 -4
  5. package/{lib-esm → dist}/components/checkbox.d.ts +7 -7
  6. package/{lib-esm → dist}/components/drawer/drawer.d.ts +21 -21
  7. package/{lib-esm → dist}/components/drawer/index.d.ts +3 -3
  8. package/{lib-esm → dist}/components/dropdown/dropdown.d.ts +9 -9
  9. package/{lib → dist}/components/dropdown/index.d.ts +4 -4
  10. package/{lib-esm → dist}/components/dropdown/use-position.d.ts +5 -5
  11. package/{lib → dist}/components/empty.d.ts +4 -4
  12. package/{lib → dist}/components/grid.d.ts +7 -7
  13. package/{lib-esm → dist}/components/html.d.ts +12 -12
  14. package/{lib → dist}/components/icon.d.ts +7 -7
  15. package/{lib-esm → dist}/components/index.d.ts +58 -58
  16. package/{lib-esm → dist}/components/input.d.ts +10 -10
  17. package/{lib → dist}/components/item-list.d.ts +10 -10
  18. package/{lib → dist}/components/item-tree.d.ts +13 -13
  19. package/{lib-esm → dist}/components/lightbox.d.ts +6 -6
  20. package/{lib-esm → dist}/components/link.d.ts +11 -11
  21. package/{lib-esm → dist}/components/list.d.ts +9 -9
  22. package/{lib-esm → dist}/components/modal/confirm.d.ts +12 -12
  23. package/{lib → dist}/components/modal/index.d.ts +4 -4
  24. package/{lib-esm → dist}/components/modal/modal.d.ts +10 -10
  25. package/{lib → dist}/components/not-found.d.ts +9 -9
  26. package/{lib → dist}/components/overlay.d.ts +8 -8
  27. package/{lib-esm → dist}/components/paragraph.d.ts +11 -11
  28. package/{lib → dist}/components/portal.d.ts +7 -7
  29. package/{lib-esm → dist}/components/route-link.d.ts +11 -11
  30. package/{lib → dist}/components/symbol-badge.d.ts +15 -15
  31. package/{lib-esm → dist}/components/tab-stop.d.ts +18 -18
  32. package/{lib-esm → dist}/components/text-link.d.ts +8 -8
  33. package/{lib-esm → dist}/components/text.d.ts +4 -4
  34. package/{lib-esm → dist}/components/timestamp.d.ts +13 -13
  35. package/{lib-esm → dist}/components/tooltip.d.ts +8 -8
  36. package/{lib-esm → dist}/components/transition-component.d.ts +30 -30
  37. package/{lib → dist}/components/typography.d.ts +9 -9
  38. package/{lib → dist}/components/widget-link.d.ts +10 -10
  39. package/{lib → dist}/contexts/index.d.ts +9 -9
  40. package/{lib-esm → dist}/create-react-component.d.ts +11 -11
  41. package/{lib-esm → dist}/hooks/index.d.ts +27 -27
  42. package/{lib → dist}/hooks/use-action.d.ts +4 -4
  43. package/{lib-esm → dist}/hooks/use-children.d.ts +4 -4
  44. package/{lib-esm → dist}/hooks/use-columns.d.ts +2 -2
  45. package/{lib-esm → dist}/hooks/use-component-descriptor.d.ts +2 -2
  46. package/{lib-esm → dist}/hooks/use-component-node.d.ts +6 -6
  47. package/{lib → dist}/hooks/use-component-platform.d.ts +4 -4
  48. package/{lib → dist}/hooks/use-component.d.ts +3 -3
  49. package/{lib-esm → dist}/hooks/use-container.d.ts +2 -2
  50. package/{lib-esm → dist}/hooks/use-context.d.ts +3 -3
  51. package/{lib-esm → dist}/hooks/use-dispatch.d.ts +3 -3
  52. package/{lib-esm → dist}/hooks/use-event-listener.d.ts +2 -2
  53. package/{lib-esm → dist}/hooks/use-events.d.ts +3 -3
  54. package/{lib-esm → dist}/hooks/use-is-mounted.d.ts +3 -3
  55. package/{lib-esm → dist}/hooks/use-key-press.d.ts +2 -2
  56. package/{lib-esm → dist}/hooks/use-layout.d.ts +3 -3
  57. package/{lib-esm → dist}/hooks/use-previous.d.ts +2 -2
  58. package/{lib-esm → dist}/hooks/use-properties.d.ts +6 -6
  59. package/{lib-esm → dist}/hooks/use-render-state.d.ts +4 -4
  60. package/{lib → dist}/hooks/use-route-data.d.ts +4 -4
  61. package/{lib-esm → dist}/hooks/use-router.d.ts +3 -3
  62. package/{lib → dist}/hooks/use-scroll.d.ts +2 -2
  63. package/{lib-esm → dist}/hooks/use-settings.d.ts +3 -3
  64. package/{lib-esm → dist}/hooks/use-toggle.d.ts +2 -2
  65. package/{lib → dist}/hooks/use-transition-end.d.ts +2 -2
  66. package/{lib-esm → dist}/hooks/use-unique-menu.d.ts +2 -2
  67. package/{lib-esm → dist}/hooks/use-widget-event.d.ts +3 -3
  68. package/{lib-esm → dist}/index.d.ts +9 -9
  69. package/dist/index.js +2988 -0
  70. package/dist/index.js.map +1 -0
  71. package/{lib-esm → dist}/styles.d.ts +19 -19
  72. package/{lib-esm → dist}/utils/animations.d.ts +18 -18
  73. package/{lib → dist}/utils/browser.d.ts +12 -12
  74. package/{lib-esm → dist}/utils/convert-to-string-attributes.d.ts +2 -2
  75. package/{lib → dist}/utils/create-empty-component.d.ts +3 -3
  76. package/{lib → dist}/utils/embedded-link-mapper.d.ts +3 -3
  77. package/{lib-esm → dist}/utils/filter-css-props.d.ts +8 -8
  78. package/{lib → dist}/utils/generic-hash-link.d.ts +8 -8
  79. package/{lib-esm → dist}/utils/heading-styles.d.ts +1 -1
  80. package/{lib-esm → dist}/utils/index.d.ts +12 -12
  81. package/{lib → dist}/utils/process-html-string.d.ts +4 -4
  82. package/{lib-esm → dist}/utils/render-instructions.d.ts +8 -8
  83. package/package.json +11 -12
  84. package/lib/components/anchor-link.d.ts +0 -4
  85. package/lib/components/anchor-link.js +0 -7
  86. package/lib/components/button.js +0 -64
  87. package/lib/components/checkbox.d.ts +0 -7
  88. package/lib/components/checkbox.js +0 -39
  89. package/lib/components/drawer/drawer.d.ts +0 -21
  90. package/lib/components/drawer/drawer.js +0 -150
  91. package/lib/components/drawer/index.d.ts +0 -3
  92. package/lib/components/drawer/index.js +0 -29
  93. package/lib/components/dropdown/dropdown.d.ts +0 -9
  94. package/lib/components/dropdown/dropdown.js +0 -155
  95. package/lib/components/dropdown/index.js +0 -10
  96. package/lib/components/dropdown/use-position.d.ts +0 -5
  97. package/lib/components/dropdown/use-position.js +0 -57
  98. package/lib/components/empty.js +0 -40
  99. package/lib/components/grid.js +0 -64
  100. package/lib/components/html.d.ts +0 -12
  101. package/lib/components/html.js +0 -78
  102. package/lib/components/icon.js +0 -35
  103. package/lib/components/index.d.ts +0 -58
  104. package/lib/components/index.js +0 -69
  105. package/lib/components/input.d.ts +0 -10
  106. package/lib/components/input.js +0 -94
  107. package/lib/components/item-list.js +0 -62
  108. package/lib/components/item-tree.js +0 -55
  109. package/lib/components/lightbox.d.ts +0 -6
  110. package/lib/components/lightbox.js +0 -92
  111. package/lib/components/link.d.ts +0 -11
  112. package/lib/components/link.js +0 -99
  113. package/lib/components/list.d.ts +0 -9
  114. package/lib/components/list.js +0 -56
  115. package/lib/components/modal/confirm.d.ts +0 -12
  116. package/lib/components/modal/confirm.js +0 -61
  117. package/lib/components/modal/index.js +0 -10
  118. package/lib/components/modal/modal.d.ts +0 -10
  119. package/lib/components/modal/modal.js +0 -127
  120. package/lib/components/not-found.js +0 -55
  121. package/lib/components/overlay.js +0 -73
  122. package/lib/components/paragraph.d.ts +0 -11
  123. package/lib/components/paragraph.js +0 -66
  124. package/lib/components/portal.js +0 -61
  125. package/lib/components/route-link.d.ts +0 -11
  126. package/lib/components/route-link.js +0 -115
  127. package/lib/components/symbol-badge.js +0 -205
  128. package/lib/components/tab-stop.d.ts +0 -18
  129. package/lib/components/tab-stop.js +0 -100
  130. package/lib/components/text-link.d.ts +0 -8
  131. package/lib/components/text-link.js +0 -62
  132. package/lib/components/text.d.ts +0 -4
  133. package/lib/components/text.js +0 -35
  134. package/lib/components/timestamp.d.ts +0 -13
  135. package/lib/components/timestamp.js +0 -39
  136. package/lib/components/tooltip.d.ts +0 -8
  137. package/lib/components/tooltip.js +0 -127
  138. package/lib/components/transition-component.d.ts +0 -30
  139. package/lib/components/transition-component.js +0 -77
  140. package/lib/components/typography.js +0 -43
  141. package/lib/components/widget-link.js +0 -116
  142. package/lib/contexts/index.js +0 -15
  143. package/lib/create-react-component.d.ts +0 -11
  144. package/lib/create-react-component.js +0 -18
  145. package/lib/hooks/index.d.ts +0 -27
  146. package/lib/hooks/index.js +0 -58
  147. package/lib/hooks/use-action.js +0 -21
  148. package/lib/hooks/use-children.d.ts +0 -4
  149. package/lib/hooks/use-children.js +0 -70
  150. package/lib/hooks/use-columns.d.ts +0 -2
  151. package/lib/hooks/use-columns.js +0 -6
  152. package/lib/hooks/use-component-descriptor.d.ts +0 -2
  153. package/lib/hooks/use-component-descriptor.js +0 -6
  154. package/lib/hooks/use-component-node.d.ts +0 -6
  155. package/lib/hooks/use-component-node.js +0 -37
  156. package/lib/hooks/use-component-platform.js +0 -39
  157. package/lib/hooks/use-component.js +0 -57
  158. package/lib/hooks/use-container.d.ts +0 -2
  159. package/lib/hooks/use-container.js +0 -6
  160. package/lib/hooks/use-context.d.ts +0 -3
  161. package/lib/hooks/use-context.js +0 -50
  162. package/lib/hooks/use-dispatch.d.ts +0 -3
  163. package/lib/hooks/use-dispatch.js +0 -64
  164. package/lib/hooks/use-event-listener.d.ts +0 -2
  165. package/lib/hooks/use-event-listener.js +0 -21
  166. package/lib/hooks/use-events.d.ts +0 -3
  167. package/lib/hooks/use-events.js +0 -12
  168. package/lib/hooks/use-is-mounted.d.ts +0 -3
  169. package/lib/hooks/use-is-mounted.js +0 -14
  170. package/lib/hooks/use-key-press.d.ts +0 -2
  171. package/lib/hooks/use-key-press.js +0 -46
  172. package/lib/hooks/use-layout.d.ts +0 -3
  173. package/lib/hooks/use-layout.js +0 -50
  174. package/lib/hooks/use-previous.d.ts +0 -2
  175. package/lib/hooks/use-previous.js +0 -11
  176. package/lib/hooks/use-properties.d.ts +0 -6
  177. package/lib/hooks/use-properties.js +0 -9
  178. package/lib/hooks/use-render-state.d.ts +0 -4
  179. package/lib/hooks/use-render-state.js +0 -70
  180. package/lib/hooks/use-route-data.js +0 -58
  181. package/lib/hooks/use-router.d.ts +0 -3
  182. package/lib/hooks/use-router.js +0 -9
  183. package/lib/hooks/use-scroll.js +0 -71
  184. package/lib/hooks/use-settings.d.ts +0 -3
  185. package/lib/hooks/use-settings.js +0 -38
  186. package/lib/hooks/use-toggle.d.ts +0 -2
  187. package/lib/hooks/use-toggle.js +0 -28
  188. package/lib/hooks/use-transition-end.js +0 -62
  189. package/lib/hooks/use-unique-menu.d.ts +0 -2
  190. package/lib/hooks/use-unique-menu.js +0 -15
  191. package/lib/hooks/use-widget-event.d.ts +0 -3
  192. package/lib/hooks/use-widget-event.js +0 -21
  193. package/lib/index.d.ts +0 -9
  194. package/lib/index.js +0 -98
  195. package/lib/styles.d.ts +0 -19
  196. package/lib/styles.js +0 -53
  197. package/lib/utils/animations.d.ts +0 -18
  198. package/lib/utils/animations.js +0 -104
  199. package/lib/utils/browser.js +0 -54
  200. package/lib/utils/convert-to-string-attributes.d.ts +0 -2
  201. package/lib/utils/convert-to-string-attributes.js +0 -23
  202. package/lib/utils/create-empty-component.js +0 -25
  203. package/lib/utils/embedded-link-mapper.js +0 -62
  204. package/lib/utils/filter-css-props.d.ts +0 -8
  205. package/lib/utils/filter-css-props.js +0 -28
  206. package/lib/utils/generic-hash-link.js +0 -70
  207. package/lib/utils/heading-styles.d.ts +0 -1
  208. package/lib/utils/heading-styles.js +0 -48
  209. package/lib/utils/index.d.ts +0 -12
  210. package/lib/utils/index.js +0 -28
  211. package/lib/utils/process-html-string.js +0 -16
  212. package/lib/utils/render-instructions.d.ts +0 -8
  213. package/lib/utils/render-instructions.js +0 -19
  214. package/lib-esm/components/anchor-link.js +0 -5
  215. package/lib-esm/components/button.d.ts +0 -4
  216. package/lib-esm/components/button.js +0 -36
  217. package/lib-esm/components/checkbox.js +0 -34
  218. package/lib-esm/components/drawer/drawer.js +0 -121
  219. package/lib-esm/components/drawer/index.js +0 -3
  220. package/lib-esm/components/dropdown/dropdown.js +0 -127
  221. package/lib-esm/components/dropdown/index.d.ts +0 -4
  222. package/lib-esm/components/dropdown/index.js +0 -3
  223. package/lib-esm/components/dropdown/use-position.js +0 -53
  224. package/lib-esm/components/empty.d.ts +0 -4
  225. package/lib-esm/components/empty.js +0 -35
  226. package/lib-esm/components/grid.d.ts +0 -7
  227. package/lib-esm/components/grid.js +0 -36
  228. package/lib-esm/components/html.js +0 -53
  229. package/lib-esm/components/icon.d.ts +0 -7
  230. package/lib-esm/components/icon.js +0 -30
  231. package/lib-esm/components/index.js +0 -30
  232. package/lib-esm/components/input.js +0 -69
  233. package/lib-esm/components/item-list.d.ts +0 -10
  234. package/lib-esm/components/item-list.js +0 -34
  235. package/lib-esm/components/item-tree.d.ts +0 -13
  236. package/lib-esm/components/item-tree.js +0 -50
  237. package/lib-esm/components/lightbox.js +0 -64
  238. package/lib-esm/components/link.js +0 -71
  239. package/lib-esm/components/list.js +0 -31
  240. package/lib-esm/components/modal/confirm.js +0 -33
  241. package/lib-esm/components/modal/index.d.ts +0 -4
  242. package/lib-esm/components/modal/index.js +0 -3
  243. package/lib-esm/components/modal/modal.js +0 -99
  244. package/lib-esm/components/not-found.d.ts +0 -9
  245. package/lib-esm/components/not-found.js +0 -27
  246. package/lib-esm/components/overlay.d.ts +0 -8
  247. package/lib-esm/components/overlay.js +0 -45
  248. package/lib-esm/components/paragraph.js +0 -38
  249. package/lib-esm/components/portal.d.ts +0 -7
  250. package/lib-esm/components/portal.js +0 -36
  251. package/lib-esm/components/route-link.js +0 -90
  252. package/lib-esm/components/symbol-badge.d.ts +0 -15
  253. package/lib-esm/components/symbol-badge.js +0 -200
  254. package/lib-esm/components/tab-stop.js +0 -75
  255. package/lib-esm/components/text-link.js +0 -34
  256. package/lib-esm/components/text.js +0 -30
  257. package/lib-esm/components/timestamp.js +0 -33
  258. package/lib-esm/components/tooltip.js +0 -99
  259. package/lib-esm/components/transition-component.js +0 -72
  260. package/lib-esm/components/typography.d.ts +0 -9
  261. package/lib-esm/components/typography.js +0 -38
  262. package/lib-esm/components/widget-link.d.ts +0 -10
  263. package/lib-esm/components/widget-link.js +0 -88
  264. package/lib-esm/contexts/index.d.ts +0 -9
  265. package/lib-esm/contexts/index.js +0 -12
  266. package/lib-esm/create-react-component.js +0 -16
  267. package/lib-esm/hooks/index.js +0 -26
  268. package/lib-esm/hooks/use-action.d.ts +0 -4
  269. package/lib-esm/hooks/use-action.js +0 -14
  270. package/lib-esm/hooks/use-children.js +0 -65
  271. package/lib-esm/hooks/use-columns.js +0 -4
  272. package/lib-esm/hooks/use-component-descriptor.js +0 -4
  273. package/lib-esm/hooks/use-component-node.js +0 -35
  274. package/lib-esm/hooks/use-component-platform.d.ts +0 -4
  275. package/lib-esm/hooks/use-component-platform.js +0 -34
  276. package/lib-esm/hooks/use-component.d.ts +0 -3
  277. package/lib-esm/hooks/use-component.js +0 -52
  278. package/lib-esm/hooks/use-container.js +0 -4
  279. package/lib-esm/hooks/use-context.js +0 -45
  280. package/lib-esm/hooks/use-dispatch.js +0 -59
  281. package/lib-esm/hooks/use-event-listener.js +0 -19
  282. package/lib-esm/hooks/use-events.js +0 -7
  283. package/lib-esm/hooks/use-is-mounted.js +0 -12
  284. package/lib-esm/hooks/use-key-press.js +0 -41
  285. package/lib-esm/hooks/use-layout.js +0 -45
  286. package/lib-esm/hooks/use-previous.js +0 -9
  287. package/lib-esm/hooks/use-properties.js +0 -7
  288. package/lib-esm/hooks/use-render-state.js +0 -65
  289. package/lib-esm/hooks/use-route-data.d.ts +0 -4
  290. package/lib-esm/hooks/use-route-data.js +0 -53
  291. package/lib-esm/hooks/use-router.js +0 -7
  292. package/lib-esm/hooks/use-scroll.d.ts +0 -2
  293. package/lib-esm/hooks/use-scroll.js +0 -66
  294. package/lib-esm/hooks/use-settings.js +0 -33
  295. package/lib-esm/hooks/use-toggle.js +0 -26
  296. package/lib-esm/hooks/use-transition-end.d.ts +0 -2
  297. package/lib-esm/hooks/use-transition-end.js +0 -60
  298. package/lib-esm/hooks/use-unique-menu.js +0 -10
  299. package/lib-esm/hooks/use-widget-event.js +0 -16
  300. package/lib-esm/index.js +0 -7
  301. package/lib-esm/styles.js +0 -26
  302. package/lib-esm/utils/animations.js +0 -101
  303. package/lib-esm/utils/browser.d.ts +0 -12
  304. package/lib-esm/utils/browser.js +0 -51
  305. package/lib-esm/utils/convert-to-string-attributes.js +0 -21
  306. package/lib-esm/utils/create-empty-component.d.ts +0 -3
  307. package/lib-esm/utils/create-empty-component.js +0 -20
  308. package/lib-esm/utils/embedded-link-mapper.d.ts +0 -3
  309. package/lib-esm/utils/embedded-link-mapper.js +0 -57
  310. package/lib-esm/utils/filter-css-props.js +0 -25
  311. package/lib-esm/utils/generic-hash-link.d.ts +0 -8
  312. package/lib-esm/utils/generic-hash-link.js +0 -63
  313. package/lib-esm/utils/heading-styles.js +0 -44
  314. package/lib-esm/utils/index.js +0 -10
  315. package/lib-esm/utils/process-html-string.d.ts +0 -4
  316. package/lib-esm/utils/process-html-string.js +0 -10
  317. package/lib-esm/utils/render-instructions.js +0 -12
@@ -1,88 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import { WidgetRenderState } from '@telia-ace/widget-core';
24
- import { appendClassNames } from '@telia-ace/widget-utilities';
25
- import { WidgetState } from '@webprovisions/platform';
26
- import React, { forwardRef, useEffect } from 'react';
27
- import { useContainer } from '../hooks';
28
- import Link from './link';
29
- export default forwardRef(function (_a, ref) {
30
- var className = _a.className, children = _a.children, _b = _a.onClick, onClick = _b === void 0 ? function () { } : _b, widgetName = _a.widgetName, activationOptions = _a.activationOptions, other = __rest(_a, ["className", "children", "onClick", "widgetName", "activationOptions"]);
31
- var container = useContainer();
32
- var getWidget = function () {
33
- var implementation = container.get('$widget').implementation;
34
- return implementation.widgets.get(widgetName);
35
- };
36
- useEffect(function () {
37
- var widget = getWidget();
38
- widget === null || widget === void 0 ? void 0 : widget.activate(activationOptions).then(function () { return widget.invoke('attach'); });
39
- return function () {
40
- widget === null || widget === void 0 ? void 0 : widget.deactivate();
41
- };
42
- }, [widgetName]);
43
- var openWidget = function (e) {
44
- var widget = getWidget();
45
- var target = e.currentTarget;
46
- if (widget) {
47
- var toggle = function () {
48
- widget
49
- .invoke('renderState')
50
- .then(function (renderState) {
51
- return renderState === WidgetRenderState.open
52
- ? widget.invoke('close')
53
- : widget.invoke('open');
54
- })
55
- .then(function () {
56
- widget.events.subscribeOnce('widget:area-rendered', function (event, data) {
57
- var widgetDOMElement = container.get('widgetDOMElement');
58
- if (widgetDOMElement) {
59
- widget.events.dispatch('widget:modal-opened', {
60
- name: widget.name,
61
- ref: target,
62
- });
63
- }
64
- });
65
- });
66
- };
67
- if (widget.state === WidgetState.Deactivated) {
68
- widget
69
- .activate(activationOptions)
70
- .then(function () { return widget.invoke('attach'); })
71
- .then(toggle);
72
- }
73
- else {
74
- toggle();
75
- }
76
- }
77
- };
78
- var onEnter = function (e) {
79
- if (e.key === 'Enter') {
80
- e.preventDefault();
81
- openWidget(e);
82
- }
83
- };
84
- return (React.createElement(Link, __assign({ className: appendClassNames(className, 'humany-widget-link'), onKeyDown: onEnter, onClick: function (e) {
85
- onClick(e);
86
- openWidget(e);
87
- } }, other, { ref: ref }), children));
88
- });
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { ComponentDescriptor, ComponentNodeProperties } from '@telia-ace/widget-core';
3
- import { RoutingService } from '@telia-ace/widget-routing';
4
- import { Container } from '@webprovisions/platform';
5
- export declare const ContainerContext: import("react").Context<Container>;
6
- export declare const ColumnContext: import("react").Context<number>;
7
- export declare const ComponentNodeContext: import("react").Context<ComponentDescriptor>;
8
- export declare const ComponentPropertyContext: import("react").Context<ComponentNodeProperties>;
9
- export declare const RoutingContext: import("react").Context<RoutingService | null>;
@@ -1,12 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- import { createContext } from 'react';
3
- export var ContainerContext = createContext(new Container());
4
- export var ColumnContext = createContext(1);
5
- export var ComponentNodeContext = createContext({
6
- id: '',
7
- type: '',
8
- name: '',
9
- branch: '',
10
- });
11
- export var ComponentPropertyContext = createContext({});
12
- export var RoutingContext = createContext(null);
@@ -1,16 +0,0 @@
1
- import { extendComponent, } from '@telia-ace/widget-core';
2
- import { lazy } from 'react';
3
- /**
4
- * Registers a React component on the component platform.
5
- * @param container Container to register the component on.
6
- * @param type Type name to resolve the component from configuration.
7
- * @param reactComponent Promise resolving to the React component for rendering.
8
- * @param fn Handler for controlling the component.
9
- */
10
- var createReactComponent = function (container, type, reactComponent, fn, options) {
11
- return container.getAsync('componentResolver').then(function (componentResolver) {
12
- componentResolver.registerComponent(type, lazy(function () { return reactComponent; }));
13
- return extendComponent(container, type, fn || (function () { }), type, options);
14
- });
15
- };
16
- export default createReactComponent;
@@ -1,26 +0,0 @@
1
- export { default as useAction } from './use-action';
2
- export { default as useChildren } from './use-children';
3
- export { default as useColumns } from './use-columns';
4
- export { default as useComponent } from './use-component';
5
- export { default as useComponentDescriptor } from './use-component-descriptor';
6
- export { default as useComponentNode } from './use-component-node';
7
- export { default as useComponentPlatform } from './use-component-platform';
8
- export { default as useContainer } from './use-container';
9
- export { default as useContext } from './use-context';
10
- export { default as useDispatch } from './use-dispatch';
11
- export { default as useEventListener } from './use-event-listener';
12
- export { default as useEvents } from './use-events';
13
- export { default as useIsMounted } from './use-is-mounted';
14
- export { default as useKeyPress } from './use-key-press';
15
- export { default as useLayout } from './use-layout';
16
- export { default as usePrevious } from './use-previous';
17
- export { default as useProperties } from './use-properties';
18
- export { default as useRenderState } from './use-render-state';
19
- export { default as useRouteData } from './use-route-data';
20
- export { default as useRouter } from './use-router';
21
- export { default as useScroll } from './use-scroll';
22
- export { default as useSettings } from './use-settings';
23
- export { default as useToggle } from './use-toggle';
24
- export { default as useTransitionEnd } from './use-transition-end';
25
- export { default as useUniqueMenu } from './use-unique-menu';
26
- export { default as useWidgetEvent } from './use-widget-event';
@@ -1,4 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- export declare type Action = (action: string, value?: any) => void;
3
- export declare const useAction: (passedOrigin?: string | undefined, passedContainer?: Container | undefined) => Action;
4
- export default useAction;
@@ -1,14 +0,0 @@
1
- import useComponentDescriptor from './use-component-descriptor';
2
- import useContainer from './use-container';
3
- export var useAction = function (passedOrigin, passedContainer) {
4
- var origin = useComponentDescriptor().id;
5
- var container = useContainer();
6
- return function (action, value) {
7
- (passedContainer || container)
8
- .getAsync('actionResolver')
9
- .then(function (resolver) {
10
- resolver.action(passedOrigin || origin, action, value);
11
- });
12
- };
13
- };
14
- export default useAction;
@@ -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 { asDescriptor, createEventSubscriber, } from '@telia-ace/widget-core';
18
- import { useCallback, useEffect, useState } from 'react';
19
- import useComponentNode from './use-component-node';
20
- import useComponentPlatform from './use-component-platform';
21
- import useIsMounted from './use-is-mounted';
22
- var useChildren = function () {
23
- var node = useComponentNode();
24
- var components = useComponentPlatform();
25
- var _a = __read(useState([]), 2), children = _a[0], setChildren = _a[1];
26
- var isMounted = useIsMounted();
27
- var updateChildren = useCallback(function (node) {
28
- if (components && isMounted.current) {
29
- var branch = components.getBranch(node);
30
- var children_1 = node.getChildren(branch).map(function (child) { return asDescriptor(child); });
31
- setChildren(children_1);
32
- }
33
- }, [isMounted, components, setChildren]);
34
- useEffect(function () {
35
- if (node) {
36
- updateChildren(node);
37
- }
38
- }, [node, components]);
39
- useEffect(function () {
40
- if (components) {
41
- var _a = __read(createEventSubscriber(components.events), 2), subscribe = _a[0], unsubscribe_1 = _a[1];
42
- subscribe('components:set-layout', function (event, data) {
43
- if (node === data.node.parent || data.node.parent === components.nodes.root) {
44
- updateChildren(data.node.parent);
45
- }
46
- });
47
- subscribe('components:node-appended', function (event, data) {
48
- if (node === data.node.parent || data.node.parent === components.nodes.root) {
49
- updateChildren(data.node.parent);
50
- }
51
- });
52
- subscribe('components:node-removed', function (event, _a) {
53
- var parentNode = _a.parentNode;
54
- if (parentNode === node || parentNode === components.nodes.root) {
55
- updateChildren(parentNode);
56
- }
57
- });
58
- return function () {
59
- unsubscribe_1();
60
- };
61
- }
62
- }, [node, components, updateChildren]);
63
- return children;
64
- };
65
- export default useChildren;
@@ -1,4 +0,0 @@
1
- import { useContext } from 'react';
2
- import { ColumnContext } from '../contexts';
3
- var useColumns = function () { return useContext(ColumnContext); };
4
- export default useColumns;
@@ -1,4 +0,0 @@
1
- import { useContext } from 'react';
2
- import { ComponentNodeContext } from '../contexts';
3
- var useComponentDescriptor = function () { return useContext(ComponentNodeContext); };
4
- export default useComponentDescriptor;
@@ -1,35 +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 { useContext, useEffect, useState } from 'react';
18
- import { useComponentPlatform } from '.';
19
- import { ComponentNodeContext } from '../contexts';
20
- /**
21
- * Provides the `ComponentNode` for the current context.
22
- */
23
- var useComponentNode = function (id) {
24
- var descriptor = useContext(ComponentNodeContext);
25
- var components = useComponentPlatform();
26
- var _a = __read(useState(), 2), node = _a[0], setNode = _a[1];
27
- useEffect(function () {
28
- if ((id || descriptor.id) && components) {
29
- var node_1 = components.nodes.get(id || descriptor.id);
30
- setNode(node_1);
31
- }
32
- }, [id, descriptor.id, components]);
33
- return node;
34
- };
35
- export default useComponentNode;
@@ -1,4 +0,0 @@
1
- import { ComponentPlatform } from '@telia-ace/widget-core';
2
- import { Container } from '@webprovisions/platform';
3
- declare const useComponentPlatform: (passedContainer?: Container | undefined) => ComponentPlatform | null;
4
- export default useComponentPlatform;
@@ -1,34 +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 { ComponentPlatform } 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 useComponentPlatform = function (passedContainer) {
22
- var container = useContainer();
23
- var _a = __read(useState(null), 2), componentPlatform = _a[0], setComponentPlatform = _a[1];
24
- var isMounted = useIsMounted();
25
- useEffect(function () {
26
- ComponentPlatform.getInstance(passedContainer || container).then(function (platform) {
27
- if (isMounted.current) {
28
- setComponentPlatform(platform);
29
- }
30
- });
31
- }, [isMounted]);
32
- return componentPlatform;
33
- };
34
- export default useComponentPlatform;
@@ -1,3 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- declare const useComponent: (passedType?: string | undefined, passedContainer?: Container | undefined) => void | any | null;
3
- export default useComponent;
@@ -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,4 +0,0 @@
1
- import { useContext } from 'react';
2
- import { ContainerContext } from '../contexts';
3
- var useContainer = function () { return useContext(ContainerContext); };
4
- export default useContainer;
@@ -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,7 +0,0 @@
1
- import useContainer from './use-container';
2
- var useEvents = function (passedContainer) {
3
- var container = useContainer();
4
- var events = (passedContainer || container).get('$widget').events;
5
- return events;
6
- };
7
- export default useEvents;
@@ -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,9 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- var usePrevious = function (value) {
3
- var ref = useRef();
4
- useEffect(function () {
5
- ref.current = value;
6
- });
7
- return ref.current;
8
- };
9
- export default usePrevious;
@@ -1,7 +0,0 @@
1
- import { useContext } from 'react';
2
- import { ComponentPropertyContext } from '../contexts';
3
- var useProperties = function () {
4
- var properties = useContext(ComponentPropertyContext);
5
- return properties;
6
- };
7
- export default useProperties;