@reykjavik/hanna-react 0.10.76 → 0.10.77

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.
Files changed (143) hide show
  1. package/AccordionList.d.ts +3 -3
  2. package/AccordionList.js +1 -1
  3. package/ActionCards.d.ts +2 -2
  4. package/Alert.d.ts +4 -4
  5. package/Alert.js +4 -4
  6. package/ArticleCards.d.ts +3 -3
  7. package/ArticleCarousel/_ArticleCarouselCard.d.ts +2 -2
  8. package/ArticleCarousel.d.ts +2 -2
  9. package/ArticleMeta.d.ts +2 -2
  10. package/Attention.d.ts +1 -1
  11. package/BasicTable.d.ts +1 -1
  12. package/BgBox.d.ts +1 -1
  13. package/Bling.d.ts +5 -5
  14. package/BlockQuote.d.ts +1 -1
  15. package/BreadCrumbs.d.ts +3 -3
  16. package/ButtonBack.d.ts +1 -1
  17. package/ButtonBar.d.ts +1 -1
  18. package/ButtonPrimary.d.ts +1 -1
  19. package/ButtonSecondary.d.ts +1 -1
  20. package/ButtonTertiary.d.ts +3 -3
  21. package/CHANGELOG.md +15 -1
  22. package/CarouselStepper.d.ts +1 -1
  23. package/CenterColumn.d.ts +1 -1
  24. package/Checkbox.d.ts +1 -1
  25. package/CheckboxButton.d.ts +4 -0
  26. package/CheckboxButton.js +9 -0
  27. package/CheckboxButtonsGroup.d.ts +3 -2
  28. package/CheckboxButtonsGroup.js +2 -3
  29. package/CheckboxGroup.d.ts +4 -3
  30. package/CityBlock.d.ts +1 -1
  31. package/ContactBubble.d.ts +5 -5
  32. package/ContactBubble.js +2 -1
  33. package/ContentArticle.d.ts +1 -1
  34. package/ContentArticle.js +4 -2
  35. package/ContentImage.d.ts +1 -1
  36. package/Datepicker.d.ts +2 -2
  37. package/Datepicker.js +5 -5
  38. package/ExtraLinks.d.ts +4 -4
  39. package/FeatureList.d.ts +1 -1
  40. package/FieldGroup.d.ts +1 -1
  41. package/FileInput/_FileInput.utils.d.ts +1 -1
  42. package/FileInput/_FileInputFileList.d.ts +1 -1
  43. package/FileInput.d.ts +1 -1
  44. package/Foonote.d.ts +1 -1
  45. package/FooterBadges.d.ts +1 -1
  46. package/FooterInfo.d.ts +3 -3
  47. package/Footnote.d.ts +1 -1
  48. package/Form.d.ts +1 -1
  49. package/FormField.d.ts +8 -8
  50. package/FormField.js +7 -6
  51. package/Gallery/_GalleryItem.d.ts +1 -1
  52. package/Gallery/_GalleryModal.d.ts +1 -1
  53. package/Gallery/_GalleryModalContext.d.ts +1 -1
  54. package/Gallery.d.ts +3 -3
  55. package/GridBlocks.d.ts +3 -3
  56. package/Heading.d.ts +2 -2
  57. package/HeroBlock.d.ts +2 -2
  58. package/IframeBlock.d.ts +1 -1
  59. package/Illustration.d.ts +1 -1
  60. package/ImageCards.d.ts +3 -3
  61. package/InfoBlock.d.ts +1 -1
  62. package/InfoHero.d.ts +2 -2
  63. package/IslandBlock.d.ts +4 -4
  64. package/IslandPageBlock.d.ts +3 -3
  65. package/LabeledTextBlock.d.ts +1 -1
  66. package/Layout.d.ts +3 -3
  67. package/Layout.js +2 -2
  68. package/MainMenu/_Auxiliary.d.ts +2 -2
  69. package/MainMenu/_PrimaryPanel.d.ts +1 -1
  70. package/MainMenu.d.ts +8 -8
  71. package/MainMenu.js +2 -2
  72. package/MiniMetrics.d.ts +1 -1
  73. package/Modal.d.ts +1 -1
  74. package/NameCard.d.ts +4 -4
  75. package/NameCards.d.ts +1 -1
  76. package/NewsHero.d.ts +2 -2
  77. package/PageFilter.d.ts +1 -1
  78. package/PageHeading.d.ts +1 -1
  79. package/Picture.d.ts +1 -1
  80. package/ProcessOverview.d.ts +2 -2
  81. package/PullQuote.d.ts +1 -1
  82. package/README.md +1 -1
  83. package/RadioButtonsGroup.d.ts +3 -2
  84. package/RadioButtonsGroup.js +2 -2
  85. package/RadioGroup.d.ts +5 -4
  86. package/RadioGroup.js +1 -1
  87. package/RelatedLinks.d.ts +3 -3
  88. package/RowBlock.d.ts +1 -1
  89. package/RowBlockColumn.d.ts +1 -1
  90. package/SearchInput.d.ts +3 -3
  91. package/SearchResults/_SearchResultsItem.d.ts +2 -2
  92. package/SearchResults.d.ts +4 -4
  93. package/SeenEffect.d.ts +1 -1
  94. package/Selectbox.d.ts +2 -2
  95. package/ShareButtons.d.ts +2 -2
  96. package/Sharpie.d.ts +3 -3
  97. package/SiteSearchAutocomplete.d.ts +2 -2
  98. package/SiteSearchCurtain.d.ts +2 -2
  99. package/SiteSearchCurtain.js +7 -12
  100. package/SiteSearchInput.d.ts +5 -5
  101. package/Skeleton.d.ts +3 -3
  102. package/SubHeading.d.ts +1 -1
  103. package/Tabs.d.ts +6 -6
  104. package/Tabs.js +2 -2
  105. package/TagPill.d.ts +2 -2
  106. package/TextBlock.d.ts +1 -1
  107. package/TextButton.d.ts +1 -1
  108. package/TextInput.d.ts +3 -3
  109. package/VSpacer.d.ts +3 -3
  110. package/VerticalTabsTOC.d.ts +3 -3
  111. package/WizardLayout.d.ts +2 -2
  112. package/WizardLayout.js +2 -2
  113. package/WizardStepper.d.ts +2 -2
  114. package/_abstract/_AbstractCarousel.d.ts +3 -3
  115. package/_abstract/_AbstractCarousel.js +2 -2
  116. package/_abstract/_Blings.d.ts +2 -2
  117. package/_abstract/_Block.d.ts +4 -4
  118. package/_abstract/_Button.d.ts +9 -9
  119. package/_abstract/_CardList.d.ts +8 -8
  120. package/_abstract/_Image.d.ts +5 -5
  121. package/_abstract/_Link.d.ts +8 -8
  122. package/_abstract/_Link.js +3 -3
  123. package/_abstract/_Quote.d.ts +1 -1
  124. package/_abstract/_TogglerGroup.d.ts +7 -5
  125. package/_abstract/_TogglerGroup.js +14 -16
  126. package/_abstract/_TogglerGroupField.d.ts +6 -4
  127. package/_abstract/_TogglerGroupField.js +9 -3
  128. package/_abstract/_TogglerInput.d.ts +3 -2
  129. package/_abstract/_TogglerInput.js +9 -7
  130. package/assets.d.ts +4 -4
  131. package/constants.d.ts +2 -2
  132. package/index.d.ts +1 -0
  133. package/package.json +6 -6
  134. package/utils/browserSide.d.ts +1 -0
  135. package/utils/browserSide.js +6 -0
  136. package/utils/config.d.ts +2 -0
  137. package/utils/config.js +3 -4
  138. package/utils/seenEffect.d.ts +3 -3
  139. package/utils/useGetSVGtext.d.ts +1 -1
  140. package/utils/useMenuToggling.d.ts +1 -1
  141. package/utils/useMixedControlState.d.ts +5 -5
  142. package/utils.d.ts +1 -0
  143. package/utils.js +1 -0
@@ -1,15 +1,15 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { BemProps, BemPropsModifier } from '@hugsmidjan/react/types';
3
- declare type ButtonElmProps = {
3
+ type ButtonElmProps = {
4
4
  href?: never;
5
5
  } & BemPropsModifier & Omit<JSX.IntrinsicElements['button'], 'className' | 'style'>;
6
- declare type AnchorElmProps = {
6
+ type AnchorElmProps = {
7
7
  href: string;
8
8
  type?: never;
9
9
  name?: never;
10
10
  value?: never;
11
11
  } & BemPropsModifier & Omit<JSX.IntrinsicElements['a'], 'className' | 'style'>;
12
- export declare type ButtonProps = {
12
+ export type ButtonProps = {
13
13
  /** Label takes preference over `children` */
14
14
  label?: string | JSX.Element;
15
15
  } & (ButtonElmProps | AnchorElmProps);
@@ -18,22 +18,22 @@ declare const sizes: {
18
18
  readonly small: "small";
19
19
  readonly wide: "wide";
20
20
  };
21
- declare type ButtonSize = keyof typeof sizes;
21
+ type ButtonSize = keyof typeof sizes;
22
22
  declare const variants: {
23
23
  readonly normal: "";
24
24
  readonly destructive: "destructive";
25
25
  };
26
- declare type ButtonVariant = keyof typeof variants;
27
- declare type NavigationFlag = 'none' | 'go-back' | 'go-forward';
28
- declare type ButtonIcon = 'edit';
29
- export declare type ButtonVariantProps = {
26
+ type ButtonVariant = keyof typeof variants;
27
+ type NavigationFlag = 'none' | 'go-back' | 'go-forward';
28
+ type ButtonIcon = 'edit';
29
+ export type ButtonVariantProps = {
30
30
  size?: ButtonSize;
31
31
  variant?: ButtonVariant;
32
32
  icon?: ButtonIcon | NavigationFlag;
33
33
  /** @deprecated (Will be removed in v0.11) */
34
34
  small?: boolean;
35
35
  };
36
- declare type _ButtonProps = ButtonProps & ButtonVariantProps & BemProps & {
36
+ type _ButtonProps = ButtonProps & ButtonVariantProps & BemProps & {
37
37
  children?: ReactNode;
38
38
  };
39
39
  export declare const Button: (props: _ButtonProps) => JSX.Element;
@@ -1,31 +1,31 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
3
  import { ImageProps } from './_Image';
4
- declare type BaseCardProps = {
4
+ type BaseCardProps = {
5
5
  title: string;
6
6
  href: string;
7
7
  };
8
- export declare type ImageCardProps = BaseCardProps & {
8
+ export type ImageCardProps = BaseCardProps & {
9
9
  meta?: string;
10
10
  image?: ImageProps;
11
11
  imgPlaceholder?: boolean;
12
12
  };
13
- export declare type TextCardProps = BaseCardProps & {
13
+ export type TextCardProps = BaseCardProps & {
14
14
  summary?: string;
15
15
  };
16
- export declare type CardListProps<T> = {
16
+ export type CardListProps<T> = {
17
17
  cards: Array<T>;
18
18
  title?: string | undefined;
19
19
  titleTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'p';
20
20
  };
21
- export declare type CardListSummaryProps = {
21
+ export type CardListSummaryProps = {
22
22
  summaryElement?: ReactElement;
23
23
  };
24
- export declare type ImageCardListProps = CardListProps<ImageCardProps> & {
24
+ export type ImageCardListProps = CardListProps<ImageCardProps> & {
25
25
  imgPlaceholder?: boolean | string;
26
26
  };
27
- export declare type TextCardListProps = CardListProps<TextCardProps>;
28
- declare type _CardListProps = EitherObj<ImageCardListProps, TextCardListProps> & CardListSummaryProps & {
27
+ export type TextCardListProps = CardListProps<TextCardProps>;
28
+ type _CardListProps = EitherObj<ImageCardListProps, TextCardListProps> & CardListSummaryProps & {
29
29
  bemPrefix: string;
30
30
  children?: ReactNode;
31
31
  standalone?: boolean;
@@ -1,8 +1,8 @@
1
- export declare type Source = {
1
+ export type Source = {
2
2
  srcset: string;
3
3
  media: string;
4
4
  };
5
- export declare type ImagePropsLinked = {
5
+ export type ImagePropsLinked = {
6
6
  altText?: string;
7
7
  sources?: Array<Source>;
8
8
  /** The default image source to (lazy) load */
@@ -12,7 +12,7 @@ export declare type ImagePropsLinked = {
12
12
  inline?: false;
13
13
  focalPoint?: string;
14
14
  };
15
- export declare type ImagePropsInlinedSvg = {
15
+ export type ImagePropsInlinedSvg = {
16
16
  altText?: string;
17
17
  /** Should the image be fetched and inlined as <svg/> */
18
18
  inline: true;
@@ -21,8 +21,8 @@ export declare type ImagePropsInlinedSvg = {
21
21
  preloadSrc?: undefined;
22
22
  focalPoint?: undefined;
23
23
  };
24
- export declare type ImageProps = ImagePropsLinked | ImagePropsInlinedSvg;
25
- declare type _ImageProps = {
24
+ export type ImageProps = ImagePropsLinked | ImagePropsInlinedSvg;
25
+ type _ImageProps = {
26
26
  /** container className */
27
27
  className: string | undefined;
28
28
  /** Controls if the container is rendered when image is missing/undefined.
@@ -1,16 +1,16 @@
1
- declare type HTMLAnchorProps = JSX.IntrinsicElements['a'];
2
- declare type LinkProps = HTMLAnchorProps & {
1
+ type HTMLAnchorProps = JSX.IntrinsicElements['a'];
2
+ type LinkProps = HTMLAnchorProps & {
3
3
  href: string;
4
4
  };
5
- declare type _LinkRenderer_internal = (props: LinkProps) => JSX.Element;
5
+ type _LinkRenderer_internal = (props: LinkProps) => JSX.Element;
6
6
  export declare let Link: _LinkRenderer_internal;
7
7
  /**
8
8
  * Props object ready to be ..spread onto an anchor element
9
9
  * */
10
- export declare type LinkRendererProps = Omit<LinkProps, 'ref'> & {
10
+ export type LinkRendererProps = Omit<LinkProps, 'ref'> & {
11
11
  ref: Exclude<HTMLAnchorProps['ref'], string>;
12
12
  };
13
- export declare type LinkRenderer = (props: LinkRendererProps) => JSX.Element;
13
+ export type LinkRenderer = (props: LinkRendererProps) => JSX.Element;
14
14
  /**
15
15
  * Allows you to set a callback function to wrapp <a href=""/> links with
16
16
  * a custom routing component.
@@ -37,7 +37,7 @@ export declare type LinkRenderer = (props: LinkRendererProps) => JSX.Element;
37
37
  * setLinkRenderer.pop(); // reset link rendering
38
38
  * ```
39
39
  *
40
- * The Default linkrenderer is defined as:
40
+ * The default linkrenderer is defined as:
41
41
  *
42
42
  * ```js
43
43
  * (linkProps) => React.createElement('a', linkProps);
@@ -47,13 +47,13 @@ export declare type LinkRenderer = (props: LinkRendererProps) => JSX.Element;
47
47
  * as an argument — like so:
48
48
  *
49
49
  * ```js
50
- * setLinkRenderer(undefined);
50
+ * setLinkRenderer(undefined); // pushes the default linkrenderer to the stack
51
51
  * ```
52
52
  */
53
53
  export declare const setLinkRenderer: {
54
54
  (linkRenderer: LinkRenderer | undefined): void;
55
55
  /**
56
- *
56
+ * Unsets the last pushed custom renderer
57
57
  */
58
58
  pop(): void;
59
59
  };
@@ -32,7 +32,7 @@ const history = [];
32
32
  * setLinkRenderer.pop(); // reset link rendering
33
33
  * ```
34
34
  *
35
- * The Default linkrenderer is defined as:
35
+ * The default linkrenderer is defined as:
36
36
  *
37
37
  * ```js
38
38
  * (linkProps) => React.createElement('a', linkProps);
@@ -42,7 +42,7 @@ const history = [];
42
42
  * as an argument — like so:
43
43
  *
44
44
  * ```js
45
- * setLinkRenderer(undefined);
45
+ * setLinkRenderer(undefined); // pushes the default linkrenderer to the stack
46
46
  * ```
47
47
  */
48
48
  const setLinkRenderer = (linkRenderer) => {
@@ -61,7 +61,7 @@ const setLinkRenderer = (linkRenderer) => {
61
61
  };
62
62
  exports.setLinkRenderer = setLinkRenderer;
63
63
  /**
64
- *
64
+ * Unsets the last pushed custom renderer
65
65
  */
66
66
  exports.setLinkRenderer.pop = () => {
67
67
  history.shift();
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
- export declare type QuoteProps = {
3
+ export type QuoteProps = {
4
4
  children: ReactNode;
5
5
  } & EitherObj<object, {
6
6
  by: string | JSX.Element;
@@ -1,14 +1,14 @@
1
1
  import { FormFieldInputProps } from '../FormField';
2
2
  import { TogglerInputProps } from './_TogglerInput';
3
- export declare type TogglerGroupOption = {
3
+ export type TogglerGroupOption = {
4
4
  value: string;
5
5
  label?: string | JSX.Element;
6
6
  disabled?: boolean;
7
7
  id?: string;
8
8
  };
9
- export declare type TogglerGroupOptions = Array<TogglerGroupOption>;
10
- declare type RestrictedInputProps = Omit<JSX.IntrinsicElements['input'], 'type' | 'value' | 'checked' | 'defaultChecked' | 'className' | 'id' | 'name' | 'children'>;
11
- export declare type TogglerGroupProps = {
9
+ export type TogglerGroupOptions = Array<TogglerGroupOption>;
10
+ type RestrictedInputProps = Omit<JSX.IntrinsicElements['input'], 'type' | 'value' | 'defaultValue' | 'checked' | 'defaultChecked' | 'className' | 'id' | 'name' | 'children'>;
11
+ export type TogglerGroupProps = {
12
12
  options: TogglerGroupOptions;
13
13
  className?: string;
14
14
  name: string;
@@ -21,10 +21,12 @@ export declare type TogglerGroupProps = {
21
21
  selectedValues: Array<string>;
22
22
  }) => void;
23
23
  } & Omit<FormFieldInputProps, 'disabled'>;
24
- declare type _TogglerGroupProps = {
24
+ type _TogglerGroupProps = {
25
25
  bem: string;
26
26
  Toggler: (props: TogglerInputProps) => JSX.Element;
27
27
  value?: ReadonlyArray<string>;
28
+ defaultValue?: ReadonlyArray<string>;
29
+ isRadio?: true;
28
30
  };
29
31
  export declare const TogglerGroup: (props: TogglerGroupProps & _TogglerGroupProps) => JSX.Element;
30
32
  export {};
@@ -4,32 +4,30 @@ exports.TogglerGroup = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/getBemClass"));
7
+ const utils_1 = require("../utils");
7
8
  const TogglerGroup = (props) => {
8
9
  const {
9
10
  // id,
10
- className, bem, name, disabled, Toggler, onSelected, options, inputProps = {}, } = props;
11
- const values = props.value;
11
+ className, bem, name, disabled, Toggler, onSelected, options, isRadio, inputProps = {}, } = props;
12
+ const [values, setValues] = (0, utils_1.useMixedControlState)(props, 'value', []);
12
13
  return (react_1.default.createElement("ul", { className: (0, getBemClass_1.default)(bem, null, className), role: "group", "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-required": props.required }, options.map((option, i) => {
13
14
  const isDisabled = option.disabled != null
14
15
  ? option.disabled
15
16
  : disabled && typeof disabled !== 'boolean'
16
17
  ? disabled.includes(i)
17
18
  : disabled;
18
- const isChecked = values && values.includes(option.value);
19
- return (react_1.default.createElement(Toggler, Object.assign({ key: i }, inputProps, { className: bem + '__item', name: name, Wrapper: "li" }, option, { label: option.label || option.value, onChange: onSelected
20
- ? (e) => {
21
- const { value } = option;
22
- const checked = e.currentTarget.checked;
23
- inputProps.onChange && inputProps.onChange(e);
24
- const selectedValues = values
25
- ? values.filter((val) => val !== value)
26
- : [];
27
- if (checked) {
28
- selectedValues.push(value);
29
- }
30
- onSelected({ value, checked, option, selectedValues });
19
+ const isChecked = values.includes(option.value);
20
+ return (react_1.default.createElement(Toggler, Object.assign({ key: i }, inputProps, { className: bem + '__item', name: name, Wrapper: "li" }, option, { label: option.label || option.value, onChange: (e) => {
21
+ inputProps.onChange && inputProps.onChange(e);
22
+ const { value } = option;
23
+ const checked = e.currentTarget.checked;
24
+ const selectedValues = isRadio ? [] : values.filter((val) => val !== value);
25
+ if (checked) {
26
+ selectedValues.push(value);
31
27
  }
32
- : inputProps.onChange, disabled: isDisabled, "aria-invalid": props['aria-invalid'], checked: isChecked })));
28
+ setValues(selectedValues);
29
+ onSelected && onSelected({ value, checked, option, selectedValues });
30
+ }, disabled: isDisabled, "aria-invalid": props['aria-invalid'], checked: isChecked })));
33
31
  })));
34
32
  };
35
33
  exports.TogglerGroup = TogglerGroup;
@@ -3,15 +3,17 @@ import { BemPropsModifier } from '@hugsmidjan/react/types';
3
3
  import { FormFieldGroupWrappingProps } from '../FormField';
4
4
  import { TogglerGroupOption, TogglerGroupOptions, TogglerGroupProps } from './_TogglerGroup';
5
5
  import { TogglerInputProps } from './_TogglerInput';
6
- export declare type TogglerGroupFieldProps = {
6
+ export type TogglerGroupFieldProps = {
7
7
  className?: string;
8
8
  } & FormFieldGroupWrappingProps & TogglerGroupProps;
9
- declare type _TogglerGroupFieldProps = {
9
+ type _TogglerGroupFieldProps = {
10
10
  Toggler: (props: TogglerInputProps) => ReactElement;
11
+ isRadio?: true;
11
12
  value?: string | ReadonlyArray<string>;
13
+ defaultValue?: string | ReadonlyArray<string>;
12
14
  bem: string;
13
15
  } & BemPropsModifier;
14
- export declare type TogglerGroupFieldOption = TogglerGroupOption;
15
- export declare type TogglerGroupFieldOptions = TogglerGroupOptions;
16
+ export type TogglerGroupFieldOption = TogglerGroupOption;
17
+ export type TogglerGroupFieldOptions = TogglerGroupOptions;
16
18
  export declare const TogglerGroupField: (props: TogglerGroupFieldProps & _TogglerGroupFieldProps) => JSX.Element;
17
19
  export {};
@@ -2,14 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TogglerGroupField = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
6
  const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/getBemClass"));
7
7
  const FormField_1 = tslib_1.__importDefault(require("../FormField"));
8
8
  const _TogglerGroup_1 = require("./_TogglerGroup");
9
9
  const TogglerGroupField = (props) => {
10
- const { bem, Toggler, className, modifier, label, LabelTag, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, value } = props, togglerGroupProps = tslib_1.__rest(props, ["bem", "Toggler", "className", "modifier", "label", "LabelTag", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "value"]);
10
+ const { bem, Toggler, className, modifier, label, LabelTag, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, value, defaultValue } = props, togglerGroupProps = tslib_1.__rest(props, ["bem", "Toggler", "className", "modifier", "label", "LabelTag", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "value", "defaultValue"]);
11
+ const _value = (0, react_1.useMemo)(() => (value == null ? undefined : typeof value === 'string' ? [value] : value), [value]);
12
+ const _defaultValue = (0, react_1.useMemo)(() => defaultValue == null
13
+ ? undefined
14
+ : typeof defaultValue === 'string'
15
+ ? [defaultValue]
16
+ : defaultValue, [defaultValue]);
11
17
  return (react_1.default.createElement(FormField_1.default, { className: (0, getBemClass_1.default)(bem, modifier, className), group: true, label: label, LabelTag: LabelTag, assistText: assistText, hideLabel: hideLabel, disabled: disabled, readOnly: readOnly, invalid: invalid, errorMessage: errorMessage, required: required, reqText: reqText, id: id, renderInput: (className, inputProps) => {
12
- return (react_1.default.createElement(_TogglerGroup_1.TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { value: Array.isArray(value) ? value : value != null ? [value] : undefined, Toggler: Toggler })));
18
+ return (react_1.default.createElement(_TogglerGroup_1.TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { value: _value, defaultValue: _defaultValue, Toggler: Toggler })));
13
19
  } }));
14
20
  };
15
21
  exports.TogglerGroupField = TogglerGroupField;
@@ -1,5 +1,5 @@
1
1
  import { BemPropsModifier } from '@hugsmidjan/react/types';
2
- export declare type TogglerInputProps = {
2
+ export type TogglerInputProps = {
3
3
  label: string | JSX.Element;
4
4
  children?: never;
5
5
  Wrapper?: 'div' | 'li';
@@ -14,9 +14,10 @@ export declare type TogglerInputProps = {
14
14
  reqText?: string | false;
15
15
  errorMessage?: string | JSX.Element;
16
16
  } & BemPropsModifier & Omit<JSX.IntrinsicElements['input'], 'type'>;
17
- declare type _TogglerInputProps = {
17
+ type _TogglerInputProps = {
18
18
  bem: string;
19
19
  type: 'radio' | 'checkbox';
20
+ innerWrap?: boolean;
20
21
  };
21
22
  export declare const TogglerInput: (props: TogglerInputProps & _TogglerInputProps) => JSX.Element;
22
23
  export {};
@@ -2,25 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TogglerInput = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const react_1 = tslib_1.__importDefault(require("react"));
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
6
  const hooks_1 = require("@hugsmidjan/react/hooks");
7
7
  const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/getBemClass"));
8
8
  const TogglerInput = (props) => {
9
- const { bem, modifier, className, label, invalid, errorMessage, Wrapper = 'div', required, reqText, type, id } = props, inputProps = tslib_1.__rest(props, ["bem", "modifier", "className", "label", "invalid", "errorMessage", "Wrapper", "required", "reqText", "type", "id"]);
9
+ const { bem, modifier, className, label, invalid, errorMessage, Wrapper = 'div', required, reqText, type, id, innerWrap } = props, inputProps = tslib_1.__rest(props, ["bem", "modifier", "className", "label", "invalid", "errorMessage", "Wrapper", "required", "reqText", "type", "id", "innerWrap"]);
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
  // TODO: add mo-better i18n thinking
14
14
  title: (reqText || 'Þarf að haka í') + ': ' }, "*"));
15
+ const InnerWrap = innerWrap ? 'span' : react_1.Fragment;
15
16
  return (react_1.default.createElement(Wrapper, { className: (0, getBemClass_1.default)(bem, modifier, className) },
16
17
  react_1.default.createElement("input", Object.assign({ className: bem + '__input', type: type, id: domid, "aria-invalid": invalid || !!errorMessage || undefined, "aria-describedby": errorId }, inputProps)),
17
18
  ' ',
18
19
  react_1.default.createElement("label", { className: bem + '__label', htmlFor: domid },
19
- ' ',
20
- reqStar,
21
- " ",
22
- label,
23
- ' '),
20
+ react_1.default.createElement(InnerWrap, { className: bem + '__label__wrap' },
21
+ ' ',
22
+ reqStar,
23
+ " ",
24
+ label,
25
+ ' ')),
24
26
  errorMessage && (react_1.default.createElement("div", { className: bem + '__error', id: errorId }, errorMessage))));
25
27
  };
26
28
  exports.TogglerInput = TogglerInput;
package/assets.d.ts CHANGED
@@ -31,12 +31,12 @@ export declare const getCssBundleUrl: (cssTokens: string | Array<string>, versio
31
31
  /** @deprecated (Will be removed in v0.11) */
32
32
  export declare const efnistakn_menu: readonly ["menu/borgarstjori", "menu/borgarstjorn", "menu/bygg_framkv", "menu/fjarmal", "menu/fundargerdir", "menu/itrottir_aftreying", "menu/log_reglugerdir", "menu/mannaudur", "menu/menning", "menu/rad_nefndir", "menu/skipulag", "menu/skolar_fristund", "menu/svid_deildir", "menu/umhverfi_samgongur", "menu/velferd_fjolskylda"];
33
33
  /** @deprecated (Will be removed in v0.11) */
34
- export declare type Efnistakn_Menu = typeof efnistakn_menu[number];
34
+ export type Efnistakn_Menu = typeof efnistakn_menu[number];
35
35
  /** @deprecated (Will be removed in v0.11) */
36
36
  export declare const auxiliary_menu_images: Array<Illustration>;
37
37
  /** @deprecated Instead `import type { AuxilaryPanelIllustration } from '@reykjavik/hanna-react/MainMenu';` (Will be removed in v0.11) */
38
- export declare type Auxilary_MenuImages = typeof auxiliary_menu_images[number];
38
+ export type Auxilary_MenuImages = typeof auxiliary_menu_images[number];
39
39
  /** @deprecated Instead `import type { BlingType } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
40
- export declare type BlingTypes = BlingType;
40
+ export type BlingTypes = BlingType;
41
41
  /** @deprecated Instead `import type { Illustration } from '@reykjavik/hanna-utils/assets';` (Will be removed in v0.11) */
42
- export declare type Illustrations = Illustration;
42
+ export type Illustrations = Illustration;
package/constants.d.ts CHANGED
@@ -10,9 +10,9 @@ export type { ColorFamily } from '@reykjavik/hanna-css';
10
10
  export declare const themeOptions: readonly ["trustworthy", "dependable", "friendly", "lively", "colorful"] & Readonly<Record<import("@reykjavik/hanna-css").HannaColorTheme, import("@reykjavik/hanna-css").HannaColorTheme>>;
11
11
  /** @depcrecated import type `HannaColorTheme` from `@reykjavik/hanna-css` instead (Will be removed in v0.11) */
12
12
  export type { HannaColorTheme as ThemeOption } from '@reykjavik/hanna-css';
13
- export declare type Alignment = 'right' | 'left';
13
+ export type Alignment = 'right' | 'left';
14
14
  export declare const aligns: Record<string, true | undefined>;
15
- export declare type ComponentLayoutProps<Align extends string = 'right'> = EitherObj<{
15
+ export type ComponentLayoutProps<Align extends string = 'right'> = EitherObj<{
16
16
  wide?: boolean;
17
17
  }, {
18
18
  align?: Align;
package/index.d.ts CHANGED
@@ -21,6 +21,7 @@
21
21
  /// <reference path="./CarouselStepper.d.tsx" />
22
22
  /// <reference path="./CenterColumn.d.tsx" />
23
23
  /// <reference path="./Checkbox.d.tsx" />
24
+ /// <reference path="./CheckboxButton.d.tsx" />
24
25
  /// <reference path="./CheckboxButtonsGroup.d.tsx" />
25
26
  /// <reference path="./CheckboxGroup.d.tsx" />
26
27
  /// <reference path="./CityBlock.d.tsx" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.76",
3
+ "version": "0.10.77",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",
@@ -14,17 +14,17 @@
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
16
  "@hugsmidjan/qj": "^4.10.2",
17
- "@hugsmidjan/react": "^0.4.20",
18
- "@reykjavik/hanna-css": "^0.3.10",
19
- "@reykjavik/hanna-utils": "^0.2.0",
17
+ "@hugsmidjan/react": "^0.4.23",
18
+ "@reykjavik/hanna-css": "^0.3.11",
19
+ "@reykjavik/hanna-utils": "^0.2.1",
20
20
  "@types/react": "^17.0.24",
21
21
  "@types/react-autosuggest": "^10.1.0",
22
- "@types/react-datepicker": "^3.0.2",
22
+ "@types/react-datepicker": "^4.8.0",
23
23
  "@types/react-dom": "^17.0.9",
24
24
  "@types/react-transition-group": "^4.4.0",
25
25
  "iframe-resizer-react": "^1.1.0",
26
26
  "react-autosuggest": "^10.1.0",
27
- "react-datepicker": "^3.0.2",
27
+ "react-datepicker": "^4.8.0",
28
28
  "react-dropzone": "^10.2.2",
29
29
  "react-intersection-observer": "^8.30.1",
30
30
  "react-transition-group": "^4.4.1"
@@ -0,0 +1 @@
1
+ export { useIsBrowserSide, useIsServerSide } from '@hugsmidjan/react/hooks';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsServerSide = exports.useIsBrowserSide = void 0;
4
+ var hooks_1 = require("@hugsmidjan/react/hooks");
5
+ Object.defineProperty(exports, "useIsBrowserSide", { enumerable: true, get: function () { return hooks_1.useIsBrowserSide; } });
6
+ Object.defineProperty(exports, "useIsServerSide", { enumerable: true, get: function () { return hooks_1.useIsServerSide; } });
package/utils/config.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export type { LinkRenderer } from '../_abstract/_Link';
2
2
  export { setLinkRenderer } from '../_abstract/_Link';
3
+ export type { SSRSupport } from '@hugsmidjan/react/hooks';
4
+ export { setDefaultSSR } from '@hugsmidjan/react/hooks';
package/utils/config.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setLinkRenderer = void 0;
3
+ exports.setDefaultSSR = exports.setLinkRenderer = void 0;
4
4
  var _Link_1 = require("../_abstract/_Link");
5
5
  Object.defineProperty(exports, "setLinkRenderer", { enumerable: true, get: function () { return _Link_1.setLinkRenderer; } });
6
- // ---------------------------------------------------------------------------
7
- // TODO:
8
- // * Add defaultSSR variable that can be set globally for
6
+ var hooks_1 = require("@hugsmidjan/react/hooks");
7
+ Object.defineProperty(exports, "setDefaultSSR", { enumerable: true, get: function () { return hooks_1.setDefaultSSR; } });
@@ -9,8 +9,8 @@ declare const effects: {
9
9
  readonly fadeup: 1;
10
10
  readonly fadeleft: 1;
11
11
  };
12
- export declare type SeenEffectType = keyof typeof effects;
13
- export declare type EffectProp = {
12
+ export type SeenEffectType = keyof typeof effects;
13
+ export type EffectProp = {
14
14
  /** Should the component appear instantly, and not transition-in once seen */
15
15
  effectType?: SeenEffectType | 'none';
16
16
  };
@@ -19,7 +19,7 @@ export declare const ensureEffectType: (maybeType?: string) => SeenEffectType |
19
19
  export declare const getEffectAttr: (maybeType?: string) => {
20
20
  'data-seen-effect': string | undefined;
21
21
  };
22
- export declare type SeenProp = {
22
+ export type SeenProp = {
23
23
  /** Should the component appear instantly, and not transition-in once seen */
24
24
  startSeen?: boolean;
25
25
  };
@@ -1,4 +1,4 @@
1
- declare type SVGMeta = {
1
+ type SVGMeta = {
2
2
  imageSrc: string;
3
3
  code: string;
4
4
  };
@@ -1,4 +1,4 @@
1
- declare type MenuTogglingState = {
1
+ type MenuTogglingState = {
2
2
  isMenuActive: true | undefined;
3
3
  isMenuOpen: boolean;
4
4
  toggleMenu: () => void;
@@ -1,9 +1,9 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- declare type CtrlMode = 'controlled' | 'uncontrolled' | undefined;
3
- declare type RetArray<R> = [value: R, setValue: Dispatch<SetStateAction<R>>, mode: CtrlMode];
4
- declare type DefaultProp<N extends string> = `default${Capitalize<N>}`;
5
- declare type PropPair<N extends string> = N | DefaultProp<N>;
6
- declare type StrictKeys<P extends Record<string, unknown>, N extends string> = PropPair<N> extends keyof P ? P : {
2
+ type CtrlMode = 'controlled' | 'uncontrolled' | undefined;
3
+ type RetArray<R> = [value: R, setValue: Dispatch<SetStateAction<R>>, mode: CtrlMode];
4
+ type DefaultProp<N extends string> = `default${Capitalize<N>}`;
5
+ type PropPair<N extends string> = N | DefaultProp<N>;
6
+ type StrictKeys<P extends Record<string, unknown>, N extends string> = PropPair<N> extends keyof P ? P : {
7
7
  [Key in PropPair<N>]: P[Key];
8
8
  };
9
9
  /**
package/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './utils/browserSide';
1
2
  export * from './utils/config';
2
3
  export * from './utils/useDidChange';
3
4
  export * from './utils/useFormatMonitor';
package/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./utils/browserSide"), exports);
4
5
  tslib_1.__exportStar(require("./utils/config"), exports);
5
6
  tslib_1.__exportStar(require("./utils/useDidChange"), exports);
6
7
  tslib_1.__exportStar(require("./utils/useFormatMonitor"), exports);