@reykjavik/hanna-react 0.10.57 → 0.10.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AccordionList.js +3 -28
- package/ActionCards.d.ts +1 -1
- package/ActionCards.js +4 -6
- package/Alert.js +5 -30
- package/ArticleCards.d.ts +6 -0
- package/ArticleCards.js +7 -0
- package/ArticleCarousel/_ArticleCarouselCard.d.ts +1 -1
- package/ArticleCarousel/_ArticleCarouselCard.js +8 -10
- package/ArticleCarousel.js +3 -5
- package/ArticleMeta.d.ts +1 -0
- package/ArticleMeta.js +7 -28
- package/Attention.js +3 -5
- package/BasicTable.js +5 -7
- package/{esm/CenterColumn.d.ts → BgBox.d.ts} +4 -3
- package/BgBox.js +12 -0
- package/Bling.js +3 -5
- package/BlockBreak.js +2 -4
- package/BlockQuote.js +2 -4
- package/BreadCrumbs.js +4 -6
- package/ButtonBack.d.ts +1 -1
- package/ButtonBack.js +4 -6
- package/ButtonBar.js +3 -5
- package/ButtonPrimary.d.ts +1 -1
- package/ButtonPrimary.js +4 -6
- package/ButtonSecondary.d.ts +1 -1
- package/ButtonSecondary.js +4 -6
- package/ButtonTertiary.d.ts +1 -1
- package/ButtonTertiary.js +4 -6
- package/CHANGELOG.md +20 -1
- package/Carousel.js +3 -5
- package/CarouselStepper.js +3 -5
- package/CenterColumn.js +3 -5
- package/Checkbox.d.ts +1 -1
- package/Checkbox.js +4 -6
- package/CheckboxButtonsGroup.d.ts +1 -1
- package/CheckboxButtonsGroup.js +6 -8
- package/CheckboxGroup.d.ts +1 -1
- package/CheckboxGroup.js +5 -7
- package/CityBlock.d.ts +1 -1
- package/CityBlock.js +3 -5
- package/ContactBubble.js +6 -31
- package/ContentArticle.js +8 -10
- package/ContentImage.d.ts +1 -1
- package/ContentImage.js +4 -6
- package/Datepicker.js +6 -31
- package/ExtraLinks.d.ts +1 -1
- package/ExtraLinks.js +8 -21
- package/FeatureList.js +3 -5
- package/FieldGroup.js +3 -5
- package/FileInput.js +5 -41
- package/Foonote.js +2 -4
- package/FooterBadges.js +4 -6
- package/FooterInfo.js +3 -5
- package/Footnote.js +2 -4
- package/Form.js +3 -5
- package/FormField.js +3 -28
- package/Gallery/_GalleryItem.d.ts +1 -1
- package/Gallery/_GalleryItem.js +9 -45
- package/Gallery/_GalleryModal.js +6 -31
- package/Gallery/_GalleryModalContext.js +2 -4
- package/Gallery/_GalleryModalItem.js +5 -18
- package/Gallery.js +6 -31
- package/GridBlocks.d.ts +2 -2
- package/GridBlocks.js +8 -10
- package/Heading.d.ts +1 -1
- package/Heading.js +4 -6
- package/HeroBlock.d.ts +2 -2
- package/HeroBlock.js +6 -8
- package/IframeBlock.d.ts +5 -1
- package/IframeBlock.js +6 -8
- package/Illustration.d.ts +1 -1
- package/Illustration.js +4 -6
- package/ImageCards.d.ts +1 -1
- package/ImageCards.js +6 -19
- package/InfoBlock.js +2 -4
- package/InfoHero.d.ts +2 -2
- package/InfoHero.js +8 -10
- package/IslandBlock.d.ts +1 -1
- package/IslandBlock.js +3 -5
- package/IslandPageBlock.d.ts +1 -1
- package/IslandPageBlock.js +3 -5
- package/LabeledTextBlock.d.ts +1 -1
- package/LabeledTextBlock.js +4 -6
- package/Layout.js +9 -11
- package/MainMenu/_Auxiliary.js +4 -6
- package/MainMenu/_PrimaryPanel.js +5 -7
- package/MainMenu.js +7 -32
- package/MiniMetrics.d.ts +1 -1
- package/MiniMetrics.js +5 -7
- package/Modal.js +3 -5
- package/NameCard.js +6 -8
- package/NameCards.js +3 -5
- package/NewsHero.d.ts +1 -1
- package/NewsHero.js +7 -9
- package/PageFilter.js +4 -6
- package/PageHeading.js +3 -5
- package/Picture.d.ts +7 -0
- package/Picture.js +11 -0
- package/ProcessOverview.js +3 -5
- package/PullQuote.js +2 -4
- package/RadioButtonsGroup.d.ts +1 -1
- package/RadioButtonsGroup.js +6 -8
- package/RadioGroup.d.ts +2 -2
- package/RadioGroup.js +6 -8
- package/RelatedLinks.js +4 -6
- package/RowBlock.js +3 -5
- package/RowBlockColumn.js +3 -5
- package/SearchInput.js +5 -41
- package/SearchResults/_SearchResultsItem.js +6 -8
- package/SearchResults.js +7 -32
- package/SeenEffect.js +3 -16
- package/Selectbox.js +6 -42
- package/ShareButtons.js +4 -26
- package/Sharpie.js +3 -5
- package/SiteSearchAutocomplete.js +5 -41
- package/SiteSearchCurtain.js +3 -28
- package/SiteSearchInput.d.ts +1 -1
- package/SiteSearchInput.js +4 -40
- package/Skeleton.js +4 -6
- package/SubHeading.js +3 -5
- package/Tabs.js +3 -28
- package/TagPill.d.ts +1 -1
- package/TagPill.js +7 -20
- package/TextBlock.js +3 -5
- package/TextButton.d.ts +1 -1
- package/TextButton.js +4 -6
- package/TextInput.js +5 -41
- package/VSpacer.js +3 -5
- package/VerticalTabsTOC.js +3 -28
- package/WizardLayout.js +7 -9
- package/WizardLayoutClose.d.ts +1 -1
- package/WizardLayoutClose.js +4 -6
- package/WizardStepper.js +3 -5
- package/_abstract/_AbstractCarousel.js +7 -32
- package/_abstract/_Blings.js +3 -5
- package/_abstract/_Block.d.ts +2 -2
- package/_abstract/_Block.js +7 -9
- package/_abstract/{Button.d.ts → _Button.d.ts} +0 -0
- package/_abstract/{Button.js → _Button.js} +6 -19
- package/{esm/_abstract/CardList.d.ts → _abstract/_CardList.d.ts} +2 -1
- package/_abstract/{CardList.js → _CardList.js} +12 -12
- package/{esm/_abstract/Image.d.ts → _abstract/_Image.d.ts} +9 -5
- package/_abstract/{Image.js → _Image.js} +5 -7
- package/_abstract/{Link.d.ts → _Link.d.ts} +0 -0
- package/_abstract/{Link.js → _Link.js} +2 -4
- package/_abstract/_Quote.js +4 -6
- package/{esm/_abstract/TogglerGroup.d.ts → _abstract/_TogglerGroup.d.ts} +1 -1
- package/_abstract/{TogglerGroup.js → _TogglerGroup.js} +8 -8
- package/{esm/_abstract/TogglerGroupField.d.ts → _abstract/_TogglerGroupField.d.ts} +2 -2
- package/_abstract/_TogglerGroupField.js +14 -0
- package/_abstract/{TogglerInput.d.ts → _TogglerInput.d.ts} +0 -0
- package/_abstract/{TogglerInput.js → _TogglerInput.js} +4 -17
- package/_abstract/breakOnNL.js +2 -4
- package/package.json +6 -365
- package/utils/env.js +2 -4
- package/utils/seenEffect.d.ts +2 -2
- package/utils/seenEffect.js +1 -1
- package/utils/useScrollbarWidthCSSVar.js +2 -4
- package/utils.js +3 -16
- package/_abstract/CardList.d.ts +0 -29
- package/_abstract/Image.d.ts +0 -32
- package/_abstract/TogglerGroup.d.ts +0 -31
- package/_abstract/TogglerGroupField.d.ts +0 -17
- package/_abstract/TogglerGroupField.js +0 -27
- package/esm/AccordionList.d.ts +0 -17
- package/esm/AccordionList.js +0 -24
- package/esm/ActionCards.d.ts +0 -5
- package/esm/ActionCards.js +0 -9
- package/esm/Alert.d.ts +0 -49
- package/esm/Alert.js +0 -92
- package/esm/ArticleCarousel/_ArticleCarouselCard.d.ts +0 -27
- package/esm/ArticleCarousel/_ArticleCarouselCard.js +0 -24
- package/esm/ArticleCarousel.d.ts +0 -12
- package/esm/ArticleCarousel.js +0 -8
- package/esm/ArticleMeta.d.ts +0 -9
- package/esm/ArticleMeta.js +0 -18
- package/esm/Attention.d.ts +0 -7
- package/esm/Attention.js +0 -4
- package/esm/BasicTable.d.ts +0 -12
- package/esm/BasicTable.js +0 -29
- package/esm/Bling.d.ts +0 -81
- package/esm/Bling.js +0 -44
- package/esm/BlockBreak.d.ts +0 -2
- package/esm/BlockBreak.js +0 -6
- package/esm/BlockQuote.d.ts +0 -4
- package/esm/BlockQuote.js +0 -4
- package/esm/BreadCrumbs.d.ts +0 -11
- package/esm/BreadCrumbs.js +0 -28
- package/esm/ButtonBack.d.ts +0 -7
- package/esm/ButtonBack.js +0 -4
- package/esm/ButtonBar.d.ts +0 -16
- package/esm/ButtonBar.js +0 -14
- package/esm/ButtonPrimary.d.ts +0 -7
- package/esm/ButtonPrimary.js +0 -4
- package/esm/ButtonSecondary.d.ts +0 -7
- package/esm/ButtonSecondary.js +0 -4
- package/esm/ButtonTertiary.d.ts +0 -12
- package/esm/ButtonTertiary.js +0 -15
- package/esm/Carousel.d.ts +0 -4
- package/esm/Carousel.js +0 -4
- package/esm/CarouselStepper.d.ts +0 -4
- package/esm/CarouselStepper.js +0 -4
- package/esm/CenterColumn.js +0 -7
- package/esm/Checkbox.d.ts +0 -4
- package/esm/Checkbox.js +0 -4
- package/esm/CheckboxButtonsGroup.d.ts +0 -11
- package/esm/CheckboxButtonsGroup.js +0 -14
- package/esm/CheckboxGroup.d.ts +0 -9
- package/esm/CheckboxGroup.js +0 -7
- package/esm/CityBlock.d.ts +0 -23
- package/esm/CityBlock.js +0 -18
- package/esm/ContactBubble.d.ts +0 -58
- package/esm/ContactBubble.js +0 -148
- package/esm/ContentArticle.d.ts +0 -15
- package/esm/ContentArticle.js +0 -21
- package/esm/ContentImage.d.ts +0 -8
- package/esm/ContentImage.js +0 -18
- package/esm/Datepicker.d.ts +0 -39
- package/esm/Datepicker.js +0 -63
- package/esm/ExtraLinks.d.ts +0 -18
- package/esm/ExtraLinks.js +0 -34
- package/esm/FeatureList.d.ts +0 -12
- package/esm/FeatureList.js +0 -16
- package/esm/FieldGroup.d.ts +0 -9
- package/esm/FieldGroup.js +0 -9
- package/esm/FileInput.d.ts +0 -17
- package/esm/FileInput.js +0 -154
- package/esm/Foonote.d.ts +0 -12
- package/esm/Foonote.js +0 -7
- package/esm/FooterBadges.d.ts +0 -9
- package/esm/FooterBadges.js +0 -12
- package/esm/FooterInfo.d.ts +0 -18
- package/esm/FooterInfo.js +0 -9
- package/esm/Footnote.d.ts +0 -6
- package/esm/Footnote.js +0 -3
- package/esm/Form.d.ts +0 -7
- package/esm/Form.js +0 -10
- package/esm/FormField.d.ts +0 -65
- package/esm/FormField.js +0 -91
- package/esm/Gallery/_GalleryItem.d.ts +0 -8
- package/esm/Gallery/_GalleryItem.js +0 -30
- package/esm/Gallery/_GalleryModal.d.ts +0 -6
- package/esm/Gallery/_GalleryModal.js +0 -54
- package/esm/Gallery/_GalleryModalContext.d.ts +0 -9
- package/esm/Gallery/_GalleryModalContext.js +0 -3
- package/esm/Gallery/_GalleryModalItem.d.ts +0 -3
- package/esm/Gallery/_GalleryModalItem.js +0 -22
- package/esm/Gallery.d.ts +0 -17
- package/esm/Gallery.js +0 -27
- package/esm/GridBlocks.d.ts +0 -26
- package/esm/GridBlocks.js +0 -24
- package/esm/Heading.d.ts +0 -16
- package/esm/Heading.js +0 -17
- package/esm/HeroBlock.d.ts +0 -19
- package/esm/HeroBlock.js +0 -21
- package/esm/IframeBlock.d.ts +0 -23
- package/esm/IframeBlock.js +0 -26
- package/esm/Illustration.d.ts +0 -13
- package/esm/Illustration.js +0 -8
- package/esm/ImageCards.d.ts +0 -8
- package/esm/ImageCards.js +0 -22
- package/esm/InfoBlock.d.ts +0 -17
- package/esm/InfoBlock.js +0 -13
- package/esm/InfoHero.d.ts +0 -17
- package/esm/InfoHero.js +0 -82
- package/esm/IslandBlock.d.ts +0 -25
- package/esm/IslandBlock.js +0 -16
- package/esm/IslandPageBlock.d.ts +0 -24
- package/esm/IslandPageBlock.js +0 -16
- package/esm/LabeledTextBlock.d.ts +0 -11
- package/esm/LabeledTextBlock.js +0 -14
- package/esm/Layout.d.ts +0 -33
- package/esm/Layout.js +0 -52
- package/esm/MainMenu/_Auxiliary.d.ts +0 -6
- package/esm/MainMenu/_Auxiliary.js +0 -13
- package/esm/MainMenu/_PrimaryPanel.d.ts +0 -13
- package/esm/MainMenu/_PrimaryPanel.js +0 -22
- package/esm/MainMenu.d.ts +0 -48
- package/esm/MainMenu.js +0 -136
- package/esm/MiniMetrics.d.ts +0 -8
- package/esm/MiniMetrics.js +0 -12
- package/esm/Modal.d.ts +0 -10
- package/esm/Modal.js +0 -14
- package/esm/NameCard.d.ts +0 -64
- package/esm/NameCard.js +0 -82
- package/esm/NameCards.d.ts +0 -6
- package/esm/NameCards.js +0 -7
- package/esm/NewsHero.d.ts +0 -14
- package/esm/NewsHero.js +0 -86
- package/esm/PageFilter.d.ts +0 -17
- package/esm/PageFilter.js +0 -15
- package/esm/PageHeading.d.ts +0 -10
- package/esm/PageHeading.js +0 -12
- package/esm/ProcessOverview.d.ts +0 -13
- package/esm/ProcessOverview.js +0 -17
- package/esm/PullQuote.d.ts +0 -4
- package/esm/PullQuote.js +0 -4
- package/esm/RadioButtonsGroup.d.ts +0 -11
- package/esm/RadioButtonsGroup.js +0 -14
- package/esm/RadioGroup.d.ts +0 -13
- package/esm/RadioGroup.js +0 -7
- package/esm/RelatedLinks.d.ts +0 -20
- package/esm/RelatedLinks.js +0 -26
- package/esm/RowBlock.d.ts +0 -12
- package/esm/RowBlock.js +0 -9
- package/esm/RowBlockColumn.d.ts +0 -8
- package/esm/RowBlockColumn.js +0 -11
- package/esm/SearchInput.d.ts +0 -18
- package/esm/SearchInput.js +0 -33
- package/esm/SearchResults/_SearchResultsItem.d.ts +0 -18
- package/esm/SearchResults/_SearchResultsItem.js +0 -15
- package/esm/SearchResults.d.ts +0 -33
- package/esm/SearchResults.js +0 -109
- package/esm/SeenEffect.d.ts +0 -4
- package/esm/SeenEffect.js +0 -19
- package/esm/Selectbox.d.ts +0 -8
- package/esm/Selectbox.js +0 -46
- package/esm/ShareButtons.d.ts +0 -9
- package/esm/ShareButtons.js +0 -51
- package/esm/Sharpie.d.ts +0 -23
- package/esm/Sharpie.js +0 -22
- package/esm/SiteSearchAutocomplete.d.ts +0 -40
- package/esm/SiteSearchAutocomplete.js +0 -58
- package/esm/SiteSearchCurtain.d.ts +0 -6
- package/esm/SiteSearchCurtain.js +0 -33
- package/esm/SiteSearchInput.d.ts +0 -24
- package/esm/SiteSearchInput.js +0 -40
- package/esm/Skeleton.d.ts +0 -25
- package/esm/Skeleton.js +0 -30
- package/esm/SubHeading.d.ts +0 -10
- package/esm/SubHeading.js +0 -13
- package/esm/Tabs.d.ts +0 -35
- package/esm/Tabs.js +0 -94
- package/esm/TagPill.d.ts +0 -27
- package/esm/TagPill.js +0 -43
- package/esm/TextBlock.d.ts +0 -15
- package/esm/TextBlock.js +0 -15
- package/esm/TextButton.d.ts +0 -9
- package/esm/TextButton.js +0 -9
- package/esm/TextInput.d.ts +0 -16
- package/esm/TextInput.js +0 -35
- package/esm/VSpacer.d.ts +0 -24
- package/esm/VSpacer.js +0 -41
- package/esm/VerticalTabsTOC.d.ts +0 -14
- package/esm/VerticalTabsTOC.js +0 -68
- package/esm/WizardLayout.d.ts +0 -15
- package/esm/WizardLayout.js +0 -30
- package/esm/WizardLayoutClose.d.ts +0 -3
- package/esm/WizardLayoutClose.js +0 -4
- package/esm/WizardStepper.d.ts +0 -36
- package/esm/WizardStepper.js +0 -25
- package/esm/_abstract/Button.d.ts +0 -40
- package/esm/_abstract/Button.js +0 -47
- package/esm/_abstract/CardList.js +0 -36
- package/esm/_abstract/Image.js +0 -27
- package/esm/_abstract/Link.d.ts +0 -27
- package/esm/_abstract/Link.js +0 -24
- package/esm/_abstract/TogglerGroup.js +0 -29
- package/esm/_abstract/TogglerGroupField.js +0 -22
- package/esm/_abstract/TogglerInput.d.ts +0 -22
- package/esm/_abstract/TogglerInput.js +0 -33
- package/esm/_abstract/_AbstractCarousel.d.ts +0 -25
- package/esm/_abstract/_AbstractCarousel.js +0 -130
- package/esm/_abstract/_Blings.d.ts +0 -11
- package/esm/_abstract/_Blings.js +0 -12
- package/esm/_abstract/_Block.d.ts +0 -22
- package/esm/_abstract/_Block.js +0 -24
- package/esm/_abstract/_Quote.d.ts +0 -9
- package/esm/_abstract/_Quote.js +0 -8
- package/esm/_abstract/breakOnNL.d.ts +0 -2
- package/esm/_abstract/breakOnNL.js +0 -8
- package/esm/assets.d.ts +0 -42
- package/esm/assets.js +0 -56
- package/esm/constants.d.ts +0 -39
- package/esm/constants.js +0 -22
- package/esm/focus-visible.d.ts +0 -1
- package/esm/focus-visible.js +0 -1
- package/esm/package.json +0 -1
- package/esm/utils/env.d.ts +0 -1
- package/esm/utils/env.js +0 -8
- package/esm/utils/seenEffect.d.ts +0 -28
- package/esm/utils/seenEffect.js +0 -73
- package/esm/utils/useFormatMonitor.d.ts +0 -38
- package/esm/utils/useFormatMonitor.js +0 -41
- package/esm/utils/useGetSVGtext.d.ts +0 -6
- package/esm/utils/useGetSVGtext.js +0 -19
- package/esm/utils/useMenuToggling.d.ts +0 -8
- package/esm/utils/useMenuToggling.js +0 -62
- package/esm/utils/useScrollbarWidthCSSVar.d.ts +0 -1
- package/esm/utils/useScrollbarWidthCSSVar.js +0 -3
- package/esm/utils.d.ts +0 -2
- package/esm/utils.js +0 -2
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState, } from 'react';
|
|
2
|
-
import A from '@hugsmidjan/qj/A';
|
|
3
|
-
import focusElm from '@hugsmidjan/qj/focusElm';
|
|
4
|
-
import throttle from '@hugsmidjan/qj/throttle';
|
|
5
|
-
import { useIsBrowserSide } from '@hugsmidjan/react/hooks';
|
|
6
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
7
|
-
import { notNully } from '@reykjavik/hanna-utils';
|
|
8
|
-
import CarouselStepper from '../CarouselStepper';
|
|
9
|
-
import { useSeenEffect } from '../utils/seenEffect';
|
|
10
|
-
const WHEEL_AMPLIFIER = 3;
|
|
11
|
-
const WHEEL_HIJACK_TIMEOUT_MS = 667;
|
|
12
|
-
const scrollXBy = (elm, deltaX) => {
|
|
13
|
-
const left = elm.scrollLeft + deltaX;
|
|
14
|
-
elm.scrollTo(left, elm.scrollTop);
|
|
15
|
-
// NOTE 1: using elm.scrollTo({ left, behavior: 'smooth' }); seems to be too much
|
|
16
|
-
// as `behavior: 'smooth'` starts some weird interactions with the browser's
|
|
17
|
-
// `scroll-snap-type` behavior.
|
|
18
|
-
//
|
|
19
|
-
// NOTE 2: Both Chrome and Safari tend to snap hard to the nearest list item
|
|
20
|
-
// while Firefox is more smooth. Haven't found a way around that.
|
|
21
|
-
};
|
|
22
|
-
const exitWheelHijack = (elm) => () => {
|
|
23
|
-
elm.style.scrollSnapType = '';
|
|
24
|
-
const lastElmOffset = elm.lastElementChild
|
|
25
|
-
? elm.lastElementChild.offsetLeft
|
|
26
|
-
: 0;
|
|
27
|
-
// trigger one last scroll event, to make sure the element's
|
|
28
|
-
// `style.scrollSnapType`'s behavior kicks in.
|
|
29
|
-
// Otherwise the list may stay stuck in an over-scrolled state —
|
|
30
|
-
// off to the right.
|
|
31
|
-
scrollXBy(elm, Math.min(0, lastElmOffset - elm.scrollLeft));
|
|
32
|
-
};
|
|
33
|
-
const handleMouseWheel = (e) => {
|
|
34
|
-
const elm = e.currentTarget;
|
|
35
|
-
if (e.deltaX || elm.$hasXDeltaed) {
|
|
36
|
-
elm.$hasXDeltaed = true;
|
|
37
|
-
exitWheelHijack(elm);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (e.deltaY && !e.deltaX) {
|
|
41
|
-
if (e.deltaY < 0) {
|
|
42
|
-
// Stop scroll-capture when list is at left-edge
|
|
43
|
-
if (elm.scrollLeft < 50) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
// Stop scroll-capture when list is beyond left edge of last list item
|
|
49
|
-
if (elm.scrollLeft >
|
|
50
|
-
(elm.lastElementChild ? elm.lastElementChild.offsetLeft : 0)) {
|
|
51
|
-
exitWheelHijack(elm);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
e.stopImmediatePropagation();
|
|
57
|
-
// Disable `scroll-snap-style` because otherwise
|
|
58
|
-
// small-scale elm.scrollTo() calls have no effect
|
|
59
|
-
elm.style.scrollSnapType = 'initial';
|
|
60
|
-
scrollXBy(elm, e.deltaY * WHEEL_AMPLIFIER);
|
|
61
|
-
clearTimeout(elm.$timeout);
|
|
62
|
-
elm.$timeout = setTimeout(exitWheelHijack(elm), WHEEL_HIJACK_TIMEOUT_MS);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const handleMouseLeave = (e) => {
|
|
66
|
-
const elm = e.currentTarget;
|
|
67
|
-
exitWheelHijack(elm);
|
|
68
|
-
elm.$hasXDeltaed = undefined;
|
|
69
|
-
};
|
|
70
|
-
const AbstractCarousel = (props) => {
|
|
71
|
-
const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, } = props;
|
|
72
|
-
const children = props.children && props.children.filter(notNully);
|
|
73
|
-
const [leftOffset, setLeftOffset] = useState();
|
|
74
|
-
const itemCount = (children || items).length;
|
|
75
|
-
const listRef = useRef(null);
|
|
76
|
-
const [activeItem, setActiveItem] = useState(0);
|
|
77
|
-
const isBrowser = useIsBrowserSide(ssr);
|
|
78
|
-
// update on activeItem state change
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
const listElm = listRef.current;
|
|
81
|
-
if (!listElm) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const calcLeftOffset = () => {
|
|
85
|
-
var _a;
|
|
86
|
-
setLeftOffset((_a = listElm.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left);
|
|
87
|
-
scrollXBy(listElm, 0);
|
|
88
|
-
};
|
|
89
|
-
const calcActiveItem = throttle(() => {
|
|
90
|
-
const { scrollLeft, children } = listElm;
|
|
91
|
-
// using Array#find as forEachUntil
|
|
92
|
-
A(children).find((item, i) => {
|
|
93
|
-
if (scrollLeft <= item.offsetLeft + item.offsetWidth / 2) {
|
|
94
|
-
setActiveItem(i);
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}, 300, true);
|
|
99
|
-
calcLeftOffset();
|
|
100
|
-
listElm.addEventListener('wheel', handleMouseWheel);
|
|
101
|
-
listElm.addEventListener('scroll', calcActiveItem, { passive: true });
|
|
102
|
-
window.addEventListener('resize', calcLeftOffset, { passive: true });
|
|
103
|
-
return () => {
|
|
104
|
-
listElm.removeEventListener('wheel', handleMouseWheel);
|
|
105
|
-
listElm.removeEventListener('scroll', calcActiveItem);
|
|
106
|
-
window.removeEventListener('resize', calcLeftOffset);
|
|
107
|
-
};
|
|
108
|
-
}, []);
|
|
109
|
-
const scrollToItem = (newActive) => {
|
|
110
|
-
setActiveItem(newActive);
|
|
111
|
-
const listElm = listRef.current;
|
|
112
|
-
const newItem = listElm.children[newActive];
|
|
113
|
-
listElm.scrollTo(newItem ? newItem.offsetLeft : 0, 0);
|
|
114
|
-
setTimeout(() => focusElm(newItem), 500);
|
|
115
|
-
};
|
|
116
|
-
const [outerRef] = useSeenEffect(startSeen);
|
|
117
|
-
if (!itemCount) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
return (React.createElement("div", { className: getBemClass(bem, modifier, props.className), ref: outerRef, "data-sprinkled": isBrowser },
|
|
121
|
-
title && React.createElement("h2", { className: bem + '__title' }, title),
|
|
122
|
-
React.createElement("div", { className: bem + '__itemlist', style: leftOffset
|
|
123
|
-
? { '--Carousel--leftOffset': `${leftOffset}px` }
|
|
124
|
-
: undefined, "data-scroll-snapping": leftOffset ? 'true' : undefined, onMouseLeave: handleMouseLeave, ref: listRef }, children ||
|
|
125
|
-
items.map((item, i) => (
|
|
126
|
-
// @ts-expect-error (Can't be arsed...)
|
|
127
|
-
React.createElement(Component, Object.assign({ key: i }, ComponentProps, item))))),
|
|
128
|
-
isBrowser && (React.createElement(CarouselStepper, { itemCount: itemCount, setCurrent: scrollToItem, current: activeItem }))));
|
|
129
|
-
};
|
|
130
|
-
export default AbstractCarousel;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BlingType } from '@reykjavik/hanna-utils/assets';
|
|
2
|
-
import { BlingProps } from '../Bling';
|
|
3
|
-
export declare type BlingComboProps = Array<Omit<BlingProps, 'type' | 'blingUrl'> & {
|
|
4
|
-
type: BlingType;
|
|
5
|
-
}>;
|
|
6
|
-
declare type BlingsProps = {
|
|
7
|
-
blings: BlingComboProps;
|
|
8
|
-
mirror?: boolean;
|
|
9
|
-
};
|
|
10
|
-
declare const Blings: (props: BlingsProps) => JSX.Element;
|
|
11
|
-
export default Blings;
|
package/esm/_abstract/_Blings.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Bling from '../Bling';
|
|
3
|
-
const inverseAlignments = {
|
|
4
|
-
left: 'right',
|
|
5
|
-
'left-ish': 'right-ish',
|
|
6
|
-
'left-center': 'right-center',
|
|
7
|
-
'right-center': 'left-center',
|
|
8
|
-
'right-ish': 'left-ish',
|
|
9
|
-
right: 'left',
|
|
10
|
-
};
|
|
11
|
-
const Blings = (props) => (React.createElement(React.Fragment, null, props.blings.map(({ type, align, vertical, color, overlay, parent }, i) => (React.createElement(Bling, { key: type + '-' + i, type: type, align: props.mirror ? inverseAlignments[align || 'left'] : align, vertical: vertical, color: color, overlay: overlay, parent: parent })))));
|
|
12
|
-
export default Blings;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BemPropsModifier } from '@hugsmidjan/react/types';
|
|
2
|
-
import { SeenProp } from '../utils/seenEffect';
|
|
3
|
-
import { ButtonProps } from './Button';
|
|
4
|
-
import { ImageProps } from './Image';
|
|
5
|
-
export declare type BlockItem = {
|
|
6
|
-
title: string;
|
|
7
|
-
summary?: string | JSX.Element;
|
|
8
|
-
buttons?: Array<ButtonProps>;
|
|
9
|
-
};
|
|
10
|
-
export declare type ContentImageBlock = {
|
|
11
|
-
content: BlockItem;
|
|
12
|
-
image: ImageProps;
|
|
13
|
-
} & SeenProp;
|
|
14
|
-
export declare type ContentBlock = {
|
|
15
|
-
content: Array<BlockItem>;
|
|
16
|
-
image?: undefined;
|
|
17
|
-
} & SeenProp;
|
|
18
|
-
export declare type BlockProps = BemPropsModifier & (ContentBlock | ContentImageBlock);
|
|
19
|
-
declare const Block: (props: BlockProps & {
|
|
20
|
-
bem: string;
|
|
21
|
-
}) => JSX.Element;
|
|
22
|
-
export default Block;
|
package/esm/_abstract/_Block.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
-
import { useSeenEffect } from '../utils/seenEffect';
|
|
4
|
-
import Button from './Button';
|
|
5
|
-
import Image from './Image';
|
|
6
|
-
const Block = (props) => {
|
|
7
|
-
const { image, modifier, bem, content, startSeen } = props;
|
|
8
|
-
const [ref] = useSeenEffect(startSeen);
|
|
9
|
-
const contentItems = Array.isArray(content) ? content : [content];
|
|
10
|
-
return (React.createElement("div", { className: getBemClass(bem, modifier), ref: ref },
|
|
11
|
-
contentItems.map(({ title, summary, buttons = [] }, i) => {
|
|
12
|
-
const hasSummary = summary && (typeof summary !== 'string' || !!summary.trim());
|
|
13
|
-
return (React.createElement("div", { key: i, className: `${bem}__content` },
|
|
14
|
-
React.createElement("h2", { className: `${bem}__title` }, title),
|
|
15
|
-
hasSummary && React.createElement("div", { className: `${bem}__summary` }, summary),
|
|
16
|
-
buttons.length > 0 && (React.createElement("div", { className: `${bem}__buttons` },
|
|
17
|
-
' ',
|
|
18
|
-
buttons.map((buttonProps, i) => (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement(Button, Object.assign({ bem: `${bem}__button`, key: i }, buttonProps)),
|
|
20
|
-
' ')))))));
|
|
21
|
-
}),
|
|
22
|
-
image && React.createElement(Image, Object.assign({ className: `${bem}__image` }, image))));
|
|
23
|
-
};
|
|
24
|
-
export default Block;
|
package/esm/_abstract/_Quote.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Link } from './Link';
|
|
3
|
-
export const _Quote = (props) => {
|
|
4
|
-
const { bem, children, by, byHref } = props;
|
|
5
|
-
return (React.createElement("figure", { className: bem },
|
|
6
|
-
React.createElement("blockquote", { className: bem + '__quote' }, children),
|
|
7
|
-
by && (React.createElement("figcaption", { className: bem + '__by' }, byHref ? (React.createElement(Link, { href: byHref }, by)) : typeof by === 'string' ? (React.createElement("span", null, by)) : (by)))));
|
|
8
|
-
};
|
package/esm/assets.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { BlingType, Efnistakn, Formheimur, Illustration } from '@reykjavik/hanna-utils/assets';
|
|
2
|
-
import { blingTypes, efnistakn, getAssetUrl, getBlingUrl, getEfnistaknUrl, getFormheimurUrl, getIllustrationUrl, illustrations } from '@reykjavik/hanna-utils/assets';
|
|
3
|
-
export type {
|
|
4
|
-
/** @deprecated Instead `import type { BlingType } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
5
|
-
BlingType,
|
|
6
|
-
/** @deprecated Instead `import type { Efnistakn } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
7
|
-
Efnistakn,
|
|
8
|
-
/** @deprecated Instead `import type { Formheimur } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
9
|
-
Formheimur,
|
|
10
|
-
/** @deprecated Instead `import type { Illustration } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
11
|
-
Illustration, };
|
|
12
|
-
export {
|
|
13
|
-
/** @deprecated Instead `import type { blingTypes } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
14
|
-
blingTypes,
|
|
15
|
-
/** @deprecated Instead `import type { efnistakn } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
16
|
-
efnistakn,
|
|
17
|
-
/** @deprecated Instead `import type { getAssetUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
18
|
-
getAssetUrl,
|
|
19
|
-
/** @deprecated Instead `import type { getBlingUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
20
|
-
getBlingUrl,
|
|
21
|
-
/** @deprecated Instead `import type { getEfnistaknUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
22
|
-
getEfnistaknUrl,
|
|
23
|
-
/** @deprecated Instead `import type { getFormheimurUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
24
|
-
getFormheimurUrl,
|
|
25
|
-
/** @deprecated Instead `import type { getIllustrationUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
26
|
-
getIllustrationUrl,
|
|
27
|
-
/** @deprecated Instead `import type { illustrations } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
28
|
-
illustrations, };
|
|
29
|
-
/** @deprecated Use `getCssBundleUrl` from '@reykjavik/hanna-css' instead (Will be reomved in v0.11) */
|
|
30
|
-
export declare const getCssBundleUrl: (cssTokens: string | Array<string>, version?: string | undefined) => string;
|
|
31
|
-
/** @deprecated (Will be removed in v0.11) */
|
|
32
|
-
export declare const efnistakn_menu: readonly ["menu/borgarstjori", "menu/borgarstjorn", "menu/bygg_framkv", "menu/fjarmal", "menu/fundargerdir", "menu/itrottir_aftreying", "menu/log_reglugerdir", "menu/mannaudur", "menu/menning", "menu/rad_nefndir", "menu/skipulag", "menu/skolar_fristund", "menu/svid_deildir", "menu/umhverfi_samgongur", "menu/velferd_fjolskylda"];
|
|
33
|
-
/** @deprecated (Will be removed in v0.11) */
|
|
34
|
-
export declare type Efnistakn_Menu = typeof efnistakn_menu[number];
|
|
35
|
-
/** @deprecated (Will be removed in v0.11) */
|
|
36
|
-
export declare const auxiliary_menu_images: Array<Illustration>;
|
|
37
|
-
/** @deprecated Instead `import type { AuxilaryPanelIllustration } from '@reykjavik/hanna-react/MainMenu';` (Will be removed in v0.11) */
|
|
38
|
-
export declare type Auxilary_MenuImages = typeof auxiliary_menu_images[number];
|
|
39
|
-
/** @deprecated Instead `import type { BlingType } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
40
|
-
export declare type BlingTypes = BlingType;
|
|
41
|
-
/** @deprecated Instead `import type { Illustration } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
42
|
-
export declare type Illustrations = Illustration;
|
package/esm/assets.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { getCssBundleUrl as _getCssBundleUrl } from '@reykjavik/hanna-css';
|
|
2
|
-
import { blingTypes, efnistakn, getAssetUrl, getBlingUrl, getEfnistaknUrl, getFormheimurUrl, getIllustrationUrl, illustrations, } from '@reykjavik/hanna-utils/assets';
|
|
3
|
-
export {
|
|
4
|
-
/** @deprecated Instead `import type { blingTypes } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
5
|
-
blingTypes,
|
|
6
|
-
/** @deprecated Instead `import type { efnistakn } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
7
|
-
efnistakn,
|
|
8
|
-
/** @deprecated Instead `import type { getAssetUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
9
|
-
getAssetUrl,
|
|
10
|
-
/** @deprecated Instead `import type { getBlingUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
11
|
-
getBlingUrl,
|
|
12
|
-
/** @deprecated Instead `import type { getEfnistaknUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
13
|
-
getEfnistaknUrl,
|
|
14
|
-
/** @deprecated Instead `import type { getFormheimurUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
15
|
-
getFormheimurUrl,
|
|
16
|
-
/** @deprecated Instead `import type { getIllustrationUrl } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
17
|
-
getIllustrationUrl,
|
|
18
|
-
/** @deprecated Instead `import type { illustrations } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
|
|
19
|
-
illustrations, };
|
|
20
|
-
/** @deprecated Use `getCssBundleUrl` from '@reykjavik/hanna-css' instead (Will be reomved in v0.11) */
|
|
21
|
-
export const getCssBundleUrl = (cssTokens,
|
|
22
|
-
/** If you want to pin your CSS files to a specific version */
|
|
23
|
-
version) => _getCssBundleUrl(cssTokens, { version });
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Based on "https://styles.reykjavik.is/assets/efnistakn/menu/files.json"
|
|
26
|
-
/** @deprecated (Will be removed in v0.11) */
|
|
27
|
-
export const efnistakn_menu = [
|
|
28
|
-
'menu/borgarstjori',
|
|
29
|
-
'menu/borgarstjorn',
|
|
30
|
-
'menu/bygg_framkv',
|
|
31
|
-
'menu/fjarmal',
|
|
32
|
-
'menu/fundargerdir',
|
|
33
|
-
'menu/itrottir_aftreying',
|
|
34
|
-
'menu/log_reglugerdir',
|
|
35
|
-
'menu/mannaudur',
|
|
36
|
-
'menu/menning',
|
|
37
|
-
'menu/rad_nefndir',
|
|
38
|
-
'menu/skipulag',
|
|
39
|
-
'menu/skolar_fristund',
|
|
40
|
-
'menu/svid_deildir',
|
|
41
|
-
'menu/umhverfi_samgongur',
|
|
42
|
-
'menu/velferd_fjolskylda',
|
|
43
|
-
];
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
/** @deprecated (Will be removed in v0.11) */
|
|
46
|
-
export const auxiliary_menu_images = [
|
|
47
|
-
'hanna-veitiggi',
|
|
48
|
-
'hanna-vandro',
|
|
49
|
-
'hanna-hugsi',
|
|
50
|
-
'hanna-hissa',
|
|
51
|
-
'hanna-hahaha',
|
|
52
|
-
'hanna-hae',
|
|
53
|
-
'hanna-god_spurning',
|
|
54
|
-
'hanna-gjuggiborg',
|
|
55
|
-
'hanna-benda',
|
|
56
|
-
];
|
package/esm/constants.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/** @depcrecated import `colorFamilies` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
|
|
2
|
-
export declare const colorFamilies: readonly ["esja", "faxafloi", "nautholsvik", "heidmork", "ellidaardalur", "blafjoll", "sund", "rokkur", "suld"] & {
|
|
3
|
-
readonly esja: "esja";
|
|
4
|
-
readonly faxafloi: "faxafloi";
|
|
5
|
-
readonly nautholsvik: "nautholsvik";
|
|
6
|
-
readonly heidmork: "heidmork";
|
|
7
|
-
readonly ellidaardalur: "ellidaardalur";
|
|
8
|
-
readonly blafjoll: "blafjoll";
|
|
9
|
-
readonly sund: "sund";
|
|
10
|
-
readonly rokkur: "rokkur";
|
|
11
|
-
readonly suld: "suld";
|
|
12
|
-
} & {
|
|
13
|
-
/** @deprecated This is a typo (Will be removed in v0.11) */
|
|
14
|
-
ellidarardalur: string;
|
|
15
|
-
};
|
|
16
|
-
/** @depcrecated import type `ColorFamily` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
|
|
17
|
-
export type { ColorFamily } from '@reykjavik/hanna-css';
|
|
18
|
-
/** @depcrecated import `colorThemes` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
|
|
19
|
-
export declare const themeOptions: readonly ["trustworthy", "dependable", "friendly", "lively", "colorful"] & {
|
|
20
|
-
readonly trustworthy: "trustworthy";
|
|
21
|
-
readonly dependable: "dependable";
|
|
22
|
-
readonly friendly: "friendly";
|
|
23
|
-
readonly lively: "lively";
|
|
24
|
-
readonly colorful: "colorful";
|
|
25
|
-
};
|
|
26
|
-
/** @depcrecated import type `HannaColorTheme` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
|
|
27
|
-
export type { HannaColorTheme as ThemeOption } from '@reykjavik/hanna-css';
|
|
28
|
-
export declare type Alignment = 'right' | 'left';
|
|
29
|
-
export declare const aligns: Record<string, true | undefined>;
|
|
30
|
-
export declare type ComponentLayoutProps<Align extends string = 'right'> = {
|
|
31
|
-
wide?: undefined;
|
|
32
|
-
align?: undefined;
|
|
33
|
-
} | {
|
|
34
|
-
wide: boolean;
|
|
35
|
-
align?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
wide?: undefined;
|
|
38
|
-
align: Align;
|
|
39
|
-
};
|
package/esm/constants.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { colorFamilies as _colorFamilies, colorThemes } from '@reykjavik/hanna-css';
|
|
2
|
-
/** @depcrecated import `colorFamilies` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
|
|
3
|
-
export const colorFamilies = Object.assign([
|
|
4
|
-
'esja',
|
|
5
|
-
'faxafloi',
|
|
6
|
-
'nautholsvik',
|
|
7
|
-
'heidmork',
|
|
8
|
-
'ellidaardalur',
|
|
9
|
-
'blafjoll',
|
|
10
|
-
'sund',
|
|
11
|
-
'rokkur',
|
|
12
|
-
'suld',
|
|
13
|
-
], _colorFamilies, {
|
|
14
|
-
/** @deprecated This is a typo (Will be removed in v0.11) */
|
|
15
|
-
ellidarardalur: 'ellidaardalur',
|
|
16
|
-
});
|
|
17
|
-
/** @depcrecated import `colorThemes` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
|
|
18
|
-
export const themeOptions = Object.assign(['trustworthy', 'dependable', 'friendly', 'lively', 'colorful'], colorThemes);
|
|
19
|
-
export const aligns = {
|
|
20
|
-
right: true,
|
|
21
|
-
left: true,
|
|
22
|
-
};
|
package/esm/focus-visible.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@reykjavik/hanna-utils/focus-visible';
|
package/esm/focus-visible.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@reykjavik/hanna-utils/focus-visible';
|
package/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/esm/utils/env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isPreact: true | undefined;
|
package/esm/utils/env.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export const isPreact =
|
|
3
|
-
// imported from 'preact'
|
|
4
|
-
'h' in React ||
|
|
5
|
-
// imported from 'preact/compat' (has all of `react-dom` bundled)
|
|
6
|
-
('hydrate' in React && 'render' in React) ||
|
|
7
|
-
// `undefined` instead of `false` for nicer prop usage
|
|
8
|
-
undefined;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
export declare const DATA_ATTR_NAME = "is-seen";
|
|
3
|
-
export declare const getObserver: {
|
|
4
|
-
(target: Element, callback?: ((target: Element) => void) | undefined): (() => void) | undefined;
|
|
5
|
-
DATA_ATTR_NAME: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const seenEffectOptOut: (target: Element, setFlag?: boolean) => void;
|
|
8
|
-
declare const effects: {
|
|
9
|
-
readonly fadein: 1;
|
|
10
|
-
readonly fadeup: 1;
|
|
11
|
-
readonly fadeleft: 1;
|
|
12
|
-
};
|
|
13
|
-
export declare type SeenEffectType = keyof typeof effects;
|
|
14
|
-
export declare type EffectProp = {
|
|
15
|
-
/** Should the component appear instantly, and not transition-in once seen */
|
|
16
|
-
effectType?: SeenEffectType;
|
|
17
|
-
};
|
|
18
|
-
/** Asserts that a prop value is a SeenEffectType and returns undefined otherwise */
|
|
19
|
-
export declare const assertEffectType: (maybeType?: string | undefined) => SeenEffectType | undefined;
|
|
20
|
-
export declare const getEffectAttr: (maybeType?: string | undefined) => {
|
|
21
|
-
'data-seen-effect': string;
|
|
22
|
-
};
|
|
23
|
-
export declare type SeenProp = {
|
|
24
|
-
/** Should the component appear instantly, and not transition-in once seen */
|
|
25
|
-
startSeen?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export declare const useSeenEffect: <E extends Element = HTMLDivElement>(startSeen?: boolean | undefined, customRef?: RefObject<E> | undefined) => [RefObject<E> | undefined, true | undefined];
|
|
28
|
-
export {};
|
package/esm/utils/seenEffect.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
export const DATA_ATTR_NAME = 'is-seen';
|
|
3
|
-
const STACKING_DELAY = 400; // ms
|
|
4
|
-
const dataAttr = 'data-' + DATA_ATTR_NAME;
|
|
5
|
-
const inTargetSourceOrder = (a, b) => a.target.compareDocumentPosition(b.target) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;
|
|
6
|
-
const options = {
|
|
7
|
-
// root: window
|
|
8
|
-
rootMargin: '-100px 0px 0px 0px',
|
|
9
|
-
threshold: 0, // 0
|
|
10
|
-
};
|
|
11
|
-
let observer;
|
|
12
|
-
export const getObserver = (target, callback) => {
|
|
13
|
-
if (target.hasAttribute(dataAttr)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
17
|
-
if (!observer) {
|
|
18
|
-
observer = new IntersectionObserver((entries, observer) => entries
|
|
19
|
-
.filter((e) => e.isIntersecting)
|
|
20
|
-
.sort(inTargetSourceOrder)
|
|
21
|
-
.forEach(({ target }, i) => {
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
target.setAttribute(dataAttr, 'true');
|
|
24
|
-
callback && callback(target);
|
|
25
|
-
observer.unobserve(target);
|
|
26
|
-
}, STACKING_DELAY * i);
|
|
27
|
-
}), options);
|
|
28
|
-
}
|
|
29
|
-
if (target.matches('[' + dataAttr + '] *')) {
|
|
30
|
-
// opt out if target is contained by another "seen-effect" element
|
|
31
|
-
target.setAttribute(dataAttr, '');
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
target.setAttribute(dataAttr, 'false');
|
|
35
|
-
observer.observe(target);
|
|
36
|
-
return () => observer.unobserve(target);
|
|
37
|
-
};
|
|
38
|
-
export const seenEffectOptOut = (target, setFlag = true) => {
|
|
39
|
-
setFlag ? target.setAttribute(dataAttr, '') : target.removeAttribute(dataAttr);
|
|
40
|
-
};
|
|
41
|
-
getObserver.DATA_ATTR_NAME = DATA_ATTR_NAME;
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
const effects = {
|
|
45
|
-
fadein: 1,
|
|
46
|
-
fadeup: 1,
|
|
47
|
-
fadeleft: 1,
|
|
48
|
-
};
|
|
49
|
-
/** Asserts that a prop value is a SeenEffectType and returns undefined otherwise */
|
|
50
|
-
export const assertEffectType = (maybeType) => maybeType && maybeType in effects ? maybeType : undefined;
|
|
51
|
-
export const getEffectAttr = (maybeType) => ({
|
|
52
|
-
'data-seen-effect': assertEffectType(maybeType) || '',
|
|
53
|
-
});
|
|
54
|
-
export const useSeenEffect = (
|
|
55
|
-
/** Should the component appear instantly, and not transition-in once seen */
|
|
56
|
-
startSeen,
|
|
57
|
-
/** Bring Your Own RefObject */
|
|
58
|
-
customRef) => {
|
|
59
|
-
const localRef = useRef(null);
|
|
60
|
-
const [isSeen, setSeen] = useState(startSeen || undefined);
|
|
61
|
-
const ref = !startSeen && (customRef || localRef);
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
setSeen(startSeen || undefined);
|
|
64
|
-
if (ref && ref.current) {
|
|
65
|
-
// NOTE: Given that `ref` is defined, then
|
|
66
|
-
// `startSeen` is implicily `false | undefined` at
|
|
67
|
-
// this point.
|
|
68
|
-
seenEffectOptOut(ref.current, false);
|
|
69
|
-
return getObserver(ref.current, () => setSeen(true));
|
|
70
|
-
}
|
|
71
|
-
}, [ref, startSeen]);
|
|
72
|
-
return [ref || undefined, isSeen];
|
|
73
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pass a callback that gets called whenever the browser window
|
|
3
|
-
* resizes past one of the preconfigured "media-format" breakpoints.
|
|
4
|
-
*
|
|
5
|
-
* Exmple use:
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* useFormatMonitor((media) => {
|
|
9
|
-
* if (media.is === 'phone') {
|
|
10
|
-
* // do something clever because the window
|
|
11
|
-
* // just became "phone" sized.
|
|
12
|
-
* }
|
|
13
|
-
* if (media.was === 'phone') {
|
|
14
|
-
* // do something clever because the window
|
|
15
|
-
* // just stopped being "phone" sized.
|
|
16
|
-
* }
|
|
17
|
-
* })
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* The `media` argument has the following properties:
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* // type Formats = 'phone' | 'phablet' | 'tablet' | 'netbook' | 'wide'
|
|
24
|
-
* media.is //: Format
|
|
25
|
-
* media.was //?: Format
|
|
26
|
-
* // Category/mode boolean flags
|
|
27
|
-
* // (Hamburger refers to the "mobile menu" mode)
|
|
28
|
-
* media.isTopmenu
|
|
29
|
-
* media.isHamburger
|
|
30
|
-
* media.wasTopmenu
|
|
31
|
-
* media.wasHamburger
|
|
32
|
-
* media.becameTopmenu
|
|
33
|
-
* media.becameHamburger
|
|
34
|
-
* media.leftTopmenu
|
|
35
|
-
* media.leftHamburger
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare const useFormatMonitor: (callback: (media: import("formatchange").BaseMedia & Record<"isHamburger" | "isTopmenu" | "wasHamburger" | "wasTopmenu" | "becameHamburger" | "becameTopmenu" | "leftHamburger" | "leftTopmenu", boolean>) => void) => void;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { formatMonitor } from '@reykjavik/hanna-utils';
|
|
2
|
-
import { makeFormatMonitorHook } from 'formatchange/react';
|
|
3
|
-
// ==================================================
|
|
4
|
-
/**
|
|
5
|
-
* Pass a callback that gets called whenever the browser window
|
|
6
|
-
* resizes past one of the preconfigured "media-format" breakpoints.
|
|
7
|
-
*
|
|
8
|
-
* Exmple use:
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* useFormatMonitor((media) => {
|
|
12
|
-
* if (media.is === 'phone') {
|
|
13
|
-
* // do something clever because the window
|
|
14
|
-
* // just became "phone" sized.
|
|
15
|
-
* }
|
|
16
|
-
* if (media.was === 'phone') {
|
|
17
|
-
* // do something clever because the window
|
|
18
|
-
* // just stopped being "phone" sized.
|
|
19
|
-
* }
|
|
20
|
-
* })
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* The `media` argument has the following properties:
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* // type Formats = 'phone' | 'phablet' | 'tablet' | 'netbook' | 'wide'
|
|
27
|
-
* media.is //: Format
|
|
28
|
-
* media.was //?: Format
|
|
29
|
-
* // Category/mode boolean flags
|
|
30
|
-
* // (Hamburger refers to the "mobile menu" mode)
|
|
31
|
-
* media.isTopmenu
|
|
32
|
-
* media.isHamburger
|
|
33
|
-
* media.wasTopmenu
|
|
34
|
-
* media.wasHamburger
|
|
35
|
-
* media.becameTopmenu
|
|
36
|
-
* media.becameHamburger
|
|
37
|
-
* media.leftTopmenu
|
|
38
|
-
* media.leftHamburger
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export const useFormatMonitor = makeFormatMonitorHook(formatMonitor);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { getSVGtext } from '@reykjavik/hanna-utils';
|
|
3
|
-
export const useGetSVGtext = (imageSrc) => {
|
|
4
|
-
const [inlineSvg, setInlineSvg] = useState();
|
|
5
|
-
const srcRef = useRef(imageSrc);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (imageSrc) {
|
|
8
|
-
getSVGtext(imageSrc).then((code) => {
|
|
9
|
-
if (imageSrc === srcRef.current) {
|
|
10
|
-
setInlineSvg({ imageSrc, code });
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
srcRef.current = imageSrc;
|
|
15
|
-
setInlineSvg(undefined);
|
|
16
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
-
}, [imageSrc]);
|
|
18
|
-
return inlineSvg;
|
|
19
|
-
};
|