@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.
Files changed (315) hide show
  1. package/{lib-esm → dist}/components/anchor-link.d.ts +0 -0
  2. package/{lib-esm → dist}/components/button.d.ts +0 -0
  3. package/{lib-esm → dist}/components/checkbox.d.ts +0 -0
  4. package/{lib-esm → dist}/components/drawer/drawer.d.ts +0 -0
  5. package/{lib-esm → dist}/components/drawer/index.d.ts +0 -0
  6. package/{lib-esm → dist}/components/dropdown/dropdown.d.ts +0 -0
  7. package/{lib-esm → dist}/components/dropdown/index.d.ts +0 -0
  8. package/{lib-esm → dist}/components/dropdown/use-position.d.ts +0 -0
  9. package/{lib-esm → dist}/components/empty.d.ts +0 -0
  10. package/{lib-esm → dist}/components/grid.d.ts +0 -0
  11. package/{lib-esm → dist}/components/html.d.ts +0 -0
  12. package/{lib-esm → dist}/components/icon.d.ts +0 -0
  13. package/{lib-esm → dist}/components/index.d.ts +0 -0
  14. package/{lib-esm → dist}/components/input.d.ts +0 -0
  15. package/{lib-esm → dist}/components/item-list.d.ts +0 -0
  16. package/{lib-esm → dist}/components/item-tree.d.ts +0 -0
  17. package/{lib-esm → dist}/components/lightbox.d.ts +0 -0
  18. package/{lib-esm → dist}/components/link.d.ts +0 -0
  19. package/{lib-esm → dist}/components/list.d.ts +0 -0
  20. package/{lib-esm → dist}/components/modal/confirm.d.ts +0 -0
  21. package/{lib-esm → dist}/components/modal/index.d.ts +0 -0
  22. package/{lib-esm → dist}/components/modal/modal.d.ts +0 -0
  23. package/{lib-esm → dist}/components/not-found.d.ts +0 -0
  24. package/{lib-esm → dist}/components/overlay.d.ts +0 -0
  25. package/{lib-esm → dist}/components/paragraph.d.ts +0 -0
  26. package/{lib-esm → dist}/components/portal.d.ts +0 -0
  27. package/{lib-esm → dist}/components/route-link.d.ts +0 -0
  28. package/{lib-esm → dist}/components/symbol-badge.d.ts +0 -0
  29. package/{lib-esm → dist}/components/tab-stop.d.ts +0 -0
  30. package/{lib-esm → dist}/components/text-link.d.ts +0 -0
  31. package/{lib-esm → dist}/components/text.d.ts +0 -0
  32. package/{lib-esm → dist}/components/timestamp.d.ts +0 -0
  33. package/{lib-esm → dist}/components/tooltip.d.ts +0 -0
  34. package/{lib-esm → dist}/components/transition-component.d.ts +0 -0
  35. package/{lib-esm → dist}/components/typography.d.ts +0 -0
  36. package/{lib-esm → dist}/components/widget-link.d.ts +0 -0
  37. package/{lib-esm → dist}/contexts/index.d.ts +0 -0
  38. package/{lib-esm → dist}/create-react-component.d.ts +0 -0
  39. package/{lib-esm → dist}/hooks/index.d.ts +0 -0
  40. package/{lib-esm → dist}/hooks/use-action.d.ts +0 -0
  41. package/{lib-esm → dist}/hooks/use-children.d.ts +0 -0
  42. package/{lib-esm → dist}/hooks/use-columns.d.ts +0 -0
  43. package/{lib-esm → dist}/hooks/use-component-descriptor.d.ts +0 -0
  44. package/{lib-esm → dist}/hooks/use-component-node.d.ts +0 -0
  45. package/{lib-esm → dist}/hooks/use-component-platform.d.ts +0 -0
  46. package/{lib-esm → dist}/hooks/use-component.d.ts +0 -0
  47. package/{lib-esm → dist}/hooks/use-container.d.ts +0 -0
  48. package/{lib-esm → dist}/hooks/use-context.d.ts +0 -0
  49. package/{lib-esm → dist}/hooks/use-dispatch.d.ts +0 -0
  50. package/{lib-esm → dist}/hooks/use-event-listener.d.ts +0 -0
  51. package/{lib-esm → dist}/hooks/use-events.d.ts +0 -0
  52. package/{lib-esm → dist}/hooks/use-is-mounted.d.ts +0 -0
  53. package/{lib-esm → dist}/hooks/use-key-press.d.ts +0 -0
  54. package/{lib-esm → dist}/hooks/use-layout.d.ts +0 -0
  55. package/{lib-esm → dist}/hooks/use-previous.d.ts +0 -0
  56. package/{lib-esm → dist}/hooks/use-properties.d.ts +0 -0
  57. package/{lib-esm → dist}/hooks/use-render-state.d.ts +0 -0
  58. package/{lib-esm → dist}/hooks/use-route-data.d.ts +0 -0
  59. package/{lib-esm → dist}/hooks/use-router.d.ts +0 -0
  60. package/{lib-esm → dist}/hooks/use-scroll.d.ts +0 -0
  61. package/{lib-esm → dist}/hooks/use-settings.d.ts +0 -0
  62. package/{lib-esm → dist}/hooks/use-toggle.d.ts +0 -0
  63. package/{lib-esm → dist}/hooks/use-transition-end.d.ts +0 -0
  64. package/{lib-esm → dist}/hooks/use-unique-menu.d.ts +0 -0
  65. package/{lib-esm → dist}/hooks/use-widget-event.d.ts +0 -0
  66. package/{lib-esm → dist}/index.d.ts +0 -0
  67. package/dist/index.js +2988 -0
  68. package/dist/index.js.map +1 -0
  69. package/{lib-esm → dist}/styles.d.ts +0 -0
  70. package/{lib-esm → dist}/utils/animations.d.ts +0 -0
  71. package/{lib-esm → dist}/utils/browser.d.ts +0 -0
  72. package/{lib-esm → dist}/utils/convert-to-string-attributes.d.ts +0 -0
  73. package/{lib-esm → dist}/utils/create-empty-component.d.ts +0 -0
  74. package/{lib-esm → dist}/utils/embedded-link-mapper.d.ts +0 -0
  75. package/{lib-esm → dist}/utils/filter-css-props.d.ts +0 -0
  76. package/{lib-esm → dist}/utils/generic-hash-link.d.ts +0 -0
  77. package/{lib-esm → dist}/utils/heading-styles.d.ts +0 -0
  78. package/{lib-esm → dist}/utils/index.d.ts +0 -0
  79. package/{lib-esm → dist}/utils/process-html-string.d.ts +0 -0
  80. package/{lib-esm → dist}/utils/render-instructions.d.ts +0 -0
  81. package/package.json +10 -11
  82. package/lib/components/anchor-link.d.ts +0 -4
  83. package/lib/components/anchor-link.js +0 -7
  84. package/lib/components/button.d.ts +0 -4
  85. package/lib/components/button.js +0 -64
  86. package/lib/components/checkbox.d.ts +0 -7
  87. package/lib/components/checkbox.js +0 -39
  88. package/lib/components/drawer/drawer.d.ts +0 -21
  89. package/lib/components/drawer/drawer.js +0 -150
  90. package/lib/components/drawer/index.d.ts +0 -3
  91. package/lib/components/drawer/index.js +0 -29
  92. package/lib/components/dropdown/dropdown.d.ts +0 -9
  93. package/lib/components/dropdown/dropdown.js +0 -155
  94. package/lib/components/dropdown/index.d.ts +0 -4
  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.d.ts +0 -4
  99. package/lib/components/empty.js +0 -40
  100. package/lib/components/grid.d.ts +0 -7
  101. package/lib/components/grid.js +0 -64
  102. package/lib/components/html.d.ts +0 -12
  103. package/lib/components/html.js +0 -78
  104. package/lib/components/icon.d.ts +0 -7
  105. package/lib/components/icon.js +0 -35
  106. package/lib/components/index.d.ts +0 -58
  107. package/lib/components/index.js +0 -69
  108. package/lib/components/input.d.ts +0 -10
  109. package/lib/components/input.js +0 -94
  110. package/lib/components/item-list.d.ts +0 -10
  111. package/lib/components/item-list.js +0 -62
  112. package/lib/components/item-tree.d.ts +0 -13
  113. package/lib/components/item-tree.js +0 -55
  114. package/lib/components/lightbox.d.ts +0 -6
  115. package/lib/components/lightbox.js +0 -92
  116. package/lib/components/link.d.ts +0 -11
  117. package/lib/components/link.js +0 -99
  118. package/lib/components/list.d.ts +0 -9
  119. package/lib/components/list.js +0 -56
  120. package/lib/components/modal/confirm.d.ts +0 -12
  121. package/lib/components/modal/confirm.js +0 -61
  122. package/lib/components/modal/index.d.ts +0 -4
  123. package/lib/components/modal/index.js +0 -10
  124. package/lib/components/modal/modal.d.ts +0 -10
  125. package/lib/components/modal/modal.js +0 -127
  126. package/lib/components/not-found.d.ts +0 -9
  127. package/lib/components/not-found.js +0 -55
  128. package/lib/components/overlay.d.ts +0 -8
  129. package/lib/components/overlay.js +0 -73
  130. package/lib/components/paragraph.d.ts +0 -11
  131. package/lib/components/paragraph.js +0 -66
  132. package/lib/components/portal.d.ts +0 -7
  133. package/lib/components/portal.js +0 -61
  134. package/lib/components/route-link.d.ts +0 -11
  135. package/lib/components/route-link.js +0 -115
  136. package/lib/components/symbol-badge.d.ts +0 -15
  137. package/lib/components/symbol-badge.js +0 -205
  138. package/lib/components/tab-stop.d.ts +0 -18
  139. package/lib/components/tab-stop.js +0 -100
  140. package/lib/components/text-link.d.ts +0 -8
  141. package/lib/components/text-link.js +0 -62
  142. package/lib/components/text.d.ts +0 -4
  143. package/lib/components/text.js +0 -35
  144. package/lib/components/timestamp.d.ts +0 -13
  145. package/lib/components/timestamp.js +0 -39
  146. package/lib/components/tooltip.d.ts +0 -8
  147. package/lib/components/tooltip.js +0 -127
  148. package/lib/components/transition-component.d.ts +0 -30
  149. package/lib/components/transition-component.js +0 -77
  150. package/lib/components/typography.d.ts +0 -9
  151. package/lib/components/typography.js +0 -43
  152. package/lib/components/widget-link.d.ts +0 -10
  153. package/lib/components/widget-link.js +0 -116
  154. package/lib/contexts/index.d.ts +0 -9
  155. package/lib/contexts/index.js +0 -15
  156. package/lib/create-react-component.d.ts +0 -11
  157. package/lib/create-react-component.js +0 -18
  158. package/lib/hooks/index.d.ts +0 -27
  159. package/lib/hooks/index.js +0 -58
  160. package/lib/hooks/use-action.d.ts +0 -4
  161. package/lib/hooks/use-action.js +0 -21
  162. package/lib/hooks/use-children.d.ts +0 -4
  163. package/lib/hooks/use-children.js +0 -70
  164. package/lib/hooks/use-columns.d.ts +0 -2
  165. package/lib/hooks/use-columns.js +0 -6
  166. package/lib/hooks/use-component-descriptor.d.ts +0 -2
  167. package/lib/hooks/use-component-descriptor.js +0 -6
  168. package/lib/hooks/use-component-node.d.ts +0 -6
  169. package/lib/hooks/use-component-node.js +0 -37
  170. package/lib/hooks/use-component-platform.d.ts +0 -4
  171. package/lib/hooks/use-component-platform.js +0 -39
  172. package/lib/hooks/use-component.d.ts +0 -3
  173. package/lib/hooks/use-component.js +0 -57
  174. package/lib/hooks/use-container.d.ts +0 -2
  175. package/lib/hooks/use-container.js +0 -6
  176. package/lib/hooks/use-context.d.ts +0 -3
  177. package/lib/hooks/use-context.js +0 -50
  178. package/lib/hooks/use-dispatch.d.ts +0 -3
  179. package/lib/hooks/use-dispatch.js +0 -64
  180. package/lib/hooks/use-event-listener.d.ts +0 -2
  181. package/lib/hooks/use-event-listener.js +0 -21
  182. package/lib/hooks/use-events.d.ts +0 -3
  183. package/lib/hooks/use-events.js +0 -12
  184. package/lib/hooks/use-is-mounted.d.ts +0 -3
  185. package/lib/hooks/use-is-mounted.js +0 -14
  186. package/lib/hooks/use-key-press.d.ts +0 -2
  187. package/lib/hooks/use-key-press.js +0 -46
  188. package/lib/hooks/use-layout.d.ts +0 -3
  189. package/lib/hooks/use-layout.js +0 -50
  190. package/lib/hooks/use-previous.d.ts +0 -2
  191. package/lib/hooks/use-previous.js +0 -11
  192. package/lib/hooks/use-properties.d.ts +0 -6
  193. package/lib/hooks/use-properties.js +0 -9
  194. package/lib/hooks/use-render-state.d.ts +0 -4
  195. package/lib/hooks/use-render-state.js +0 -70
  196. package/lib/hooks/use-route-data.d.ts +0 -4
  197. package/lib/hooks/use-route-data.js +0 -58
  198. package/lib/hooks/use-router.d.ts +0 -3
  199. package/lib/hooks/use-router.js +0 -9
  200. package/lib/hooks/use-scroll.d.ts +0 -2
  201. package/lib/hooks/use-scroll.js +0 -71
  202. package/lib/hooks/use-settings.d.ts +0 -3
  203. package/lib/hooks/use-settings.js +0 -38
  204. package/lib/hooks/use-toggle.d.ts +0 -2
  205. package/lib/hooks/use-toggle.js +0 -28
  206. package/lib/hooks/use-transition-end.d.ts +0 -2
  207. package/lib/hooks/use-transition-end.js +0 -62
  208. package/lib/hooks/use-unique-menu.d.ts +0 -2
  209. package/lib/hooks/use-unique-menu.js +0 -15
  210. package/lib/hooks/use-widget-event.d.ts +0 -3
  211. package/lib/hooks/use-widget-event.js +0 -21
  212. package/lib/index.d.ts +0 -9
  213. package/lib/index.js +0 -98
  214. package/lib/styles.d.ts +0 -19
  215. package/lib/styles.js +0 -53
  216. package/lib/utils/animations.d.ts +0 -18
  217. package/lib/utils/animations.js +0 -104
  218. package/lib/utils/browser.d.ts +0 -12
  219. package/lib/utils/browser.js +0 -54
  220. package/lib/utils/convert-to-string-attributes.d.ts +0 -2
  221. package/lib/utils/convert-to-string-attributes.js +0 -23
  222. package/lib/utils/create-empty-component.d.ts +0 -3
  223. package/lib/utils/create-empty-component.js +0 -25
  224. package/lib/utils/embedded-link-mapper.d.ts +0 -3
  225. package/lib/utils/embedded-link-mapper.js +0 -62
  226. package/lib/utils/filter-css-props.d.ts +0 -8
  227. package/lib/utils/filter-css-props.js +0 -28
  228. package/lib/utils/generic-hash-link.d.ts +0 -8
  229. package/lib/utils/generic-hash-link.js +0 -70
  230. package/lib/utils/heading-styles.d.ts +0 -1
  231. package/lib/utils/heading-styles.js +0 -48
  232. package/lib/utils/index.d.ts +0 -12
  233. package/lib/utils/index.js +0 -28
  234. package/lib/utils/process-html-string.d.ts +0 -4
  235. package/lib/utils/process-html-string.js +0 -16
  236. package/lib/utils/render-instructions.d.ts +0 -8
  237. package/lib/utils/render-instructions.js +0 -19
  238. package/lib-esm/components/anchor-link.js +0 -5
  239. package/lib-esm/components/button.js +0 -36
  240. package/lib-esm/components/checkbox.js +0 -34
  241. package/lib-esm/components/drawer/drawer.js +0 -121
  242. package/lib-esm/components/drawer/index.js +0 -3
  243. package/lib-esm/components/dropdown/dropdown.js +0 -127
  244. package/lib-esm/components/dropdown/index.js +0 -3
  245. package/lib-esm/components/dropdown/use-position.js +0 -53
  246. package/lib-esm/components/empty.js +0 -35
  247. package/lib-esm/components/grid.js +0 -36
  248. package/lib-esm/components/html.js +0 -53
  249. package/lib-esm/components/icon.js +0 -30
  250. package/lib-esm/components/index.js +0 -30
  251. package/lib-esm/components/input.js +0 -69
  252. package/lib-esm/components/item-list.js +0 -34
  253. package/lib-esm/components/item-tree.js +0 -50
  254. package/lib-esm/components/lightbox.js +0 -64
  255. package/lib-esm/components/link.js +0 -71
  256. package/lib-esm/components/list.js +0 -31
  257. package/lib-esm/components/modal/confirm.js +0 -33
  258. package/lib-esm/components/modal/index.js +0 -3
  259. package/lib-esm/components/modal/modal.js +0 -99
  260. package/lib-esm/components/not-found.js +0 -27
  261. package/lib-esm/components/overlay.js +0 -45
  262. package/lib-esm/components/paragraph.js +0 -38
  263. package/lib-esm/components/portal.js +0 -36
  264. package/lib-esm/components/route-link.js +0 -90
  265. package/lib-esm/components/symbol-badge.js +0 -200
  266. package/lib-esm/components/tab-stop.js +0 -75
  267. package/lib-esm/components/text-link.js +0 -34
  268. package/lib-esm/components/text.js +0 -30
  269. package/lib-esm/components/timestamp.js +0 -33
  270. package/lib-esm/components/tooltip.js +0 -99
  271. package/lib-esm/components/transition-component.js +0 -72
  272. package/lib-esm/components/typography.js +0 -38
  273. package/lib-esm/components/widget-link.js +0 -88
  274. package/lib-esm/contexts/index.js +0 -12
  275. package/lib-esm/create-react-component.js +0 -16
  276. package/lib-esm/hooks/index.js +0 -26
  277. package/lib-esm/hooks/use-action.js +0 -14
  278. package/lib-esm/hooks/use-children.js +0 -65
  279. package/lib-esm/hooks/use-columns.js +0 -4
  280. package/lib-esm/hooks/use-component-descriptor.js +0 -4
  281. package/lib-esm/hooks/use-component-node.js +0 -35
  282. package/lib-esm/hooks/use-component-platform.js +0 -34
  283. package/lib-esm/hooks/use-component.js +0 -52
  284. package/lib-esm/hooks/use-container.js +0 -4
  285. package/lib-esm/hooks/use-context.js +0 -45
  286. package/lib-esm/hooks/use-dispatch.js +0 -59
  287. package/lib-esm/hooks/use-event-listener.js +0 -19
  288. package/lib-esm/hooks/use-events.js +0 -7
  289. package/lib-esm/hooks/use-is-mounted.js +0 -12
  290. package/lib-esm/hooks/use-key-press.js +0 -41
  291. package/lib-esm/hooks/use-layout.js +0 -45
  292. package/lib-esm/hooks/use-previous.js +0 -9
  293. package/lib-esm/hooks/use-properties.js +0 -7
  294. package/lib-esm/hooks/use-render-state.js +0 -65
  295. package/lib-esm/hooks/use-route-data.js +0 -53
  296. package/lib-esm/hooks/use-router.js +0 -7
  297. package/lib-esm/hooks/use-scroll.js +0 -66
  298. package/lib-esm/hooks/use-settings.js +0 -33
  299. package/lib-esm/hooks/use-toggle.js +0 -26
  300. package/lib-esm/hooks/use-transition-end.js +0 -60
  301. package/lib-esm/hooks/use-unique-menu.js +0 -10
  302. package/lib-esm/hooks/use-widget-event.js +0 -16
  303. package/lib-esm/index.js +0 -7
  304. package/lib-esm/styles.js +0 -26
  305. package/lib-esm/utils/animations.js +0 -101
  306. package/lib-esm/utils/browser.js +0 -51
  307. package/lib-esm/utils/convert-to-string-attributes.js +0 -21
  308. package/lib-esm/utils/create-empty-component.js +0 -20
  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.js +0 -63
  312. package/lib-esm/utils/heading-styles.js +0 -44
  313. package/lib-esm/utils/index.js +0 -10
  314. package/lib-esm/utils/process-html-string.js +0 -10
  315. package/lib-esm/utils/render-instructions.js +0 -12
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.genericHashLink = void 0;
29
- var react_1 = __importDefault(require("react"));
30
- var genericHashLink = function (props, As) {
31
- var hashFragment = '';
32
- var reset = function () {
33
- hashFragment = '';
34
- };
35
- var getElementAndScroll = function (scrollFunction) {
36
- var element = document.getElementById(hashFragment);
37
- if (element !== null) {
38
- scrollFunction(element);
39
- reset();
40
- return true;
41
- }
42
- return false;
43
- };
44
- var handleClick = function (e) {
45
- e.preventDefault();
46
- reset();
47
- if (props.onClick)
48
- props.onClick(e);
49
- // try to get hash fragment
50
- if (typeof props.to === 'string') {
51
- hashFragment = props.to.split('#').slice(1).join('#');
52
- }
53
- // if hash fragment is present
54
- if (hashFragment !== '') {
55
- getElementAndScroll(props.scroll ||
56
- (function (el) {
57
- return props.smooth
58
- ? el.scrollIntoView({ behavior: 'smooth' })
59
- : el.scrollIntoView();
60
- }));
61
- }
62
- return false;
63
- };
64
- var scroll = props.scroll, smooth = props.smooth, to = props.to, filteredProps = __rest(props, ["scroll", "smooth", "to"]);
65
- if (As === 'a') {
66
- filteredProps.href = 'javascript:;';
67
- }
68
- return (react_1.default.createElement(As, __assign({}, filteredProps, { onClick: handleClick }), props.children));
69
- };
70
- exports.genericHashLink = genericHashLink;
@@ -1 +0,0 @@
1
- export declare const headingElement: (element: string, style: any) => import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __read = (this && this.__read) || function (o, n) {
7
- var m = typeof Symbol === "function" && o[Symbol.iterator];
8
- if (!m) return o;
9
- var i = m.call(o), r, ar = [], e;
10
- try {
11
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
- }
13
- catch (error) { e = { error: error }; }
14
- finally {
15
- try {
16
- if (r && !r.done && (m = i["return"])) m.call(i);
17
- }
18
- finally { if (e) throw e.error; }
19
- }
20
- return ar;
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.headingElement = void 0;
24
- var styled_components_1 = require("styled-components");
25
- var headingElement = function (element, style) {
26
- var defaultTag = element;
27
- var prefix = '';
28
- if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element)) {
29
- defaultTag = element;
30
- }
31
- else {
32
- var match = element.match(/h1|h2|h3|h4|h5|h6/);
33
- if (match === null || match === void 0 ? void 0 : match[0]) {
34
- defaultTag = match[0];
35
- var _a = __read(element.split(defaultTag), 1), pre = _a[0];
36
- prefix = pre;
37
- }
38
- }
39
- var renderTag = function (element, pre, mapping) {
40
- if (mapping[element]) {
41
- return "".concat(pre).concat(mapping[element]);
42
- }
43
- return "".concat(pre).concat(element);
44
- };
45
- return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", " {\n ", "\n }\n "], ["\n ", " {\n ", "\n }\n "])), function (p) { return renderTag(defaultTag, prefix, p.theme.typographyVariantMapping || {}); }, style);
46
- };
47
- exports.headingElement = headingElement;
48
- var templateObject_1;
@@ -1,12 +0,0 @@
1
- export { transitionComposer } from './animations';
2
- export type { TransitionStateSettings } from './animations';
3
- export { Browsers, default as browser } from './browser';
4
- export { default as convertToStringAttributes } from './convert-to-string-attributes';
5
- export { default as createEmptyComponent } from './create-empty-component';
6
- export { default as embeddedLinkMapper } from './embedded-link-mapper';
7
- export { default as filterCssProps, filterCssPropsStyle } from './filter-css-props';
8
- export { genericHashLink } from './generic-hash-link';
9
- export type { Props as GenericHashLinkProps } from './generic-hash-link';
10
- export { headingElement } from './heading-styles';
11
- export { default as processHtmlString } from './process-html-string';
12
- export { defaultRenderInstructions } from './render-instructions';
@@ -1,28 +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
- exports.defaultRenderInstructions = exports.processHtmlString = exports.headingElement = exports.genericHashLink = exports.filterCssPropsStyle = exports.filterCssProps = exports.embeddedLinkMapper = exports.createEmptyComponent = exports.convertToStringAttributes = exports.browser = exports.Browsers = exports.transitionComposer = void 0;
7
- var animations_1 = require("./animations");
8
- Object.defineProperty(exports, "transitionComposer", { enumerable: true, get: function () { return animations_1.transitionComposer; } });
9
- var browser_1 = require("./browser");
10
- Object.defineProperty(exports, "Browsers", { enumerable: true, get: function () { return browser_1.Browsers; } });
11
- Object.defineProperty(exports, "browser", { enumerable: true, get: function () { return __importDefault(browser_1).default; } });
12
- var convert_to_string_attributes_1 = require("./convert-to-string-attributes");
13
- Object.defineProperty(exports, "convertToStringAttributes", { enumerable: true, get: function () { return __importDefault(convert_to_string_attributes_1).default; } });
14
- var create_empty_component_1 = require("./create-empty-component");
15
- Object.defineProperty(exports, "createEmptyComponent", { enumerable: true, get: function () { return __importDefault(create_empty_component_1).default; } });
16
- var embedded_link_mapper_1 = require("./embedded-link-mapper");
17
- Object.defineProperty(exports, "embeddedLinkMapper", { enumerable: true, get: function () { return __importDefault(embedded_link_mapper_1).default; } });
18
- var filter_css_props_1 = require("./filter-css-props");
19
- Object.defineProperty(exports, "filterCssProps", { enumerable: true, get: function () { return __importDefault(filter_css_props_1).default; } });
20
- Object.defineProperty(exports, "filterCssPropsStyle", { enumerable: true, get: function () { return filter_css_props_1.filterCssPropsStyle; } });
21
- var generic_hash_link_1 = require("./generic-hash-link");
22
- Object.defineProperty(exports, "genericHashLink", { enumerable: true, get: function () { return generic_hash_link_1.genericHashLink; } });
23
- var heading_styles_1 = require("./heading-styles");
24
- Object.defineProperty(exports, "headingElement", { enumerable: true, get: function () { return heading_styles_1.headingElement; } });
25
- var process_html_string_1 = require("./process-html-string");
26
- Object.defineProperty(exports, "processHtmlString", { enumerable: true, get: function () { return __importDefault(process_html_string_1).default; } });
27
- var render_instructions_1 = require("./render-instructions");
28
- Object.defineProperty(exports, "defaultRenderInstructions", { enumerable: true, get: function () { return render_instructions_1.defaultRenderInstructions; } });
@@ -1,4 +0,0 @@
1
- /**
2
- * Converts a html chunk to managed React nodes.
3
- */
4
- export default function parseHtmlString(html: any, instruction: any): any;
@@ -1,16 +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 htmr_1 = __importDefault(require("htmr"));
7
- /**
8
- * Converts a html chunk to managed React nodes.
9
- */
10
- function parseHtmlString(html, instruction) {
11
- if (instruction) {
12
- return (0, htmr_1.default)(html, instruction);
13
- }
14
- return (0, htmr_1.default)(html);
15
- }
16
- exports.default = parseHtmlString;
@@ -1,8 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- import React from 'react';
3
- export declare const defaultRenderInstructions: (container: Container) => {
4
- transform: {
5
- a: ({ children, ...props }: any) => JSX.Element;
6
- img: (attrs: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLImageElement>, HTMLImageElement>) => JSX.Element;
7
- };
8
- };
@@ -1,19 +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
- exports.defaultRenderInstructions = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var components_1 = require("../components");
9
- var embedded_link_mapper_1 = __importDefault(require("./embedded-link-mapper"));
10
- var imageLightboxRenderer = function (attrs) { return react_1.default.createElement(components_1.Lightbox, { attrs: attrs }); };
11
- var defaultRenderInstructions = function (container) {
12
- return {
13
- transform: {
14
- a: (0, embedded_link_mapper_1.default)(container),
15
- img: imageLightboxRenderer,
16
- },
17
- };
18
- };
19
- exports.defaultRenderInstructions = defaultRenderInstructions;
@@ -1,5 +0,0 @@
1
- import { genericHashLink } from '../utils';
2
- var AnchorLink = function (props) {
3
- return genericHashLink(props, 'a');
4
- };
5
- export default AnchorLink;
@@ -1,36 +0,0 @@
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
- var __rest = (this && this.__rest) || function (s, e) {
17
- var t = {};
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
- t[p] = s[p];
20
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
- t[p[i]] = s[p[i]];
24
- }
25
- return t;
26
- };
27
- import { appendClassNames } from '@telia-ace/widget-utilities';
28
- import React, { forwardRef } from 'react';
29
- import styled from 'styled-components';
30
- import { convertToStringAttributes } from '../utils';
31
- export default forwardRef(function (_a, ref) {
32
- var className = _a.className, children = _a.children, other = __rest(_a, ["className", "children"]);
33
- return (React.createElement(StyledButton, __assign({ type: "button", className: appendClassNames(className, 'humany-button') }, convertToStringAttributes(other), { ref: ref }), children));
34
- });
35
- var StyledButton = styled.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n -webkit-appearance: button;\n text-transform: none;\n overflow: visible;\n outline: none;\n border: none;\n background-color: transparent;\n cursor: pointer;\n font-family: inherit;\n font-size: inherit;\n line-height: normal;\n margin: 0;\n padding: 0;\n"], ["\n -webkit-appearance: button;\n text-transform: none;\n overflow: visible;\n outline: none;\n border: none;\n background-color: transparent;\n cursor: pointer;\n font-family: inherit;\n font-size: inherit;\n line-height: normal;\n margin: 0;\n padding: 0;\n"])));
36
- var templateObject_1;
@@ -1,34 +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 { appendClassNames } from '@telia-ace/widget-utilities';
24
- import React from 'react';
25
- import { convertToStringAttributes } from '../utils';
26
- var Checkbox = function (_a) {
27
- var _b = _a.onChange, onChange = _b === void 0 ? function () { } : _b, _c = _a.onEnter, onEnter = _c === void 0 ? function () { } : _c, className = _a.className, other = __rest(_a, ["onChange", "onEnter", "className"]);
28
- return (React.createElement("input", __assign({ className: appendClassNames(className, 'humany-checkbox'), onKeyDown: function (e) {
29
- if (e.key === 'Enter') {
30
- onEnter(e);
31
- }
32
- }, onChange: function (e) { return onChange(e.target.value, e.currentTarget.checked); } }, convertToStringAttributes(other))));
33
- };
34
- export default Checkbox;
@@ -1,121 +0,0 @@
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 __read = (this && this.__read) || function (o, n) {
6
- var m = typeof Symbol === "function" && o[Symbol.iterator];
7
- if (!m) return o;
8
- var i = m.call(o), r, ar = [], e;
9
- try {
10
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11
- }
12
- catch (error) { e = { error: error }; }
13
- finally {
14
- try {
15
- if (r && !r.done && (m = i["return"])) m.call(i);
16
- }
17
- finally { if (e) throw e.error; }
18
- }
19
- return ar;
20
- };
21
- var _a;
22
- import { appendClassNames, uuid } from '@telia-ace/widget-utilities';
23
- import React, { useEffect, useRef } from 'react';
24
- import { CSSTransition } from 'react-transition-group';
25
- import styled, { css } from 'styled-components';
26
- import { useEventListener, useKeyPress, usePrevious, useScroll, useToggle, useUniqueMenu, useWidgetEvent, } from '../../hooks';
27
- import { CloseButton } from '../../styles';
28
- import Portal from '../portal';
29
- import SymbolBadge from '../symbol-badge';
30
- import Typography from '../typography';
31
- export var AnimationType;
32
- (function (AnimationType) {
33
- AnimationType["SlideInLeft"] = "slide-in-left";
34
- AnimationType["SlideInRight"] = "slide-in-right";
35
- AnimationType["SlideInBottom"] = "slide-in-bottom";
36
- AnimationType["SlideInTop"] = "slide-in-top";
37
- // Fade = 'fade',
38
- })(AnimationType || (AnimationType = {}));
39
- var defaultDuration = 300;
40
- var Drawer = function (_a) {
41
- var className = _a.className, children = _a.children, header = _a.header, onToggle = _a.onToggle, trigger = _a.trigger, _b = _a.fullScreen, fullScreen = _b === void 0 ? false : _b, closeButtonAriaLabel = _a.closeButtonAriaLabel, _c = _a.animation, animation = _c === void 0 ? {
42
- type: AnimationType.SlideInBottom,
43
- } : _c;
44
- var _d = animation.duration, duration = _d === void 0 ? defaultDuration : _d;
45
- var closeButtonRef = useRef();
46
- var triggerRef = useRef();
47
- var _e = __read(useScroll(true), 2), css = _e[0], ref = _e[1];
48
- var _f = __read(useToggle(), 2), visible = _f[0], toggleVisible = _f[1];
49
- var previousVisible = usePrevious(visible);
50
- var id = useRef(uuid());
51
- useEffect(function () {
52
- if (onToggle) {
53
- onToggle(visible);
54
- }
55
- }, [visible]);
56
- var esc = useKeyPress('Escape');
57
- useEffect(function () {
58
- if (esc) {
59
- toggleVisible(false);
60
- }
61
- }, [esc]);
62
- useEventListener('click', function (event) {
63
- var target = event.target;
64
- if (!triggerRef.current || !ref.current || !target) {
65
- return;
66
- }
67
- if (triggerRef.current !== target &&
68
- ref.current !== target &&
69
- !ref.current.contains(target) &&
70
- !triggerRef.current.contains(target)) {
71
- toggleVisible(false);
72
- }
73
- }, window);
74
- var closeMenus = useUniqueMenu(id.current, function () {
75
- toggleVisible(false);
76
- });
77
- useWidgetEvent('router:changed', function () {
78
- toggleVisible(false);
79
- });
80
- useEffect(function () {
81
- if (visible && closeButtonRef.current) {
82
- closeButtonRef.current.focus();
83
- }
84
- else if (!visible && triggerRef.current && previousVisible) {
85
- triggerRef.current.focus();
86
- }
87
- }, [visible, closeButtonRef.current, triggerRef.current]);
88
- var WrapperWithAnimation = animations[animation.type];
89
- return (React.createElement(React.Fragment, null,
90
- React.createElement(CSSTransition, { in: visible, className: "humany-drawer-transition", classNames: "humany-drawer-transition", unmountOnExit: true, timeout: duration },
91
- React.createElement(Portal, null,
92
- React.createElement(WrapperWithAnimation, { duration: duration, fullScreen: fullScreen, className: appendClassNames(className, 'humany-drawer', "humany-drawer-".concat(id.current)), clientHeight: document.body.clientHeight, css: css, ref: ref },
93
- React.createElement(CloseButton, { onClick: function () { return toggleVisible(false); }, tabIndex: 0, ref: closeButtonRef, "aria-label": closeButtonAriaLabel },
94
- React.createElement(SymbolBadge, { symbol: { type: 'Svg', content: 'close' } })),
95
- !!header && (React.createElement(Header, { variant: "h1", className: "humany-drawer-header" }, header)),
96
- children))),
97
- React.cloneElement(trigger, {
98
- onClick: function (event) {
99
- toggleVisible();
100
- closeMenus();
101
- },
102
- ref: triggerRef,
103
- 'aria-label': trigger.props.title,
104
- 'aria-expanded': visible,
105
- })));
106
- };
107
- export default Drawer;
108
- var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-family: ", ";\n font-size: ", ";\n position: fixed;\n bottom: 0;\n left: 0;\n border: ", ";\n width: 100%;\n box-shadow: ", ";\n background: #ffffff;\n ", "\n"], ["\n font-family: ", ";\n font-size: ", ";\n position: fixed;\n bottom: 0;\n left: 0;\n border: ", ";\n width: 100%;\n box-shadow: ", ";\n background: #ffffff;\n ", "\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.type; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { return p.theme.border; }, function (p) { return p.theme.boxShadow; }, function (p) { return p.css && p.css; });
109
- var Header = styled(Typography)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: ", ";\n margin: 0;\n text-align: center;\n border-bottom: #eeeeee 1px solid;\n background: #ffffff;\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: bold;\n color: ", ";\n font-size: ", ";\n line-height: 1.2em;\n"], ["\n padding: ", ";\n margin: 0;\n text-align: center;\n border-bottom: #eeeeee 1px solid;\n background: #ffffff;\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: bold;\n color: ", ";\n font-size: ", ";\n line-height: 1.2em;\n"])), function (p) { return p.theme.sizes.normal; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; });
110
- var AnimationBase = css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n transition: ", "ms;\n"], ["\n transition: ", "ms;\n"])), function (p) { return p.duration; });
111
- var WrapperWithSlideInBottom = styled(Wrapper)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n max-height: 0;\n ", "\n\n &.humany-drawer-transition-enter {\n max-height: 0;\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n max-height: ", ";\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n max-height: 0;\n }\n"], ["\n max-height: 0;\n ", "\n\n &.humany-drawer-transition-enter {\n max-height: 0;\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n max-height: ", ";\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n max-height: 0;\n }\n"])), AnimationBase, function (p) { return (p.fullScreen ? '100%' : '400px'); });
112
- var WrapperWithSlideInRight = styled(Wrapper)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n transform: translateX(100%);\n height: ", ";\n\n &.humany-drawer-transition-enter {\n transform: translateX(100%);\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n transform: translateX(0);\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n transform: translateX(100%);\n }\n"], ["\n ", "\n transform: translateX(100%);\n height: ", ";\n\n &.humany-drawer-transition-enter {\n transform: translateX(100%);\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n transform: translateX(0);\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n transform: translateX(100%);\n }\n"])), AnimationBase, function (p) { return (p.fullScreen ? '100%' : 'auto'); });
113
- var WrapperWithSlideInLeft = styled(Wrapper)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n transform: translateX(-100%);\n height: ", ";\n\n &.humany-drawer-transition-enter {\n transform: translateX(-100%);\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n transform: translateX(0);\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n transform: translateX(-100%);\n }\n"], ["\n ", "\n transform: translateX(-100%);\n height: ", ";\n\n &.humany-drawer-transition-enter {\n transform: translateX(-100%);\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n transform: translateX(0);\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n transform: translateX(-100%);\n }\n"])), AnimationBase, function (p) { return (p.fullScreen ? '100%' : 'auto'); });
114
- var WrapperWithSlideInTop = styled(Wrapper)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n bottom: unset;\n top: 0;\n height: 0;\n\n &.humany-drawer-transition-enter {\n height: 0;\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n height: ", "px;\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n height: 0;\n }\n"], ["\n ", "\n bottom: unset;\n top: 0;\n height: 0;\n\n &.humany-drawer-transition-enter {\n height: 0;\n }\n &.humany-drawer-transition-enter-active,\n &.humany-drawer-transition-enter-done,\n &.humany-drawer-transition-exit {\n height: ", "px;\n }\n\n &.humany-drawer-transition-exit-active,\n &.humany-drawer-transition-exit-done {\n height: 0;\n }\n"])), AnimationBase, function (p) { return p.clientHeight; });
115
- var animations = (_a = {},
116
- _a[AnimationType.SlideInBottom] = WrapperWithSlideInBottom,
117
- _a[AnimationType.SlideInRight] = WrapperWithSlideInRight,
118
- _a[AnimationType.SlideInLeft] = WrapperWithSlideInLeft,
119
- _a[AnimationType.SlideInTop] = WrapperWithSlideInTop,
120
- _a);
121
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -1,3 +0,0 @@
1
- import Drawer, { AnimationType } from './drawer';
2
- export { AnimationType };
3
- export default Drawer;
@@ -1,127 +0,0 @@
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
- var __rest = (this && this.__rest) || function (s, e) {
17
- var t = {};
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
- t[p] = s[p];
20
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
- t[p[i]] = s[p[i]];
24
- }
25
- return t;
26
- };
27
- var __read = (this && this.__read) || function (o, n) {
28
- var m = typeof Symbol === "function" && o[Symbol.iterator];
29
- if (!m) return o;
30
- var i = m.call(o), r, ar = [], e;
31
- try {
32
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33
- }
34
- catch (error) { e = { error: error }; }
35
- finally {
36
- try {
37
- if (r && !r.done && (m = i["return"])) m.call(i);
38
- }
39
- finally { if (e) throw e.error; }
40
- }
41
- return ar;
42
- };
43
- import { appendClassNames, uuid } from '@telia-ace/widget-utilities';
44
- import React, { useCallback, useEffect, useImperativeHandle, useRef, useState, } from 'react';
45
- import styled from 'styled-components';
46
- import { useEventListener, useKeyPress, usePrevious, useUniqueMenu, useWidgetEvent, } from '../../hooks';
47
- import { CloseButton, contentBox } from '../../styles';
48
- import Portal from '../portal';
49
- import SymbolBadge from '../symbol-badge';
50
- import usePosition from './use-position';
51
- var Dropdown = React.forwardRef(function (_a, ref) {
52
- var _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.children, children = _c === void 0 ? null : _c, trigger = _a.trigger, closeButtonAriaLabel = _a.closeButtonAriaLabel, props = __rest(_a, ["className", "children", "trigger", "closeButtonAriaLabel"]);
53
- var closeButtonRef = useRef();
54
- var triggerRef = useRef();
55
- var innerRef = useRef();
56
- useImperativeHandle(ref, function () { return innerRef.current; }, [innerRef.current]);
57
- var id = useRef(uuid());
58
- var _d = __read(useState(false), 2), visible = _d[0], setVisible = _d[1];
59
- var previousVisible = usePrevious(visible);
60
- var _e = __read(usePosition(visible, id.current, innerRef.current), 2), _f = _e[0], x = _f.x, y = _f.y, set = _e[1];
61
- var esc = useKeyPress('Escape');
62
- useEffect(function () {
63
- if (esc) {
64
- setVisible(false);
65
- }
66
- }, [esc]);
67
- useEffect(function () {
68
- if (visible && closeButtonRef.current) {
69
- closeButtonRef.current.focus();
70
- }
71
- else if (!visible && triggerRef.current && previousVisible) {
72
- triggerRef.current.focus();
73
- }
74
- }, [visible, closeButtonRef.current, triggerRef.current]);
75
- useEventListener('click', function (event) {
76
- var target = event.target;
77
- if (!innerRef.current || !target) {
78
- return;
79
- }
80
- if (innerRef.current !== target && !innerRef.current.contains(target)) {
81
- setVisible(false);
82
- }
83
- }, window);
84
- useWidgetEvent('router:changed', function () {
85
- setVisible(false);
86
- });
87
- var closeMenus = useUniqueMenu(id.current, function () {
88
- setVisible(false);
89
- });
90
- var onTriggerClick = useCallback(function (event) {
91
- event.stopPropagation();
92
- set(event, triggerRef.current);
93
- setVisible(!visible);
94
- closeMenus();
95
- }, [closeMenus, set, setVisible]);
96
- return (React.createElement(React.Fragment, null,
97
- visible && (React.createElement(Portal, null,
98
- React.createElement(StyledDropdown, __assign({ className: appendClassNames('humany-dropdown', "humany-dropdown-".concat(id.current), className) }, props, { x: x, y: y, ref: innerRef }),
99
- React.createElement(CloseButton, { onClick: function () { return setVisible(false); }, tabIndex: 0, ref: closeButtonRef, "aria-label": closeButtonAriaLabel },
100
- React.createElement(SymbolBadge, { symbol: { type: 'Svg', content: 'close' } })),
101
- children))),
102
- React.cloneElement(trigger, {
103
- onClick: onTriggerClick,
104
- ref: triggerRef,
105
- 'aria-label': trigger.props.title,
106
- 'aria-expanded': visible,
107
- })));
108
- });
109
- export default Dropdown;
110
- var StyledDropdown = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n padding: ", ";\n min-width: 150px;\n position: absolute;\n box-shadow: ", ";\n\n ", ";\n"], ["\n ", "\n padding: ", ";\n min-width: 150px;\n position: absolute;\n box-shadow: ", ";\n\n ", ";\n"])), contentBox, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { return p.theme.boxShadow; }, function (p) {
111
- var _a, _b, _c;
112
- var css = '';
113
- if (p.y > 0) {
114
- css += "top: calc(".concat(((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small) || '0px', " + ").concat(p.y || '0', "px);");
115
- }
116
- else {
117
- css += "bottom: ".concat(((_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.normal) || '0px', ";");
118
- }
119
- if (p.x > 0) {
120
- css += "right: ".concat(p.x || '0', "px;");
121
- }
122
- else {
123
- css += "left: ".concat(((_c = p.theme.sizes) === null || _c === void 0 ? void 0 : _c.normal) || '0px', ";");
124
- }
125
- return css;
126
- });
127
- var templateObject_1;
@@ -1,3 +0,0 @@
1
- import Dropdown from './dropdown';
2
- export { default as useCursorPosition } from './use-position';
3
- export default Dropdown;
@@ -1,53 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- import { useCallback, useEffect, useState } from 'react';
18
- export var usePosition = function (visible, id, element) {
19
- var _a = __read(useState(0), 2), posX = _a[0], setPosX = _a[1];
20
- var _b = __read(useState(0), 2), posY = _b[0], setPosY = _b[1];
21
- var set = useCallback(function (event, trigger) {
22
- event.preventDefault();
23
- if (trigger) {
24
- var clientRect = trigger.getBoundingClientRect();
25
- setPosX(Math.max(document.body.clientWidth - clientRect.right, 1));
26
- setPosY(clientRect.bottom + window.scrollY);
27
- }
28
- }, [posX, posY, setPosX, setPosY]);
29
- useEffect(function () {
30
- if (!element || !visible) {
31
- return;
32
- }
33
- var clientRect = element.getBoundingClientRect();
34
- var newPos = {
35
- x: posX,
36
- y: posY,
37
- };
38
- if (clientRect.left < 0) {
39
- newPos.x = 0;
40
- }
41
- if (clientRect.bottom > window.innerHeight) {
42
- newPos.y = 0;
43
- }
44
- if (newPos.x !== posX) {
45
- setPosX(newPos.x);
46
- }
47
- if (newPos.y !== posY) {
48
- setPosY(newPos.y);
49
- }
50
- }, [element, visible, id]);
51
- return [{ x: posX, y: posY }, set];
52
- };
53
- export default usePosition;