@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,48 @@
|
|
|
1
|
+
import { FileListProps } from './FileInput/_FileInputFileList.js';
|
|
2
|
+
import { FormFieldWrappingProps } from './FormField.js';
|
|
3
|
+
export type FileInputProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Flags if the input should accept multiple, or just a single file at a time.
|
|
6
|
+
*
|
|
7
|
+
* Default: `true`
|
|
8
|
+
*/
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Accepted file mime type(s).
|
|
12
|
+
*
|
|
13
|
+
* Default: no restrictions.
|
|
14
|
+
*/
|
|
15
|
+
accept?: string | Array<string>;
|
|
16
|
+
dropzoneText: string | JSX.Element;
|
|
17
|
+
removeFileText?: string;
|
|
18
|
+
lang?: string;
|
|
19
|
+
showFileSize?: boolean;
|
|
20
|
+
showImagePreviews?: boolean;
|
|
21
|
+
FileList?: false | ((props: FileListProps) => JSX.Element | null);
|
|
22
|
+
onFilesUpdated?: (
|
|
23
|
+
/** Updated, full list of Files. */
|
|
24
|
+
files: Array<File>,
|
|
25
|
+
/** Information about which Files were added or removed during with this update.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: When a diff contains both added and deleted files, this indicates a
|
|
28
|
+
* name-conflict occurred — i.e. one of the added files has a name that
|
|
29
|
+
* existed in the old file list.
|
|
30
|
+
* In such cases the deletion is more implicit than explicit, and depending
|
|
31
|
+
* on the circumstances, you MIGHT wish to either warn the user, rename
|
|
32
|
+
* one of the files, instead of overwriting/deleting the older file, etc.
|
|
33
|
+
*/
|
|
34
|
+
diff: {
|
|
35
|
+
deleted?: Array<File>;
|
|
36
|
+
added?: Array<File>;
|
|
37
|
+
}) => void;
|
|
38
|
+
onFilesRejected?: (rejectedFiles: Array<File>) => void;
|
|
39
|
+
name?: string;
|
|
40
|
+
value?: ReadonlyArray<File>;
|
|
41
|
+
/** @deprecated Use props `multiple`, `accept` instead (Will be removed in v0.11) */
|
|
42
|
+
dropzoneProps?: {
|
|
43
|
+
accept?: string;
|
|
44
|
+
multiple?: boolean;
|
|
45
|
+
};
|
|
46
|
+
} & FormFieldWrappingProps;
|
|
47
|
+
export declare const FileInput: (props: FileInputProps) => JSX.Element;
|
|
48
|
+
export default FileInput;
|
package/esm/FileInput.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useDropzone } from 'react-dropzone'; // https://react-dropzone.js.org/#!/Dropzone
|
|
4
|
+
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
5
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
6
|
+
import { DEFAULT_LANG } from '@reykjavik/hanna-utils/i18n';
|
|
7
|
+
import { addPreview, formatBytes, getFileListUpdate, releasePreview, } from './FileInput/_FileInput.utils';
|
|
8
|
+
import { DefaultFileList } from './FileInput/_FileInputFileList.js';
|
|
9
|
+
import FormField from './FormField.js';
|
|
10
|
+
const defaultRemoveFileText = {
|
|
11
|
+
is: 'Fjarlægja',
|
|
12
|
+
en: 'Remove',
|
|
13
|
+
pl: 'Usuń',
|
|
14
|
+
};
|
|
15
|
+
const defaultOnFilesRejected = (rejectedFiles) => {
|
|
16
|
+
window.alert('Error:\n' +
|
|
17
|
+
rejectedFiles
|
|
18
|
+
.map((elm) => {
|
|
19
|
+
return elm.name;
|
|
20
|
+
})
|
|
21
|
+
.join(', '));
|
|
22
|
+
};
|
|
23
|
+
const arrayToFileList = (arr) => {
|
|
24
|
+
const fileList = new DataTransfer();
|
|
25
|
+
arr.forEach((item) => {
|
|
26
|
+
fileList.items.add(item);
|
|
27
|
+
});
|
|
28
|
+
return fileList.files;
|
|
29
|
+
};
|
|
30
|
+
export const FileInput = (props) => {
|
|
31
|
+
const { className, id, label, hideLabel, dropzoneProps = { multiple: true }, multiple = dropzoneProps.multiple, accept, dropzoneText, lang = DEFAULT_LANG, removeFileText = defaultRemoveFileText[lang] || defaultRemoveFileText[DEFAULT_LANG], assistText, disabled, invalid, errorMessage, required, reqText, FileList = DefaultFileList, onFilesUpdated = () => undefined, onFilesRejected, showFileSize, showImagePreviews, value = [] } = props, inputElementProps = __rest(props, ["className", "id", "label", "hideLabel", "dropzoneProps", "multiple", "accept", "dropzoneText", "lang", "removeFileText", "assistText", "disabled", "invalid", "errorMessage", "required", "reqText", "FileList", "onFilesUpdated", "onFilesRejected", "showFileSize", "showImagePreviews", "value"]);
|
|
32
|
+
const domid = useDomid(id);
|
|
33
|
+
const fileInputWrapper = useRef(null);
|
|
34
|
+
const fileInput = useRef(null);
|
|
35
|
+
const files = value;
|
|
36
|
+
const [isHover, setIsHover] = useState(false);
|
|
37
|
+
const { getRootProps, getInputProps, isDragReject, inputRef } = useDropzone({
|
|
38
|
+
onDrop: (acceptedFiles) => {
|
|
39
|
+
acceptedFiles = acceptedFiles.map((file) => {
|
|
40
|
+
addPreview(file);
|
|
41
|
+
return file;
|
|
42
|
+
});
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
44
|
+
addFiles(acceptedFiles);
|
|
45
|
+
setIsHover(false);
|
|
46
|
+
},
|
|
47
|
+
onDropRejected: onFilesRejected || defaultOnFilesRejected,
|
|
48
|
+
onDragEnter: () => {
|
|
49
|
+
// 'dragLeave' always fires right after 'dragEnter', use 'dragOver' instead
|
|
50
|
+
// console.log('enter');
|
|
51
|
+
// setIsHover(true);
|
|
52
|
+
},
|
|
53
|
+
onDragLeave: () => {
|
|
54
|
+
// console.log('leave');
|
|
55
|
+
setIsHover(false);
|
|
56
|
+
},
|
|
57
|
+
onDragOver: () => {
|
|
58
|
+
// TODO: add error icon? 'isDragReject' gives unstable results
|
|
59
|
+
// console.log(isDragReject);
|
|
60
|
+
setIsHover(true);
|
|
61
|
+
},
|
|
62
|
+
multiple,
|
|
63
|
+
accept,
|
|
64
|
+
});
|
|
65
|
+
// Synchronoyusly add previews on incoming files
|
|
66
|
+
// (NOTE: `addPreview` ignores files that already have preview.)
|
|
67
|
+
files.forEach(addPreview);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (fileInput.current) {
|
|
70
|
+
fileInput.current.files = arrayToFileList(files);
|
|
71
|
+
}
|
|
72
|
+
return () => {
|
|
73
|
+
// Make sure to revoke the data uris on unmount to avoid memory leaks
|
|
74
|
+
files.forEach(releasePreview);
|
|
75
|
+
};
|
|
76
|
+
}, [files]);
|
|
77
|
+
const removeFile = (removeTarget) => {
|
|
78
|
+
const deleted = [];
|
|
79
|
+
const targetName = typeof removeTarget !== 'string' ? removeTarget.name : removeTarget;
|
|
80
|
+
const fileList = files.filter((file) => {
|
|
81
|
+
if (file.name !== targetName) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
deleted.push(file);
|
|
85
|
+
releasePreview(file);
|
|
86
|
+
return false;
|
|
87
|
+
});
|
|
88
|
+
if (fileInput.current) {
|
|
89
|
+
fileInput.current.files = arrayToFileList(fileList);
|
|
90
|
+
}
|
|
91
|
+
onFilesUpdated(fileList, { deleted });
|
|
92
|
+
};
|
|
93
|
+
const addFiles = (added) => {
|
|
94
|
+
const { fileList, diff } = getFileListUpdate(files, added, !multiple);
|
|
95
|
+
if (fileInput.current) {
|
|
96
|
+
fileInput.current.files = arrayToFileList(fileList);
|
|
97
|
+
}
|
|
98
|
+
if (inputRef.current) {
|
|
99
|
+
// Empty on every add
|
|
100
|
+
inputRef.current.files = arrayToFileList([]);
|
|
101
|
+
}
|
|
102
|
+
onFilesUpdated(fileList, diff);
|
|
103
|
+
};
|
|
104
|
+
return (React.createElement(FormField, { className: getBemClass('FileInput', [multiple && 'multi'], className), label: label, id: domid + '-fake', LabelTag: "h4", assistText: assistText, hideLabel: hideLabel, disabled: disabled, invalid: invalid, errorMessage: errorMessage, required: required, reqText: reqText, renderInput: (className, inputProps /* , addFocusProps */) => {
|
|
105
|
+
return (React.createElement("div", { className: className.control, ref: fileInputWrapper },
|
|
106
|
+
// Explicitly skip rendering of input element if no
|
|
107
|
+
// name prop is provided. This is implicitly what the
|
|
108
|
+
// browser does on form submit.
|
|
109
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
|
|
110
|
+
// In such cases we assume the application controls the upload/submit
|
|
111
|
+
// behavior separately outside of this component.
|
|
112
|
+
inputElementProps.name ? (React.createElement("input", { className: "FileInput__input", name: inputElementProps.name, id: domid, ref: fileInput, type: "file", style: { display: 'none' }, multiple: multiple || undefined, required: inputProps.required })) : null,
|
|
113
|
+
React.createElement("input", Object.assign({
|
|
114
|
+
// fake input exclusively used to capture clicks and file drops.
|
|
115
|
+
// it's contents are wiped on every "add" action.
|
|
116
|
+
className: "FileInput__input--fake" }, getInputProps(), { tabIndex: undefined, style: undefined, multiple: multiple || undefined }, inputProps, { required: undefined })),
|
|
117
|
+
' ',
|
|
118
|
+
React.createElement("div", Object.assign({ className: getBemClass('FileInput__dropzone', [isHover && 'highlight']) }, getRootProps({ isDragReject }), { tabIndex: undefined }),
|
|
119
|
+
React.createElement("p", { className: "FileInput__droptext" }, dropzoneText)),
|
|
120
|
+
FileList && (React.createElement(FileList, Object.assign({}, {
|
|
121
|
+
files,
|
|
122
|
+
showFileSize,
|
|
123
|
+
showImagePreviews,
|
|
124
|
+
removeFileText,
|
|
125
|
+
removeFile,
|
|
126
|
+
formatBytes,
|
|
127
|
+
})))));
|
|
128
|
+
} }));
|
|
129
|
+
};
|
|
130
|
+
export default FileInput;
|
package/esm/Foonote.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FootnoteProps as _FootnoteProps } from './Footnote.js';
|
|
2
|
+
/** @deprecated (Will be removed in v0.11)
|
|
3
|
+
*
|
|
4
|
+
* This module file is a typo. import from `Footnote` instead
|
|
5
|
+
*/
|
|
6
|
+
export type FootnoteProps = _FootnoteProps;
|
|
7
|
+
/** @deprecated (Will be removed in v0.11)
|
|
8
|
+
*
|
|
9
|
+
* This module file is a typo. import from `Footnote` instead
|
|
10
|
+
*/
|
|
11
|
+
export declare const Footnote: (props: _FootnoteProps) => JSX.Element;
|
|
12
|
+
export default Footnote;
|
package/esm/Foonote.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from './_abstract/_Link.js';
|
|
3
|
+
export const FooterBadges = (props) => {
|
|
4
|
+
if (!props.badges.length) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return (React.createElement("ul", { className: "FooterBadges" }, props.badges.map(({ altText, src, href }, i) => (React.createElement("li", { key: i, className: "FooterBadges__badge" }, href ? (React.createElement(Link, { href: href },
|
|
8
|
+
' ',
|
|
9
|
+
React.createElement("img", { src: src, alt: altText }),
|
|
10
|
+
' ')) : (React.createElement("img", { src: src, alt: altText })))))));
|
|
11
|
+
};
|
|
12
|
+
export default FooterBadges;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BemPropsModifier } from '@hugsmidjan/react/types';
|
|
2
|
+
export type FooterInfoGroup = {
|
|
3
|
+
title: string;
|
|
4
|
+
modifier?: string;
|
|
5
|
+
main?: boolean;
|
|
6
|
+
/** @deprecated (Will be removed in v0.11) */
|
|
7
|
+
role?: JSX.IntrinsicElements['div']['role'];
|
|
8
|
+
} & BemPropsModifier & ({
|
|
9
|
+
content: JSX.Element;
|
|
10
|
+
html?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
html: string;
|
|
13
|
+
content?: undefined;
|
|
14
|
+
});
|
|
15
|
+
export type FooterInfoBoxes = Array<FooterInfoGroup>;
|
|
16
|
+
export type FooterInfoProps = {
|
|
17
|
+
boxes: FooterInfoBoxes;
|
|
18
|
+
};
|
|
19
|
+
export declare const FooterInfo: (props: FooterInfoProps) => JSX.Element;
|
|
20
|
+
export default FooterInfo;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
export const FooterInfo = (props) => {
|
|
4
|
+
const { boxes } = props;
|
|
5
|
+
return (React.createElement("div", { className: "FooterInfo" }, boxes.map((group, i) => (React.createElement("div", { className: getBemClass('FooterInfo__group', [
|
|
6
|
+
group.main && 'main',
|
|
7
|
+
group.modifier,
|
|
8
|
+
]), key: i },
|
|
9
|
+
React.createElement("h3", { className: "FooterInfo__grouptitle" }, group.title),
|
|
10
|
+
group.content ? (React.createElement("div", { className: getBemClass('FooterInfo__groupcontent', group.modifier) }, group.content)) : (React.createElement("div", { className: getBemClass('FooterInfo__groupcontent', group.modifier), dangerouslySetInnerHTML: { __html: group.html } })))))));
|
|
11
|
+
};
|
|
12
|
+
export default FooterInfo;
|
package/esm/Footnote.js
ADDED
package/esm/Form.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ComponentLayoutProps } from './constants.js';
|
|
3
|
+
export type FormProps = ComponentLayoutProps & React.FormHTMLAttributes<HTMLFormElement> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare const Form: (props: FormProps) => JSX.Element;
|
|
7
|
+
export default Form;
|
package/esm/Form.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
+
export const Form = (props) => {
|
|
4
|
+
const { children, align, wide } = props;
|
|
5
|
+
return (React.createElement("form", Object.assign({}, props, { className: getBemClass('Form', [
|
|
6
|
+
align === 'right' && 'align--' + align,
|
|
7
|
+
!align && wide && 'wide',
|
|
8
|
+
]) }), children));
|
|
9
|
+
};
|
|
10
|
+
export default Form;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { SSRSupport } from './utils.js';
|
|
3
|
+
type InputClassNames = {
|
|
4
|
+
/** Basic/raw FormField BEM name */
|
|
5
|
+
bem: string;
|
|
6
|
+
/** Standard name for "<input/>"-styled controls */
|
|
7
|
+
input: string;
|
|
8
|
+
/** Standard name for radio/checkbox group conotrols */
|
|
9
|
+
options: string;
|
|
10
|
+
/** Generic name for unstyled/free-form controls. */
|
|
11
|
+
control: string;
|
|
12
|
+
};
|
|
13
|
+
export type FormFieldInputProps = {
|
|
14
|
+
id?: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
'aria-invalid'?: boolean | 'true' | 'false';
|
|
19
|
+
'aria-labelledby'?: string;
|
|
20
|
+
'aria-describedby'?: string;
|
|
21
|
+
};
|
|
22
|
+
type FocusEvents = {
|
|
23
|
+
onFocus?: (e: any) => void;
|
|
24
|
+
onBlur?: (e: any) => void;
|
|
25
|
+
};
|
|
26
|
+
type FocusPropMaker = <P extends FocusEvents>(ownProps?: P) => P & Required<FocusEvents>;
|
|
27
|
+
export type FormFieldWrappingProps = {
|
|
28
|
+
/** Container className - alongside "FormField" */
|
|
29
|
+
className?: string;
|
|
30
|
+
label: string | JSX.Element;
|
|
31
|
+
assistText?: string | JSX.Element;
|
|
32
|
+
hideLabel?: boolean;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
readOnly?: boolean;
|
|
35
|
+
invalid?: boolean;
|
|
36
|
+
errorMessage?: string | JSX.Element;
|
|
37
|
+
required?: boolean;
|
|
38
|
+
/** Hidden label prefix text to indicate that the field is required.
|
|
39
|
+
*
|
|
40
|
+
* If your field is required but should not say so in its label
|
|
41
|
+
* then set this prop to `false`
|
|
42
|
+
*
|
|
43
|
+
* Default: `"Þarf að fylla út"`
|
|
44
|
+
* */
|
|
45
|
+
reqText?: string | false;
|
|
46
|
+
/** Optional pre-determinted id="" for the __input */
|
|
47
|
+
id?: string;
|
|
48
|
+
/** Ref object pointing to the outermost `.FormField` element */
|
|
49
|
+
wrapperRef?: RefObject<HTMLElement>;
|
|
50
|
+
ssr?: SSRSupport;
|
|
51
|
+
};
|
|
52
|
+
export type FormFieldGroupWrappingProps = FormFieldWrappingProps & {
|
|
53
|
+
LabelTag?: 'h3' | 'h4' | 'h5';
|
|
54
|
+
};
|
|
55
|
+
export type FormFieldProps = FormFieldGroupWrappingProps & {
|
|
56
|
+
/** Container className - alongside "FormField" */
|
|
57
|
+
className: string;
|
|
58
|
+
small?: boolean;
|
|
59
|
+
group?: boolean;
|
|
60
|
+
empty?: boolean;
|
|
61
|
+
filled?: boolean;
|
|
62
|
+
renderInput(className: InputClassNames, inputProps: FormFieldInputProps, addFocusProps: FocusPropMaker, isBrowser?: boolean): JSX.Element;
|
|
63
|
+
};
|
|
64
|
+
export declare const FormField: (props: FormFieldProps) => JSX.Element;
|
|
65
|
+
export default FormField;
|
package/esm/FormField.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
3
|
+
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
+
import { isPreact } from './utils/env.js';
|
|
5
|
+
import { useIsBrowserSide } from './utils.js';
|
|
6
|
+
const inputClassNames = {
|
|
7
|
+
bem: 'FormField',
|
|
8
|
+
input: 'FormField__input',
|
|
9
|
+
options: 'FormField__options',
|
|
10
|
+
control: 'FormField__control',
|
|
11
|
+
};
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// eslint-disable-next-line complexity
|
|
14
|
+
export const FormField = (props) => {
|
|
15
|
+
const { className, small, group, LabelTag = group ? 'h4' : undefined, label, assistText, hideLabel, empty, filled, readOnly, disabled, invalid, errorMessage, required, reqText, // i18n
|
|
16
|
+
renderInput, id, ssr, } = props;
|
|
17
|
+
const isBrowser = useIsBrowserSide(ssr);
|
|
18
|
+
const isInvalid = invalid || !!errorMessage || undefined;
|
|
19
|
+
const domid = useDomid(id);
|
|
20
|
+
const [focused, setFocused] = useState(false);
|
|
21
|
+
// @ts-expect-error (Duck knows why this errors?!)
|
|
22
|
+
const addFocusProps = useCallback((ownProps) => {
|
|
23
|
+
const { onFocus, onBlur } = ownProps || {};
|
|
24
|
+
const focusHandler = (e) => {
|
|
25
|
+
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
26
|
+
setFocused(true);
|
|
27
|
+
}
|
|
28
|
+
onFocus && onFocus(e);
|
|
29
|
+
};
|
|
30
|
+
const blurHandler = (e) => {
|
|
31
|
+
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
32
|
+
setFocused(false);
|
|
33
|
+
}
|
|
34
|
+
onBlur && onBlur(e);
|
|
35
|
+
};
|
|
36
|
+
const focusProps = Object.assign(Object.assign({}, ownProps), { onFocus: focusHandler, onBlur: blurHandler });
|
|
37
|
+
if (isPreact) {
|
|
38
|
+
const focusinHandler = (e) => {
|
|
39
|
+
e.currentTarget !== e.target && focusHandler(e);
|
|
40
|
+
};
|
|
41
|
+
const focusoutHandler = (e) => {
|
|
42
|
+
e.currentTarget !== e.target && blurHandler(e);
|
|
43
|
+
};
|
|
44
|
+
// @ts-expect-error (Sneak this in as Preact does not bubble `FocusEvent`s)
|
|
45
|
+
focusProps.onfocusin = focusinHandler;
|
|
46
|
+
// @ts-expect-error (Sneak this in as Preact does not bubble `FocusEvent`s)
|
|
47
|
+
focusProps.onfocusout = focusoutHandler;
|
|
48
|
+
}
|
|
49
|
+
return focusProps;
|
|
50
|
+
}, []);
|
|
51
|
+
const errorId = errorMessage ? 'error:' + domid : undefined;
|
|
52
|
+
const assistTextId = assistText ? 'assist:' + domid : undefined;
|
|
53
|
+
const labelId = LabelTag ? 'label:' + domid : undefined;
|
|
54
|
+
const reqStar = required && reqText !== false && (React.createElement("abbr", { className: "FormField__label__reqstar",
|
|
55
|
+
// TODO: add mo-better i18n thinking
|
|
56
|
+
title: (reqText || 'Þarf að fylla út') + ': ' }, "*"));
|
|
57
|
+
const inputProps = {
|
|
58
|
+
id: domid,
|
|
59
|
+
disabled: disabled,
|
|
60
|
+
required: required,
|
|
61
|
+
readOnly: readOnly,
|
|
62
|
+
'aria-invalid': isInvalid,
|
|
63
|
+
'aria-describedby': assistTextId && errorId ? assistTextId + ' ' + errorId : assistTextId || errorId,
|
|
64
|
+
'aria-labelledby': labelId, // undefined if normalLabel
|
|
65
|
+
};
|
|
66
|
+
return (React.createElement("div", { className: getBemClass('FormField', [
|
|
67
|
+
small && 'small',
|
|
68
|
+
hideLabel && 'nolabel',
|
|
69
|
+
isInvalid && 'invalid',
|
|
70
|
+
disabled && 'disabled',
|
|
71
|
+
readOnly && 'readonly',
|
|
72
|
+
isBrowser && empty && 'empty',
|
|
73
|
+
isBrowser && filled && 'filled',
|
|
74
|
+
isBrowser && focused && 'focused',
|
|
75
|
+
], className), ref: props.wrapperRef },
|
|
76
|
+
LabelTag ? (React.createElement(LabelTag, { className: "FormField__label", id: labelId },
|
|
77
|
+
' ',
|
|
78
|
+
reqStar,
|
|
79
|
+
" ",
|
|
80
|
+
label,
|
|
81
|
+
' ')) : (React.createElement("label", { className: "FormField__label", htmlFor: domid },
|
|
82
|
+
' ',
|
|
83
|
+
reqStar,
|
|
84
|
+
" ",
|
|
85
|
+
label,
|
|
86
|
+
' ')),
|
|
87
|
+
' ',
|
|
88
|
+
renderInput(inputClassNames, inputProps, addFocusProps, isBrowser),
|
|
89
|
+
assistText && (React.createElement("div", { id: assistTextId, className: "FormField__assist" }, assistText)),
|
|
90
|
+
errorMessage && (React.createElement("div", { id: errorId, className: "FormField__error" }, errorMessage))));
|
|
91
|
+
};
|
|
92
|
+
export default FormField;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { Button } from '../_abstract/_Button.js';
|
|
4
|
+
import { Image } from '../_abstract/_Image.js';
|
|
5
|
+
import { GalleryModalContext } from './_GalleryModalContext.js';
|
|
6
|
+
export const GalleryItem = (props) => {
|
|
7
|
+
const { caption, description, largeImageSrc } = props, image = __rest(props, ["caption", "description", "largeImageSrc"]);
|
|
8
|
+
const { setCurrentImage } = useContext(GalleryModalContext);
|
|
9
|
+
return (React.createElement("figure", { className: "GalleryItem" },
|
|
10
|
+
React.createElement("figcaption", { className: "GalleryItem__caption" }, caption),
|
|
11
|
+
largeImageSrc ? (React.createElement(Button, { bem: "GalleryItem__button", href: largeImageSrc, onClick: (e) => {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
setCurrentImage(Object.assign(Object.assign({}, image), { caption, description, largeImageSrc }));
|
|
14
|
+
} },
|
|
15
|
+
' ',
|
|
16
|
+
React.createElement(Image, Object.assign({ className: "GalleryItem__image" }, image)),
|
|
17
|
+
' ')) : (React.createElement(Image, Object.assign({ className: "GalleryItem__image" }, image))),
|
|
18
|
+
description && React.createElement("div", { className: "GalleryItem__description" }, description)));
|
|
19
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { CSSTransition } from 'react-transition-group';
|
|
3
|
+
import { objectClean, objectIsSame } from '@hugsmidjan/qj/object';
|
|
4
|
+
import CarouselPaging from '@hugsmidjan/react/CarouselPaging';
|
|
5
|
+
import Modal from '@hugsmidjan/react/Modal';
|
|
6
|
+
import { GalleryModalContext } from './_GalleryModalContext.js';
|
|
7
|
+
import { GalleryModalItem } from './_GalleryModalItem.js';
|
|
8
|
+
export const GalleryModal = (props) => {
|
|
9
|
+
const { texts } = props;
|
|
10
|
+
const { currentImage, items, setCurrentImage } = useContext(GalleryModalContext);
|
|
11
|
+
const [image, setImage] = useState(currentImage);
|
|
12
|
+
const [animated, setAnimated] = useState(false);
|
|
13
|
+
const updateImage = (index) => {
|
|
14
|
+
setAnimated(!animated);
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
setCurrentImage(items[index]);
|
|
17
|
+
}, 200);
|
|
18
|
+
};
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (image !== currentImage) {
|
|
21
|
+
const imgSource = (currentImage === null || currentImage === void 0 ? void 0 : currentImage.largeImageSrc) || (currentImage === null || currentImage === void 0 ? void 0 : currentImage.src);
|
|
22
|
+
if (imgSource) {
|
|
23
|
+
const imageToLoad = new window.Image();
|
|
24
|
+
imageToLoad.src = imgSource;
|
|
25
|
+
imageToLoad.onload = () => {
|
|
26
|
+
setImage(currentImage);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setImage(undefined);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, [image, currentImage]);
|
|
34
|
+
if (!image) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const imageIndex = items.findIndex((item) =>
|
|
38
|
+
// FIXME: This if weirdly inefficient. Either memoize,
|
|
39
|
+
// or do a simpler single-property comparison.
|
|
40
|
+
objectIsSame(objectClean(image), objectClean(item)));
|
|
41
|
+
return (React.createElement(Modal, { open: true, onClosed: () => {
|
|
42
|
+
setCurrentImage(undefined);
|
|
43
|
+
}, startOpen: false, bem: "GalleryModal", texts: { closeButton: texts.modalCloseLabel } },
|
|
44
|
+
React.createElement(React.Fragment, null,
|
|
45
|
+
React.createElement(CSSTransition, { in: animated, timeout: 200, onEntered: () => {
|
|
46
|
+
setAnimated(!animated);
|
|
47
|
+
}, classNames: "GalleryModalItem--" },
|
|
48
|
+
React.createElement(GalleryModalItem, Object.assign({}, image))),
|
|
49
|
+
React.createElement(CarouselPaging, { bem: "GalleryModalPager", itemCount: items.length, current: imageIndex, setCurrent: updateImage, texts: {
|
|
50
|
+
next: texts.modalNextLabel,
|
|
51
|
+
prev: texts.modalPrevLabel,
|
|
52
|
+
} }))));
|
|
53
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { GalleryProps } from '../Gallery.js';
|
|
3
|
+
import { GalleryItemProps } from './_GalleryItem.js';
|
|
4
|
+
type ModalContextProps = {
|
|
5
|
+
setCurrentImage: (item: GalleryItemProps | undefined) => void;
|
|
6
|
+
currentImage: GalleryItemProps | undefined;
|
|
7
|
+
} & GalleryProps;
|
|
8
|
+
export declare const GalleryModalContext: import("react").Context<ModalContextProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Image } from '../_abstract/_Image.js';
|
|
4
|
+
export const GalleryModalItem = (props) => {
|
|
5
|
+
const { caption, description } = props, image = __rest(props, ["caption", "description"]);
|
|
6
|
+
return (React.createElement("div", { className: "GalleryModalItem" },
|
|
7
|
+
(caption || description) && (React.createElement("div", { className: "GalleryModalItem__text" },
|
|
8
|
+
React.createElement("div", { className: "GalleryModalItem__caption" }, caption),
|
|
9
|
+
React.createElement("div", { className: "GalleryModalItem__description" }, description))),
|
|
10
|
+
React.createElement(Image, { className: "GalleryModalItem__image", src: image.largeImageSrc || image.src })));
|
|
11
|
+
};
|
package/esm/Gallery.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GalleryItemProps } from './Gallery/_GalleryItem.js';
|
|
2
|
+
import { SeenProp } from './utils/seenEffect.js';
|
|
3
|
+
import { SSRSupport } from './utils.js';
|
|
4
|
+
export type { GalleryItemProps } from './Gallery/_GalleryItem.js';
|
|
5
|
+
export type GalleryI18n = {
|
|
6
|
+
modalNextLabel: string;
|
|
7
|
+
modalPrevLabel: string;
|
|
8
|
+
modalCloseLabel: string;
|
|
9
|
+
};
|
|
10
|
+
export type GalleryProps = {
|
|
11
|
+
items: Array<GalleryItemProps>;
|
|
12
|
+
texts?: GalleryI18n;
|
|
13
|
+
lang?: string;
|
|
14
|
+
ssr?: SSRSupport;
|
|
15
|
+
} & SeenProp;
|
|
16
|
+
export declare const Gallery: (props: GalleryProps) => JSX.Element;
|
|
17
|
+
export default Gallery;
|
package/esm/Gallery.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
3
|
+
import { AbstractCarousel } from './_abstract/_AbstractCarousel.js';
|
|
4
|
+
import { GalleryItem } from './Gallery/_GalleryItem.js';
|
|
5
|
+
import { GalleryModal } from './Gallery/_GalleryModal.js';
|
|
6
|
+
import { GalleryModalContext } from './Gallery/_GalleryModalContext.js';
|
|
7
|
+
const defaultTexts = {
|
|
8
|
+
en: {
|
|
9
|
+
modalNextLabel: 'Next image',
|
|
10
|
+
modalPrevLabel: 'Previous image',
|
|
11
|
+
modalCloseLabel: 'Back to article',
|
|
12
|
+
},
|
|
13
|
+
is: {
|
|
14
|
+
modalNextLabel: 'Næsta mynd',
|
|
15
|
+
modalPrevLabel: 'Fyrri mynd',
|
|
16
|
+
modalCloseLabel: 'Til baka í grein',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const Gallery = (props) => {
|
|
20
|
+
const { items, ssr, startSeen } = props;
|
|
21
|
+
const texts = getTexts(props, defaultTexts);
|
|
22
|
+
const [modalImage, setModalImage] = useState(undefined);
|
|
23
|
+
return (React.createElement(GalleryModalContext.Provider, { value: { items, setCurrentImage: setModalImage, currentImage: modalImage } },
|
|
24
|
+
React.createElement(AbstractCarousel, { bem: "Gallery", items: items, Component: GalleryItem, ssr: ssr, startSeen: startSeen }),
|
|
25
|
+
React.createElement(GalleryModal, Object.assign({}, modalImage, { texts: texts }))));
|
|
26
|
+
};
|
|
27
|
+
export default Gallery;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Efnistakn } from '@reykjavik/hanna-utils/assets';
|
|
2
|
+
import { ButtonProps } from './_abstract/_Button.js';
|
|
3
|
+
import { ImageProps } from './_abstract/_Image.js';
|
|
4
|
+
import { SeenProp } from './utils/seenEffect.js';
|
|
5
|
+
export type GridBlockItem = {
|
|
6
|
+
title: string;
|
|
7
|
+
summary: string | JSX.Element;
|
|
8
|
+
icon?: Efnistakn;
|
|
9
|
+
image?: ImageProps;
|
|
10
|
+
} & ({
|
|
11
|
+
href?: string;
|
|
12
|
+
links: Array<ButtonProps>;
|
|
13
|
+
} | {
|
|
14
|
+
href: string;
|
|
15
|
+
links?: Array<ButtonProps>;
|
|
16
|
+
});
|
|
17
|
+
export type GridBlocksProps = {
|
|
18
|
+
blocks: Array<GridBlockItem>;
|
|
19
|
+
twocol?: boolean;
|
|
20
|
+
} & SeenProp;
|
|
21
|
+
export type GridBlocksProp1s = {
|
|
22
|
+
blocks: Array<GridBlockItem>;
|
|
23
|
+
twocol?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const GridBlocks: (props: GridBlocksProps) => JSX.Element;
|
|
26
|
+
export default GridBlocks;
|