@reykjavik/hanna-react 0.10.53
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/CHANGELOG.md +795 -0
- package/README.md +69 -0
- package/lib/AccordionList.cjs +91 -0
- package/lib/AccordionList.mjs +69 -0
- package/lib/ActionCards.cjs +57 -0
- package/lib/ActionCards.mjs +35 -0
- package/lib/Alert.cjs +159 -0
- package/lib/Alert.mjs +139 -0
- package/lib/ArticleCarousel/_ArticleCarouselCard.cjs +75 -0
- package/lib/ArticleCarousel/_ArticleCarouselCard.mjs +51 -0
- package/lib/ArticleCarousel.cjs +43 -0
- package/lib/ArticleCarousel.mjs +21 -0
- package/lib/ArticleMeta.cjs +46 -0
- package/lib/ArticleMeta.mjs +22 -0
- package/lib/Attention.cjs +33 -0
- package/lib/Attention.mjs +9 -0
- package/lib/BasicTable.cjs +72 -0
- package/lib/BasicTable.mjs +50 -0
- package/lib/Bling.cjs +76 -0
- package/lib/Bling.mjs +52 -0
- package/lib/BlockBreak.cjs +32 -0
- package/lib/BlockBreak.mjs +8 -0
- package/lib/BlockQuote.cjs +47 -0
- package/lib/BlockQuote.mjs +25 -0
- package/lib/BreadCrumbs.cjs +67 -0
- package/lib/BreadCrumbs.mjs +43 -0
- package/lib/ButtonBack.cjs +47 -0
- package/lib/ButtonBack.mjs +25 -0
- package/lib/ButtonBar.cjs +45 -0
- package/lib/ButtonBar.mjs +18 -0
- package/lib/ButtonPrimary.cjs +47 -0
- package/lib/ButtonPrimary.mjs +25 -0
- package/lib/ButtonSecondary.cjs +47 -0
- package/lib/ButtonSecondary.mjs +25 -0
- package/lib/ButtonTertiary.cjs +64 -0
- package/lib/ButtonTertiary.mjs +42 -0
- package/lib/Carousel.cjs +52 -0
- package/lib/Carousel.mjs +30 -0
- package/lib/CarouselStepper.cjs +51 -0
- package/lib/CarouselStepper.mjs +29 -0
- package/lib/CenterColumn.cjs +40 -0
- package/lib/CenterColumn.mjs +16 -0
- package/lib/Checkbox.cjs +52 -0
- package/lib/Checkbox.mjs +30 -0
- package/lib/CheckboxButtonsGroup.cjs +65 -0
- package/lib/CheckboxButtonsGroup.mjs +43 -0
- package/lib/CheckboxGroup.cjs +55 -0
- package/lib/CheckboxGroup.mjs +33 -0
- package/lib/CityBlock.cjs +49 -0
- package/lib/CityBlock.mjs +25 -0
- package/lib/ContactBubble.cjs +200 -0
- package/lib/ContactBubble.mjs +173 -0
- package/lib/ContentArticle.cjs +63 -0
- package/lib/ContentArticle.mjs +41 -0
- package/lib/ContentImage.cjs +58 -0
- package/lib/ContentImage.mjs +36 -0
- package/lib/Datepicker.cjs +164 -0
- package/lib/Datepicker.mjs +142 -0
- package/lib/ExtraLinks.cjs +96 -0
- package/lib/ExtraLinks.mjs +74 -0
- package/lib/FeatureList.cjs +53 -0
- package/lib/FeatureList.mjs +29 -0
- package/lib/FieldGroup.cjs +40 -0
- package/lib/FieldGroup.mjs +16 -0
- package/lib/FileInput.cjs +256 -0
- package/lib/FileInput.mjs +234 -0
- package/lib/Foonote.cjs +30 -0
- package/lib/Foonote.mjs +6 -0
- package/lib/FooterBadges.cjs +49 -0
- package/lib/FooterBadges.mjs +25 -0
- package/lib/FooterInfo.cjs +47 -0
- package/lib/FooterInfo.mjs +23 -0
- package/lib/Footnote.cjs +32 -0
- package/lib/Footnote.mjs +8 -0
- package/lib/Form.cjs +56 -0
- package/lib/Form.mjs +34 -0
- package/lib/FormField.cjs +153 -0
- package/lib/FormField.mjs +131 -0
- package/lib/Gallery/_GalleryItem.cjs +83 -0
- package/lib/Gallery/_GalleryItem.mjs +61 -0
- package/lib/Gallery/_GalleryModal.cjs +104 -0
- package/lib/Gallery/_GalleryModal.mjs +82 -0
- package/lib/Gallery/_GalleryModalContext.cjs +30 -0
- package/lib/Gallery/_GalleryModalContext.mjs +6 -0
- package/lib/Gallery/_GalleryModalItem.cjs +59 -0
- package/lib/Gallery/_GalleryModalItem.mjs +36 -0
- package/lib/Gallery.cjs +79 -0
- package/lib/Gallery.mjs +57 -0
- package/lib/GridBlocks.cjs +81 -0
- package/lib/GridBlocks.mjs +59 -0
- package/lib/Heading.cjs +45 -0
- package/lib/Heading.mjs +21 -0
- package/lib/HeroBlock.cjs +74 -0
- package/lib/HeroBlock.mjs +52 -0
- package/lib/IframeBlock.cjs +48 -0
- package/lib/IframeBlock.mjs +24 -0
- package/lib/Illustration.cjs +51 -0
- package/lib/Illustration.mjs +31 -0
- package/lib/ImageCards.cjs +72 -0
- package/lib/ImageCards.mjs +52 -0
- package/lib/InfoBlock.cjs +51 -0
- package/lib/InfoBlock.mjs +27 -0
- package/lib/InfoHero.cjs +150 -0
- package/lib/InfoHero.mjs +128 -0
- package/lib/IslandBlock.cjs +63 -0
- package/lib/IslandBlock.mjs +41 -0
- package/lib/IslandPageBlock.cjs +49 -0
- package/lib/IslandPageBlock.mjs +25 -0
- package/lib/LabeledTextBlock.cjs +60 -0
- package/lib/LabeledTextBlock.mjs +38 -0
- package/lib/Layout.cjs +113 -0
- package/lib/Layout.mjs +87 -0
- package/lib/MainMenu/_Auxiliary.cjs +54 -0
- package/lib/MainMenu/_Auxiliary.mjs +28 -0
- package/lib/MainMenu/_PrimaryPanel.cjs +74 -0
- package/lib/MainMenu/_PrimaryPanel.mjs +48 -0
- package/lib/MainMenu.cjs +209 -0
- package/lib/MainMenu.mjs +187 -0
- package/lib/MiniMetrics.cjs +56 -0
- package/lib/MiniMetrics.mjs +34 -0
- package/lib/Modal.cjs +70 -0
- package/lib/Modal.mjs +48 -0
- package/lib/NameCard.cjs +115 -0
- package/lib/NameCard.mjs +91 -0
- package/lib/NameCards.cjs +52 -0
- package/lib/NameCards.mjs +30 -0
- package/lib/NewsHero.cjs +136 -0
- package/lib/NewsHero.mjs +114 -0
- package/lib/PageFilter.cjs +48 -0
- package/lib/PageFilter.mjs +24 -0
- package/lib/PageHeading.cjs +42 -0
- package/lib/PageHeading.mjs +18 -0
- package/lib/ProcessOverview.cjs +52 -0
- package/lib/ProcessOverview.mjs +28 -0
- package/lib/PullQuote.cjs +47 -0
- package/lib/PullQuote.mjs +25 -0
- package/lib/RadioButtonsGroup.cjs +64 -0
- package/lib/RadioButtonsGroup.mjs +42 -0
- package/lib/RadioGroup.cjs +58 -0
- package/lib/RadioGroup.mjs +36 -0
- package/lib/RelatedLinks.cjs +61 -0
- package/lib/RelatedLinks.mjs +37 -0
- package/lib/RowBlock.cjs +39 -0
- package/lib/RowBlock.mjs +15 -0
- package/lib/RowBlockColumn.cjs +40 -0
- package/lib/RowBlockColumn.mjs +16 -0
- package/lib/SearchInput.cjs +136 -0
- package/lib/SearchInput.mjs +114 -0
- package/lib/SearchResults/_SearchResultsItem.cjs +54 -0
- package/lib/SearchResults/_SearchResultsItem.mjs +30 -0
- package/lib/SearchResults.cjs +172 -0
- package/lib/SearchResults.mjs +150 -0
- package/lib/SeenEffect.cjs +66 -0
- package/lib/SeenEffect.mjs +44 -0
- package/lib/Selectbox.cjs +144 -0
- package/lib/Selectbox.mjs +122 -0
- package/lib/ShareButtons.cjs +101 -0
- package/lib/ShareButtons.mjs +83 -0
- package/lib/Sharpie.cjs +51 -0
- package/lib/Sharpie.mjs +27 -0
- package/lib/SiteSearchAutocomplete.cjs +150 -0
- package/lib/SiteSearchAutocomplete.mjs +126 -0
- package/lib/SiteSearchCurtain.cjs +78 -0
- package/lib/SiteSearchCurtain.mjs +56 -0
- package/lib/SiteSearchInput.cjs +119 -0
- package/lib/SiteSearchInput.mjs +97 -0
- package/lib/Skeleton.cjs +63 -0
- package/lib/Skeleton.mjs +39 -0
- package/lib/SubHeading.cjs +43 -0
- package/lib/SubHeading.mjs +19 -0
- package/lib/Tabs.cjs +166 -0
- package/lib/Tabs.mjs +144 -0
- package/lib/TagPill.cjs +113 -0
- package/lib/TagPill.mjs +91 -0
- package/lib/TextBlock.cjs +45 -0
- package/lib/TextBlock.mjs +21 -0
- package/lib/TextButton.cjs +55 -0
- package/lib/TextButton.mjs +33 -0
- package/lib/TextInput.cjs +136 -0
- package/lib/TextInput.mjs +114 -0
- package/lib/VSpacer.cjs +70 -0
- package/lib/VSpacer.mjs +46 -0
- package/lib/VerticalTabsTOC.cjs +123 -0
- package/lib/VerticalTabsTOC.mjs +101 -0
- package/lib/WizardLayout.cjs +79 -0
- package/lib/WizardLayout.mjs +55 -0
- package/lib/WizardLayoutClose.cjs +47 -0
- package/lib/WizardLayoutClose.mjs +25 -0
- package/lib/WizardStepper.cjs +55 -0
- package/lib/WizardStepper.mjs +31 -0
- package/lib/_abstract/Button.cjs +114 -0
- package/lib/_abstract/Button.mjs +92 -0
- package/lib/_abstract/CardList.cjs +100 -0
- package/lib/_abstract/CardList.mjs +76 -0
- package/lib/_abstract/Image.cjs +75 -0
- package/lib/_abstract/Image.mjs +51 -0
- package/lib/_abstract/Link.cjs +37 -0
- package/lib/_abstract/Link.mjs +10 -0
- package/lib/_abstract/TogglerGroup.cjs +92 -0
- package/lib/_abstract/TogglerGroup.mjs +70 -0
- package/lib/_abstract/TogglerGroupField.cjs +121 -0
- package/lib/_abstract/TogglerGroupField.mjs +99 -0
- package/lib/_abstract/TogglerInput.cjs +105 -0
- package/lib/_abstract/TogglerInput.mjs +83 -0
- package/lib/_abstract/_AbstractCarousel.cjs +170 -0
- package/lib/_abstract/_AbstractCarousel.mjs +152 -0
- package/lib/_abstract/_Blings.cjs +47 -0
- package/lib/_abstract/_Blings.mjs +23 -0
- package/lib/_abstract/_Block.cjs +73 -0
- package/lib/_abstract/_Block.mjs +51 -0
- package/lib/_abstract/_Quote.cjs +43 -0
- package/lib/_abstract/_Quote.mjs +17 -0
- package/lib/_abstract/breakOnNL.cjs +30 -0
- package/lib/_abstract/breakOnNL.mjs +6 -0
- package/lib/assets.cjs +77 -0
- package/lib/assets.mjs +53 -0
- package/lib/constants.cjs +49 -0
- package/lib/constants.mjs +24 -0
- package/lib/focus-visible.cjs +1 -0
- package/lib/focus-visible.mjs +1 -0
- package/lib/utils/config.cjs +27 -0
- package/lib/utils/config.mjs +4 -0
- package/lib/utils/detectEdgeScroll.cjs +95 -0
- package/lib/utils/detectEdgeScroll.mjs +71 -0
- package/lib/utils/env.cjs +31 -0
- package/lib/utils/env.mjs +5 -0
- package/lib/utils/seenEffect.cjs +93 -0
- package/lib/utils/seenEffect.mjs +65 -0
- package/lib/utils/useFormatMonitor.cjs +29 -0
- package/lib/utils/useFormatMonitor.mjs +6 -0
- package/lib/utils/useGetSVGtext.cjs +44 -0
- package/lib/utils/useGetSVGtext.mjs +21 -0
- package/lib/utils/useMenuToggling.cjs +83 -0
- package/lib/utils/useMenuToggling.mjs +60 -0
- package/lib/utils/useScrollbarWidthCSSVar.cjs +32 -0
- package/lib/utils/useScrollbarWidthCSSVar.mjs +6 -0
- package/lib/utils.cjs +18 -0
- package/lib/utils.mjs +2 -0
- package/package.json +491 -0
- package/types/AccordionList.d.ts +17 -0
- package/types/ActionCards.d.ts +5 -0
- package/types/Alert.d.ts +49 -0
- package/types/ArticleCarousel/_ArticleCarouselCard.d.ts +27 -0
- package/types/ArticleCarousel.d.ts +12 -0
- package/types/ArticleMeta.d.ts +9 -0
- package/types/Attention.d.ts +7 -0
- package/types/BasicTable.d.ts +12 -0
- package/types/Bling.d.ts +81 -0
- package/types/BlockBreak.d.ts +2 -0
- package/types/BlockQuote.d.ts +4 -0
- package/types/BreadCrumbs.d.ts +11 -0
- package/types/ButtonBack.d.ts +7 -0
- package/types/ButtonBar.d.ts +16 -0
- package/types/ButtonPrimary.d.ts +7 -0
- package/types/ButtonSecondary.d.ts +7 -0
- package/types/ButtonTertiary.d.ts +12 -0
- package/types/Carousel.d.ts +4 -0
- package/types/CarouselStepper.d.ts +4 -0
- package/types/CenterColumn.d.ts +7 -0
- package/types/Checkbox.d.ts +4 -0
- package/types/CheckboxButtonsGroup.d.ts +11 -0
- package/types/CheckboxGroup.d.ts +9 -0
- package/types/CityBlock.d.ts +23 -0
- package/types/ContactBubble.d.ts +58 -0
- package/types/ContentArticle.d.ts +15 -0
- package/types/ContentImage.d.ts +8 -0
- package/types/Datepicker.d.ts +39 -0
- package/types/ExtraLinks.d.ts +18 -0
- package/types/FeatureList.d.ts +12 -0
- package/types/FieldGroup.d.ts +9 -0
- package/types/FileInput.d.ts +17 -0
- package/types/Foonote.d.ts +12 -0
- package/types/FooterBadges.d.ts +9 -0
- package/types/FooterInfo.d.ts +18 -0
- package/types/Footnote.d.ts +6 -0
- package/types/Form.d.ts +7 -0
- package/types/FormField.d.ts +65 -0
- package/types/Gallery/_GalleryItem.d.ts +8 -0
- package/types/Gallery/_GalleryModal.d.ts +6 -0
- package/types/Gallery/_GalleryModalContext.d.ts +9 -0
- package/types/Gallery/_GalleryModalItem.d.ts +3 -0
- package/types/Gallery.d.ts +17 -0
- package/types/GridBlocks.d.ts +26 -0
- package/types/Heading.d.ts +16 -0
- package/types/HeroBlock.d.ts +19 -0
- package/types/IframeBlock.d.ts +23 -0
- package/types/Illustration.d.ts +13 -0
- package/types/ImageCards.d.ts +8 -0
- package/types/InfoBlock.d.ts +17 -0
- package/types/InfoHero.d.ts +17 -0
- package/types/IslandBlock.d.ts +25 -0
- package/types/IslandPageBlock.d.ts +24 -0
- package/types/LabeledTextBlock.d.ts +11 -0
- package/types/Layout.d.ts +33 -0
- package/types/MainMenu/_Auxiliary.d.ts +6 -0
- package/types/MainMenu/_PrimaryPanel.d.ts +13 -0
- package/types/MainMenu.d.ts +48 -0
- package/types/MiniMetrics.d.ts +8 -0
- package/types/Modal.d.ts +10 -0
- package/types/NameCard.d.ts +64 -0
- package/types/NameCards.d.ts +6 -0
- package/types/NewsHero.d.ts +14 -0
- package/types/PageFilter.d.ts +17 -0
- package/types/PageHeading.d.ts +10 -0
- package/types/ProcessOverview.d.ts +13 -0
- package/types/PullQuote.d.ts +4 -0
- package/types/RadioButtonsGroup.d.ts +11 -0
- package/types/RadioGroup.d.ts +13 -0
- package/types/RelatedLinks.d.ts +20 -0
- package/types/RowBlock.d.ts +12 -0
- package/types/RowBlockColumn.d.ts +8 -0
- package/types/SearchInput.d.ts +18 -0
- package/types/SearchResults/_SearchResultsItem.d.ts +18 -0
- package/types/SearchResults.d.ts +33 -0
- package/types/SeenEffect.d.ts +4 -0
- package/types/Selectbox.d.ts +8 -0
- package/types/ShareButtons.d.ts +9 -0
- package/types/Sharpie.d.ts +23 -0
- package/types/SiteSearchAutocomplete.d.ts +40 -0
- package/types/SiteSearchCurtain.d.ts +6 -0
- package/types/SiteSearchInput.d.ts +24 -0
- package/types/Skeleton.d.ts +25 -0
- package/types/SubHeading.d.ts +10 -0
- package/types/Tabs.d.ts +35 -0
- package/types/TagPill.d.ts +27 -0
- package/types/TextBlock.d.ts +15 -0
- package/types/TextButton.d.ts +9 -0
- package/types/TextInput.d.ts +16 -0
- package/types/VSpacer.d.ts +24 -0
- package/types/VerticalTabsTOC.d.ts +14 -0
- package/types/WizardLayout.d.ts +15 -0
- package/types/WizardLayoutClose.d.ts +3 -0
- package/types/WizardStepper.d.ts +36 -0
- package/types/_abstract/Button.d.ts +40 -0
- package/types/_abstract/CardList.d.ts +29 -0
- package/types/_abstract/Image.d.ts +32 -0
- package/types/_abstract/Link.d.ts +27 -0
- package/types/_abstract/TogglerGroup.d.ts +31 -0
- package/types/_abstract/TogglerGroupField.d.ts +17 -0
- package/types/_abstract/TogglerInput.d.ts +22 -0
- package/types/_abstract/_AbstractCarousel.d.ts +25 -0
- package/types/_abstract/_Blings.d.ts +11 -0
- package/types/_abstract/_Block.d.ts +22 -0
- package/types/_abstract/_Quote.d.ts +9 -0
- package/types/_abstract/breakOnNL.d.ts +2 -0
- package/types/assets.d.ts +42 -0
- package/types/constants.d.ts +39 -0
- package/types/focus-visible.d.ts +1 -0
- package/types/utils/config.d.ts +2 -0
- package/types/utils/detectEdgeScroll.d.ts +52 -0
- package/types/utils/env.d.ts +1 -0
- package/types/utils/seenEffect.d.ts +28 -0
- package/types/utils/useFormatMonitor.d.ts +38 -0
- package/types/utils/useGetSVGtext.d.ts +6 -0
- package/types/utils/useMenuToggling.d.ts +8 -0
- package/types/utils/useScrollbarWidthCSSVar.d.ts +1 -0
- package/types/utils.d.ts +2 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @reykjavik/hanna-react
|
|
2
|
+
|
|
3
|
+
The official React components for Hanna – Reykjavík's design-system
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install --save @reykjavik/hanna-react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Versioning
|
|
10
|
+
|
|
11
|
+
This module always targets the most recent version of the Hanna markup
|
|
12
|
+
patterns (currently **Hanna 0.8**).
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
NOTE:
|
|
16
|
+
If need arises we may decide to branch the repo and publish separate
|
|
17
|
+
legacy modules (i.e. `@reykjavik/hanna_1-react`) that provide active
|
|
18
|
+
long-term-support for older major-versions of Hanna's markup patterns.
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
The version number of the `@reykjavik/hanna-react` package reflects changes in
|
|
22
|
+
the React Component signatures, dependencies, etc. and may have major releases
|
|
23
|
+
at much higher rate than Hanna's markup patterns.
|
|
24
|
+
|
|
25
|
+
Note, however, that a major version update to the Hanna markup patterns
|
|
26
|
+
automatically triggers a major version bump in this package.
|
|
27
|
+
|
|
28
|
+
If you need a version of this package that "targets" an older Hanna markup
|
|
29
|
+
version, you'll find the appropriate package version in the
|
|
30
|
+
[change log](CHANGELOG.md).
|
|
31
|
+
|
|
32
|
+
## CSS
|
|
33
|
+
|
|
34
|
+
Each component is paired with a CSS file that can be loaded via the Hanna CSS
|
|
35
|
+
server – https://styles.reykjavik.is/
|
|
36
|
+
|
|
37
|
+
If your project uses `<Layout/>`, `<HeroBlock/>`, `<TextInput/>`,
|
|
38
|
+
`<Selectbox/>` and `<ButtonPrimary/>` you can load the required CSS by linking
|
|
39
|
+
to
|
|
40
|
+
<https://styles.reykjavik.is/bundle/v0.8?m=-basics,Layout,HeroBlock,TextInput,Selectbox,ButtonPrimary>
|
|
41
|
+
|
|
42
|
+
The preferred way to build the CSS URL is to use the helper `getCssBundleUrl`:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import { getCssBundleUrl } from '@reykjavik/hanna-css';
|
|
46
|
+
|
|
47
|
+
const cssUrl = getCssBundleUrl([
|
|
48
|
+
'-basics',
|
|
49
|
+
'Layout',
|
|
50
|
+
'HeroBlock',
|
|
51
|
+
'TextInput',
|
|
52
|
+
'Selectbox',
|
|
53
|
+
'ButtonPrimary',
|
|
54
|
+
]);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**NOTE:** The `-basics` URL token adds basic CSS resets, `@font-face`
|
|
58
|
+
declarations global color-variables, etc.
|
|
59
|
+
|
|
60
|
+
For best result, try and make sure each web page has **only one `<link />`**
|
|
61
|
+
to the CSS server to avoid unpredictable styling behavior.
|
|
62
|
+
|
|
63
|
+
<!--
|
|
64
|
+
## Older versions
|
|
65
|
+
|
|
66
|
+
To view the documentation for older versions of Hanna, check out the
|
|
67
|
+
corresponding branches in the git repo.
|
|
68
|
+
|
|
69
|
+
-->
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var AccordionList_exports = {};
|
|
39
|
+
__export(AccordionList_exports, {
|
|
40
|
+
default: () => AccordionList_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(AccordionList_exports);
|
|
43
|
+
var import_react = __toESM(require("react"));
|
|
44
|
+
var import_hooks = require("@hugsmidjan/react/hooks");
|
|
45
|
+
var import_getBemClass = __toESM(require("@hugsmidjan/react/utils/getBemClass"));
|
|
46
|
+
var import_seenEffect = require("./utils/seenEffect");
|
|
47
|
+
const AccordionListItem = (props) => {
|
|
48
|
+
const { title, content, id, disabled = false, defaultOpen, ssr } = props;
|
|
49
|
+
const [open, setOpen] = (0, import_react.useState)(defaultOpen);
|
|
50
|
+
(0, import_react.useEffect)(() => setOpen(defaultOpen), [defaultOpen]);
|
|
51
|
+
const domid = (0, import_hooks.useDomid)();
|
|
52
|
+
const isBrowser = (0, import_hooks.useIsBrowserSide)(ssr);
|
|
53
|
+
const itemDisabled = isBrowser && disabled || !content;
|
|
54
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
55
|
+
className: (0, import_getBemClass.default)("AccordionList__item", [itemDisabled && "disabled"]),
|
|
56
|
+
id,
|
|
57
|
+
"data-start-open": defaultOpen || void 0,
|
|
58
|
+
"data-sprinkled": isBrowser
|
|
59
|
+
}, /* @__PURE__ */ import_react.default.createElement("h3", {
|
|
60
|
+
className: "AccordionList__title"
|
|
61
|
+
}, isBrowser ? /* @__PURE__ */ import_react.default.createElement("button", {
|
|
62
|
+
type: "button",
|
|
63
|
+
className: "AccordionList__button",
|
|
64
|
+
"aria-controls": domid,
|
|
65
|
+
"aria-expanded": open || void 0,
|
|
66
|
+
onClick: () => {
|
|
67
|
+
setOpen(!open);
|
|
68
|
+
},
|
|
69
|
+
disabled: itemDisabled
|
|
70
|
+
}, title) : title), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
71
|
+
id: isBrowser && domid,
|
|
72
|
+
className: "AccordionList__content",
|
|
73
|
+
hidden: isBrowser && (!open || itemDisabled)
|
|
74
|
+
}, content));
|
|
75
|
+
};
|
|
76
|
+
const AccordionList = (props) => {
|
|
77
|
+
const { items, ssr, wide, defaultOpen, startSeen } = props;
|
|
78
|
+
const [ref] = (0, import_seenEffect.useSeenEffect)(startSeen);
|
|
79
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
80
|
+
className: (0, import_getBemClass.default)("AccordionList", [wide && "wide"]),
|
|
81
|
+
ref
|
|
82
|
+
}, items.map((item, i) => /* @__PURE__ */ import_react.default.createElement(AccordionListItem, __spreadProps(__spreadValues({
|
|
83
|
+
key: i
|
|
84
|
+
}, item), {
|
|
85
|
+
ssr,
|
|
86
|
+
defaultOpen: defaultOpen && defaultOpen.includes(i)
|
|
87
|
+
}))));
|
|
88
|
+
};
|
|
89
|
+
var AccordionList_default = AccordionList;
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import React, { useEffect, useState } from "react";
|
|
21
|
+
import { useDomid, useIsBrowserSide } from "@hugsmidjan/react/hooks";
|
|
22
|
+
import getBemClass from "@hugsmidjan/react/utils/getBemClass";
|
|
23
|
+
import { useSeenEffect } from "./utils/seenEffect";
|
|
24
|
+
const AccordionListItem = (props) => {
|
|
25
|
+
const { title, content, id, disabled = false, defaultOpen, ssr } = props;
|
|
26
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
27
|
+
useEffect(() => setOpen(defaultOpen), [defaultOpen]);
|
|
28
|
+
const domid = useDomid();
|
|
29
|
+
const isBrowser = useIsBrowserSide(ssr);
|
|
30
|
+
const itemDisabled = isBrowser && disabled || !content;
|
|
31
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
32
|
+
className: getBemClass("AccordionList__item", [itemDisabled && "disabled"]),
|
|
33
|
+
id,
|
|
34
|
+
"data-start-open": defaultOpen || void 0,
|
|
35
|
+
"data-sprinkled": isBrowser
|
|
36
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
37
|
+
className: "AccordionList__title"
|
|
38
|
+
}, isBrowser ? /* @__PURE__ */ React.createElement("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
className: "AccordionList__button",
|
|
41
|
+
"aria-controls": domid,
|
|
42
|
+
"aria-expanded": open || void 0,
|
|
43
|
+
onClick: () => {
|
|
44
|
+
setOpen(!open);
|
|
45
|
+
},
|
|
46
|
+
disabled: itemDisabled
|
|
47
|
+
}, title) : title), /* @__PURE__ */ React.createElement("div", {
|
|
48
|
+
id: isBrowser && domid,
|
|
49
|
+
className: "AccordionList__content",
|
|
50
|
+
hidden: isBrowser && (!open || itemDisabled)
|
|
51
|
+
}, content));
|
|
52
|
+
};
|
|
53
|
+
const AccordionList = (props) => {
|
|
54
|
+
const { items, ssr, wide, defaultOpen, startSeen } = props;
|
|
55
|
+
const [ref] = useSeenEffect(startSeen);
|
|
56
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
57
|
+
className: getBemClass("AccordionList", [wide && "wide"]),
|
|
58
|
+
ref
|
|
59
|
+
}, items.map((item, i) => /* @__PURE__ */ React.createElement(AccordionListItem, __spreadProps(__spreadValues({
|
|
60
|
+
key: i
|
|
61
|
+
}, item), {
|
|
62
|
+
ssr,
|
|
63
|
+
defaultOpen: defaultOpen && defaultOpen.includes(i)
|
|
64
|
+
}))));
|
|
65
|
+
};
|
|
66
|
+
var AccordionList_default = AccordionList;
|
|
67
|
+
export {
|
|
68
|
+
AccordionList_default as default
|
|
69
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var ActionCards_exports = {};
|
|
39
|
+
__export(ActionCards_exports, {
|
|
40
|
+
default: () => ActionCards_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(ActionCards_exports);
|
|
43
|
+
var import_react = __toESM(require("react"));
|
|
44
|
+
var import_CardList = require("./_abstract/CardList");
|
|
45
|
+
var import_seenEffect = require("./utils/seenEffect");
|
|
46
|
+
const ActionCards = (props) => {
|
|
47
|
+
const [ref] = (0, import_seenEffect.useSeenEffect)(props.startSeen);
|
|
48
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
49
|
+
className: "ActionCards",
|
|
50
|
+
ref
|
|
51
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_CardList.CardList, __spreadProps(__spreadValues({}, props), {
|
|
52
|
+
bemPrefix: "ActionCards"
|
|
53
|
+
})));
|
|
54
|
+
};
|
|
55
|
+
var ActionCards_default = ActionCards;
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import React from "react";
|
|
21
|
+
import { CardList } from "./_abstract/CardList";
|
|
22
|
+
import { useSeenEffect } from "./utils/seenEffect";
|
|
23
|
+
const ActionCards = (props) => {
|
|
24
|
+
const [ref] = useSeenEffect(props.startSeen);
|
|
25
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
26
|
+
className: "ActionCards",
|
|
27
|
+
ref
|
|
28
|
+
}, /* @__PURE__ */ React.createElement(CardList, __spreadProps(__spreadValues({}, props), {
|
|
29
|
+
bemPrefix: "ActionCards"
|
|
30
|
+
})));
|
|
31
|
+
};
|
|
32
|
+
var ActionCards_default = ActionCards;
|
|
33
|
+
export {
|
|
34
|
+
ActionCards_default as default
|
|
35
|
+
};
|
package/lib/Alert.cjs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var Alert_exports = {};
|
|
39
|
+
__export(Alert_exports, {
|
|
40
|
+
alertTypes: () => alertTypes,
|
|
41
|
+
default: () => Alert_default,
|
|
42
|
+
defaultAlertTexts: () => defaultAlertTexts
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(Alert_exports);
|
|
45
|
+
var import_react = __toESM(require("react"));
|
|
46
|
+
var import_hooks = require("@hugsmidjan/react/hooks");
|
|
47
|
+
var import_getBemClass = __toESM(require("@hugsmidjan/react/utils/getBemClass"));
|
|
48
|
+
var import_i18n = require("@reykjavik/hanna-utils/i18n");
|
|
49
|
+
var import_Button = __toESM(require("./_abstract/Button"));
|
|
50
|
+
var import_env = require("./utils/env");
|
|
51
|
+
const AlertCloseTransitionDuration = 400;
|
|
52
|
+
const useAutoClosing = (autoClose) => {
|
|
53
|
+
const [temp, setTemp] = (0, import_react.useState)(0);
|
|
54
|
+
if (!autoClose) {
|
|
55
|
+
return { autoClosing: false };
|
|
56
|
+
}
|
|
57
|
+
const thaw = () => setTemp((temp2) => temp2 + 1);
|
|
58
|
+
const freeze = () => setTemp((temp2) => temp2 - 1);
|
|
59
|
+
return {
|
|
60
|
+
autoClosing: temp === 0,
|
|
61
|
+
autoClosingProps: __spreadValues({
|
|
62
|
+
onMouseEnter: freeze,
|
|
63
|
+
onMouseLeave: thaw,
|
|
64
|
+
onFocus: freeze,
|
|
65
|
+
onBlur: thaw
|
|
66
|
+
}, import_env.isPreact ? {
|
|
67
|
+
onfocusin: (e) => e.currentTarget !== e.target && freeze(),
|
|
68
|
+
onfocusout: (e) => e.currentTarget !== e.target && thaw()
|
|
69
|
+
} : void 0)
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const defaultAlertTexts = {
|
|
73
|
+
en: { closeLabel: "Hide" },
|
|
74
|
+
is: { closeLabel: "Fela" }
|
|
75
|
+
};
|
|
76
|
+
const alertTypes = {
|
|
77
|
+
info: 1,
|
|
78
|
+
success: 1,
|
|
79
|
+
warning: 1,
|
|
80
|
+
error: 1,
|
|
81
|
+
critical: 1
|
|
82
|
+
};
|
|
83
|
+
const Alert = (props) => {
|
|
84
|
+
const {
|
|
85
|
+
type,
|
|
86
|
+
childrenHTML,
|
|
87
|
+
children,
|
|
88
|
+
onClose,
|
|
89
|
+
closeUrl,
|
|
90
|
+
closable = !!(onClose || closeUrl != null),
|
|
91
|
+
ssr,
|
|
92
|
+
onClosed
|
|
93
|
+
} = props;
|
|
94
|
+
const autoClose = props.autoClose && props.autoClose > 0 ? props.autoClose : 0;
|
|
95
|
+
const closing = (0, import_react.useRef)();
|
|
96
|
+
const [open, setOpen] = (0, import_react.useState)(!!ssr);
|
|
97
|
+
const isBrowser = (0, import_hooks.useIsBrowserSide)(ssr);
|
|
98
|
+
const showCloseButton = closable && (isBrowser || closeUrl != null);
|
|
99
|
+
const { closeLabel, closeLabelLong } = (0, import_i18n.getTexts)(props, defaultAlertTexts);
|
|
100
|
+
(0, import_hooks.useOnMount)(() => {
|
|
101
|
+
setOpen(true);
|
|
102
|
+
});
|
|
103
|
+
const closeAlert = (0, import_react.useCallback)((event) => {
|
|
104
|
+
const ret = onClose && onClose(event);
|
|
105
|
+
if (ret !== false) {
|
|
106
|
+
setOpen(false);
|
|
107
|
+
if (closing.current) {
|
|
108
|
+
clearTimeout(closing.current);
|
|
109
|
+
closing.current = void 0;
|
|
110
|
+
}
|
|
111
|
+
closing.current = setTimeout(() => {
|
|
112
|
+
onClosed && onClosed();
|
|
113
|
+
}, AlertCloseTransitionDuration);
|
|
114
|
+
}
|
|
115
|
+
}, [onClose, onClosed]);
|
|
116
|
+
const { autoClosing, autoClosingProps } = useAutoClosing(autoClose);
|
|
117
|
+
(0, import_react.useEffect)(() => {
|
|
118
|
+
if (autoClosing) {
|
|
119
|
+
let autoCloseTimeout;
|
|
120
|
+
autoCloseTimeout = setTimeout(() => {
|
|
121
|
+
closeAlert();
|
|
122
|
+
}, autoClose * 1e3);
|
|
123
|
+
return () => {
|
|
124
|
+
if (autoCloseTimeout) {
|
|
125
|
+
clearTimeout(autoCloseTimeout);
|
|
126
|
+
autoCloseTimeout = void 0;
|
|
127
|
+
}
|
|
128
|
+
if (closing.current) {
|
|
129
|
+
clearTimeout(closing.current);
|
|
130
|
+
closing.current = void 0;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}, [closeAlert, autoClosing, autoClose]);
|
|
135
|
+
return /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({
|
|
136
|
+
className: (0, import_getBemClass.default)("Alert", [
|
|
137
|
+
!!alertTypes[type] && type,
|
|
138
|
+
closable && "closable"
|
|
139
|
+
]),
|
|
140
|
+
role: "alert",
|
|
141
|
+
hidden: !open || void 0
|
|
142
|
+
}, autoClosingProps), childrenHTML ? /* @__PURE__ */ import_react.default.createElement("div", {
|
|
143
|
+
dangerouslySetInnerHTML: { __html: childrenHTML }
|
|
144
|
+
}) : children, " ", showCloseButton && /* @__PURE__ */ import_react.default.createElement(import_Button.default, __spreadProps(__spreadValues({
|
|
145
|
+
bem: "Alert__close"
|
|
146
|
+
}, closeUrl != null ? { href: closeUrl } : { type: "button" }), {
|
|
147
|
+
onClick: (e) => {
|
|
148
|
+
closeAlert(e);
|
|
149
|
+
},
|
|
150
|
+
"aria-label": closeLabelLong,
|
|
151
|
+
title: closeLabelLong || closeLabel
|
|
152
|
+
}), closeLabel));
|
|
153
|
+
};
|
|
154
|
+
var Alert_default = Alert;
|
|
155
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
+
0 && (module.exports = {
|
|
157
|
+
alertTypes,
|
|
158
|
+
defaultAlertTexts
|
|
159
|
+
});
|
package/lib/Alert.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import React, {
|
|
21
|
+
useCallback,
|
|
22
|
+
useEffect,
|
|
23
|
+
useRef,
|
|
24
|
+
useState
|
|
25
|
+
} from "react";
|
|
26
|
+
import { useIsBrowserSide, useOnMount } from "@hugsmidjan/react/hooks";
|
|
27
|
+
import getBemClass from "@hugsmidjan/react/utils/getBemClass";
|
|
28
|
+
import { getTexts } from "@reykjavik/hanna-utils/i18n";
|
|
29
|
+
import Button from "./_abstract/Button";
|
|
30
|
+
import { isPreact } from "./utils/env";
|
|
31
|
+
const AlertCloseTransitionDuration = 400;
|
|
32
|
+
const useAutoClosing = (autoClose) => {
|
|
33
|
+
const [temp, setTemp] = useState(0);
|
|
34
|
+
if (!autoClose) {
|
|
35
|
+
return { autoClosing: false };
|
|
36
|
+
}
|
|
37
|
+
const thaw = () => setTemp((temp2) => temp2 + 1);
|
|
38
|
+
const freeze = () => setTemp((temp2) => temp2 - 1);
|
|
39
|
+
return {
|
|
40
|
+
autoClosing: temp === 0,
|
|
41
|
+
autoClosingProps: __spreadValues({
|
|
42
|
+
onMouseEnter: freeze,
|
|
43
|
+
onMouseLeave: thaw,
|
|
44
|
+
onFocus: freeze,
|
|
45
|
+
onBlur: thaw
|
|
46
|
+
}, isPreact ? {
|
|
47
|
+
onfocusin: (e) => e.currentTarget !== e.target && freeze(),
|
|
48
|
+
onfocusout: (e) => e.currentTarget !== e.target && thaw()
|
|
49
|
+
} : void 0)
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const defaultAlertTexts = {
|
|
53
|
+
en: { closeLabel: "Hide" },
|
|
54
|
+
is: { closeLabel: "Fela" }
|
|
55
|
+
};
|
|
56
|
+
const alertTypes = {
|
|
57
|
+
info: 1,
|
|
58
|
+
success: 1,
|
|
59
|
+
warning: 1,
|
|
60
|
+
error: 1,
|
|
61
|
+
critical: 1
|
|
62
|
+
};
|
|
63
|
+
const Alert = (props) => {
|
|
64
|
+
const {
|
|
65
|
+
type,
|
|
66
|
+
childrenHTML,
|
|
67
|
+
children,
|
|
68
|
+
onClose,
|
|
69
|
+
closeUrl,
|
|
70
|
+
closable = !!(onClose || closeUrl != null),
|
|
71
|
+
ssr,
|
|
72
|
+
onClosed
|
|
73
|
+
} = props;
|
|
74
|
+
const autoClose = props.autoClose && props.autoClose > 0 ? props.autoClose : 0;
|
|
75
|
+
const closing = useRef();
|
|
76
|
+
const [open, setOpen] = useState(!!ssr);
|
|
77
|
+
const isBrowser = useIsBrowserSide(ssr);
|
|
78
|
+
const showCloseButton = closable && (isBrowser || closeUrl != null);
|
|
79
|
+
const { closeLabel, closeLabelLong } = getTexts(props, defaultAlertTexts);
|
|
80
|
+
useOnMount(() => {
|
|
81
|
+
setOpen(true);
|
|
82
|
+
});
|
|
83
|
+
const closeAlert = useCallback((event) => {
|
|
84
|
+
const ret = onClose && onClose(event);
|
|
85
|
+
if (ret !== false) {
|
|
86
|
+
setOpen(false);
|
|
87
|
+
if (closing.current) {
|
|
88
|
+
clearTimeout(closing.current);
|
|
89
|
+
closing.current = void 0;
|
|
90
|
+
}
|
|
91
|
+
closing.current = setTimeout(() => {
|
|
92
|
+
onClosed && onClosed();
|
|
93
|
+
}, AlertCloseTransitionDuration);
|
|
94
|
+
}
|
|
95
|
+
}, [onClose, onClosed]);
|
|
96
|
+
const { autoClosing, autoClosingProps } = useAutoClosing(autoClose);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (autoClosing) {
|
|
99
|
+
let autoCloseTimeout;
|
|
100
|
+
autoCloseTimeout = setTimeout(() => {
|
|
101
|
+
closeAlert();
|
|
102
|
+
}, autoClose * 1e3);
|
|
103
|
+
return () => {
|
|
104
|
+
if (autoCloseTimeout) {
|
|
105
|
+
clearTimeout(autoCloseTimeout);
|
|
106
|
+
autoCloseTimeout = void 0;
|
|
107
|
+
}
|
|
108
|
+
if (closing.current) {
|
|
109
|
+
clearTimeout(closing.current);
|
|
110
|
+
closing.current = void 0;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}, [closeAlert, autoClosing, autoClose]);
|
|
115
|
+
return /* @__PURE__ */ React.createElement("div", __spreadValues({
|
|
116
|
+
className: getBemClass("Alert", [
|
|
117
|
+
!!alertTypes[type] && type,
|
|
118
|
+
closable && "closable"
|
|
119
|
+
]),
|
|
120
|
+
role: "alert",
|
|
121
|
+
hidden: !open || void 0
|
|
122
|
+
}, autoClosingProps), childrenHTML ? /* @__PURE__ */ React.createElement("div", {
|
|
123
|
+
dangerouslySetInnerHTML: { __html: childrenHTML }
|
|
124
|
+
}) : children, " ", showCloseButton && /* @__PURE__ */ React.createElement(Button, __spreadProps(__spreadValues({
|
|
125
|
+
bem: "Alert__close"
|
|
126
|
+
}, closeUrl != null ? { href: closeUrl } : { type: "button" }), {
|
|
127
|
+
onClick: (e) => {
|
|
128
|
+
closeAlert(e);
|
|
129
|
+
},
|
|
130
|
+
"aria-label": closeLabelLong,
|
|
131
|
+
title: closeLabelLong || closeLabel
|
|
132
|
+
}), closeLabel));
|
|
133
|
+
};
|
|
134
|
+
var Alert_default = Alert;
|
|
135
|
+
export {
|
|
136
|
+
alertTypes,
|
|
137
|
+
Alert_default as default,
|
|
138
|
+
defaultAlertTexts
|
|
139
|
+
};
|