@reykjavik/hanna-react 0.10.99 → 0.10.101
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 +2 -2
- package/ActionCards.d.ts +2 -1
- package/ActionCards.js +1 -1
- package/Alert.d.ts +2 -2
- package/Alert.js +20 -12
- package/ArticleCards.d.ts +4 -1
- package/ArticleCards.js +1 -1
- package/ArticleCarousel/_ArticleCarouselCard.js +1 -2
- package/ArticleCarousel.d.ts +2 -2
- package/ArticleCarousel.js +1 -1
- package/ArticleMeta.d.ts +2 -1
- package/ArticleMeta.js +2 -2
- package/Attention.d.ts +2 -1
- package/Attention.js +4 -1
- package/BasicTable.d.ts +2 -1
- package/BgBox.d.ts +2 -1
- package/BgBox.js +4 -2
- package/Bling.d.ts +2 -1
- package/Bling.js +5 -3
- package/BlockBreak.js +1 -0
- package/BreadCrumbs.d.ts +2 -1
- package/BreadCrumbs.js +3 -2
- package/ButtonBack.js +2 -0
- package/ButtonBar.d.ts +4 -3
- package/ButtonBar.js +3 -3
- package/ButtonPrimary.js +2 -0
- package/ButtonSecondary.js +2 -0
- package/ButtonTertiary.js +2 -0
- package/CHANGELOG.md +14 -1
- package/CarouselStepper.d.ts +2 -1
- package/CenterColumn.d.ts +2 -1
- package/CenterColumn.js +4 -2
- package/CheckboxButton.d.ts +4 -2
- package/CheckboxButtonsGroup.js +2 -2
- package/CityBlock.d.ts +2 -1
- package/CityBlock.js +1 -1
- package/ContactBubble.d.ts +2 -2
- package/ContactBubble.js +5 -4
- package/ContentArticle.d.ts +2 -1
- package/ContentArticle.js +3 -2
- package/ContentImage.d.ts +2 -1
- package/ContentImage.js +4 -3
- package/Datepicker.js +6 -6
- package/ExtraLinks.d.ts +2 -1
- package/ExtraLinks.js +4 -2
- package/FeatureList.d.ts +2 -1
- package/FeatureList.js +3 -2
- package/FieldGroup.d.ts +2 -1
- package/FieldGroup.js +4 -2
- package/FileInput.d.ts +2 -2
- package/FileInput.js +10 -5
- package/Foonote.js +3 -4
- package/Footnote.d.ts +2 -1
- package/Footnote.js +2 -1
- package/Form.js +4 -5
- package/FormField.d.ts +25 -5
- package/FormField.js +32 -7
- package/Gallery/_GalleryItem.js +2 -2
- package/Gallery/_GalleryModalItem.js +1 -1
- package/Gallery.d.ts +2 -2
- package/Gallery.js +5 -4
- package/GridBlocks.d.ts +2 -5
- package/GridBlocks.js +3 -3
- package/Heading.d.ts +2 -1
- package/Heading.js +3 -3
- package/HeroBlock.d.ts +2 -1
- package/HeroBlock.js +4 -3
- package/IframeBlock.d.ts +9 -4
- package/IframeBlock.js +13 -12
- package/Illustration.d.ts +2 -1
- package/Illustration.js +1 -1
- package/ImageCards.d.ts +2 -1
- package/ImageCards.js +2 -2
- package/InfoBlock.d.ts +2 -1
- package/InfoBlock.js +3 -2
- package/InfoHero.d.ts +2 -1
- package/InfoHero.js +3 -3
- package/IslandBlock.d.ts +2 -1
- package/IslandBlock.js +2 -2
- package/IslandPageBlock.d.ts +2 -1
- package/IslandPageBlock.js +2 -2
- package/LabeledTextBlock.d.ts +2 -1
- package/LabeledTextBlock.js +2 -2
- package/Layout.d.ts +2 -2
- package/Layout.js +3 -3
- package/MainMenu.d.ts +2 -2
- package/MainMenu.js +4 -3
- package/MiniMetrics.d.ts +2 -1
- package/MiniMetrics.js +3 -2
- package/Modal.d.ts +2 -1
- package/Multiselect.d.ts +11 -6
- package/Multiselect.js +15 -11
- package/NameCard.d.ts +2 -1
- package/NameCard.js +10 -6
- package/NameCards.d.ts +3 -2
- package/NameCards.js +3 -2
- package/NewsHero.d.ts +2 -1
- package/NewsHero.js +3 -3
- package/PageFilter.d.ts +2 -1
- package/PageFilter.js +2 -2
- package/PageHeading.d.ts +2 -1
- package/PageHeading.js +2 -5
- package/Picture.d.ts +2 -1
- package/Picture.js +1 -5
- package/ProcessOverview.d.ts +2 -1
- package/ProcessOverview.js +2 -5
- package/RadioButtonsGroup.js +2 -2
- package/RadioGroup.js +1 -1
- package/ReadSpeakerPlayer.d.ts +1 -1
- package/ReadSpeakerPlayer.js +2 -2
- package/RelatedLinks.d.ts +2 -1
- package/RelatedLinks.js +3 -2
- package/RowBlock.d.ts +2 -1
- package/RowBlock.js +2 -2
- package/RowBlockColumn.d.ts +2 -1
- package/RowBlockColumn.js +3 -3
- package/SearchInput.d.ts +3 -9
- package/SearchInput.js +4 -5
- package/SearchResults/_SearchResultsItem.js +1 -1
- package/SearchResults.d.ts +2 -1
- package/SearchResults.js +2 -2
- package/SeenEffect.js +2 -0
- package/Selectbox.js +3 -4
- package/ShareButtons.d.ts +2 -2
- package/ShareButtons.js +5 -3
- package/Sharpie.d.ts +2 -1
- package/Sharpie.js +2 -2
- package/SiteSearchAutocomplete.d.ts +2 -1
- package/SiteSearchAutocomplete.js +4 -4
- package/SiteSearchCurtain.js +2 -0
- package/SiteSearchInput.d.ts +3 -6
- package/SiteSearchInput.js +4 -4
- package/Skeleton.d.ts +4 -1
- package/Skeleton.js +15 -18
- package/SubHeading.d.ts +2 -1
- package/SubHeading.js +3 -3
- package/Tabs.d.ts +2 -2
- package/Tabs.js +5 -5
- package/TagPill.js +2 -0
- package/TextBlock.d.ts +2 -1
- package/TextBlock.js +3 -3
- package/TextButton.js +2 -0
- package/TextInput.d.ts +2 -2
- package/TextInput.js +3 -4
- package/Tooltip.d.ts +2 -1
- package/Tooltip.js +28 -15
- package/VSpacer.d.ts +2 -1
- package/VSpacer.js +3 -7
- package/VerticalTabsTOC.d.ts +1 -1
- package/VerticalTabsTOC.js +1 -1
- package/WizardLayout.d.ts +2 -2
- package/WizardLayout.js +4 -3
- package/WizardLayoutClose.js +2 -0
- package/WizardStepper.d.ts +2 -1
- package/WizardStepper.js +2 -2
- package/_abstract/_AbstractCarousel.d.ts +2 -2
- package/_abstract/_AbstractCarousel.js +6 -3
- package/_abstract/_Block.d.ts +2 -1
- package/_abstract/_Block.js +3 -3
- package/_abstract/_Button.js +4 -1
- package/_abstract/_CardList.d.ts +3 -1
- package/_abstract/_CardList.js +6 -3
- package/_abstract/_Image.d.ts +6 -3
- package/_abstract/_Image.js +11 -4
- package/_abstract/_Quote.d.ts +2 -1
- package/_abstract/_Quote.js +3 -2
- package/_abstract/_TogglerGroup.js +1 -1
- package/_abstract/_TogglerGroupField.js +5 -5
- package/_abstract/_TogglerInput.d.ts +2 -2
- package/_abstract/_TogglerInput.js +4 -2
- package/esm/AccordionList.d.ts +2 -2
- package/esm/AccordionList.js +3 -3
- package/esm/ActionCards.d.ts +2 -1
- package/esm/ActionCards.js +1 -1
- package/esm/Alert.d.ts +2 -2
- package/esm/Alert.js +21 -13
- package/esm/ArticleCards.d.ts +4 -1
- package/esm/ArticleCards.js +1 -1
- package/esm/ArticleCarousel/_ArticleCarouselCard.js +1 -2
- package/esm/ArticleCarousel.d.ts +2 -2
- package/esm/ArticleCarousel.js +1 -1
- package/esm/ArticleMeta.d.ts +2 -1
- package/esm/ArticleMeta.js +2 -2
- package/esm/Attention.d.ts +2 -1
- package/esm/Attention.js +4 -1
- package/esm/BasicTable.d.ts +2 -1
- package/esm/BgBox.d.ts +2 -1
- package/esm/BgBox.js +4 -2
- package/esm/Bling.d.ts +2 -1
- package/esm/Bling.js +5 -3
- package/esm/BlockBreak.js +1 -0
- package/esm/BreadCrumbs.d.ts +2 -1
- package/esm/BreadCrumbs.js +3 -2
- package/esm/ButtonBack.js +2 -0
- package/esm/ButtonBar.d.ts +4 -3
- package/esm/ButtonBar.js +3 -3
- package/esm/ButtonPrimary.js +2 -0
- package/esm/ButtonSecondary.js +2 -0
- package/esm/ButtonTertiary.js +2 -0
- package/esm/CarouselStepper.d.ts +2 -1
- package/esm/CenterColumn.d.ts +2 -1
- package/esm/CenterColumn.js +4 -2
- package/esm/CheckboxButton.d.ts +4 -2
- package/esm/CheckboxButtonsGroup.js +2 -2
- package/esm/CityBlock.d.ts +2 -1
- package/esm/CityBlock.js +1 -1
- package/esm/ContactBubble.d.ts +2 -2
- package/esm/ContactBubble.js +5 -4
- package/esm/ContentArticle.d.ts +2 -1
- package/esm/ContentArticle.js +3 -2
- package/esm/ContentImage.d.ts +2 -1
- package/esm/ContentImage.js +4 -3
- package/esm/Datepicker.js +7 -7
- package/esm/ExtraLinks.d.ts +2 -1
- package/esm/ExtraLinks.js +4 -2
- package/esm/FeatureList.d.ts +2 -1
- package/esm/FeatureList.js +3 -2
- package/esm/FieldGroup.d.ts +2 -1
- package/esm/FieldGroup.js +4 -2
- package/esm/FileInput.d.ts +2 -2
- package/esm/FileInput.js +10 -5
- package/esm/Foonote.js +2 -2
- package/esm/Footnote.d.ts +2 -1
- package/esm/Footnote.js +2 -1
- package/esm/Form.js +5 -5
- package/esm/FormField.d.ts +25 -5
- package/esm/FormField.js +30 -6
- package/esm/Gallery/_GalleryItem.js +2 -2
- package/esm/Gallery/_GalleryModalItem.js +1 -1
- package/esm/Gallery.d.ts +2 -2
- package/esm/Gallery.js +6 -5
- package/esm/GridBlocks.d.ts +2 -5
- package/esm/GridBlocks.js +3 -3
- package/esm/Heading.d.ts +2 -1
- package/esm/Heading.js +3 -3
- package/esm/HeroBlock.d.ts +2 -1
- package/esm/HeroBlock.js +4 -3
- package/esm/IframeBlock.d.ts +9 -4
- package/esm/IframeBlock.js +13 -12
- package/esm/Illustration.d.ts +2 -1
- package/esm/Illustration.js +1 -1
- package/esm/ImageCards.d.ts +2 -1
- package/esm/ImageCards.js +2 -2
- package/esm/InfoBlock.d.ts +2 -1
- package/esm/InfoBlock.js +3 -2
- package/esm/InfoHero.d.ts +2 -1
- package/esm/InfoHero.js +3 -3
- package/esm/IslandBlock.d.ts +2 -1
- package/esm/IslandBlock.js +2 -2
- package/esm/IslandPageBlock.d.ts +2 -1
- package/esm/IslandPageBlock.js +2 -2
- package/esm/LabeledTextBlock.d.ts +2 -1
- package/esm/LabeledTextBlock.js +2 -2
- package/esm/Layout.d.ts +2 -2
- package/esm/Layout.js +3 -3
- package/esm/MainMenu.d.ts +2 -2
- package/esm/MainMenu.js +4 -3
- package/esm/MiniMetrics.d.ts +2 -1
- package/esm/MiniMetrics.js +3 -2
- package/esm/Modal.d.ts +2 -1
- package/esm/Multiselect.d.ts +11 -6
- package/esm/Multiselect.js +15 -11
- package/esm/NameCard.d.ts +2 -1
- package/esm/NameCard.js +10 -6
- package/esm/NameCards.d.ts +3 -2
- package/esm/NameCards.js +3 -2
- package/esm/NewsHero.d.ts +2 -1
- package/esm/NewsHero.js +3 -3
- package/esm/PageFilter.d.ts +2 -1
- package/esm/PageFilter.js +2 -2
- package/esm/PageHeading.d.ts +2 -1
- package/esm/PageHeading.js +2 -5
- package/esm/Picture.d.ts +2 -1
- package/esm/Picture.js +1 -5
- package/esm/ProcessOverview.d.ts +2 -1
- package/esm/ProcessOverview.js +2 -5
- package/esm/RadioButtonsGroup.js +2 -2
- package/esm/RadioGroup.js +1 -1
- package/esm/ReadSpeakerPlayer.d.ts +1 -1
- package/esm/ReadSpeakerPlayer.js +2 -2
- package/esm/RelatedLinks.d.ts +2 -1
- package/esm/RelatedLinks.js +3 -2
- package/esm/RowBlock.d.ts +2 -1
- package/esm/RowBlock.js +2 -2
- package/esm/RowBlockColumn.d.ts +2 -1
- package/esm/RowBlockColumn.js +3 -3
- package/esm/SearchInput.d.ts +3 -9
- package/esm/SearchInput.js +4 -5
- package/esm/SearchResults/_SearchResultsItem.js +1 -1
- package/esm/SearchResults.d.ts +2 -1
- package/esm/SearchResults.js +2 -2
- package/esm/SeenEffect.js +2 -0
- package/esm/Selectbox.js +3 -4
- package/esm/ShareButtons.d.ts +2 -2
- package/esm/ShareButtons.js +5 -3
- package/esm/Sharpie.d.ts +2 -1
- package/esm/Sharpie.js +2 -2
- package/esm/SiteSearchAutocomplete.d.ts +2 -1
- package/esm/SiteSearchAutocomplete.js +4 -4
- package/esm/SiteSearchCurtain.js +2 -0
- package/esm/SiteSearchInput.d.ts +3 -6
- package/esm/SiteSearchInput.js +4 -4
- package/esm/Skeleton.d.ts +4 -1
- package/esm/Skeleton.js +15 -18
- package/esm/SubHeading.d.ts +2 -1
- package/esm/SubHeading.js +3 -3
- package/esm/Tabs.d.ts +2 -2
- package/esm/Tabs.js +5 -5
- package/esm/TagPill.js +2 -0
- package/esm/TextBlock.d.ts +2 -1
- package/esm/TextBlock.js +3 -3
- package/esm/TextButton.js +2 -0
- package/esm/TextInput.d.ts +2 -2
- package/esm/TextInput.js +3 -4
- package/esm/Tooltip.d.ts +2 -1
- package/esm/Tooltip.js +28 -15
- package/esm/VSpacer.d.ts +2 -1
- package/esm/VSpacer.js +3 -7
- package/esm/VerticalTabsTOC.d.ts +1 -1
- package/esm/VerticalTabsTOC.js +1 -1
- package/esm/WizardLayout.d.ts +2 -2
- package/esm/WizardLayout.js +4 -3
- package/esm/WizardLayoutClose.js +2 -0
- package/esm/WizardStepper.d.ts +2 -1
- package/esm/WizardStepper.js +2 -2
- package/esm/_abstract/_AbstractCarousel.d.ts +2 -2
- package/esm/_abstract/_AbstractCarousel.js +6 -3
- package/esm/_abstract/_Block.d.ts +2 -1
- package/esm/_abstract/_Block.js +3 -3
- package/esm/_abstract/_Button.js +4 -1
- package/esm/_abstract/_CardList.d.ts +3 -1
- package/esm/_abstract/_CardList.js +6 -3
- package/esm/_abstract/_Image.d.ts +6 -3
- package/esm/_abstract/_Image.js +12 -5
- package/esm/_abstract/_Quote.d.ts +2 -1
- package/esm/_abstract/_Quote.js +3 -2
- package/esm/_abstract/_TogglerGroup.js +1 -1
- package/esm/_abstract/_TogglerGroupField.js +5 -5
- package/esm/_abstract/_TogglerInput.d.ts +2 -2
- package/esm/_abstract/_TogglerInput.js +4 -2
- package/esm/utils.d.ts +25 -2
- package/package.json +1 -1
- package/utils.d.ts +25 -2
package/WizardLayoutClose.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.WizardLayoutClose = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const _Button_js_1 = require("./_abstract/_Button.js");
|
|
7
|
+
// NOTE: As a `_abstract/_Button.tsx`-derived component, all `<button/>` and
|
|
8
|
+
// `<a/>` props are allowed directly, so adding `wrapperProps` makes no sense.
|
|
7
9
|
const WizardLayoutClose = (props) => (react_1.default.createElement(_Button_js_1.Button, Object.assign({ bem: "WizardLayoutClose" }, props)));
|
|
8
10
|
exports.WizardLayoutClose = WizardLayoutClose;
|
|
9
11
|
exports.default = exports.WizardLayoutClose;
|
package/WizardStepper.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WrapperElmProps } from './utils.js';
|
|
1
2
|
export type WizardStepperStep = {
|
|
2
3
|
label: string;
|
|
3
4
|
/**
|
|
@@ -31,6 +32,6 @@ export type WizardStepperProps = {
|
|
|
31
32
|
/** By default, clickable steps after the active step are not immediately clickable */
|
|
32
33
|
allowForwardSkip?: boolean;
|
|
33
34
|
onClick: (clickedIndex: number) => void;
|
|
34
|
-
};
|
|
35
|
+
} & WrapperElmProps;
|
|
35
36
|
export declare const WizardStepper: (props: WizardStepperProps) => JSX.Element;
|
|
36
37
|
export default WizardStepper;
|
package/WizardStepper.js
CHANGED
|
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
7
7
|
const WizardStepper = (props) => {
|
|
8
|
-
const { steps, activeStep = -1, allowForwardSkip, disableBacktrack, onClick } = props;
|
|
9
|
-
return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)('WizardStepper', activeStep === -1 && 'preview') }, steps.map((step, i) => {
|
|
8
|
+
const { steps, activeStep = -1, allowForwardSkip, disableBacktrack, onClick, wrapperProps, } = props;
|
|
9
|
+
return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)('WizardStepper', activeStep === -1 && 'preview', (wrapperProps || {}).className) }), steps.map((step, i) => {
|
|
10
10
|
const { clickable, done, neutral } = step;
|
|
11
11
|
const label = step.label || '…';
|
|
12
12
|
const stepClass = (0, classUtils_1.modifiedClass)('WizardStepper__step', [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
|
-
import { SSRSupportProps } from '../utils.js';
|
|
3
|
+
import { SSRSupportProps, WrapperElmProps } from '../utils.js';
|
|
4
4
|
import { SeenProp } from '../utils/seenEffect.js';
|
|
5
5
|
import { BemProps } from '../utils/types.js';
|
|
6
6
|
export type CarouselProps<I extends Record<string, unknown> = {}, P extends Record<string, unknown> | undefined = {}> = {
|
|
@@ -20,7 +20,7 @@ export type CarouselProps<I extends Record<string, unknown> = {}, P extends Reco
|
|
|
20
20
|
* `<Fragment />` or some such.
|
|
21
21
|
*/
|
|
22
22
|
itemCount?: number;
|
|
23
|
-
}> & SeenProp;
|
|
23
|
+
}> & WrapperElmProps & SeenProp;
|
|
24
24
|
type AbstractCarouselProps<I extends Record<string, unknown> = Record<string, unknown>, P extends Record<string, unknown> | undefined = Record<string, unknown>> = CarouselProps<I, P> & BemProps & {
|
|
25
25
|
title?: string;
|
|
26
26
|
};
|
|
@@ -23,15 +23,16 @@ const scrollXBy = (elm, deltaX) => {
|
|
|
23
23
|
// NOTE 2: Both Chrome and Safari tend to snap hard to the nearest list item
|
|
24
24
|
// while Firefox is more smooth. Haven't found a way around that.
|
|
25
25
|
};
|
|
26
|
+
// eslint-disable-next-line complexity
|
|
26
27
|
const AbstractCarousel = (props) => {
|
|
27
|
-
const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, } = props;
|
|
28
|
+
const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, className, wrapperProps, } = props;
|
|
28
29
|
const children = !props.children
|
|
29
30
|
? undefined
|
|
30
31
|
: Array.isArray(props.children)
|
|
31
32
|
? props.children.filter(hanna_utils_1.notNully)
|
|
32
33
|
: [props.children];
|
|
33
34
|
const [leftOffset, setLeftOffset] = (0, react_1.useState)();
|
|
34
|
-
const itemCount = props.itemCount
|
|
35
|
+
const itemCount = props.itemCount != null ? props.itemCount : (children || items).length;
|
|
35
36
|
const listRef = (0, react_1.useRef)(null);
|
|
36
37
|
const [activeItem, setActiveItem] = (0, react_1.useState)(0);
|
|
37
38
|
const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
|
|
@@ -96,7 +97,9 @@ const AbstractCarousel = (props) => {
|
|
|
96
97
|
items.map((item, i) => (
|
|
97
98
|
// @ts-expect-error (Can't be arsed...)
|
|
98
99
|
react_1.default.createElement(Component, Object.assign({ key: i }, ComponentProps, item))))));
|
|
99
|
-
return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)(bem, modifier,
|
|
100
|
+
return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier,
|
|
101
|
+
// Prefer `className` over `wrapperProps.className`
|
|
102
|
+
className || (wrapperProps || {}).className), ref: outerRef, "data-sprinkled": isBrowser }),
|
|
100
103
|
title && react_1.default.createElement("h2", { className: bem + '__title' }, title),
|
|
101
104
|
isBrowser ? (react_1.default.createElement("div", { className: bem + '__itemlist-wrapper' },
|
|
102
105
|
itemList,
|
package/_abstract/_Block.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WrapperElmProps } from '../utils.js';
|
|
1
2
|
import { SeenProp } from '../utils/seenEffect.js';
|
|
2
3
|
import { BemModifierProps } from '../utils/types.js';
|
|
3
4
|
import { ButtonProps } from './_Button.js';
|
|
@@ -15,7 +16,7 @@ export type ContentBlock = {
|
|
|
15
16
|
content: Array<BlockItem>;
|
|
16
17
|
image?: undefined;
|
|
17
18
|
} & SeenProp;
|
|
18
|
-
export type BlockProps =
|
|
19
|
+
export type BlockProps = (ContentBlock | ContentImageBlock) & BemModifierProps & WrapperElmProps;
|
|
19
20
|
export declare const Block: (props: BlockProps & {
|
|
20
21
|
bem: string;
|
|
21
22
|
}) => JSX.Element;
|
package/_abstract/_Block.js
CHANGED
|
@@ -8,10 +8,10 @@ const seenEffect_js_1 = require("../utils/seenEffect.js");
|
|
|
8
8
|
const _Button_js_1 = require("./_Button.js");
|
|
9
9
|
const _Image_js_1 = require("./_Image.js");
|
|
10
10
|
const Block = (props) => {
|
|
11
|
-
const { image, modifier, bem, content, startSeen } = props;
|
|
11
|
+
const { image, modifier, bem, content, startSeen, wrapperProps } = props;
|
|
12
12
|
const [ref] = (0, seenEffect_js_1.useSeenEffect)(startSeen);
|
|
13
13
|
const contentItems = Array.isArray(content) ? content : [content];
|
|
14
|
-
return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)(bem, modifier), ref: ref },
|
|
14
|
+
return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier, (wrapperProps || {}).className), ref: ref }),
|
|
15
15
|
contentItems.map(({ title, summary, buttons = [] }, i) => {
|
|
16
16
|
const hasSummary = summary && (typeof summary !== 'string' || !!summary.trim());
|
|
17
17
|
return (react_1.default.createElement("div", { key: i, className: `${bem}__content` },
|
|
@@ -23,6 +23,6 @@ const Block = (props) => {
|
|
|
23
23
|
react_1.default.createElement(_Button_js_1.Button, Object.assign({ bem: `${bem}__button`, key: i }, buttonProps)),
|
|
24
24
|
' ')))))));
|
|
25
25
|
}),
|
|
26
|
-
image && react_1.default.createElement(_Image_js_1.Image, Object.assign({
|
|
26
|
+
image && react_1.default.createElement(_Image_js_1.Image, Object.assign({ bem: `${bem}__image` }, image))));
|
|
27
27
|
};
|
|
28
28
|
exports.Block = Block;
|
package/_abstract/_Button.js
CHANGED
|
@@ -25,8 +25,11 @@ const icons = {
|
|
|
25
25
|
// TODO: insert icons
|
|
26
26
|
edit: 'edit',
|
|
27
27
|
};
|
|
28
|
+
// NOTE: As this component already accepts all `<button/>` and `<a/>` props
|
|
29
|
+
// directly, it makes little sense to add support for `wrapperProps` on top.
|
|
28
30
|
const Button = (props) => {
|
|
29
|
-
const { bem, small,
|
|
31
|
+
const { bem, small, // eslint-disable-line deprecation/deprecation
|
|
32
|
+
size = small ? 'small' : 'normal', modifier, children, variant = 'normal', icon = 'none', label = children } = props, buttonProps = tslib_1.__rest(props, ["bem", "small", "size", "modifier", "children", "variant", "icon", "label"]);
|
|
30
33
|
const className = bem &&
|
|
31
34
|
(0, classUtils_1.modifiedClass)(bem, [modifier, variants[variant], sizes[size], navigationFlags[icon]]);
|
|
32
35
|
const iconProp = icons[icon] && { 'data-icon': icons[icon] };
|
package/_abstract/_CardList.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
|
+
import { WrapperElmProps } from '../utils.js';
|
|
4
|
+
import { BemModifierProps } from '../utils/types.js';
|
|
3
5
|
import { ImageProps } from './_Image.js';
|
|
4
6
|
export type TextCardProps = {
|
|
5
7
|
title: string;
|
|
@@ -28,6 +30,6 @@ type _CardListProps = EitherObj<ImageCardListProps, TextCardListProps> & CardLis
|
|
|
28
30
|
bemPrefix: string;
|
|
29
31
|
children?: ReactNode;
|
|
30
32
|
standalone?: boolean;
|
|
31
|
-
};
|
|
33
|
+
} & WrapperElmProps<'ul'> & BemModifierProps;
|
|
32
34
|
export declare const CardList: (props: _CardListProps) => JSX.Element;
|
|
33
35
|
export {};
|
package/_abstract/_CardList.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CardList = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
6
7
|
const _Button_js_1 = require("./_Button.js");
|
|
7
8
|
const _Image_js_1 = require("./_Image.js");
|
|
8
9
|
const Card = (props) => {
|
|
@@ -11,7 +12,7 @@ const Card = (props) => {
|
|
|
11
12
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
12
13
|
react_1.default.createElement(_Button_js_1.Button, { bem: cardClass, href: href, target: target },
|
|
13
14
|
' ',
|
|
14
|
-
!!(image || imgPlaceholder) && (react_1.default.createElement(_Image_js_1.Image, Object.assign({
|
|
15
|
+
!!(image || imgPlaceholder) && (react_1.default.createElement(_Image_js_1.Image, Object.assign({ bem: `${bem}__image` }, image, { placeholder: imgPlaceholder }))),
|
|
15
16
|
react_1.default.createElement("span", { className: `${cardClass}__title` }, title),
|
|
16
17
|
' ',
|
|
17
18
|
meta && react_1.default.createElement("span", { className: `${cardClass}__meta` }, meta),
|
|
@@ -21,7 +22,7 @@ const Card = (props) => {
|
|
|
21
22
|
' '));
|
|
22
23
|
};
|
|
23
24
|
const CardList = (props) => {
|
|
24
|
-
const { bemPrefix, title, summaryElement, cards, titleTag = 'h2', children, imgPlaceholder, } = props;
|
|
25
|
+
const { bemPrefix, modifier, title, summaryElement, cards, titleTag = 'h2', children, imgPlaceholder, wrapperProps, } = props;
|
|
25
26
|
const TitleTag = titleTag;
|
|
26
27
|
const fallbackImageUrl = (imgPlaceholder !== true && imgPlaceholder) || undefined;
|
|
27
28
|
const fallbackImageStyle = fallbackImageUrl
|
|
@@ -33,7 +34,9 @@ const CardList = (props) => {
|
|
|
33
34
|
summaryElement ? (react_1.default.createElement("div", { className: bemPrefix + '__summary' },
|
|
34
35
|
title && react_1.default.createElement(TitleTag, { className: bemPrefix + '__title' }, title),
|
|
35
36
|
summaryElement)) : (title && react_1.default.createElement(TitleTag, { className: bemPrefix + '__title' }, title)),
|
|
36
|
-
react_1.default.createElement("ul", {
|
|
37
|
+
react_1.default.createElement("ul", Object.assign({}, wrapperProps, { className: props.standalone
|
|
38
|
+
? (0, classUtils_1.modifiedClass)(bemPrefix, modifier, (wrapperProps || {}).className)
|
|
39
|
+
: bemPrefix + '__list', style: fallbackImageStyle }), cards.map((card, i) => (react_1.default.createElement("li", { key: i, className: bemPrefix + '__item' },
|
|
37
40
|
react_1.default.createElement(Card
|
|
38
41
|
/* Assert as `ImageCardProps` to silence the imgPlaceholder false-positive */
|
|
39
42
|
, Object.assign({}, card, { bem: bemPrefix, imgPlaceholder: !!imgPlaceholder })))))),
|
package/_abstract/_Image.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { WrapperElmProps } from '../utils.js';
|
|
2
|
+
import { BemProps } from '../utils/types.js';
|
|
1
3
|
export type Source = {
|
|
2
4
|
srcset: string;
|
|
3
5
|
media: string;
|
|
@@ -23,14 +25,15 @@ export type ImagePropsInlinedSvg = {
|
|
|
23
25
|
};
|
|
24
26
|
export type ImageProps = ImagePropsLinked | ImagePropsInlinedSvg;
|
|
25
27
|
type _ImageProps = {
|
|
26
|
-
/** container className */
|
|
27
|
-
className: string | undefined;
|
|
28
28
|
/** Controls if the container is rendered when image is missing/undefined.
|
|
29
29
|
* (With a `--missing` className modifier added.)
|
|
30
30
|
*
|
|
31
31
|
* Accepts a function that defines a default content for the container.
|
|
32
32
|
*/
|
|
33
33
|
placeholder?: boolean | (() => JSX.Element);
|
|
34
|
-
|
|
34
|
+
/** Extra, custom className in addition to the `bem` base */
|
|
35
|
+
className?: string | undefined;
|
|
36
|
+
bem: string | undefined;
|
|
37
|
+
} & BemProps & WrapperElmProps;
|
|
35
38
|
export declare const Image: (props: ImageProps & _ImageProps) => JSX.Element | null;
|
|
36
39
|
export {};
|
package/_abstract/_Image.js
CHANGED
|
@@ -7,19 +7,26 @@ const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
|
7
7
|
const useGetSVGtext_js_1 = require("../utils/useGetSVGtext.js");
|
|
8
8
|
// eslint-disable-next-line complexity
|
|
9
9
|
const Image = (props) => {
|
|
10
|
-
const { src, altText = '', sources = [], preloadSrc,
|
|
10
|
+
const { src, altText = '', sources = [], preloadSrc, modifier, bem, inline, placeholder, focalPoint, className, wrapperProps = {}, } = props;
|
|
11
11
|
const _src = (sources.length && preloadSrc) || src;
|
|
12
12
|
const imageSrc = _src || (sources[0] != null ? sources[0].srcset.split(' ')[0] : undefined);
|
|
13
13
|
const imgLoading = preloadSrc ? 'eager' : 'lazy';
|
|
14
14
|
const inlineSvg = (0, useGetSVGtext_js_1.useGetSVGtext)(inline ? imageSrc : undefined, altText);
|
|
15
|
+
const extraClasses = (0, classUtils_1.classes)(className, wrapperProps.className) || undefined;
|
|
16
|
+
const classNames = bem
|
|
17
|
+
? (0, classUtils_1.modifiedClass)(bem, [modifier, !imageSrc && 'missing'], extraClasses)
|
|
18
|
+
: extraClasses;
|
|
15
19
|
if (!imageSrc) {
|
|
16
|
-
return placeholder ? (react_1.default.createElement("span", {
|
|
20
|
+
return placeholder ? (react_1.default.createElement("span", Object.assign({}, props.wrapperProps, { className: classNames }), placeholder !== true && placeholder())) : null;
|
|
17
21
|
}
|
|
18
22
|
if (inline && inlineSvg) {
|
|
19
23
|
const __html = inlineSvg.imageSrc === imageSrc ? inlineSvg.code : '';
|
|
20
|
-
return react_1.default.createElement("span", { className:
|
|
24
|
+
return (react_1.default.createElement("span", Object.assign({}, props.wrapperProps, { className: classNames, dangerouslySetInnerHTML: { __html } })));
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
const wrapperStyles = wrapperProps.style;
|
|
27
|
+
return (react_1.default.createElement("picture", Object.assign({}, props.wrapperProps, { className: classNames, style: focalPoint
|
|
28
|
+
? Object.assign(Object.assign({}, wrapperStyles), { '--focalPoint': focalPoint })
|
|
29
|
+
: wrapperStyles }),
|
|
23
30
|
' ',
|
|
24
31
|
sources.map((source, i) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
25
32
|
react_1.default.createElement("source", { key: i, srcSet: source.srcset, media: source.media }),
|
package/_abstract/_Quote.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
|
+
import { WrapperElmProps } from '../utils.js';
|
|
3
4
|
export type QuoteProps = {
|
|
4
5
|
children: ReactNode;
|
|
5
|
-
} & EitherObj<object, {
|
|
6
|
+
} & WrapperElmProps & EitherObj<object, {
|
|
6
7
|
by: string | JSX.Element;
|
|
7
8
|
byHref?: string;
|
|
8
9
|
}>;
|
package/_abstract/_Quote.js
CHANGED
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._Quote = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
6
7
|
const _Link_js_1 = require("./_Link.js");
|
|
7
8
|
const _Quote = (props) => {
|
|
8
|
-
const { bem, children, by, byHref } = props;
|
|
9
|
-
return (react_1.default.createElement("figure", { className: bem },
|
|
9
|
+
const { bem, children, by, byHref, wrapperProps } = props;
|
|
10
|
+
return (react_1.default.createElement("figure", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, null, (wrapperProps || {}).className) }),
|
|
10
11
|
react_1.default.createElement("blockquote", { className: bem + '__quote' }, children),
|
|
11
12
|
by && (react_1.default.createElement("figcaption", { className: bem + '__by' }, byHref ? (react_1.default.createElement(_Link_js_1.Link, { href: byHref }, by)) : typeof by === 'string' ? (react_1.default.createElement("span", null, by)) : (by)))));
|
|
12
13
|
};
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TogglerGroup = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const hooks_1 = require("@hugsmidjan/react/hooks");
|
|
7
6
|
const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
7
|
+
const hooks_1 = require("@hugsmidjan/react/hooks");
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
9
|
const TogglerGroup = (props) => {
|
|
10
10
|
const {
|
|
@@ -4,18 +4,18 @@ exports.TogglerGroupField = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
7
|
-
const FormField_js_1 = tslib_1.
|
|
7
|
+
const FormField_js_1 = tslib_1.__importStar(require("../FormField.js"));
|
|
8
8
|
const _TogglerGroup_js_1 = require("./_TogglerGroup.js");
|
|
9
9
|
const TogglerGroupField = (props) => {
|
|
10
|
-
const
|
|
10
|
+
const _a = (0, FormField_js_1.groupFormFieldWrapperProps)(props), { bem, Toggler, modifier, value, defaultValue, fieldWrapperProps } = _a, togglerGroupProps = tslib_1.__rest(_a, ["bem", "Toggler", "modifier", "value", "defaultValue", "fieldWrapperProps"]);
|
|
11
11
|
const _value = (0, react_1.useMemo)(() => (value == null ? undefined : typeof value === 'string' ? [value] : value), [value]);
|
|
12
12
|
const _defaultValue = (0, react_1.useMemo)(() => defaultValue == null
|
|
13
13
|
? undefined
|
|
14
14
|
: typeof defaultValue === 'string'
|
|
15
15
|
? [defaultValue]
|
|
16
16
|
: defaultValue, [defaultValue]);
|
|
17
|
-
return (react_1.default.createElement(FormField_js_1.default, {
|
|
18
|
-
return (react_1.default.createElement(_TogglerGroup_js_1.TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { disabled: disabled, value: _value, defaultValue: _defaultValue, Toggler: Toggler })));
|
|
19
|
-
} }));
|
|
17
|
+
return (react_1.default.createElement(FormField_js_1.default, Object.assign({ extraClassName: (0, classUtils_1.modifiedClass)(bem, modifier), group: true }, fieldWrapperProps, { renderInput: (className, inputProps) => {
|
|
18
|
+
return (react_1.default.createElement(_TogglerGroup_js_1.TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { disabled: props.disabled, value: _value, defaultValue: _defaultValue, Toggler: Toggler })));
|
|
19
|
+
} })));
|
|
20
20
|
};
|
|
21
21
|
exports.TogglerGroupField = TogglerGroupField;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WrapperElmProps } from '../utils.js';
|
|
1
2
|
import { BemModifierProps } from '../utils/types.js';
|
|
2
3
|
export type TogglerInputProps = {
|
|
3
4
|
label: string | JSX.Element;
|
|
@@ -13,9 +14,8 @@ export type TogglerInputProps = {
|
|
|
13
14
|
reqText?: string | false;
|
|
14
15
|
errorMessage?: string | JSX.Element;
|
|
15
16
|
Wrapper?: 'div' | 'li';
|
|
16
|
-
wrapperProps?: JSX.IntrinsicElements['div'];
|
|
17
17
|
inputProps?: JSX.IntrinsicElements['input'];
|
|
18
|
-
} & BemModifierProps & Omit<JSX.IntrinsicElements['input'], 'type'>;
|
|
18
|
+
} & BemModifierProps & WrapperElmProps & Omit<JSX.IntrinsicElements['input'], 'type'>;
|
|
19
19
|
type _TogglerInputProps = {
|
|
20
20
|
bem: string;
|
|
21
21
|
type: 'radio' | 'checkbox';
|
|
@@ -10,7 +10,7 @@ const TogglerInput = (props) => {
|
|
|
10
10
|
const domid = (0, hooks_1.useDomid)(id);
|
|
11
11
|
const errorId = errorMessage && 'error' + domid;
|
|
12
12
|
const reqStar = required && reqText !== false && (react_1.default.createElement("abbr", { className: bem + '__label__reqstar',
|
|
13
|
-
//
|
|
13
|
+
// FIXME: add mo-better i18n thinking
|
|
14
14
|
title: (reqText || 'Þarf að haka í') + ': ' }, "*"));
|
|
15
15
|
const readOnly = restInputProps.readOnly || (inputProps || {}).readOnly;
|
|
16
16
|
const labelContent = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -19,7 +19,9 @@ const TogglerInput = (props) => {
|
|
|
19
19
|
" ",
|
|
20
20
|
label,
|
|
21
21
|
' '));
|
|
22
|
-
return (react_1.default.createElement(Wrapper, Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier,
|
|
22
|
+
return (react_1.default.createElement(Wrapper, Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier,
|
|
23
|
+
// Prefer `className` over `wrapperProps.className`
|
|
24
|
+
className || (wrapperProps || {}).className) }),
|
|
23
25
|
react_1.default.createElement("input", Object.assign({ className: bem + '__input', type: type, id: domid, "aria-invalid": invalid || !!errorMessage || undefined, "aria-describedby": errorId }, restInputProps, inputProps, (readOnly && { disabled: true }))),
|
|
24
26
|
' ',
|
|
25
27
|
react_1.default.createElement("label", { className: bem + '__label', htmlFor: domid },
|
package/esm/AccordionList.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SeenProp } from './utils/seenEffect.js';
|
|
2
|
-
import { SSRSupportProps } from './utils.js';
|
|
2
|
+
import { SSRSupportProps, WrapperElmProps } from './utils.js';
|
|
3
3
|
export type AccordionListItemProps = {
|
|
4
4
|
title: string | JSX.Element;
|
|
5
5
|
content: string | JSX.Element | undefined;
|
|
@@ -19,6 +19,6 @@ export type AccordionListProps = {
|
|
|
19
19
|
/** Index of those items that should start open (uncontrolled use) */
|
|
20
20
|
defaultOpen?: Array<number>;
|
|
21
21
|
wide?: boolean;
|
|
22
|
-
} & SSRSupportProps & SeenProp;
|
|
22
|
+
} & WrapperElmProps & SSRSupportProps & SeenProp;
|
|
23
23
|
export declare const AccordionList: (props: AccordionListProps) => JSX.Element;
|
|
24
24
|
export default AccordionList;
|
package/esm/AccordionList.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useRef } from 'react';
|
|
|
2
2
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
3
3
|
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
4
4
|
import { useSeenEffect } from './utils/seenEffect.js';
|
|
5
|
-
import { useIsBrowserSide, useMixedControlState } from './utils.js';
|
|
5
|
+
import { useIsBrowserSide, useMixedControlState, } from './utils.js';
|
|
6
6
|
const AccordionListItem = (props) => {
|
|
7
7
|
const { title, content, id, disabled = false, ssr, open, onToggle } = props;
|
|
8
8
|
const defaultOpen = useRef(props.defaultOpen);
|
|
@@ -14,7 +14,7 @@ const AccordionListItem = (props) => {
|
|
|
14
14
|
React.createElement("div", { id: isBrowser && domid, className: "AccordionList__content", hidden: isBrowser && (!open || itemDisabled) }, content)));
|
|
15
15
|
};
|
|
16
16
|
export const AccordionList = (props) => {
|
|
17
|
-
const { items, ssr, wide, startSeen, defaultOpen } = props;
|
|
17
|
+
const { items, ssr, wide, startSeen, defaultOpen, wrapperProps } = props;
|
|
18
18
|
const [ref] = useSeenEffect(startSeen);
|
|
19
19
|
const [open, setOpenArray, mode] = useMixedControlState(props, 'open', []);
|
|
20
20
|
const onToggle = (index) => {
|
|
@@ -27,6 +27,6 @@ export const AccordionList = (props) => {
|
|
|
27
27
|
return newOpen;
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
return (React.createElement("div", { className: modifiedClass('AccordionList', [wide && 'wide']), ref: ref }, items.map((item, i) => (React.createElement(AccordionListItem, Object.assign({ key: i }, item, { ssr: ssr, open: open.includes(i), onToggle: () => onToggle(i), defaultOpen: defaultOpen && defaultOpen.includes(i) }))))));
|
|
30
|
+
return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('AccordionList', [wide && 'wide'], (wrapperProps || {}).className), ref: ref }), items.map((item, i) => (React.createElement(AccordionListItem, Object.assign({ key: i }, item, { ssr: ssr, open: open.includes(i), onToggle: () => onToggle(i), defaultOpen: defaultOpen && defaultOpen.includes(i) }))))));
|
|
31
31
|
};
|
|
32
32
|
export default AccordionList;
|
package/esm/ActionCards.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CardListSummaryProps, TextCardListProps, TextCardProps } from './_abstract/_CardList.js';
|
|
2
2
|
import { SeenProp } from './utils/seenEffect.js';
|
|
3
|
-
|
|
3
|
+
import { WrapperElmProps } from './utils.js';
|
|
4
|
+
export type ActionCardsProps = TextCardListProps & CardListSummaryProps & WrapperElmProps & SeenProp;
|
|
4
5
|
export type ActionCardsItemProps = TextCardProps;
|
|
5
6
|
export declare const ActionCards: (props: ActionCardsProps) => JSX.Element;
|
|
6
7
|
export default ActionCards;
|
package/esm/ActionCards.js
CHANGED
|
@@ -4,6 +4,6 @@ import { useSeenEffect } from './utils/seenEffect.js';
|
|
|
4
4
|
export const ActionCards = (props) => {
|
|
5
5
|
const [ref] = useSeenEffect(props.startSeen);
|
|
6
6
|
return (React.createElement("div", { className: "ActionCards", ref: ref },
|
|
7
|
-
React.createElement(CardList, Object.assign({}, props, {
|
|
7
|
+
React.createElement(CardList, Object.assign({ bemPrefix: "ActionCards" }, props, { wrapperProps: undefined }))));
|
|
8
8
|
};
|
|
9
9
|
export default ActionCards;
|
package/esm/Alert.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { EitherObj } from '@reykjavik/hanna-utils';
|
|
3
3
|
import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
|
|
4
|
-
import { SSRSupportProps } from './utils.js';
|
|
4
|
+
import { SSRSupportProps, WrapperElmProps } from './utils.js';
|
|
5
5
|
export type AlertI18n = {
|
|
6
6
|
closeLabel: string;
|
|
7
7
|
closeLabelLong?: string;
|
|
@@ -42,6 +42,6 @@ export type AlertProps = {
|
|
|
42
42
|
onClose?(event: MouseEvent): void | boolean;
|
|
43
43
|
/** Callback that fires after the alert has closed/transitoned out */
|
|
44
44
|
onClosed?(): void;
|
|
45
|
-
}>;
|
|
45
|
+
}> & WrapperElmProps<null, 'role' | 'hidden'>;
|
|
46
46
|
export declare const Alert: (props: AlertProps) => JSX.Element;
|
|
47
47
|
export default Alert;
|
package/esm/Alert.js
CHANGED
|
@@ -3,21 +3,31 @@ import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
|
3
3
|
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
4
4
|
import { Button } from './_abstract/_Button.js';
|
|
5
5
|
import { isPreact } from './utils/env.js';
|
|
6
|
-
import { useIsBrowserSide } from './utils.js';
|
|
6
|
+
import { useIsBrowserSide, } from './utils.js';
|
|
7
7
|
// FIXME: Eventually import from @reykjavik/hanna-css
|
|
8
8
|
const AlertCloseTransitionDuration = 400;
|
|
9
|
-
const useAutoClosing = (autoClose) => {
|
|
9
|
+
const useAutoClosing = (autoClose, props) => {
|
|
10
10
|
const [temp, setTemp] = useState(0);
|
|
11
11
|
if (!autoClose) {
|
|
12
12
|
return { autoClosing: false };
|
|
13
13
|
}
|
|
14
|
-
const thaw = () =>
|
|
15
|
-
|
|
14
|
+
const thaw = (e) => {
|
|
15
|
+
setTemp((temp) => temp + 1);
|
|
16
|
+
const handler = props[e.type.startsWith('blur') ? 'onBlur' : 'onMouseLeave'];
|
|
17
|
+
// @ts-expect-error (Proper fix ends up as too much code for this extreme edge case)
|
|
18
|
+
handler && handler(e);
|
|
19
|
+
};
|
|
20
|
+
const freeze = (e) => {
|
|
21
|
+
setTemp((temp) => temp - 1);
|
|
22
|
+
const handler = props[e.type.startsWith('focus') ? 'onFocus' : 'onMouseEnter'];
|
|
23
|
+
// @ts-expect-error (Resolving ends up as too much code for this extreme edge case)
|
|
24
|
+
handler && handler(e);
|
|
25
|
+
};
|
|
16
26
|
return {
|
|
17
27
|
autoClosing: temp === 0,
|
|
18
28
|
autoClosingProps: Object.assign({ onMouseEnter: freeze, onMouseLeave: thaw, onFocus: freeze, onBlur: thaw }, (isPreact && {
|
|
19
|
-
onfocusin: (e) => e.currentTarget !== e.target && freeze(),
|
|
20
|
-
onfocusout: (e) => e.currentTarget !== e.target && thaw(),
|
|
29
|
+
onfocusin: (e) => e.currentTarget !== e.target && freeze(e),
|
|
30
|
+
onfocusout: (e) => e.currentTarget !== e.target && thaw(e),
|
|
21
31
|
})),
|
|
22
32
|
};
|
|
23
33
|
};
|
|
@@ -33,7 +43,8 @@ export const alertTypes = {
|
|
|
33
43
|
critical: 1,
|
|
34
44
|
};
|
|
35
45
|
export const Alert = (props) => {
|
|
36
|
-
const { type, childrenHTML, children, onClose,
|
|
46
|
+
const { type, childrenHTML, children, onClose, // eslint-disable-line deprecation/deprecation
|
|
47
|
+
closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, wrapperProps, } = props;
|
|
37
48
|
const autoClose = Math.max(props.autoClose || 0, 0);
|
|
38
49
|
const closing = useRef();
|
|
39
50
|
const [open, setOpen] = useState(!!ssr);
|
|
@@ -46,7 +57,7 @@ export const Alert = (props) => {
|
|
|
46
57
|
const closeAlert = useCallback((event) => {
|
|
47
58
|
const ret = onClose &&
|
|
48
59
|
// @ts-expect-error (@deprecated `event` parameter will be removed in v0.11)
|
|
49
|
-
onClose(event);
|
|
60
|
+
onClose(event); // eslint-disable-line deprecation/deprecation
|
|
50
61
|
if (ret !== false) {
|
|
51
62
|
setOpen(false);
|
|
52
63
|
if (closing.current) {
|
|
@@ -58,7 +69,7 @@ export const Alert = (props) => {
|
|
|
58
69
|
}, AlertCloseTransitionDuration);
|
|
59
70
|
}
|
|
60
71
|
}, [onClose, onClosed]);
|
|
61
|
-
const { autoClosing, autoClosingProps } = useAutoClosing(autoClose);
|
|
72
|
+
const { autoClosing, autoClosingProps } = useAutoClosing(autoClose, props);
|
|
62
73
|
useEffect(() => {
|
|
63
74
|
if (autoClosing) {
|
|
64
75
|
let autoCloseTimeout;
|
|
@@ -77,10 +88,7 @@ export const Alert = (props) => {
|
|
|
77
88
|
};
|
|
78
89
|
}
|
|
79
90
|
}, [closeAlert, autoClosing, autoClose]);
|
|
80
|
-
return (React.createElement("div", Object.assign({ className: modifiedClass('Alert', [
|
|
81
|
-
!!alertTypes[type] && type,
|
|
82
|
-
closable && 'closable',
|
|
83
|
-
]), role: "alert", hidden: !open || undefined }, autoClosingProps),
|
|
91
|
+
return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('Alert', [!!alertTypes[type] && type, closable && 'closable'], (wrapperProps || {}).className), role: "alert", hidden: !open || undefined }, autoClosingProps),
|
|
84
92
|
childrenHTML ? (React.createElement("div", { dangerouslySetInnerHTML: { __html: childrenHTML } })) : (children),
|
|
85
93
|
' ',
|
|
86
94
|
showCloseButton && (React.createElement(Button, Object.assign({ bem: "Alert__close" }, (closeUrl != null ? { href: closeUrl } : { type: 'button' }), { onClick: (e) => {
|
package/esm/ArticleCards.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ImageCardListProps, ImageCardProps } from './_abstract/_CardList.js';
|
|
2
|
+
import { WrapperElmProps } from './utils.js';
|
|
2
3
|
export type ArticleCardsItemProps = ImageCardProps;
|
|
3
4
|
/** @deprecated Use `ArticleCardsItemProps` instead (Remove in v0.11) */
|
|
4
5
|
export type ArticleCardProps = ArticleCardsItemProps;
|
|
5
|
-
export type ArticleCardsProps = Pick<ImageCardListProps, 'cards' | 'imgPlaceholder'
|
|
6
|
+
export type ArticleCardsProps = Pick<ImageCardListProps, 'cards' | 'imgPlaceholder'> & {
|
|
7
|
+
size?: 'large' | 'normal';
|
|
8
|
+
} & WrapperElmProps<'ul'>;
|
|
6
9
|
export declare const ArticleCards: (props: ArticleCardsProps) => JSX.Element;
|
|
7
10
|
export default ArticleCards;
|
package/esm/ArticleCards.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardList } from './_abstract/_CardList.js';
|
|
3
|
-
export const ArticleCards = (props) => (React.createElement(CardList, { bemPrefix: "ArticleCards", standalone: true, cards: props.cards, imgPlaceholder: props.imgPlaceholder || true }));
|
|
3
|
+
export const ArticleCards = (props) => (React.createElement(CardList, { bemPrefix: "ArticleCards", modifier: props.size === 'large' ? 'large' : undefined, standalone: true, cards: props.cards, imgPlaceholder: props.imgPlaceholder || true, wrapperProps: props.wrapperProps }));
|
|
4
4
|
export default ArticleCards;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
3
2
|
import { getIllustrationUrl } from '@reykjavik/hanna-utils/assets';
|
|
4
3
|
import { Image } from '../_abstract/_Image.js';
|
|
5
4
|
import { Link } from '../_abstract/_Link.js';
|
|
@@ -11,7 +10,7 @@ export const ArticleCarouselCard = (props) => {
|
|
|
11
10
|
return (React.createElement("div", { className: "ArticleCarouselCard", "data-color": color && colorFamilies[color], "data-color-theme": !color ? theme && themeOptions[theme] : undefined },
|
|
12
11
|
React.createElement(Link, { className: "ArticleCarouselCard__link", href: href, target: target },
|
|
13
12
|
' ',
|
|
14
|
-
React.createElement(Image, Object.assign({
|
|
13
|
+
React.createElement(Image, Object.assign({ bem: "ArticleCarouselCard__illustration", modifier: photo && 'photo', placeholder: true }, imageProps)),
|
|
15
14
|
React.createElement("h3", { className: "ArticleCarouselCard__title" }, title),
|
|
16
15
|
' '),
|
|
17
16
|
' ',
|
package/esm/ArticleCarousel.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ArticleCarouselCardProps, ArticleCarouselImageProps } from './ArticleCarousel/_ArticleCarouselCard.js';
|
|
2
2
|
import { SeenProp } from './utils/seenEffect.js';
|
|
3
|
-
import { SSRSupportProps } from './utils.js';
|
|
3
|
+
import { SSRSupportProps, WrapperElmProps } from './utils.js';
|
|
4
4
|
export type ArticleCarouselProps = {
|
|
5
5
|
items: Array<ArticleCarouselCardProps>;
|
|
6
6
|
title?: string;
|
|
7
7
|
moreLabel?: string;
|
|
8
|
-
} & SSRSupportProps & SeenProp;
|
|
8
|
+
} & WrapperElmProps & SSRSupportProps & SeenProp;
|
|
9
9
|
export type { ArticleCarouselCardProps, ArticleCarouselImageProps };
|
|
10
10
|
export declare const ArticleCarousel: (props: ArticleCarouselProps) => JSX.Element;
|
|
11
11
|
export default ArticleCarousel;
|
package/esm/ArticleCarousel.js
CHANGED
|
@@ -3,6 +3,6 @@ import { AbstractCarousel } from './_abstract/_AbstractCarousel.js';
|
|
|
3
3
|
import { ArticleCarouselCard, } from './ArticleCarousel/_ArticleCarouselCard.js';
|
|
4
4
|
export const ArticleCarousel = (props) => {
|
|
5
5
|
const { title, items, moreLabel, ssr, startSeen } = props;
|
|
6
|
-
return (React.createElement(AbstractCarousel, { bem: "ArticleCarousel", title: title, items: items, Component: ArticleCarouselCard, ComponentProps: { moreLabel }, ssr: ssr, startSeen: startSeen }));
|
|
6
|
+
return (React.createElement(AbstractCarousel, { bem: "ArticleCarousel", title: title, items: items, Component: ArticleCarouselCard, ComponentProps: { moreLabel }, ssr: ssr, startSeen: startSeen, wrapperProps: props.wrapperProps }));
|
|
7
7
|
};
|
|
8
8
|
export default ArticleCarousel;
|
package/esm/ArticleMeta.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WrapperElmProps } from './utils.js';
|
|
1
2
|
export type ArticleMetaItem = {
|
|
2
3
|
label: string;
|
|
3
4
|
href?: string;
|
|
@@ -5,6 +6,6 @@ export type ArticleMetaItem = {
|
|
|
5
6
|
export type ArticleMetaProps = {
|
|
6
7
|
items: Array<ArticleMetaItem>;
|
|
7
8
|
small?: boolean;
|
|
8
|
-
};
|
|
9
|
+
} & WrapperElmProps;
|
|
9
10
|
export declare const ArticleMeta: (props: ArticleMetaProps) => JSX.Element | null;
|
|
10
11
|
export default ArticleMeta;
|
package/esm/ArticleMeta.js
CHANGED
|
@@ -2,11 +2,11 @@ import React, { Fragment } from 'react';
|
|
|
2
2
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
3
3
|
import { Link } from './_abstract/_Link.js';
|
|
4
4
|
export const ArticleMeta = (props) => {
|
|
5
|
-
const { items, small } = props;
|
|
5
|
+
const { items, small, wrapperProps } = props;
|
|
6
6
|
if (items.length === 0) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
return (React.createElement("div", { className: modifiedClass('ArticleMeta', small && 'small') }, items.map(({ label, href }, i) => (React.createElement(Fragment, { key: i },
|
|
9
|
+
return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('ArticleMeta', small && 'small', (wrapperProps || {}).className) }), items.map(({ label, href }, i) => (React.createElement(Fragment, { key: i },
|
|
10
10
|
href == null ? (React.createElement("span", { className: "ArticleMeta__item" },
|
|
11
11
|
" ",
|
|
12
12
|
label,
|
package/esm/Attention.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { WrapperElmProps } from './utils.js';
|
|
2
3
|
export type AttentionProps = {
|
|
3
4
|
small?: boolean;
|
|
4
5
|
children: ReactNode;
|
|
5
|
-
};
|
|
6
|
+
} & WrapperElmProps;
|
|
6
7
|
export declare const Attention: (props: AttentionProps) => JSX.Element;
|
|
7
8
|
export default Attention;
|