@reykjavik/hanna-react 0.10.83 → 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.
- package/AccordionList.d.ts +2 -2
- package/AccordionList.js +5 -5
- package/ActionCards.d.ts +2 -2
- package/ActionCards.js +4 -4
- package/Alert.d.ts +1 -1
- package/Alert.js +6 -6
- package/ArticleCards.d.ts +1 -1
- package/ArticleCards.js +2 -2
- package/ArticleCarousel/_ArticleCarouselCard.d.ts +2 -2
- package/ArticleCarousel/_ArticleCarouselCard.js +7 -7
- package/ArticleCarousel.d.ts +3 -3
- package/ArticleCarousel.js +3 -3
- package/ArticleMeta.js +2 -2
- package/BasicTable.d.ts +1 -1
- package/BasicTable.js +2 -2
- package/BgBox.d.ts +1 -1
- package/BgBox.js +3 -3
- package/Bling.js +2 -2
- package/BlockQuote.d.ts +1 -1
- package/BlockQuote.js +2 -2
- package/BreadCrumbs.js +2 -2
- package/ButtonBack.d.ts +1 -1
- package/ButtonBack.js +2 -2
- package/ButtonPrimary.d.ts +1 -1
- package/ButtonPrimary.js +2 -2
- package/ButtonSecondary.d.ts +1 -1
- package/ButtonSecondary.js +2 -2
- package/ButtonTertiary.d.ts +1 -1
- package/ButtonTertiary.js +2 -2
- package/CHANGELOG.md +13 -0
- package/Carousel.d.ts +2 -2
- package/Carousel.js +2 -2
- package/CenterColumn.d.ts +1 -1
- package/CenterColumn.js +2 -2
- package/Checkbox.d.ts +1 -1
- package/Checkbox.js +2 -2
- package/CheckboxButton.d.ts +1 -1
- package/CheckboxButton.js +2 -2
- package/CheckboxButtonsGroup.d.ts +1 -1
- package/CheckboxButtonsGroup.js +3 -3
- package/CheckboxGroup.d.ts +1 -1
- package/CheckboxGroup.js +3 -3
- package/CityBlock.d.ts +4 -4
- package/CityBlock.js +4 -4
- package/ContactBubble.d.ts +1 -1
- package/ContactBubble.js +6 -6
- package/ContentArticle.d.ts +4 -4
- package/ContentArticle.js +14 -14
- package/ContentImage.d.ts +1 -1
- package/ContentImage.js +2 -2
- package/Datepicker.d.ts +1 -1
- package/Datepicker.js +2 -2
- package/ExtraLinks.d.ts +2 -2
- package/ExtraLinks.js +6 -6
- package/FeatureList.d.ts +1 -1
- package/FeatureList.js +4 -4
- package/FileInput.d.ts +2 -2
- package/FileInput.js +4 -4
- package/Foonote.d.ts +1 -1
- package/Foonote.js +2 -2
- package/FooterBadges.js +2 -2
- package/Form.d.ts +1 -1
- package/FormField.d.ts +1 -1
- package/FormField.js +4 -4
- package/Gallery/_GalleryItem.d.ts +1 -1
- package/Gallery/_GalleryItem.js +7 -7
- package/Gallery/_GalleryModal.d.ts +1 -1
- package/Gallery/_GalleryModal.js +4 -4
- package/Gallery/_GalleryModalContext.d.ts +2 -2
- package/Gallery/_GalleryModalItem.d.ts +1 -1
- package/Gallery/_GalleryModalItem.js +2 -2
- package/Gallery.d.ts +4 -4
- package/Gallery.js +7 -7
- package/GridBlocks.d.ts +3 -3
- package/GridBlocks.js +8 -8
- package/Heading.d.ts +1 -1
- package/HeroBlock.d.ts +3 -3
- package/HeroBlock.js +8 -8
- package/Illustration.d.ts +1 -1
- package/Illustration.js +2 -2
- package/ImageCards.d.ts +2 -2
- package/ImageCards.js +4 -4
- package/InfoBlock.d.ts +1 -1
- package/InfoBlock.js +2 -2
- package/InfoHero.d.ts +3 -3
- package/InfoHero.js +10 -10
- package/IslandBlock.d.ts +4 -4
- package/IslandBlock.js +4 -4
- package/IslandPageBlock.d.ts +4 -4
- package/IslandPageBlock.js +4 -4
- package/LabeledTextBlock.d.ts +2 -2
- package/LabeledTextBlock.js +4 -4
- package/Layout.d.ts +1 -1
- package/Layout.js +13 -13
- package/MainMenu/_Auxiliary.d.ts +1 -1
- package/MainMenu/_Auxiliary.js +2 -2
- package/MainMenu/_PrimaryPanel.js +2 -2
- package/MainMenu.d.ts +3 -3
- package/MainMenu.js +15 -13
- package/MiniMetrics.d.ts +2 -2
- package/MiniMetrics.js +4 -4
- package/NameCard.js +4 -4
- package/NameCards.d.ts +1 -1
- package/NameCards.js +2 -2
- package/NewsHero.d.ts +2 -2
- package/NewsHero.js +7 -7
- package/PageFilter.d.ts +1 -1
- package/PageFilter.js +4 -4
- package/PageHeading.d.ts +1 -1
- package/PageHeading.js +2 -2
- package/Picture.d.ts +1 -1
- package/Picture.js +2 -2
- package/PullQuote.d.ts +1 -1
- package/PullQuote.js +2 -2
- package/RadioButtonsGroup.d.ts +1 -1
- package/RadioButtonsGroup.js +4 -4
- package/RadioGroup.d.ts +2 -2
- package/RadioGroup.js +4 -4
- package/RelatedLinks.js +2 -2
- package/RowBlock.d.ts +1 -1
- package/RowBlock.js +2 -2
- package/SearchInput.d.ts +1 -1
- package/SearchInput.js +2 -2
- package/SearchResults/_SearchResultsItem.js +4 -4
- package/SearchResults.d.ts +2 -2
- package/SearchResults.js +7 -7
- package/SeenEffect.d.ts +1 -1
- package/SeenEffect.js +3 -3
- package/Selectbox.d.ts +2 -2
- package/Selectbox.js +2 -2
- package/ShareButtons.d.ts +1 -1
- package/ShareButtons.js +2 -2
- package/SiteSearchAutocomplete.js +2 -2
- package/SiteSearchCurtain.js +2 -2
- package/SiteSearchInput.d.ts +2 -2
- package/SiteSearchInput.js +2 -2
- package/SubHeading.d.ts +2 -2
- package/SubHeading.js +2 -2
- package/Tabs.d.ts +2 -2
- package/Tabs.js +4 -4
- package/TagPill.d.ts +1 -1
- package/TagPill.js +3 -3
- package/TextBlock.d.ts +2 -2
- package/TextBlock.js +2 -2
- package/TextButton.d.ts +1 -1
- package/TextButton.js +2 -2
- package/TextInput.d.ts +1 -1
- package/TextInput.js +2 -2
- package/VerticalTabsTOC.d.ts +1 -1
- package/VerticalTabsTOC.js +2 -2
- package/WizardLayout.d.ts +1 -1
- package/WizardLayout.js +8 -8
- package/WizardLayoutClose.d.ts +1 -1
- package/WizardLayoutClose.js +2 -2
- package/_abstract/_AbstractCarousel.d.ts +2 -2
- package/_abstract/_AbstractCarousel.js +6 -6
- package/_abstract/_Blings.d.ts +1 -1
- package/_abstract/_Blings.js +2 -2
- package/_abstract/_Block.d.ts +3 -3
- package/_abstract/_Block.js +6 -6
- package/_abstract/_Button.js +2 -2
- package/_abstract/_CardList.d.ts +1 -1
- package/_abstract/_CardList.js +4 -4
- package/_abstract/_Image.js +2 -2
- package/_abstract/_Quote.js +2 -2
- package/_abstract/_TogglerGroup.d.ts +2 -2
- package/_abstract/_TogglerGroup.js +2 -2
- package/_abstract/_TogglerGroupField.d.ts +3 -3
- package/_abstract/_TogglerGroupField.js +4 -4
- package/assets.d.ts +2 -2
- package/esm/AccordionList.d.ts +25 -0
- package/esm/AccordionList.js +32 -0
- package/esm/ActionCards.d.ts +6 -0
- package/esm/ActionCards.js +9 -0
- package/esm/Alert.d.ts +48 -0
- package/esm/Alert.js +90 -0
- package/esm/ArticleCards.d.ts +8 -0
- package/esm/ArticleCards.js +4 -0
- package/esm/ArticleCarousel/_ArticleCarouselCard.d.ts +28 -0
- package/esm/ArticleCarousel/_ArticleCarouselCard.js +24 -0
- package/esm/ArticleCarousel.d.ts +12 -0
- package/esm/ArticleCarousel.js +8 -0
- package/esm/ArticleMeta.d.ts +10 -0
- package/esm/ArticleMeta.js +19 -0
- package/esm/Attention.d.ts +7 -0
- package/esm/Attention.js +4 -0
- package/esm/BasicTable.d.ts +14 -0
- package/esm/BasicTable.js +29 -0
- package/esm/BgBox.d.ts +8 -0
- package/esm/BgBox.js +9 -0
- package/esm/Bling.d.ts +81 -0
- package/esm/Bling.js +44 -0
- package/esm/BlockBreak.d.ts +2 -0
- package/esm/BlockBreak.js +6 -0
- package/esm/BlockQuote.d.ts +4 -0
- package/esm/BlockQuote.js +4 -0
- package/esm/BreadCrumbs.d.ts +11 -0
- package/esm/BreadCrumbs.js +28 -0
- package/esm/ButtonBack.d.ts +7 -0
- package/esm/ButtonBack.js +4 -0
- package/esm/ButtonBar.d.ts +17 -0
- package/esm/ButtonBar.js +15 -0
- package/esm/ButtonPrimary.d.ts +7 -0
- package/esm/ButtonPrimary.js +4 -0
- package/esm/ButtonSecondary.d.ts +7 -0
- package/esm/ButtonSecondary.js +4 -0
- package/esm/ButtonTertiary.d.ts +12 -0
- package/esm/ButtonTertiary.js +15 -0
- package/esm/Carousel.d.ts +4 -0
- package/esm/Carousel.js +4 -0
- package/esm/CarouselStepper.d.ts +4 -0
- package/esm/CarouselStepper.js +4 -0
- package/esm/CenterColumn.d.ts +7 -0
- package/esm/CenterColumn.js +7 -0
- package/esm/Checkbox.d.ts +4 -0
- package/esm/Checkbox.js +4 -0
- package/esm/CheckboxButton.d.ts +4 -0
- package/esm/CheckboxButton.js +4 -0
- package/esm/CheckboxButtonsGroup.d.ts +12 -0
- package/esm/CheckboxButtonsGroup.js +13 -0
- package/esm/CheckboxGroup.d.ts +10 -0
- package/esm/CheckboxGroup.js +7 -0
- package/esm/CityBlock.d.ts +21 -0
- package/esm/CityBlock.js +18 -0
- package/esm/ContactBubble.d.ts +58 -0
- package/esm/ContactBubble.js +152 -0
- package/esm/ContentArticle.d.ts +16 -0
- package/esm/ContentArticle.js +24 -0
- package/esm/ContentImage.d.ts +8 -0
- package/esm/ContentImage.js +18 -0
- package/esm/Datepicker.d.ts +40 -0
- package/esm/Datepicker.js +78 -0
- package/esm/ExtraLinks.d.ts +18 -0
- package/esm/ExtraLinks.js +24 -0
- package/esm/FeatureList.d.ts +12 -0
- package/esm/FeatureList.js +16 -0
- package/esm/FieldGroup.d.ts +10 -0
- package/esm/FieldGroup.js +9 -0
- package/esm/FileInput/_FileInput.utils.d.ts +36 -0
- package/esm/FileInput/_FileInput.utils.js +69 -0
- package/esm/FileInput/_FileInputFileList.d.ts +11 -0
- package/esm/FileInput/_FileInputFileList.js +19 -0
- package/esm/FileInput.d.ts +48 -0
- package/esm/FileInput.js +130 -0
- package/esm/Foonote.d.ts +12 -0
- package/esm/Foonote.js +7 -0
- package/esm/FooterBadges.d.ts +9 -0
- package/esm/FooterBadges.js +12 -0
- package/esm/FooterInfo.d.ts +20 -0
- package/esm/FooterInfo.js +12 -0
- package/esm/Footnote.d.ts +6 -0
- package/esm/Footnote.js +3 -0
- package/esm/Form.d.ts +7 -0
- package/esm/Form.js +10 -0
- package/esm/FormField.d.ts +65 -0
- package/esm/FormField.js +92 -0
- package/esm/Gallery/_GalleryItem.d.ts +7 -0
- package/esm/Gallery/_GalleryItem.js +19 -0
- package/esm/Gallery/_GalleryModal.d.ts +6 -0
- package/esm/Gallery/_GalleryModal.js +53 -0
- package/esm/Gallery/_GalleryModalContext.d.ts +9 -0
- package/esm/Gallery/_GalleryModalContext.js +2 -0
- package/esm/Gallery/_GalleryModalItem.d.ts +2 -0
- package/esm/Gallery/_GalleryModalItem.js +11 -0
- package/esm/Gallery.d.ts +17 -0
- package/esm/Gallery.js +27 -0
- package/esm/GridBlocks.d.ts +26 -0
- package/esm/GridBlocks.js +24 -0
- package/esm/Heading.d.ts +22 -0
- package/esm/Heading.js +19 -0
- package/esm/HeroBlock.d.ts +19 -0
- package/esm/HeroBlock.js +21 -0
- package/esm/IframeBlock.d.ts +28 -0
- package/esm/IframeBlock.js +26 -0
- package/esm/Illustration.d.ts +10 -0
- package/esm/Illustration.js +8 -0
- package/esm/ImageCards.d.ts +10 -0
- package/esm/ImageCards.js +12 -0
- package/esm/InfoBlock.d.ts +13 -0
- package/esm/InfoBlock.js +13 -0
- package/esm/InfoHero.d.ts +18 -0
- package/esm/InfoHero.js +83 -0
- package/esm/IslandBlock.d.ts +25 -0
- package/esm/IslandBlock.js +16 -0
- package/esm/IslandPageBlock.d.ts +24 -0
- package/esm/IslandPageBlock.js +16 -0
- package/esm/LabeledTextBlock.d.ts +11 -0
- package/esm/LabeledTextBlock.js +14 -0
- package/esm/Layout.d.ts +32 -0
- package/esm/Layout.js +56 -0
- package/esm/MainMenu/_Auxiliary.d.ts +6 -0
- package/esm/MainMenu/_Auxiliary.js +13 -0
- package/esm/MainMenu/_PrimaryPanel.d.ts +29 -0
- package/esm/MainMenu/_PrimaryPanel.js +22 -0
- package/esm/MainMenu.d.ts +62 -0
- package/esm/MainMenu.js +221 -0
- package/esm/MiniMetrics.d.ts +8 -0
- package/esm/MiniMetrics.js +12 -0
- package/esm/Modal.d.ts +8 -0
- package/esm/Modal.js +14 -0
- package/esm/NameCard.d.ts +64 -0
- package/esm/NameCard.js +82 -0
- package/esm/NameCards.d.ts +6 -0
- package/esm/NameCards.js +7 -0
- package/esm/NewsHero.d.ts +14 -0
- package/esm/NewsHero.js +86 -0
- package/esm/PageFilter.d.ts +16 -0
- package/esm/PageFilter.js +15 -0
- package/esm/PageHeading.d.ts +10 -0
- package/esm/PageHeading.js +12 -0
- package/esm/Picture.d.ts +7 -0
- package/esm/Picture.js +8 -0
- package/esm/ProcessOverview.d.ts +13 -0
- package/esm/ProcessOverview.js +17 -0
- package/esm/PullQuote.d.ts +4 -0
- package/esm/PullQuote.js +4 -0
- package/esm/RadioButtonsGroup.d.ts +12 -0
- package/esm/RadioButtonsGroup.js +14 -0
- package/esm/RadioGroup.d.ts +16 -0
- package/esm/RadioGroup.js +8 -0
- package/esm/RelatedLinks.d.ts +20 -0
- package/esm/RelatedLinks.js +26 -0
- package/esm/RowBlock.d.ts +12 -0
- package/esm/RowBlock.js +9 -0
- package/esm/RowBlockColumn.d.ts +8 -0
- package/esm/RowBlockColumn.js +11 -0
- package/esm/SearchInput.d.ts +18 -0
- package/esm/SearchInput.js +23 -0
- package/esm/SearchResults/_SearchResultsItem.d.ts +18 -0
- package/esm/SearchResults/_SearchResultsItem.js +14 -0
- package/esm/SearchResults.d.ts +37 -0
- package/esm/SearchResults.js +108 -0
- package/esm/SeenEffect.d.ts +4 -0
- package/esm/SeenEffect.js +9 -0
- package/esm/Selectbox.d.ts +11 -0
- package/esm/Selectbox.js +40 -0
- package/esm/ShareButtons.d.ts +9 -0
- package/esm/ShareButtons.js +56 -0
- package/esm/Sharpie.d.ts +23 -0
- package/esm/Sharpie.js +22 -0
- package/esm/SiteSearchAutocomplete.d.ts +40 -0
- package/esm/SiteSearchAutocomplete.js +48 -0
- package/esm/SiteSearchCurtain.d.ts +6 -0
- package/esm/SiteSearchCurtain.js +28 -0
- package/esm/SiteSearchInput.d.ts +24 -0
- package/esm/SiteSearchInput.js +30 -0
- package/esm/Skeleton.d.ts +25 -0
- package/esm/Skeleton.js +30 -0
- package/esm/SubHeading.d.ts +10 -0
- package/esm/SubHeading.js +13 -0
- package/esm/Tabs.d.ts +35 -0
- package/esm/Tabs.js +94 -0
- package/esm/TagPill.d.ts +25 -0
- package/esm/TagPill.js +34 -0
- package/esm/TextBlock.d.ts +15 -0
- package/esm/TextBlock.js +15 -0
- package/esm/TextButton.d.ts +9 -0
- package/esm/TextButton.js +9 -0
- package/esm/TextInput.d.ts +16 -0
- package/esm/TextInput.js +32 -0
- package/esm/Tooltip.d.ts +7 -0
- package/esm/Tooltip.js +58 -0
- package/esm/VSpacer.d.ts +22 -0
- package/esm/VSpacer.js +41 -0
- package/esm/VerticalTabsTOC.d.ts +14 -0
- package/esm/VerticalTabsTOC.js +68 -0
- package/esm/WizardLayout.d.ts +15 -0
- package/esm/WizardLayout.js +30 -0
- package/esm/WizardLayoutClose.d.ts +3 -0
- package/esm/WizardLayoutClose.js +4 -0
- package/esm/WizardStepper.d.ts +36 -0
- package/esm/WizardStepper.js +26 -0
- package/esm/_abstract/_AbstractCarousel.d.ts +29 -0
- package/esm/_abstract/_AbstractCarousel.js +108 -0
- package/esm/_abstract/_Blings.d.ts +11 -0
- package/esm/_abstract/_Blings.js +11 -0
- package/esm/_abstract/_Block.d.ts +21 -0
- package/esm/_abstract/_Block.js +23 -0
- package/esm/_abstract/_Button.d.ts +40 -0
- package/esm/_abstract/_Button.js +36 -0
- package/esm/_abstract/_CardList.d.ts +34 -0
- package/esm/_abstract/_CardList.js +37 -0
- package/esm/_abstract/_Image.d.ts +36 -0
- package/esm/_abstract/_Image.js +26 -0
- package/esm/_abstract/_Link.d.ts +60 -0
- package/esm/_abstract/_Link.js +64 -0
- package/esm/_abstract/_Quote.d.ts +11 -0
- package/esm/_abstract/_Quote.js +8 -0
- package/esm/_abstract/_TogglerGroup.d.ts +32 -0
- package/esm/_abstract/_TogglerGroup.js +28 -0
- package/esm/_abstract/_TogglerGroupField.d.ts +19 -0
- package/esm/_abstract/_TogglerGroupField.js +17 -0
- package/esm/_abstract/_TogglerInput.d.ts +23 -0
- package/esm/_abstract/_TogglerInput.js +23 -0
- package/esm/_abstract/breakOnNL.d.ts +1 -0
- package/esm/_abstract/breakOnNL.js +7 -0
- package/esm/assets.d.ts +42 -0
- package/esm/assets.js +58 -0
- package/esm/constants.d.ts +19 -0
- package/esm/constants.js +22 -0
- package/esm/focus-visible.d.ts +1 -0
- package/esm/focus-visible.js +3 -0
- package/esm/index.d.ts +97 -0
- package/esm/index.js +1 -0
- package/esm/package.json +1 -0
- package/esm/utils/HannaUIState.d.ts +8 -0
- package/esm/utils/HannaUIState.js +7 -0
- package/esm/utils/browserSide.d.ts +1 -0
- package/esm/utils/browserSide.js +1 -0
- package/esm/utils/config.d.ts +4 -0
- package/esm/utils/config.js +2 -0
- package/esm/utils/env.d.ts +1 -0
- package/esm/utils/env.js +8 -0
- package/esm/utils/seenEffect.d.ts +27 -0
- package/esm/utils/seenEffect.js +75 -0
- package/esm/utils/useDidChange.d.ts +37 -0
- package/esm/utils/useDidChange.js +43 -0
- package/esm/utils/useFormatMonitor.d.ts +38 -0
- package/esm/utils/useFormatMonitor.js +41 -0
- package/esm/utils/useGetSVGtext.d.ts +10 -0
- package/esm/utils/useGetSVGtext.js +23 -0
- package/esm/utils/useMenuToggling.d.ts +8 -0
- package/esm/utils/useMenuToggling.js +62 -0
- package/esm/utils/useMixedControlState.d.ts +137 -0
- package/esm/utils/useMixedControlState.js +101 -0
- package/esm/utils/useScrollbarWidthCSSVar.d.ts +17 -0
- package/esm/utils/useScrollbarWidthCSSVar.js +19 -0
- package/esm/utils.d.ts +8 -0
- package/esm/utils.js +8 -0
- package/package.json +390 -4
- package/utils/config.d.ts +2 -2
- package/utils/config.js +2 -2
- package/utils/useDidChange.d.ts +1 -1
- package/utils/useDidChange.js +1 -1
- package/utils/useMenuToggling.js +2 -2
- package/utils.d.ts +8 -8
- package/utils.js +8 -8
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/// <reference path="./AccordionList.d.tsx" />
|
|
2
|
+
/// <reference path="./ActionCards.d.tsx" />
|
|
3
|
+
/// <reference path="./Alert.d.tsx" />
|
|
4
|
+
/// <reference path="./ArticleCards.d.tsx" />
|
|
5
|
+
/// <reference path="./ArticleCarousel.d.tsx" />
|
|
6
|
+
/// <reference path="./ArticleMeta.d.tsx" />
|
|
7
|
+
/// <reference path="./assets.d.ts" />
|
|
8
|
+
/// <reference path="./Attention.d.tsx" />
|
|
9
|
+
/// <reference path="./BasicTable.d.tsx" />
|
|
10
|
+
/// <reference path="./BgBox.d.tsx" />
|
|
11
|
+
/// <reference path="./Bling.d.tsx" />
|
|
12
|
+
/// <reference path="./BlockBreak.d.tsx" />
|
|
13
|
+
/// <reference path="./BlockQuote.d.tsx" />
|
|
14
|
+
/// <reference path="./BreadCrumbs.d.tsx" />
|
|
15
|
+
/// <reference path="./ButtonBack.d.tsx" />
|
|
16
|
+
/// <reference path="./ButtonBar.d.tsx" />
|
|
17
|
+
/// <reference path="./ButtonPrimary.d.tsx" />
|
|
18
|
+
/// <reference path="./ButtonSecondary.d.tsx" />
|
|
19
|
+
/// <reference path="./ButtonTertiary.d.tsx" />
|
|
20
|
+
/// <reference path="./Carousel.d.tsx" />
|
|
21
|
+
/// <reference path="./CarouselStepper.d.tsx" />
|
|
22
|
+
/// <reference path="./CenterColumn.d.tsx" />
|
|
23
|
+
/// <reference path="./Checkbox.d.tsx" />
|
|
24
|
+
/// <reference path="./CheckboxButton.d.tsx" />
|
|
25
|
+
/// <reference path="./CheckboxButtonsGroup.d.tsx" />
|
|
26
|
+
/// <reference path="./CheckboxGroup.d.tsx" />
|
|
27
|
+
/// <reference path="./CityBlock.d.tsx" />
|
|
28
|
+
/// <reference path="./constants.d.ts" />
|
|
29
|
+
/// <reference path="./ContactBubble.d.tsx" />
|
|
30
|
+
/// <reference path="./ContentArticle.d.tsx" />
|
|
31
|
+
/// <reference path="./ContentImage.d.tsx" />
|
|
32
|
+
/// <reference path="./Datepicker.d.tsx" />
|
|
33
|
+
/// <reference path="./ExtraLinks.d.tsx" />
|
|
34
|
+
/// <reference path="./FeatureList.d.tsx" />
|
|
35
|
+
/// <reference path="./FieldGroup.d.tsx" />
|
|
36
|
+
/// <reference path="./FileInput.d.tsx" />
|
|
37
|
+
/// <reference path="./focus-visible.d.ts" />
|
|
38
|
+
/// <reference path="./Foonote.d.tsx" />
|
|
39
|
+
/// <reference path="./FooterBadges.d.tsx" />
|
|
40
|
+
/// <reference path="./FooterInfo.d.tsx" />
|
|
41
|
+
/// <reference path="./Footnote.d.tsx" />
|
|
42
|
+
/// <reference path="./Form.d.tsx" />
|
|
43
|
+
/// <reference path="./FormField.d.tsx" />
|
|
44
|
+
/// <reference path="./Gallery.d.tsx" />
|
|
45
|
+
/// <reference path="./GridBlocks.d.tsx" />
|
|
46
|
+
/// <reference path="./Heading.d.tsx" />
|
|
47
|
+
/// <reference path="./HeroBlock.d.tsx" />
|
|
48
|
+
/// <reference path="./IframeBlock.d.tsx" />
|
|
49
|
+
/// <reference path="./Illustration.d.tsx" />
|
|
50
|
+
/// <reference path="./ImageCards.d.tsx" />
|
|
51
|
+
/// <reference path="./InfoBlock.d.tsx" />
|
|
52
|
+
/// <reference path="./InfoHero.d.tsx" />
|
|
53
|
+
/// <reference path="./IslandBlock.d.tsx" />
|
|
54
|
+
/// <reference path="./IslandPageBlock.d.tsx" />
|
|
55
|
+
/// <reference path="./LabeledTextBlock.d.tsx" />
|
|
56
|
+
/// <reference path="./Layout.d.tsx" />
|
|
57
|
+
/// <reference path="./MainMenu.d.tsx" />
|
|
58
|
+
/// <reference path="./MiniMetrics.d.tsx" />
|
|
59
|
+
/// <reference path="./Modal.d.tsx" />
|
|
60
|
+
/// <reference path="./NameCard.d.tsx" />
|
|
61
|
+
/// <reference path="./NameCards.d.tsx" />
|
|
62
|
+
/// <reference path="./NewsHero.d.tsx" />
|
|
63
|
+
/// <reference path="./PageFilter.d.tsx" />
|
|
64
|
+
/// <reference path="./PageHeading.d.tsx" />
|
|
65
|
+
/// <reference path="./Picture.d.tsx" />
|
|
66
|
+
/// <reference path="./ProcessOverview.d.tsx" />
|
|
67
|
+
/// <reference path="./PullQuote.d.tsx" />
|
|
68
|
+
/// <reference path="./RadioButtonsGroup.d.tsx" />
|
|
69
|
+
/// <reference path="./RadioGroup.d.tsx" />
|
|
70
|
+
/// <reference path="./RelatedLinks.d.tsx" />
|
|
71
|
+
/// <reference path="./RowBlock.d.tsx" />
|
|
72
|
+
/// <reference path="./RowBlockColumn.d.tsx" />
|
|
73
|
+
/// <reference path="./SearchInput.d.tsx" />
|
|
74
|
+
/// <reference path="./SearchResults.d.tsx" />
|
|
75
|
+
/// <reference path="./SeenEffect.d.tsx" />
|
|
76
|
+
/// <reference path="./Selectbox.d.tsx" />
|
|
77
|
+
/// <reference path="./ShareButtons.d.tsx" />
|
|
78
|
+
/// <reference path="./Sharpie.d.tsx" />
|
|
79
|
+
/// <reference path="./SiteSearchAutocomplete.d.tsx" />
|
|
80
|
+
/// <reference path="./SiteSearchCurtain.d.tsx" />
|
|
81
|
+
/// <reference path="./SiteSearchInput.d.tsx" />
|
|
82
|
+
/// <reference path="./Skeleton.d.tsx" />
|
|
83
|
+
/// <reference path="./SubHeading.d.tsx" />
|
|
84
|
+
/// <reference path="./Tabs.d.tsx" />
|
|
85
|
+
/// <reference path="./TagPill.d.tsx" />
|
|
86
|
+
/// <reference path="./TextBlock.d.tsx" />
|
|
87
|
+
/// <reference path="./TextButton.d.tsx" />
|
|
88
|
+
/// <reference path="./TextInput.d.tsx" />
|
|
89
|
+
/// <reference path="./Tooltip.d.tsx" />
|
|
90
|
+
/// <reference path="./utils.d.ts" />
|
|
91
|
+
/// <reference path="./VerticalTabsTOC.d.tsx" />
|
|
92
|
+
/// <reference path="./VSpacer.d.tsx" />
|
|
93
|
+
/// <reference path="./WizardLayout.d.tsx" />
|
|
94
|
+
/// <reference path="./WizardLayoutClose.d.tsx" />
|
|
95
|
+
/// <reference path="./WizardStepper.d.tsx" />
|
|
96
|
+
|
|
97
|
+
export {};
|
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type HannaUIStateProps = {
|
|
3
|
+
closeHamburgerMenu: () => void;
|
|
4
|
+
isHamburgerMenuOpen: boolean | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const HannaUIState: import("react").Provider<HannaUIStateProps>;
|
|
7
|
+
export declare const useHannaUIState: () => HannaUIStateProps;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
const _HannaUIContext = createContext({
|
|
3
|
+
closeHamburgerMenu: () => undefined,
|
|
4
|
+
isHamburgerMenuOpen: undefined,
|
|
5
|
+
});
|
|
6
|
+
export const HannaUIState = _HannaUIContext.Provider;
|
|
7
|
+
export const useHannaUIState = () => useContext(_HannaUIContext);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useIsBrowserSide, useIsServerSide } from '@hugsmidjan/react/hooks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useIsBrowserSide, useIsServerSide } from '@hugsmidjan/react/hooks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isPreact: true | undefined;
|
package/esm/utils/env.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
declare const effects: {
|
|
8
|
+
readonly fadein: 1;
|
|
9
|
+
readonly fadeup: 1;
|
|
10
|
+
readonly fadeleft: 1;
|
|
11
|
+
};
|
|
12
|
+
export type SeenEffectType = keyof typeof effects;
|
|
13
|
+
export type EffectProp = {
|
|
14
|
+
/** Should the component appear instantly, and not transition-in once seen */
|
|
15
|
+
effectType?: SeenEffectType | 'none';
|
|
16
|
+
};
|
|
17
|
+
/** Asserts that a prop value is a SeenEffectType and returns undefined otherwise */
|
|
18
|
+
export declare const ensureEffectType: (maybeType?: string) => SeenEffectType | undefined;
|
|
19
|
+
export declare const getEffectAttr: (maybeType?: string) => {
|
|
20
|
+
'data-seen-effect': string | undefined;
|
|
21
|
+
};
|
|
22
|
+
export type SeenProp = {
|
|
23
|
+
/** Should the component appear instantly, and not transition-in once seen */
|
|
24
|
+
startSeen?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const useSeenEffect: <E extends Element = HTMLDivElement>(startSeen?: boolean, customRef?: RefObject<E> | undefined) => [RefObject<E> | undefined, true | undefined];
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
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 teardown/unmount effect
|
|
37
|
+
return () => observer.unobserve(target);
|
|
38
|
+
};
|
|
39
|
+
getObserver.DATA_ATTR_NAME = DATA_ATTR_NAME;
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
const effects = {
|
|
43
|
+
fadein: 1,
|
|
44
|
+
fadeup: 1,
|
|
45
|
+
fadeleft: 1,
|
|
46
|
+
};
|
|
47
|
+
/** Asserts that a prop value is a SeenEffectType and returns undefined otherwise */
|
|
48
|
+
export const ensureEffectType = (maybeType) => maybeType && maybeType in effects ? maybeType : undefined;
|
|
49
|
+
export const getEffectAttr = (maybeType) => ({
|
|
50
|
+
'data-seen-effect': maybeType === 'none' ? undefined : ensureEffectType(maybeType) || '',
|
|
51
|
+
});
|
|
52
|
+
export const useSeenEffect = (
|
|
53
|
+
/** Should the component appear instantly, and not transition-in once seen */
|
|
54
|
+
startSeen,
|
|
55
|
+
/** Bring Your Own RefObject */
|
|
56
|
+
customRef) => {
|
|
57
|
+
const _startSeen = startSeen || undefined; // normalize
|
|
58
|
+
const [isSeen, setSeen] = useState(_startSeen);
|
|
59
|
+
const localRef = useRef(null);
|
|
60
|
+
const ref = customRef || localRef;
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
setSeen(_startSeen);
|
|
63
|
+
const refElm = ref.current;
|
|
64
|
+
if (refElm) {
|
|
65
|
+
if (_startSeen) {
|
|
66
|
+
refElm.setAttribute(dataAttr, '');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
refElm.removeAttribute(dataAttr);
|
|
70
|
+
return getObserver(refElm, () => setSeen(true));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [_startSeen, ref]);
|
|
74
|
+
return [ref, isSeen];
|
|
75
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reports if value changed since last time the hook was called.
|
|
3
|
+
*
|
|
4
|
+
* Returns an `{ lastValue }` shaped object, when change is detected.
|
|
5
|
+
* Returns `undefined` otherwise
|
|
6
|
+
*
|
|
7
|
+
* Common usage is if you want an component which is effectively uncontrolled,
|
|
8
|
+
* but resets/changes its internal state whenever a certain prop value changes.
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { useDidChange } from './utils.js';
|
|
12
|
+
* // import { useDidChange } from '@reykjavik/hanna-react/utils';
|
|
13
|
+
*
|
|
14
|
+
* // inside your component/hook
|
|
15
|
+
* const [visible, setVisible] = useState(props.visible);
|
|
16
|
+
* if (useDidChange(props.visible)) {
|
|
17
|
+
* setVisible(props.visible);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Another use case might be to capture not only IF but HOW a prop value changed
|
|
22
|
+
* in a controlled component
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const [trend, setTrend] = useState(null);
|
|
26
|
+
* const countChanged = useDidChange(props.count);
|
|
27
|
+
* if (countChanged) {
|
|
28
|
+
* setTrend(props.count > countChanged.lastValue ? 'increasing' : 'decreasing');
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* **NOTE:** This hook should be handled with care, as its overuse can easily lead
|
|
33
|
+
* to poorly structured and buggy component behavior.
|
|
34
|
+
*/
|
|
35
|
+
export declare const useDidChange: <T>(value: T) => {
|
|
36
|
+
lastValue: T;
|
|
37
|
+
} | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Reports if value changed since last time the hook was called.
|
|
4
|
+
*
|
|
5
|
+
* Returns an `{ lastValue }` shaped object, when change is detected.
|
|
6
|
+
* Returns `undefined` otherwise
|
|
7
|
+
*
|
|
8
|
+
* Common usage is if you want an component which is effectively uncontrolled,
|
|
9
|
+
* but resets/changes its internal state whenever a certain prop value changes.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { useDidChange } from './utils.js';
|
|
13
|
+
* // import { useDidChange } from '@reykjavik/hanna-react/utils';
|
|
14
|
+
*
|
|
15
|
+
* // inside your component/hook
|
|
16
|
+
* const [visible, setVisible] = useState(props.visible);
|
|
17
|
+
* if (useDidChange(props.visible)) {
|
|
18
|
+
* setVisible(props.visible);
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Another use case might be to capture not only IF but HOW a prop value changed
|
|
23
|
+
* in a controlled component
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const [trend, setTrend] = useState(null);
|
|
27
|
+
* const countChanged = useDidChange(props.count);
|
|
28
|
+
* if (countChanged) {
|
|
29
|
+
* setTrend(props.count > countChanged.lastValue ? 'increasing' : 'decreasing');
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* **NOTE:** This hook should be handled with care, as its overuse can easily lead
|
|
34
|
+
* to poorly structured and buggy component behavior.
|
|
35
|
+
*/
|
|
36
|
+
export const useDidChange = (value) => {
|
|
37
|
+
const lastValueRef = useRef(value);
|
|
38
|
+
const lastValue = lastValueRef.current;
|
|
39
|
+
if (value !== lastValue) {
|
|
40
|
+
lastValueRef.current = value;
|
|
41
|
+
return { lastValue };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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) | undefined) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getFormatMonitor } 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(getFormatMonitor);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type SVGMeta = {
|
|
2
|
+
imageSrc: string;
|
|
3
|
+
code: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Fetches a remote SVG image and returns its XML/source
|
|
7
|
+
* string for inlining, or further processing
|
|
8
|
+
*/
|
|
9
|
+
export declare const useGetSVGtext: (imageSrc: string | undefined) => SVGMeta | undefined;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { getSVGtext } from '@reykjavik/hanna-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Fetches a remote SVG image and returns its XML/source
|
|
5
|
+
* string for inlining, or further processing
|
|
6
|
+
*/
|
|
7
|
+
export const useGetSVGtext = (imageSrc) => {
|
|
8
|
+
const [inlineSvg, setInlineSvg] = useState();
|
|
9
|
+
const srcRef = useRef(imageSrc);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (imageSrc) {
|
|
12
|
+
getSVGtext(imageSrc).then((code) => {
|
|
13
|
+
if (imageSrc === srcRef.current) {
|
|
14
|
+
setInlineSvg({ imageSrc, code });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
srcRef.current = imageSrc;
|
|
19
|
+
setInlineSvg(undefined);
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, [imageSrc]);
|
|
22
|
+
return inlineSvg;
|
|
23
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { focusElement } from '@reykjavik/hanna-utils';
|
|
3
|
+
import { useFormatMonitor } from './useFormatMonitor.js';
|
|
4
|
+
const htmlClass = (className, add) => {
|
|
5
|
+
document.documentElement.classList[add ? 'add' : 'remove'](className);
|
|
6
|
+
};
|
|
7
|
+
const noop = () => undefined;
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
export const useMenuToggling = (doInitialize = true) => {
|
|
10
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
11
|
+
const [isMenuActive, setIsMenuActive] = useState();
|
|
12
|
+
const _state = { isMenuOpen, isMenuActive };
|
|
13
|
+
const stateRef = useRef(_state);
|
|
14
|
+
stateRef.current = _state;
|
|
15
|
+
const _openMenu = () => {
|
|
16
|
+
if (!stateRef.current.isMenuOpen) {
|
|
17
|
+
setIsMenuOpen(true);
|
|
18
|
+
htmlClass('menu-is-open', true);
|
|
19
|
+
htmlClass('menu-is-closed', false);
|
|
20
|
+
focusElement('#pagenav');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const _closeMenu = () => {
|
|
24
|
+
if (stateRef.current.isMenuOpen) {
|
|
25
|
+
setIsMenuOpen(false);
|
|
26
|
+
htmlClass('menu-is-closed', true);
|
|
27
|
+
htmlClass('menu-is-open', false);
|
|
28
|
+
focusElement('.Layout__header__skiplink');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
useFormatMonitor(doInitialize
|
|
32
|
+
? (media) => {
|
|
33
|
+
if (media.becameHamburger) {
|
|
34
|
+
setIsMenuActive(true);
|
|
35
|
+
htmlClass('menu-is-active', true);
|
|
36
|
+
htmlClass('menu-is-closed', true);
|
|
37
|
+
}
|
|
38
|
+
if (media.leftHamburger) {
|
|
39
|
+
_closeMenu();
|
|
40
|
+
setIsMenuActive(undefined);
|
|
41
|
+
htmlClass('menu-is-active', false);
|
|
42
|
+
htmlClass('menu-is-closed', false);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
: noop);
|
|
46
|
+
const { toggleMenu, closeMenu } = useRef(doInitialize
|
|
47
|
+
? {
|
|
48
|
+
toggleMenu: () => {
|
|
49
|
+
if (stateRef.current.isMenuActive) {
|
|
50
|
+
stateRef.current.isMenuOpen ? _closeMenu() : _openMenu();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
closeMenu: _closeMenu,
|
|
54
|
+
}
|
|
55
|
+
: { toggleMenu: noop, closeMenu: noop }).current;
|
|
56
|
+
return {
|
|
57
|
+
isMenuActive,
|
|
58
|
+
isMenuOpen,
|
|
59
|
+
toggleMenu,
|
|
60
|
+
closeMenu,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
type CtrlMode = 'controlled' | 'uncontrolled' | undefined;
|
|
3
|
+
type RetArray<R> = [value: R, setValue: Dispatch<SetStateAction<R>>, mode: CtrlMode];
|
|
4
|
+
type DefaultProp<N extends string> = `default${Capitalize<N>}`;
|
|
5
|
+
type PropPair<N extends string> = N | DefaultProp<N>;
|
|
6
|
+
type StrictKeys<P extends Record<string, unknown>, N extends string> = PropPair<N> extends keyof P ? P : {
|
|
7
|
+
[Key in PropPair<N>]: P[Key];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* State hook to simplify dealing with a the complexities of supporting a mixture
|
|
11
|
+
* of "controlled" and "uncontrolled" component state.
|
|
12
|
+
*
|
|
13
|
+
* The returned value and dispatcher/setter function return the controlled
|
|
14
|
+
* `value`, but gracefully handle changes in defaultValue in uncontrolled mode,
|
|
15
|
+
* and handles (unexpected) "mode-changes" in a predictable manner.
|
|
16
|
+
*
|
|
17
|
+
* It assumes (by default) that the calling component has
|
|
18
|
+
* a pair of props following the naming convention `foo` and `defaultFoo` —
|
|
19
|
+
* similar to React's own `<input/>` and `<select/>` HTML components warn about
|
|
20
|
+
* their `value` and `defaultValue` props being misused.
|
|
21
|
+
*
|
|
22
|
+
* NOTE: This hook also exposes a slightly lower-level helper hook
|
|
23
|
+
* `useMixedControlState.raw(value, defaultValue)`, for cases where you don't
|
|
24
|
+
* have a neatly-shaped props object as described above, or you need to do
|
|
25
|
+
* some sort of pre-processing of either prop value.
|
|
26
|
+
*
|
|
27
|
+
* ```tsx
|
|
28
|
+
* import React, { FC, ReactNode } from 'react';
|
|
29
|
+
* import { useMixedControlState } from '@reykjavik/hanna-react/utils';
|
|
30
|
+
*
|
|
31
|
+
* type FooBarProps = {
|
|
32
|
+
* visible?: boolean;
|
|
33
|
+
* onChange?: (newVisible: boolean) => void;
|
|
34
|
+
* defaultVisible?: boolean;
|
|
35
|
+
* };
|
|
36
|
+
*
|
|
37
|
+
* export const FooBar: FC<FooBarProps> = (props) => {
|
|
38
|
+
* const [visible, setVisible] = useMixedControlState(props, 'visible', true);
|
|
39
|
+
*
|
|
40
|
+
* const handleToggle = () => {
|
|
41
|
+
* props.onChange?.(!visible);
|
|
42
|
+
* setVisible(!visible);
|
|
43
|
+
* };
|
|
44
|
+
* return (
|
|
45
|
+
* <div>
|
|
46
|
+
* <button onClick={handleToggle}>Toggle</button>
|
|
47
|
+
* <div hidden={!visible}>{props.children}</div>
|
|
48
|
+
* </div>
|
|
49
|
+
* );
|
|
50
|
+
* };
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function useMixedControlState<N extends string, P extends {
|
|
54
|
+
[x in PropPair<N>]?: unknown;
|
|
55
|
+
}, D extends Exclude<V, undefined>, V = P[DefaultProp<N>] | P[N]>(
|
|
56
|
+
/** The props object of your component */
|
|
57
|
+
props: StrictKeys<P, N>, // StrictKeys give nicer error messages to users.
|
|
58
|
+
/** Name of the prop for the controlled value */
|
|
59
|
+
name: N,
|
|
60
|
+
/**
|
|
61
|
+
* A last-resort default value to use instead of `undefined`. \
|
|
62
|
+
* **NOTE:** All post-factum changes/updates to this value are ignored!
|
|
63
|
+
*/
|
|
64
|
+
emptyValue: D): RetArray<Exclude<V, undefined>>;
|
|
65
|
+
export declare function useMixedControlState<N extends string, P extends {
|
|
66
|
+
[x in PropPair<N>]?: unknown;
|
|
67
|
+
}, D extends Exclude<V, undefined>, V = P[DefaultProp<N>] | P[N]>(
|
|
68
|
+
/** The props object of your component */
|
|
69
|
+
props: StrictKeys<P, N>, // StrictKeys give nicer error messages to users.
|
|
70
|
+
/** Name of the prop for the controlled value */
|
|
71
|
+
name: N,
|
|
72
|
+
/**
|
|
73
|
+
* A last-resort default value to use instead of `undefined`. \
|
|
74
|
+
* **NOTE:** All post-factum changes/updates to this value are ignored!
|
|
75
|
+
*/
|
|
76
|
+
emptyValue?: D): RetArray<V>;
|
|
77
|
+
export declare namespace useMixedControlState {
|
|
78
|
+
var $warningLogger: ((message: string) => void) | undefined;
|
|
79
|
+
var raw: typeof useRaw;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A slightly lower-level hook alternative to
|
|
83
|
+
* `useMixedControlState(props, name)`, for cases where you don't
|
|
84
|
+
* have a neatly-/conventionally-shaped props object, or if you need to do
|
|
85
|
+
* some sort of pre-processing of either prop value.
|
|
86
|
+
*
|
|
87
|
+
* ```tsx
|
|
88
|
+
* import { useMixedControlState } from '@reykjavik/hanna-react/utils';
|
|
89
|
+
*
|
|
90
|
+
* declare const props: { visible?: boolean; defaultVisible?: boolean };
|
|
91
|
+
*
|
|
92
|
+
* const [vislble, setVisible] = useMixedControlState.raw(
|
|
93
|
+
* props.vislble,
|
|
94
|
+
* props.defaultVisible,
|
|
95
|
+
* 'visible'
|
|
96
|
+
* );
|
|
97
|
+
* // has the same effect as this:
|
|
98
|
+
* const [visible, setVisible] = useMixedControlState(props, 'visible');
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function useRaw<C, U, D extends Exclude<C | U, undefined>>(
|
|
102
|
+
/** Controlled value. */
|
|
103
|
+
value: C,
|
|
104
|
+
/** Default/initial value for uncontrolled use. */
|
|
105
|
+
defaultValue: U,
|
|
106
|
+
/**
|
|
107
|
+
* Prop name to display more meaningful warnings about when value
|
|
108
|
+
* and defaultValue are both defined, or if the component switches
|
|
109
|
+
* between modes mid-stream.
|
|
110
|
+
*
|
|
111
|
+
* If left undefined, the hook emits more generic/vague warnings
|
|
112
|
+
*/
|
|
113
|
+
warningPropName: string | undefined,
|
|
114
|
+
/**
|
|
115
|
+
* A last-resort default value to use instead of `undefined`. \
|
|
116
|
+
* **NOTE:** All post-factum changes/updates to this value are ignored!
|
|
117
|
+
*/
|
|
118
|
+
emptyValue: D): RetArray<Exclude<C | U, undefined>>;
|
|
119
|
+
declare function useRaw<C, U, D extends C | U>(
|
|
120
|
+
/** Controlled value. */
|
|
121
|
+
value: C,
|
|
122
|
+
/** Default/initial value for uncontrolled use. */
|
|
123
|
+
defaultValue: U,
|
|
124
|
+
/**
|
|
125
|
+
* Prop name to display more meaningful warnings about when value
|
|
126
|
+
* and defaultValue are both defined, or if the component switches
|
|
127
|
+
* between modes mid-stream.
|
|
128
|
+
*
|
|
129
|
+
* If left undefined, the hook emits more generic/vague warnings
|
|
130
|
+
*/
|
|
131
|
+
warningPropName?: string,
|
|
132
|
+
/**
|
|
133
|
+
* A last-resort default value to use instead of `undefined`. \
|
|
134
|
+
* **NOTE:** All post-factum changes/updates to this value are ignored!
|
|
135
|
+
*/
|
|
136
|
+
emptyValue?: D): RetArray<C | U>;
|
|
137
|
+
export {};
|