@reykjavik/hanna-react 0.10.59 → 0.10.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AccordionList.js +3 -28
- package/ActionCards.js +2 -4
- package/Alert.js +4 -29
- package/ArticleCards.js +2 -4
- package/ArticleCarousel/_ArticleCarouselCard.js +4 -6
- package/ArticleCarousel.js +3 -5
- package/ArticleMeta.js +3 -28
- package/Attention.js +3 -5
- package/BasicTable.js +5 -7
- package/BgBox.js +3 -5
- package/Bling.js +3 -5
- package/BlockBreak.js +2 -4
- package/BlockQuote.js +2 -4
- package/BreadCrumbs.js +2 -4
- package/ButtonBack.js +3 -5
- package/ButtonBar.js +3 -5
- package/ButtonPrimary.js +3 -5
- package/ButtonSecondary.js +3 -5
- package/ButtonTertiary.js +3 -5
- package/CHANGELOG.md +8 -0
- package/Carousel.js +3 -5
- package/CarouselStepper.js +3 -5
- package/CenterColumn.js +3 -5
- package/Checkbox.js +3 -5
- package/CheckboxButtonsGroup.js +4 -6
- package/CheckboxGroup.js +4 -6
- package/CityBlock.js +3 -5
- package/ContactBubble.js +4 -29
- package/ContentArticle.js +8 -10
- package/ContentImage.js +3 -5
- package/Datepicker.js +6 -31
- package/ExtraLinks.js +4 -17
- package/FeatureList.js +3 -5
- package/FieldGroup.js +3 -5
- package/FileInput.js +5 -41
- package/Foonote.js +2 -4
- package/FooterBadges.js +2 -4
- package/FooterInfo.js +3 -5
- package/Footnote.js +2 -4
- package/Form.js +3 -5
- package/FormField.js +3 -28
- package/Gallery/_GalleryItem.js +6 -42
- package/Gallery/_GalleryModal.js +6 -31
- package/Gallery/_GalleryModalContext.js +2 -4
- package/Gallery/_GalleryModalItem.js +4 -17
- package/Gallery.js +6 -31
- package/GridBlocks.js +5 -7
- package/Heading.js +3 -5
- package/HeroBlock.js +5 -7
- package/IframeBlock.d.ts +5 -1
- package/IframeBlock.js +6 -8
- package/Illustration.js +3 -5
- package/ImageCards.js +4 -17
- package/InfoBlock.js +2 -4
- package/InfoHero.js +7 -9
- package/IslandBlock.js +3 -5
- package/IslandPageBlock.js +3 -5
- package/LabeledTextBlock.js +4 -6
- package/Layout.js +4 -6
- package/MainMenu/_Auxiliary.js +2 -4
- package/MainMenu/_PrimaryPanel.js +3 -5
- package/MainMenu.js +5 -30
- package/MiniMetrics.js +4 -6
- package/Modal.js +3 -5
- package/NameCard.js +5 -7
- package/NameCards.js +3 -5
- package/NewsHero.js +6 -8
- package/PageFilter.js +4 -6
- package/PageHeading.js +3 -5
- package/Picture.js +4 -6
- package/ProcessOverview.js +3 -5
- package/PullQuote.js +2 -4
- package/RadioButtonsGroup.js +4 -6
- package/RadioGroup.js +4 -6
- package/RelatedLinks.js +2 -4
- package/RowBlock.js +3 -5
- package/RowBlockColumn.js +3 -5
- package/SearchInput.js +5 -41
- package/SearchResults/_SearchResultsItem.js +3 -5
- package/SearchResults.js +7 -32
- package/SeenEffect.js +3 -16
- package/Selectbox.js +6 -42
- package/ShareButtons.js +2 -24
- package/Sharpie.js +3 -5
- package/SiteSearchAutocomplete.js +5 -41
- package/SiteSearchCurtain.js +3 -28
- package/SiteSearchInput.d.ts +1 -1
- package/SiteSearchInput.js +4 -40
- package/Skeleton.js +4 -6
- package/SubHeading.js +3 -5
- package/Tabs.js +3 -28
- package/TagPill.js +5 -18
- package/TextBlock.js +3 -5
- package/TextButton.js +3 -5
- package/TextInput.js +5 -41
- package/VSpacer.js +3 -5
- package/VerticalTabsTOC.js +3 -28
- package/WizardLayout.js +3 -5
- package/WizardLayoutClose.js +3 -5
- package/WizardStepper.js +3 -5
- package/_abstract/_AbstractCarousel.js +7 -32
- package/_abstract/_Blings.js +3 -5
- package/_abstract/_Block.js +5 -7
- package/_abstract/_Button.js +4 -17
- package/_abstract/_CardList.js +4 -6
- package/_abstract/_Image.js +3 -5
- package/_abstract/_Link.js +2 -4
- package/_abstract/_Quote.js +2 -4
- package/_abstract/_TogglerGroup.js +8 -8
- package/_abstract/_TogglerGroupField.js +6 -19
- package/_abstract/_TogglerInput.js +4 -17
- package/_abstract/breakOnNL.js +2 -4
- package/package.json +4 -378
- package/utils/env.js +2 -4
- package/utils/useScrollbarWidthCSSVar.js +2 -4
- package/utils.js +3 -16
- package/esm/AccordionList.d.ts +0 -17
- package/esm/AccordionList.js +0 -24
- package/esm/ActionCards.d.ts +0 -5
- package/esm/ActionCards.js +0 -9
- package/esm/Alert.d.ts +0 -49
- package/esm/Alert.js +0 -92
- package/esm/ArticleCards.d.ts +0 -6
- package/esm/ArticleCards.js +0 -4
- package/esm/ArticleCarousel/_ArticleCarouselCard.d.ts +0 -27
- package/esm/ArticleCarousel/_ArticleCarouselCard.js +0 -24
- package/esm/ArticleCarousel.d.ts +0 -12
- package/esm/ArticleCarousel.js +0 -8
- package/esm/ArticleMeta.d.ts +0 -10
- package/esm/ArticleMeta.js +0 -19
- package/esm/Attention.d.ts +0 -7
- package/esm/Attention.js +0 -4
- package/esm/BasicTable.d.ts +0 -12
- package/esm/BasicTable.js +0 -29
- package/esm/BgBox.d.ts +0 -8
- package/esm/BgBox.js +0 -9
- package/esm/Bling.d.ts +0 -81
- package/esm/Bling.js +0 -44
- package/esm/BlockBreak.d.ts +0 -2
- package/esm/BlockBreak.js +0 -6
- package/esm/BlockQuote.d.ts +0 -4
- package/esm/BlockQuote.js +0 -4
- package/esm/BreadCrumbs.d.ts +0 -11
- package/esm/BreadCrumbs.js +0 -28
- package/esm/ButtonBack.d.ts +0 -7
- package/esm/ButtonBack.js +0 -4
- package/esm/ButtonBar.d.ts +0 -16
- package/esm/ButtonBar.js +0 -14
- package/esm/ButtonPrimary.d.ts +0 -7
- package/esm/ButtonPrimary.js +0 -4
- package/esm/ButtonSecondary.d.ts +0 -7
- package/esm/ButtonSecondary.js +0 -4
- package/esm/ButtonTertiary.d.ts +0 -12
- package/esm/ButtonTertiary.js +0 -15
- package/esm/Carousel.d.ts +0 -4
- package/esm/Carousel.js +0 -4
- package/esm/CarouselStepper.d.ts +0 -4
- package/esm/CarouselStepper.js +0 -4
- package/esm/CenterColumn.d.ts +0 -7
- package/esm/CenterColumn.js +0 -7
- package/esm/Checkbox.d.ts +0 -4
- package/esm/Checkbox.js +0 -4
- package/esm/CheckboxButtonsGroup.d.ts +0 -11
- package/esm/CheckboxButtonsGroup.js +0 -14
- package/esm/CheckboxGroup.d.ts +0 -9
- package/esm/CheckboxGroup.js +0 -7
- package/esm/CityBlock.d.ts +0 -23
- package/esm/CityBlock.js +0 -18
- package/esm/ContactBubble.d.ts +0 -58
- package/esm/ContactBubble.js +0 -148
- package/esm/ContentArticle.d.ts +0 -15
- package/esm/ContentArticle.js +0 -21
- package/esm/ContentImage.d.ts +0 -8
- package/esm/ContentImage.js +0 -18
- package/esm/Datepicker.d.ts +0 -39
- package/esm/Datepicker.js +0 -63
- package/esm/ExtraLinks.d.ts +0 -18
- package/esm/ExtraLinks.js +0 -34
- package/esm/FeatureList.d.ts +0 -12
- package/esm/FeatureList.js +0 -16
- package/esm/FieldGroup.d.ts +0 -9
- package/esm/FieldGroup.js +0 -9
- package/esm/FileInput.d.ts +0 -17
- package/esm/FileInput.js +0 -154
- package/esm/Foonote.d.ts +0 -12
- package/esm/Foonote.js +0 -7
- package/esm/FooterBadges.d.ts +0 -9
- package/esm/FooterBadges.js +0 -12
- package/esm/FooterInfo.d.ts +0 -18
- package/esm/FooterInfo.js +0 -9
- package/esm/Footnote.d.ts +0 -6
- package/esm/Footnote.js +0 -3
- package/esm/Form.d.ts +0 -7
- package/esm/Form.js +0 -10
- package/esm/FormField.d.ts +0 -65
- package/esm/FormField.js +0 -91
- package/esm/Gallery/_GalleryItem.d.ts +0 -8
- package/esm/Gallery/_GalleryItem.js +0 -30
- package/esm/Gallery/_GalleryModal.d.ts +0 -6
- package/esm/Gallery/_GalleryModal.js +0 -54
- package/esm/Gallery/_GalleryModalContext.d.ts +0 -9
- package/esm/Gallery/_GalleryModalContext.js +0 -3
- package/esm/Gallery/_GalleryModalItem.d.ts +0 -3
- package/esm/Gallery/_GalleryModalItem.js +0 -22
- package/esm/Gallery.d.ts +0 -17
- package/esm/Gallery.js +0 -27
- package/esm/GridBlocks.d.ts +0 -26
- package/esm/GridBlocks.js +0 -24
- package/esm/Heading.d.ts +0 -16
- package/esm/Heading.js +0 -17
- package/esm/HeroBlock.d.ts +0 -19
- package/esm/HeroBlock.js +0 -21
- package/esm/IframeBlock.d.ts +0 -23
- package/esm/IframeBlock.js +0 -26
- package/esm/Illustration.d.ts +0 -13
- package/esm/Illustration.js +0 -8
- package/esm/ImageCards.d.ts +0 -8
- package/esm/ImageCards.js +0 -22
- package/esm/InfoBlock.d.ts +0 -17
- package/esm/InfoBlock.js +0 -13
- package/esm/InfoHero.d.ts +0 -17
- package/esm/InfoHero.js +0 -82
- package/esm/IslandBlock.d.ts +0 -25
- package/esm/IslandBlock.js +0 -16
- package/esm/IslandPageBlock.d.ts +0 -24
- package/esm/IslandPageBlock.js +0 -16
- package/esm/LabeledTextBlock.d.ts +0 -11
- package/esm/LabeledTextBlock.js +0 -14
- package/esm/Layout.d.ts +0 -33
- package/esm/Layout.js +0 -52
- package/esm/MainMenu/_Auxiliary.d.ts +0 -6
- package/esm/MainMenu/_Auxiliary.js +0 -13
- package/esm/MainMenu/_PrimaryPanel.d.ts +0 -13
- package/esm/MainMenu/_PrimaryPanel.js +0 -22
- package/esm/MainMenu.d.ts +0 -48
- package/esm/MainMenu.js +0 -136
- package/esm/MiniMetrics.d.ts +0 -8
- package/esm/MiniMetrics.js +0 -12
- package/esm/Modal.d.ts +0 -10
- package/esm/Modal.js +0 -14
- package/esm/NameCard.d.ts +0 -64
- package/esm/NameCard.js +0 -82
- package/esm/NameCards.d.ts +0 -6
- package/esm/NameCards.js +0 -7
- package/esm/NewsHero.d.ts +0 -14
- package/esm/NewsHero.js +0 -86
- package/esm/PageFilter.d.ts +0 -17
- package/esm/PageFilter.js +0 -15
- package/esm/PageHeading.d.ts +0 -10
- package/esm/PageHeading.js +0 -12
- package/esm/Picture.d.ts +0 -7
- package/esm/Picture.js +0 -8
- package/esm/ProcessOverview.d.ts +0 -13
- package/esm/ProcessOverview.js +0 -17
- package/esm/PullQuote.d.ts +0 -4
- package/esm/PullQuote.js +0 -4
- package/esm/RadioButtonsGroup.d.ts +0 -11
- package/esm/RadioButtonsGroup.js +0 -14
- package/esm/RadioGroup.d.ts +0 -13
- package/esm/RadioGroup.js +0 -7
- package/esm/RelatedLinks.d.ts +0 -20
- package/esm/RelatedLinks.js +0 -26
- package/esm/RowBlock.d.ts +0 -12
- package/esm/RowBlock.js +0 -9
- package/esm/RowBlockColumn.d.ts +0 -8
- package/esm/RowBlockColumn.js +0 -11
- package/esm/SearchInput.d.ts +0 -18
- package/esm/SearchInput.js +0 -33
- package/esm/SearchResults/_SearchResultsItem.d.ts +0 -18
- package/esm/SearchResults/_SearchResultsItem.js +0 -15
- package/esm/SearchResults.d.ts +0 -33
- package/esm/SearchResults.js +0 -109
- package/esm/SeenEffect.d.ts +0 -4
- package/esm/SeenEffect.js +0 -19
- package/esm/Selectbox.d.ts +0 -8
- package/esm/Selectbox.js +0 -46
- package/esm/ShareButtons.d.ts +0 -9
- package/esm/ShareButtons.js +0 -51
- package/esm/Sharpie.d.ts +0 -23
- package/esm/Sharpie.js +0 -22
- package/esm/SiteSearchAutocomplete.d.ts +0 -40
- package/esm/SiteSearchAutocomplete.js +0 -58
- package/esm/SiteSearchCurtain.d.ts +0 -6
- package/esm/SiteSearchCurtain.js +0 -33
- package/esm/SiteSearchInput.d.ts +0 -24
- package/esm/SiteSearchInput.js +0 -40
- package/esm/Skeleton.d.ts +0 -25
- package/esm/Skeleton.js +0 -30
- package/esm/SubHeading.d.ts +0 -10
- package/esm/SubHeading.js +0 -13
- package/esm/Tabs.d.ts +0 -35
- package/esm/Tabs.js +0 -94
- package/esm/TagPill.d.ts +0 -27
- package/esm/TagPill.js +0 -43
- package/esm/TextBlock.d.ts +0 -15
- package/esm/TextBlock.js +0 -15
- package/esm/TextButton.d.ts +0 -9
- package/esm/TextButton.js +0 -9
- package/esm/TextInput.d.ts +0 -16
- package/esm/TextInput.js +0 -35
- package/esm/VSpacer.d.ts +0 -24
- package/esm/VSpacer.js +0 -41
- package/esm/VerticalTabsTOC.d.ts +0 -14
- package/esm/VerticalTabsTOC.js +0 -68
- package/esm/WizardLayout.d.ts +0 -15
- package/esm/WizardLayout.js +0 -30
- package/esm/WizardLayoutClose.d.ts +0 -3
- package/esm/WizardLayoutClose.js +0 -4
- package/esm/WizardStepper.d.ts +0 -36
- package/esm/WizardStepper.js +0 -25
- package/esm/_abstract/_AbstractCarousel.d.ts +0 -25
- package/esm/_abstract/_AbstractCarousel.js +0 -130
- package/esm/_abstract/_Blings.d.ts +0 -11
- package/esm/_abstract/_Blings.js +0 -12
- package/esm/_abstract/_Block.d.ts +0 -22
- package/esm/_abstract/_Block.js +0 -24
- package/esm/_abstract/_Button.d.ts +0 -40
- package/esm/_abstract/_Button.js +0 -47
- package/esm/_abstract/_CardList.d.ts +0 -30
- package/esm/_abstract/_CardList.js +0 -38
- package/esm/_abstract/_Image.d.ts +0 -36
- package/esm/_abstract/_Image.js +0 -27
- package/esm/_abstract/_Link.d.ts +0 -27
- package/esm/_abstract/_Link.js +0 -24
- package/esm/_abstract/_Quote.d.ts +0 -9
- package/esm/_abstract/_Quote.js +0 -8
- package/esm/_abstract/_TogglerGroup.d.ts +0 -31
- package/esm/_abstract/_TogglerGroup.js +0 -29
- package/esm/_abstract/_TogglerGroupField.d.ts +0 -17
- package/esm/_abstract/_TogglerGroupField.js +0 -22
- package/esm/_abstract/_TogglerInput.d.ts +0 -22
- package/esm/_abstract/_TogglerInput.js +0 -33
- package/esm/_abstract/breakOnNL.d.ts +0 -2
- package/esm/_abstract/breakOnNL.js +0 -8
- package/esm/assets.d.ts +0 -42
- package/esm/assets.js +0 -56
- package/esm/constants.d.ts +0 -39
- package/esm/constants.js +0 -22
- package/esm/focus-visible.d.ts +0 -1
- package/esm/focus-visible.js +0 -1
- package/esm/package.json +0 -1
- package/esm/utils/env.d.ts +0 -1
- package/esm/utils/env.js +0 -8
- package/esm/utils/seenEffect.d.ts +0 -28
- package/esm/utils/seenEffect.js +0 -73
- package/esm/utils/useFormatMonitor.d.ts +0 -38
- package/esm/utils/useFormatMonitor.js +0 -41
- package/esm/utils/useGetSVGtext.d.ts +0 -6
- package/esm/utils/useGetSVGtext.js +0 -19
- package/esm/utils/useMenuToggling.d.ts +0 -8
- package/esm/utils/useMenuToggling.js +0 -62
- package/esm/utils/useScrollbarWidthCSSVar.d.ts +0 -1
- package/esm/utils/useScrollbarWidthCSSVar.js +0 -3
- package/esm/utils.d.ts +0 -2
- package/esm/utils.js +0 -2
package/esm/FeatureList.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Efnistakn } from '@reykjavik/hanna-utils/assets';
|
|
2
|
-
import { SeenProp } from './utils/seenEffect';
|
|
3
|
-
export declare type FeatureListProps = {
|
|
4
|
-
title: string;
|
|
5
|
-
features: Array<{
|
|
6
|
-
icon?: Efnistakn;
|
|
7
|
-
iconUrl?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}>;
|
|
10
|
-
} & SeenProp;
|
|
11
|
-
declare const FeatureList: (props: FeatureListProps) => JSX.Element;
|
|
12
|
-
export default FeatureList;
|
package/esm/FeatureList.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useSeenEffect } from './utils/seenEffect';
|
|
3
|
-
import Bling from './Bling';
|
|
4
|
-
const FeatureList = (props) => {
|
|
5
|
-
const { title, features, startSeen } = props;
|
|
6
|
-
const [ref] = useSeenEffect(startSeen);
|
|
7
|
-
const _features = features.length ? features : [{ name: '...' }];
|
|
8
|
-
return (React.createElement(React.Fragment, null,
|
|
9
|
-
React.createElement(Bling, { type: "snake-large", align: "left", vertical: "down-ish" }),
|
|
10
|
-
React.createElement("div", { className: "FeatureList", ref: ref },
|
|
11
|
-
React.createElement("h2", { className: "FeatureList__title" }, title),
|
|
12
|
-
React.createElement("ul", { className: "FeatureList__list" }, _features.map(({ name, icon, iconUrl }, i) => (React.createElement("li", { key: i, className: "FeatureList__feature", style: iconUrl
|
|
13
|
-
? { '--efnistakn': `url("${iconUrl}")` }
|
|
14
|
-
: undefined, "data-efnistakn": !iconUrl ? icon : undefined }, name)))))));
|
|
15
|
-
};
|
|
16
|
-
export default FeatureList;
|
package/esm/FieldGroup.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export declare type FieldGroupProps = {
|
|
3
|
-
legend: string;
|
|
4
|
-
disabled?: boolean;
|
|
5
|
-
className?: string;
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
};
|
|
8
|
-
declare const FieldGroup: (props: FieldGroupProps) => JSX.Element;
|
|
9
|
-
export default FieldGroup;
|
package/esm/FieldGroup.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
-
const FieldGroup = (props) => {
|
|
4
|
-
const { legend, children, className, disabled } = props;
|
|
5
|
-
return (React.createElement("fieldset", { className: getBemClass('FieldGroup', null, className), role: "group", disabled: disabled },
|
|
6
|
-
React.createElement("legend", { className: "FieldGroup__legend" }, legend),
|
|
7
|
-
children));
|
|
8
|
-
};
|
|
9
|
-
export default FieldGroup;
|
package/esm/FileInput.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FormFieldWrappingProps } from './FormField';
|
|
2
|
-
declare type dropzonePropsProps = {
|
|
3
|
-
accept?: string;
|
|
4
|
-
multiple?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare type FileInputProps = {
|
|
7
|
-
dropzoneProps: dropzonePropsProps;
|
|
8
|
-
dropzoneText: string | JSX.Element;
|
|
9
|
-
showFileSize?: boolean;
|
|
10
|
-
showImagePreviews?: boolean;
|
|
11
|
-
removeFileText: string;
|
|
12
|
-
onFilesUpdated?: (files: Array<File>) => void;
|
|
13
|
-
name?: string;
|
|
14
|
-
value?: ReadonlyArray<File>;
|
|
15
|
-
} & FormFieldWrappingProps;
|
|
16
|
-
declare const FileInput: (props: FileInputProps) => JSX.Element;
|
|
17
|
-
export default FileInput;
|
package/esm/FileInput.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
13
|
-
import { useDropzone } from 'react-dropzone'; // https://react-dropzone.js.org/#!/Dropzone
|
|
14
|
-
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
15
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
16
|
-
import FormField from './FormField';
|
|
17
|
-
/**
|
|
18
|
-
* Attaches a `preview` prop to file objects that don't already have a `preview` key defined
|
|
19
|
-
*
|
|
20
|
-
* The preview's value is either a data URI (for image-type files) or `undefined`
|
|
21
|
-
*/
|
|
22
|
-
const addPreview = (file) => {
|
|
23
|
-
if (!('preview' in file)) {
|
|
24
|
-
file.preview = file.type.includes('image/') ? URL.createObjectURL(file) : undefined;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Revokes `preview` data URIs to avoid memory leaks
|
|
29
|
-
*
|
|
30
|
-
* (See: https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL)
|
|
31
|
-
*/
|
|
32
|
-
const releasePreview = (file) => {
|
|
33
|
-
file.preview && URL.revokeObjectURL(file.preview);
|
|
34
|
-
delete file.preview;
|
|
35
|
-
};
|
|
36
|
-
const arrayToFileList = (arr) => {
|
|
37
|
-
const fileList = new DataTransfer();
|
|
38
|
-
arr.forEach((item) => {
|
|
39
|
-
fileList.items.add(item);
|
|
40
|
-
});
|
|
41
|
-
return fileList.files;
|
|
42
|
-
};
|
|
43
|
-
const dedupeFilesArray = (files) => {
|
|
44
|
-
const newArray = [];
|
|
45
|
-
const found = {};
|
|
46
|
-
files.forEach((file) => {
|
|
47
|
-
if (!(file.name in found)) {
|
|
48
|
-
newArray.push(file);
|
|
49
|
-
found[file.name] = true;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
releasePreview(file);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return newArray;
|
|
56
|
-
};
|
|
57
|
-
const formatBytes = (bytes, decimals = 2) => {
|
|
58
|
-
if (bytes === 0) {
|
|
59
|
-
return '0 Bytes';
|
|
60
|
-
}
|
|
61
|
-
const k = 1024;
|
|
62
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
63
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
64
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)) + ' ' + sizes[i];
|
|
65
|
-
};
|
|
66
|
-
const FileInput = (props) => {
|
|
67
|
-
const { className, id, label, hideLabel, dropzoneProps = { multiple: true }, dropzoneText, removeFileText, assistText, disabled, invalid, errorMessage, required, reqText, onFilesUpdated = () => undefined, showFileSize, showImagePreviews, value = [] } = props, inputElementProps = __rest(props, ["className", "id", "label", "hideLabel", "dropzoneProps", "dropzoneText", "removeFileText", "assistText", "disabled", "invalid", "errorMessage", "required", "reqText", "onFilesUpdated", "showFileSize", "showImagePreviews", "value"]);
|
|
68
|
-
const domid = useDomid(id);
|
|
69
|
-
const fileInputWrapper = useRef(null);
|
|
70
|
-
const fileInput = useRef(null);
|
|
71
|
-
const files = value;
|
|
72
|
-
const [isHover, setIsHover] = useState(false);
|
|
73
|
-
const { getRootProps, getInputProps, isDragReject, inputRef } = useDropzone(Object.assign({ onDrop: (acceptedFiles) => {
|
|
74
|
-
acceptedFiles = acceptedFiles.map((file) => {
|
|
75
|
-
addPreview(file);
|
|
76
|
-
return file;
|
|
77
|
-
});
|
|
78
|
-
addFiles(acceptedFiles); // eslint-disable-line
|
|
79
|
-
setIsHover(false);
|
|
80
|
-
}, onDropRejected: (rejectedFiles) => {
|
|
81
|
-
window.alert('Error:\n' +
|
|
82
|
-
rejectedFiles
|
|
83
|
-
.map((elm) => {
|
|
84
|
-
return elm.name;
|
|
85
|
-
})
|
|
86
|
-
.join(', '));
|
|
87
|
-
}, onDragEnter: () => {
|
|
88
|
-
// 'dragLeave' always fires right after 'dragEnter', use 'dragOver' instead
|
|
89
|
-
// console.log('enter');
|
|
90
|
-
// setIsHover(true);
|
|
91
|
-
}, onDragLeave: () => {
|
|
92
|
-
// console.log('leave');
|
|
93
|
-
setIsHover(false);
|
|
94
|
-
}, onDragOver: () => {
|
|
95
|
-
// TODO: add error icon? 'isDragReject' gives unstable results
|
|
96
|
-
// console.log(isDragReject);
|
|
97
|
-
setIsHover(true);
|
|
98
|
-
} }, dropzoneProps));
|
|
99
|
-
// Add previews on incoming files
|
|
100
|
-
// (NOTE: `addPreview` ignores files that already have preview.)
|
|
101
|
-
files.forEach(addPreview);
|
|
102
|
-
useEffect(() => () => {
|
|
103
|
-
// Make sure to revoke the data uris on unmount to avoid memory leaks
|
|
104
|
-
files.forEach(releasePreview);
|
|
105
|
-
}, [files]);
|
|
106
|
-
const removeFile = (name) => {
|
|
107
|
-
if (fileInput.current) {
|
|
108
|
-
const newFileList = files.filter((file) => {
|
|
109
|
-
if (file.name !== name) {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
releasePreview(file);
|
|
113
|
-
});
|
|
114
|
-
fileInput.current.files = arrayToFileList(newFileList);
|
|
115
|
-
onFilesUpdated(newFileList);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const addFiles = (filelist) => {
|
|
119
|
-
if (fileInput.current) {
|
|
120
|
-
const newFileList = dropzoneProps.multiple
|
|
121
|
-
? dedupeFilesArray(files.concat(filelist))
|
|
122
|
-
: filelist;
|
|
123
|
-
fileInput.current.files = arrayToFileList(newFileList);
|
|
124
|
-
onFilesUpdated(newFileList);
|
|
125
|
-
}
|
|
126
|
-
if (inputRef.current) {
|
|
127
|
-
// Empty on every add
|
|
128
|
-
inputRef.current.files = arrayToFileList([]);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
const filesList = files.map((file) => (React.createElement("li", { key: file.name, className: "FileInput__file" },
|
|
132
|
-
React.createElement("button", { className: "FileInput__file-remove", type: "button", onClick: () => removeFile(file.name), "aria-label": removeFileText }, removeFileText),
|
|
133
|
-
React.createElement("span", { className: "FileInput__fileinfo" },
|
|
134
|
-
showImagePreviews && file.preview && (React.createElement(React.Fragment, null,
|
|
135
|
-
React.createElement("span", { className: "FileInput__preview" },
|
|
136
|
-
React.createElement("img", { src: file.preview })),
|
|
137
|
-
' ')),
|
|
138
|
-
React.createElement("span", { className: "FileInput__filename" }, file.name),
|
|
139
|
-
showFileSize && (React.createElement("small", { className: "FileInput__filesize" },
|
|
140
|
-
" - (",
|
|
141
|
-
formatBytes(file.size),
|
|
142
|
-
")"))))));
|
|
143
|
-
return (React.createElement(FormField, { className: getBemClass('FileInput', [dropzoneProps.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 */) => {
|
|
144
|
-
return (React.createElement("div", { className: className.control, ref: fileInputWrapper },
|
|
145
|
-
React.createElement("input", { className: "FileInput__input", name: inputElementProps.name, id: domid, ref: fileInput, type: "file", style: { display: 'none' }, multiple: dropzoneProps.multiple || undefined, required: inputProps.required }),
|
|
146
|
-
' ',
|
|
147
|
-
React.createElement("input", Object.assign({ className: "FileInput__input--fake" }, getInputProps(), { tabIndex: undefined, style: undefined, multiple: dropzoneProps.multiple || undefined }, inputProps, { required: undefined })),
|
|
148
|
-
' ',
|
|
149
|
-
React.createElement("div", Object.assign({ className: getBemClass('FileInput__dropzone', [isHover && 'highlight']) }, getRootProps({ isDragReject }), { tabIndex: undefined }),
|
|
150
|
-
React.createElement("p", { className: "FileInput__droptext" }, dropzoneText)),
|
|
151
|
-
filesList.length ? React.createElement("ul", { className: "FileInput__filelist" }, filesList) : ''));
|
|
152
|
-
} }));
|
|
153
|
-
};
|
|
154
|
-
export default FileInput;
|
package/esm/Foonote.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FootnoteProps as _FootnoteProps } from './Footnote';
|
|
2
|
-
/** @deprecated (Will be removed in v0.11)
|
|
3
|
-
*
|
|
4
|
-
* This module file is a typo. import from `Footnote` instead
|
|
5
|
-
*/
|
|
6
|
-
export declare 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
|
-
declare const Footnote: (props: _FootnoteProps) => JSX.Element;
|
|
12
|
-
export default Footnote;
|
package/esm/Foonote.js
DELETED
package/esm/FooterBadges.d.ts
DELETED
package/esm/FooterBadges.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Link } from './_abstract/_Link';
|
|
3
|
-
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;
|
package/esm/FooterInfo.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BemPropsModifier } from '@hugsmidjan/react/types';
|
|
2
|
-
export declare type FooterInfoGroup = {
|
|
3
|
-
title: string;
|
|
4
|
-
role?: JSX.IntrinsicElements['div']['role'];
|
|
5
|
-
modifier?: string;
|
|
6
|
-
} & BemPropsModifier & ({
|
|
7
|
-
content: JSX.Element;
|
|
8
|
-
html?: undefined;
|
|
9
|
-
} | {
|
|
10
|
-
html: string;
|
|
11
|
-
content?: undefined;
|
|
12
|
-
});
|
|
13
|
-
export declare type FooterInfoBoxes = Array<FooterInfoGroup>;
|
|
14
|
-
export declare type FooterInfoProps = {
|
|
15
|
-
boxes: FooterInfoBoxes;
|
|
16
|
-
};
|
|
17
|
-
declare const FooterInfo: (props: FooterInfoProps) => JSX.Element;
|
|
18
|
-
export default FooterInfo;
|
package/esm/FooterInfo.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
-
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', group.modifier), role: group.role, key: i },
|
|
6
|
-
React.createElement("h3", { className: "FooterInfo__grouptitle" }, group.title),
|
|
7
|
-
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 } })))))));
|
|
8
|
-
};
|
|
9
|
-
export default FooterInfo;
|
package/esm/Footnote.d.ts
DELETED
package/esm/Footnote.js
DELETED
package/esm/Form.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { ComponentLayoutProps } from './constants';
|
|
3
|
-
export declare type FormProps = ComponentLayoutProps & React.FormHTMLAttributes<HTMLFormElement> & {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
};
|
|
6
|
-
declare const Form: (props: FormProps) => JSX.Element;
|
|
7
|
-
export default Form;
|
package/esm/Form.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
3
|
-
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;
|
package/esm/FormField.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
import { SSRSupport } from '@hugsmidjan/react/hooks';
|
|
3
|
-
declare 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 declare 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
|
-
declare type FocusEvents = {
|
|
23
|
-
onFocus?: (e: any) => void;
|
|
24
|
-
onBlur?: (e: any) => void;
|
|
25
|
-
};
|
|
26
|
-
declare type FocusPropMaker = <P extends FocusEvents>(ownProps?: P) => P & Required<FocusEvents>;
|
|
27
|
-
export declare 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 declare type FormFieldGroupWrappingProps = FormFieldWrappingProps & {
|
|
53
|
-
LabelTag?: 'h3' | 'h4' | 'h5';
|
|
54
|
-
};
|
|
55
|
-
export declare 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
|
-
declare const FormField: (props: FormFieldProps) => JSX.Element;
|
|
65
|
-
export default FormField;
|
package/esm/FormField.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import { useDomid, useIsBrowserSide } from '@hugsmidjan/react/hooks';
|
|
3
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
4
|
-
import { isPreact } from './utils/env';
|
|
5
|
-
const inputClassNames = {
|
|
6
|
-
bem: 'FormField',
|
|
7
|
-
input: 'FormField__input',
|
|
8
|
-
options: 'FormField__options',
|
|
9
|
-
control: 'FormField__control',
|
|
10
|
-
};
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
// eslint-disable-next-line complexity
|
|
13
|
-
const FormField = (props) => {
|
|
14
|
-
const { className, small, group, LabelTag = group ? 'h4' : undefined, label, assistText, hideLabel, empty, filled, readOnly, disabled, invalid, errorMessage, required, reqText, // i18n
|
|
15
|
-
renderInput, id, ssr, } = props;
|
|
16
|
-
const isBrowser = useIsBrowserSide(ssr);
|
|
17
|
-
const isInvalid = invalid || !!errorMessage || undefined;
|
|
18
|
-
const domid = useDomid(id);
|
|
19
|
-
const [focused, setFocused] = useState(false);
|
|
20
|
-
// @ts-expect-error (Duck knows why this errors?!)
|
|
21
|
-
const addFocusProps = useCallback((ownProps) => {
|
|
22
|
-
const { onFocus, onBlur } = ownProps || {};
|
|
23
|
-
const focusHandler = (e) => {
|
|
24
|
-
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
25
|
-
setFocused(true);
|
|
26
|
-
}
|
|
27
|
-
onFocus && onFocus(e);
|
|
28
|
-
};
|
|
29
|
-
const blurHandler = (e) => {
|
|
30
|
-
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
31
|
-
setFocused(false);
|
|
32
|
-
}
|
|
33
|
-
onBlur && onBlur(e);
|
|
34
|
-
};
|
|
35
|
-
const focusProps = Object.assign(Object.assign({}, ownProps), { onFocus: focusHandler, onBlur: blurHandler });
|
|
36
|
-
if (isPreact) {
|
|
37
|
-
const focusinHandler = (e) => {
|
|
38
|
-
e.currentTarget !== e.target && focusHandler(e);
|
|
39
|
-
};
|
|
40
|
-
const focusoutHandler = (e) => {
|
|
41
|
-
e.currentTarget !== e.target && blurHandler(e);
|
|
42
|
-
};
|
|
43
|
-
// @ts-expect-error (Sneak this in as Preact does not bubble `FocusEvent`s)
|
|
44
|
-
focusProps.onfocusin = focusinHandler;
|
|
45
|
-
// @ts-expect-error (Sneak this in as Preact does not bubble `FocusEvent`s)
|
|
46
|
-
focusProps.onfocusout = focusoutHandler;
|
|
47
|
-
}
|
|
48
|
-
return focusProps;
|
|
49
|
-
}, []);
|
|
50
|
-
const errorId = errorMessage ? 'error:' + domid : undefined;
|
|
51
|
-
const assistTextId = assistText ? 'assist:' + domid : undefined;
|
|
52
|
-
const labelId = LabelTag ? 'label:' + domid : undefined;
|
|
53
|
-
const reqStar = required && reqText !== false && (React.createElement("abbr", { className: 'FormField__label__reqstar',
|
|
54
|
-
// TODO: add mo-better i18n thinking
|
|
55
|
-
title: (reqText || 'Þarf að fylla út') + ': ' }, "*"));
|
|
56
|
-
const inputProps = {
|
|
57
|
-
id: domid,
|
|
58
|
-
disabled: disabled,
|
|
59
|
-
required: required,
|
|
60
|
-
readOnly: readOnly,
|
|
61
|
-
'aria-invalid': isInvalid,
|
|
62
|
-
'aria-describedby': assistTextId && errorId ? assistTextId + ' ' + errorId : assistTextId || errorId,
|
|
63
|
-
'aria-labelledby': labelId, // undefined if normalLabel
|
|
64
|
-
};
|
|
65
|
-
return (React.createElement("div", { className: getBemClass('FormField', [
|
|
66
|
-
small && 'small',
|
|
67
|
-
hideLabel && 'nolabel',
|
|
68
|
-
isInvalid && 'invalid',
|
|
69
|
-
disabled && 'disabled',
|
|
70
|
-
readOnly && 'readonly',
|
|
71
|
-
isBrowser && empty && 'empty',
|
|
72
|
-
isBrowser && filled && 'filled',
|
|
73
|
-
isBrowser && focused && 'focused',
|
|
74
|
-
], className), role: group ? 'group' : undefined, ref: props.wrapperRef },
|
|
75
|
-
LabelTag ? (React.createElement(LabelTag, { className: 'FormField__label', id: labelId },
|
|
76
|
-
' ',
|
|
77
|
-
reqStar,
|
|
78
|
-
" ",
|
|
79
|
-
label,
|
|
80
|
-
' ')) : (React.createElement("label", { className: 'FormField__label', htmlFor: domid },
|
|
81
|
-
' ',
|
|
82
|
-
reqStar,
|
|
83
|
-
" ",
|
|
84
|
-
label,
|
|
85
|
-
' ')),
|
|
86
|
-
' ',
|
|
87
|
-
renderInput(inputClassNames, inputProps, addFocusProps, isBrowser),
|
|
88
|
-
assistText && (React.createElement("div", { id: assistTextId, className: 'FormField__assist' }, assistText)),
|
|
89
|
-
errorMessage && (React.createElement("div", { id: errorId, className: 'FormField__error' }, errorMessage))));
|
|
90
|
-
};
|
|
91
|
-
export default FormField;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ImageProps } from '../_abstract/_Image';
|
|
2
|
-
export declare type GalleryItemProps = {
|
|
3
|
-
caption?: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
largeImageSrc?: string;
|
|
6
|
-
} & ImageProps;
|
|
7
|
-
declare const GalleryItem: (props: GalleryItemProps) => JSX.Element;
|
|
8
|
-
export default GalleryItem;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useContext } from 'react';
|
|
13
|
-
import Button from '../_abstract/_Button';
|
|
14
|
-
import Image from '../_abstract/_Image';
|
|
15
|
-
import GalleryModalContext from './_GalleryModalContext';
|
|
16
|
-
const GalleryItem = (props) => {
|
|
17
|
-
const { caption, description, largeImageSrc } = props, image = __rest(props, ["caption", "description", "largeImageSrc"]);
|
|
18
|
-
const { setCurrentImage } = useContext(GalleryModalContext);
|
|
19
|
-
return (React.createElement("figure", { className: "GalleryItem" },
|
|
20
|
-
React.createElement("figcaption", { className: "GalleryItem__caption" }, caption),
|
|
21
|
-
largeImageSrc ? (React.createElement(Button, { bem: "GalleryItem__button", href: largeImageSrc, onClick: (e) => {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
setCurrentImage(Object.assign(Object.assign({}, image), { caption, description, largeImageSrc }));
|
|
24
|
-
} },
|
|
25
|
-
' ',
|
|
26
|
-
React.createElement(Image, Object.assign({ className: "GalleryItem__image" }, image)),
|
|
27
|
-
' ')) : (React.createElement(Image, Object.assign({ className: "GalleryItem__image" }, image))),
|
|
28
|
-
description && React.createElement("div", { className: "GalleryItem__description" }, description)));
|
|
29
|
-
};
|
|
30
|
-
export default GalleryItem;
|
|
@@ -1,54 +0,0 @@
|
|
|
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';
|
|
7
|
-
import GalleryModalItem from './_GalleryModalItem';
|
|
8
|
-
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
|
-
};
|
|
54
|
-
export default GalleryModal;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { GalleryProps } from '../Gallery';
|
|
3
|
-
import { GalleryItemProps } from './_GalleryItem';
|
|
4
|
-
declare type ModalContextProps = {
|
|
5
|
-
setCurrentImage: (item: GalleryItemProps | undefined) => void;
|
|
6
|
-
currentImage: GalleryItemProps | undefined;
|
|
7
|
-
} & GalleryProps;
|
|
8
|
-
declare const GalleryModalContext: React.Context<ModalContextProps>;
|
|
9
|
-
export default GalleryModalContext;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import Image from '../_abstract/_Image';
|
|
14
|
-
const GalleryModalItem = (props) => {
|
|
15
|
-
const { caption, description } = props, image = __rest(props, ["caption", "description"]);
|
|
16
|
-
return (React.createElement("div", { className: "GalleryModalItem" },
|
|
17
|
-
(caption || description) && (React.createElement("div", { className: "GalleryModalItem__text" },
|
|
18
|
-
React.createElement("div", { className: "GalleryModalItem__caption" }, caption),
|
|
19
|
-
React.createElement("div", { className: "GalleryModalItem__description" }, description))),
|
|
20
|
-
React.createElement(Image, { className: "GalleryModalItem__image", src: image.largeImageSrc || image.src })));
|
|
21
|
-
};
|
|
22
|
-
export default GalleryModalItem;
|