@reykjavik/hanna-react 0.10.67 → 0.10.68

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.
@@ -10,6 +10,7 @@ export declare type ArticleCarouselCardProps = {
10
10
  title: string;
11
11
  summary: string;
12
12
  href: string;
13
+ target?: string;
13
14
  color?: ColorFamily;
14
15
  /** NOTE: if both `color` and `theme` are specified
15
16
  * then `color` takes precedence.
@@ -9,11 +9,11 @@ const _Image_1 = tslib_1.__importDefault(require("../_abstract/_Image"));
9
9
  const _Link_1 = require("../_abstract/_Link");
10
10
  const constants_1 = require("../constants");
11
11
  const ArticleCarouselCard = (props) => {
12
- const { date, title, summary, href, moreLabel, color, theme, illustration, image } = props;
12
+ const { date, title, summary, href, target, moreLabel, color, theme, illustration, image, } = props;
13
13
  const photo = image === null || image === void 0 ? void 0 : image.photo;
14
14
  const imageProps = illustration ? { src: (0, assets_1.getIllustrationUrl)(illustration) } : image;
15
15
  return (react_1.default.createElement("div", { className: "ArticleCarouselCard", "data-color": color && constants_1.colorFamilies[color], "data-color-theme": !color ? theme && constants_1.themeOptions[theme] : undefined },
16
- react_1.default.createElement(_Link_1.Link, { className: "ArticleCarouselCard__link", href: href },
16
+ react_1.default.createElement(_Link_1.Link, { className: "ArticleCarouselCard__link", href: href, target: target },
17
17
  ' ',
18
18
  react_1.default.createElement(_Image_1.default, Object.assign({ placeholder: true, className: (0, getBemClass_1.default)('ArticleCarouselCard__illustration', photo && 'photo') }, imageProps)),
19
19
  react_1.default.createElement("h3", { className: "ArticleCarouselCard__title" }, title),
@@ -21,7 +21,7 @@ const ArticleCarouselCard = (props) => {
21
21
  ' ',
22
22
  date && react_1.default.createElement("span", { className: "ArticleCarouselCard__date" }, date),
23
23
  react_1.default.createElement("div", { className: "ArticleCarouselCard__summary" }, summary),
24
- moreLabel && (react_1.default.createElement(_Link_1.Link, { className: "ArticleCarouselCard__morelink", href: href, "aria-label": title },
24
+ moreLabel && (react_1.default.createElement(_Link_1.Link, { className: "ArticleCarouselCard__morelink", href: href, target: target, "aria-label": title },
25
25
  ' ',
26
26
  moreLabel,
27
27
  ' '))));
package/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.68
8
+
9
+ _2022-09-26_
10
+
11
+ - feat: Add prop `target` to `ArticleCarouselCardProps`
12
+ - feat: Improve `Selectbox`'s `options` and `onSelected` prop generics
13
+ - feat: Add prop `headingTag` to `ContentArticle` to support `<h1/>`
14
+ - feat: Add prop `forceH1` to `Heading`
15
+ - fix: Mark uncontrolled `TextInput`'s with user input `--filled` after reload
16
+ - fix(ts): Botched re-export of `SelectboxOption*` types
17
+
7
18
  ## 0.10.67
8
19
 
9
20
  _2022-09-14_
@@ -7,6 +7,7 @@ export declare type ContentArticleProps = {
7
7
  /** Date, author, etc. */
8
8
  meta: ArticleMetaProps['items'];
9
9
  headline: string;
10
+ headlineTag?: 'h1' | 'h2';
10
11
  topImage?: ContentImageProps;
11
12
  body: ReactNode;
12
13
  relatedLinks?: RelatedLinksProps;
package/ContentArticle.js CHANGED
@@ -13,7 +13,7 @@ const ContentArticle = (props) => {
13
13
  const [ref] = (0, seenEffect_1.useSeenEffect)(props.startSeen);
14
14
  return (react_1.default.createElement("div", { className: "ContentArticle", ref: ref },
15
15
  react_1.default.createElement(ArticleMeta_1.default, { items: props.meta }),
16
- react_1.default.createElement(Heading_1.default, null, props.headline),
16
+ react_1.default.createElement(Heading_1.default, { forceH1: props.headlineTag === 'h1' }, props.headline),
17
17
  react_1.default.createElement(TextBlock_1.default, { startSeen: true },
18
18
  props.topImage && react_1.default.createElement(ContentImage_1.default, Object.assign({}, props.topImage)),
19
19
  props.body),
package/Heading.d.ts CHANGED
@@ -11,6 +11,11 @@ export declare type HeadingProps = {
11
11
  Tag?: 'h2' | 'h3';
12
12
  size?: HeadingSize;
13
13
  children: ReactNode;
14
+ /**
15
+ * Make an exception and render a `<h1/>` element.
16
+ *
17
+ * This prop is ignore if the `Tag` prop is defined. */
18
+ forceH1?: boolean;
14
19
  } & ComponentLayoutProps;
15
20
  declare const Heading: (props: HeadingProps) => JSX.Element;
16
21
  export default Heading;
package/Heading.js CHANGED
@@ -10,7 +10,8 @@ const sizes = {
10
10
  large: 'large',
11
11
  };
12
12
  const Heading = (props) => {
13
- const { size = 'normal', Tag = 'h2', align, wide, children } = props;
13
+ const { size = 'normal', align, wide, children } = props;
14
+ const Tag = props.Tag || (props.forceH1 ? 'h1' : 'h2');
14
15
  return (react_1.default.createElement(Tag, { className: (0, getBemClass_1.default)('Heading', [
15
16
  sizes[size],
16
17
  align === 'right' && 'align--' + align,
package/Selectbox.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import type { SelectboxOption as _SelectboxOption, SelectboxOptions as _SelectboxOptions, SelectboxProps as _SelectboxProps } from '@hugsmidjan/react/Selectbox';
1
+ import type { SelectboxProps as _SelectboxProps } from '@hugsmidjan/react/Selectbox';
2
2
  import { FormFieldWrappingProps } from './FormField';
3
- export declare type SelectboxOption = _SelectboxOption;
3
+ export { type SelectboxOption, type SelectboxOptions as SelectboxOptionList,
4
4
  /** @deprecated Use `SelectboxOptionList` instead (Will be removed in v0.11) */
5
- export declare type SelectboxOptions = _SelectboxOptions;
6
- export declare type SelectboxOptionList = _SelectboxOptions;
7
- export declare type SelectboxProps = FormFieldWrappingProps & Omit<_SelectboxProps, 'bem'> & {
5
+ type SelectboxOptions, } from '@hugsmidjan/react/Selectbox';
6
+ declare type OptionOrValue = _SelectboxProps['options'][0];
7
+ export declare type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem'> & {
8
8
  small?: boolean;
9
9
  };
10
- declare const Selectbox: (props: SelectboxProps) => JSX.Element;
10
+ declare const Selectbox: <O extends import("@hugsmidjan/react/__types/Selectbox.privates").OptionOrValue>(props: SelectboxProps<O>) => JSX.Element;
11
11
  export default Selectbox;
package/TextInput.js CHANGED
@@ -6,7 +6,8 @@ const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/g
6
6
  const FormField_1 = tslib_1.__importDefault(require("./FormField"));
7
7
  const TextInput = (props) => {
8
8
  var _a;
9
- const { className, label, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, onChange, small, type, ssr, inputRef } = props, inputElementProps = tslib_1.__rest(props, ["className", "label", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "onChange", "small", "type", "ssr", "inputRef"]);
9
+ const _inputRef = (0, react_1.useRef)(null);
10
+ const { className, label, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, onChange, small, type, ssr, inputRef = _inputRef } = props, inputElementProps = tslib_1.__rest(props, ["className", "label", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "onChange", "small", "type", "ssr", "inputRef"]);
10
11
  const { value, defaultValue, placeholder } = inputElementProps;
11
12
  const [hasValue, setHasValue] = (0, react_1.useState)(undefined);
12
13
  const filled = !!((_a = value !== null && value !== void 0 ? value : hasValue) !== null && _a !== void 0 ? _a : !!defaultValue);
@@ -22,6 +23,12 @@ const TextInput = (props) => {
22
23
  // TypeScript is silly sometimes.
23
24
  e);
24
25
  };
26
+ (0, react_1.useEffect)(() => {
27
+ var _a;
28
+ if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) {
29
+ setHasValue(true);
30
+ }
31
+ }, []);
25
32
  return (react_1.default.createElement(FormField_1.default, { className: (0, getBemClass_1.default)('TextInput', modifiers, className), ssr: ssr, small: small, label: label, empty: empty, filled: filled, assistText: assistText, hideLabel: hideLabel, disabled: disabled, readOnly: readOnly, invalid: invalid, errorMessage: errorMessage, required: required, reqText: reqText, id: id, renderInput: (className, inputProps, addFocusProps) => multiline ? (react_1.default.createElement("textarea", Object.assign({ className: className.input, onChange: _onChange }, inputProps, addFocusProps(inputElementProps), { ref: inputRef }))) : (react_1.default.createElement("input", Object.assign({ className: className.input, onChange: _onChange, type: type }, inputProps, addFocusProps(inputElementProps), { ref: inputRef }))) }));
26
33
  };
27
34
  exports.default = TextInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.67",
3
+ "version": "0.10.68",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",