@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
package/LICENSE.txt ADDED
@@ -0,0 +1,6 @@
1
+ Copyright © 2021, Telia Company AB. All rights reserved.
2
+
3
+ THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
4
+ THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
5
+ AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
6
+ http://www.humany.com/legal
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # `@telia-ace/widget-ui`
2
+
3
+ Generic UI components for ACE widgets.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { GenericHashLinkProps } from '../utils';
3
+ declare const AnchorLink: React.SFC<GenericHashLinkProps>;
4
+ export default AnchorLink;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var utils_1 = require("../utils");
4
+ var AnchorLink = function (props) {
5
+ return (0, utils_1.genericHashLink)(props, 'a');
6
+ };
7
+ exports.default = AnchorLink;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare type Props = React.ComponentProps<'button'>;
3
+ declare const _default: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & React.RefAttributes<HTMLButtonElement>>;
4
+ export default _default;
@@ -0,0 +1,64 @@
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 __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __rest = (this && this.__rest) || function (s, e) {
41
+ var t = {};
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
+ t[p] = s[p];
44
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
+ t[p[i]] = s[p[i]];
48
+ }
49
+ return t;
50
+ };
51
+ var __importDefault = (this && this.__importDefault) || function (mod) {
52
+ return (mod && mod.__esModule) ? mod : { "default": mod };
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ var widget_utilities_1 = require("@telia-ace/widget-utilities");
56
+ var react_1 = __importStar(require("react"));
57
+ var styled_components_1 = __importDefault(require("styled-components"));
58
+ var utils_1 = require("../utils");
59
+ exports.default = (0, react_1.forwardRef)(function (_a, ref) {
60
+ var className = _a.className, children = _a.children, other = __rest(_a, ["className", "children"]);
61
+ return (react_1.default.createElement(StyledButton, __assign({ type: "button", className: (0, widget_utilities_1.appendClassNames)(className, 'humany-button') }, (0, utils_1.convertToStringAttributes)(other), { ref: ref }), children));
62
+ });
63
+ var StyledButton = styled_components_1.default.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"])));
64
+ var templateObject_1;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare type Props = Merge<React.ComponentProps<'input'>, {
3
+ onChange?: (value: string, checked: boolean) => void;
4
+ onEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
5
+ }>;
6
+ declare const Checkbox: React.SFC<Props>;
7
+ export default Checkbox;
@@ -0,0 +1,39 @@
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
+ var widget_utilities_1 = require("@telia-ace/widget-utilities");
29
+ var react_1 = __importDefault(require("react"));
30
+ var utils_1 = require("../utils");
31
+ var Checkbox = function (_a) {
32
+ 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"]);
33
+ return (react_1.default.createElement("input", __assign({ className: (0, widget_utilities_1.appendClassNames)(className, 'humany-checkbox'), onKeyDown: function (e) {
34
+ if (e.key === 'Enter') {
35
+ onEnter(e);
36
+ }
37
+ }, onChange: function (e) { return onChange(e.target.value, e.currentTarget.checked); } }, (0, utils_1.convertToStringAttributes)(other))));
38
+ };
39
+ exports.default = Checkbox;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ export declare enum AnimationType {
3
+ SlideInLeft = "slide-in-left",
4
+ SlideInRight = "slide-in-right",
5
+ SlideInBottom = "slide-in-bottom",
6
+ SlideInTop = "slide-in-top"
7
+ }
8
+ export declare type Props = {
9
+ header?: string | React.ReactNode;
10
+ className?: string;
11
+ animation?: {
12
+ type: AnimationType;
13
+ duration?: number;
14
+ };
15
+ trigger: React.ReactElement;
16
+ fullScreen?: boolean;
17
+ closeButtonAriaLabel?: string;
18
+ onToggle?: (visible: boolean) => void;
19
+ };
20
+ declare const Drawer: React.FC<Props>;
21
+ export default Drawer;
@@ -0,0 +1,150 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || function (mod) {
23
+ if (mod && mod.__esModule) return mod;
24
+ var result = {};
25
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
+ __setModuleDefault(result, mod);
27
+ return result;
28
+ };
29
+ var __read = (this && this.__read) || function (o, n) {
30
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
31
+ if (!m) return o;
32
+ var i = m.call(o), r, ar = [], e;
33
+ try {
34
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
35
+ }
36
+ catch (error) { e = { error: error }; }
37
+ finally {
38
+ try {
39
+ if (r && !r.done && (m = i["return"])) m.call(i);
40
+ }
41
+ finally { if (e) throw e.error; }
42
+ }
43
+ return ar;
44
+ };
45
+ var __importDefault = (this && this.__importDefault) || function (mod) {
46
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
+ };
48
+ var _a;
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.AnimationType = void 0;
51
+ var widget_utilities_1 = require("@telia-ace/widget-utilities");
52
+ var react_1 = __importStar(require("react"));
53
+ var react_transition_group_1 = require("react-transition-group");
54
+ var styled_components_1 = __importStar(require("styled-components"));
55
+ var hooks_1 = require("../../hooks");
56
+ var styles_1 = require("../../styles");
57
+ var portal_1 = __importDefault(require("../portal"));
58
+ var symbol_badge_1 = __importDefault(require("../symbol-badge"));
59
+ var typography_1 = __importDefault(require("../typography"));
60
+ var AnimationType;
61
+ (function (AnimationType) {
62
+ AnimationType["SlideInLeft"] = "slide-in-left";
63
+ AnimationType["SlideInRight"] = "slide-in-right";
64
+ AnimationType["SlideInBottom"] = "slide-in-bottom";
65
+ AnimationType["SlideInTop"] = "slide-in-top";
66
+ // Fade = 'fade',
67
+ })(AnimationType = exports.AnimationType || (exports.AnimationType = {}));
68
+ var defaultDuration = 300;
69
+ var Drawer = function (_a) {
70
+ 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 ? {
71
+ type: AnimationType.SlideInBottom,
72
+ } : _c;
73
+ var _d = animation.duration, duration = _d === void 0 ? defaultDuration : _d;
74
+ var closeButtonRef = (0, react_1.useRef)();
75
+ var triggerRef = (0, react_1.useRef)();
76
+ var _e = __read((0, hooks_1.useScroll)(true), 2), css = _e[0], ref = _e[1];
77
+ var _f = __read((0, hooks_1.useToggle)(), 2), visible = _f[0], toggleVisible = _f[1];
78
+ var previousVisible = (0, hooks_1.usePrevious)(visible);
79
+ var id = (0, react_1.useRef)((0, widget_utilities_1.uuid)());
80
+ (0, react_1.useEffect)(function () {
81
+ if (onToggle) {
82
+ onToggle(visible);
83
+ }
84
+ }, [visible]);
85
+ var esc = (0, hooks_1.useKeyPress)('Escape');
86
+ (0, react_1.useEffect)(function () {
87
+ if (esc) {
88
+ toggleVisible(false);
89
+ }
90
+ }, [esc]);
91
+ (0, hooks_1.useEventListener)('click', function (event) {
92
+ var target = event.target;
93
+ if (!triggerRef.current || !ref.current || !target) {
94
+ return;
95
+ }
96
+ if (triggerRef.current !== target &&
97
+ ref.current !== target &&
98
+ !ref.current.contains(target) &&
99
+ !triggerRef.current.contains(target)) {
100
+ toggleVisible(false);
101
+ }
102
+ }, window);
103
+ var closeMenus = (0, hooks_1.useUniqueMenu)(id.current, function () {
104
+ toggleVisible(false);
105
+ });
106
+ (0, hooks_1.useWidgetEvent)('router:changed', function () {
107
+ toggleVisible(false);
108
+ });
109
+ (0, react_1.useEffect)(function () {
110
+ if (visible && closeButtonRef.current) {
111
+ closeButtonRef.current.focus();
112
+ }
113
+ else if (!visible && triggerRef.current && previousVisible) {
114
+ triggerRef.current.focus();
115
+ }
116
+ }, [visible, closeButtonRef.current, triggerRef.current]);
117
+ var WrapperWithAnimation = animations[animation.type];
118
+ return (react_1.default.createElement(react_1.default.Fragment, null,
119
+ react_1.default.createElement(react_transition_group_1.CSSTransition, { in: visible, className: "humany-drawer-transition", classNames: "humany-drawer-transition", unmountOnExit: true, timeout: duration },
120
+ react_1.default.createElement(portal_1.default, null,
121
+ react_1.default.createElement(WrapperWithAnimation, { duration: duration, fullScreen: fullScreen, className: (0, widget_utilities_1.appendClassNames)(className, 'humany-drawer', "humany-drawer-".concat(id.current)), clientHeight: document.body.clientHeight, css: css, ref: ref },
122
+ react_1.default.createElement(styles_1.CloseButton, { onClick: function () { return toggleVisible(false); }, tabIndex: 0, ref: closeButtonRef, "aria-label": closeButtonAriaLabel },
123
+ react_1.default.createElement(symbol_badge_1.default, { symbol: { type: 'Svg', content: 'close' } })),
124
+ !!header && (react_1.default.createElement(Header, { variant: "h1", className: "humany-drawer-header" }, header)),
125
+ children))),
126
+ react_1.default.cloneElement(trigger, {
127
+ onClick: function (event) {
128
+ toggleVisible();
129
+ closeMenus();
130
+ },
131
+ ref: triggerRef,
132
+ 'aria-label': trigger.props.title,
133
+ 'aria-expanded': visible,
134
+ })));
135
+ };
136
+ exports.default = Drawer;
137
+ var Wrapper = styled_components_1.default.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; });
138
+ var Header = (0, styled_components_1.default)(typography_1.default)(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; });
139
+ var AnimationBase = (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n transition: ", "ms;\n"], ["\n transition: ", "ms;\n"])), function (p) { return p.duration; });
140
+ var WrapperWithSlideInBottom = (0, styled_components_1.default)(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'); });
141
+ var WrapperWithSlideInRight = (0, styled_components_1.default)(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'); });
142
+ var WrapperWithSlideInLeft = (0, styled_components_1.default)(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'); });
143
+ var WrapperWithSlideInTop = (0, styled_components_1.default)(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; });
144
+ var animations = (_a = {},
145
+ _a[AnimationType.SlideInBottom] = WrapperWithSlideInBottom,
146
+ _a[AnimationType.SlideInRight] = WrapperWithSlideInRight,
147
+ _a[AnimationType.SlideInLeft] = WrapperWithSlideInLeft,
148
+ _a[AnimationType.SlideInTop] = WrapperWithSlideInTop,
149
+ _a);
150
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -0,0 +1,3 @@
1
+ import Drawer, { AnimationType } from './drawer';
2
+ export { AnimationType };
3
+ export default Drawer;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.AnimationType = void 0;
27
+ var drawer_1 = __importStar(require("./drawer"));
28
+ Object.defineProperty(exports, "AnimationType", { enumerable: true, get: function () { return drawer_1.AnimationType; } });
29
+ exports.default = drawer_1.default;
@@ -0,0 +1,9 @@
1
+ import React, { ReactElement } from 'react';
2
+ export declare type Props = {
3
+ className?: string;
4
+ children?: any;
5
+ trigger: ReactElement;
6
+ closeButtonAriaLabel?: string;
7
+ };
8
+ declare const Dropdown: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
9
+ export default Dropdown;
@@ -0,0 +1,155 @@
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 __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __rest = (this && this.__rest) || function (s, e) {
41
+ var t = {};
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
+ t[p] = s[p];
44
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
+ t[p[i]] = s[p[i]];
48
+ }
49
+ return t;
50
+ };
51
+ var __read = (this && this.__read) || function (o, n) {
52
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
53
+ if (!m) return o;
54
+ var i = m.call(o), r, ar = [], e;
55
+ try {
56
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
57
+ }
58
+ catch (error) { e = { error: error }; }
59
+ finally {
60
+ try {
61
+ if (r && !r.done && (m = i["return"])) m.call(i);
62
+ }
63
+ finally { if (e) throw e.error; }
64
+ }
65
+ return ar;
66
+ };
67
+ var __importDefault = (this && this.__importDefault) || function (mod) {
68
+ return (mod && mod.__esModule) ? mod : { "default": mod };
69
+ };
70
+ Object.defineProperty(exports, "__esModule", { value: true });
71
+ var widget_utilities_1 = require("@telia-ace/widget-utilities");
72
+ var react_1 = __importStar(require("react"));
73
+ var styled_components_1 = __importDefault(require("styled-components"));
74
+ var hooks_1 = require("../../hooks");
75
+ var styles_1 = require("../../styles");
76
+ var portal_1 = __importDefault(require("../portal"));
77
+ var symbol_badge_1 = __importDefault(require("../symbol-badge"));
78
+ var use_position_1 = __importDefault(require("./use-position"));
79
+ var Dropdown = react_1.default.forwardRef(function (_a, ref) {
80
+ 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"]);
81
+ var closeButtonRef = (0, react_1.useRef)();
82
+ var triggerRef = (0, react_1.useRef)();
83
+ var innerRef = (0, react_1.useRef)();
84
+ (0, react_1.useImperativeHandle)(ref, function () { return innerRef.current; }, [innerRef.current]);
85
+ var id = (0, react_1.useRef)((0, widget_utilities_1.uuid)());
86
+ var _d = __read((0, react_1.useState)(false), 2), visible = _d[0], setVisible = _d[1];
87
+ var previousVisible = (0, hooks_1.usePrevious)(visible);
88
+ var _e = __read((0, use_position_1.default)(visible, id.current, innerRef.current), 2), _f = _e[0], x = _f.x, y = _f.y, set = _e[1];
89
+ var esc = (0, hooks_1.useKeyPress)('Escape');
90
+ (0, react_1.useEffect)(function () {
91
+ if (esc) {
92
+ setVisible(false);
93
+ }
94
+ }, [esc]);
95
+ (0, react_1.useEffect)(function () {
96
+ if (visible && closeButtonRef.current) {
97
+ closeButtonRef.current.focus();
98
+ }
99
+ else if (!visible && triggerRef.current && previousVisible) {
100
+ triggerRef.current.focus();
101
+ }
102
+ }, [visible, closeButtonRef.current, triggerRef.current]);
103
+ (0, hooks_1.useEventListener)('click', function (event) {
104
+ var target = event.target;
105
+ if (!innerRef.current || !target) {
106
+ return;
107
+ }
108
+ if (innerRef.current !== target && !innerRef.current.contains(target)) {
109
+ setVisible(false);
110
+ }
111
+ }, window);
112
+ (0, hooks_1.useWidgetEvent)('router:changed', function () {
113
+ setVisible(false);
114
+ });
115
+ var closeMenus = (0, hooks_1.useUniqueMenu)(id.current, function () {
116
+ setVisible(false);
117
+ });
118
+ var onTriggerClick = (0, react_1.useCallback)(function (event) {
119
+ event.stopPropagation();
120
+ set(event, triggerRef.current);
121
+ setVisible(!visible);
122
+ closeMenus();
123
+ }, [closeMenus, set, setVisible]);
124
+ return (react_1.default.createElement(react_1.default.Fragment, null,
125
+ visible && (react_1.default.createElement(portal_1.default, null,
126
+ react_1.default.createElement(StyledDropdown, __assign({ className: (0, widget_utilities_1.appendClassNames)('humany-dropdown', "humany-dropdown-".concat(id.current), className) }, props, { x: x, y: y, ref: innerRef }),
127
+ react_1.default.createElement(styles_1.CloseButton, { onClick: function () { return setVisible(false); }, tabIndex: 0, ref: closeButtonRef, "aria-label": closeButtonAriaLabel },
128
+ react_1.default.createElement(symbol_badge_1.default, { symbol: { type: 'Svg', content: 'close' } })),
129
+ children))),
130
+ react_1.default.cloneElement(trigger, {
131
+ onClick: onTriggerClick,
132
+ ref: triggerRef,
133
+ 'aria-label': trigger.props.title,
134
+ 'aria-expanded': visible,
135
+ })));
136
+ });
137
+ exports.default = Dropdown;
138
+ var StyledDropdown = styled_components_1.default.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"])), styles_1.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) {
139
+ var _a, _b, _c;
140
+ var css = '';
141
+ if (p.y > 0) {
142
+ css += "top: calc(".concat(((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small) || '0px', " + ").concat(p.y || '0', "px);");
143
+ }
144
+ else {
145
+ css += "bottom: ".concat(((_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.normal) || '0px', ";");
146
+ }
147
+ if (p.x > 0) {
148
+ css += "right: ".concat(p.x || '0', "px;");
149
+ }
150
+ else {
151
+ css += "left: ".concat(((_c = p.theme.sizes) === null || _c === void 0 ? void 0 : _c.normal) || '0px', ";");
152
+ }
153
+ return css;
154
+ });
155
+ var templateObject_1;
@@ -0,0 +1,4 @@
1
+ import Dropdown from './dropdown';
2
+ export type { Props } from './dropdown';
3
+ export { default as useCursorPosition } from './use-position';
4
+ export default Dropdown;
@@ -0,0 +1,10 @@
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.useCursorPosition = void 0;
7
+ var dropdown_1 = __importDefault(require("./dropdown"));
8
+ var use_position_1 = require("./use-position");
9
+ Object.defineProperty(exports, "useCursorPosition", { enumerable: true, get: function () { return __importDefault(use_position_1).default; } });
10
+ exports.default = dropdown_1.default;
@@ -0,0 +1,5 @@
1
+ export declare const usePosition: (visible: boolean, id: string, element?: HTMLDivElement | undefined) => [{
2
+ x: number;
3
+ y: number;
4
+ }, (event: React.MouseEvent, trigger?: HTMLElement | undefined) => void];
5
+ export default usePosition;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.usePosition = void 0;
20
+ var react_1 = require("react");
21
+ var usePosition = function (visible, id, element) {
22
+ var _a = __read((0, react_1.useState)(0), 2), posX = _a[0], setPosX = _a[1];
23
+ var _b = __read((0, react_1.useState)(0), 2), posY = _b[0], setPosY = _b[1];
24
+ var set = (0, react_1.useCallback)(function (event, trigger) {
25
+ event.preventDefault();
26
+ if (trigger) {
27
+ var clientRect = trigger.getBoundingClientRect();
28
+ setPosX(Math.max(document.body.clientWidth - clientRect.right, 1));
29
+ setPosY(clientRect.bottom + window.scrollY);
30
+ }
31
+ }, [posX, posY, setPosX, setPosY]);
32
+ (0, react_1.useEffect)(function () {
33
+ if (!element || !visible) {
34
+ return;
35
+ }
36
+ var clientRect = element.getBoundingClientRect();
37
+ var newPos = {
38
+ x: posX,
39
+ y: posY,
40
+ };
41
+ if (clientRect.left < 0) {
42
+ newPos.x = 0;
43
+ }
44
+ if (clientRect.bottom > window.innerHeight) {
45
+ newPos.y = 0;
46
+ }
47
+ if (newPos.x !== posX) {
48
+ setPosX(newPos.x);
49
+ }
50
+ if (newPos.y !== posY) {
51
+ setPosY(newPos.y);
52
+ }
53
+ }, [element, visible, id]);
54
+ return [{ x: posX, y: posY }, set];
55
+ };
56
+ exports.usePosition = usePosition;
57
+ exports.default = exports.usePosition;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare type Props = {};
3
+ declare const Empty: React.SFC<Props>;
4
+ export default Empty;