@telia-ace/widget-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +3 -0
  3. package/lib/components/anchor-link.d.ts +4 -0
  4. package/lib/components/anchor-link.js +7 -0
  5. package/lib/components/button.d.ts +4 -0
  6. package/lib/components/button.js +64 -0
  7. package/lib/components/checkbox.d.ts +7 -0
  8. package/lib/components/checkbox.js +39 -0
  9. package/lib/components/drawer/drawer.d.ts +21 -0
  10. package/lib/components/drawer/drawer.js +150 -0
  11. package/lib/components/drawer/index.d.ts +3 -0
  12. package/lib/components/drawer/index.js +29 -0
  13. package/lib/components/dropdown/dropdown.d.ts +9 -0
  14. package/lib/components/dropdown/dropdown.js +155 -0
  15. package/lib/components/dropdown/index.d.ts +4 -0
  16. package/lib/components/dropdown/index.js +10 -0
  17. package/lib/components/dropdown/use-position.d.ts +5 -0
  18. package/lib/components/dropdown/use-position.js +57 -0
  19. package/lib/components/empty.d.ts +4 -0
  20. package/lib/components/empty.js +40 -0
  21. package/lib/components/grid.d.ts +7 -0
  22. package/lib/components/grid.js +64 -0
  23. package/lib/components/html.d.ts +12 -0
  24. package/lib/components/html.js +78 -0
  25. package/lib/components/icon.d.ts +7 -0
  26. package/lib/components/icon.js +35 -0
  27. package/lib/components/index.d.ts +58 -0
  28. package/lib/components/index.js +69 -0
  29. package/lib/components/input.d.ts +10 -0
  30. package/lib/components/input.js +94 -0
  31. package/lib/components/item-list.d.ts +10 -0
  32. package/lib/components/item-list.js +62 -0
  33. package/lib/components/item-tree.d.ts +13 -0
  34. package/lib/components/item-tree.js +55 -0
  35. package/lib/components/lightbox.d.ts +6 -0
  36. package/lib/components/lightbox.js +92 -0
  37. package/lib/components/link.d.ts +11 -0
  38. package/lib/components/link.js +99 -0
  39. package/lib/components/list.d.ts +9 -0
  40. package/lib/components/list.js +56 -0
  41. package/lib/components/modal/confirm.d.ts +12 -0
  42. package/lib/components/modal/confirm.js +61 -0
  43. package/lib/components/modal/index.d.ts +4 -0
  44. package/lib/components/modal/index.js +10 -0
  45. package/lib/components/modal/modal.d.ts +10 -0
  46. package/lib/components/modal/modal.js +127 -0
  47. package/lib/components/not-found.d.ts +9 -0
  48. package/lib/components/not-found.js +55 -0
  49. package/lib/components/overlay.d.ts +8 -0
  50. package/lib/components/overlay.js +73 -0
  51. package/lib/components/paragraph.d.ts +11 -0
  52. package/lib/components/paragraph.js +66 -0
  53. package/lib/components/portal.d.ts +7 -0
  54. package/lib/components/portal.js +61 -0
  55. package/lib/components/route-link.d.ts +11 -0
  56. package/lib/components/route-link.js +115 -0
  57. package/lib/components/symbol-badge.d.ts +15 -0
  58. package/lib/components/symbol-badge.js +197 -0
  59. package/lib/components/tab-stop.d.ts +18 -0
  60. package/lib/components/tab-stop.js +100 -0
  61. package/lib/components/text-link.d.ts +8 -0
  62. package/lib/components/text-link.js +62 -0
  63. package/lib/components/text.d.ts +4 -0
  64. package/lib/components/text.js +35 -0
  65. package/lib/components/timestamp.d.ts +13 -0
  66. package/lib/components/timestamp.js +39 -0
  67. package/lib/components/tooltip.d.ts +8 -0
  68. package/lib/components/tooltip.js +127 -0
  69. package/lib/components/transition-component.d.ts +30 -0
  70. package/lib/components/transition-component.js +77 -0
  71. package/lib/components/typography.d.ts +9 -0
  72. package/lib/components/typography.js +43 -0
  73. package/lib/components/widget-link.d.ts +10 -0
  74. package/lib/components/widget-link.js +116 -0
  75. package/lib/contexts/index.d.ts +9 -0
  76. package/lib/contexts/index.js +15 -0
  77. package/lib/create-react-component.d.ts +11 -0
  78. package/lib/create-react-component.js +18 -0
  79. package/lib/hooks/index.d.ts +27 -0
  80. package/lib/hooks/index.js +58 -0
  81. package/lib/hooks/use-action.d.ts +4 -0
  82. package/lib/hooks/use-action.js +21 -0
  83. package/lib/hooks/use-children.d.ts +4 -0
  84. package/lib/hooks/use-children.js +70 -0
  85. package/lib/hooks/use-columns.d.ts +2 -0
  86. package/lib/hooks/use-columns.js +6 -0
  87. package/lib/hooks/use-component-descriptor.d.ts +2 -0
  88. package/lib/hooks/use-component-descriptor.js +6 -0
  89. package/lib/hooks/use-component-node.d.ts +6 -0
  90. package/lib/hooks/use-component-node.js +37 -0
  91. package/lib/hooks/use-component-platform.d.ts +4 -0
  92. package/lib/hooks/use-component-platform.js +39 -0
  93. package/lib/hooks/use-component.d.ts +3 -0
  94. package/lib/hooks/use-component.js +57 -0
  95. package/lib/hooks/use-container.d.ts +2 -0
  96. package/lib/hooks/use-container.js +6 -0
  97. package/lib/hooks/use-context.d.ts +3 -0
  98. package/lib/hooks/use-context.js +50 -0
  99. package/lib/hooks/use-dispatch.d.ts +3 -0
  100. package/lib/hooks/use-dispatch.js +64 -0
  101. package/lib/hooks/use-event-listener.d.ts +2 -0
  102. package/lib/hooks/use-event-listener.js +21 -0
  103. package/lib/hooks/use-events.d.ts +3 -0
  104. package/lib/hooks/use-events.js +12 -0
  105. package/lib/hooks/use-is-mounted.d.ts +3 -0
  106. package/lib/hooks/use-is-mounted.js +14 -0
  107. package/lib/hooks/use-key-press.d.ts +2 -0
  108. package/lib/hooks/use-key-press.js +46 -0
  109. package/lib/hooks/use-layout.d.ts +3 -0
  110. package/lib/hooks/use-layout.js +50 -0
  111. package/lib/hooks/use-previous.d.ts +2 -0
  112. package/lib/hooks/use-previous.js +11 -0
  113. package/lib/hooks/use-properties.d.ts +6 -0
  114. package/lib/hooks/use-properties.js +9 -0
  115. package/lib/hooks/use-render-state.d.ts +4 -0
  116. package/lib/hooks/use-render-state.js +66 -0
  117. package/lib/hooks/use-route-data.d.ts +4 -0
  118. package/lib/hooks/use-route-data.js +54 -0
  119. package/lib/hooks/use-router.d.ts +3 -0
  120. package/lib/hooks/use-router.js +9 -0
  121. package/lib/hooks/use-scroll.d.ts +2 -0
  122. package/lib/hooks/use-scroll.js +71 -0
  123. package/lib/hooks/use-settings.d.ts +3 -0
  124. package/lib/hooks/use-settings.js +38 -0
  125. package/lib/hooks/use-toggle.d.ts +2 -0
  126. package/lib/hooks/use-toggle.js +28 -0
  127. package/lib/hooks/use-transition-end.d.ts +2 -0
  128. package/lib/hooks/use-transition-end.js +62 -0
  129. package/lib/hooks/use-unique-menu.d.ts +2 -0
  130. package/lib/hooks/use-unique-menu.js +15 -0
  131. package/lib/hooks/use-widget-event.d.ts +3 -0
  132. package/lib/hooks/use-widget-event.js +21 -0
  133. package/lib/index.d.ts +9 -0
  134. package/lib/index.js +92 -0
  135. package/lib/styles.d.ts +19 -0
  136. package/lib/styles.js +53 -0
  137. package/lib/utils/animations.d.ts +18 -0
  138. package/lib/utils/animations.js +104 -0
  139. package/lib/utils/browser.d.ts +12 -0
  140. package/lib/utils/browser.js +54 -0
  141. package/lib/utils/convert-to-string-attributes.d.ts +2 -0
  142. package/lib/utils/convert-to-string-attributes.js +23 -0
  143. package/lib/utils/create-empty-component.d.ts +4 -0
  144. package/lib/utils/create-empty-component.js +25 -0
  145. package/lib/utils/embedded-link-mapper.d.ts +4 -0
  146. package/lib/utils/embedded-link-mapper.js +62 -0
  147. package/lib/utils/filter-css-props.d.ts +8 -0
  148. package/lib/utils/filter-css-props.js +28 -0
  149. package/lib/utils/generic-hash-link.d.ts +8 -0
  150. package/lib/utils/generic-hash-link.js +70 -0
  151. package/lib/utils/heading-styles.d.ts +1 -0
  152. package/lib/utils/heading-styles.js +48 -0
  153. package/lib/utils/index.d.ts +12 -0
  154. package/lib/utils/index.js +28 -0
  155. package/lib/utils/process-html-string.d.ts +4 -0
  156. package/lib/utils/process-html-string.js +16 -0
  157. package/lib/utils/render-instructions.d.ts +8 -0
  158. package/lib/utils/render-instructions.js +19 -0
  159. package/lib-esm/components/anchor-link.d.ts +4 -0
  160. package/lib-esm/components/anchor-link.js +5 -0
  161. package/lib-esm/components/button.d.ts +4 -0
  162. package/lib-esm/components/button.js +36 -0
  163. package/lib-esm/components/checkbox.d.ts +7 -0
  164. package/lib-esm/components/checkbox.js +34 -0
  165. package/lib-esm/components/drawer/drawer.d.ts +21 -0
  166. package/lib-esm/components/drawer/drawer.js +121 -0
  167. package/lib-esm/components/drawer/index.d.ts +3 -0
  168. package/lib-esm/components/drawer/index.js +3 -0
  169. package/lib-esm/components/dropdown/dropdown.d.ts +9 -0
  170. package/lib-esm/components/dropdown/dropdown.js +127 -0
  171. package/lib-esm/components/dropdown/index.d.ts +4 -0
  172. package/lib-esm/components/dropdown/index.js +3 -0
  173. package/lib-esm/components/dropdown/use-position.d.ts +5 -0
  174. package/lib-esm/components/dropdown/use-position.js +53 -0
  175. package/lib-esm/components/empty.d.ts +4 -0
  176. package/lib-esm/components/empty.js +35 -0
  177. package/lib-esm/components/grid.d.ts +7 -0
  178. package/lib-esm/components/grid.js +36 -0
  179. package/lib-esm/components/html.d.ts +12 -0
  180. package/lib-esm/components/html.js +53 -0
  181. package/lib-esm/components/icon.d.ts +7 -0
  182. package/lib-esm/components/icon.js +30 -0
  183. package/lib-esm/components/index.d.ts +58 -0
  184. package/lib-esm/components/index.js +30 -0
  185. package/lib-esm/components/input.d.ts +10 -0
  186. package/lib-esm/components/input.js +69 -0
  187. package/lib-esm/components/item-list.d.ts +10 -0
  188. package/lib-esm/components/item-list.js +34 -0
  189. package/lib-esm/components/item-tree.d.ts +13 -0
  190. package/lib-esm/components/item-tree.js +50 -0
  191. package/lib-esm/components/lightbox.d.ts +6 -0
  192. package/lib-esm/components/lightbox.js +64 -0
  193. package/lib-esm/components/link.d.ts +11 -0
  194. package/lib-esm/components/link.js +71 -0
  195. package/lib-esm/components/list.d.ts +9 -0
  196. package/lib-esm/components/list.js +31 -0
  197. package/lib-esm/components/modal/confirm.d.ts +12 -0
  198. package/lib-esm/components/modal/confirm.js +33 -0
  199. package/lib-esm/components/modal/index.d.ts +4 -0
  200. package/lib-esm/components/modal/index.js +3 -0
  201. package/lib-esm/components/modal/modal.d.ts +10 -0
  202. package/lib-esm/components/modal/modal.js +99 -0
  203. package/lib-esm/components/not-found.d.ts +9 -0
  204. package/lib-esm/components/not-found.js +27 -0
  205. package/lib-esm/components/overlay.d.ts +8 -0
  206. package/lib-esm/components/overlay.js +45 -0
  207. package/lib-esm/components/paragraph.d.ts +11 -0
  208. package/lib-esm/components/paragraph.js +38 -0
  209. package/lib-esm/components/portal.d.ts +7 -0
  210. package/lib-esm/components/portal.js +36 -0
  211. package/lib-esm/components/route-link.d.ts +11 -0
  212. package/lib-esm/components/route-link.js +90 -0
  213. package/lib-esm/components/symbol-badge.d.ts +15 -0
  214. package/lib-esm/components/symbol-badge.js +192 -0
  215. package/lib-esm/components/tab-stop.d.ts +18 -0
  216. package/lib-esm/components/tab-stop.js +75 -0
  217. package/lib-esm/components/text-link.d.ts +8 -0
  218. package/lib-esm/components/text-link.js +34 -0
  219. package/lib-esm/components/text.d.ts +4 -0
  220. package/lib-esm/components/text.js +30 -0
  221. package/lib-esm/components/timestamp.d.ts +13 -0
  222. package/lib-esm/components/timestamp.js +33 -0
  223. package/lib-esm/components/tooltip.d.ts +8 -0
  224. package/lib-esm/components/tooltip.js +99 -0
  225. package/lib-esm/components/transition-component.d.ts +30 -0
  226. package/lib-esm/components/transition-component.js +72 -0
  227. package/lib-esm/components/typography.d.ts +9 -0
  228. package/lib-esm/components/typography.js +38 -0
  229. package/lib-esm/components/widget-link.d.ts +10 -0
  230. package/lib-esm/components/widget-link.js +88 -0
  231. package/lib-esm/contexts/index.d.ts +9 -0
  232. package/lib-esm/contexts/index.js +12 -0
  233. package/lib-esm/create-react-component.d.ts +11 -0
  234. package/lib-esm/create-react-component.js +16 -0
  235. package/lib-esm/hooks/index.d.ts +27 -0
  236. package/lib-esm/hooks/index.js +26 -0
  237. package/lib-esm/hooks/use-action.d.ts +4 -0
  238. package/lib-esm/hooks/use-action.js +14 -0
  239. package/lib-esm/hooks/use-children.d.ts +4 -0
  240. package/lib-esm/hooks/use-children.js +65 -0
  241. package/lib-esm/hooks/use-columns.d.ts +2 -0
  242. package/lib-esm/hooks/use-columns.js +4 -0
  243. package/lib-esm/hooks/use-component-descriptor.d.ts +2 -0
  244. package/lib-esm/hooks/use-component-descriptor.js +4 -0
  245. package/lib-esm/hooks/use-component-node.d.ts +6 -0
  246. package/lib-esm/hooks/use-component-node.js +35 -0
  247. package/lib-esm/hooks/use-component-platform.d.ts +4 -0
  248. package/lib-esm/hooks/use-component-platform.js +34 -0
  249. package/lib-esm/hooks/use-component.d.ts +3 -0
  250. package/lib-esm/hooks/use-component.js +52 -0
  251. package/lib-esm/hooks/use-container.d.ts +2 -0
  252. package/lib-esm/hooks/use-container.js +4 -0
  253. package/lib-esm/hooks/use-context.d.ts +3 -0
  254. package/lib-esm/hooks/use-context.js +45 -0
  255. package/lib-esm/hooks/use-dispatch.d.ts +3 -0
  256. package/lib-esm/hooks/use-dispatch.js +59 -0
  257. package/lib-esm/hooks/use-event-listener.d.ts +2 -0
  258. package/lib-esm/hooks/use-event-listener.js +19 -0
  259. package/lib-esm/hooks/use-events.d.ts +3 -0
  260. package/lib-esm/hooks/use-events.js +7 -0
  261. package/lib-esm/hooks/use-is-mounted.d.ts +3 -0
  262. package/lib-esm/hooks/use-is-mounted.js +12 -0
  263. package/lib-esm/hooks/use-key-press.d.ts +2 -0
  264. package/lib-esm/hooks/use-key-press.js +41 -0
  265. package/lib-esm/hooks/use-layout.d.ts +3 -0
  266. package/lib-esm/hooks/use-layout.js +45 -0
  267. package/lib-esm/hooks/use-previous.d.ts +2 -0
  268. package/lib-esm/hooks/use-previous.js +9 -0
  269. package/lib-esm/hooks/use-properties.d.ts +6 -0
  270. package/lib-esm/hooks/use-properties.js +7 -0
  271. package/lib-esm/hooks/use-render-state.d.ts +4 -0
  272. package/lib-esm/hooks/use-render-state.js +61 -0
  273. package/lib-esm/hooks/use-route-data.d.ts +4 -0
  274. package/lib-esm/hooks/use-route-data.js +49 -0
  275. package/lib-esm/hooks/use-router.d.ts +3 -0
  276. package/lib-esm/hooks/use-router.js +7 -0
  277. package/lib-esm/hooks/use-scroll.d.ts +2 -0
  278. package/lib-esm/hooks/use-scroll.js +66 -0
  279. package/lib-esm/hooks/use-settings.d.ts +3 -0
  280. package/lib-esm/hooks/use-settings.js +33 -0
  281. package/lib-esm/hooks/use-toggle.d.ts +2 -0
  282. package/lib-esm/hooks/use-toggle.js +26 -0
  283. package/lib-esm/hooks/use-transition-end.d.ts +2 -0
  284. package/lib-esm/hooks/use-transition-end.js +60 -0
  285. package/lib-esm/hooks/use-unique-menu.d.ts +2 -0
  286. package/lib-esm/hooks/use-unique-menu.js +10 -0
  287. package/lib-esm/hooks/use-widget-event.d.ts +3 -0
  288. package/lib-esm/hooks/use-widget-event.js +16 -0
  289. package/lib-esm/index.d.ts +9 -0
  290. package/lib-esm/index.js +7 -0
  291. package/lib-esm/styles.d.ts +19 -0
  292. package/lib-esm/styles.js +26 -0
  293. package/lib-esm/utils/animations.d.ts +18 -0
  294. package/lib-esm/utils/animations.js +101 -0
  295. package/lib-esm/utils/browser.d.ts +12 -0
  296. package/lib-esm/utils/browser.js +51 -0
  297. package/lib-esm/utils/convert-to-string-attributes.d.ts +2 -0
  298. package/lib-esm/utils/convert-to-string-attributes.js +21 -0
  299. package/lib-esm/utils/create-empty-component.d.ts +4 -0
  300. package/lib-esm/utils/create-empty-component.js +20 -0
  301. package/lib-esm/utils/embedded-link-mapper.d.ts +4 -0
  302. package/lib-esm/utils/embedded-link-mapper.js +57 -0
  303. package/lib-esm/utils/filter-css-props.d.ts +8 -0
  304. package/lib-esm/utils/filter-css-props.js +25 -0
  305. package/lib-esm/utils/generic-hash-link.d.ts +8 -0
  306. package/lib-esm/utils/generic-hash-link.js +63 -0
  307. package/lib-esm/utils/heading-styles.d.ts +1 -0
  308. package/lib-esm/utils/heading-styles.js +44 -0
  309. package/lib-esm/utils/index.d.ts +12 -0
  310. package/lib-esm/utils/index.js +10 -0
  311. package/lib-esm/utils/process-html-string.d.ts +4 -0
  312. package/lib-esm/utils/process-html-string.js +10 -0
  313. package/lib-esm/utils/render-instructions.d.ts +8 -0
  314. package/lib-esm/utils/render-instructions.js +12 -0
  315. package/package.json +47 -0
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import { Transition } from 'react-transition-group';
3
+ import { transitionComposer } from '../utils';
4
+ /**
5
+ * Wrapper component for Transition from 'react-transition-group'
6
+ * Controls animated enter/exit transitions of a child component bu dynamically creating
7
+ * css that is forwarded to the child component.
8
+ *
9
+ * TODO:
10
+ * Extend to accept more specific transitions (TransitionStateSettings) to enable different
11
+ * enter and exit animations, timings and easings
12
+ */
13
+ var TransitionComponent = function (props) {
14
+ var inState = props.in, _a = props.mountOnEnter, mountOnEnter = _a === void 0 ? true : _a, _b = props.unmountOnExit, unmountOnExit = _b === void 0 ? true : _b, timeout = props.timeout, children = props.children, transitions = props.transitions;
15
+ var generateTransitionDefinition = function () {
16
+ var _a, _b;
17
+ if (!transitions || transitions === 'none') {
18
+ return;
19
+ }
20
+ if (typeof transitions === 'string') {
21
+ return {
22
+ enter: {
23
+ transitionKeys: transitions,
24
+ duration: !!timeout
25
+ ? typeof timeout === 'number'
26
+ ? timeout
27
+ : timeout.enter
28
+ : 200,
29
+ easing: 'ease-in',
30
+ },
31
+ exit: {
32
+ transitionKeys: transitions,
33
+ duration: !!timeout
34
+ ? typeof timeout === 'number'
35
+ ? timeout
36
+ : timeout.exit
37
+ : 200,
38
+ easing: 'ease-out',
39
+ },
40
+ };
41
+ }
42
+ if (typeof transitions === 'object') {
43
+ var enter = transitions.enter, exit = transitions.exit;
44
+ return {
45
+ enter: {
46
+ transitionKeys: (_a = transitions.enter) === null || _a === void 0 ? void 0 : _a.type,
47
+ duration: !!timeout
48
+ ? typeof timeout === 'number'
49
+ ? timeout
50
+ : timeout.enter
51
+ : 200,
52
+ easing: !!enter.easing ? enter.easing : 'ease-in',
53
+ },
54
+ exit: {
55
+ transitionKeys: (_b = transitions.enter) === null || _b === void 0 ? void 0 : _b.type,
56
+ duration: !!timeout
57
+ ? typeof timeout === 'number'
58
+ ? timeout
59
+ : timeout.enter
60
+ : 200,
61
+ easing: !!exit.easing ? exit.easing : 'ease-out',
62
+ },
63
+ };
64
+ }
65
+ };
66
+ var def = generateTransitionDefinition();
67
+ return (React.createElement(Transition, { timeout: {
68
+ enter: (def && def.enter.duration) || 0,
69
+ exit: (def && def.exit.duration) || 0,
70
+ }, in: inState, appear: true, mountOnEnter: mountOnEnter, unmountOnExit: unmountOnExit, onEnter: function (node) { return node.clientHeight; } }, function (state) { return children && children(state, def && transitionComposer.compose(state, def)); }));
71
+ };
72
+ export default TransitionComponent;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export declare type TypographyVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span';
3
+ export declare type Props = {
4
+ variant: TypographyVariant;
5
+ component?: React.ElementType;
6
+ className?: string;
7
+ };
8
+ declare const Typography: React.FC<Props>;
9
+ export default Typography;
@@ -0,0 +1,38 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+ import React from 'react';
17
+ import styled from 'styled-components';
18
+ import { useContext } from '../hooks';
19
+ var defaultVariantMapping = {
20
+ h1: 'h1',
21
+ h2: 'h2',
22
+ h3: 'h3',
23
+ h4: 'h4',
24
+ h5: 'h5',
25
+ h6: 'h6',
26
+ p: 'p',
27
+ span: 'span',
28
+ };
29
+ var Typography = function (_a) {
30
+ var variant = _a.variant, component = _a.component, className = _a.className, children = _a.children;
31
+ var _b = useContext().typographyVariantMapping, typographyVariantMapping = _b === void 0 ? {} : _b;
32
+ var variantMapping = __assign(__assign({}, defaultVariantMapping), typographyVariantMapping);
33
+ var Component = component || variantMapping[variant] || 'span';
34
+ return (React.createElement(Base, { className: className, as: Component }, children));
35
+ };
36
+ var Base = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
37
+ export default Typography;
38
+ var templateObject_1;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { Props as LinkProps } from './link';
3
+ export declare type Props = Merge<LinkProps, {
4
+ widgetName: string;
5
+ activationOptions?: {
6
+ [key: string]: any;
7
+ };
8
+ }>;
9
+ declare const _default: React.ForwardRefExoticComponent<Pick<Props, "to" | "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement> | "disabled" | "routeName" | "params" | "widgetName" | "activationOptions"> & React.RefAttributes<HTMLAnchorElement>>;
10
+ export default _default;
@@ -0,0 +1,88 @@
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
+ });
@@ -0,0 +1,9 @@
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>;
@@ -0,0 +1,12 @@
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);
@@ -0,0 +1,11 @@
1
+ import { ExtendComponentHandler, ExtendComponentOptions, ReactComponent } from '@telia-ace/widget-core';
2
+ import { Container } from '@webprovisions/platform';
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
+ declare const createReactComponent: (container: Container, type: string, reactComponent: ReactComponent, fn?: ExtendComponentHandler | undefined, options?: ExtendComponentOptions | undefined) => Promise<void>;
11
+ export default createReactComponent;
@@ -0,0 +1,16 @@
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;
@@ -0,0 +1,27 @@
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 type { DispatchAction } from './use-dispatch';
12
+ export { default as useEventListener } from './use-event-listener';
13
+ export { default as useEvents } from './use-events';
14
+ export { default as useIsMounted } from './use-is-mounted';
15
+ export { default as useKeyPress } from './use-key-press';
16
+ export { default as useLayout } from './use-layout';
17
+ export { default as usePrevious } from './use-previous';
18
+ export { default as useProperties } from './use-properties';
19
+ export { default as useRenderState } from './use-render-state';
20
+ export { default as useRouteData } from './use-route-data';
21
+ export { default as useRouter } from './use-router';
22
+ export { default as useScroll } from './use-scroll';
23
+ export { default as useSettings } from './use-settings';
24
+ export { default as useToggle } from './use-toggle';
25
+ export { default as useTransitionEnd } from './use-transition-end';
26
+ export { default as useUniqueMenu } from './use-unique-menu';
27
+ export { default as useWidgetEvent } from './use-widget-event';
@@ -0,0 +1,26 @@
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';
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,4 @@
1
+ import { ComponentDescriptor } from '@telia-ace/widget-core';
2
+ export declare type SetPropertiesAction<T> = (key: string, value: Partial<T>) => void;
3
+ declare const useChildren: () => ComponentDescriptor[];
4
+ export default useChildren;
@@ -0,0 +1,65 @@
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;
@@ -0,0 +1,2 @@
1
+ declare const useColumns: () => number;
2
+ export default useColumns;
@@ -0,0 +1,4 @@
1
+ import { useContext } from 'react';
2
+ import { ColumnContext } from '../contexts';
3
+ var useColumns = function () { return useContext(ColumnContext); };
4
+ export default useColumns;
@@ -0,0 +1,2 @@
1
+ declare const useComponentDescriptor: () => import("@telia-ace/widget-core").ComponentDescriptor;
2
+ export default useComponentDescriptor;
@@ -0,0 +1,4 @@
1
+ import { useContext } from 'react';
2
+ import { ComponentNodeContext } from '../contexts';
3
+ var useComponentDescriptor = function () { return useContext(ComponentNodeContext); };
4
+ export default useComponentDescriptor;
@@ -0,0 +1,6 @@
1
+ import { ComponentNode } from '@telia-ace/widget-core';
2
+ /**
3
+ * Provides the `ComponentNode` for the current context.
4
+ */
5
+ declare const useComponentNode: (id?: string | undefined) => ComponentNode | undefined;
6
+ export default useComponentNode;
@@ -0,0 +1,35 @@
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;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,34 @@
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;
@@ -0,0 +1,3 @@
1
+ import { Container } from '@webprovisions/platform';
2
+ declare const useComponent: (passedType?: string | undefined, passedContainer?: Container | undefined) => void | any | null;
3
+ export default useComponent;
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,2 @@
1
+ declare const useContainer: () => import("@webprovisions/platform").Container;
2
+ export default useContainer;
@@ -0,0 +1,4 @@
1
+ import { useContext } from 'react';
2
+ import { ContainerContext } from '../contexts';
3
+ var useContainer = function () { return useContext(ContainerContext); };
4
+ export default useContainer;
@@ -0,0 +1,3 @@
1
+ import { ComponentNodeContext } from '@telia-ace/widget-core';
2
+ declare const useContext: <T extends ComponentNodeContext>(id?: string | undefined) => T;
3
+ export default useContext;
@@ -0,0 +1,45 @@
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;