@reykjavik/hanna-react 0.10.84 → 0.10.85

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 (437) hide show
  1. package/AccordionList.d.ts +2 -2
  2. package/AccordionList.js +5 -5
  3. package/ActionCards.d.ts +2 -2
  4. package/ActionCards.js +4 -4
  5. package/Alert.d.ts +1 -1
  6. package/Alert.js +6 -6
  7. package/ArticleCards.d.ts +1 -1
  8. package/ArticleCards.js +2 -2
  9. package/ArticleCarousel/_ArticleCarouselCard.d.ts +2 -2
  10. package/ArticleCarousel/_ArticleCarouselCard.js +7 -7
  11. package/ArticleCarousel.d.ts +3 -3
  12. package/ArticleCarousel.js +3 -3
  13. package/ArticleMeta.js +2 -2
  14. package/BasicTable.d.ts +1 -1
  15. package/BasicTable.js +2 -2
  16. package/BgBox.d.ts +1 -1
  17. package/BgBox.js +3 -3
  18. package/Bling.js +2 -2
  19. package/BlockQuote.d.ts +1 -1
  20. package/BlockQuote.js +2 -2
  21. package/BreadCrumbs.js +2 -2
  22. package/ButtonBack.d.ts +1 -1
  23. package/ButtonBack.js +2 -2
  24. package/ButtonPrimary.d.ts +1 -1
  25. package/ButtonPrimary.js +2 -2
  26. package/ButtonSecondary.d.ts +1 -1
  27. package/ButtonSecondary.js +2 -2
  28. package/ButtonTertiary.d.ts +1 -1
  29. package/ButtonTertiary.js +2 -2
  30. package/CHANGELOG.md +7 -0
  31. package/Carousel.d.ts +2 -2
  32. package/Carousel.js +2 -2
  33. package/CenterColumn.d.ts +1 -1
  34. package/CenterColumn.js +2 -2
  35. package/Checkbox.d.ts +1 -1
  36. package/Checkbox.js +2 -2
  37. package/CheckboxButton.d.ts +1 -1
  38. package/CheckboxButton.js +2 -2
  39. package/CheckboxButtonsGroup.d.ts +1 -1
  40. package/CheckboxButtonsGroup.js +3 -3
  41. package/CheckboxGroup.d.ts +1 -1
  42. package/CheckboxGroup.js +3 -3
  43. package/CityBlock.d.ts +4 -4
  44. package/CityBlock.js +4 -4
  45. package/ContactBubble.d.ts +1 -1
  46. package/ContactBubble.js +6 -6
  47. package/ContentArticle.d.ts +4 -4
  48. package/ContentArticle.js +14 -14
  49. package/ContentImage.d.ts +1 -1
  50. package/ContentImage.js +2 -2
  51. package/Datepicker.d.ts +1 -1
  52. package/Datepicker.js +2 -2
  53. package/ExtraLinks.d.ts +2 -2
  54. package/ExtraLinks.js +6 -6
  55. package/FeatureList.d.ts +1 -1
  56. package/FeatureList.js +4 -4
  57. package/FileInput.d.ts +2 -2
  58. package/FileInput.js +4 -4
  59. package/Foonote.d.ts +1 -1
  60. package/Foonote.js +2 -2
  61. package/FooterBadges.js +2 -2
  62. package/Form.d.ts +1 -1
  63. package/FormField.d.ts +1 -1
  64. package/FormField.js +4 -4
  65. package/Gallery/_GalleryItem.d.ts +1 -1
  66. package/Gallery/_GalleryItem.js +7 -7
  67. package/Gallery/_GalleryModal.d.ts +1 -1
  68. package/Gallery/_GalleryModal.js +4 -4
  69. package/Gallery/_GalleryModalContext.d.ts +2 -2
  70. package/Gallery/_GalleryModalItem.d.ts +1 -1
  71. package/Gallery/_GalleryModalItem.js +2 -2
  72. package/Gallery.d.ts +4 -4
  73. package/Gallery.js +7 -7
  74. package/GridBlocks.d.ts +3 -3
  75. package/GridBlocks.js +8 -8
  76. package/Heading.d.ts +1 -1
  77. package/HeroBlock.d.ts +3 -3
  78. package/HeroBlock.js +8 -8
  79. package/Illustration.d.ts +1 -1
  80. package/Illustration.js +2 -2
  81. package/ImageCards.d.ts +2 -2
  82. package/ImageCards.js +4 -4
  83. package/InfoBlock.d.ts +1 -1
  84. package/InfoBlock.js +2 -2
  85. package/InfoHero.d.ts +3 -3
  86. package/InfoHero.js +10 -10
  87. package/IslandBlock.d.ts +4 -4
  88. package/IslandBlock.js +4 -4
  89. package/IslandPageBlock.d.ts +4 -4
  90. package/IslandPageBlock.js +4 -4
  91. package/LabeledTextBlock.d.ts +2 -2
  92. package/LabeledTextBlock.js +4 -4
  93. package/Layout.d.ts +1 -1
  94. package/Layout.js +13 -13
  95. package/MainMenu/_Auxiliary.d.ts +1 -1
  96. package/MainMenu/_Auxiliary.js +2 -2
  97. package/MainMenu/_PrimaryPanel.js +2 -2
  98. package/MainMenu.d.ts +3 -3
  99. package/MainMenu.js +15 -13
  100. package/MiniMetrics.d.ts +2 -2
  101. package/MiniMetrics.js +4 -4
  102. package/NameCard.js +4 -4
  103. package/NameCards.d.ts +1 -1
  104. package/NameCards.js +2 -2
  105. package/NewsHero.d.ts +2 -2
  106. package/NewsHero.js +7 -7
  107. package/PageFilter.d.ts +1 -1
  108. package/PageFilter.js +4 -4
  109. package/PageHeading.d.ts +1 -1
  110. package/PageHeading.js +2 -2
  111. package/Picture.d.ts +1 -1
  112. package/Picture.js +2 -2
  113. package/PullQuote.d.ts +1 -1
  114. package/PullQuote.js +2 -2
  115. package/RadioButtonsGroup.d.ts +1 -1
  116. package/RadioButtonsGroup.js +4 -4
  117. package/RadioGroup.d.ts +2 -2
  118. package/RadioGroup.js +4 -4
  119. package/RelatedLinks.js +2 -2
  120. package/RowBlock.d.ts +1 -1
  121. package/RowBlock.js +2 -2
  122. package/SearchInput.d.ts +1 -1
  123. package/SearchInput.js +2 -2
  124. package/SearchResults/_SearchResultsItem.js +4 -4
  125. package/SearchResults.d.ts +2 -2
  126. package/SearchResults.js +7 -7
  127. package/SeenEffect.d.ts +1 -1
  128. package/SeenEffect.js +3 -3
  129. package/Selectbox.d.ts +2 -2
  130. package/Selectbox.js +2 -2
  131. package/ShareButtons.d.ts +1 -1
  132. package/ShareButtons.js +2 -2
  133. package/SiteSearchAutocomplete.js +2 -2
  134. package/SiteSearchCurtain.js +2 -2
  135. package/SiteSearchInput.d.ts +2 -2
  136. package/SiteSearchInput.js +2 -2
  137. package/SubHeading.d.ts +2 -2
  138. package/SubHeading.js +2 -2
  139. package/Tabs.d.ts +2 -2
  140. package/Tabs.js +4 -4
  141. package/TagPill.d.ts +1 -1
  142. package/TagPill.js +3 -3
  143. package/TextBlock.d.ts +2 -2
  144. package/TextBlock.js +2 -2
  145. package/TextButton.d.ts +1 -1
  146. package/TextButton.js +2 -2
  147. package/TextInput.d.ts +1 -1
  148. package/TextInput.js +2 -2
  149. package/VerticalTabsTOC.d.ts +1 -1
  150. package/VerticalTabsTOC.js +2 -2
  151. package/WizardLayout.d.ts +1 -1
  152. package/WizardLayout.js +8 -8
  153. package/WizardLayoutClose.d.ts +1 -1
  154. package/WizardLayoutClose.js +2 -2
  155. package/_abstract/_AbstractCarousel.d.ts +2 -2
  156. package/_abstract/_AbstractCarousel.js +6 -6
  157. package/_abstract/_Blings.d.ts +1 -1
  158. package/_abstract/_Blings.js +2 -2
  159. package/_abstract/_Block.d.ts +3 -3
  160. package/_abstract/_Block.js +6 -6
  161. package/_abstract/_Button.js +2 -2
  162. package/_abstract/_CardList.d.ts +1 -1
  163. package/_abstract/_CardList.js +4 -4
  164. package/_abstract/_Image.js +2 -2
  165. package/_abstract/_Quote.js +2 -2
  166. package/_abstract/_TogglerGroup.d.ts +2 -2
  167. package/_abstract/_TogglerGroup.js +2 -2
  168. package/_abstract/_TogglerGroupField.d.ts +3 -3
  169. package/_abstract/_TogglerGroupField.js +4 -4
  170. package/assets.d.ts +2 -2
  171. package/esm/AccordionList.d.ts +25 -0
  172. package/esm/AccordionList.js +32 -0
  173. package/esm/ActionCards.d.ts +6 -0
  174. package/esm/ActionCards.js +9 -0
  175. package/esm/Alert.d.ts +48 -0
  176. package/esm/Alert.js +90 -0
  177. package/esm/ArticleCards.d.ts +8 -0
  178. package/esm/ArticleCards.js +4 -0
  179. package/esm/ArticleCarousel/_ArticleCarouselCard.d.ts +28 -0
  180. package/esm/ArticleCarousel/_ArticleCarouselCard.js +24 -0
  181. package/esm/ArticleCarousel.d.ts +12 -0
  182. package/esm/ArticleCarousel.js +8 -0
  183. package/esm/ArticleMeta.d.ts +10 -0
  184. package/esm/ArticleMeta.js +19 -0
  185. package/esm/Attention.d.ts +7 -0
  186. package/esm/Attention.js +4 -0
  187. package/esm/BasicTable.d.ts +14 -0
  188. package/esm/BasicTable.js +29 -0
  189. package/esm/BgBox.d.ts +8 -0
  190. package/esm/BgBox.js +9 -0
  191. package/esm/Bling.d.ts +81 -0
  192. package/esm/Bling.js +44 -0
  193. package/esm/BlockBreak.d.ts +2 -0
  194. package/esm/BlockBreak.js +6 -0
  195. package/esm/BlockQuote.d.ts +4 -0
  196. package/esm/BlockQuote.js +4 -0
  197. package/esm/BreadCrumbs.d.ts +11 -0
  198. package/esm/BreadCrumbs.js +28 -0
  199. package/esm/ButtonBack.d.ts +7 -0
  200. package/esm/ButtonBack.js +4 -0
  201. package/esm/ButtonBar.d.ts +17 -0
  202. package/esm/ButtonBar.js +15 -0
  203. package/esm/ButtonPrimary.d.ts +7 -0
  204. package/esm/ButtonPrimary.js +4 -0
  205. package/esm/ButtonSecondary.d.ts +7 -0
  206. package/esm/ButtonSecondary.js +4 -0
  207. package/esm/ButtonTertiary.d.ts +12 -0
  208. package/esm/ButtonTertiary.js +15 -0
  209. package/esm/Carousel.d.ts +4 -0
  210. package/esm/Carousel.js +4 -0
  211. package/esm/CarouselStepper.d.ts +4 -0
  212. package/esm/CarouselStepper.js +4 -0
  213. package/esm/CenterColumn.d.ts +7 -0
  214. package/esm/CenterColumn.js +7 -0
  215. package/esm/Checkbox.d.ts +4 -0
  216. package/esm/Checkbox.js +4 -0
  217. package/esm/CheckboxButton.d.ts +4 -0
  218. package/esm/CheckboxButton.js +4 -0
  219. package/esm/CheckboxButtonsGroup.d.ts +12 -0
  220. package/esm/CheckboxButtonsGroup.js +13 -0
  221. package/esm/CheckboxGroup.d.ts +10 -0
  222. package/esm/CheckboxGroup.js +7 -0
  223. package/esm/CityBlock.d.ts +21 -0
  224. package/esm/CityBlock.js +18 -0
  225. package/esm/ContactBubble.d.ts +58 -0
  226. package/esm/ContactBubble.js +152 -0
  227. package/esm/ContentArticle.d.ts +16 -0
  228. package/esm/ContentArticle.js +24 -0
  229. package/esm/ContentImage.d.ts +8 -0
  230. package/esm/ContentImage.js +18 -0
  231. package/esm/Datepicker.d.ts +40 -0
  232. package/esm/Datepicker.js +78 -0
  233. package/esm/ExtraLinks.d.ts +18 -0
  234. package/esm/ExtraLinks.js +24 -0
  235. package/esm/FeatureList.d.ts +12 -0
  236. package/esm/FeatureList.js +16 -0
  237. package/esm/FieldGroup.d.ts +10 -0
  238. package/esm/FieldGroup.js +9 -0
  239. package/esm/FileInput/_FileInput.utils.d.ts +36 -0
  240. package/esm/FileInput/_FileInput.utils.js +69 -0
  241. package/esm/FileInput/_FileInputFileList.d.ts +11 -0
  242. package/esm/FileInput/_FileInputFileList.js +19 -0
  243. package/esm/FileInput.d.ts +48 -0
  244. package/esm/FileInput.js +130 -0
  245. package/esm/Foonote.d.ts +12 -0
  246. package/esm/Foonote.js +7 -0
  247. package/esm/FooterBadges.d.ts +9 -0
  248. package/esm/FooterBadges.js +12 -0
  249. package/esm/FooterInfo.d.ts +20 -0
  250. package/esm/FooterInfo.js +12 -0
  251. package/esm/Footnote.d.ts +6 -0
  252. package/esm/Footnote.js +3 -0
  253. package/esm/Form.d.ts +7 -0
  254. package/esm/Form.js +10 -0
  255. package/esm/FormField.d.ts +65 -0
  256. package/esm/FormField.js +92 -0
  257. package/esm/Gallery/_GalleryItem.d.ts +7 -0
  258. package/esm/Gallery/_GalleryItem.js +19 -0
  259. package/esm/Gallery/_GalleryModal.d.ts +6 -0
  260. package/esm/Gallery/_GalleryModal.js +53 -0
  261. package/esm/Gallery/_GalleryModalContext.d.ts +9 -0
  262. package/esm/Gallery/_GalleryModalContext.js +2 -0
  263. package/esm/Gallery/_GalleryModalItem.d.ts +2 -0
  264. package/esm/Gallery/_GalleryModalItem.js +11 -0
  265. package/esm/Gallery.d.ts +17 -0
  266. package/esm/Gallery.js +27 -0
  267. package/esm/GridBlocks.d.ts +26 -0
  268. package/esm/GridBlocks.js +24 -0
  269. package/esm/Heading.d.ts +22 -0
  270. package/esm/Heading.js +19 -0
  271. package/esm/HeroBlock.d.ts +19 -0
  272. package/esm/HeroBlock.js +21 -0
  273. package/esm/IframeBlock.d.ts +28 -0
  274. package/esm/IframeBlock.js +26 -0
  275. package/esm/Illustration.d.ts +10 -0
  276. package/esm/Illustration.js +8 -0
  277. package/esm/ImageCards.d.ts +10 -0
  278. package/esm/ImageCards.js +12 -0
  279. package/esm/InfoBlock.d.ts +13 -0
  280. package/esm/InfoBlock.js +13 -0
  281. package/esm/InfoHero.d.ts +18 -0
  282. package/esm/InfoHero.js +83 -0
  283. package/esm/IslandBlock.d.ts +25 -0
  284. package/esm/IslandBlock.js +16 -0
  285. package/esm/IslandPageBlock.d.ts +24 -0
  286. package/esm/IslandPageBlock.js +16 -0
  287. package/esm/LabeledTextBlock.d.ts +11 -0
  288. package/esm/LabeledTextBlock.js +14 -0
  289. package/esm/Layout.d.ts +32 -0
  290. package/esm/Layout.js +56 -0
  291. package/esm/MainMenu/_Auxiliary.d.ts +6 -0
  292. package/esm/MainMenu/_Auxiliary.js +13 -0
  293. package/esm/MainMenu/_PrimaryPanel.d.ts +29 -0
  294. package/esm/MainMenu/_PrimaryPanel.js +22 -0
  295. package/esm/MainMenu.d.ts +62 -0
  296. package/esm/MainMenu.js +221 -0
  297. package/esm/MiniMetrics.d.ts +8 -0
  298. package/esm/MiniMetrics.js +12 -0
  299. package/esm/Modal.d.ts +8 -0
  300. package/esm/Modal.js +14 -0
  301. package/esm/NameCard.d.ts +64 -0
  302. package/esm/NameCard.js +82 -0
  303. package/esm/NameCards.d.ts +6 -0
  304. package/esm/NameCards.js +7 -0
  305. package/esm/NewsHero.d.ts +14 -0
  306. package/esm/NewsHero.js +86 -0
  307. package/esm/PageFilter.d.ts +16 -0
  308. package/esm/PageFilter.js +15 -0
  309. package/esm/PageHeading.d.ts +10 -0
  310. package/esm/PageHeading.js +12 -0
  311. package/esm/Picture.d.ts +7 -0
  312. package/esm/Picture.js +8 -0
  313. package/esm/ProcessOverview.d.ts +13 -0
  314. package/esm/ProcessOverview.js +17 -0
  315. package/esm/PullQuote.d.ts +4 -0
  316. package/esm/PullQuote.js +4 -0
  317. package/esm/RadioButtonsGroup.d.ts +12 -0
  318. package/esm/RadioButtonsGroup.js +14 -0
  319. package/esm/RadioGroup.d.ts +16 -0
  320. package/esm/RadioGroup.js +8 -0
  321. package/esm/RelatedLinks.d.ts +20 -0
  322. package/esm/RelatedLinks.js +26 -0
  323. package/esm/RowBlock.d.ts +12 -0
  324. package/esm/RowBlock.js +9 -0
  325. package/esm/RowBlockColumn.d.ts +8 -0
  326. package/esm/RowBlockColumn.js +11 -0
  327. package/esm/SearchInput.d.ts +18 -0
  328. package/esm/SearchInput.js +23 -0
  329. package/esm/SearchResults/_SearchResultsItem.d.ts +18 -0
  330. package/esm/SearchResults/_SearchResultsItem.js +14 -0
  331. package/esm/SearchResults.d.ts +37 -0
  332. package/esm/SearchResults.js +108 -0
  333. package/esm/SeenEffect.d.ts +4 -0
  334. package/esm/SeenEffect.js +9 -0
  335. package/esm/Selectbox.d.ts +11 -0
  336. package/esm/Selectbox.js +40 -0
  337. package/esm/ShareButtons.d.ts +9 -0
  338. package/esm/ShareButtons.js +56 -0
  339. package/esm/Sharpie.d.ts +23 -0
  340. package/esm/Sharpie.js +22 -0
  341. package/esm/SiteSearchAutocomplete.d.ts +40 -0
  342. package/esm/SiteSearchAutocomplete.js +48 -0
  343. package/esm/SiteSearchCurtain.d.ts +6 -0
  344. package/esm/SiteSearchCurtain.js +28 -0
  345. package/esm/SiteSearchInput.d.ts +24 -0
  346. package/esm/SiteSearchInput.js +30 -0
  347. package/esm/Skeleton.d.ts +25 -0
  348. package/esm/Skeleton.js +30 -0
  349. package/esm/SubHeading.d.ts +10 -0
  350. package/esm/SubHeading.js +13 -0
  351. package/esm/Tabs.d.ts +35 -0
  352. package/esm/Tabs.js +94 -0
  353. package/esm/TagPill.d.ts +25 -0
  354. package/esm/TagPill.js +34 -0
  355. package/esm/TextBlock.d.ts +15 -0
  356. package/esm/TextBlock.js +15 -0
  357. package/esm/TextButton.d.ts +9 -0
  358. package/esm/TextButton.js +9 -0
  359. package/esm/TextInput.d.ts +16 -0
  360. package/esm/TextInput.js +32 -0
  361. package/esm/Tooltip.d.ts +7 -0
  362. package/esm/Tooltip.js +58 -0
  363. package/esm/VSpacer.d.ts +22 -0
  364. package/esm/VSpacer.js +41 -0
  365. package/esm/VerticalTabsTOC.d.ts +14 -0
  366. package/esm/VerticalTabsTOC.js +68 -0
  367. package/esm/WizardLayout.d.ts +15 -0
  368. package/esm/WizardLayout.js +30 -0
  369. package/esm/WizardLayoutClose.d.ts +3 -0
  370. package/esm/WizardLayoutClose.js +4 -0
  371. package/esm/WizardStepper.d.ts +36 -0
  372. package/esm/WizardStepper.js +26 -0
  373. package/esm/_abstract/_AbstractCarousel.d.ts +29 -0
  374. package/esm/_abstract/_AbstractCarousel.js +108 -0
  375. package/esm/_abstract/_Blings.d.ts +11 -0
  376. package/esm/_abstract/_Blings.js +11 -0
  377. package/esm/_abstract/_Block.d.ts +21 -0
  378. package/esm/_abstract/_Block.js +23 -0
  379. package/esm/_abstract/_Button.d.ts +40 -0
  380. package/esm/_abstract/_Button.js +36 -0
  381. package/esm/_abstract/_CardList.d.ts +34 -0
  382. package/esm/_abstract/_CardList.js +37 -0
  383. package/esm/_abstract/_Image.d.ts +36 -0
  384. package/esm/_abstract/_Image.js +26 -0
  385. package/esm/_abstract/_Link.d.ts +60 -0
  386. package/esm/_abstract/_Link.js +64 -0
  387. package/esm/_abstract/_Quote.d.ts +11 -0
  388. package/esm/_abstract/_Quote.js +8 -0
  389. package/esm/_abstract/_TogglerGroup.d.ts +32 -0
  390. package/esm/_abstract/_TogglerGroup.js +28 -0
  391. package/esm/_abstract/_TogglerGroupField.d.ts +19 -0
  392. package/esm/_abstract/_TogglerGroupField.js +17 -0
  393. package/esm/_abstract/_TogglerInput.d.ts +23 -0
  394. package/esm/_abstract/_TogglerInput.js +23 -0
  395. package/esm/_abstract/breakOnNL.d.ts +1 -0
  396. package/esm/_abstract/breakOnNL.js +7 -0
  397. package/esm/assets.d.ts +42 -0
  398. package/esm/assets.js +58 -0
  399. package/esm/constants.d.ts +19 -0
  400. package/esm/constants.js +22 -0
  401. package/esm/focus-visible.d.ts +1 -0
  402. package/esm/focus-visible.js +3 -0
  403. package/esm/index.d.ts +97 -0
  404. package/esm/index.js +1 -0
  405. package/esm/package.json +1 -0
  406. package/esm/utils/HannaUIState.d.ts +8 -0
  407. package/esm/utils/HannaUIState.js +7 -0
  408. package/esm/utils/browserSide.d.ts +1 -0
  409. package/esm/utils/browserSide.js +1 -0
  410. package/esm/utils/config.d.ts +4 -0
  411. package/esm/utils/config.js +2 -0
  412. package/esm/utils/env.d.ts +1 -0
  413. package/esm/utils/env.js +8 -0
  414. package/esm/utils/seenEffect.d.ts +27 -0
  415. package/esm/utils/seenEffect.js +75 -0
  416. package/esm/utils/useDidChange.d.ts +37 -0
  417. package/esm/utils/useDidChange.js +43 -0
  418. package/esm/utils/useFormatMonitor.d.ts +38 -0
  419. package/esm/utils/useFormatMonitor.js +41 -0
  420. package/esm/utils/useGetSVGtext.d.ts +10 -0
  421. package/esm/utils/useGetSVGtext.js +23 -0
  422. package/esm/utils/useMenuToggling.d.ts +8 -0
  423. package/esm/utils/useMenuToggling.js +62 -0
  424. package/esm/utils/useMixedControlState.d.ts +137 -0
  425. package/esm/utils/useMixedControlState.js +101 -0
  426. package/esm/utils/useScrollbarWidthCSSVar.d.ts +17 -0
  427. package/esm/utils/useScrollbarWidthCSSVar.js +19 -0
  428. package/esm/utils.d.ts +8 -0
  429. package/esm/utils.js +8 -0
  430. package/package.json +389 -3
  431. package/utils/config.d.ts +2 -2
  432. package/utils/config.js +2 -2
  433. package/utils/useDidChange.d.ts +1 -1
  434. package/utils/useDidChange.js +1 -1
  435. package/utils/useMenuToggling.js +2 -2
  436. package/utils.d.ts +8 -8
  437. package/utils.js +8 -8
@@ -0,0 +1,58 @@
1
+ import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
2
+ import { SSRSupport } from './utils.js';
3
+ export type ContactBubbleI18n = {
4
+ lang?: string;
5
+ openBtn: string;
6
+ openBtnLong?: string;
7
+ closeBtn: string;
8
+ closeBtnLong?: string;
9
+ };
10
+ export declare const defaultTexts: DefaultTexts<ContactBubbleI18n>;
11
+ declare const icons: {
12
+ readonly suggestions: 1;
13
+ readonly phone: 1;
14
+ readonly faq: 1;
15
+ readonly livechat: 1;
16
+ readonly other: 0;
17
+ };
18
+ export type ContactBubbleIcon = keyof typeof icons;
19
+ export declare const ensureIcon: (maybeIcon: string | undefined) => ContactBubbleIcon | undefined;
20
+ export type ContactBubbleItem = {
21
+ label: string;
22
+ extraLabel?: string;
23
+ icon?: ContactBubbleIcon;
24
+ } & ({
25
+ href: string;
26
+ /** Prevents default link behavior unless the handler function returns `true` */
27
+ onClick?: () => void | boolean;
28
+ target?: string;
29
+ } | {
30
+ onClick: () => void | boolean;
31
+ href?: undefined;
32
+ target?: undefined;
33
+ });
34
+ export type ContactBubbleProps = {
35
+ title?: string;
36
+ links: Array<ContactBubbleItem>;
37
+ /** By default the ContactBubble's toggler is hidden if the page
38
+ * is scrolled to near the top or the bottom.
39
+ *
40
+ * This means that on short pages (with hardly any scrolling)
41
+ * the ContactBubble **always** hidden.
42
+ *
43
+ * Set this prop to `true` if you want to disable this
44
+ * magic and always show the bubble toggler
45
+ */
46
+ alwaysShow?: boolean;
47
+ texts?: ContactBubbleI18n;
48
+ lang?: string;
49
+ ssr?: SSRSupport;
50
+ } & ({
51
+ open?: boolean;
52
+ onToggle: (isOpen: boolean) => void;
53
+ } | {
54
+ open?: undefined;
55
+ onToggle?: (isOpen: boolean) => void;
56
+ });
57
+ export declare const ContactBubble: (props: ContactBubbleProps) => JSX.Element | null;
58
+ export default ContactBubble;
@@ -0,0 +1,152 @@
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
+ import focusElm from '@hugsmidjan/qj/focusElm';
3
+ import { useDomid } from '@hugsmidjan/react/hooks';
4
+ import getBemClass from '@hugsmidjan/react/utils/getBemClass';
5
+ import { getPageScrollElm } from '@reykjavik/hanna-utils';
6
+ import { getTexts } from '@reykjavik/hanna-utils/i18n';
7
+ import { Link } from './_abstract/_Link.js';
8
+ import { breakOnNL } from './_abstract/breakOnNL.js';
9
+ import { useIsBrowserSide } from './utils.js';
10
+ export const defaultTexts = {
11
+ is: {
12
+ lang: 'is',
13
+ openBtn: 'Hafa samband',
14
+ closeBtn: 'Loka',
15
+ closeBtnLong: 'Loka valmynd',
16
+ },
17
+ en: {
18
+ lang: 'en',
19
+ openBtn: 'Contact us',
20
+ closeBtn: 'Close',
21
+ closeBtnLong: 'Close bubble',
22
+ },
23
+ };
24
+ // ---------------------------------------------------------------------------
25
+ const icons = {
26
+ suggestions: 1,
27
+ phone: 1,
28
+ faq: 1,
29
+ livechat: 1,
30
+ other: 0,
31
+ };
32
+ export const ensureIcon = (maybeIcon) => maybeIcon && icons[maybeIcon]
33
+ ? maybeIcon
34
+ : undefined;
35
+ export const ContactBubble = (props) => {
36
+ const { title, links, onToggle, alwaysShow } = props;
37
+ const txt = getTexts(props, defaultTexts);
38
+ const useLocalState = props.open == null;
39
+ const [localOpen, setLocalOpen] = useState(false);
40
+ const open = useLocalState ? localOpen : props.open;
41
+ const isBrowser = useIsBrowserSide(props.ssr);
42
+ const domid = useDomid();
43
+ const wrapperRef = useRef(null);
44
+ const { openBubble, closeBubble } = useMemo(() => ({
45
+ openBubble: () => {
46
+ useLocalState && setLocalOpen(true);
47
+ onToggle && onToggle(true);
48
+ },
49
+ closeBubble: (setFocus) => {
50
+ useLocalState && setLocalOpen(false);
51
+ onToggle && onToggle(false);
52
+ setFocus !== false && focusElm(wrapperRef.current);
53
+ },
54
+ }), [useLocalState, onToggle]);
55
+ useEffect(() => {
56
+ const wrapperElm = wrapperRef.current;
57
+ if (!wrapperElm) {
58
+ return;
59
+ }
60
+ if (alwaysShow) {
61
+ wrapperElm.dataset.show = 'true';
62
+ return;
63
+ }
64
+ const scrollElm = getPageScrollElm();
65
+ let pending = 0;
66
+ const checkScroll = () => {
67
+ if (!pending) {
68
+ pending = requestAnimationFrame(() => {
69
+ const { scrollTop, scrollHeight, clientHeight } = scrollElm;
70
+ const scrollLength = scrollHeight - clientHeight;
71
+ // const f = scrollLength > 600 ? 1 : (scrollLength - 200) / 600;
72
+ const f = 1;
73
+ const show = scrollTop > f * 150 && scrollLength - scrollTop > f * 250;
74
+ wrapperElm.dataset.show = String(show);
75
+ !show && closeBubble(false);
76
+ pending = 0;
77
+ });
78
+ }
79
+ };
80
+ checkScroll();
81
+ // Set scroll-listeners on both the ´document` and the `scrollElm`
82
+ // because mobile browsers seem to handle CSS height and overflow
83
+ // rules on <html> and <body> differently from desktop browsers.
84
+ // Only one of these two handlers seems to trigger though,
85
+ // (as Element scroll events don't bubble)
86
+ // and even if they did, the rAF throttling prevents that from
87
+ // becoming a problem.
88
+ document.addEventListener('scroll', checkScroll);
89
+ scrollElm.addEventListener('scroll', checkScroll);
90
+ return () => {
91
+ document.removeEventListener('scroll', checkScroll);
92
+ scrollElm.removeEventListener('scroll', checkScroll);
93
+ };
94
+ }, [isBrowser, alwaysShow, closeBubble]);
95
+ useEffect(() => {
96
+ const escHandler = (e) => e.key === 'Escape' && closeBubble();
97
+ const outsideClickHandler = (e) => {
98
+ var _a;
99
+ if (open && !((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
100
+ closeBubble(false);
101
+ }
102
+ };
103
+ document.addEventListener('keydown', escHandler);
104
+ document.addEventListener('click', outsideClickHandler, true);
105
+ const htmlDataset = document.documentElement.dataset;
106
+ if (open) {
107
+ htmlDataset.contactBubble = 'true';
108
+ }
109
+ else {
110
+ delete htmlDataset.contactBubble;
111
+ }
112
+ return () => {
113
+ delete htmlDataset.contactBubble;
114
+ document.removeEventListener('keydown', escHandler);
115
+ document.removeEventListener('click', outsideClickHandler, true);
116
+ };
117
+ }, [open, closeBubble]);
118
+ if (links.length === 0) {
119
+ return null;
120
+ }
121
+ const menu = (React.createElement("div", { className: "ContactBubble", id: isBrowser && domid, hidden: isBrowser && !open, "data-always-show": alwaysShow || undefined, "data-sprinkled": isBrowser },
122
+ React.createElement("h2", { className: "ContactBubble__title" }, title || txt.openBtn),
123
+ React.createElement("ul", { className: "ContactBubble__list" }, links.map((linkInfo, i) => {
124
+ const { href, label, extraLabel, target, onClick } = linkInfo;
125
+ const icon = ensureIcon(linkInfo.icon);
126
+ const itemClass = getBemClass('ContactBubble__item', icon && 'type--' + icon);
127
+ const onClickHandler = (e) => {
128
+ if (onClick) {
129
+ const doPreventDefault = onClick() !== true;
130
+ if (doPreventDefault) {
131
+ e.preventDefault();
132
+ }
133
+ }
134
+ closeBubble(false);
135
+ };
136
+ const content = [
137
+ ' ',
138
+ label,
139
+ '\n',
140
+ extraLabel && React.createElement("small", { key: "\uD83E\uDD21" }, breakOnNL(extraLabel)),
141
+ '\n',
142
+ ];
143
+ return (React.createElement("li", { key: i, className: itemClass }, href && href !== '#' ? (React.createElement(Link, { className: "ContactBubble__link", href: href, onClick: onClickHandler, target: target }, content)) : (React.createElement("button", { className: "ContactBubble__link", onClick: onClickHandler, type: "button" }, content))));
144
+ })),
145
+ '\n\n',
146
+ isBrowser && (React.createElement("button", { className: "ContactBubble__closebtn", "aria-controls": domid, "aria-label": txt.closeBtnLong, onClick: () => closeBubble(), type: "button" }, txt.closeBtn))));
147
+ return isBrowser ? (React.createElement("div", { className: "ContactBubble__wrapper", ref: wrapperRef },
148
+ React.createElement("button", { className: "ContactBubble__openbtn", "aria-controls": domid, "aria-expanded": open, "aria-label": txt.openBtnLong, onClick: open ? () => closeBubble() : openBubble, type: "button" }, txt.openBtn),
149
+ '\n\n',
150
+ menu)) : (menu);
151
+ };
152
+ export default ContactBubble;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ import { SeenProp } from './utils/seenEffect.js';
3
+ import { ArticleMetaProps } from './ArticleMeta.js';
4
+ import { ContentImageProps } from './ContentImage.js';
5
+ import { RelatedLinksProps } from './RelatedLinks.js';
6
+ export type ContentArticleProps = {
7
+ /** Date, author, etc. */
8
+ meta?: ArticleMetaProps['items'];
9
+ headline: string;
10
+ headlineTag?: 'h1' | 'h2';
11
+ topImage?: ContentImageProps;
12
+ body: ReactNode;
13
+ relatedLinks?: RelatedLinksProps;
14
+ } & SeenProp;
15
+ export declare const ContentArticle: (props: ContentArticleProps) => JSX.Element;
16
+ export default ContentArticle;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { useSeenEffect } from './utils/seenEffect.js';
3
+ import ArticleMeta from './ArticleMeta.js';
4
+ import ContentImage from './ContentImage.js';
5
+ import Heading from './Heading.js';
6
+ import RelatedLinks from './RelatedLinks.js';
7
+ import TextBlock from './TextBlock.js';
8
+ import VSpacer from './VSpacer.js';
9
+ export const ContentArticle = (props) => {
10
+ const { relatedLinks } = props;
11
+ const [ref] = useSeenEffect(props.startSeen);
12
+ const headingElm = (React.createElement(Heading, { forceH1: props.headlineTag === 'h1' }, props.headline));
13
+ return (React.createElement("div", { className: "ContentArticle", ref: ref },
14
+ props.meta ? (React.createElement("div", { className: "ContentArticle__header" },
15
+ headingElm,
16
+ React.createElement(ArticleMeta, { items: props.meta }))) : (headingElm),
17
+ React.createElement(TextBlock, { startSeen: true },
18
+ props.topImage && React.createElement(ContentImage, Object.assign({}, props.topImage)),
19
+ props.body),
20
+ relatedLinks && relatedLinks.links.length > 0 && (React.createElement(VSpacer, { size: "small" },
21
+ React.createElement("hr", null))),
22
+ relatedLinks && React.createElement(RelatedLinks, Object.assign({}, relatedLinks))));
23
+ };
24
+ export default ContentArticle;
@@ -0,0 +1,8 @@
1
+ import { ImageProps } from './_abstract/_Image.js';
2
+ export type ContentImageProps = {
3
+ image?: ImageProps;
4
+ caption?: string | JSX.Element;
5
+ credit?: string | JSX.Element;
6
+ };
7
+ export declare const ContentImage: (props: ContentImageProps) => JSX.Element;
8
+ export default ContentImage;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Image } from './_abstract/_Image.js';
3
+ export const ContentImage = (props) => {
4
+ const { image, caption, credit } = props;
5
+ return (React.createElement("figure", { className: "ContentImage" },
6
+ (caption || credit) && (React.createElement("figcaption", { className: "ContentImage__caption" },
7
+ caption && React.createElement("span", { className: "ContentImage__text" },
8
+ " ",
9
+ caption,
10
+ " "),
11
+ ' ',
12
+ credit && React.createElement("small", { className: "ContentImage__credit" },
13
+ " ",
14
+ credit,
15
+ " "))),
16
+ React.createElement(Image, Object.assign({ className: "ContentImage__image" }, image))));
17
+ };
18
+ export default ContentImage;
@@ -0,0 +1,40 @@
1
+ import { RefObject } from 'react';
2
+ import { FormFieldWrappingProps } from './FormField.js';
3
+ export type DatepickerProps = {
4
+ small?: boolean;
5
+ placeholder?: string;
6
+ value?: Date;
7
+ name?: string;
8
+ startDate?: Date;
9
+ endDate?: Date;
10
+ minDate?: Date;
11
+ maxDate?: Date;
12
+ localeCode?: 'is' | 'en' | 'pl';
13
+ dateFormat?: string | Array<string>;
14
+ isStartDate?: boolean;
15
+ isEndDate?: boolean;
16
+ inputRef?: RefObject<HTMLInputElement>;
17
+ onChange: (date?: Date) => void;
18
+ datepickerExtraProps?: Record<string, unknown>;
19
+ /** @deprecated use value instead. (Will be removed in v0.11) */
20
+ initialDate?: Date;
21
+ } & FormFieldWrappingProps;
22
+ export declare const getDateDiff: (date: Date, diff: number) => Date;
23
+ export type DatepickerLocaleProps = {
24
+ nextMonthAriaLabel: string;
25
+ nextMonthButtonLabel: string;
26
+ nextYearAriaLabel: string;
27
+ nextYearButtonLabel: string;
28
+ previousMonthAriaLabel: string;
29
+ previousMonthButtonLabel: string;
30
+ previousYearAriaLabel: string;
31
+ previousYearButtonLabel: string;
32
+ timeInputLabel: string;
33
+ weekAriaLabelPrefix: string;
34
+ weekLabel: string;
35
+ ariaLabelPrefix: string;
36
+ chooseDayAriaLabelPrefix: string;
37
+ disabledDayAriaLabelPrefix: string;
38
+ };
39
+ export declare const Datepicker: (props: DatepickerProps) => JSX.Element;
40
+ export default Datepicker;
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ // Documentation: https://reactdatepicker.com/
3
+ import ReactDatePicker, { registerLocale,
4
+ // setDefaultLocale,
5
+ } from 'react-datepicker';
6
+ import { useDomid } from '@hugsmidjan/react/hooks';
7
+ import getBemClass from '@hugsmidjan/react/utils/getBemClass';
8
+ // For more info on localization see: https://stackoverflow.com/questions/54399084/change-locale-in-react-datepicker/58306958#58306958
9
+ import is from 'date-fns/locale/is';
10
+ import pl from 'date-fns/locale/pl';
11
+ import FormField from './FormField.js';
12
+ registerLocale('is', is);
13
+ registerLocale('pl', pl);
14
+ export const getDateDiff = (date, diff) => {
15
+ const newDate = new Date(date);
16
+ newDate.setDate(newDate.getDate() + diff);
17
+ return newDate;
18
+ };
19
+ const i18n = {
20
+ is: {
21
+ nextMonthAriaLabel: 'Næsti mánuður',
22
+ nextMonthButtonLabel: 'Næsti mánuður',
23
+ nextYearAriaLabel: 'Næsta ár',
24
+ nextYearButtonLabel: 'Næsta ár',
25
+ previousMonthAriaLabel: 'Fyrri mánuður',
26
+ previousMonthButtonLabel: 'Fyrri mánuður',
27
+ previousYearAriaLabel: 'Fyrra ár',
28
+ previousYearButtonLabel: 'Fyrra ár',
29
+ timeInputLabel: 'Tími: ',
30
+ weekAriaLabelPrefix: 'Vika: ',
31
+ weekLabel: 'Vika',
32
+ ariaLabelPrefix: 'Mánuður:',
33
+ chooseDayAriaLabelPrefix: 'Veldu:',
34
+ disabledDayAriaLabelPrefix: 'Dagsetning ekki í boði',
35
+ },
36
+ pl: {
37
+ nextMonthAriaLabel: 'Następny miesiącu',
38
+ nextMonthButtonLabel: 'Następny miesiącu',
39
+ nextYearAriaLabel: 'Następny rok',
40
+ nextYearButtonLabel: 'Następny rok',
41
+ previousMonthAriaLabel: 'Poprzedni miesiac',
42
+ previousMonthButtonLabel: 'Poprzedni miesiac',
43
+ previousYearAriaLabel: 'Poprzedni rok',
44
+ previousYearButtonLabel: 'Poprzedni rok',
45
+ timeInputLabel: 'Czas: ',
46
+ weekAriaLabelPrefix: 'Tydzień: ',
47
+ weekLabel: 'Tydzień',
48
+ ariaLabelPrefix: 'Miesiąc:',
49
+ chooseDayAriaLabelPrefix: 'Wybierać:',
50
+ disabledDayAriaLabelPrefix: 'Data niedostępna',
51
+ },
52
+ };
53
+ export const Datepicker = (props) => {
54
+ const { className, id, label, hideLabel, assistText, disabled, readOnly, invalid, errorMessage, required, reqText, placeholder, small, localeCode = 'is', dateFormat = 'd.M.yyyy', initialDate, value = initialDate, name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, ssr, inputRef, } = props;
55
+ const domid = useDomid(id);
56
+ const txts = i18n[localeCode] || {};
57
+ const filled = !!value;
58
+ const empty = !filled && !placeholder;
59
+ return (React.createElement(FormField, { className: getBemClass('Datepicker', [], className), ssr: ssr, label: label, small: small, assistText: assistText, hideLabel: hideLabel, invalid: invalid, required: required, reqText: reqText, disabled: disabled, readOnly: readOnly, filled: filled, empty: empty, errorMessage: errorMessage, renderInput: (className, inputProps, addFocusProps) => {
60
+ return (React.createElement("div", Object.assign({ className: className.input, onClick: ({ target, currentTarget }) => { var _a; return target === currentTarget && ((_a = currentTarget.querySelector('input')) === null || _a === void 0 ? void 0 : _a.focus()); }, ref: inputRef &&
61
+ ((elm) => {
62
+ inputRef.current =
63
+ (elm === null || elm === void 0 ? void 0 : elm.querySelector('input')) || undefined;
64
+ return elm;
65
+ }) }, addFocusProps()),
66
+ React.createElement(ReactDatePicker, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: name, locale: localeCode, dateFormat: dateFormat, onChange: (date) => {
67
+ onChange(date || undefined);
68
+ const inputElm = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current;
69
+ if (inputElm) {
70
+ inputElm.dispatchEvent(new Event('change', { bubbles: true }));
71
+ }
72
+ }, placeholderText: placeholder,
73
+ // TODO: Implement this
74
+ // selectsRange
75
+ minDate: minDate, maxDate: maxDate, startDate: startDate, endDate: endDate, selectsStart: isStartDate, selectsEnd: isEndDate, formatWeekDay: (weekday) => weekday.charAt(0).toUpperCase(), showYearDropdown: true, scrollableYearDropdown: true, yearDropdownItemNumber: 15, showMonthDropdown: true }, inputProps, txts, datepickerExtraProps))));
76
+ } }));
77
+ };
78
+ export default Datepicker;
@@ -0,0 +1,18 @@
1
+ import { TextCardListProps } from './_abstract/_CardList.js';
2
+ import { SeenProp } from './utils/seenEffect.js';
3
+ export type RelatedLink = {
4
+ href: string;
5
+ label: string;
6
+ blank?: boolean;
7
+ type?: 'link' | 'pdf' | 'text';
8
+ };
9
+ type RelatedProps = {
10
+ relatedTitle?: string;
11
+ relatedLinks?: Array<RelatedLink>;
12
+ };
13
+ export type ExtraLinksCardProps = TextCardListProps['cards'][number];
14
+ export type ExtraLinksProps = TextCardListProps & RelatedProps & {
15
+ className?: string;
16
+ } & SeenProp;
17
+ export declare const ExtraLinks: (props: ExtraLinksProps) => JSX.Element;
18
+ export default ExtraLinks;
@@ -0,0 +1,24 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ import getBemClass from '@hugsmidjan/react/utils/getBemClass';
4
+ import { CardList } from './_abstract/_CardList.js';
5
+ import { Link } from './_abstract/_Link.js';
6
+ import { useSeenEffect } from './utils/seenEffect.js';
7
+ const ExtraLinks__related = (props) => {
8
+ const { relatedTitle, relatedLinks } = props;
9
+ return (React.createElement("div", { className: "ExtraLinks__related" },
10
+ relatedTitle && React.createElement("h3", { className: "ExtraLinks__related__title" }, relatedTitle),
11
+ React.createElement("ul", { className: "ExtraLinks__related__list" }, relatedLinks &&
12
+ relatedLinks.map(({ href, label, blank = false, type }, i) => (React.createElement("li", { className: "ExtraLinks__related__item", key: i },
13
+ React.createElement(Link, { className: getBemClass('ExtraLinks__related__link', type), href: href, target: blank ? '_blank' : '', rel: blank ? 'noreferrer noopener' : '' }, label)))))));
14
+ };
15
+ export const ExtraLinks = (props) => {
16
+ const { relatedTitle, relatedLinks, className, startSeen } = props, cardListProps = __rest(props, ["relatedTitle", "relatedLinks", "className", "startSeen"]);
17
+ const hasRelated = !!(relatedLinks && relatedLinks.length);
18
+ const [ref] = useSeenEffect(startSeen);
19
+ return (React.createElement("div", { className: getBemClass('ExtraLinks', hasRelated && 'related', className), ref: ref },
20
+ React.createElement("div", { className: "ExtraLinks__main" },
21
+ React.createElement(CardList, Object.assign({}, cardListProps, { bemPrefix: "ExtraLinks" }))),
22
+ hasRelated && (React.createElement(ExtraLinks__related, { relatedTitle: relatedTitle, relatedLinks: relatedLinks }))));
23
+ };
24
+ export default ExtraLinks;
@@ -0,0 +1,12 @@
1
+ import { Efnistakn } from '@reykjavik/hanna-utils/assets';
2
+ import { SeenProp } from './utils/seenEffect.js';
3
+ export type FeatureListProps = {
4
+ title: string;
5
+ features: Array<{
6
+ icon?: Efnistakn;
7
+ iconUrl?: string;
8
+ name: string;
9
+ }>;
10
+ } & SeenProp;
11
+ export declare const FeatureList: (props: FeatureListProps) => JSX.Element;
12
+ export default FeatureList;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { useSeenEffect } from './utils/seenEffect.js';
3
+ import Bling from './Bling.js';
4
+ export const FeatureList = (props) => {
5
+ const { title, features, startSeen } = props;
6
+ const [ref] = useSeenEffect(startSeen);
7
+ const _features = features.length ? features : [{ name: '...' }];
8
+ return (React.createElement(React.Fragment, null,
9
+ React.createElement(Bling, { type: "snake-large", align: "left", vertical: "down-ish" }),
10
+ React.createElement("div", { className: "FeatureList", ref: ref },
11
+ React.createElement("h2", { className: "FeatureList__title" }, title),
12
+ React.createElement("ul", { className: "FeatureList__list" }, _features.map(({ name, icon, iconUrl }, i) => (React.createElement("li", { key: i, className: "FeatureList__feature", style: iconUrl
13
+ ? { '--efnistakn': `url("${iconUrl}")` }
14
+ : undefined, "data-efnistakn": !iconUrl ? icon : undefined }, name)))))));
15
+ };
16
+ export default FeatureList;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ export type FieldGroupProps = {
3
+ legend: string;
4
+ disabled?: boolean;
5
+ small?: boolean;
6
+ className?: string;
7
+ children: ReactNode;
8
+ };
9
+ export declare const FieldGroup: (props: FieldGroupProps) => JSX.Element;
10
+ export default FieldGroup;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import getBemClass from '@hugsmidjan/react/utils/getBemClass';
3
+ export const FieldGroup = (props) => {
4
+ const { legend, children, className, disabled, small } = props;
5
+ return (React.createElement("fieldset", { className: getBemClass('FieldGroup', small && 'small', className), disabled: disabled },
6
+ React.createElement("legend", { className: "FieldGroup__legend" }, legend),
7
+ children));
8
+ };
9
+ export default FieldGroup;
@@ -0,0 +1,36 @@
1
+ export type CustomFile = {
2
+ preview?: string;
3
+ } & File;
4
+ /**
5
+ * Attaches a `preview` prop to file objects that don't already have a `preview` key defined
6
+ *
7
+ * The preview's value is either a data URI (for image-type files) or `undefined`
8
+ */
9
+ export declare const addPreview: (file: CustomFile) => void;
10
+ /**
11
+ * Revokes `preview` data URIs to avoid memory leaks
12
+ *
13
+ * (See: https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL)
14
+ */
15
+ export declare const releasePreview: (file: CustomFile) => void;
16
+ /**
17
+ * Small+stupid file size pretty-printer.
18
+ */
19
+ export declare const formatBytes: (bytes: number, lang?: string, decimals?: number) => string;
20
+ /**
21
+ * Figures out how to handle adding files to a FileInput
22
+ * Which files to retaine, which too delete, and
23
+ * what the updated fileList should look like.
24
+ *
25
+ *
26
+ */
27
+ export declare const getFileListUpdate: (oldFileList: Array<File>, added: Array<File>, replaceMode: boolean) => {
28
+ fileList: File[];
29
+ diff: {
30
+ added: File[];
31
+ deleted: File[];
32
+ } | {
33
+ added: File[];
34
+ deleted?: undefined;
35
+ };
36
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Attaches a `preview` prop to file objects that don't already have a `preview` key defined
3
+ *
4
+ * The preview's value is either a data URI (for image-type files) or `undefined`
5
+ */
6
+ export const addPreview = (file) => {
7
+ if (!('preview' in file)) {
8
+ file.preview = file.type.includes('image/') ? URL.createObjectURL(file) : undefined;
9
+ }
10
+ };
11
+ /**
12
+ * Revokes `preview` data URIs to avoid memory leaks
13
+ *
14
+ * (See: https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL)
15
+ */
16
+ export const releasePreview = (file) => {
17
+ file.preview && URL.revokeObjectURL(file.preview);
18
+ delete file.preview;
19
+ };
20
+ // ---------------------------------------------------------------------------
21
+ const k = 1024;
22
+ const kThreshold = 970 / k; // Snap up a unit level at this point
23
+ const units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB' /*, 'EB', 'ZB', 'YB' */];
24
+ const decimalSymbols = { is: ',', en: '.', pl: ',' };
25
+ /**
26
+ * Small+stupid file size pretty-printer.
27
+ */
28
+ export const formatBytes = (bytes, lang = 'is', decimals = 2) => {
29
+ if (bytes === 0) {
30
+ return '0 Bytes';
31
+ }
32
+ const i = Math.min(Math.floor(Math.log(Math.abs(bytes) / kThreshold) / Math.log(k)), units.length - 1);
33
+ const scaled = bytes / Math.pow(k, i);
34
+ const formatted = (parseFloat(scaled.toFixed(decimals)) + '').replace('.',
35
+ // NOTE: As of 2022-11 Chrome still doesn't support Icelandic
36
+ decimalSymbols[lang] || (1.1).toLocaleString(lang)[1]);
37
+ return `${formatted} ${units[i]}`;
38
+ };
39
+ /**
40
+ * Figures out how to handle adding files to a FileInput
41
+ * Which files to retaine, which too delete, and
42
+ * what the updated fileList should look like.
43
+ *
44
+ *
45
+ */
46
+ export const getFileListUpdate = (oldFileList, added,
47
+ /**
48
+ * `replaceMode: true` is the default "single-file" input behavior.
49
+ *
50
+ * Pass `false` to this argument when the "multiple" prop is true.
51
+ */
52
+ replaceMode) => {
53
+ const deleted = replaceMode ? oldFileList : [];
54
+ const retained = [];
55
+ if (!replaceMode) {
56
+ oldFileList.forEach((oldFile) => {
57
+ if (added.find(({ name }) => name === oldFile.name)) {
58
+ deleted.push(oldFile);
59
+ }
60
+ else {
61
+ retained.push(oldFile);
62
+ }
63
+ });
64
+ }
65
+ return {
66
+ fileList: retained.concat(added),
67
+ diff: deleted.length ? { added, deleted } : { added },
68
+ };
69
+ };
@@ -0,0 +1,11 @@
1
+ import type { formatBytes } from './_FileInput.utils';
2
+ import { CustomFile } from './_FileInput.utils';
3
+ export type FileListProps = {
4
+ files: Array<CustomFile>;
5
+ showFileSize?: boolean;
6
+ showImagePreviews?: boolean;
7
+ removeFileText: string;
8
+ removeFile: (file: File | string) => void;
9
+ formatBytes: typeof formatBytes;
10
+ };
11
+ export declare const DefaultFileList: (props: FileListProps) => JSX.Element | null;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ export const DefaultFileList = (props) => {
3
+ const { files, showFileSize, showImagePreviews, removeFileText, removeFile, formatBytes, } = props;
4
+ if (!files.length) {
5
+ return null;
6
+ }
7
+ return (React.createElement("ul", { className: "FileInput__filelist" }, files.map((file) => (React.createElement("li", { key: file.name, className: "FileInput__file" },
8
+ React.createElement("button", { className: "FileInput__file-remove", type: "button", onClick: () => removeFile(file), "aria-label": `${removeFileText} ${file.name}` }, removeFileText),
9
+ React.createElement("span", { className: "FileInput__fileinfo" },
10
+ showImagePreviews && file.preview && (React.createElement(React.Fragment, null,
11
+ React.createElement("span", { className: "FileInput__preview" },
12
+ React.createElement("img", { src: file.preview, alt: "" })),
13
+ ' ')),
14
+ React.createElement("span", { className: "FileInput__filename" }, file.name),
15
+ showFileSize && (React.createElement("small", { className: "FileInput__filesize" },
16
+ " - (",
17
+ formatBytes(file.size),
18
+ ")"))))))));
19
+ };