@reykjavik/hanna-react 0.10.93 → 0.10.95
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 -3
- package/AccordionList.js +3 -3
- package/Alert.d.ts +2 -3
- package/Alert.js +2 -2
- package/ArticleCarousel/_ArticleCarouselCard.js +2 -2
- package/ArticleCarousel.d.ts +2 -3
- package/ArticleMeta.js +2 -2
- package/Attention.js +2 -2
- package/BasicTable.js +2 -2
- package/BgBox.js +2 -2
- package/Bling.js +2 -2
- package/ButtonBar.js +2 -2
- package/CHANGELOG.md +14 -1
- package/ContactBubble.d.ts +2 -3
- package/ContactBubble.js +2 -2
- package/Datepicker.js +2 -2
- package/ExtraLinks.js +3 -3
- package/FieldGroup.js +2 -2
- package/FileInput.js +3 -3
- package/FooterInfo.d.ts +2 -2
- package/FooterInfo.js +3 -3
- package/Form.js +2 -2
- package/FormField.d.ts +2 -3
- package/FormField.js +2 -2
- package/Gallery.d.ts +2 -3
- package/GridBlocks.js +2 -2
- package/Heading.js +2 -2
- package/IframeBlock.js +2 -2
- package/ImageCards.js +2 -2
- package/InfoHero.js +2 -2
- package/LabeledTextBlock.js +2 -2
- package/Layout.d.ts +3 -6
- package/Layout.js +7 -13
- package/MainMenu/_PrimaryPanel.js +2 -2
- package/MainMenu.d.ts +2 -3
- package/MainMenu.js +3 -3
- package/Multiselect.js +5 -5
- package/NameCard.js +2 -2
- package/NewsHero.js +2 -2
- package/PageFilter.js +2 -2
- package/PageHeading.js +2 -2
- package/Picture.js +2 -2
- package/ProcessOverview.js +2 -2
- package/ReadSpeakerPlayer.js +2 -2
- package/RowBlock.d.ts +2 -2
- package/RowBlock.js +2 -2
- package/RowBlockColumn.js +2 -2
- package/SearchInput.js +2 -2
- package/SearchResults.js +2 -2
- package/Selectbox.js +2 -2
- package/ShareButtons.d.ts +2 -3
- package/Sharpie.js +2 -2
- package/SiteSearchAutocomplete.d.ts +1 -1
- package/SiteSearchCurtain.js +2 -2
- package/SiteSearchInput.d.ts +2 -3
- package/Skeleton.js +2 -2
- package/SubHeading.js +2 -2
- package/Tabs.d.ts +2 -3
- package/Tabs.js +2 -2
- package/TagPill.js +3 -3
- package/TextBlock.js +2 -2
- package/TextInput.js +2 -2
- package/Tooltip.js +2 -2
- package/VSpacer.js +2 -2
- package/WizardLayout.d.ts +2 -3
- package/WizardLayout.js +2 -2
- package/WizardStepper.js +3 -3
- package/_abstract/_AbstractCarousel.d.ts +3 -4
- package/_abstract/_AbstractCarousel.js +2 -2
- package/_abstract/_Block.d.ts +2 -2
- package/_abstract/_Block.js +2 -2
- package/_abstract/_Button.d.ts +3 -3
- package/_abstract/_Button.js +2 -2
- package/_abstract/_Image.js +3 -3
- package/_abstract/_TogglerGroup.js +2 -2
- package/_abstract/_TogglerGroupField.d.ts +2 -2
- package/_abstract/_TogglerGroupField.js +2 -2
- package/_abstract/_TogglerInput.d.ts +2 -2
- package/_abstract/_TogglerInput.js +2 -2
- package/_mixed_export_resolution_/ReactDropzone.d.ts +3 -3
- package/_mixed_export_resolution_/ReactDropzone.js +3 -3
- package/esm/AccordionList.d.ts +2 -3
- package/esm/AccordionList.js +3 -3
- package/esm/Alert.d.ts +2 -3
- package/esm/Alert.js +2 -2
- package/esm/ArticleCarousel/_ArticleCarouselCard.js +2 -2
- package/esm/ArticleCarousel.d.ts +2 -3
- package/esm/ArticleMeta.js +2 -2
- package/esm/Attention.js +2 -2
- package/esm/BasicTable.js +2 -2
- package/esm/BgBox.js +2 -2
- package/esm/Bling.js +2 -2
- package/esm/ButtonBar.js +2 -2
- package/esm/ContactBubble.d.ts +2 -3
- package/esm/ContactBubble.js +2 -2
- package/esm/Datepicker.js +2 -2
- package/esm/ExtraLinks.js +3 -3
- package/esm/FieldGroup.js +2 -2
- package/esm/FileInput.js +3 -3
- package/esm/FooterInfo.d.ts +2 -2
- package/esm/FooterInfo.js +3 -3
- package/esm/Form.js +2 -2
- package/esm/FormField.d.ts +2 -3
- package/esm/FormField.js +2 -2
- package/esm/Gallery.d.ts +2 -3
- package/esm/GridBlocks.js +2 -2
- package/esm/Heading.js +2 -2
- package/esm/IframeBlock.js +2 -2
- package/esm/ImageCards.js +2 -2
- package/esm/InfoHero.js +2 -2
- package/esm/LabeledTextBlock.js +2 -2
- package/esm/Layout.d.ts +3 -6
- package/esm/Layout.js +7 -13
- package/esm/MainMenu/_PrimaryPanel.js +2 -2
- package/esm/MainMenu.d.ts +2 -3
- package/esm/MainMenu.js +3 -3
- package/esm/Multiselect.js +5 -5
- package/esm/NameCard.js +2 -2
- package/esm/NewsHero.js +2 -2
- package/esm/PageFilter.js +2 -2
- package/esm/PageHeading.js +2 -2
- package/esm/Picture.js +2 -2
- package/esm/ProcessOverview.js +2 -2
- package/esm/ReadSpeakerPlayer.js +2 -2
- package/esm/RowBlock.d.ts +2 -2
- package/esm/RowBlock.js +2 -2
- package/esm/RowBlockColumn.js +2 -2
- package/esm/SearchInput.js +2 -2
- package/esm/SearchResults.js +2 -2
- package/esm/Selectbox.js +2 -2
- package/esm/ShareButtons.d.ts +2 -3
- package/esm/Sharpie.js +2 -2
- package/esm/SiteSearchAutocomplete.d.ts +1 -1
- package/esm/SiteSearchCurtain.js +2 -2
- package/esm/SiteSearchInput.d.ts +2 -3
- package/esm/Skeleton.js +2 -2
- package/esm/SubHeading.js +2 -2
- package/esm/Tabs.d.ts +2 -3
- package/esm/Tabs.js +2 -2
- package/esm/TagPill.js +3 -3
- package/esm/TextBlock.js +2 -2
- package/esm/TextInput.js +2 -2
- package/esm/Tooltip.js +2 -2
- package/esm/VSpacer.js +2 -2
- package/esm/WizardLayout.d.ts +2 -3
- package/esm/WizardLayout.js +2 -2
- package/esm/WizardStepper.js +3 -3
- package/esm/_abstract/_AbstractCarousel.d.ts +3 -4
- package/esm/_abstract/_AbstractCarousel.js +2 -2
- package/esm/_abstract/_Block.d.ts +2 -2
- package/esm/_abstract/_Block.js +2 -2
- package/esm/_abstract/_Button.d.ts +3 -3
- package/esm/_abstract/_Button.js +2 -2
- package/esm/_abstract/_Image.js +3 -3
- package/esm/_abstract/_TogglerGroup.js +2 -2
- package/esm/_abstract/_TogglerGroupField.d.ts +2 -2
- package/esm/_abstract/_TogglerGroupField.js +2 -2
- package/esm/_abstract/_TogglerInput.d.ts +2 -2
- package/esm/_abstract/_TogglerInput.js +2 -2
- package/esm/_mixed_export_resolution_/ReactDropzone.d.ts +3 -3
- package/esm/_mixed_export_resolution_/ReactDropzone.js +3 -3
- package/esm/utils/HannaUIState.d.ts +3 -4
- package/esm/utils/config.d.ts +11 -1
- package/esm/utils/config.js +1 -0
- package/esm/utils/types.d.ts +12 -0
- package/esm/utils/types.js +1 -0
- package/esm/utils/useGetSVGtext.d.ts +1 -1
- package/esm/utils/useGetSVGtext.js +2 -2
- package/esm/utils/useMenuToggling.d.ts +2 -0
- package/esm/utils/useMenuToggling.js +31 -21
- package/esm/utils.d.ts +2 -1
- package/esm/utils.js +2 -1
- package/package.json +5 -4
- package/utils/HannaUIState.d.ts +3 -4
- package/utils/config.d.ts +11 -1
- package/utils/config.js +1 -0
- package/utils/types.d.ts +12 -0
- package/utils/types.js +2 -0
- package/utils/useGetSVGtext.d.ts +1 -1
- package/utils/useGetSVGtext.js +2 -2
- package/utils/useMenuToggling.d.ts +2 -0
- package/utils/useMenuToggling.js +31 -21
- package/utils.d.ts +2 -1
- package/utils.js +5 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
3
4
|
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
4
|
-
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
5
5
|
export const TogglerInput = (props) => {
|
|
6
6
|
const { bem, modifier, className, label, invalid, errorMessage, Wrapper = 'div', required, reqText, type, id, innerWrap, wrapperProps, inputProps } = props, restInputProps = __rest(props, ["bem", "modifier", "className", "label", "invalid", "errorMessage", "Wrapper", "required", "reqText", "type", "id", "innerWrap", "wrapperProps", "inputProps"]);
|
|
7
7
|
const domid = useDomid(id);
|
|
@@ -16,7 +16,7 @@ export const TogglerInput = (props) => {
|
|
|
16
16
|
" ",
|
|
17
17
|
label,
|
|
18
18
|
' '));
|
|
19
|
-
return (React.createElement(Wrapper, Object.assign({}, wrapperProps, { className:
|
|
19
|
+
return (React.createElement(Wrapper, Object.assign({}, wrapperProps, { className: modifiedClass(bem, modifier, className) }),
|
|
20
20
|
React.createElement("input", Object.assign({ className: bem + '__input', type: type, id: domid, "aria-invalid": invalid || !!errorMessage || undefined, "aria-describedby": errorId }, restInputProps, inputProps, (readOnly && { disabled: true }))),
|
|
21
21
|
' ',
|
|
22
22
|
React.createElement("label", { className: bem + '__label', htmlFor: domid },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
export declare const ReactDropzone: typeof
|
|
3
|
-
export declare const useDropzone: typeof
|
|
1
|
+
import * as _pkg from 'react-dropzone';
|
|
2
|
+
export declare const ReactDropzone: typeof _pkg.default;
|
|
3
|
+
export declare const useDropzone: typeof _pkg.useDropzone;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// See <file://./_WAT.md> for info on why this file exists
|
|
2
|
-
import * as
|
|
3
|
-
const _default = reactDropzonePkg.default;
|
|
2
|
+
import * as _pkg from 'react-dropzone';
|
|
4
3
|
// This defensive code is required to get around the fact that react-dropzone
|
|
5
4
|
// mixes default and named exports.
|
|
6
5
|
// Depending whether this module is run as ESM or CJS, then `_default` may be
|
|
7
6
|
// either the actual default export or an object with a default property.
|
|
8
7
|
// Rejoice in the woeful borderlands of modern ESM and legacy CJS interop.
|
|
9
|
-
|
|
8
|
+
const reactDropzonePkg = 'default' in _pkg.default ? _pkg.default : _pkg;
|
|
9
|
+
export const ReactDropzone = reactDropzonePkg.default;
|
|
10
10
|
export const useDropzone = reactDropzonePkg.useDropzone;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
type
|
|
2
|
+
export type HannaUIStateState = {
|
|
3
3
|
closeHamburgerMenu: () => void;
|
|
4
4
|
isHamburgerMenuOpen: boolean | undefined;
|
|
5
5
|
};
|
|
6
|
-
export declare const HannaUIState: import("react").Provider<
|
|
7
|
-
export declare const useHannaUIState: () =>
|
|
8
|
-
export {};
|
|
6
|
+
export declare const HannaUIState: import("react").Provider<HannaUIStateState>;
|
|
7
|
+
export declare const useHannaUIState: () => HannaUIStateState;
|
package/esm/utils/config.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import { SSRSupport } from '@hugsmidjan/react/hooks';
|
|
1
2
|
export type { LinkRenderer } from '../_abstract/_Link.js';
|
|
2
3
|
export { setLinkRenderer } from '../_abstract/_Link.js';
|
|
3
|
-
export type { SSRSupport } from '@hugsmidjan/react/hooks';
|
|
4
4
|
export { setDefaultSSR } from '@hugsmidjan/react/hooks';
|
|
5
|
+
export type SSRSupportProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Indicates whether server-side rendering is supported or not.
|
|
8
|
+
*
|
|
9
|
+
* The `ssr-only` value is useful for cases where you need
|
|
10
|
+
* to demo the server-rendered version in a browser.
|
|
11
|
+
*/
|
|
12
|
+
ssr?: SSRSupport;
|
|
13
|
+
};
|
|
14
|
+
export type { SSRSupport };
|
package/esm/utils/config.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Modifiers } from '@hugsmidjan/qj/classUtils';
|
|
2
|
+
export type BemModifierProps = {
|
|
3
|
+
/** List of CSS BEM --modifier's to add to the component's main wrapper.
|
|
4
|
+
*
|
|
5
|
+
* All falsy values are neatly skipped.
|
|
6
|
+
*/
|
|
7
|
+
modifier?: Modifiers;
|
|
8
|
+
};
|
|
9
|
+
export type BemProps = {
|
|
10
|
+
/** CSS BEM class-name prefix to be used for this component. Defaults to the same as the original component's displayName */
|
|
11
|
+
bem?: string;
|
|
12
|
+
} & BemModifierProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,5 +6,5 @@ type SVGMeta = {
|
|
|
6
6
|
* Fetches a remote SVG image and returns its XML/source
|
|
7
7
|
* string for inlining, or further processing
|
|
8
8
|
*/
|
|
9
|
-
export declare const useGetSVGtext: (imageSrc: string | undefined) => SVGMeta | undefined;
|
|
9
|
+
export declare const useGetSVGtext: (imageSrc: string | undefined, altText?: string) => SVGMeta | undefined;
|
|
10
10
|
export {};
|
|
@@ -4,12 +4,12 @@ import { getSVGtext } from '@reykjavik/hanna-utils';
|
|
|
4
4
|
* Fetches a remote SVG image and returns its XML/source
|
|
5
5
|
* string for inlining, or further processing
|
|
6
6
|
*/
|
|
7
|
-
export const useGetSVGtext = (imageSrc) => {
|
|
7
|
+
export const useGetSVGtext = (imageSrc, altText) => {
|
|
8
8
|
const [inlineSvg, setInlineSvg] = useState();
|
|
9
9
|
const srcRef = useRef(imageSrc);
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
if (imageSrc) {
|
|
12
|
-
getSVGtext(imageSrc).then((code) => {
|
|
12
|
+
getSVGtext(imageSrc, altText).then((code) => {
|
|
13
13
|
if (imageSrc === srcRef.current) {
|
|
14
14
|
setInlineSvg({ imageSrc, code });
|
|
15
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { HannaUIStateState } from './HannaUIState.js';
|
|
1
2
|
type MenuTogglingState = {
|
|
2
3
|
isMenuActive: true | undefined;
|
|
3
4
|
isMenuOpen: boolean;
|
|
4
5
|
toggleMenu: () => void;
|
|
5
6
|
closeMenu: () => void;
|
|
7
|
+
uiState: HannaUIStateState;
|
|
6
8
|
};
|
|
7
9
|
export declare const useMenuToggling: (doInitialize?: boolean) => MenuTogglingState;
|
|
8
10
|
export {};
|
|
@@ -7,14 +7,33 @@ const htmlClass = (className, add) => {
|
|
|
7
7
|
const noop = () => undefined;
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
export const useMenuToggling = (doInitialize = true) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const stateRef = useRef({
|
|
11
|
+
isMenuOpen: false,
|
|
12
|
+
isMenuActive: undefined,
|
|
13
|
+
toggleMenu: doInitialize
|
|
14
|
+
? () => {
|
|
15
|
+
if (stateRef.current.isMenuActive) {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
17
|
+
stateRef.current.isMenuOpen ? _closeMenu() : _openMenu();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
: noop,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
22
|
+
closeMenu: () => doInitialize && _closeMenu(),
|
|
23
|
+
});
|
|
24
|
+
const [{ isMenuOpen, isMenuActive, uiState }, setMenuState] = useState({
|
|
25
|
+
isMenuOpen: false,
|
|
26
|
+
isMenuActive: undefined,
|
|
27
|
+
uiState: {
|
|
28
|
+
closeHamburgerMenu: () => stateRef.current.closeMenu(),
|
|
29
|
+
isHamburgerMenuOpen: false,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
stateRef.current.isMenuOpen = isMenuOpen;
|
|
33
|
+
stateRef.current.isMenuActive = isMenuActive;
|
|
15
34
|
const _openMenu = () => {
|
|
16
35
|
if (!stateRef.current.isMenuOpen) {
|
|
17
|
-
|
|
36
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuOpen: true, uiState: Object.assign(Object.assign({}, state.uiState), { isHamburgerMenuOpen: true }) })));
|
|
18
37
|
htmlClass('menu-is-open', true);
|
|
19
38
|
htmlClass('menu-is-closed', false);
|
|
20
39
|
focusElement('#pagenav');
|
|
@@ -22,7 +41,7 @@ export const useMenuToggling = (doInitialize = true) => {
|
|
|
22
41
|
};
|
|
23
42
|
const _closeMenu = () => {
|
|
24
43
|
if (stateRef.current.isMenuOpen) {
|
|
25
|
-
|
|
44
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuOpen: false, uiState: Object.assign(Object.assign({}, state.uiState), { isHamburgerMenuOpen: false }) })));
|
|
26
45
|
htmlClass('menu-is-closed', true);
|
|
27
46
|
htmlClass('menu-is-open', false);
|
|
28
47
|
focusElement('.Layout__header__skiplink');
|
|
@@ -31,32 +50,23 @@ export const useMenuToggling = (doInitialize = true) => {
|
|
|
31
50
|
useFormatMonitor(doInitialize
|
|
32
51
|
? (media) => {
|
|
33
52
|
if (media.becameHamburger) {
|
|
34
|
-
|
|
53
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuActive: true })));
|
|
35
54
|
htmlClass('menu-is-active', true);
|
|
36
55
|
htmlClass('menu-is-closed', true);
|
|
37
56
|
}
|
|
38
57
|
if (media.leftHamburger) {
|
|
39
58
|
_closeMenu();
|
|
40
|
-
|
|
59
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuActive: undefined })));
|
|
41
60
|
htmlClass('menu-is-active', false);
|
|
42
61
|
htmlClass('menu-is-closed', false);
|
|
43
62
|
}
|
|
44
63
|
}
|
|
45
64
|
: noop);
|
|
46
|
-
const { toggleMenu, closeMenu } = useRef(doInitialize
|
|
47
|
-
? {
|
|
48
|
-
toggleMenu: () => {
|
|
49
|
-
if (stateRef.current.isMenuActive) {
|
|
50
|
-
stateRef.current.isMenuOpen ? _closeMenu() : _openMenu();
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
closeMenu: _closeMenu,
|
|
54
|
-
}
|
|
55
|
-
: { toggleMenu: noop, closeMenu: noop }).current;
|
|
56
65
|
return {
|
|
57
66
|
isMenuActive,
|
|
58
67
|
isMenuOpen,
|
|
59
|
-
toggleMenu,
|
|
60
|
-
closeMenu,
|
|
68
|
+
toggleMenu: stateRef.current.toggleMenu,
|
|
69
|
+
closeMenu: stateRef.current.closeMenu,
|
|
70
|
+
uiState,
|
|
61
71
|
};
|
|
62
72
|
};
|
package/esm/utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './utils/browserSide.js';
|
|
2
2
|
export * from './utils/config.js';
|
|
3
|
-
export
|
|
3
|
+
export { HannaUIState, useHannaUIState } from './utils/HannaUIState.js';
|
|
4
4
|
export * from './utils/useDidChange.js';
|
|
5
5
|
export * from './utils/useFormatMonitor.js';
|
|
6
6
|
export * from './utils/useGetSVGtext.js';
|
|
7
|
+
export * from './utils/useMenuToggling.js';
|
|
7
8
|
export * from './utils/useMixedControlState.js';
|
|
8
9
|
export * from './utils/useScrollbarWidthCSSVar.js';
|
|
9
10
|
/**
|
package/esm/utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './utils/browserSide.js';
|
|
2
2
|
export * from './utils/config.js';
|
|
3
|
-
export
|
|
3
|
+
export { HannaUIState, useHannaUIState } from './utils/HannaUIState.js';
|
|
4
4
|
export * from './utils/useDidChange.js';
|
|
5
5
|
export * from './utils/useFormatMonitor.js';
|
|
6
6
|
export * from './utils/useGetSVGtext.js';
|
|
7
|
+
export * from './utils/useMenuToggling.js';
|
|
7
8
|
export * from './utils/useMixedControlState.js';
|
|
8
9
|
export * from './utils/useScrollbarWidthCSSVar.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/hanna-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.95",
|
|
4
4
|
"author": "Reykjavík (http://www.reykjavik.is)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Hugsmiðjan ehf (http://www.hugsmidjan.is)",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@floating-ui/react": "^0.19.2",
|
|
17
|
-
"@hugsmidjan/qj": "^4.
|
|
17
|
+
"@hugsmidjan/qj": "^4.21.0",
|
|
18
18
|
"@hugsmidjan/react": "^0.4.32",
|
|
19
19
|
"@reykjavik/hanna-css": "^0.4.3",
|
|
20
|
-
"@reykjavik/hanna-utils": "^0.2.
|
|
20
|
+
"@reykjavik/hanna-utils": "^0.2.8",
|
|
21
21
|
"@types/react": "^17.0.24",
|
|
22
22
|
"@types/react-autosuggest": "^10.1.0",
|
|
23
23
|
"@types/react-datepicker": "^4.8.0",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"react-datepicker": "4.11.0",
|
|
29
29
|
"react-dropzone": "^10.2.2",
|
|
30
30
|
"react-intersection-observer": "^8.30.1",
|
|
31
|
-
"react-transition-group": "^4.4.1"
|
|
31
|
+
"react-transition-group": "^4.4.1",
|
|
32
|
+
"tslib": "^2.4.0"
|
|
32
33
|
},
|
|
33
34
|
"engines": {
|
|
34
35
|
"node": ">=16"
|
package/utils/HannaUIState.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
type
|
|
2
|
+
export type HannaUIStateState = {
|
|
3
3
|
closeHamburgerMenu: () => void;
|
|
4
4
|
isHamburgerMenuOpen: boolean | undefined;
|
|
5
5
|
};
|
|
6
|
-
export declare const HannaUIState: import("react").Provider<
|
|
7
|
-
export declare const useHannaUIState: () =>
|
|
8
|
-
export {};
|
|
6
|
+
export declare const HannaUIState: import("react").Provider<HannaUIStateState>;
|
|
7
|
+
export declare const useHannaUIState: () => HannaUIStateState;
|
package/utils/config.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
import { SSRSupport } from '@hugsmidjan/react/hooks';
|
|
1
2
|
export type { LinkRenderer } from '../_abstract/_Link.js';
|
|
2
3
|
export { setLinkRenderer } from '../_abstract/_Link.js';
|
|
3
|
-
export type { SSRSupport } from '@hugsmidjan/react/hooks';
|
|
4
4
|
export { setDefaultSSR } from '@hugsmidjan/react/hooks';
|
|
5
|
+
export type SSRSupportProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Indicates whether server-side rendering is supported or not.
|
|
8
|
+
*
|
|
9
|
+
* The `ssr-only` value is useful for cases where you need
|
|
10
|
+
* to demo the server-rendered version in a browser.
|
|
11
|
+
*/
|
|
12
|
+
ssr?: SSRSupport;
|
|
13
|
+
};
|
|
14
|
+
export type { SSRSupport };
|
package/utils/config.js
CHANGED
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setDefaultSSR = exports.setLinkRenderer = void 0;
|
|
4
4
|
var _Link_js_1 = require("../_abstract/_Link.js");
|
|
5
5
|
Object.defineProperty(exports, "setLinkRenderer", { enumerable: true, get: function () { return _Link_js_1.setLinkRenderer; } });
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
6
7
|
var hooks_1 = require("@hugsmidjan/react/hooks");
|
|
7
8
|
Object.defineProperty(exports, "setDefaultSSR", { enumerable: true, get: function () { return hooks_1.setDefaultSSR; } });
|
package/utils/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Modifiers } from '@hugsmidjan/qj/classUtils';
|
|
2
|
+
export type BemModifierProps = {
|
|
3
|
+
/** List of CSS BEM --modifier's to add to the component's main wrapper.
|
|
4
|
+
*
|
|
5
|
+
* All falsy values are neatly skipped.
|
|
6
|
+
*/
|
|
7
|
+
modifier?: Modifiers;
|
|
8
|
+
};
|
|
9
|
+
export type BemProps = {
|
|
10
|
+
/** CSS BEM class-name prefix to be used for this component. Defaults to the same as the original component's displayName */
|
|
11
|
+
bem?: string;
|
|
12
|
+
} & BemModifierProps;
|
package/utils/types.js
ADDED
package/utils/useGetSVGtext.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ type SVGMeta = {
|
|
|
6
6
|
* Fetches a remote SVG image and returns its XML/source
|
|
7
7
|
* string for inlining, or further processing
|
|
8
8
|
*/
|
|
9
|
-
export declare const useGetSVGtext: (imageSrc: string | undefined) => SVGMeta | undefined;
|
|
9
|
+
export declare const useGetSVGtext: (imageSrc: string | undefined, altText?: string) => SVGMeta | undefined;
|
|
10
10
|
export {};
|
package/utils/useGetSVGtext.js
CHANGED
|
@@ -7,12 +7,12 @@ const hanna_utils_1 = require("@reykjavik/hanna-utils");
|
|
|
7
7
|
* Fetches a remote SVG image and returns its XML/source
|
|
8
8
|
* string for inlining, or further processing
|
|
9
9
|
*/
|
|
10
|
-
const useGetSVGtext = (imageSrc) => {
|
|
10
|
+
const useGetSVGtext = (imageSrc, altText) => {
|
|
11
11
|
const [inlineSvg, setInlineSvg] = (0, react_1.useState)();
|
|
12
12
|
const srcRef = (0, react_1.useRef)(imageSrc);
|
|
13
13
|
(0, react_1.useEffect)(() => {
|
|
14
14
|
if (imageSrc) {
|
|
15
|
-
(0, hanna_utils_1.getSVGtext)(imageSrc).then((code) => {
|
|
15
|
+
(0, hanna_utils_1.getSVGtext)(imageSrc, altText).then((code) => {
|
|
16
16
|
if (imageSrc === srcRef.current) {
|
|
17
17
|
setInlineSvg({ imageSrc, code });
|
|
18
18
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { HannaUIStateState } from './HannaUIState.js';
|
|
1
2
|
type MenuTogglingState = {
|
|
2
3
|
isMenuActive: true | undefined;
|
|
3
4
|
isMenuOpen: boolean;
|
|
4
5
|
toggleMenu: () => void;
|
|
5
6
|
closeMenu: () => void;
|
|
7
|
+
uiState: HannaUIStateState;
|
|
6
8
|
};
|
|
7
9
|
export declare const useMenuToggling: (doInitialize?: boolean) => MenuTogglingState;
|
|
8
10
|
export {};
|
package/utils/useMenuToggling.js
CHANGED
|
@@ -10,14 +10,33 @@ const htmlClass = (className, add) => {
|
|
|
10
10
|
const noop = () => undefined;
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
const useMenuToggling = (doInitialize = true) => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const stateRef = (0, react_1.useRef)({
|
|
14
|
+
isMenuOpen: false,
|
|
15
|
+
isMenuActive: undefined,
|
|
16
|
+
toggleMenu: doInitialize
|
|
17
|
+
? () => {
|
|
18
|
+
if (stateRef.current.isMenuActive) {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20
|
+
stateRef.current.isMenuOpen ? _closeMenu() : _openMenu();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
: noop,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
25
|
+
closeMenu: () => doInitialize && _closeMenu(),
|
|
26
|
+
});
|
|
27
|
+
const [{ isMenuOpen, isMenuActive, uiState }, setMenuState] = (0, react_1.useState)({
|
|
28
|
+
isMenuOpen: false,
|
|
29
|
+
isMenuActive: undefined,
|
|
30
|
+
uiState: {
|
|
31
|
+
closeHamburgerMenu: () => stateRef.current.closeMenu(),
|
|
32
|
+
isHamburgerMenuOpen: false,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
stateRef.current.isMenuOpen = isMenuOpen;
|
|
36
|
+
stateRef.current.isMenuActive = isMenuActive;
|
|
18
37
|
const _openMenu = () => {
|
|
19
38
|
if (!stateRef.current.isMenuOpen) {
|
|
20
|
-
|
|
39
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuOpen: true, uiState: Object.assign(Object.assign({}, state.uiState), { isHamburgerMenuOpen: true }) })));
|
|
21
40
|
htmlClass('menu-is-open', true);
|
|
22
41
|
htmlClass('menu-is-closed', false);
|
|
23
42
|
(0, hanna_utils_1.focusElement)('#pagenav');
|
|
@@ -25,7 +44,7 @@ const useMenuToggling = (doInitialize = true) => {
|
|
|
25
44
|
};
|
|
26
45
|
const _closeMenu = () => {
|
|
27
46
|
if (stateRef.current.isMenuOpen) {
|
|
28
|
-
|
|
47
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuOpen: false, uiState: Object.assign(Object.assign({}, state.uiState), { isHamburgerMenuOpen: false }) })));
|
|
29
48
|
htmlClass('menu-is-closed', true);
|
|
30
49
|
htmlClass('menu-is-open', false);
|
|
31
50
|
(0, hanna_utils_1.focusElement)('.Layout__header__skiplink');
|
|
@@ -34,33 +53,24 @@ const useMenuToggling = (doInitialize = true) => {
|
|
|
34
53
|
(0, useFormatMonitor_js_1.useFormatMonitor)(doInitialize
|
|
35
54
|
? (media) => {
|
|
36
55
|
if (media.becameHamburger) {
|
|
37
|
-
|
|
56
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuActive: true })));
|
|
38
57
|
htmlClass('menu-is-active', true);
|
|
39
58
|
htmlClass('menu-is-closed', true);
|
|
40
59
|
}
|
|
41
60
|
if (media.leftHamburger) {
|
|
42
61
|
_closeMenu();
|
|
43
|
-
|
|
62
|
+
setMenuState((state) => (Object.assign(Object.assign({}, state), { isMenuActive: undefined })));
|
|
44
63
|
htmlClass('menu-is-active', false);
|
|
45
64
|
htmlClass('menu-is-closed', false);
|
|
46
65
|
}
|
|
47
66
|
}
|
|
48
67
|
: noop);
|
|
49
|
-
const { toggleMenu, closeMenu } = (0, react_1.useRef)(doInitialize
|
|
50
|
-
? {
|
|
51
|
-
toggleMenu: () => {
|
|
52
|
-
if (stateRef.current.isMenuActive) {
|
|
53
|
-
stateRef.current.isMenuOpen ? _closeMenu() : _openMenu();
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
closeMenu: _closeMenu,
|
|
57
|
-
}
|
|
58
|
-
: { toggleMenu: noop, closeMenu: noop }).current;
|
|
59
68
|
return {
|
|
60
69
|
isMenuActive,
|
|
61
70
|
isMenuOpen,
|
|
62
|
-
toggleMenu,
|
|
63
|
-
closeMenu,
|
|
71
|
+
toggleMenu: stateRef.current.toggleMenu,
|
|
72
|
+
closeMenu: stateRef.current.closeMenu,
|
|
73
|
+
uiState,
|
|
64
74
|
};
|
|
65
75
|
};
|
|
66
76
|
exports.useMenuToggling = useMenuToggling;
|
package/utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './utils/browserSide.js';
|
|
2
2
|
export * from './utils/config.js';
|
|
3
|
-
export
|
|
3
|
+
export { HannaUIState, useHannaUIState } from './utils/HannaUIState.js';
|
|
4
4
|
export * from './utils/useDidChange.js';
|
|
5
5
|
export * from './utils/useFormatMonitor.js';
|
|
6
6
|
export * from './utils/useGetSVGtext.js';
|
|
7
|
+
export * from './utils/useMenuToggling.js';
|
|
7
8
|
export * from './utils/useMixedControlState.js';
|
|
8
9
|
export * from './utils/useScrollbarWidthCSSVar.js';
|
|
9
10
|
/**
|
package/utils.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHannaUIState = exports.HannaUIState = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./utils/browserSide.js"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./utils/config.js"), exports);
|
|
6
|
-
|
|
7
|
+
var HannaUIState_js_1 = require("./utils/HannaUIState.js");
|
|
8
|
+
Object.defineProperty(exports, "HannaUIState", { enumerable: true, get: function () { return HannaUIState_js_1.HannaUIState; } });
|
|
9
|
+
Object.defineProperty(exports, "useHannaUIState", { enumerable: true, get: function () { return HannaUIState_js_1.useHannaUIState; } });
|
|
7
10
|
tslib_1.__exportStar(require("./utils/useDidChange.js"), exports);
|
|
8
11
|
tslib_1.__exportStar(require("./utils/useFormatMonitor.js"), exports);
|
|
9
12
|
tslib_1.__exportStar(require("./utils/useGetSVGtext.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./utils/useMenuToggling.js"), exports);
|
|
10
14
|
tslib_1.__exportStar(require("./utils/useMixedControlState.js"), exports);
|
|
11
15
|
tslib_1.__exportStar(require("./utils/useScrollbarWidthCSSVar.js"), exports);
|