@reykjavik/hanna-react 0.10.104 → 0.10.105
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/AutosuggestSearch.js +3 -3
- package/CHANGELOG.md +10 -0
- package/Layout.js +4 -9
- package/SiteSearchAutocomplete.js +3 -3
- package/SiteSearchInput.d.ts +2 -0
- package/SiteSearchInput.js +2 -2
- package/WizardLayout.js +3 -10
- package/_abstract/_Layouts.d.ts +4 -0
- package/_abstract/_Layouts.js +29 -0
- package/esm/AutosuggestSearch.js +4 -4
- package/esm/Layout.js +4 -9
- package/esm/SiteSearchAutocomplete.js +4 -4
- package/esm/SiteSearchInput.d.ts +2 -0
- package/esm/SiteSearchInput.js +2 -2
- package/esm/WizardLayout.js +3 -10
- package/esm/_abstract/_Layouts.d.ts +4 -0
- package/esm/_abstract/_Layouts.js +23 -0
- package/package.json +2 -2
package/AutosuggestSearch.js
CHANGED
|
@@ -39,7 +39,7 @@ const AutosuggestSearch = (props) => {
|
|
|
39
39
|
? opt.label.toString()
|
|
40
40
|
: getOptionValue(opt), InputComponent = SearchInput_js_1.default, renderInputField, wrapperProps, } = props;
|
|
41
41
|
const [value, setValue] = (0, react_1.useState)('');
|
|
42
|
-
const inputRef = (0, react_1.
|
|
42
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
43
43
|
const txt = (0, i18n_1.getTexts)(props, exports.defaultAutosuggestSearchTexts);
|
|
44
44
|
return (react_1.default.createElement(react_autosuggest_1.default, { theme: {
|
|
45
45
|
container: 'AutosuggestSearch',
|
|
@@ -63,8 +63,8 @@ const AutosuggestSearch = (props) => {
|
|
|
63
63
|
? (inputProps) => renderInputField(inputProps, txt)
|
|
64
64
|
: (inputProps) => {
|
|
65
65
|
/* prettier-ignore */
|
|
66
|
-
const { className, type, disabled, readOnly, required, children } = inputProps, siteSearchProps = tslib_1.__rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children"]);
|
|
67
|
-
return (react_1.default.createElement(InputComponent, Object.assign({ lang: props.lang }, siteSearchProps, { button: button, label: txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
66
|
+
const { className, type, disabled, readOnly, required, children, ref } = inputProps, siteSearchProps = tslib_1.__rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children", "ref"]);
|
|
67
|
+
return (react_1.default.createElement(InputComponent, Object.assign({ lang: props.lang }, siteSearchProps, { inputRef: ref, button: button, label: txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
68
68
|
} }));
|
|
69
69
|
};
|
|
70
70
|
exports.AutosuggestSearch = AutosuggestSearch;
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.105
|
|
8
|
+
|
|
9
|
+
_2023-10-04_
|
|
10
|
+
|
|
11
|
+
- `Layout` and `WizardLayout`:
|
|
12
|
+
- feat: Implement `__header__homelink` and `__header__sitename` markup
|
|
13
|
+
- feat: Warn about missing/redundant `siteName` prop
|
|
14
|
+
- fix: Focus error on `SiteSearchAutocomplete` and `AutosuggestSearch`
|
|
15
|
+
suggestion click
|
|
16
|
+
|
|
7
17
|
## 0.10.104
|
|
8
18
|
|
|
9
19
|
_2023-09-13_
|
package/Layout.js
CHANGED
|
@@ -4,9 +4,8 @@ exports.Layout = exports.defaultLayoutTexts = void 0;
|
|
|
4
4
|
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
|
-
const assets_1 = require("@reykjavik/hanna-utils/assets");
|
|
8
7
|
const i18n_1 = require("@reykjavik/hanna-utils/i18n");
|
|
9
|
-
const
|
|
8
|
+
const _Layouts_js_1 = require("./_abstract/_Layouts.js");
|
|
10
9
|
const _Link_js_1 = require("./_abstract/_Link.js");
|
|
11
10
|
const utils_js_1 = require("./utils.js");
|
|
12
11
|
exports.defaultLayoutTexts = {
|
|
@@ -28,19 +27,15 @@ exports.defaultLayoutTexts = {
|
|
|
28
27
|
};
|
|
29
28
|
const Layout = (props) => {
|
|
30
29
|
(0, utils_js_1.useScrollbarWidthCSSVar)();
|
|
31
|
-
const { ssr, globalAlerts, mainChildren, navChildren, footerChildren, colorTheme, children, siteName
|
|
30
|
+
const { ssr, globalAlerts, mainChildren, navChildren, footerChildren, colorTheme, children, siteName, logoLink = '/', wrapperProps, } = props;
|
|
31
|
+
(0, _Layouts_js_1.issueSiteNameWarningInDev)(props);
|
|
32
32
|
const { isMenuActive, uiState, closeMenu, toggleMenu } = (0, utils_js_1.useMenuToggling)(ssr !== 'ssr-only');
|
|
33
33
|
const txt = (0, i18n_1.getTexts)(props, exports.defaultLayoutTexts);
|
|
34
34
|
return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)('Layout', props.modifier, (wrapperProps || {}).className), "data-color-theme": colorTheme }),
|
|
35
35
|
globalAlerts && (react_1.default.createElement("div", { className: "Layout__alerts", role: "alert" }, globalAlerts)),
|
|
36
36
|
react_1.default.createElement("div", { className: "Layout__content" },
|
|
37
37
|
react_1.default.createElement("div", { className: "Layout__header", role: "banner" },
|
|
38
|
-
|
|
39
|
-
' ',
|
|
40
|
-
react_1.default.createElement(_Image_js_1.Image, { bem: undefined, inline: true, src: (0, assets_1.getAssetUrl)('reykjavik-logo.svg'), altText: "Reykjav\u00EDk" }),
|
|
41
|
-
' ',
|
|
42
|
-
siteName,
|
|
43
|
-
' '),
|
|
38
|
+
(0, _Layouts_js_1.renderLayoutHomeLink)('Layout', logoLink, siteName),
|
|
44
39
|
' ',
|
|
45
40
|
navChildren && (react_1.default.createElement(_Link_js_1.Link, { className: "Layout__header__skiplink", href: "#pagenav", onClick: isMenuActive &&
|
|
46
41
|
((e) => {
|
|
@@ -35,7 +35,7 @@ exports.defaultSiteSearchACTexts = {
|
|
|
35
35
|
const SiteSearchAutocomplete = (props) => {
|
|
36
36
|
const { suggestions, setSuggestions, renderSuggestion, getSuggestionValue, onSuggestionsFetchRequested, onSuggestionSelected, onSuggestionHighlighted, onSubmit, onButtonClick, bem = 'SiteSearchAutocomplete', wrapperProps, } = props;
|
|
37
37
|
const [value, setValue] = (0, react_1.useState)('');
|
|
38
|
-
const inputRef = (0, react_1.
|
|
38
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
39
39
|
const txt = (0, i18n_1.getTexts)(props, exports.defaultSiteSearchACTexts);
|
|
40
40
|
if (process.env.NODE_ENV !== 'production' && !txt.buttonText) {
|
|
41
41
|
console.warn('SiteSearchAutocomplete: Missing translation: `buttonText`');
|
|
@@ -56,8 +56,8 @@ const SiteSearchAutocomplete = (props) => {
|
|
|
56
56
|
},
|
|
57
57
|
}, renderInputComponent: (inputProps) => {
|
|
58
58
|
/* prettier-ignore */
|
|
59
|
-
const { className, type, disabled, readOnly, required, children } = inputProps, siteSearchProps = tslib_1.__rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children"]);
|
|
60
|
-
return (react_1.default.createElement(SiteSearchInput_js_1.SiteSearchInput, Object.assign({}, siteSearchProps, { label: props.label || // eslint-disable-line deprecation/deprecation
|
|
59
|
+
const { className, type, disabled, readOnly, required, children, ref } = inputProps, siteSearchProps = tslib_1.__rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children", "ref"]);
|
|
60
|
+
return (react_1.default.createElement(SiteSearchInput_js_1.SiteSearchInput, Object.assign({}, siteSearchProps, { inputRef: ref, label: props.label || // eslint-disable-line deprecation/deprecation
|
|
61
61
|
txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
62
62
|
} }));
|
|
63
63
|
};
|
package/SiteSearchInput.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
import { FormFieldWrappingProps } from './FormField.js';
|
|
2
3
|
type InputElmProps = Omit<JSX.IntrinsicElements['input'], 'className' | 'type' | 'disabled' | 'readOnly' | 'required' | 'onSubmit' | 'ref' | 'value'> & {
|
|
3
4
|
value?: string;
|
|
4
5
|
};
|
|
5
6
|
export type SiteSearchInputProps = Pick<FormFieldWrappingProps, 'id' | 'label' | 'ssr' | 'wrapperProps'> & {
|
|
7
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
6
8
|
/**
|
|
7
9
|
* Triggered when user hits ENTER key with the focus inside the input field.
|
|
8
10
|
*
|
package/SiteSearchInput.js
CHANGED
|
@@ -7,7 +7,7 @@ const FormField_js_1 = tslib_1.__importStar(require("./FormField.js"));
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
const SiteSearchInput = (props) => {
|
|
9
9
|
var _a;
|
|
10
|
-
const _b = (0, FormField_js_1.groupFormFieldWrapperProps)(props), { onChange, buttonText = 'Leita', onSubmit, onButtonClick = props.onSubmit, button, onKeyDown, placeholder = typeof props.label === 'string' ? props.label : undefined, fieldWrapperProps } = _b, inputElementProps = tslib_1.__rest(_b, ["onChange", "buttonText", "onSubmit", "onButtonClick", "button", "onKeyDown", "placeholder", "fieldWrapperProps"]);
|
|
10
|
+
const _b = (0, FormField_js_1.groupFormFieldWrapperProps)(props), { onChange, inputRef, buttonText = 'Leita', onSubmit, onButtonClick = props.onSubmit, button, onKeyDown, placeholder = typeof props.label === 'string' ? props.label : undefined, fieldWrapperProps } = _b, inputElementProps = tslib_1.__rest(_b, ["onChange", "inputRef", "buttonText", "onSubmit", "onButtonClick", "button", "onKeyDown", "placeholder", "fieldWrapperProps"]);
|
|
11
11
|
const { value, defaultValue } = inputElementProps;
|
|
12
12
|
const [hasValue, setHasValue] = (0, react_1.useState)(undefined);
|
|
13
13
|
const filled = !!((_a = value !== null && value !== void 0 ? value : hasValue) !== null && _a !== void 0 ? _a : !!defaultValue);
|
|
@@ -27,7 +27,7 @@ const SiteSearchInput = (props) => {
|
|
|
27
27
|
}
|
|
28
28
|
onKeyDown && onKeyDown(e);
|
|
29
29
|
}
|
|
30
|
-
: onKeyDown }, inputElementProps)),
|
|
30
|
+
: onKeyDown }, inputElementProps, { ref: inputRef })),
|
|
31
31
|
' ',
|
|
32
32
|
showButton && (react_1.default.createElement("button", { className: "SiteSearchInput__button", type: "submit", onClick: onButtonClick &&
|
|
33
33
|
((e) => onButtonClick(e.currentTarget.value) !== true && e.preventDefault()), title: buttonText }, buttonText)))) })));
|
package/WizardLayout.js
CHANGED
|
@@ -4,27 +4,20 @@ exports.WizardLayout = void 0;
|
|
|
4
4
|
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
|
-
const
|
|
8
|
-
const _Image_js_1 = require("./_abstract/_Image.js");
|
|
9
|
-
const _Link_js_1 = require("./_abstract/_Link.js");
|
|
7
|
+
const _Layouts_js_1 = require("./_abstract/_Layouts.js");
|
|
10
8
|
const useScrollbarWidthCSSVar_js_1 = require("./utils/useScrollbarWidthCSSVar.js");
|
|
11
9
|
const utils_js_1 = require("./utils.js");
|
|
12
10
|
const WizardLayout = (props) => {
|
|
13
11
|
(0, useScrollbarWidthCSSVar_js_1.useScrollbarWidthCSSVar)();
|
|
14
12
|
const {
|
|
15
13
|
// ssr,
|
|
16
|
-
wizardStepper, wizardFooter, children, colorTheme, logoLink = '/', siteName
|
|
14
|
+
wizardStepper, wizardFooter, children, colorTheme, logoLink = '/', siteName, globalAlerts, wrapperProps, } = props;
|
|
17
15
|
const isBrowser = (0, utils_js_1.useIsBrowserSide)( /* ssr */);
|
|
18
16
|
return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)('WizardLayout', null, (wrapperProps || {}).className), "data-sprinkled": isBrowser, "data-color-theme": colorTheme }),
|
|
19
17
|
globalAlerts && (react_1.default.createElement("div", { className: "WizardLayout__alerts", role: "alert" }, globalAlerts)),
|
|
20
18
|
react_1.default.createElement("div", { className: "WizardLayout__content" },
|
|
21
19
|
react_1.default.createElement("div", { className: "WizardLayout__header", role: "banner" },
|
|
22
|
-
|
|
23
|
-
' ',
|
|
24
|
-
react_1.default.createElement(_Image_js_1.Image, { bem: undefined, inline: true, src: (0, assets_1.getAssetUrl)('reykjavik-logo.svg'), altText: "Reykjav\u00EDk" }),
|
|
25
|
-
' ',
|
|
26
|
-
siteName,
|
|
27
|
-
' '),
|
|
20
|
+
(0, _Layouts_js_1.renderLayoutHomeLink)('WizardLayout', logoLink, siteName),
|
|
28
21
|
' '),
|
|
29
22
|
react_1.default.createElement("div", { className: "WizardLayout__wrap" },
|
|
30
23
|
wizardStepper && (react_1.default.createElement("div", { className: "WizardLayout__stepper", role: "navigation" }, wizardStepper)),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.issueSiteNameWarningInDev = exports.renderLayoutHomeLink = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const assets_1 = require("@reykjavik/hanna-utils/assets");
|
|
7
|
+
const _Image_js_1 = require("./_Image.js");
|
|
8
|
+
const _Link_js_1 = require("./_Link.js");
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
const renderLayoutHomeLink = (bem, logoLink, siteName) => (react_1.default.createElement(_Link_js_1.Link, { className: `${bem}__header__homelink`, href: logoLink },
|
|
11
|
+
' ',
|
|
12
|
+
react_1.default.createElement(_Image_js_1.Image, { bem: undefined, className: `${bem}__header__logo`, src: (0, assets_1.getRvkLogoUrl)(siteName ? 'reykjavik-logo-notext.svg' : 'reykjavik-logo.svg'), altText: "Reykjav\u00EDk", inline: true }),
|
|
13
|
+
' ',
|
|
14
|
+
siteName && react_1.default.createElement("span", { className: `${bem}__header__sitename` }, siteName),
|
|
15
|
+
' '));
|
|
16
|
+
exports.renderLayoutHomeLink = renderLayoutHomeLink;
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
const issueSiteNameWarningInDev = (props) => {
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
if (!('siteName' in props)) {
|
|
21
|
+
console.warn('Layout: Prop `siteName` is missing.\n', 'If this is intentional, please pass `undefined` or the empty string.');
|
|
22
|
+
}
|
|
23
|
+
else if (props.siteName &&
|
|
24
|
+
['Reykjavík', 'Reykjavik', 'Reykjavíkurborg', 'Reykjavík City'].includes(props.siteName.trim())) {
|
|
25
|
+
console.warn('Layout: `siteName` should not be set to "Reykjavík" (or something equally generic).\n', 'If you are making a website for Reykjavíkurborg, then you should leave `siteName` empty, ', 'as the SVG logo already says "Reykjavík".\n');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.issueSiteNameWarningInDev = issueSiteNameWarningInDev;
|
package/esm/AutosuggestSearch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useRef, useState } from 'react';
|
|
3
3
|
import Autosuggest from 'react-autosuggest';
|
|
4
4
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
5
5
|
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
@@ -36,7 +36,7 @@ export const AutosuggestSearch = (props) => {
|
|
|
36
36
|
? opt.label.toString()
|
|
37
37
|
: getOptionValue(opt), InputComponent = SearchInput, renderInputField, wrapperProps, } = props;
|
|
38
38
|
const [value, setValue] = useState('');
|
|
39
|
-
const inputRef =
|
|
39
|
+
const inputRef = useRef(null);
|
|
40
40
|
const txt = getTexts(props, defaultAutosuggestSearchTexts);
|
|
41
41
|
return (React.createElement(Autosuggest, { theme: {
|
|
42
42
|
container: 'AutosuggestSearch',
|
|
@@ -60,7 +60,7 @@ export const AutosuggestSearch = (props) => {
|
|
|
60
60
|
? (inputProps) => renderInputField(inputProps, txt)
|
|
61
61
|
: (inputProps) => {
|
|
62
62
|
/* prettier-ignore */
|
|
63
|
-
const { className, type, disabled, readOnly, required, children } = inputProps, siteSearchProps = __rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children"]);
|
|
64
|
-
return (React.createElement(InputComponent, Object.assign({ lang: props.lang }, siteSearchProps, { button: button, label: txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
63
|
+
const { className, type, disabled, readOnly, required, children, ref } = inputProps, siteSearchProps = __rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children", "ref"]);
|
|
64
|
+
return (React.createElement(InputComponent, Object.assign({ lang: props.lang }, siteSearchProps, { inputRef: ref, button: button, label: txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
65
65
|
} }));
|
|
66
66
|
};
|
package/esm/Layout.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
3
|
-
import { getAssetUrl } from '@reykjavik/hanna-utils/assets';
|
|
4
3
|
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
5
|
-
import {
|
|
4
|
+
import { issueSiteNameWarningInDev, renderLayoutHomeLink } from './_abstract/_Layouts.js';
|
|
6
5
|
import { Link } from './_abstract/_Link.js';
|
|
7
6
|
import { HannaUIState, useMenuToggling, useScrollbarWidthCSSVar, } from './utils.js';
|
|
8
7
|
export const defaultLayoutTexts = {
|
|
@@ -24,19 +23,15 @@ export const defaultLayoutTexts = {
|
|
|
24
23
|
};
|
|
25
24
|
export const Layout = (props) => {
|
|
26
25
|
useScrollbarWidthCSSVar();
|
|
27
|
-
const { ssr, globalAlerts, mainChildren, navChildren, footerChildren, colorTheme, children, siteName
|
|
26
|
+
const { ssr, globalAlerts, mainChildren, navChildren, footerChildren, colorTheme, children, siteName, logoLink = '/', wrapperProps, } = props;
|
|
27
|
+
issueSiteNameWarningInDev(props);
|
|
28
28
|
const { isMenuActive, uiState, closeMenu, toggleMenu } = useMenuToggling(ssr !== 'ssr-only');
|
|
29
29
|
const txt = getTexts(props, defaultLayoutTexts);
|
|
30
30
|
return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('Layout', props.modifier, (wrapperProps || {}).className), "data-color-theme": colorTheme }),
|
|
31
31
|
globalAlerts && (React.createElement("div", { className: "Layout__alerts", role: "alert" }, globalAlerts)),
|
|
32
32
|
React.createElement("div", { className: "Layout__content" },
|
|
33
33
|
React.createElement("div", { className: "Layout__header", role: "banner" },
|
|
34
|
-
|
|
35
|
-
' ',
|
|
36
|
-
React.createElement(Image, { bem: undefined, inline: true, src: getAssetUrl('reykjavik-logo.svg'), altText: "Reykjav\u00EDk" }),
|
|
37
|
-
' ',
|
|
38
|
-
siteName,
|
|
39
|
-
' '),
|
|
34
|
+
renderLayoutHomeLink('Layout', logoLink, siteName),
|
|
40
35
|
' ',
|
|
41
36
|
navChildren && (React.createElement(Link, { className: "Layout__header__skiplink", href: "#pagenav", onClick: isMenuActive &&
|
|
42
37
|
((e) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useRef, useState } from 'react';
|
|
3
3
|
import Autosuggest from 'react-autosuggest';
|
|
4
4
|
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
5
5
|
import { SiteSearchInput } from './SiteSearchInput.js';
|
|
@@ -32,7 +32,7 @@ export const defaultSiteSearchACTexts = {
|
|
|
32
32
|
export const SiteSearchAutocomplete = (props) => {
|
|
33
33
|
const { suggestions, setSuggestions, renderSuggestion, getSuggestionValue, onSuggestionsFetchRequested, onSuggestionSelected, onSuggestionHighlighted, onSubmit, onButtonClick, bem = 'SiteSearchAutocomplete', wrapperProps, } = props;
|
|
34
34
|
const [value, setValue] = useState('');
|
|
35
|
-
const inputRef =
|
|
35
|
+
const inputRef = useRef(null);
|
|
36
36
|
const txt = getTexts(props, defaultSiteSearchACTexts);
|
|
37
37
|
if (process.env.NODE_ENV !== 'production' && !txt.buttonText) {
|
|
38
38
|
console.warn('SiteSearchAutocomplete: Missing translation: `buttonText`');
|
|
@@ -53,8 +53,8 @@ export const SiteSearchAutocomplete = (props) => {
|
|
|
53
53
|
},
|
|
54
54
|
}, renderInputComponent: (inputProps) => {
|
|
55
55
|
/* prettier-ignore */
|
|
56
|
-
const { className, type, disabled, readOnly, required, children } = inputProps, siteSearchProps = __rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children"]);
|
|
57
|
-
return (React.createElement(SiteSearchInput, Object.assign({}, siteSearchProps, { label: props.label || // eslint-disable-line deprecation/deprecation
|
|
56
|
+
const { className, type, disabled, readOnly, required, children, ref } = inputProps, siteSearchProps = __rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children", "ref"]);
|
|
57
|
+
return (React.createElement(SiteSearchInput, Object.assign({}, siteSearchProps, { inputRef: ref, label: props.label || // eslint-disable-line deprecation/deprecation
|
|
58
58
|
txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
|
|
59
59
|
} }));
|
|
60
60
|
};
|
package/esm/SiteSearchInput.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
import { FormFieldWrappingProps } from './FormField.js';
|
|
2
3
|
type InputElmProps = Omit<JSX.IntrinsicElements['input'], 'className' | 'type' | 'disabled' | 'readOnly' | 'required' | 'onSubmit' | 'ref' | 'value'> & {
|
|
3
4
|
value?: string;
|
|
4
5
|
};
|
|
5
6
|
export type SiteSearchInputProps = Pick<FormFieldWrappingProps, 'id' | 'label' | 'ssr' | 'wrapperProps'> & {
|
|
7
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
6
8
|
/**
|
|
7
9
|
* Triggered when user hits ENTER key with the focus inside the input field.
|
|
8
10
|
*
|
package/esm/SiteSearchInput.js
CHANGED
|
@@ -4,7 +4,7 @@ import FormField, { groupFormFieldWrapperProps, } from './FormField.js';
|
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
export const SiteSearchInput = (props) => {
|
|
6
6
|
var _a;
|
|
7
|
-
const _b = groupFormFieldWrapperProps(props), { onChange, buttonText = 'Leita', onSubmit, onButtonClick = props.onSubmit, button, onKeyDown, placeholder = typeof props.label === 'string' ? props.label : undefined, fieldWrapperProps } = _b, inputElementProps = __rest(_b, ["onChange", "buttonText", "onSubmit", "onButtonClick", "button", "onKeyDown", "placeholder", "fieldWrapperProps"]);
|
|
7
|
+
const _b = groupFormFieldWrapperProps(props), { onChange, inputRef, buttonText = 'Leita', onSubmit, onButtonClick = props.onSubmit, button, onKeyDown, placeholder = typeof props.label === 'string' ? props.label : undefined, fieldWrapperProps } = _b, inputElementProps = __rest(_b, ["onChange", "inputRef", "buttonText", "onSubmit", "onButtonClick", "button", "onKeyDown", "placeholder", "fieldWrapperProps"]);
|
|
8
8
|
const { value, defaultValue } = inputElementProps;
|
|
9
9
|
const [hasValue, setHasValue] = useState(undefined);
|
|
10
10
|
const filled = !!((_a = value !== null && value !== void 0 ? value : hasValue) !== null && _a !== void 0 ? _a : !!defaultValue);
|
|
@@ -24,7 +24,7 @@ export const SiteSearchInput = (props) => {
|
|
|
24
24
|
}
|
|
25
25
|
onKeyDown && onKeyDown(e);
|
|
26
26
|
}
|
|
27
|
-
: onKeyDown }, inputElementProps)),
|
|
27
|
+
: onKeyDown }, inputElementProps, { ref: inputRef })),
|
|
28
28
|
' ',
|
|
29
29
|
showButton && (React.createElement("button", { className: "SiteSearchInput__button", type: "submit", onClick: onButtonClick &&
|
|
30
30
|
((e) => onButtonClick(e.currentTarget.value) !== true && e.preventDefault()), title: buttonText }, buttonText)))) })));
|
package/esm/WizardLayout.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
3
|
-
import {
|
|
4
|
-
import { Image } from './_abstract/_Image.js';
|
|
5
|
-
import { Link } from './_abstract/_Link.js';
|
|
3
|
+
import { renderLayoutHomeLink } from './_abstract/_Layouts.js';
|
|
6
4
|
import { useScrollbarWidthCSSVar } from './utils/useScrollbarWidthCSSVar.js';
|
|
7
5
|
import { useIsBrowserSide } from './utils.js';
|
|
8
6
|
export const WizardLayout = (props) => {
|
|
9
7
|
useScrollbarWidthCSSVar();
|
|
10
8
|
const {
|
|
11
9
|
// ssr,
|
|
12
|
-
wizardStepper, wizardFooter, children, colorTheme, logoLink = '/', siteName
|
|
10
|
+
wizardStepper, wizardFooter, children, colorTheme, logoLink = '/', siteName, globalAlerts, wrapperProps, } = props;
|
|
13
11
|
const isBrowser = useIsBrowserSide( /* ssr */);
|
|
14
12
|
return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('WizardLayout', null, (wrapperProps || {}).className), "data-sprinkled": isBrowser, "data-color-theme": colorTheme }),
|
|
15
13
|
globalAlerts && (React.createElement("div", { className: "WizardLayout__alerts", role: "alert" }, globalAlerts)),
|
|
16
14
|
React.createElement("div", { className: "WizardLayout__content" },
|
|
17
15
|
React.createElement("div", { className: "WizardLayout__header", role: "banner" },
|
|
18
|
-
|
|
19
|
-
' ',
|
|
20
|
-
React.createElement(Image, { bem: undefined, inline: true, src: getAssetUrl('reykjavik-logo.svg'), altText: "Reykjav\u00EDk" }),
|
|
21
|
-
' ',
|
|
22
|
-
siteName,
|
|
23
|
-
' '),
|
|
16
|
+
renderLayoutHomeLink('WizardLayout', logoLink, siteName),
|
|
24
17
|
' '),
|
|
25
18
|
React.createElement("div", { className: "WizardLayout__wrap" },
|
|
26
19
|
wizardStepper && (React.createElement("div", { className: "WizardLayout__stepper", role: "navigation" }, wizardStepper)),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getRvkLogoUrl } from '@reykjavik/hanna-utils/assets';
|
|
3
|
+
import { Image } from './_Image.js';
|
|
4
|
+
import { Link } from './_Link.js';
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
export const renderLayoutHomeLink = (bem, logoLink, siteName) => (React.createElement(Link, { className: `${bem}__header__homelink`, href: logoLink },
|
|
7
|
+
' ',
|
|
8
|
+
React.createElement(Image, { bem: undefined, className: `${bem}__header__logo`, src: getRvkLogoUrl(siteName ? 'reykjavik-logo-notext.svg' : 'reykjavik-logo.svg'), altText: "Reykjav\u00EDk", inline: true }),
|
|
9
|
+
' ',
|
|
10
|
+
siteName && React.createElement("span", { className: `${bem}__header__sitename` }, siteName),
|
|
11
|
+
' '));
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
export const issueSiteNameWarningInDev = (props) => {
|
|
14
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
+
if (!('siteName' in props)) {
|
|
16
|
+
console.warn('Layout: Prop `siteName` is missing.\n', 'If this is intentional, please pass `undefined` or the empty string.');
|
|
17
|
+
}
|
|
18
|
+
else if (props.siteName &&
|
|
19
|
+
['Reykjavík', 'Reykjavik', 'Reykjavíkurborg', 'Reykjavík City'].includes(props.siteName.trim())) {
|
|
20
|
+
console.warn('Layout: `siteName` should not be set to "Reykjavík" (or something equally generic).\n', 'If you are making a website for Reykjavíkurborg, then you should leave `siteName` empty, ', 'as the SVG logo already says "Reykjavík".\n');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/hanna-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.105",
|
|
4
4
|
"author": "Reykjavík (http://www.reykjavik.is)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Hugsmiðjan ehf (http://www.hugsmidjan.is)",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@hugsmidjan/qj": "^4.22.1",
|
|
19
19
|
"@hugsmidjan/react": "^0.4.32",
|
|
20
20
|
"@reykjavik/hanna-css": "^0.4.7",
|
|
21
|
-
"@reykjavik/hanna-utils": "^0.2.
|
|
21
|
+
"@reykjavik/hanna-utils": "^0.2.11",
|
|
22
22
|
"@types/react-autosuggest": "^10.1.0",
|
|
23
23
|
"@types/react-datepicker": "^4.8.0",
|
|
24
24
|
"@types/react-transition-group": "^4.4.0",
|