@reykjavik/hanna-react 0.10.155 → 0.10.157

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/CHANGELOG.md CHANGED
@@ -4,12 +4,22 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
- ## 0.10.155
7
+ ## 0.10.157
8
+
9
+ _2025-09-16_
10
+
11
+ - `Multiselect`
12
+ - fix: Sync `.checked` prop of keyboard-toggled `input`s with visual state
13
+ - `Selectbox`:
14
+ - fix: Remove stray `modifier` prop from `SelectboxProps`
15
+ - docs: Add JSDoc comments for `FormfieldProps.renderInput` parameters
16
+
17
+ ## 0.10.155 – 0.10.156
8
18
 
9
19
  _2025-06-23_
10
20
 
11
- - feat: Allow `MainMenu2` items to be `undefined` for easier conditional item
12
- array population
21
+ - feat: Allow `MainMenu2` items to be `undefined`, `null` or `false` for
22
+ easier conditional item array population
13
23
 
14
24
  ## 0.10.154
15
25
 
package/FormField.d.ts CHANGED
@@ -5,7 +5,7 @@ import { SSRSupportProps, WrapperElmProps } from './utils.js';
5
5
  type InputClassNames = {
6
6
  /** Basic/raw FormField BEM name */
7
7
  bem: string;
8
- /** Standard name for "<input/>"-styled controls */
8
+ /** Standard name for "<input/>"-styled controls or container elements */
9
9
  input: string;
10
10
  /** Standard name for radio/checkbox group conotrols */
11
11
  options: string;
@@ -77,9 +77,30 @@ type FormFieldProps = FormFieldGroupWrappingProps & {
77
77
  group?: boolean | 'inputlike';
78
78
  empty?: boolean;
79
79
  filled?: boolean;
80
- renderInput(className: InputClassNames, inputProps: FormFieldInputProps & {
80
+ renderInput(
81
+ /**
82
+ * Object with standard classNames for various input-related elements
83
+ */
84
+ className: InputClassNames,
85
+ /**
86
+ * The input's managed props, including `id`, a bunch of `aria-*` attributes,
87
+ * `disabled`, `readOnly`, and `required`.
88
+ */
89
+ inputProps: FormFieldInputProps & {
81
90
  id: string;
82
- }, addFocusProps: FocusPropMaker, isBrowser?: boolean): JSX.Element;
91
+ },
92
+ /**
93
+ * Function that generates `onFocus` and `onBlur` event handlers for the
94
+ * `___input` element, capturing bubbled `FocusEvent`s and emulating
95
+ * `onFocusOut` and `onFocusIn` behavior. This is useful for multi-input
96
+ * controls.
97
+ */
98
+ addFocusProps: FocusPropMaker,
99
+ /**
100
+ * Sugar flag indicating whether the component is being rendered in a browser
101
+ * environment or not.
102
+ */
103
+ isBrowser?: boolean): JSX.Element;
83
104
  };
84
105
  export declare const FormField: (props: FormFieldProps) => JSX.Element;
85
106
  export default FormField;
package/MainMenu2.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Illustration } from '@reykjavik/hanna-utils/assets';
4
4
  import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
5
5
  import { I18NProps } from './utils/types.js';
6
6
  import { SSRSupportProps, WrapperElmProps } from './utils.js';
7
+ type Falseish = undefined | null | false;
7
8
  export type MainMenu2I18n = {
8
9
  title: string;
9
10
  homeLink: string;
@@ -64,11 +65,11 @@ export type MainMenu2SubMenuItem = MainMenu2Item & {
64
65
  export type MainMenu2SubMenu = {
65
66
  title: string;
66
67
  current?: boolean;
67
- subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
68
+ subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem | Falseish>;
68
69
  };
69
- export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem | undefined>;
70
- export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem | undefined>;
71
- export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
70
+ export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem | Falseish>;
71
+ export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem | Falseish>;
72
+ export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem | Falseish>;
72
73
  export type MainMenu2Props = {
73
74
  /**
74
75
  * URL for the mandatory (usually screen-reader-only) homepage Link.
@@ -114,3 +115,4 @@ export type MainMenu2Props = {
114
115
  imageUrl?: string;
115
116
  }> & WrapperElmProps & I18NProps<MainMenu2I18n> & SSRSupportProps;
116
117
  export declare const MainMenu2: (props: MainMenu2Props) => JSX.Element;
118
+ export {};
package/Multiselect.js CHANGED
@@ -163,6 +163,17 @@ const Multiselect = (props) => {
163
163
  e.preventDefault();
164
164
  const selItem = filteredOptions[activeItemIndex];
165
165
  if (selItem) {
166
+ // Manually toggle the checkbox, to ensure that uncontrolled
167
+ // components (e.g. screen readers) are in sync with the visual state.
168
+ let input;
169
+ inputWrapperRef
170
+ .current.querySelectorAll(`input[type="checkbox"]`)
171
+ .forEach((elm) => {
172
+ if (elm.value === selItem.value) {
173
+ input = elm;
174
+ }
175
+ });
176
+ input.checked = !input.checked;
166
177
  handleCheckboxSelection(selItem);
167
178
  }
168
179
  }
package/Selectbox.d.ts CHANGED
@@ -3,7 +3,7 @@ import { FormFieldWrappingProps } from './FormField.js';
3
3
  export { type SelectboxOption, type SelectboxOptions as SelectboxOptionList, } from '@hugsmidjan/react/Selectbox';
4
4
  /** @deprecated Use `SelectboxOptionList` instead (Will be removed in v0.11) */
5
5
  export type SelectboxOptions = _SelectboxOptions;
6
- export type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem'> & {
6
+ export type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem' | 'modifier'> & {
7
7
  small?: boolean;
8
8
  };
9
9
  export declare const Selectbox: <O extends OptionOrValue>(props: SelectboxProps<O>) => JSX.Element;
@@ -5,7 +5,7 @@ import { SSRSupportProps, WrapperElmProps } from './utils.js';
5
5
  type InputClassNames = {
6
6
  /** Basic/raw FormField BEM name */
7
7
  bem: string;
8
- /** Standard name for "<input/>"-styled controls */
8
+ /** Standard name for "<input/>"-styled controls or container elements */
9
9
  input: string;
10
10
  /** Standard name for radio/checkbox group conotrols */
11
11
  options: string;
@@ -77,9 +77,30 @@ type FormFieldProps = FormFieldGroupWrappingProps & {
77
77
  group?: boolean | 'inputlike';
78
78
  empty?: boolean;
79
79
  filled?: boolean;
80
- renderInput(className: InputClassNames, inputProps: FormFieldInputProps & {
80
+ renderInput(
81
+ /**
82
+ * Object with standard classNames for various input-related elements
83
+ */
84
+ className: InputClassNames,
85
+ /**
86
+ * The input's managed props, including `id`, a bunch of `aria-*` attributes,
87
+ * `disabled`, `readOnly`, and `required`.
88
+ */
89
+ inputProps: FormFieldInputProps & {
81
90
  id: string;
82
- }, addFocusProps: FocusPropMaker, isBrowser?: boolean): JSX.Element;
91
+ },
92
+ /**
93
+ * Function that generates `onFocus` and `onBlur` event handlers for the
94
+ * `___input` element, capturing bubbled `FocusEvent`s and emulating
95
+ * `onFocusOut` and `onFocusIn` behavior. This is useful for multi-input
96
+ * controls.
97
+ */
98
+ addFocusProps: FocusPropMaker,
99
+ /**
100
+ * Sugar flag indicating whether the component is being rendered in a browser
101
+ * environment or not.
102
+ */
103
+ isBrowser?: boolean): JSX.Element;
83
104
  };
84
105
  export declare const FormField: (props: FormFieldProps) => JSX.Element;
85
106
  export default FormField;
@@ -4,6 +4,7 @@ import { Illustration } from '@reykjavik/hanna-utils/assets';
4
4
  import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
5
5
  import { I18NProps } from './utils/types.js';
6
6
  import { SSRSupportProps, WrapperElmProps } from './utils.js';
7
+ type Falseish = undefined | null | false;
7
8
  export type MainMenu2I18n = {
8
9
  title: string;
9
10
  homeLink: string;
@@ -64,11 +65,11 @@ export type MainMenu2SubMenuItem = MainMenu2Item & {
64
65
  export type MainMenu2SubMenu = {
65
66
  title: string;
66
67
  current?: boolean;
67
- subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
68
+ subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem | Falseish>;
68
69
  };
69
- export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem | undefined>;
70
- export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem | undefined>;
71
- export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
70
+ export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem | Falseish>;
71
+ export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem | Falseish>;
72
+ export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem | Falseish>;
72
73
  export type MainMenu2Props = {
73
74
  /**
74
75
  * URL for the mandatory (usually screen-reader-only) homepage Link.
@@ -114,3 +115,4 @@ export type MainMenu2Props = {
114
115
  imageUrl?: string;
115
116
  }> & WrapperElmProps & I18NProps<MainMenu2I18n> & SSRSupportProps;
116
117
  export declare const MainMenu2: (props: MainMenu2Props) => JSX.Element;
118
+ export {};
@@ -159,6 +159,17 @@ export const Multiselect = (props) => {
159
159
  e.preventDefault();
160
160
  const selItem = filteredOptions[activeItemIndex];
161
161
  if (selItem) {
162
+ // Manually toggle the checkbox, to ensure that uncontrolled
163
+ // components (e.g. screen readers) are in sync with the visual state.
164
+ let input;
165
+ inputWrapperRef
166
+ .current.querySelectorAll(`input[type="checkbox"]`)
167
+ .forEach((elm) => {
168
+ if (elm.value === selItem.value) {
169
+ input = elm;
170
+ }
171
+ });
172
+ input.checked = !input.checked;
162
173
  handleCheckboxSelection(selItem);
163
174
  }
164
175
  }
@@ -3,7 +3,7 @@ import { FormFieldWrappingProps } from './FormField.js';
3
3
  export { type SelectboxOption, type SelectboxOptions as SelectboxOptionList, } from '@hugsmidjan/react/Selectbox';
4
4
  /** @deprecated Use `SelectboxOptionList` instead (Will be removed in v0.11) */
5
5
  export type SelectboxOptions = _SelectboxOptions;
6
- export type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem'> & {
6
+ export type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem' | 'modifier'> & {
7
7
  small?: boolean;
8
8
  };
9
9
  export declare const Selectbox: <O extends OptionOrValue>(props: SelectboxProps<O>) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.155",
3
+ "version": "0.10.157",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",