@reykjavik/hanna-react 0.10.57 → 0.10.60

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 (392) hide show
  1. package/AccordionList.js +3 -28
  2. package/ActionCards.d.ts +1 -1
  3. package/ActionCards.js +4 -6
  4. package/Alert.js +5 -30
  5. package/ArticleCards.d.ts +6 -0
  6. package/ArticleCards.js +7 -0
  7. package/ArticleCarousel/_ArticleCarouselCard.d.ts +1 -1
  8. package/ArticleCarousel/_ArticleCarouselCard.js +8 -10
  9. package/ArticleCarousel.js +3 -5
  10. package/ArticleMeta.d.ts +1 -0
  11. package/ArticleMeta.js +7 -28
  12. package/Attention.js +3 -5
  13. package/BasicTable.js +5 -7
  14. package/{esm/CenterColumn.d.ts → BgBox.d.ts} +4 -3
  15. package/BgBox.js +12 -0
  16. package/Bling.js +3 -5
  17. package/BlockBreak.js +2 -4
  18. package/BlockQuote.js +2 -4
  19. package/BreadCrumbs.js +4 -6
  20. package/ButtonBack.d.ts +1 -1
  21. package/ButtonBack.js +4 -6
  22. package/ButtonBar.js +3 -5
  23. package/ButtonPrimary.d.ts +1 -1
  24. package/ButtonPrimary.js +4 -6
  25. package/ButtonSecondary.d.ts +1 -1
  26. package/ButtonSecondary.js +4 -6
  27. package/ButtonTertiary.d.ts +1 -1
  28. package/ButtonTertiary.js +4 -6
  29. package/CHANGELOG.md +20 -1
  30. package/Carousel.js +3 -5
  31. package/CarouselStepper.js +3 -5
  32. package/CenterColumn.js +3 -5
  33. package/Checkbox.d.ts +1 -1
  34. package/Checkbox.js +4 -6
  35. package/CheckboxButtonsGroup.d.ts +1 -1
  36. package/CheckboxButtonsGroup.js +6 -8
  37. package/CheckboxGroup.d.ts +1 -1
  38. package/CheckboxGroup.js +5 -7
  39. package/CityBlock.d.ts +1 -1
  40. package/CityBlock.js +3 -5
  41. package/ContactBubble.js +6 -31
  42. package/ContentArticle.js +8 -10
  43. package/ContentImage.d.ts +1 -1
  44. package/ContentImage.js +4 -6
  45. package/Datepicker.js +6 -31
  46. package/ExtraLinks.d.ts +1 -1
  47. package/ExtraLinks.js +8 -21
  48. package/FeatureList.js +3 -5
  49. package/FieldGroup.js +3 -5
  50. package/FileInput.js +5 -41
  51. package/Foonote.js +2 -4
  52. package/FooterBadges.js +4 -6
  53. package/FooterInfo.js +3 -5
  54. package/Footnote.js +2 -4
  55. package/Form.js +3 -5
  56. package/FormField.js +3 -28
  57. package/Gallery/_GalleryItem.d.ts +1 -1
  58. package/Gallery/_GalleryItem.js +9 -45
  59. package/Gallery/_GalleryModal.js +6 -31
  60. package/Gallery/_GalleryModalContext.js +2 -4
  61. package/Gallery/_GalleryModalItem.js +5 -18
  62. package/Gallery.js +6 -31
  63. package/GridBlocks.d.ts +2 -2
  64. package/GridBlocks.js +8 -10
  65. package/Heading.d.ts +1 -1
  66. package/Heading.js +4 -6
  67. package/HeroBlock.d.ts +2 -2
  68. package/HeroBlock.js +6 -8
  69. package/IframeBlock.d.ts +5 -1
  70. package/IframeBlock.js +6 -8
  71. package/Illustration.d.ts +1 -1
  72. package/Illustration.js +4 -6
  73. package/ImageCards.d.ts +1 -1
  74. package/ImageCards.js +6 -19
  75. package/InfoBlock.js +2 -4
  76. package/InfoHero.d.ts +2 -2
  77. package/InfoHero.js +8 -10
  78. package/IslandBlock.d.ts +1 -1
  79. package/IslandBlock.js +3 -5
  80. package/IslandPageBlock.d.ts +1 -1
  81. package/IslandPageBlock.js +3 -5
  82. package/LabeledTextBlock.d.ts +1 -1
  83. package/LabeledTextBlock.js +4 -6
  84. package/Layout.js +9 -11
  85. package/MainMenu/_Auxiliary.js +4 -6
  86. package/MainMenu/_PrimaryPanel.js +5 -7
  87. package/MainMenu.js +7 -32
  88. package/MiniMetrics.d.ts +1 -1
  89. package/MiniMetrics.js +5 -7
  90. package/Modal.js +3 -5
  91. package/NameCard.js +6 -8
  92. package/NameCards.js +3 -5
  93. package/NewsHero.d.ts +1 -1
  94. package/NewsHero.js +7 -9
  95. package/PageFilter.js +4 -6
  96. package/PageHeading.js +3 -5
  97. package/Picture.d.ts +7 -0
  98. package/Picture.js +11 -0
  99. package/ProcessOverview.js +3 -5
  100. package/PullQuote.js +2 -4
  101. package/RadioButtonsGroup.d.ts +1 -1
  102. package/RadioButtonsGroup.js +6 -8
  103. package/RadioGroup.d.ts +2 -2
  104. package/RadioGroup.js +6 -8
  105. package/RelatedLinks.js +4 -6
  106. package/RowBlock.js +3 -5
  107. package/RowBlockColumn.js +3 -5
  108. package/SearchInput.js +5 -41
  109. package/SearchResults/_SearchResultsItem.js +6 -8
  110. package/SearchResults.js +7 -32
  111. package/SeenEffect.js +3 -16
  112. package/Selectbox.js +6 -42
  113. package/ShareButtons.js +4 -26
  114. package/Sharpie.js +3 -5
  115. package/SiteSearchAutocomplete.js +5 -41
  116. package/SiteSearchCurtain.js +3 -28
  117. package/SiteSearchInput.d.ts +1 -1
  118. package/SiteSearchInput.js +4 -40
  119. package/Skeleton.js +4 -6
  120. package/SubHeading.js +3 -5
  121. package/Tabs.js +3 -28
  122. package/TagPill.d.ts +1 -1
  123. package/TagPill.js +7 -20
  124. package/TextBlock.js +3 -5
  125. package/TextButton.d.ts +1 -1
  126. package/TextButton.js +4 -6
  127. package/TextInput.js +5 -41
  128. package/VSpacer.js +3 -5
  129. package/VerticalTabsTOC.js +3 -28
  130. package/WizardLayout.js +7 -9
  131. package/WizardLayoutClose.d.ts +1 -1
  132. package/WizardLayoutClose.js +4 -6
  133. package/WizardStepper.js +3 -5
  134. package/_abstract/_AbstractCarousel.js +7 -32
  135. package/_abstract/_Blings.js +3 -5
  136. package/_abstract/_Block.d.ts +2 -2
  137. package/_abstract/_Block.js +7 -9
  138. package/_abstract/{Button.d.ts → _Button.d.ts} +0 -0
  139. package/_abstract/{Button.js → _Button.js} +6 -19
  140. package/{esm/_abstract/CardList.d.ts → _abstract/_CardList.d.ts} +2 -1
  141. package/_abstract/{CardList.js → _CardList.js} +12 -12
  142. package/{esm/_abstract/Image.d.ts → _abstract/_Image.d.ts} +9 -5
  143. package/_abstract/{Image.js → _Image.js} +5 -7
  144. package/_abstract/{Link.d.ts → _Link.d.ts} +0 -0
  145. package/_abstract/{Link.js → _Link.js} +2 -4
  146. package/_abstract/_Quote.js +4 -6
  147. package/{esm/_abstract/TogglerGroup.d.ts → _abstract/_TogglerGroup.d.ts} +1 -1
  148. package/_abstract/{TogglerGroup.js → _TogglerGroup.js} +8 -8
  149. package/{esm/_abstract/TogglerGroupField.d.ts → _abstract/_TogglerGroupField.d.ts} +2 -2
  150. package/_abstract/_TogglerGroupField.js +14 -0
  151. package/_abstract/{TogglerInput.d.ts → _TogglerInput.d.ts} +0 -0
  152. package/_abstract/{TogglerInput.js → _TogglerInput.js} +4 -17
  153. package/_abstract/breakOnNL.js +2 -4
  154. package/package.json +6 -365
  155. package/utils/env.js +2 -4
  156. package/utils/seenEffect.d.ts +2 -2
  157. package/utils/seenEffect.js +1 -1
  158. package/utils/useScrollbarWidthCSSVar.js +2 -4
  159. package/utils.js +3 -16
  160. package/_abstract/CardList.d.ts +0 -29
  161. package/_abstract/Image.d.ts +0 -32
  162. package/_abstract/TogglerGroup.d.ts +0 -31
  163. package/_abstract/TogglerGroupField.d.ts +0 -17
  164. package/_abstract/TogglerGroupField.js +0 -27
  165. package/esm/AccordionList.d.ts +0 -17
  166. package/esm/AccordionList.js +0 -24
  167. package/esm/ActionCards.d.ts +0 -5
  168. package/esm/ActionCards.js +0 -9
  169. package/esm/Alert.d.ts +0 -49
  170. package/esm/Alert.js +0 -92
  171. package/esm/ArticleCarousel/_ArticleCarouselCard.d.ts +0 -27
  172. package/esm/ArticleCarousel/_ArticleCarouselCard.js +0 -24
  173. package/esm/ArticleCarousel.d.ts +0 -12
  174. package/esm/ArticleCarousel.js +0 -8
  175. package/esm/ArticleMeta.d.ts +0 -9
  176. package/esm/ArticleMeta.js +0 -18
  177. package/esm/Attention.d.ts +0 -7
  178. package/esm/Attention.js +0 -4
  179. package/esm/BasicTable.d.ts +0 -12
  180. package/esm/BasicTable.js +0 -29
  181. package/esm/Bling.d.ts +0 -81
  182. package/esm/Bling.js +0 -44
  183. package/esm/BlockBreak.d.ts +0 -2
  184. package/esm/BlockBreak.js +0 -6
  185. package/esm/BlockQuote.d.ts +0 -4
  186. package/esm/BlockQuote.js +0 -4
  187. package/esm/BreadCrumbs.d.ts +0 -11
  188. package/esm/BreadCrumbs.js +0 -28
  189. package/esm/ButtonBack.d.ts +0 -7
  190. package/esm/ButtonBack.js +0 -4
  191. package/esm/ButtonBar.d.ts +0 -16
  192. package/esm/ButtonBar.js +0 -14
  193. package/esm/ButtonPrimary.d.ts +0 -7
  194. package/esm/ButtonPrimary.js +0 -4
  195. package/esm/ButtonSecondary.d.ts +0 -7
  196. package/esm/ButtonSecondary.js +0 -4
  197. package/esm/ButtonTertiary.d.ts +0 -12
  198. package/esm/ButtonTertiary.js +0 -15
  199. package/esm/Carousel.d.ts +0 -4
  200. package/esm/Carousel.js +0 -4
  201. package/esm/CarouselStepper.d.ts +0 -4
  202. package/esm/CarouselStepper.js +0 -4
  203. package/esm/CenterColumn.js +0 -7
  204. package/esm/Checkbox.d.ts +0 -4
  205. package/esm/Checkbox.js +0 -4
  206. package/esm/CheckboxButtonsGroup.d.ts +0 -11
  207. package/esm/CheckboxButtonsGroup.js +0 -14
  208. package/esm/CheckboxGroup.d.ts +0 -9
  209. package/esm/CheckboxGroup.js +0 -7
  210. package/esm/CityBlock.d.ts +0 -23
  211. package/esm/CityBlock.js +0 -18
  212. package/esm/ContactBubble.d.ts +0 -58
  213. package/esm/ContactBubble.js +0 -148
  214. package/esm/ContentArticle.d.ts +0 -15
  215. package/esm/ContentArticle.js +0 -21
  216. package/esm/ContentImage.d.ts +0 -8
  217. package/esm/ContentImage.js +0 -18
  218. package/esm/Datepicker.d.ts +0 -39
  219. package/esm/Datepicker.js +0 -63
  220. package/esm/ExtraLinks.d.ts +0 -18
  221. package/esm/ExtraLinks.js +0 -34
  222. package/esm/FeatureList.d.ts +0 -12
  223. package/esm/FeatureList.js +0 -16
  224. package/esm/FieldGroup.d.ts +0 -9
  225. package/esm/FieldGroup.js +0 -9
  226. package/esm/FileInput.d.ts +0 -17
  227. package/esm/FileInput.js +0 -154
  228. package/esm/Foonote.d.ts +0 -12
  229. package/esm/Foonote.js +0 -7
  230. package/esm/FooterBadges.d.ts +0 -9
  231. package/esm/FooterBadges.js +0 -12
  232. package/esm/FooterInfo.d.ts +0 -18
  233. package/esm/FooterInfo.js +0 -9
  234. package/esm/Footnote.d.ts +0 -6
  235. package/esm/Footnote.js +0 -3
  236. package/esm/Form.d.ts +0 -7
  237. package/esm/Form.js +0 -10
  238. package/esm/FormField.d.ts +0 -65
  239. package/esm/FormField.js +0 -91
  240. package/esm/Gallery/_GalleryItem.d.ts +0 -8
  241. package/esm/Gallery/_GalleryItem.js +0 -30
  242. package/esm/Gallery/_GalleryModal.d.ts +0 -6
  243. package/esm/Gallery/_GalleryModal.js +0 -54
  244. package/esm/Gallery/_GalleryModalContext.d.ts +0 -9
  245. package/esm/Gallery/_GalleryModalContext.js +0 -3
  246. package/esm/Gallery/_GalleryModalItem.d.ts +0 -3
  247. package/esm/Gallery/_GalleryModalItem.js +0 -22
  248. package/esm/Gallery.d.ts +0 -17
  249. package/esm/Gallery.js +0 -27
  250. package/esm/GridBlocks.d.ts +0 -26
  251. package/esm/GridBlocks.js +0 -24
  252. package/esm/Heading.d.ts +0 -16
  253. package/esm/Heading.js +0 -17
  254. package/esm/HeroBlock.d.ts +0 -19
  255. package/esm/HeroBlock.js +0 -21
  256. package/esm/IframeBlock.d.ts +0 -23
  257. package/esm/IframeBlock.js +0 -26
  258. package/esm/Illustration.d.ts +0 -13
  259. package/esm/Illustration.js +0 -8
  260. package/esm/ImageCards.d.ts +0 -8
  261. package/esm/ImageCards.js +0 -22
  262. package/esm/InfoBlock.d.ts +0 -17
  263. package/esm/InfoBlock.js +0 -13
  264. package/esm/InfoHero.d.ts +0 -17
  265. package/esm/InfoHero.js +0 -82
  266. package/esm/IslandBlock.d.ts +0 -25
  267. package/esm/IslandBlock.js +0 -16
  268. package/esm/IslandPageBlock.d.ts +0 -24
  269. package/esm/IslandPageBlock.js +0 -16
  270. package/esm/LabeledTextBlock.d.ts +0 -11
  271. package/esm/LabeledTextBlock.js +0 -14
  272. package/esm/Layout.d.ts +0 -33
  273. package/esm/Layout.js +0 -52
  274. package/esm/MainMenu/_Auxiliary.d.ts +0 -6
  275. package/esm/MainMenu/_Auxiliary.js +0 -13
  276. package/esm/MainMenu/_PrimaryPanel.d.ts +0 -13
  277. package/esm/MainMenu/_PrimaryPanel.js +0 -22
  278. package/esm/MainMenu.d.ts +0 -48
  279. package/esm/MainMenu.js +0 -136
  280. package/esm/MiniMetrics.d.ts +0 -8
  281. package/esm/MiniMetrics.js +0 -12
  282. package/esm/Modal.d.ts +0 -10
  283. package/esm/Modal.js +0 -14
  284. package/esm/NameCard.d.ts +0 -64
  285. package/esm/NameCard.js +0 -82
  286. package/esm/NameCards.d.ts +0 -6
  287. package/esm/NameCards.js +0 -7
  288. package/esm/NewsHero.d.ts +0 -14
  289. package/esm/NewsHero.js +0 -86
  290. package/esm/PageFilter.d.ts +0 -17
  291. package/esm/PageFilter.js +0 -15
  292. package/esm/PageHeading.d.ts +0 -10
  293. package/esm/PageHeading.js +0 -12
  294. package/esm/ProcessOverview.d.ts +0 -13
  295. package/esm/ProcessOverview.js +0 -17
  296. package/esm/PullQuote.d.ts +0 -4
  297. package/esm/PullQuote.js +0 -4
  298. package/esm/RadioButtonsGroup.d.ts +0 -11
  299. package/esm/RadioButtonsGroup.js +0 -14
  300. package/esm/RadioGroup.d.ts +0 -13
  301. package/esm/RadioGroup.js +0 -7
  302. package/esm/RelatedLinks.d.ts +0 -20
  303. package/esm/RelatedLinks.js +0 -26
  304. package/esm/RowBlock.d.ts +0 -12
  305. package/esm/RowBlock.js +0 -9
  306. package/esm/RowBlockColumn.d.ts +0 -8
  307. package/esm/RowBlockColumn.js +0 -11
  308. package/esm/SearchInput.d.ts +0 -18
  309. package/esm/SearchInput.js +0 -33
  310. package/esm/SearchResults/_SearchResultsItem.d.ts +0 -18
  311. package/esm/SearchResults/_SearchResultsItem.js +0 -15
  312. package/esm/SearchResults.d.ts +0 -33
  313. package/esm/SearchResults.js +0 -109
  314. package/esm/SeenEffect.d.ts +0 -4
  315. package/esm/SeenEffect.js +0 -19
  316. package/esm/Selectbox.d.ts +0 -8
  317. package/esm/Selectbox.js +0 -46
  318. package/esm/ShareButtons.d.ts +0 -9
  319. package/esm/ShareButtons.js +0 -51
  320. package/esm/Sharpie.d.ts +0 -23
  321. package/esm/Sharpie.js +0 -22
  322. package/esm/SiteSearchAutocomplete.d.ts +0 -40
  323. package/esm/SiteSearchAutocomplete.js +0 -58
  324. package/esm/SiteSearchCurtain.d.ts +0 -6
  325. package/esm/SiteSearchCurtain.js +0 -33
  326. package/esm/SiteSearchInput.d.ts +0 -24
  327. package/esm/SiteSearchInput.js +0 -40
  328. package/esm/Skeleton.d.ts +0 -25
  329. package/esm/Skeleton.js +0 -30
  330. package/esm/SubHeading.d.ts +0 -10
  331. package/esm/SubHeading.js +0 -13
  332. package/esm/Tabs.d.ts +0 -35
  333. package/esm/Tabs.js +0 -94
  334. package/esm/TagPill.d.ts +0 -27
  335. package/esm/TagPill.js +0 -43
  336. package/esm/TextBlock.d.ts +0 -15
  337. package/esm/TextBlock.js +0 -15
  338. package/esm/TextButton.d.ts +0 -9
  339. package/esm/TextButton.js +0 -9
  340. package/esm/TextInput.d.ts +0 -16
  341. package/esm/TextInput.js +0 -35
  342. package/esm/VSpacer.d.ts +0 -24
  343. package/esm/VSpacer.js +0 -41
  344. package/esm/VerticalTabsTOC.d.ts +0 -14
  345. package/esm/VerticalTabsTOC.js +0 -68
  346. package/esm/WizardLayout.d.ts +0 -15
  347. package/esm/WizardLayout.js +0 -30
  348. package/esm/WizardLayoutClose.d.ts +0 -3
  349. package/esm/WizardLayoutClose.js +0 -4
  350. package/esm/WizardStepper.d.ts +0 -36
  351. package/esm/WizardStepper.js +0 -25
  352. package/esm/_abstract/Button.d.ts +0 -40
  353. package/esm/_abstract/Button.js +0 -47
  354. package/esm/_abstract/CardList.js +0 -36
  355. package/esm/_abstract/Image.js +0 -27
  356. package/esm/_abstract/Link.d.ts +0 -27
  357. package/esm/_abstract/Link.js +0 -24
  358. package/esm/_abstract/TogglerGroup.js +0 -29
  359. package/esm/_abstract/TogglerGroupField.js +0 -22
  360. package/esm/_abstract/TogglerInput.d.ts +0 -22
  361. package/esm/_abstract/TogglerInput.js +0 -33
  362. package/esm/_abstract/_AbstractCarousel.d.ts +0 -25
  363. package/esm/_abstract/_AbstractCarousel.js +0 -130
  364. package/esm/_abstract/_Blings.d.ts +0 -11
  365. package/esm/_abstract/_Blings.js +0 -12
  366. package/esm/_abstract/_Block.d.ts +0 -22
  367. package/esm/_abstract/_Block.js +0 -24
  368. package/esm/_abstract/_Quote.d.ts +0 -9
  369. package/esm/_abstract/_Quote.js +0 -8
  370. package/esm/_abstract/breakOnNL.d.ts +0 -2
  371. package/esm/_abstract/breakOnNL.js +0 -8
  372. package/esm/assets.d.ts +0 -42
  373. package/esm/assets.js +0 -56
  374. package/esm/constants.d.ts +0 -39
  375. package/esm/constants.js +0 -22
  376. package/esm/focus-visible.d.ts +0 -1
  377. package/esm/focus-visible.js +0 -1
  378. package/esm/package.json +0 -1
  379. package/esm/utils/env.d.ts +0 -1
  380. package/esm/utils/env.js +0 -8
  381. package/esm/utils/seenEffect.d.ts +0 -28
  382. package/esm/utils/seenEffect.js +0 -73
  383. package/esm/utils/useFormatMonitor.d.ts +0 -38
  384. package/esm/utils/useFormatMonitor.js +0 -41
  385. package/esm/utils/useGetSVGtext.d.ts +0 -6
  386. package/esm/utils/useGetSVGtext.js +0 -19
  387. package/esm/utils/useMenuToggling.d.ts +0 -8
  388. package/esm/utils/useMenuToggling.js +0 -62
  389. package/esm/utils/useScrollbarWidthCSSVar.d.ts +0 -1
  390. package/esm/utils/useScrollbarWidthCSSVar.js +0 -3
  391. package/esm/utils.d.ts +0 -2
  392. package/esm/utils.js +0 -2
@@ -1,130 +0,0 @@
1
- import React, { useEffect, useRef, useState, } from 'react';
2
- import A from '@hugsmidjan/qj/A';
3
- import focusElm from '@hugsmidjan/qj/focusElm';
4
- import throttle from '@hugsmidjan/qj/throttle';
5
- import { useIsBrowserSide } from '@hugsmidjan/react/hooks';
6
- import getBemClass from '@hugsmidjan/react/utils/getBemClass';
7
- import { notNully } from '@reykjavik/hanna-utils';
8
- import CarouselStepper from '../CarouselStepper';
9
- import { useSeenEffect } from '../utils/seenEffect';
10
- const WHEEL_AMPLIFIER = 3;
11
- const WHEEL_HIJACK_TIMEOUT_MS = 667;
12
- const scrollXBy = (elm, deltaX) => {
13
- const left = elm.scrollLeft + deltaX;
14
- elm.scrollTo(left, elm.scrollTop);
15
- // NOTE 1: using elm.scrollTo({ left, behavior: 'smooth' }); seems to be too much
16
- // as `behavior: 'smooth'` starts some weird interactions with the browser's
17
- // `scroll-snap-type` behavior.
18
- //
19
- // NOTE 2: Both Chrome and Safari tend to snap hard to the nearest list item
20
- // while Firefox is more smooth. Haven't found a way around that.
21
- };
22
- const exitWheelHijack = (elm) => () => {
23
- elm.style.scrollSnapType = '';
24
- const lastElmOffset = elm.lastElementChild
25
- ? elm.lastElementChild.offsetLeft
26
- : 0;
27
- // trigger one last scroll event, to make sure the element's
28
- // `style.scrollSnapType`'s behavior kicks in.
29
- // Otherwise the list may stay stuck in an over-scrolled state —
30
- // off to the right.
31
- scrollXBy(elm, Math.min(0, lastElmOffset - elm.scrollLeft));
32
- };
33
- const handleMouseWheel = (e) => {
34
- const elm = e.currentTarget;
35
- if (e.deltaX || elm.$hasXDeltaed) {
36
- elm.$hasXDeltaed = true;
37
- exitWheelHijack(elm);
38
- return;
39
- }
40
- if (e.deltaY && !e.deltaX) {
41
- if (e.deltaY < 0) {
42
- // Stop scroll-capture when list is at left-edge
43
- if (elm.scrollLeft < 50) {
44
- return;
45
- }
46
- }
47
- else {
48
- // Stop scroll-capture when list is beyond left edge of last list item
49
- if (elm.scrollLeft >
50
- (elm.lastElementChild ? elm.lastElementChild.offsetLeft : 0)) {
51
- exitWheelHijack(elm);
52
- return;
53
- }
54
- }
55
- e.preventDefault();
56
- e.stopImmediatePropagation();
57
- // Disable `scroll-snap-style` because otherwise
58
- // small-scale elm.scrollTo() calls have no effect
59
- elm.style.scrollSnapType = 'initial';
60
- scrollXBy(elm, e.deltaY * WHEEL_AMPLIFIER);
61
- clearTimeout(elm.$timeout);
62
- elm.$timeout = setTimeout(exitWheelHijack(elm), WHEEL_HIJACK_TIMEOUT_MS);
63
- }
64
- };
65
- const handleMouseLeave = (e) => {
66
- const elm = e.currentTarget;
67
- exitWheelHijack(elm);
68
- elm.$hasXDeltaed = undefined;
69
- };
70
- const AbstractCarousel = (props) => {
71
- const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, } = props;
72
- const children = props.children && props.children.filter(notNully);
73
- const [leftOffset, setLeftOffset] = useState();
74
- const itemCount = (children || items).length;
75
- const listRef = useRef(null);
76
- const [activeItem, setActiveItem] = useState(0);
77
- const isBrowser = useIsBrowserSide(ssr);
78
- // update on activeItem state change
79
- useEffect(() => {
80
- const listElm = listRef.current;
81
- if (!listElm) {
82
- return;
83
- }
84
- const calcLeftOffset = () => {
85
- var _a;
86
- setLeftOffset((_a = listElm.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left);
87
- scrollXBy(listElm, 0);
88
- };
89
- const calcActiveItem = throttle(() => {
90
- const { scrollLeft, children } = listElm;
91
- // using Array#find as forEachUntil
92
- A(children).find((item, i) => {
93
- if (scrollLeft <= item.offsetLeft + item.offsetWidth / 2) {
94
- setActiveItem(i);
95
- return true;
96
- }
97
- });
98
- }, 300, true);
99
- calcLeftOffset();
100
- listElm.addEventListener('wheel', handleMouseWheel);
101
- listElm.addEventListener('scroll', calcActiveItem, { passive: true });
102
- window.addEventListener('resize', calcLeftOffset, { passive: true });
103
- return () => {
104
- listElm.removeEventListener('wheel', handleMouseWheel);
105
- listElm.removeEventListener('scroll', calcActiveItem);
106
- window.removeEventListener('resize', calcLeftOffset);
107
- };
108
- }, []);
109
- const scrollToItem = (newActive) => {
110
- setActiveItem(newActive);
111
- const listElm = listRef.current;
112
- const newItem = listElm.children[newActive];
113
- listElm.scrollTo(newItem ? newItem.offsetLeft : 0, 0);
114
- setTimeout(() => focusElm(newItem), 500);
115
- };
116
- const [outerRef] = useSeenEffect(startSeen);
117
- if (!itemCount) {
118
- return null;
119
- }
120
- return (React.createElement("div", { className: getBemClass(bem, modifier, props.className), ref: outerRef, "data-sprinkled": isBrowser },
121
- title && React.createElement("h2", { className: bem + '__title' }, title),
122
- React.createElement("div", { className: bem + '__itemlist', style: leftOffset
123
- ? { '--Carousel--leftOffset': `${leftOffset}px` }
124
- : undefined, "data-scroll-snapping": leftOffset ? 'true' : undefined, onMouseLeave: handleMouseLeave, ref: listRef }, children ||
125
- items.map((item, i) => (
126
- // @ts-expect-error (Can't be arsed...)
127
- React.createElement(Component, Object.assign({ key: i }, ComponentProps, item))))),
128
- isBrowser && (React.createElement(CarouselStepper, { itemCount: itemCount, setCurrent: scrollToItem, current: activeItem }))));
129
- };
130
- export default AbstractCarousel;
@@ -1,11 +0,0 @@
1
- import { BlingType } from '@reykjavik/hanna-utils/assets';
2
- import { BlingProps } from '../Bling';
3
- export declare type BlingComboProps = Array<Omit<BlingProps, 'type' | 'blingUrl'> & {
4
- type: BlingType;
5
- }>;
6
- declare type BlingsProps = {
7
- blings: BlingComboProps;
8
- mirror?: boolean;
9
- };
10
- declare const Blings: (props: BlingsProps) => JSX.Element;
11
- export default Blings;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import Bling from '../Bling';
3
- const inverseAlignments = {
4
- left: 'right',
5
- 'left-ish': 'right-ish',
6
- 'left-center': 'right-center',
7
- 'right-center': 'left-center',
8
- 'right-ish': 'left-ish',
9
- right: 'left',
10
- };
11
- const Blings = (props) => (React.createElement(React.Fragment, null, props.blings.map(({ type, align, vertical, color, overlay, parent }, i) => (React.createElement(Bling, { key: type + '-' + i, type: type, align: props.mirror ? inverseAlignments[align || 'left'] : align, vertical: vertical, color: color, overlay: overlay, parent: parent })))));
12
- export default Blings;
@@ -1,22 +0,0 @@
1
- import { BemPropsModifier } from '@hugsmidjan/react/types';
2
- import { SeenProp } from '../utils/seenEffect';
3
- import { ButtonProps } from './Button';
4
- import { ImageProps } from './Image';
5
- export declare type BlockItem = {
6
- title: string;
7
- summary?: string | JSX.Element;
8
- buttons?: Array<ButtonProps>;
9
- };
10
- export declare type ContentImageBlock = {
11
- content: BlockItem;
12
- image: ImageProps;
13
- } & SeenProp;
14
- export declare type ContentBlock = {
15
- content: Array<BlockItem>;
16
- image?: undefined;
17
- } & SeenProp;
18
- export declare type BlockProps = BemPropsModifier & (ContentBlock | ContentImageBlock);
19
- declare const Block: (props: BlockProps & {
20
- bem: string;
21
- }) => JSX.Element;
22
- export default Block;
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import getBemClass from '@hugsmidjan/react/utils/getBemClass';
3
- import { useSeenEffect } from '../utils/seenEffect';
4
- import Button from './Button';
5
- import Image from './Image';
6
- const Block = (props) => {
7
- const { image, modifier, bem, content, startSeen } = props;
8
- const [ref] = useSeenEffect(startSeen);
9
- const contentItems = Array.isArray(content) ? content : [content];
10
- return (React.createElement("div", { className: getBemClass(bem, modifier), ref: ref },
11
- contentItems.map(({ title, summary, buttons = [] }, i) => {
12
- const hasSummary = summary && (typeof summary !== 'string' || !!summary.trim());
13
- return (React.createElement("div", { key: i, className: `${bem}__content` },
14
- React.createElement("h2", { className: `${bem}__title` }, title),
15
- hasSummary && React.createElement("div", { className: `${bem}__summary` }, summary),
16
- buttons.length > 0 && (React.createElement("div", { className: `${bem}__buttons` },
17
- ' ',
18
- buttons.map((buttonProps, i) => (React.createElement(React.Fragment, null,
19
- React.createElement(Button, Object.assign({ bem: `${bem}__button`, key: i }, buttonProps)),
20
- ' ')))))));
21
- }),
22
- image && React.createElement(Image, Object.assign({ className: `${bem}__image` }, image))));
23
- };
24
- export default Block;
@@ -1,9 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export declare type QuoteProps = {
3
- children: ReactNode;
4
- by?: string | JSX.Element;
5
- byHref?: string;
6
- };
7
- export declare const _Quote: (props: {
8
- bem: string;
9
- } & QuoteProps) => JSX.Element;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { Link } from './Link';
3
- export const _Quote = (props) => {
4
- const { bem, children, by, byHref } = props;
5
- return (React.createElement("figure", { className: bem },
6
- React.createElement("blockquote", { className: bem + '__quote' }, children),
7
- by && (React.createElement("figcaption", { className: bem + '__by' }, byHref ? (React.createElement(Link, { href: byHref }, by)) : typeof by === 'string' ? (React.createElement("span", null, by)) : (by)))));
8
- };
@@ -1,2 +0,0 @@
1
- declare const breakOnNL: (text: string | undefined) => "" | (string | JSX.Element)[] | undefined;
2
- export default breakOnNL;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- const breakOnNL = (text) => text &&
3
- text
4
- .trim()
5
- .replace(/(?:\n\s*)+/g, '\n\n')
6
- .split(/\n/)
7
- .map((bit) => bit || React.createElement("br", null));
8
- export default breakOnNL;
package/esm/assets.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import type { BlingType, Efnistakn, Formheimur, Illustration } from '@reykjavik/hanna-utils/assets';
2
- import { blingTypes, efnistakn, getAssetUrl, getBlingUrl, getEfnistaknUrl, getFormheimurUrl, getIllustrationUrl, illustrations } from '@reykjavik/hanna-utils/assets';
3
- export type {
4
- /** @deprecated Instead `import type { BlingType } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
5
- BlingType,
6
- /** @deprecated Instead `import type { Efnistakn } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
7
- Efnistakn,
8
- /** @deprecated Instead `import type { Formheimur } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
9
- Formheimur,
10
- /** @deprecated Instead `import type { Illustration } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
11
- Illustration, };
12
- export {
13
- /** @deprecated Instead `import type { blingTypes } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
14
- blingTypes,
15
- /** @deprecated Instead `import type { efnistakn } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
16
- efnistakn,
17
- /** @deprecated Instead `import type { getAssetUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
18
- getAssetUrl,
19
- /** @deprecated Instead `import type { getBlingUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
20
- getBlingUrl,
21
- /** @deprecated Instead `import type { getEfnistaknUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
22
- getEfnistaknUrl,
23
- /** @deprecated Instead `import type { getFormheimurUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
24
- getFormheimurUrl,
25
- /** @deprecated Instead `import type { getIllustrationUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
26
- getIllustrationUrl,
27
- /** @deprecated Instead `import type { illustrations } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
28
- illustrations, };
29
- /** @deprecated Use `getCssBundleUrl` from '@reykjavik/hanna-css' instead (Will be reomved in v0.11) */
30
- export declare const getCssBundleUrl: (cssTokens: string | Array<string>, version?: string | undefined) => string;
31
- /** @deprecated (Will be removed in v0.11) */
32
- export declare const efnistakn_menu: readonly ["menu/borgarstjori", "menu/borgarstjorn", "menu/bygg_framkv", "menu/fjarmal", "menu/fundargerdir", "menu/itrottir_aftreying", "menu/log_reglugerdir", "menu/mannaudur", "menu/menning", "menu/rad_nefndir", "menu/skipulag", "menu/skolar_fristund", "menu/svid_deildir", "menu/umhverfi_samgongur", "menu/velferd_fjolskylda"];
33
- /** @deprecated (Will be removed in v0.11) */
34
- export declare type Efnistakn_Menu = typeof efnistakn_menu[number];
35
- /** @deprecated (Will be removed in v0.11) */
36
- export declare const auxiliary_menu_images: Array<Illustration>;
37
- /** @deprecated Instead `import type { AuxilaryPanelIllustration } from '@reykjavik/hanna-react/MainMenu';` (Will be removed in v0.11) */
38
- export declare type Auxilary_MenuImages = typeof auxiliary_menu_images[number];
39
- /** @deprecated Instead `import type { BlingType } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
40
- export declare type BlingTypes = BlingType;
41
- /** @deprecated Instead `import type { Illustration } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
42
- export declare type Illustrations = Illustration;
package/esm/assets.js DELETED
@@ -1,56 +0,0 @@
1
- import { getCssBundleUrl as _getCssBundleUrl } from '@reykjavik/hanna-css';
2
- import { blingTypes, efnistakn, getAssetUrl, getBlingUrl, getEfnistaknUrl, getFormheimurUrl, getIllustrationUrl, illustrations, } from '@reykjavik/hanna-utils/assets';
3
- export {
4
- /** @deprecated Instead `import type { blingTypes } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
5
- blingTypes,
6
- /** @deprecated Instead `import type { efnistakn } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
7
- efnistakn,
8
- /** @deprecated Instead `import type { getAssetUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
9
- getAssetUrl,
10
- /** @deprecated Instead `import type { getBlingUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
11
- getBlingUrl,
12
- /** @deprecated Instead `import type { getEfnistaknUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
13
- getEfnistaknUrl,
14
- /** @deprecated Instead `import type { getFormheimurUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
15
- getFormheimurUrl,
16
- /** @deprecated Instead `import type { getIllustrationUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
17
- getIllustrationUrl,
18
- /** @deprecated Instead `import type { illustrations } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
19
- illustrations, };
20
- /** @deprecated Use `getCssBundleUrl` from '@reykjavik/hanna-css' instead (Will be reomved in v0.11) */
21
- export const getCssBundleUrl = (cssTokens,
22
- /** If you want to pin your CSS files to a specific version */
23
- version) => _getCssBundleUrl(cssTokens, { version });
24
- // ---------------------------------------------------------------------------
25
- // Based on "https://styles.reykjavik.is/assets/efnistakn/menu/files.json"
26
- /** @deprecated (Will be removed in v0.11) */
27
- export const efnistakn_menu = [
28
- 'menu/borgarstjori',
29
- 'menu/borgarstjorn',
30
- 'menu/bygg_framkv',
31
- 'menu/fjarmal',
32
- 'menu/fundargerdir',
33
- 'menu/itrottir_aftreying',
34
- 'menu/log_reglugerdir',
35
- 'menu/mannaudur',
36
- 'menu/menning',
37
- 'menu/rad_nefndir',
38
- 'menu/skipulag',
39
- 'menu/skolar_fristund',
40
- 'menu/svid_deildir',
41
- 'menu/umhverfi_samgongur',
42
- 'menu/velferd_fjolskylda',
43
- ];
44
- // ---------------------------------------------------------------------------
45
- /** @deprecated (Will be removed in v0.11) */
46
- export const auxiliary_menu_images = [
47
- 'hanna-veitiggi',
48
- 'hanna-vandro',
49
- 'hanna-hugsi',
50
- 'hanna-hissa',
51
- 'hanna-hahaha',
52
- 'hanna-hae',
53
- 'hanna-god_spurning',
54
- 'hanna-gjuggiborg',
55
- 'hanna-benda',
56
- ];
@@ -1,39 +0,0 @@
1
- /** @depcrecated import `colorFamilies` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
2
- export declare const colorFamilies: readonly ["esja", "faxafloi", "nautholsvik", "heidmork", "ellidaardalur", "blafjoll", "sund", "rokkur", "suld"] & {
3
- readonly esja: "esja";
4
- readonly faxafloi: "faxafloi";
5
- readonly nautholsvik: "nautholsvik";
6
- readonly heidmork: "heidmork";
7
- readonly ellidaardalur: "ellidaardalur";
8
- readonly blafjoll: "blafjoll";
9
- readonly sund: "sund";
10
- readonly rokkur: "rokkur";
11
- readonly suld: "suld";
12
- } & {
13
- /** @deprecated This is a typo (Will be removed in v0.11) */
14
- ellidarardalur: string;
15
- };
16
- /** @depcrecated import type `ColorFamily` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
17
- export type { ColorFamily } from '@reykjavik/hanna-css';
18
- /** @depcrecated import `colorThemes` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
19
- export declare const themeOptions: readonly ["trustworthy", "dependable", "friendly", "lively", "colorful"] & {
20
- readonly trustworthy: "trustworthy";
21
- readonly dependable: "dependable";
22
- readonly friendly: "friendly";
23
- readonly lively: "lively";
24
- readonly colorful: "colorful";
25
- };
26
- /** @depcrecated import type `HannaColorTheme` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
27
- export type { HannaColorTheme as ThemeOption } from '@reykjavik/hanna-css';
28
- export declare type Alignment = 'right' | 'left';
29
- export declare const aligns: Record<string, true | undefined>;
30
- export declare type ComponentLayoutProps<Align extends string = 'right'> = {
31
- wide?: undefined;
32
- align?: undefined;
33
- } | {
34
- wide: boolean;
35
- align?: undefined;
36
- } | {
37
- wide?: undefined;
38
- align: Align;
39
- };
package/esm/constants.js DELETED
@@ -1,22 +0,0 @@
1
- import { colorFamilies as _colorFamilies, colorThemes } from '@reykjavik/hanna-css';
2
- /** @depcrecated import `colorFamilies` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
3
- export const colorFamilies = Object.assign([
4
- 'esja',
5
- 'faxafloi',
6
- 'nautholsvik',
7
- 'heidmork',
8
- 'ellidaardalur',
9
- 'blafjoll',
10
- 'sund',
11
- 'rokkur',
12
- 'suld',
13
- ], _colorFamilies, {
14
- /** @deprecated This is a typo (Will be removed in v0.11) */
15
- ellidarardalur: 'ellidaardalur',
16
- });
17
- /** @depcrecated import `colorThemes` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
18
- export const themeOptions = Object.assign(['trustworthy', 'dependable', 'friendly', 'lively', 'colorful'], colorThemes);
19
- export const aligns = {
20
- right: true,
21
- left: true,
22
- };
@@ -1 +0,0 @@
1
- import '@reykjavik/hanna-utils/focus-visible';
@@ -1 +0,0 @@
1
- import '@reykjavik/hanna-utils/focus-visible';
package/esm/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"module"}
@@ -1 +0,0 @@
1
- export declare const isPreact: true | undefined;
package/esm/utils/env.js DELETED
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- export const isPreact =
3
- // imported from 'preact'
4
- 'h' in React ||
5
- // imported from 'preact/compat' (has all of `react-dom` bundled)
6
- ('hydrate' in React && 'render' in React) ||
7
- // `undefined` instead of `false` for nicer prop usage
8
- undefined;
@@ -1,28 +0,0 @@
1
- import { RefObject } from 'react';
2
- export declare const DATA_ATTR_NAME = "is-seen";
3
- export declare const getObserver: {
4
- (target: Element, callback?: ((target: Element) => void) | undefined): (() => void) | undefined;
5
- DATA_ATTR_NAME: string;
6
- };
7
- export declare const seenEffectOptOut: (target: Element, setFlag?: boolean) => void;
8
- declare const effects: {
9
- readonly fadein: 1;
10
- readonly fadeup: 1;
11
- readonly fadeleft: 1;
12
- };
13
- export declare type SeenEffectType = keyof typeof effects;
14
- export declare type EffectProp = {
15
- /** Should the component appear instantly, and not transition-in once seen */
16
- effectType?: SeenEffectType;
17
- };
18
- /** Asserts that a prop value is a SeenEffectType and returns undefined otherwise */
19
- export declare const assertEffectType: (maybeType?: string | undefined) => SeenEffectType | undefined;
20
- export declare const getEffectAttr: (maybeType?: string | undefined) => {
21
- 'data-seen-effect': string;
22
- };
23
- export declare type SeenProp = {
24
- /** Should the component appear instantly, and not transition-in once seen */
25
- startSeen?: boolean;
26
- };
27
- export declare const useSeenEffect: <E extends Element = HTMLDivElement>(startSeen?: boolean | undefined, customRef?: RefObject<E> | undefined) => [RefObject<E> | undefined, true | undefined];
28
- export {};
@@ -1,73 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
- export const DATA_ATTR_NAME = 'is-seen';
3
- const STACKING_DELAY = 400; // ms
4
- const dataAttr = 'data-' + DATA_ATTR_NAME;
5
- const inTargetSourceOrder = (a, b) => a.target.compareDocumentPosition(b.target) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;
6
- const options = {
7
- // root: window
8
- rootMargin: '-100px 0px 0px 0px',
9
- threshold: 0, // 0
10
- };
11
- let observer;
12
- export const getObserver = (target, callback) => {
13
- if (target.hasAttribute(dataAttr)) {
14
- return;
15
- }
16
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
17
- if (!observer) {
18
- observer = new IntersectionObserver((entries, observer) => entries
19
- .filter((e) => e.isIntersecting)
20
- .sort(inTargetSourceOrder)
21
- .forEach(({ target }, i) => {
22
- setTimeout(() => {
23
- target.setAttribute(dataAttr, 'true');
24
- callback && callback(target);
25
- observer.unobserve(target);
26
- }, STACKING_DELAY * i);
27
- }), options);
28
- }
29
- if (target.matches('[' + dataAttr + '] *')) {
30
- // opt out if target is contained by another "seen-effect" element
31
- target.setAttribute(dataAttr, '');
32
- return;
33
- }
34
- target.setAttribute(dataAttr, 'false');
35
- observer.observe(target);
36
- return () => observer.unobserve(target);
37
- };
38
- export const seenEffectOptOut = (target, setFlag = true) => {
39
- setFlag ? target.setAttribute(dataAttr, '') : target.removeAttribute(dataAttr);
40
- };
41
- getObserver.DATA_ATTR_NAME = DATA_ATTR_NAME;
42
- // ---------------------------------------------------------------------------
43
- // ---------------------------------------------------------------------------
44
- const effects = {
45
- fadein: 1,
46
- fadeup: 1,
47
- fadeleft: 1,
48
- };
49
- /** Asserts that a prop value is a SeenEffectType and returns undefined otherwise */
50
- export const assertEffectType = (maybeType) => maybeType && maybeType in effects ? maybeType : undefined;
51
- export const getEffectAttr = (maybeType) => ({
52
- 'data-seen-effect': assertEffectType(maybeType) || '',
53
- });
54
- export const useSeenEffect = (
55
- /** Should the component appear instantly, and not transition-in once seen */
56
- startSeen,
57
- /** Bring Your Own RefObject */
58
- customRef) => {
59
- const localRef = useRef(null);
60
- const [isSeen, setSeen] = useState(startSeen || undefined);
61
- const ref = !startSeen && (customRef || localRef);
62
- useEffect(() => {
63
- setSeen(startSeen || undefined);
64
- if (ref && ref.current) {
65
- // NOTE: Given that `ref` is defined, then
66
- // `startSeen` is implicily `false | undefined` at
67
- // this point.
68
- seenEffectOptOut(ref.current, false);
69
- return getObserver(ref.current, () => setSeen(true));
70
- }
71
- }, [ref, startSeen]);
72
- return [ref || undefined, isSeen];
73
- };
@@ -1,38 +0,0 @@
1
- /**
2
- * Pass a callback that gets called whenever the browser window
3
- * resizes past one of the preconfigured "media-format" breakpoints.
4
- *
5
- * Exmple use:
6
- *
7
- * ```ts
8
- * useFormatMonitor((media) => {
9
- * if (media.is === 'phone') {
10
- * // do something clever because the window
11
- * // just became "phone" sized.
12
- * }
13
- * if (media.was === 'phone') {
14
- * // do something clever because the window
15
- * // just stopped being "phone" sized.
16
- * }
17
- * })
18
- * ```
19
- *
20
- * The `media` argument has the following properties:
21
- *
22
- * ```ts
23
- * // type Formats = 'phone' | 'phablet' | 'tablet' | 'netbook' | 'wide'
24
- * media.is //: Format
25
- * media.was //?: Format
26
- * // Category/mode boolean flags
27
- * // (Hamburger refers to the "mobile menu" mode)
28
- * media.isTopmenu
29
- * media.isHamburger
30
- * media.wasTopmenu
31
- * media.wasHamburger
32
- * media.becameTopmenu
33
- * media.becameHamburger
34
- * media.leftTopmenu
35
- * media.leftHamburger
36
- * ```
37
- */
38
- export declare const useFormatMonitor: (callback: (media: import("formatchange").BaseMedia & Record<"isHamburger" | "isTopmenu" | "wasHamburger" | "wasTopmenu" | "becameHamburger" | "becameTopmenu" | "leftHamburger" | "leftTopmenu", boolean>) => void) => void;
@@ -1,41 +0,0 @@
1
- import { formatMonitor } from '@reykjavik/hanna-utils';
2
- import { makeFormatMonitorHook } from 'formatchange/react';
3
- // ==================================================
4
- /**
5
- * Pass a callback that gets called whenever the browser window
6
- * resizes past one of the preconfigured "media-format" breakpoints.
7
- *
8
- * Exmple use:
9
- *
10
- * ```ts
11
- * useFormatMonitor((media) => {
12
- * if (media.is === 'phone') {
13
- * // do something clever because the window
14
- * // just became "phone" sized.
15
- * }
16
- * if (media.was === 'phone') {
17
- * // do something clever because the window
18
- * // just stopped being "phone" sized.
19
- * }
20
- * })
21
- * ```
22
- *
23
- * The `media` argument has the following properties:
24
- *
25
- * ```ts
26
- * // type Formats = 'phone' | 'phablet' | 'tablet' | 'netbook' | 'wide'
27
- * media.is //: Format
28
- * media.was //?: Format
29
- * // Category/mode boolean flags
30
- * // (Hamburger refers to the "mobile menu" mode)
31
- * media.isTopmenu
32
- * media.isHamburger
33
- * media.wasTopmenu
34
- * media.wasHamburger
35
- * media.becameTopmenu
36
- * media.becameHamburger
37
- * media.leftTopmenu
38
- * media.leftHamburger
39
- * ```
40
- */
41
- export const useFormatMonitor = makeFormatMonitorHook(formatMonitor);
@@ -1,6 +0,0 @@
1
- declare type SVGMeta = {
2
- imageSrc: string;
3
- code: string;
4
- };
5
- export declare const useGetSVGtext: (imageSrc: string | undefined) => SVGMeta | undefined;
6
- export {};
@@ -1,19 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
- import { getSVGtext } from '@reykjavik/hanna-utils';
3
- export const useGetSVGtext = (imageSrc) => {
4
- const [inlineSvg, setInlineSvg] = useState();
5
- const srcRef = useRef(imageSrc);
6
- useEffect(() => {
7
- if (imageSrc) {
8
- getSVGtext(imageSrc).then((code) => {
9
- if (imageSrc === srcRef.current) {
10
- setInlineSvg({ imageSrc, code });
11
- }
12
- });
13
- }
14
- srcRef.current = imageSrc;
15
- setInlineSvg(undefined);
16
- // eslint-disable-next-line react-hooks/exhaustive-deps
17
- }, [imageSrc]);
18
- return inlineSvg;
19
- };
@@ -1,8 +0,0 @@
1
- declare type MenuTogglingState = {
2
- isMenuActive: true | undefined;
3
- isMenuOpen: boolean;
4
- toggleMenu: () => void;
5
- closeMenu: () => void;
6
- };
7
- export declare const useMenuToggling: (doInitialize?: boolean) => MenuTogglingState;
8
- export {};