@reykjavik/hanna-react 0.10.59 → 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 (355) hide show
  1. package/AccordionList.js +3 -28
  2. package/ActionCards.js +2 -4
  3. package/Alert.js +4 -29
  4. package/ArticleCards.js +2 -4
  5. package/ArticleCarousel/_ArticleCarouselCard.js +4 -6
  6. package/ArticleCarousel.js +3 -5
  7. package/ArticleMeta.js +3 -28
  8. package/Attention.js +3 -5
  9. package/BasicTable.js +5 -7
  10. package/BgBox.js +3 -5
  11. package/Bling.js +3 -5
  12. package/BlockBreak.js +2 -4
  13. package/BlockQuote.js +2 -4
  14. package/BreadCrumbs.js +2 -4
  15. package/ButtonBack.js +3 -5
  16. package/ButtonBar.js +3 -5
  17. package/ButtonPrimary.js +3 -5
  18. package/ButtonSecondary.js +3 -5
  19. package/ButtonTertiary.js +3 -5
  20. package/CHANGELOG.md +8 -0
  21. package/Carousel.js +3 -5
  22. package/CarouselStepper.js +3 -5
  23. package/CenterColumn.js +3 -5
  24. package/Checkbox.js +3 -5
  25. package/CheckboxButtonsGroup.js +4 -6
  26. package/CheckboxGroup.js +4 -6
  27. package/CityBlock.js +3 -5
  28. package/ContactBubble.js +4 -29
  29. package/ContentArticle.js +8 -10
  30. package/ContentImage.js +3 -5
  31. package/Datepicker.js +6 -31
  32. package/ExtraLinks.js +4 -17
  33. package/FeatureList.js +3 -5
  34. package/FieldGroup.js +3 -5
  35. package/FileInput.js +5 -41
  36. package/Foonote.js +2 -4
  37. package/FooterBadges.js +2 -4
  38. package/FooterInfo.js +3 -5
  39. package/Footnote.js +2 -4
  40. package/Form.js +3 -5
  41. package/FormField.js +3 -28
  42. package/Gallery/_GalleryItem.js +6 -42
  43. package/Gallery/_GalleryModal.js +6 -31
  44. package/Gallery/_GalleryModalContext.js +2 -4
  45. package/Gallery/_GalleryModalItem.js +4 -17
  46. package/Gallery.js +6 -31
  47. package/GridBlocks.js +5 -7
  48. package/Heading.js +3 -5
  49. package/HeroBlock.js +5 -7
  50. package/IframeBlock.d.ts +5 -1
  51. package/IframeBlock.js +6 -8
  52. package/Illustration.js +3 -5
  53. package/ImageCards.js +4 -17
  54. package/InfoBlock.js +2 -4
  55. package/InfoHero.js +7 -9
  56. package/IslandBlock.js +3 -5
  57. package/IslandPageBlock.js +3 -5
  58. package/LabeledTextBlock.js +4 -6
  59. package/Layout.js +4 -6
  60. package/MainMenu/_Auxiliary.js +2 -4
  61. package/MainMenu/_PrimaryPanel.js +3 -5
  62. package/MainMenu.js +5 -30
  63. package/MiniMetrics.js +4 -6
  64. package/Modal.js +3 -5
  65. package/NameCard.js +5 -7
  66. package/NameCards.js +3 -5
  67. package/NewsHero.js +6 -8
  68. package/PageFilter.js +4 -6
  69. package/PageHeading.js +3 -5
  70. package/Picture.js +4 -6
  71. package/ProcessOverview.js +3 -5
  72. package/PullQuote.js +2 -4
  73. package/RadioButtonsGroup.js +4 -6
  74. package/RadioGroup.js +4 -6
  75. package/RelatedLinks.js +2 -4
  76. package/RowBlock.js +3 -5
  77. package/RowBlockColumn.js +3 -5
  78. package/SearchInput.js +5 -41
  79. package/SearchResults/_SearchResultsItem.js +3 -5
  80. package/SearchResults.js +7 -32
  81. package/SeenEffect.js +3 -16
  82. package/Selectbox.js +6 -42
  83. package/ShareButtons.js +2 -24
  84. package/Sharpie.js +3 -5
  85. package/SiteSearchAutocomplete.js +5 -41
  86. package/SiteSearchCurtain.js +3 -28
  87. package/SiteSearchInput.d.ts +1 -1
  88. package/SiteSearchInput.js +4 -40
  89. package/Skeleton.js +4 -6
  90. package/SubHeading.js +3 -5
  91. package/Tabs.js +3 -28
  92. package/TagPill.js +5 -18
  93. package/TextBlock.js +3 -5
  94. package/TextButton.js +3 -5
  95. package/TextInput.js +5 -41
  96. package/VSpacer.js +3 -5
  97. package/VerticalTabsTOC.js +3 -28
  98. package/WizardLayout.js +3 -5
  99. package/WizardLayoutClose.js +3 -5
  100. package/WizardStepper.js +3 -5
  101. package/_abstract/_AbstractCarousel.js +7 -32
  102. package/_abstract/_Blings.js +3 -5
  103. package/_abstract/_Block.js +5 -7
  104. package/_abstract/_Button.js +4 -17
  105. package/_abstract/_CardList.js +4 -6
  106. package/_abstract/_Image.js +3 -5
  107. package/_abstract/_Link.js +2 -4
  108. package/_abstract/_Quote.js +2 -4
  109. package/_abstract/_TogglerGroup.js +8 -8
  110. package/_abstract/_TogglerGroupField.js +6 -19
  111. package/_abstract/_TogglerInput.js +4 -17
  112. package/_abstract/breakOnNL.js +2 -4
  113. package/package.json +4 -378
  114. package/utils/env.js +2 -4
  115. package/utils/useScrollbarWidthCSSVar.js +2 -4
  116. package/utils.js +3 -16
  117. package/esm/AccordionList.d.ts +0 -17
  118. package/esm/AccordionList.js +0 -24
  119. package/esm/ActionCards.d.ts +0 -5
  120. package/esm/ActionCards.js +0 -9
  121. package/esm/Alert.d.ts +0 -49
  122. package/esm/Alert.js +0 -92
  123. package/esm/ArticleCards.d.ts +0 -6
  124. package/esm/ArticleCards.js +0 -4
  125. package/esm/ArticleCarousel/_ArticleCarouselCard.d.ts +0 -27
  126. package/esm/ArticleCarousel/_ArticleCarouselCard.js +0 -24
  127. package/esm/ArticleCarousel.d.ts +0 -12
  128. package/esm/ArticleCarousel.js +0 -8
  129. package/esm/ArticleMeta.d.ts +0 -10
  130. package/esm/ArticleMeta.js +0 -19
  131. package/esm/Attention.d.ts +0 -7
  132. package/esm/Attention.js +0 -4
  133. package/esm/BasicTable.d.ts +0 -12
  134. package/esm/BasicTable.js +0 -29
  135. package/esm/BgBox.d.ts +0 -8
  136. package/esm/BgBox.js +0 -9
  137. package/esm/Bling.d.ts +0 -81
  138. package/esm/Bling.js +0 -44
  139. package/esm/BlockBreak.d.ts +0 -2
  140. package/esm/BlockBreak.js +0 -6
  141. package/esm/BlockQuote.d.ts +0 -4
  142. package/esm/BlockQuote.js +0 -4
  143. package/esm/BreadCrumbs.d.ts +0 -11
  144. package/esm/BreadCrumbs.js +0 -28
  145. package/esm/ButtonBack.d.ts +0 -7
  146. package/esm/ButtonBack.js +0 -4
  147. package/esm/ButtonBar.d.ts +0 -16
  148. package/esm/ButtonBar.js +0 -14
  149. package/esm/ButtonPrimary.d.ts +0 -7
  150. package/esm/ButtonPrimary.js +0 -4
  151. package/esm/ButtonSecondary.d.ts +0 -7
  152. package/esm/ButtonSecondary.js +0 -4
  153. package/esm/ButtonTertiary.d.ts +0 -12
  154. package/esm/ButtonTertiary.js +0 -15
  155. package/esm/Carousel.d.ts +0 -4
  156. package/esm/Carousel.js +0 -4
  157. package/esm/CarouselStepper.d.ts +0 -4
  158. package/esm/CarouselStepper.js +0 -4
  159. package/esm/CenterColumn.d.ts +0 -7
  160. package/esm/CenterColumn.js +0 -7
  161. package/esm/Checkbox.d.ts +0 -4
  162. package/esm/Checkbox.js +0 -4
  163. package/esm/CheckboxButtonsGroup.d.ts +0 -11
  164. package/esm/CheckboxButtonsGroup.js +0 -14
  165. package/esm/CheckboxGroup.d.ts +0 -9
  166. package/esm/CheckboxGroup.js +0 -7
  167. package/esm/CityBlock.d.ts +0 -23
  168. package/esm/CityBlock.js +0 -18
  169. package/esm/ContactBubble.d.ts +0 -58
  170. package/esm/ContactBubble.js +0 -148
  171. package/esm/ContentArticle.d.ts +0 -15
  172. package/esm/ContentArticle.js +0 -21
  173. package/esm/ContentImage.d.ts +0 -8
  174. package/esm/ContentImage.js +0 -18
  175. package/esm/Datepicker.d.ts +0 -39
  176. package/esm/Datepicker.js +0 -63
  177. package/esm/ExtraLinks.d.ts +0 -18
  178. package/esm/ExtraLinks.js +0 -34
  179. package/esm/FeatureList.d.ts +0 -12
  180. package/esm/FeatureList.js +0 -16
  181. package/esm/FieldGroup.d.ts +0 -9
  182. package/esm/FieldGroup.js +0 -9
  183. package/esm/FileInput.d.ts +0 -17
  184. package/esm/FileInput.js +0 -154
  185. package/esm/Foonote.d.ts +0 -12
  186. package/esm/Foonote.js +0 -7
  187. package/esm/FooterBadges.d.ts +0 -9
  188. package/esm/FooterBadges.js +0 -12
  189. package/esm/FooterInfo.d.ts +0 -18
  190. package/esm/FooterInfo.js +0 -9
  191. package/esm/Footnote.d.ts +0 -6
  192. package/esm/Footnote.js +0 -3
  193. package/esm/Form.d.ts +0 -7
  194. package/esm/Form.js +0 -10
  195. package/esm/FormField.d.ts +0 -65
  196. package/esm/FormField.js +0 -91
  197. package/esm/Gallery/_GalleryItem.d.ts +0 -8
  198. package/esm/Gallery/_GalleryItem.js +0 -30
  199. package/esm/Gallery/_GalleryModal.d.ts +0 -6
  200. package/esm/Gallery/_GalleryModal.js +0 -54
  201. package/esm/Gallery/_GalleryModalContext.d.ts +0 -9
  202. package/esm/Gallery/_GalleryModalContext.js +0 -3
  203. package/esm/Gallery/_GalleryModalItem.d.ts +0 -3
  204. package/esm/Gallery/_GalleryModalItem.js +0 -22
  205. package/esm/Gallery.d.ts +0 -17
  206. package/esm/Gallery.js +0 -27
  207. package/esm/GridBlocks.d.ts +0 -26
  208. package/esm/GridBlocks.js +0 -24
  209. package/esm/Heading.d.ts +0 -16
  210. package/esm/Heading.js +0 -17
  211. package/esm/HeroBlock.d.ts +0 -19
  212. package/esm/HeroBlock.js +0 -21
  213. package/esm/IframeBlock.d.ts +0 -23
  214. package/esm/IframeBlock.js +0 -26
  215. package/esm/Illustration.d.ts +0 -13
  216. package/esm/Illustration.js +0 -8
  217. package/esm/ImageCards.d.ts +0 -8
  218. package/esm/ImageCards.js +0 -22
  219. package/esm/InfoBlock.d.ts +0 -17
  220. package/esm/InfoBlock.js +0 -13
  221. package/esm/InfoHero.d.ts +0 -17
  222. package/esm/InfoHero.js +0 -82
  223. package/esm/IslandBlock.d.ts +0 -25
  224. package/esm/IslandBlock.js +0 -16
  225. package/esm/IslandPageBlock.d.ts +0 -24
  226. package/esm/IslandPageBlock.js +0 -16
  227. package/esm/LabeledTextBlock.d.ts +0 -11
  228. package/esm/LabeledTextBlock.js +0 -14
  229. package/esm/Layout.d.ts +0 -33
  230. package/esm/Layout.js +0 -52
  231. package/esm/MainMenu/_Auxiliary.d.ts +0 -6
  232. package/esm/MainMenu/_Auxiliary.js +0 -13
  233. package/esm/MainMenu/_PrimaryPanel.d.ts +0 -13
  234. package/esm/MainMenu/_PrimaryPanel.js +0 -22
  235. package/esm/MainMenu.d.ts +0 -48
  236. package/esm/MainMenu.js +0 -136
  237. package/esm/MiniMetrics.d.ts +0 -8
  238. package/esm/MiniMetrics.js +0 -12
  239. package/esm/Modal.d.ts +0 -10
  240. package/esm/Modal.js +0 -14
  241. package/esm/NameCard.d.ts +0 -64
  242. package/esm/NameCard.js +0 -82
  243. package/esm/NameCards.d.ts +0 -6
  244. package/esm/NameCards.js +0 -7
  245. package/esm/NewsHero.d.ts +0 -14
  246. package/esm/NewsHero.js +0 -86
  247. package/esm/PageFilter.d.ts +0 -17
  248. package/esm/PageFilter.js +0 -15
  249. package/esm/PageHeading.d.ts +0 -10
  250. package/esm/PageHeading.js +0 -12
  251. package/esm/Picture.d.ts +0 -7
  252. package/esm/Picture.js +0 -8
  253. package/esm/ProcessOverview.d.ts +0 -13
  254. package/esm/ProcessOverview.js +0 -17
  255. package/esm/PullQuote.d.ts +0 -4
  256. package/esm/PullQuote.js +0 -4
  257. package/esm/RadioButtonsGroup.d.ts +0 -11
  258. package/esm/RadioButtonsGroup.js +0 -14
  259. package/esm/RadioGroup.d.ts +0 -13
  260. package/esm/RadioGroup.js +0 -7
  261. package/esm/RelatedLinks.d.ts +0 -20
  262. package/esm/RelatedLinks.js +0 -26
  263. package/esm/RowBlock.d.ts +0 -12
  264. package/esm/RowBlock.js +0 -9
  265. package/esm/RowBlockColumn.d.ts +0 -8
  266. package/esm/RowBlockColumn.js +0 -11
  267. package/esm/SearchInput.d.ts +0 -18
  268. package/esm/SearchInput.js +0 -33
  269. package/esm/SearchResults/_SearchResultsItem.d.ts +0 -18
  270. package/esm/SearchResults/_SearchResultsItem.js +0 -15
  271. package/esm/SearchResults.d.ts +0 -33
  272. package/esm/SearchResults.js +0 -109
  273. package/esm/SeenEffect.d.ts +0 -4
  274. package/esm/SeenEffect.js +0 -19
  275. package/esm/Selectbox.d.ts +0 -8
  276. package/esm/Selectbox.js +0 -46
  277. package/esm/ShareButtons.d.ts +0 -9
  278. package/esm/ShareButtons.js +0 -51
  279. package/esm/Sharpie.d.ts +0 -23
  280. package/esm/Sharpie.js +0 -22
  281. package/esm/SiteSearchAutocomplete.d.ts +0 -40
  282. package/esm/SiteSearchAutocomplete.js +0 -58
  283. package/esm/SiteSearchCurtain.d.ts +0 -6
  284. package/esm/SiteSearchCurtain.js +0 -33
  285. package/esm/SiteSearchInput.d.ts +0 -24
  286. package/esm/SiteSearchInput.js +0 -40
  287. package/esm/Skeleton.d.ts +0 -25
  288. package/esm/Skeleton.js +0 -30
  289. package/esm/SubHeading.d.ts +0 -10
  290. package/esm/SubHeading.js +0 -13
  291. package/esm/Tabs.d.ts +0 -35
  292. package/esm/Tabs.js +0 -94
  293. package/esm/TagPill.d.ts +0 -27
  294. package/esm/TagPill.js +0 -43
  295. package/esm/TextBlock.d.ts +0 -15
  296. package/esm/TextBlock.js +0 -15
  297. package/esm/TextButton.d.ts +0 -9
  298. package/esm/TextButton.js +0 -9
  299. package/esm/TextInput.d.ts +0 -16
  300. package/esm/TextInput.js +0 -35
  301. package/esm/VSpacer.d.ts +0 -24
  302. package/esm/VSpacer.js +0 -41
  303. package/esm/VerticalTabsTOC.d.ts +0 -14
  304. package/esm/VerticalTabsTOC.js +0 -68
  305. package/esm/WizardLayout.d.ts +0 -15
  306. package/esm/WizardLayout.js +0 -30
  307. package/esm/WizardLayoutClose.d.ts +0 -3
  308. package/esm/WizardLayoutClose.js +0 -4
  309. package/esm/WizardStepper.d.ts +0 -36
  310. package/esm/WizardStepper.js +0 -25
  311. package/esm/_abstract/_AbstractCarousel.d.ts +0 -25
  312. package/esm/_abstract/_AbstractCarousel.js +0 -130
  313. package/esm/_abstract/_Blings.d.ts +0 -11
  314. package/esm/_abstract/_Blings.js +0 -12
  315. package/esm/_abstract/_Block.d.ts +0 -22
  316. package/esm/_abstract/_Block.js +0 -24
  317. package/esm/_abstract/_Button.d.ts +0 -40
  318. package/esm/_abstract/_Button.js +0 -47
  319. package/esm/_abstract/_CardList.d.ts +0 -30
  320. package/esm/_abstract/_CardList.js +0 -38
  321. package/esm/_abstract/_Image.d.ts +0 -36
  322. package/esm/_abstract/_Image.js +0 -27
  323. package/esm/_abstract/_Link.d.ts +0 -27
  324. package/esm/_abstract/_Link.js +0 -24
  325. package/esm/_abstract/_Quote.d.ts +0 -9
  326. package/esm/_abstract/_Quote.js +0 -8
  327. package/esm/_abstract/_TogglerGroup.d.ts +0 -31
  328. package/esm/_abstract/_TogglerGroup.js +0 -29
  329. package/esm/_abstract/_TogglerGroupField.d.ts +0 -17
  330. package/esm/_abstract/_TogglerGroupField.js +0 -22
  331. package/esm/_abstract/_TogglerInput.d.ts +0 -22
  332. package/esm/_abstract/_TogglerInput.js +0 -33
  333. package/esm/_abstract/breakOnNL.d.ts +0 -2
  334. package/esm/_abstract/breakOnNL.js +0 -8
  335. package/esm/assets.d.ts +0 -42
  336. package/esm/assets.js +0 -56
  337. package/esm/constants.d.ts +0 -39
  338. package/esm/constants.js +0 -22
  339. package/esm/focus-visible.d.ts +0 -1
  340. package/esm/focus-visible.js +0 -1
  341. package/esm/package.json +0 -1
  342. package/esm/utils/env.d.ts +0 -1
  343. package/esm/utils/env.js +0 -8
  344. package/esm/utils/seenEffect.d.ts +0 -28
  345. package/esm/utils/seenEffect.js +0 -73
  346. package/esm/utils/useFormatMonitor.d.ts +0 -38
  347. package/esm/utils/useFormatMonitor.js +0 -41
  348. package/esm/utils/useGetSVGtext.d.ts +0 -6
  349. package/esm/utils/useGetSVGtext.js +0 -19
  350. package/esm/utils/useMenuToggling.d.ts +0 -8
  351. package/esm/utils/useMenuToggling.js +0 -62
  352. package/esm/utils/useScrollbarWidthCSSVar.d.ts +0 -1
  353. package/esm/utils/useScrollbarWidthCSSVar.js +0 -3
  354. package/esm/utils.d.ts +0 -2
  355. package/esm/utils.js +0 -2
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import getBemClass from '@hugsmidjan/react/utils/getBemClass';
3
- import { useGetSVGtext } from '../utils/useGetSVGtext';
4
- // eslint-disable-next-line complexity
5
- const Image = (props) => {
6
- const { src, altText = '', sources = [], preloadSrc, className, inline, placeholder, focalPoint, } = props;
7
- const _src = (sources.length && preloadSrc) || src;
8
- const imageSrc = _src || (sources[0] != null ? sources[0].srcset.split(' ')[0] : undefined);
9
- const imgLoading = preloadSrc ? 'eager' : 'lazy';
10
- const inlineSvg = useGetSVGtext(inline ? imageSrc : undefined);
11
- if (!imageSrc) {
12
- return placeholder ? (React.createElement("span", { className: className && getBemClass(className, 'missing') }, placeholder !== true && placeholder())) : null;
13
- }
14
- if (inline && inlineSvg) {
15
- const __html = inlineSvg.imageSrc === imageSrc ? inlineSvg.code : '';
16
- return React.createElement("span", { className: className, dangerouslySetInnerHTML: { __html } });
17
- }
18
- return (React.createElement("picture", { className: className, style: focalPoint ? { '--focalPoint': focalPoint } : undefined },
19
- ' ',
20
- sources.map((source, i) => (React.createElement(React.Fragment, null,
21
- React.createElement("source", { key: i, srcSet: source.srcset, media: source.media }),
22
- ' '))),
23
- ' ',
24
- React.createElement("img", { src: imageSrc, alt: altText, loading: imgLoading }),
25
- ' '));
26
- };
27
- export default Image;
@@ -1,27 +0,0 @@
1
- /**
2
- * Props object ready to be ..spread onto an anchor element
3
- * */
4
- export declare type LinkProps = JSX.IntrinsicElements['a'] & {
5
- href: string;
6
- };
7
- export declare type LinkRenderer = (props: LinkProps) => JSX.Element;
8
- export declare let Link: LinkRenderer;
9
- /**
10
- * Allows you to set a callback function to wrapp <a href=""/> links with
11
- * a custom routing component.
12
- *
13
- * Example use:
14
- *
15
- * ```js
16
- * import { Link } from 'remix'; // or whatever :-)
17
- *
18
- * setLinkRenderer((linkProps) =>
19
- * <Link to={linkProps.href}><a {...linkProps} /></Link>);
20
- * ```
21
- *
22
- * The Default linkrenderer defined as:
23
- * ```js
24
- * (linkProps) => React.createElement('a', linkProps);
25
- * ```
26
- */
27
- export declare const setLinkRenderer: (linkRenderer: LinkRenderer | undefined) => void;
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- const DefaultLinkRenderer = (props) => React.createElement('a', props);
3
- export let Link = DefaultLinkRenderer;
4
- /**
5
- * Allows you to set a callback function to wrapp <a href=""/> links with
6
- * a custom routing component.
7
- *
8
- * Example use:
9
- *
10
- * ```js
11
- * import { Link } from 'remix'; // or whatever :-)
12
- *
13
- * setLinkRenderer((linkProps) =>
14
- * <Link to={linkProps.href}><a {...linkProps} /></Link>);
15
- * ```
16
- *
17
- * The Default linkrenderer defined as:
18
- * ```js
19
- * (linkProps) => React.createElement('a', linkProps);
20
- * ```
21
- */
22
- export const setLinkRenderer = (linkRenderer) => {
23
- Link = linkRenderer || DefaultLinkRenderer;
24
- };
@@ -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,31 +0,0 @@
1
- import { FormFieldInputProps } from '../FormField';
2
- import { TogglerInputProps } from './_TogglerInput';
3
- export declare type TogglerGroupOption = {
4
- value: string;
5
- label?: string | JSX.Element;
6
- disabled?: boolean;
7
- id?: string;
8
- };
9
- export declare type TogglerGroupOptions = Array<TogglerGroupOption>;
10
- declare type RestrictedInputProps = Omit<JSX.IntrinsicElements['input'], 'type' | 'value' | 'checked' | 'defaultChecked' | 'className' | 'id' | 'name' | 'children'>;
11
- export declare type TogglerGroupProps = {
12
- options: TogglerGroupOptions;
13
- className?: string;
14
- name: string;
15
- children?: undefined;
16
- disabled?: boolean | ReadonlyArray<number>;
17
- inputProps?: RestrictedInputProps;
18
- onSelected?: (payload: {
19
- value: string;
20
- checked: boolean;
21
- option: TogglerGroupOption;
22
- selectedValues: Array<string>;
23
- }) => void;
24
- } & Omit<FormFieldInputProps, 'disabled'>;
25
- declare type _TogglerGroupProps = {
26
- bem: string;
27
- Toggler: (props: TogglerInputProps) => JSX.Element;
28
- value?: ReadonlyArray<string>;
29
- };
30
- declare const TogglerGroup: (props: TogglerGroupProps & _TogglerGroupProps) => JSX.Element;
31
- export default TogglerGroup;
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import getBemClass from '@hugsmidjan/react/utils/getBemClass';
3
- const TogglerGroup = (props) => {
4
- const {
5
- // id,
6
- className, bem, name, disabled, Toggler, onSelected, options, inputProps = {}, } = props;
7
- const values = props.value || [];
8
- return (React.createElement("ul", { className: getBemClass(bem, null, className), role: "group", "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-required": props.required }, options.map((option, i) => {
9
- const isDisabled = option.disabled != null
10
- ? option.disabled
11
- : disabled && typeof disabled !== 'boolean'
12
- ? disabled.includes(i)
13
- : disabled;
14
- const isChecked = values.includes(option.value);
15
- return (React.createElement(Toggler, Object.assign({ key: i }, inputProps, { className: bem + '__item', name: name, Wrapper: "li" }, option, { label: option.label || option.value, onChange: onSelected
16
- ? (e) => {
17
- const { value } = option;
18
- const checked = e.currentTarget.checked;
19
- inputProps.onChange && inputProps.onChange(e);
20
- const selectedValues = values.filter((val) => val !== value);
21
- if (checked) {
22
- selectedValues.push(value);
23
- }
24
- onSelected({ value, checked, option, selectedValues });
25
- }
26
- : inputProps.onChange, disabled: isDisabled, "aria-invalid": props['aria-invalid'], checked: isChecked })));
27
- })));
28
- };
29
- export default TogglerGroup;
@@ -1,17 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { BemPropsModifier } from '@hugsmidjan/react/types';
3
- import { FormFieldGroupWrappingProps } from '../FormField';
4
- import { TogglerGroupOption, TogglerGroupOptions, TogglerGroupProps } from './_TogglerGroup';
5
- import { TogglerInputProps } from './_TogglerInput';
6
- export declare type TogglerGroupFieldProps = {
7
- className?: string;
8
- } & FormFieldGroupWrappingProps & TogglerGroupProps;
9
- declare type _TogglerGroupFieldProps = {
10
- Toggler: (props: TogglerInputProps) => ReactElement;
11
- value?: string | ReadonlyArray<string>;
12
- bem: string;
13
- } & BemPropsModifier;
14
- export declare type TogglerGroupFieldOption = TogglerGroupOption;
15
- export declare type TogglerGroupFieldOptions = TogglerGroupOptions;
16
- declare const TogglerGroupField: (props: TogglerGroupFieldProps & _TogglerGroupFieldProps) => JSX.Element;
17
- export default TogglerGroupField;
@@ -1,22 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React from 'react';
13
- import getBemClass from '@hugsmidjan/react/utils/getBemClass';
14
- import FormField from '../FormField';
15
- import TogglerGroup from './_TogglerGroup';
16
- const TogglerGroupField = (props) => {
17
- const { bem, Toggler, className, modifier, label, LabelTag, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, value } = props, togglerGroupProps = __rest(props, ["bem", "Toggler", "className", "modifier", "label", "LabelTag", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "value"]);
18
- return (React.createElement(FormField, { className: getBemClass(bem, modifier, className), group: true, label: label, LabelTag: LabelTag, assistText: assistText, hideLabel: hideLabel, disabled: disabled, readOnly: readOnly, invalid: invalid, errorMessage: errorMessage, required: required, reqText: reqText, id: id, renderInput: (className, inputProps) => {
19
- return (React.createElement(TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { value: Array.isArray(value) ? value : value != null ? [value] : undefined, Toggler: Toggler })));
20
- } }));
21
- };
22
- export default TogglerGroupField;
@@ -1,22 +0,0 @@
1
- import { BemPropsModifier } from '@hugsmidjan/react/types';
2
- export declare type TogglerInputProps = {
3
- label: string | JSX.Element;
4
- children?: undefined;
5
- Wrapper?: 'div' | 'li';
6
- invalid?: boolean;
7
- /** Hidden label prefix text to indicate that the field is required.
8
- *
9
- * If your field is required but should not say so in its label
10
- * then set this prop to `false`
11
- *
12
- * Default: `"Þarf að fylla út"`
13
- * */
14
- reqText?: string | false;
15
- errorMessage?: string | JSX.Element;
16
- } & BemPropsModifier & Omit<JSX.IntrinsicElements['input'], 'type'>;
17
- declare type _TogglerInputProps = {
18
- bem: string;
19
- type: 'radio' | 'checkbox';
20
- };
21
- declare const TogglerInput: (props: TogglerInputProps & _TogglerInputProps) => JSX.Element;
22
- export default TogglerInput;
@@ -1,33 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React from 'react';
13
- import { useDomid } from '@hugsmidjan/react/hooks';
14
- import getBemClass from '@hugsmidjan/react/utils/getBemClass';
15
- const TogglerInput = (props) => {
16
- const { bem, modifier, className, label, invalid, errorMessage, Wrapper = 'div', required, reqText, type, id } = props, inputProps = __rest(props, ["bem", "modifier", "className", "label", "invalid", "errorMessage", "Wrapper", "required", "reqText", "type", "id"]);
17
- const domid = useDomid(id);
18
- const errorId = errorMessage && 'error' + domid;
19
- const reqStar = required && reqText !== false && (React.createElement("abbr", { className: bem + '__label__reqstar',
20
- // TODO: add mo-better i18n thinking
21
- title: (reqText || 'Þarf að haka í') + ': ' }, "*"));
22
- return (React.createElement(Wrapper, { className: getBemClass(bem, modifier, className) },
23
- React.createElement("input", Object.assign({ className: bem + '__input', type: type, id: domid, "aria-invalid": invalid || !!errorMessage || undefined, "aria-describedby": errorId }, inputProps)),
24
- ' ',
25
- React.createElement("label", { className: bem + '__label', htmlFor: domid },
26
- ' ',
27
- reqStar,
28
- " ",
29
- label,
30
- ' '),
31
- errorMessage && (React.createElement("div", { className: bem + '__error', id: errorId }, errorMessage))));
32
- };
33
- export default TogglerInput;
@@ -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 | 'none';
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 | undefined;
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': maybeType === 'none' ? undefined : 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);