@reykjavik/hanna-react 0.10.84 → 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 +7 -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 +389 -3
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Autosuggest, { RenderSuggestion } from 'react-autosuggest';
|
|
3
|
+
import { BemProps } from '@hugsmidjan/react/types';
|
|
4
|
+
import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
|
|
5
|
+
export type SiteSearchACI18n = {
|
|
6
|
+
lang?: string;
|
|
7
|
+
/** Label for the autocomplete's combobox container div */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Label for the text input */
|
|
10
|
+
inputLabel: string;
|
|
11
|
+
/** Placeholder text for the text input */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Label for the suggestions item list container */
|
|
14
|
+
suggestionsLabel: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const defaultSiteSearchACTexts: DefaultTexts<SiteSearchACI18n>;
|
|
17
|
+
export type SiteSearchAutocompleteProps<T> = {
|
|
18
|
+
suggestions: Array<T>;
|
|
19
|
+
renderSuggestion?: RenderSuggestion<T>;
|
|
20
|
+
setSuggestions: (suggestions: Array<T>) => void;
|
|
21
|
+
getSuggestionValue: (suggestion: T) => string;
|
|
22
|
+
onSuggestionsFetchRequested: (request: Autosuggest.SuggestionsFetchRequestedParams) => void;
|
|
23
|
+
onSuggestionSelected?: (event: React.FormEvent<HTMLElement>, data: Autosuggest.SuggestionSelectedEventData<T>) => void;
|
|
24
|
+
onSuggestionHighlighted?: (params: {
|
|
25
|
+
suggestion: T;
|
|
26
|
+
}) => void;
|
|
27
|
+
/** Triggered when user hits ENTER key with the focus inside the input field */
|
|
28
|
+
onSubmit?: (value: string) => void;
|
|
29
|
+
/** Custom action to perform when the user clicks the search button
|
|
30
|
+
*
|
|
31
|
+
* Defaults to `onSubmit`
|
|
32
|
+
*/
|
|
33
|
+
onButtonClick?: (value: string) => void;
|
|
34
|
+
lang?: string;
|
|
35
|
+
texts?: SiteSearchACI18n;
|
|
36
|
+
/** @deprecated Use `text` prop instead (will be removed in v0.11) */
|
|
37
|
+
label?: string;
|
|
38
|
+
} & BemProps;
|
|
39
|
+
export declare const SiteSearchAutocomplete: <T>(props: SiteSearchAutocompleteProps<T>) => JSX.Element;
|
|
40
|
+
export default SiteSearchAutocomplete;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { createRef, useState } from 'react';
|
|
3
|
+
import Autosuggest from 'react-autosuggest';
|
|
4
|
+
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
5
|
+
import SiteSearchInput from './SiteSearchInput.js';
|
|
6
|
+
export const defaultSiteSearchACTexts = {
|
|
7
|
+
is: {
|
|
8
|
+
lang: 'is',
|
|
9
|
+
label: 'Leit á vefnum',
|
|
10
|
+
inputLabel: 'Leitarorð',
|
|
11
|
+
placeholder: 'Sláðu inn leitarorð',
|
|
12
|
+
suggestionsLabel: 'Tillögur',
|
|
13
|
+
},
|
|
14
|
+
en: {
|
|
15
|
+
lang: 'en',
|
|
16
|
+
label: 'Site search',
|
|
17
|
+
inputLabel: 'Search terms',
|
|
18
|
+
placeholder: 'Enter search terms',
|
|
19
|
+
suggestionsLabel: 'Suggestions',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const SiteSearchAutocomplete = (props) => {
|
|
23
|
+
const { suggestions, setSuggestions, renderSuggestion, getSuggestionValue, onSuggestionsFetchRequested, onSuggestionSelected, onSuggestionHighlighted, onSubmit, onButtonClick = onSubmit, bem = 'SiteSearchAutocomplete', } = props;
|
|
24
|
+
const [value, setValue] = useState('');
|
|
25
|
+
const inputRef = createRef();
|
|
26
|
+
const txt = getTexts(props, defaultSiteSearchACTexts);
|
|
27
|
+
return (React.createElement(Autosuggest, { theme: {
|
|
28
|
+
container: bem,
|
|
29
|
+
containerOpen: bem + '--open',
|
|
30
|
+
suggestionsContainer: bem + '__container',
|
|
31
|
+
suggestionsContainerOpen: bem + '__container--open',
|
|
32
|
+
suggestionsList: bem + '__list',
|
|
33
|
+
suggestion: bem + '__item',
|
|
34
|
+
suggestionHighlighted: bem + '__item--highlighted',
|
|
35
|
+
}, focusInputOnSuggestionClick: true, suggestions: suggestions, onSuggestionsClearRequested: () => setSuggestions([]), onSuggestionsFetchRequested: onSuggestionsFetchRequested, getSuggestionValue: getSuggestionValue, onSuggestionSelected: onSuggestionSelected, onSuggestionHighlighted: onSuggestionHighlighted, renderSuggestion: renderSuggestion || ((s) => String(s)), containerProps: { 'aria-label': txt.label }, renderSuggestionsContainer: ({ containerProps, children }) => (React.createElement("div", Object.assign({}, containerProps, { "aria-label": suggestions.length ? txt.suggestionsLabel : undefined }), children)), inputProps: {
|
|
36
|
+
ref: inputRef,
|
|
37
|
+
value: value,
|
|
38
|
+
onChange: (_, { newValue }) => {
|
|
39
|
+
setValue(newValue);
|
|
40
|
+
},
|
|
41
|
+
}, renderInputComponent: (inputProps) => {
|
|
42
|
+
/* prettier-ignore */
|
|
43
|
+
const { className, type, disabled, readOnly, required, children } = inputProps, //eslint-disable-line @typescript-eslint/no-unused-vars
|
|
44
|
+
siteSearchProps = __rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children"]);
|
|
45
|
+
return (React.createElement(SiteSearchInput, Object.assign({}, siteSearchProps, { label: props.label || txt.inputLabel, placeholder: txt.placeholder, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
46
|
+
} }));
|
|
47
|
+
};
|
|
48
|
+
export default SiteSearchAutocomplete;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useLaggedState } from '@hugsmidjan/react/hooks';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
import { isPreact } from './utils/env.js';
|
|
5
|
+
export const SiteSearchCurtain = (props) => {
|
|
6
|
+
const [focused, setFocused] = useLaggedState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const closeSearch = (e) => {
|
|
9
|
+
if (e.key === 'Escape') {
|
|
10
|
+
setFocused(false);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
document.addEventListener('keyup', closeSearch);
|
|
14
|
+
return () => document.removeEventListener('keyup', closeSearch);
|
|
15
|
+
},
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
[]);
|
|
18
|
+
const focusHandler = () => {
|
|
19
|
+
setFocused(true);
|
|
20
|
+
};
|
|
21
|
+
const blurHandler = (e) => {
|
|
22
|
+
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
23
|
+
setFocused(false, 100);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement("div", Object.assign({ className: getBemClass('SiteSearchCurtain', [focused && 'focused']), onFocus: focusHandler, onBlur: blurHandler }, (isPreact && { onfocusin: focusHandler, onfocusout: blurHandler })), props.children));
|
|
27
|
+
};
|
|
28
|
+
export default SiteSearchCurtain;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormFieldWrappingProps } from './FormField.js';
|
|
3
|
+
import { SSRSupport } from './utils.js';
|
|
4
|
+
type InputElmProps = Omit<JSX.IntrinsicElements['input'], 'className' | 'type' | 'disabled' | 'readOnly' | 'required' | 'onSubmit'>;
|
|
5
|
+
type WrappingProps = Pick<FormFieldWrappingProps, 'id' | 'label'>;
|
|
6
|
+
export type SiteSearchInputProps = {
|
|
7
|
+
/** Triggered when user hits ENTER key with the focus inside the input field
|
|
8
|
+
*
|
|
9
|
+
* Return `true` to **allow** the browser's default submit hehavior
|
|
10
|
+
*/
|
|
11
|
+
onSubmit?: () => boolean | void;
|
|
12
|
+
/** Custom action to perform when the user clicks the search button
|
|
13
|
+
*
|
|
14
|
+
* Return `true` to **allow** the browser's default submit hehavior
|
|
15
|
+
*
|
|
16
|
+
* Defaults to `onSearch`
|
|
17
|
+
*/
|
|
18
|
+
onButtonClick?: () => boolean | void;
|
|
19
|
+
buttonText?: string;
|
|
20
|
+
children?: never;
|
|
21
|
+
ssr?: SSRSupport;
|
|
22
|
+
} & WrappingProps & InputElmProps;
|
|
23
|
+
export declare const SiteSearchInput: React.ForwardRefExoticComponent<Pick<SiteSearchInputProps, "form" | "label" | "slot" | "style" | "title" | "key" | "list" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "step" | "value" | "pattern" | "ssr" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "size" | "src" | "multiple" | "alt" | "width" | "accept" | "autoComplete" | "capture" | "checked" | "crossOrigin" | "enterKeyHint" | "height" | "max" | "maxLength" | "min" | "minLength" | "onButtonClick" | "buttonText"> & React.RefAttributes<HTMLInputElement>>;
|
|
24
|
+
export default SiteSearchInput;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import FormField from './FormField.js';
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export const SiteSearchInput = React.forwardRef((props, ref) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const { label, id, onChange, placeholder = typeof label === 'string' ? label : undefined, buttonText = 'Leita', onSubmit, onButtonClick = onSubmit, onKeyDown, ssr } = props, inputElementProps = __rest(props, ["label", "id", "onChange", "placeholder", "buttonText", "onSubmit", "onButtonClick", "onKeyDown", "ssr"]);
|
|
8
|
+
const { value, defaultValue } = inputElementProps;
|
|
9
|
+
const [hasValue, setHasValue] = useState(undefined);
|
|
10
|
+
const filled = !!((_a = value !== null && value !== void 0 ? value : hasValue) !== null && _a !== void 0 ? _a : !!defaultValue);
|
|
11
|
+
const empty = !filled && !placeholder;
|
|
12
|
+
const _onChange = value != null
|
|
13
|
+
? onChange
|
|
14
|
+
: (e) => {
|
|
15
|
+
setHasValue(!!e.target.value);
|
|
16
|
+
onChange && onChange(e);
|
|
17
|
+
};
|
|
18
|
+
return (React.createElement(FormField, { className: "SiteSearchInput", ssr: ssr, label: label, empty: empty, filled: filled, id: id, renderInput: (className, inputProps, addFocusProps) => (React.createElement("div", Object.assign({ className: className.input }, addFocusProps()),
|
|
19
|
+
React.createElement("input", Object.assign({ className: "SiteSearchInput__input", onChange: _onChange }, inputProps, { placeholder: placeholder, onKeyDown: onSubmit
|
|
20
|
+
? (e) => {
|
|
21
|
+
if (e.key === 'Enter' && onSubmit() !== true) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
}
|
|
24
|
+
onKeyDown && onKeyDown(e);
|
|
25
|
+
}
|
|
26
|
+
: onKeyDown }, inputElementProps, { ref: ref })),
|
|
27
|
+
' ',
|
|
28
|
+
React.createElement("button", { className: "SiteSearchInput__button", type: "submit", onClick: onButtonClick && ((e) => !onButtonClick() && e.preventDefault()), title: buttonText }, buttonText))) }));
|
|
29
|
+
});
|
|
30
|
+
export default SiteSearchInput;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
export type SkeletonProps = {
|
|
3
|
+
text?: boolean;
|
|
4
|
+
height?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
|
|
5
|
+
items?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
|
|
6
|
+
gap?: 1 | 2 | 3 | 4 | 5;
|
|
7
|
+
};
|
|
8
|
+
export declare const Skeleton: {
|
|
9
|
+
(props: SkeletonProps): JSX.Element;
|
|
10
|
+
/** Returns a single `<Skeleton height={X}/>` element of branded type `SkeletonBlock` */
|
|
11
|
+
block(height?: SkeletonProps['height']): SkeletonBlock;
|
|
12
|
+
/** Returns a single `<Skeleton text height={X}/>` element of branded type `SkeletonText` */
|
|
13
|
+
text(height?: SkeletonProps['height']): SkeletonText;
|
|
14
|
+
};
|
|
15
|
+
export default Skeleton;
|
|
16
|
+
declare const _SkeletonBlock__Brand: unique symbol;
|
|
17
|
+
/** The `<Skeleton height={X}/>` element returned by `Skeleton.block(X)` */
|
|
18
|
+
export type SkeletonBlock = ReactElement & {
|
|
19
|
+
[_SkeletonBlock__Brand]: true;
|
|
20
|
+
};
|
|
21
|
+
declare const _SkeletonText__Brand: unique symbol;
|
|
22
|
+
/** The `<Skeleton text height={X}/>` element returned by `Skeleton.text(X)` */
|
|
23
|
+
export type SkeletonText = ReactElement & {
|
|
24
|
+
[_SkeletonText__Brand]: true;
|
|
25
|
+
};
|
package/esm/Skeleton.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import range from '@hugsmidjan/qj/range';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
const makeRenderSkeleton = (props) => (key) => (React.createElement("span", { key: key, className: getBemClass('Skeleton', [
|
|
5
|
+
props.text && 'text',
|
|
6
|
+
props.height && 'height--' + props.height,
|
|
7
|
+
props.gap && 'gap--' + props.gap,
|
|
8
|
+
]) }));
|
|
9
|
+
const minmax = (num = 0, max = 100, min = 1) => {
|
|
10
|
+
num = Math.min(Math.max(Math.round(num), min), max);
|
|
11
|
+
return num > min ? num : undefined;
|
|
12
|
+
};
|
|
13
|
+
export const Skeleton = (props) => {
|
|
14
|
+
const height = minmax(props.height, 40);
|
|
15
|
+
const renderSkeleton = makeRenderSkeleton({
|
|
16
|
+
height,
|
|
17
|
+
text: props.text,
|
|
18
|
+
gap: minmax(props.gap, 5, 0),
|
|
19
|
+
});
|
|
20
|
+
const items = minmax(props.items, 20) || 1;
|
|
21
|
+
if (items > 1) {
|
|
22
|
+
return React.createElement(React.Fragment, null, range(1, items).map(renderSkeleton));
|
|
23
|
+
}
|
|
24
|
+
return renderSkeleton();
|
|
25
|
+
};
|
|
26
|
+
export default Skeleton;
|
|
27
|
+
/** Returns a single `<Skeleton height={X}/>` element of branded type `SkeletonBlock` */
|
|
28
|
+
Skeleton.block = (height) => (React.createElement(Skeleton, { height: height }));
|
|
29
|
+
/** Returns a single `<Skeleton text height={X}/>` element of branded type `SkeletonText` */
|
|
30
|
+
Skeleton.text = (height) => (React.createElement(Skeleton, { text: true, height: height }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SeenProp } from './utils/seenEffect.js';
|
|
3
|
+
import { ComponentLayoutProps } from './constants.js';
|
|
4
|
+
export type SubHeadingProps = {
|
|
5
|
+
Tag?: 'h2' | 'h3';
|
|
6
|
+
small?: boolean;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
} & ComponentLayoutProps & SeenProp;
|
|
9
|
+
export declare const SubHeading: (props: SubHeadingProps) => JSX.Element;
|
|
10
|
+
export default SubHeading;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
import { useSeenEffect } from './utils/seenEffect.js';
|
|
4
|
+
export const SubHeading = (props) => {
|
|
5
|
+
const { small, Tag = 'h2', children, align, wide, startSeen } = props;
|
|
6
|
+
const [ref] = useSeenEffect(startSeen);
|
|
7
|
+
return (React.createElement(Tag, { className: getBemClass('SubHeading', [
|
|
8
|
+
small && 'small',
|
|
9
|
+
align === 'right' && 'align--' + align,
|
|
10
|
+
!align && wide && 'wide',
|
|
11
|
+
]), ref: ref }, children));
|
|
12
|
+
};
|
|
13
|
+
export default SubHeading;
|
package/esm/Tabs.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SeenProp } from './utils/seenEffect.js';
|
|
2
|
+
import { SSRSupport } from './utils.js';
|
|
3
|
+
export type TabItemProps = {
|
|
4
|
+
label: string;
|
|
5
|
+
badge?: string | number;
|
|
6
|
+
longLabel?: string;
|
|
7
|
+
type?: 'button' | 'submit';
|
|
8
|
+
id?: string;
|
|
9
|
+
href?: string;
|
|
10
|
+
'aria-controls'?: string;
|
|
11
|
+
onActivated?: () => void | false;
|
|
12
|
+
};
|
|
13
|
+
/** @deprecated Use `TabItemProps` instead (Will be removed in v0.11) */
|
|
14
|
+
export type TabProps = TabItemProps;
|
|
15
|
+
type BaseTabsProps<T extends TabItemProps = TabItemProps> = {
|
|
16
|
+
id?: string;
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
'aria-labelledby'?: string;
|
|
19
|
+
tabs: Array<T>;
|
|
20
|
+
activeIdx?: number;
|
|
21
|
+
onSetActive?: (idx: number, tab: T) => void;
|
|
22
|
+
role?: 'tablist' | 'toc';
|
|
23
|
+
'aria-controls'?: string;
|
|
24
|
+
activateOnFocus?: boolean;
|
|
25
|
+
ssr?: SSRSupport;
|
|
26
|
+
};
|
|
27
|
+
export type TabsProps<T extends TabItemProps = TabItemProps> = BaseTabsProps<T> & {
|
|
28
|
+
vertical?: boolean;
|
|
29
|
+
/** Optional <Tabs/> block connected to the currently active tab */
|
|
30
|
+
subTabs?: BaseTabsProps;
|
|
31
|
+
} & SeenProp;
|
|
32
|
+
/** @deprecated Use `TabsProps` instead (Will be removed in v0.11) */
|
|
33
|
+
export type TablistProps<T extends TabItemProps = TabItemProps> = TabsProps<T>;
|
|
34
|
+
export declare const Tabs: (props: TabsProps) => JSX.Element;
|
|
35
|
+
export default Tabs;
|
package/esm/Tabs.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { getFrag } from '@hugsmidjan/qj/frag';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
import { useSeenEffect } from './utils/seenEffect.js';
|
|
5
|
+
import { useIsBrowserSide } from './utils.js';
|
|
6
|
+
const navKeyEffects = {
|
|
7
|
+
ArrowUp: -1,
|
|
8
|
+
ArrowLeft: -1,
|
|
9
|
+
ArrowDown: 1,
|
|
10
|
+
ArrowRight: 1,
|
|
11
|
+
};
|
|
12
|
+
// eslint-disable-next-line complexity
|
|
13
|
+
const renderTab = (tabProps, index, listProps) => {
|
|
14
|
+
const { label, badge, href, type, longLabel } = tabProps;
|
|
15
|
+
const { activeIdx, activateTab, focusedIdx, setFocusedIdx, tabRole, listAriaControls, isBrowser, } = listProps;
|
|
16
|
+
const handleClick = isBrowser &&
|
|
17
|
+
((e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
activateTab(index);
|
|
20
|
+
e.currentTarget.focus();
|
|
21
|
+
});
|
|
22
|
+
const handleFocus = isBrowser && (() => setFocusedIdx(index));
|
|
23
|
+
const isActive = activeIdx === index || undefined;
|
|
24
|
+
const Tag = href && !tabRole ? 'a' : 'button';
|
|
25
|
+
const tagProps = Tag === 'button'
|
|
26
|
+
? {
|
|
27
|
+
role: tabRole,
|
|
28
|
+
type: type || 'button',
|
|
29
|
+
// 'aria-selected': tabRole && isActive,
|
|
30
|
+
tabIndex: tabRole ? (focusedIdx === index ? 0 : -1) : undefined,
|
|
31
|
+
'aria-controls': tabProps['aria-controls'] || (tabRole && getFrag(href)) || listAriaControls,
|
|
32
|
+
}
|
|
33
|
+
: { href };
|
|
34
|
+
return [
|
|
35
|
+
React.createElement(Tag, Object.assign({ key: index, className: "Tabs__tab", "data-active": isActive }, tagProps, { onClick: handleClick, onFocus: handleFocus, "aria-label": longLabel, title: longLabel }),
|
|
36
|
+
label,
|
|
37
|
+
" ",
|
|
38
|
+
badge != null && React.createElement("small", { className: "Tabs__tab__badge" },
|
|
39
|
+
"(",
|
|
40
|
+
badge,
|
|
41
|
+
")")),
|
|
42
|
+
' ',
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
// NOTE: This isBrowser tablist behavior is based on
|
|
46
|
+
// https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-2/tabs.html
|
|
47
|
+
export const Tabs = (props) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const { tabs, role, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-controls': listAriaControls, id, activeIdx, onSetActive, activateOnFocus, ssr, startSeen, vertical, subTabs, } = props;
|
|
50
|
+
const isBrowser = useIsBrowserSide(ssr);
|
|
51
|
+
const [focusedIdx, setFocusedIdx] = useState(activeIdx || 0);
|
|
52
|
+
const tabRole = isBrowser && role === 'tablist' ? 'tab' : undefined;
|
|
53
|
+
const activateTab = (index) => {
|
|
54
|
+
const tab = tabs[index];
|
|
55
|
+
if (index === activeIdx || !tab) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const ret = tab.onActivated && tab.onActivated.call(null);
|
|
59
|
+
if (onSetActive && ret !== false) {
|
|
60
|
+
onSetActive(index, tab);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const handleKeydown = tabRole &&
|
|
64
|
+
((e) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const delta = navKeyEffects[e.key];
|
|
67
|
+
if (delta) {
|
|
68
|
+
// prevent scolling +
|
|
69
|
+
// prevent bubbling to parent Tabs container
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
let nextIdx = (focusedIdx || 0) + delta;
|
|
72
|
+
const maxIdx = tabs.length - 1;
|
|
73
|
+
nextIdx = nextIdx < 0 ? maxIdx : nextIdx > maxIdx ? 0 : nextIdx;
|
|
74
|
+
(_a = e.currentTarget.querySelectorAll('.Tabs__tab')[nextIdx]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
75
|
+
activateOnFocus && activateTab(nextIdx);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const [ref] = useSeenEffect(startSeen);
|
|
79
|
+
const listProps = {
|
|
80
|
+
activeIdx,
|
|
81
|
+
activateTab,
|
|
82
|
+
focusedIdx,
|
|
83
|
+
setFocusedIdx,
|
|
84
|
+
tabRole,
|
|
85
|
+
listAriaControls,
|
|
86
|
+
isBrowser,
|
|
87
|
+
};
|
|
88
|
+
return (React.createElement("div", { className: getBemClass('Tabs', vertical && 'vertical'), role: tabRole && role, id: id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onKeyDown: handleKeydown, "data-sprinkled": isBrowser, ref: ref },
|
|
89
|
+
tabs.map((tabProps, index) => renderTab(tabProps, index, listProps)),
|
|
90
|
+
subTabs && (React.createElement(Tabs, Object.assign({}, subTabs, { role: 'role' in subTabs ? subTabs.role : role, activateOnFocus: (_a = subTabs.activateOnFocus) !== null && _a !== void 0 ? _a : activateOnFocus, ssr: (_b = subTabs.ssr) !== null && _b !== void 0 ? _b : ssr, startSeen: true,
|
|
91
|
+
// just to be sure
|
|
92
|
+
vertical: undefined, subTabs: undefined })))));
|
|
93
|
+
};
|
|
94
|
+
export default Tabs;
|
package/esm/TagPill.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
|
+
import { ButtonProps } from './_abstract/_Button.js';
|
|
4
|
+
declare const colors: {
|
|
5
|
+
readonly normal: "";
|
|
6
|
+
readonly green: "color--green";
|
|
7
|
+
readonly yellow: "color--yellow";
|
|
8
|
+
readonly orange: "color--orange";
|
|
9
|
+
readonly red: "color--red";
|
|
10
|
+
};
|
|
11
|
+
export type TagPillColor = keyof typeof colors;
|
|
12
|
+
export type TagPillProps = ButtonProps & {
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
large?: boolean;
|
|
15
|
+
color?: TagPillColor;
|
|
16
|
+
} & EitherObj<{
|
|
17
|
+
removable?: false;
|
|
18
|
+
}, {
|
|
19
|
+
removable: true;
|
|
20
|
+
onRemove?: () => void;
|
|
21
|
+
removeLabel?: string;
|
|
22
|
+
removeLabelLong?: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const TagPill: (props: TagPillProps) => JSX.Element;
|
|
25
|
+
export default TagPill;
|
package/esm/TagPill.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
import { Button } from './_abstract/_Button.js';
|
|
5
|
+
const colors = {
|
|
6
|
+
normal: '',
|
|
7
|
+
green: 'color--green',
|
|
8
|
+
yellow: 'color--yellow',
|
|
9
|
+
orange: 'color--orange',
|
|
10
|
+
red: 'color--red',
|
|
11
|
+
};
|
|
12
|
+
export const TagPill = (props) => {
|
|
13
|
+
const { modifier, large, removable, onRemove, children, color = 'normal', label = children, removeLabel = 'x', removeLabelLong = removeLabel } = props, buttonProps = __rest(props, ["modifier", "large", "removable", "onRemove", "children", "color", "label", "removeLabel", "removeLabelLong"]);
|
|
14
|
+
const isStatic = !('href' in props || 'type' in props || props.onClick);
|
|
15
|
+
process.env.NODE_ENV !== 'production' &&
|
|
16
|
+
removable &&
|
|
17
|
+
isStatic &&
|
|
18
|
+
!onRemove &&
|
|
19
|
+
console.warn('Removable static (non-button) `TagPill`s ' +
|
|
20
|
+
'must have an `onRemove` handler defined');
|
|
21
|
+
const modifiers = [modifier, large && 'large', colors[color]];
|
|
22
|
+
const removeBtn = removable && (React.createElement("button", { className: "TagPill__remove", onClick: onRemove && (() => onRemove()), "aria-label": removeLabelLong, type: "button" }, removeLabel));
|
|
23
|
+
return isStatic ? (React.createElement("span", Object.assign({ className: getBemClass('TagPill', modifiers) }, buttonProps),
|
|
24
|
+
label,
|
|
25
|
+
" ",
|
|
26
|
+
removeBtn)) : onRemove ? (React.createElement("span", { className: getBemClass('TagPill', modifiers) },
|
|
27
|
+
React.createElement(Button, Object.assign({ bem: "TagPill__button" }, buttonProps), label),
|
|
28
|
+
' ',
|
|
29
|
+
removeBtn)) : (React.createElement(Button, Object.assign({ bem: "TagPill" }, buttonProps, { modifier: modifiers }),
|
|
30
|
+
label,
|
|
31
|
+
' ',
|
|
32
|
+
removable && (React.createElement("span", { className: "TagPill__remove", "aria-label": removeLabelLong }, removeLabel))));
|
|
33
|
+
};
|
|
34
|
+
export default TagPill;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SeenProp } from './utils/seenEffect.js';
|
|
3
|
+
import { ComponentLayoutProps } from './constants.js';
|
|
4
|
+
export type TextBlockProps = ComponentLayoutProps & {
|
|
5
|
+
/** Make H2 headings float to the left
|
|
6
|
+
*
|
|
7
|
+
* Overrides the `align` and `wide` prop and automatically sets `align` to `right`
|
|
8
|
+
*/
|
|
9
|
+
labelled?: boolean;
|
|
10
|
+
/** Sets a smaller text-size */
|
|
11
|
+
small?: boolean;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
} & SeenProp;
|
|
14
|
+
export declare const TextBlock: (props: TextBlockProps) => JSX.Element;
|
|
15
|
+
export default TextBlock;
|
package/esm/TextBlock.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
import { useSeenEffect } from './utils/seenEffect.js';
|
|
4
|
+
export const TextBlock = (props) => {
|
|
5
|
+
const { children, align, labelled, wide, small, startSeen } = props;
|
|
6
|
+
const rightAligned = align === 'right' || labelled;
|
|
7
|
+
const [ref] = useSeenEffect(startSeen);
|
|
8
|
+
return (React.createElement("div", { className: getBemClass('TextBlock', [
|
|
9
|
+
labelled && 'labelled',
|
|
10
|
+
rightAligned && 'align--right',
|
|
11
|
+
wide && !rightAligned && 'wide',
|
|
12
|
+
small && !labelled && 'small',
|
|
13
|
+
]), ref: ref }, children));
|
|
14
|
+
};
|
|
15
|
+
export default TextBlock;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps } from './_abstract/_Button.js';
|
|
3
|
+
export type TextButtonProps = ButtonProps & {
|
|
4
|
+
disabled?: never;
|
|
5
|
+
};
|
|
6
|
+
export declare const TextButton: (props: TextButtonProps & {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}) => JSX.Element;
|
|
9
|
+
export default TextButton;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from './_abstract/_Button.js';
|
|
3
|
+
export const TextButton = (props) => {
|
|
4
|
+
if ('disabled' in props) {
|
|
5
|
+
props = Object.assign(Object.assign({}, props), { disabled: undefined });
|
|
6
|
+
}
|
|
7
|
+
return React.createElement(Button, Object.assign({ bem: "TextButton" }, props));
|
|
8
|
+
};
|
|
9
|
+
export default TextButton;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { FormFieldWrappingProps } from './FormField.js';
|
|
3
|
+
type InputElmProps = JSX.IntrinsicElements['input'];
|
|
4
|
+
type TextareaElmProps = JSX.IntrinsicElements['textarea'];
|
|
5
|
+
export type TextInputProps = {
|
|
6
|
+
small?: boolean;
|
|
7
|
+
children?: never;
|
|
8
|
+
} & FormFieldWrappingProps & (({
|
|
9
|
+
type?: 'text' | 'email' | 'tel' | 'number' | 'date' | 'url' | 'password' | 'search';
|
|
10
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
11
|
+
} & InputElmProps) | ({
|
|
12
|
+
type: 'textarea';
|
|
13
|
+
inputRef?: RefObject<HTMLTextAreaElement>;
|
|
14
|
+
} & TextareaElmProps));
|
|
15
|
+
export declare const TextInput: (props: TextInputProps) => JSX.Element;
|
|
16
|
+
export default TextInput;
|
package/esm/TextInput.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
import FormField from './FormField.js';
|
|
5
|
+
export const TextInput = (props) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const _inputRef = useRef(null);
|
|
8
|
+
const { className, label, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, onChange, small, type, ssr, inputRef = _inputRef } = props, inputElementProps = __rest(props, ["className", "label", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "onChange", "small", "type", "ssr", "inputRef"]);
|
|
9
|
+
const { value, defaultValue, placeholder } = inputElementProps;
|
|
10
|
+
const [hasValue, setHasValue] = useState(undefined);
|
|
11
|
+
const filled = !!((_a = value !== null && value !== void 0 ? value : hasValue) !== null && _a !== void 0 ? _a : !!defaultValue);
|
|
12
|
+
const empty = !filled && !placeholder;
|
|
13
|
+
const multiline = type === 'textarea';
|
|
14
|
+
const modifiers = [multiline && 'multiline'];
|
|
15
|
+
const _onChange = value != null
|
|
16
|
+
? onChange
|
|
17
|
+
: (e) => {
|
|
18
|
+
setHasValue(!!e.target.value);
|
|
19
|
+
onChange &&
|
|
20
|
+
onChange(
|
|
21
|
+
// TypeScript is silly sometimes.
|
|
22
|
+
e);
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
var _a;
|
|
26
|
+
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) {
|
|
27
|
+
setHasValue(true);
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
return (React.createElement(FormField, { className: getBemClass('TextInput', modifiers, className), ssr: ssr, small: small, label: label, empty: empty, filled: filled, assistText: assistText, hideLabel: hideLabel, disabled: disabled, readOnly: readOnly, invalid: invalid, errorMessage: errorMessage, required: required, reqText: reqText, id: id, renderInput: (className, inputProps, addFocusProps) => multiline ? (React.createElement("textarea", Object.assign({ className: className.input, onChange: _onChange }, inputProps, addFocusProps(inputElementProps), { ref: inputRef }))) : (React.createElement("input", Object.assign({ className: className.input, onChange: _onChange, type: type }, inputProps, addFocusProps(inputElementProps), { ref: inputRef }))) }));
|
|
31
|
+
};
|
|
32
|
+
export default TextInput;
|