@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/Tooltip.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { arrow as arrowPlugin, autoUpdate, flip, offset, shift, useFloating, } from '@floating-ui/react';
|
|
3
|
+
import { useCallbackOnEsc, useLaggedState } from '@hugsmidjan/react/hooks';
|
|
4
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
5
|
+
const getSide = (placement) => placement.split('-')[0];
|
|
6
|
+
const ToolTip = (props) => {
|
|
7
|
+
const { text, label, iconOnly } = props;
|
|
8
|
+
const arrowRef = useRef(null);
|
|
9
|
+
const [isOpen, setIsOpen] = useLaggedState(false, 300);
|
|
10
|
+
const { x, y, reference, floating, middlewareData, placement } = useFloating({
|
|
11
|
+
placement: 'top',
|
|
12
|
+
middleware: [offset(10), flip(), shift(), arrowPlugin({ element: arrowRef })],
|
|
13
|
+
whileElementsMounted: autoUpdate,
|
|
14
|
+
});
|
|
15
|
+
const { arrow } = middlewareData;
|
|
16
|
+
const arrowX = arrow === null || arrow === void 0 ? void 0 : arrow.x;
|
|
17
|
+
const arrowY = arrow === null || arrow === void 0 ? void 0 : arrow.y;
|
|
18
|
+
useCallbackOnEsc(() => {
|
|
19
|
+
setIsOpen(false);
|
|
20
|
+
});
|
|
21
|
+
return (React.createElement("details", { className: `Tooltip Tooltip--${getSide(placement)}`, open: isOpen, onMouseEnter: () => setIsOpen(true, 100), onFocus: () => {
|
|
22
|
+
if (isOpen) {
|
|
23
|
+
setIsOpen(true, 0);
|
|
24
|
+
}
|
|
25
|
+
}, onBlur: () => setIsOpen(false), onClick: (e) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
setIsOpen(!isOpen, 0);
|
|
28
|
+
}, onMouseDown: () => {
|
|
29
|
+
if (isOpen) {
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
setIsOpen(true, 0);
|
|
32
|
+
}, 100);
|
|
33
|
+
}
|
|
34
|
+
}, onMouseLeave: (e) => {
|
|
35
|
+
if (e.currentTarget.$contextClicked_firefox_fix) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
setIsOpen(false);
|
|
39
|
+
}, onContextMenu: (e) => {
|
|
40
|
+
const elm = e.currentTarget;
|
|
41
|
+
clearTimeout(elm.$contextClicked_firefox_fix);
|
|
42
|
+
elm.$contextClicked_firefox_fix = setTimeout(() => {
|
|
43
|
+
delete elm.$contextClicked_firefox_fix;
|
|
44
|
+
}, 300);
|
|
45
|
+
}, style: x == null
|
|
46
|
+
? undefined
|
|
47
|
+
: {
|
|
48
|
+
'--tooltip-content-pos-y': `${y}px`,
|
|
49
|
+
'--tooltip-content-pos-x': `${x}px`,
|
|
50
|
+
'--tooltip-arrow-pos-x': `${arrowX}px`,
|
|
51
|
+
'--tooltip-arrow-pos-y': `${arrowY}px`,
|
|
52
|
+
} },
|
|
53
|
+
React.createElement("summary", { className: getBemClass('Tooltip__trigger', iconOnly && 'icononly'), ref: reference }, label),
|
|
54
|
+
React.createElement("div", { className: "Tooltip__content", onClick: (e) => e.stopPropagation(), ref: floating },
|
|
55
|
+
x !== null && (React.createElement("div", { "data-floating-ui-hack-plz-ignore": "", style: { position: 'absolute', display: 'none' }, ref: arrowRef })),
|
|
56
|
+
text)));
|
|
57
|
+
};
|
|
58
|
+
export default ToolTip;
|
package/esm/VSpacer.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
|
+
declare const sizes: {
|
|
4
|
+
readonly none: "none";
|
|
5
|
+
readonly small: "small";
|
|
6
|
+
readonly default: "";
|
|
7
|
+
readonly medium: "";
|
|
8
|
+
readonly large: "large";
|
|
9
|
+
readonly xlarge: "xlarge";
|
|
10
|
+
};
|
|
11
|
+
type VSpacerSize = keyof typeof sizes;
|
|
12
|
+
type VSpacerSizePos = Exclude<VSpacerSize, 'none'>;
|
|
13
|
+
export type VSpacerProps = EitherObj<{
|
|
14
|
+
size?: VSpacerSizePos;
|
|
15
|
+
}, {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
size?: VSpacerSizePos;
|
|
18
|
+
top?: VSpacerSize;
|
|
19
|
+
bottom?: VSpacerSize;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const VSpacer: (props: VSpacerProps) => JSX.Element;
|
|
22
|
+
export default VSpacer;
|
package/esm/VSpacer.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
const sizes = {
|
|
4
|
+
none: 'none',
|
|
5
|
+
small: 'small',
|
|
6
|
+
default: '',
|
|
7
|
+
medium: '',
|
|
8
|
+
large: 'large',
|
|
9
|
+
xlarge: 'xlarge',
|
|
10
|
+
};
|
|
11
|
+
const hasChildren = (children) => (children && !(Array.isArray(children) && !children.length)) || undefined;
|
|
12
|
+
const normalizeProp = (value, exclude) => value && value !== exclude ? sizes[value] : undefined;
|
|
13
|
+
export const VSpacer = (props) => {
|
|
14
|
+
const { size, top, bottom, children } = props;
|
|
15
|
+
const isWrapper = hasChildren(children);
|
|
16
|
+
let topVal = normalizeProp(isWrapper && top);
|
|
17
|
+
let bottomVal = normalizeProp(isWrapper && bottom);
|
|
18
|
+
let sizeVal = !(topVal && bottomVal) && normalizeProp(size, 'none');
|
|
19
|
+
// collapse effectively-duplicate class modifiers
|
|
20
|
+
if (!sizeVal && topVal === bottomVal && topVal !== 'none') {
|
|
21
|
+
sizeVal = topVal;
|
|
22
|
+
topVal = bottomVal = undefined;
|
|
23
|
+
}
|
|
24
|
+
else if (sizeVal) {
|
|
25
|
+
if (sizeVal === topVal) {
|
|
26
|
+
sizeVal = topVal;
|
|
27
|
+
topVal = undefined;
|
|
28
|
+
}
|
|
29
|
+
if (sizeVal === bottomVal) {
|
|
30
|
+
sizeVal = bottomVal;
|
|
31
|
+
bottomVal = undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const className = getBemClass('VSpacer', [
|
|
35
|
+
sizeVal,
|
|
36
|
+
topVal && 'top--' + topVal,
|
|
37
|
+
bottomVal && 'bottom--' + bottomVal,
|
|
38
|
+
]);
|
|
39
|
+
return isWrapper ? (React.createElement("div", { className: className }, children)) : (React.createElement("hr", { className: className }));
|
|
40
|
+
};
|
|
41
|
+
export default VSpacer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TabItemProps, TabsProps } from './Tabs.js';
|
|
2
|
+
export type VerticalTabsTOCItem = TabItemProps & {
|
|
3
|
+
items?: Array<VerticalTabsTOCSubItem>;
|
|
4
|
+
};
|
|
5
|
+
export type VerticalTabsTOCSubItem = TabItemProps & {
|
|
6
|
+
type?: never;
|
|
7
|
+
href: string;
|
|
8
|
+
};
|
|
9
|
+
export type VerticalTabsTOCProps = {
|
|
10
|
+
items: Array<VerticalTabsTOCItem>;
|
|
11
|
+
onItemSelect: (itemId: string) => void;
|
|
12
|
+
} & Pick<TabsProps, 'aria-label' | 'ssr' | 'activateOnFocus' | 'id' | 'startSeen'>;
|
|
13
|
+
export declare const VerticalTabsTOC: (props: VerticalTabsTOCProps) => JSX.Element;
|
|
14
|
+
export default VerticalTabsTOC;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { setFrag } from '@hugsmidjan/qj/frag';
|
|
3
|
+
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
4
|
+
import Tabs from './Tabs.js';
|
|
5
|
+
const getId = (url) => (url && decodeURIComponent(url.split('#')[1] || '')) || '';
|
|
6
|
+
const getItemId = (item) => getId(item && item.href);
|
|
7
|
+
const mapToItemsById = (items, domid) => {
|
|
8
|
+
const updatedItems = items.map((item) => {
|
|
9
|
+
return Object.assign(Object.assign({}, item), { 'aria-controls': item['aria-controls'] || domid });
|
|
10
|
+
});
|
|
11
|
+
const itemsById = {};
|
|
12
|
+
updatedItems.forEach((topItem, activeIdx) => {
|
|
13
|
+
const subItems = topItem.items;
|
|
14
|
+
if (!subItems) {
|
|
15
|
+
const itemId = getItemId(topItem);
|
|
16
|
+
itemsById[itemId] = { activeIdx };
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
subItems.forEach((subItem, idx) => {
|
|
20
|
+
itemsById[getItemId(subItem)] = {
|
|
21
|
+
activeIdx,
|
|
22
|
+
subTabs: {
|
|
23
|
+
activeIdx: idx,
|
|
24
|
+
'aria-label': topItem.longLabel || topItem.label,
|
|
25
|
+
id: topItem['aria-controls'],
|
|
26
|
+
tabs: subItems,
|
|
27
|
+
onSetActive: (_, item) => {
|
|
28
|
+
const newId = getItemId(item);
|
|
29
|
+
setFrag(newId);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
if (idx === 0) {
|
|
34
|
+
topItem.href = topItem.href || '#' + getItemId(subItem);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return { itemsById, updatedItems };
|
|
39
|
+
};
|
|
40
|
+
export const VerticalTabsTOC = (props) => {
|
|
41
|
+
const { onItemSelect, items } = props;
|
|
42
|
+
const _domid = useDomid();
|
|
43
|
+
const domid = props.id || _domid;
|
|
44
|
+
const { itemsById, updatedItems } = useMemo(() => mapToItemsById(items, domid), [items, domid]);
|
|
45
|
+
const [state, setState] = useState(() => {
|
|
46
|
+
const initialId = typeof location !== 'undefined' ? getId(location.hash) : '';
|
|
47
|
+
return itemsById[initialId] || itemsById[getItemId(updatedItems[0])] || {};
|
|
48
|
+
});
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const handleHash = () => {
|
|
51
|
+
const newId = getId(location.href);
|
|
52
|
+
const newState = itemsById[newId];
|
|
53
|
+
if (newState) {
|
|
54
|
+
setState(newState);
|
|
55
|
+
onItemSelect(newId);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener('hashchange', handleHash);
|
|
59
|
+
return () => window.removeEventListener('hashchange', handleHash);
|
|
60
|
+
}, [itemsById, onItemSelect]);
|
|
61
|
+
return (React.createElement(Tabs, { id: domid, vertical: true, "aria-label": props['aria-label'], onSetActive: (_, item) => {
|
|
62
|
+
var _a;
|
|
63
|
+
const itemId = getItemId(item);
|
|
64
|
+
const newId = itemId || getItemId((_a = itemsById[itemId].subTabs) === null || _a === void 0 ? void 0 : _a.tabs[0]);
|
|
65
|
+
setFrag(newId);
|
|
66
|
+
}, tabs: updatedItems, role: "tablist", activeIdx: state.activeIdx, subTabs: state.subTabs }));
|
|
67
|
+
};
|
|
68
|
+
export default VerticalTabsTOC;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { HannaColorTheme } from '@reykjavik/hanna-css';
|
|
3
|
+
import { SSRSupport } from './utils.js';
|
|
4
|
+
type WizardLayoutProps = {
|
|
5
|
+
wizardStepper?: ReactNode | false;
|
|
6
|
+
wizardFooter?: ReactNode | false;
|
|
7
|
+
colorTheme?: HannaColorTheme;
|
|
8
|
+
siteName?: string;
|
|
9
|
+
logoLink?: string;
|
|
10
|
+
globalAlerts?: ReactNode;
|
|
11
|
+
ssr?: SSRSupport;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare const WizardLayout: (props: WizardLayoutProps) => JSX.Element;
|
|
15
|
+
export default WizardLayout;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getAssetUrl } from '@reykjavik/hanna-utils/assets';
|
|
3
|
+
import { Image } from './_abstract/_Image.js';
|
|
4
|
+
import { Link } from './_abstract/_Link.js';
|
|
5
|
+
import { useScrollbarWidthCSSVar } from './utils/useScrollbarWidthCSSVar.js';
|
|
6
|
+
import { useIsBrowserSide } from './utils.js';
|
|
7
|
+
export const WizardLayout = (props) => {
|
|
8
|
+
useScrollbarWidthCSSVar();
|
|
9
|
+
const {
|
|
10
|
+
// ssr,
|
|
11
|
+
wizardStepper, wizardFooter, children, colorTheme, logoLink = '/', siteName = 'Reykjavík', globalAlerts, } = props;
|
|
12
|
+
const isBrowser = useIsBrowserSide( /* ssr */);
|
|
13
|
+
return (React.createElement("div", { className: "WizardLayout", "data-sprinkled": isBrowser, "data-color-theme": colorTheme },
|
|
14
|
+
globalAlerts && (React.createElement("div", { className: "WizardLayout__alerts", role: "alert" }, globalAlerts)),
|
|
15
|
+
React.createElement("div", { className: "WizardLayout__content" },
|
|
16
|
+
React.createElement("div", { className: "WizardLayout__header", role: "banner" },
|
|
17
|
+
React.createElement(Link, { className: "WizardLayout__header__logo", href: logoLink },
|
|
18
|
+
' ',
|
|
19
|
+
React.createElement(Image, { className: undefined, inline: true, src: getAssetUrl('reykjavik-logo.svg') }),
|
|
20
|
+
' ',
|
|
21
|
+
siteName,
|
|
22
|
+
' '),
|
|
23
|
+
' '),
|
|
24
|
+
React.createElement("div", { className: "WizardLayout__wrap" },
|
|
25
|
+
wizardStepper && (React.createElement("div", { className: "WizardLayout__stepper", role: "navigation" }, wizardStepper)),
|
|
26
|
+
React.createElement("div", { className: "WizardLayout__main", role: "main" }, children),
|
|
27
|
+
React.createElement("div", { className: "WizardLayout__deco WizardLayout__deco--geometry" })),
|
|
28
|
+
React.createElement("div", { className: "WizardLayout__footer", role: "complementary" }, wizardFooter))));
|
|
29
|
+
};
|
|
30
|
+
export default WizardLayout;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type WizardStepperStep = {
|
|
2
|
+
label: string;
|
|
3
|
+
/**
|
|
4
|
+
* Should the step be clickable?
|
|
5
|
+
*
|
|
6
|
+
* * `true` = The items becomes clickable as allowed by the `activeStep`,
|
|
7
|
+
* `disableBacktrack` and `allowForwardSkip` props.
|
|
8
|
+
* * `false | undefined` = Never clickable, regardless of `activeStep`.
|
|
9
|
+
* * `"always"` = Always clickable regardless of `activeStep` or other props.
|
|
10
|
+
*/
|
|
11
|
+
clickable?: boolean | 'always';
|
|
12
|
+
/**
|
|
13
|
+
* Flags the item as having a non-default done state
|
|
14
|
+
*
|
|
15
|
+
* * `undefined` = automatically set "done" on items before `activeStep`
|
|
16
|
+
* * `true` = Always flag as "done", regardless of `activeStep`
|
|
17
|
+
* * `false` = Never flag as "done", regardless of `activeStep`
|
|
18
|
+
*/
|
|
19
|
+
done?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Flags the step as not part of the numbering scheme
|
|
22
|
+
*/
|
|
23
|
+
neutral?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type WizardStepperProps = {
|
|
26
|
+
steps: ReadonlyArray<WizardStepperStep>;
|
|
27
|
+
/** Zero-based index of the active (current) step */
|
|
28
|
+
activeStep?: number;
|
|
29
|
+
/** By default, clickable steps remain clickable once "done" */
|
|
30
|
+
disableBacktrack?: boolean;
|
|
31
|
+
/** By default, clickable steps after the active step are not immediately clickable */
|
|
32
|
+
allowForwardSkip?: boolean;
|
|
33
|
+
onClick: (clickedIndex: number) => void;
|
|
34
|
+
};
|
|
35
|
+
export declare const WizardStepper: (props: WizardStepperProps) => JSX.Element;
|
|
36
|
+
export default WizardStepper;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
export const WizardStepper = (props) => {
|
|
4
|
+
const { steps, activeStep = -1, allowForwardSkip, disableBacktrack, onClick } = props;
|
|
5
|
+
return (React.createElement("div", { className: getBemClass('WizardStepper', activeStep === -1 && 'preview') }, steps.map((step, i) => {
|
|
6
|
+
const { clickable, done, neutral } = step;
|
|
7
|
+
const label = step.label || '…';
|
|
8
|
+
const stepClass = getBemClass('WizardStepper__step', [
|
|
9
|
+
(done || (done == null && i < activeStep)) && 'done',
|
|
10
|
+
neutral && 'neutral',
|
|
11
|
+
]);
|
|
12
|
+
const isClickable = clickable === 'always' ||
|
|
13
|
+
(clickable &&
|
|
14
|
+
(activeStep === i ||
|
|
15
|
+
(i > activeStep && allowForwardSkip) ||
|
|
16
|
+
(i < activeStep && !disableBacktrack)));
|
|
17
|
+
const ariaCurrent = activeStep === i ? 'step' : undefined;
|
|
18
|
+
return (React.createElement(React.Fragment, { key: i },
|
|
19
|
+
isClickable ? (React.createElement("button", { type: "button", className: stepClass, onClick: () => onClick(i), "aria-current": ariaCurrent }, label)) : (React.createElement("span", { className: stepClass, "aria-current": ariaCurrent },
|
|
20
|
+
' ',
|
|
21
|
+
label,
|
|
22
|
+
' ')),
|
|
23
|
+
' '));
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
export default WizardStepper;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { BemProps } from '@hugsmidjan/react/types';
|
|
3
|
+
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
4
|
+
import { SSRSupport } from '../utils.js';
|
|
5
|
+
import { SeenProp } from '../utils/seenEffect.js';
|
|
6
|
+
export type CarouselProps<I extends Record<string, unknown> = {}, P extends Record<string, unknown> | undefined = {}> = {
|
|
7
|
+
className?: string;
|
|
8
|
+
ssr?: SSRSupport;
|
|
9
|
+
/** @deprecated Ingored because never used (Will be removed in v0.11) */
|
|
10
|
+
scrollRight?: boolean;
|
|
11
|
+
} & EitherObj<{
|
|
12
|
+
items: Array<I>;
|
|
13
|
+
Component: (props: P extends undefined ? I : I & P) => ReactElement | null;
|
|
14
|
+
ComponentProps?: P;
|
|
15
|
+
}, {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Explicit number of items contained by the `children` prop
|
|
19
|
+
*
|
|
20
|
+
* Use this when your returned child elements are wrapped in a
|
|
21
|
+
* `<Fragment />` or some such.
|
|
22
|
+
*/
|
|
23
|
+
itemCount?: number;
|
|
24
|
+
}> & SeenProp;
|
|
25
|
+
type AbstractCarouselProps<I extends Record<string, unknown> = Record<string, unknown>, P extends Record<string, unknown> | undefined = Record<string, unknown>> = CarouselProps<I, P> & BemProps & {
|
|
26
|
+
title?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const AbstractCarousel: <I extends Record<string, unknown> = Record<string, unknown>, P extends Record<string, unknown> | undefined = Record<string, unknown>>(props: AbstractCarouselProps<I, P>) => JSX.Element | null;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState, } from 'react';
|
|
2
|
+
import A from '@hugsmidjan/qj/A';
|
|
3
|
+
import debounce from '@hugsmidjan/qj/debounce';
|
|
4
|
+
import focusElm from '@hugsmidjan/qj/focusElm';
|
|
5
|
+
import throttle from '@hugsmidjan/qj/throttle';
|
|
6
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
7
|
+
import { notNully } from '@reykjavik/hanna-utils';
|
|
8
|
+
import CarouselStepper from '../CarouselStepper.js';
|
|
9
|
+
import { useIsBrowserSide } from '../utils.js';
|
|
10
|
+
import { useSeenEffect } from '../utils/seenEffect.js';
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
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
|
+
export const AbstractCarousel = (props) => {
|
|
23
|
+
const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, } = props;
|
|
24
|
+
const children = !props.children
|
|
25
|
+
? undefined
|
|
26
|
+
: Array.isArray(props.children)
|
|
27
|
+
? props.children.filter(notNully)
|
|
28
|
+
: [props.children];
|
|
29
|
+
const [leftOffset, setLeftOffset] = useState();
|
|
30
|
+
const itemCount = props.itemCount || (children || items).length;
|
|
31
|
+
const listRef = useRef(null);
|
|
32
|
+
const [activeItem, setActiveItem] = useState(0);
|
|
33
|
+
const isBrowser = useIsBrowserSide(ssr);
|
|
34
|
+
// Since listElm gets unmounted and remounted based on isBrowser, we
|
|
35
|
+
// wait for isBrowser is true before setting scroll and resize events.
|
|
36
|
+
const listElm = isBrowser && listRef.current;
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!listElm) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const calcLeftOffset = () => {
|
|
42
|
+
var _a;
|
|
43
|
+
setLeftOffset((_a = listElm.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left);
|
|
44
|
+
scrollXBy(listElm, 0);
|
|
45
|
+
};
|
|
46
|
+
const calcActiveItem = throttle(() => {
|
|
47
|
+
const { scrollLeft, children } = listElm;
|
|
48
|
+
// using Array#find as forEachUntil
|
|
49
|
+
A(children).find((item, i) => {
|
|
50
|
+
if (scrollLeft <= item.offsetLeft + item.offsetWidth / 2) {
|
|
51
|
+
setActiveItem(i);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}, 300, true);
|
|
56
|
+
calcLeftOffset();
|
|
57
|
+
listElm.addEventListener('scroll', calcActiveItem, { passive: true });
|
|
58
|
+
window.addEventListener('resize', calcLeftOffset, { passive: true });
|
|
59
|
+
return () => {
|
|
60
|
+
listElm.removeEventListener('scroll', calcActiveItem);
|
|
61
|
+
window.removeEventListener('resize', calcLeftOffset);
|
|
62
|
+
};
|
|
63
|
+
}, [listElm]);
|
|
64
|
+
const scrollToItem = (newActive) => {
|
|
65
|
+
const listElm = listRef.current;
|
|
66
|
+
const newItem = listElm.children[newActive];
|
|
67
|
+
if (!newItem) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setActiveItem(newActive);
|
|
71
|
+
listElm.scrollLeft = newItem.offsetLeft || 1;
|
|
72
|
+
setTimeout(() => focusElm(newItem), 500);
|
|
73
|
+
};
|
|
74
|
+
const { delayedScrollLeft, delayedScrollRight } = useMemo(() => {
|
|
75
|
+
const delayedScrollLeft = debounce((currentActive) => {
|
|
76
|
+
scrollToItem(currentActive - 1);
|
|
77
|
+
setTimeout(() => delayedScrollLeft(currentActive - 1), 0);
|
|
78
|
+
}, 1000);
|
|
79
|
+
const delayedScrollRight = debounce((currentActive) => {
|
|
80
|
+
scrollToItem(currentActive + 1);
|
|
81
|
+
setTimeout(() => delayedScrollRight(currentActive + 1), 0);
|
|
82
|
+
}, 1000);
|
|
83
|
+
return { delayedScrollLeft, delayedScrollRight };
|
|
84
|
+
}, []);
|
|
85
|
+
const [outerRef] = useSeenEffect(startSeen);
|
|
86
|
+
if (!itemCount) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const itemList = (React.createElement("div", { className: bem + '__itemlist', style: leftOffset
|
|
90
|
+
? { '--Carousel--leftOffset': `${leftOffset}px` }
|
|
91
|
+
: undefined, "data-scroll-snapping": leftOffset ? 'true' : undefined, ref: listRef }, children ||
|
|
92
|
+
items.map((item, i) => (
|
|
93
|
+
// @ts-expect-error (Can't be arsed...)
|
|
94
|
+
React.createElement(Component, Object.assign({ key: i }, ComponentProps, item))))));
|
|
95
|
+
return (React.createElement("div", { className: getBemClass(bem, modifier, props.className), ref: outerRef, "data-sprinkled": isBrowser },
|
|
96
|
+
title && React.createElement("h2", { className: bem + '__title' }, title),
|
|
97
|
+
isBrowser ? (React.createElement("div", { className: bem + '__itemlist-wrapper' },
|
|
98
|
+
itemList,
|
|
99
|
+
activeItem > 0 && (React.createElement("div", { className: bem + '__itemlist-goLeft', onClick: () => {
|
|
100
|
+
delayedScrollLeft.cancel();
|
|
101
|
+
scrollToItem(activeItem - 1);
|
|
102
|
+
}, onMouseOver: () => delayedScrollLeft(activeItem), onMouseOut: () => delayedScrollLeft.cancel() })),
|
|
103
|
+
activeItem < itemCount - 1 && (React.createElement("div", { className: bem + '__itemlist-goRight', onClick: () => {
|
|
104
|
+
delayedScrollRight.cancel();
|
|
105
|
+
scrollToItem(activeItem + 1);
|
|
106
|
+
}, onMouseOver: () => delayedScrollRight(activeItem), onMouseOut: () => delayedScrollRight.cancel() })))) : (itemList),
|
|
107
|
+
isBrowser && (React.createElement(CarouselStepper, { itemCount: itemCount, setCurrent: scrollToItem, current: activeItem }))));
|
|
108
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlingType } from '@reykjavik/hanna-utils/assets';
|
|
2
|
+
import { BlingProps } from '../Bling.js';
|
|
3
|
+
export type BlingComboProps = Array<Omit<BlingProps, 'type' | 'blingUrl'> & {
|
|
4
|
+
type: BlingType;
|
|
5
|
+
}>;
|
|
6
|
+
type BlingsProps = {
|
|
7
|
+
blings: BlingComboProps;
|
|
8
|
+
mirror?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const Blings: (props: BlingsProps) => JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Bling from '../Bling.js';
|
|
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
|
+
export 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 })))));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BemPropsModifier } from '@hugsmidjan/react/types';
|
|
2
|
+
import { SeenProp } from '../utils/seenEffect.js';
|
|
3
|
+
import { ButtonProps } from './_Button.js';
|
|
4
|
+
import { ImageProps } from './_Image.js';
|
|
5
|
+
export type BlockItem = {
|
|
6
|
+
title: string;
|
|
7
|
+
summary?: string | JSX.Element;
|
|
8
|
+
buttons?: Array<ButtonProps>;
|
|
9
|
+
};
|
|
10
|
+
export type ContentImageBlock = {
|
|
11
|
+
content: BlockItem;
|
|
12
|
+
image: ImageProps;
|
|
13
|
+
} & SeenProp;
|
|
14
|
+
export type ContentBlock = {
|
|
15
|
+
content: Array<BlockItem>;
|
|
16
|
+
image?: undefined;
|
|
17
|
+
} & SeenProp;
|
|
18
|
+
export type BlockProps = BemPropsModifier & (ContentBlock | ContentImageBlock);
|
|
19
|
+
export declare const Block: (props: BlockProps & {
|
|
20
|
+
bem: string;
|
|
21
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
import { useSeenEffect } from '../utils/seenEffect.js';
|
|
4
|
+
import { Button } from './_Button.js';
|
|
5
|
+
import { Image } from './_Image.js';
|
|
6
|
+
export 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
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BemProps, BemPropsModifier } from '@hugsmidjan/react/types';
|
|
3
|
+
type ButtonElmProps = {
|
|
4
|
+
href?: never;
|
|
5
|
+
} & BemPropsModifier & Omit<JSX.IntrinsicElements['button'], 'className' | 'style'>;
|
|
6
|
+
type AnchorElmProps = {
|
|
7
|
+
href: string;
|
|
8
|
+
type?: never;
|
|
9
|
+
name?: never;
|
|
10
|
+
value?: never;
|
|
11
|
+
} & BemPropsModifier & Omit<JSX.IntrinsicElements['a'], 'className' | 'style'>;
|
|
12
|
+
export type ButtonProps = {
|
|
13
|
+
/** Label takes preference over `children` */
|
|
14
|
+
label?: string | JSX.Element;
|
|
15
|
+
} & (ButtonElmProps | AnchorElmProps);
|
|
16
|
+
declare const sizes: {
|
|
17
|
+
readonly normal: "";
|
|
18
|
+
readonly small: "small";
|
|
19
|
+
readonly wide: "wide";
|
|
20
|
+
};
|
|
21
|
+
type ButtonSize = keyof typeof sizes;
|
|
22
|
+
declare const variants: {
|
|
23
|
+
readonly normal: "";
|
|
24
|
+
readonly destructive: "destructive";
|
|
25
|
+
};
|
|
26
|
+
type ButtonVariant = keyof typeof variants;
|
|
27
|
+
type NavigationFlag = 'none' | 'go-back' | 'go-forward';
|
|
28
|
+
type ButtonIcon = 'edit';
|
|
29
|
+
export type ButtonVariantProps = {
|
|
30
|
+
size?: ButtonSize;
|
|
31
|
+
variant?: ButtonVariant;
|
|
32
|
+
icon?: ButtonIcon | NavigationFlag;
|
|
33
|
+
/** @deprecated (Will be removed in v0.11) */
|
|
34
|
+
small?: boolean;
|
|
35
|
+
};
|
|
36
|
+
type _ButtonProps = ButtonProps & ButtonVariantProps & BemProps & {
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
};
|
|
39
|
+
export declare const Button: (props: _ButtonProps) => JSX.Element;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
import { Link } from './_Link.js';
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
const sizes = {
|
|
7
|
+
normal: '',
|
|
8
|
+
small: 'small',
|
|
9
|
+
wide: 'wide',
|
|
10
|
+
};
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
const variants = {
|
|
13
|
+
normal: '',
|
|
14
|
+
destructive: 'destructive',
|
|
15
|
+
};
|
|
16
|
+
const navigationFlags = {
|
|
17
|
+
none: '',
|
|
18
|
+
'go-back': 'go--back',
|
|
19
|
+
'go-forward': 'go--forward',
|
|
20
|
+
};
|
|
21
|
+
const icons = {
|
|
22
|
+
// TODO: insert icons
|
|
23
|
+
edit: 'edit',
|
|
24
|
+
};
|
|
25
|
+
export const Button = (props) => {
|
|
26
|
+
const { bem, small, size = 'normal', modifier, children, variant = 'normal', icon = 'none', label = children } = props, buttonProps = __rest(props, ["bem", "small", "size", "modifier", "children", "variant", "icon", "label"]);
|
|
27
|
+
const className = bem &&
|
|
28
|
+
getBemClass(bem, [modifier, variants[variant], sizes[size], navigationFlags[icon]]);
|
|
29
|
+
const iconProp = icons[icon] && { 'data-icon': icons[icon] };
|
|
30
|
+
if (buttonProps.href != null) {
|
|
31
|
+
return (React.createElement(Link, Object.assign({ className: className }, buttonProps, { style: undefined }, iconProp), label));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return (React.createElement("button", Object.assign({ className: className, type: "button" }, buttonProps, { style: undefined }, iconProp), label));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
|
+
import { ImageProps } from './_Image.js';
|
|
4
|
+
type BaseCardProps = {
|
|
5
|
+
title: string;
|
|
6
|
+
href: string;
|
|
7
|
+
};
|
|
8
|
+
export type ImageCardProps = BaseCardProps & {
|
|
9
|
+
meta?: string;
|
|
10
|
+
image?: ImageProps;
|
|
11
|
+
imgPlaceholder?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type TextCardProps = BaseCardProps & {
|
|
14
|
+
summary?: string;
|
|
15
|
+
};
|
|
16
|
+
export type CardListProps<T> = {
|
|
17
|
+
cards: Array<T>;
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
titleTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'p';
|
|
20
|
+
};
|
|
21
|
+
export type CardListSummaryProps = {
|
|
22
|
+
summaryElement?: ReactElement;
|
|
23
|
+
};
|
|
24
|
+
export type ImageCardListProps = CardListProps<ImageCardProps> & {
|
|
25
|
+
imgPlaceholder?: boolean | string;
|
|
26
|
+
};
|
|
27
|
+
export type TextCardListProps = CardListProps<TextCardProps>;
|
|
28
|
+
type _CardListProps = EitherObj<ImageCardListProps, TextCardListProps> & CardListSummaryProps & {
|
|
29
|
+
bemPrefix: string;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
standalone?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare const CardList: (props: _CardListProps) => JSX.Element;
|
|
34
|
+
export {};
|