@reykjavik/hanna-react 0.10.124 → 0.10.126
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 +6 -1
- package/CHANGELOG.md +31 -16
- package/FocusTrap.d.ts +3 -2
- package/FocusTrap.js +5 -4
- package/_abstract/_AbstractModal.d.ts +3 -2
- package/_abstract/_AbstractModal.js +4 -4
- package/esm/AutosuggestSearch.js +6 -1
- package/esm/FocusTrap.d.ts +3 -2
- package/esm/FocusTrap.js +5 -4
- package/esm/_abstract/_AbstractModal.d.ts +3 -2
- package/esm/_abstract/_AbstractModal.js +4 -4
- package/package.json +1 -1
package/AutosuggestSearch.js
CHANGED
|
@@ -8,6 +8,8 @@ const classUtils_1 = require("@hugsmidjan/qj/classUtils");
|
|
|
8
8
|
const i18n_1 = require("@reykjavik/hanna-utils/i18n");
|
|
9
9
|
const SearchInput_js_1 = tslib_1.__importDefault(require("./SearchInput.js"));
|
|
10
10
|
const utils_js_1 = require("./utils.js");
|
|
11
|
+
/** Change methods/types that should update the input value */
|
|
12
|
+
const inputChangeMethods = new Set(['type', 'enter', 'click']);
|
|
11
13
|
exports.defaultAutosuggestSearchTexts = {
|
|
12
14
|
is: {
|
|
13
15
|
label: 'Leit á vefnum',
|
|
@@ -76,7 +78,10 @@ const AutosuggestSearch = (props) => {
|
|
|
76
78
|
}, inputProps: {
|
|
77
79
|
ref: inputRef,
|
|
78
80
|
value: inputValue,
|
|
79
|
-
onChange: (_, { newValue }) => {
|
|
81
|
+
onChange: (_, { newValue, method }) => {
|
|
82
|
+
if (!inputChangeMethods.has(method)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
80
85
|
onInput(newValue);
|
|
81
86
|
setInputValue(newValue);
|
|
82
87
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.126
|
|
8
|
+
|
|
9
|
+
_2024-06-05_
|
|
10
|
+
|
|
11
|
+
- `FocusTrap`:
|
|
12
|
+
- feat: Add className to wrapper element
|
|
13
|
+
- fix: Exclude `FocusTrap` elements from list of eligible focusables
|
|
14
|
+
- fix: Mishandled focus-managment of `Modal` while open
|
|
15
|
+
|
|
16
|
+
## 0.10.125
|
|
17
|
+
|
|
18
|
+
_2024-04-10_
|
|
19
|
+
|
|
20
|
+
- fix: Stop updating `AutosuggestSearch` input value on up/down arrow keys
|
|
21
|
+
|
|
7
22
|
## 0.10.124
|
|
8
23
|
|
|
9
24
|
_2024-04-05_
|
|
@@ -86,7 +101,7 @@ _2023-12-08_
|
|
|
86
101
|
|
|
87
102
|
- feat: Add component `MainMenu2`
|
|
88
103
|
- feat: Make `Datepicker` more flexible when parsing manual input strings –
|
|
89
|
-
adds several, localized default formats
|
|
104
|
+
adds several, localized default formats
|
|
90
105
|
- feat: Add accessibility helper component `FocusTrap`
|
|
91
106
|
- Decouple all mobile-menu toggling logic from the `Layout` component
|
|
92
107
|
- feat: Deprecate `useFormatMonitor` media flags `*Hamburger`, `*Topmenu`
|
|
@@ -217,7 +232,7 @@ _2023-09-04_
|
|
|
217
232
|
- feat: Add props `wrapperProps` to `CarouselStepper`
|
|
218
233
|
- feat: Remove defeault/implicit seen-effect styling from all
|
|
219
234
|
components(except `SeenEffect`, `BgBox` and `CenterColumn`) — flag
|
|
220
|
-
`startSeen` prop as deprecated
|
|
235
|
+
`startSeen` prop as deprecated
|
|
221
236
|
- fix: Export type `MultiselectOption`, deprecate `MultiSelectOption`
|
|
222
237
|
|
|
223
238
|
## 0.10.101
|
|
@@ -302,7 +317,7 @@ _2023-06-01_
|
|
|
302
317
|
_2023-05-25_
|
|
303
318
|
|
|
304
319
|
- feat(ts): Export utility type `HtmlProps` from `utils` module — for adding
|
|
305
|
-
HTML attributes (including `data-*`) to React components
|
|
320
|
+
HTML attributes (including `data-*`) to React components
|
|
306
321
|
- fix: Update dependencies to fix esm–cjs import resolution errors
|
|
307
322
|
|
|
308
323
|
## 0.10.87
|
|
@@ -368,9 +383,9 @@ _2023-02-08_
|
|
|
368
383
|
|
|
369
384
|
- feat: Automatically close "Hamburger menu" when user clicks `MainMenu` links
|
|
370
385
|
- feat: Support `MainMenuProps.onItemClick` `MainMenuItem.onClick` returning
|
|
371
|
-
`false` to prevent auto-closing of "Hamburger menu"
|
|
386
|
+
`false` to prevent auto-closing of "Hamburger menu"
|
|
372
387
|
- feat: Add `useHannaUIState` hook to "utils" — exposing `isHamburgerMenuOpen`
|
|
373
|
-
and `closeHamburgerMenu()
|
|
388
|
+
and `closeHamburgerMenu()`
|
|
374
389
|
- fix: Toggle `MainMenu` mega panels on repeated top-level link clicks
|
|
375
390
|
- fix: Close the currently open `MainMenu` mega panels on intra-link click
|
|
376
391
|
- fix: Close `ContactBubble` on intra-link/button click
|
|
@@ -435,7 +450,7 @@ _2022-11-23_
|
|
|
435
450
|
|
|
436
451
|
- feat: Add prop `onFilesRejected` to `FileInputProps`
|
|
437
452
|
- feat: Add prop `itemCount` for all Carousel-related components with
|
|
438
|
-
`children` — drop requirement for children to be an Array
|
|
453
|
+
`children` — drop requirement for children to be an Array
|
|
439
454
|
- feat(ts): Export `ArticleCardsItemProps`, deprecate `ArticleCardProps`
|
|
440
455
|
- feat(ts): Only allow either `align="right"` or `fullWidth` on `BasicTable`
|
|
441
456
|
- feat: Make `SiteSearchAutocompleteProps.renderSuggestion` optional
|
|
@@ -471,7 +486,7 @@ _2022-09-28_
|
|
|
471
486
|
_2022-09-27_
|
|
472
487
|
|
|
473
488
|
- feat: Add controlled props `open` and `onToggle` to `AccordionList` — it now
|
|
474
|
-
supports either [controlled or uncontrolled](./README-conventions.md) use
|
|
489
|
+
supports either [controlled or uncontrolled](./README-conventions.md) use
|
|
475
490
|
- fix: Squash `useMixedControlState` bugs/misbehavior and improve its typing
|
|
476
491
|
|
|
477
492
|
## 0.10.68
|
|
@@ -499,7 +514,7 @@ _2022-09-14_
|
|
|
499
514
|
- fix(ts): Make `PullQuote` & `BlockQuote`'s `by` prop required for `byHref`
|
|
500
515
|
- fix(ts): Remove accidentally exposed props on several `*Cards` components —
|
|
501
516
|
these props were never supported and were either a no-op, or resulted in
|
|
502
|
-
unstyled garbage
|
|
517
|
+
unstyled garbage
|
|
503
518
|
|
|
504
519
|
## 0.10.66
|
|
505
520
|
|
|
@@ -536,7 +551,7 @@ _2022-08-23_
|
|
|
536
551
|
_2022-08-11_
|
|
537
552
|
|
|
538
553
|
- feat: Add mouse-cursor scroll controls for `Carousel`-related components —
|
|
539
|
-
Remove mousewheel hijacking behavior
|
|
554
|
+
Remove mousewheel hijacking behavior
|
|
540
555
|
- fix: `startSeen` hiding components with `html.before-sprinkling` present
|
|
541
556
|
|
|
542
557
|
## 0.10.60
|
|
@@ -544,7 +559,7 @@ _2022-08-11_
|
|
|
544
559
|
_2022-06-24_
|
|
545
560
|
|
|
546
561
|
- fix: Add missing prop `checkOrigin` on `IframeBlock` (default: `false`)
|
|
547
|
-
- fix: Support "uncontrolled" use of `CheckboxGroup`, `RadioGroup`, et al
|
|
562
|
+
- fix: Support "uncontrolled" use of `CheckboxGroup`, `RadioGroup`, et al
|
|
548
563
|
- fix: Change build to only export CommonJS
|
|
549
564
|
|
|
550
565
|
## 0.10.59
|
|
@@ -573,7 +588,7 @@ _2022-06-07_
|
|
|
573
588
|
|
|
574
589
|
- **IMPORTANT** feat: Rename package to `@reykjavik/hanna-react` — this means
|
|
575
590
|
`@hugsmidjan_is/hanna-react` will not receive any more updates. The library
|
|
576
|
-
is otherwise the same, with the same compatibility
|
|
591
|
+
is otherwise the same, with the same compatibility
|
|
577
592
|
- feat: Add `@reykjavik/hanna-utils` as dependency
|
|
578
593
|
- feat: Deprecate the `assets` exports (instead use
|
|
579
594
|
`@reykjavik/hanna-utils/assets`)
|
|
@@ -700,7 +715,7 @@ _2022-03-22_
|
|
|
700
715
|
|
|
701
716
|
- fix: Attempt to Better capture weird `Selectbox` edge cases — Where the
|
|
702
717
|
browser (or React) snap value to something unexpected because of mismatching
|
|
703
|
-
value and/or options
|
|
718
|
+
value and/or options
|
|
704
719
|
|
|
705
720
|
## 0.10.32 – 0.10.34
|
|
706
721
|
|
|
@@ -752,7 +767,7 @@ _2022-03-09_
|
|
|
752
767
|
- feat: Deprecate the `event` argument for `Alert`'s `onClose` callback
|
|
753
768
|
- feat: Add prop `align?: 'right'` to `ButtonBar`
|
|
754
769
|
- fix: Make `FileInput` image previews (thumbnails) more resilient overall
|
|
755
|
-
- fix: Plug memory-leaks caused by `FileInput` image thumbnails
|
|
770
|
+
- fix: Plug memory-leaks caused by `FileInput` image thumbnails
|
|
756
771
|
- fix: Add support for "uncontrolled" use of `TextInput` and `Selectbox`
|
|
757
772
|
- fix: Suppress React's dev warning about preact compatibility workarounds
|
|
758
773
|
|
|
@@ -788,7 +803,7 @@ _2022-02-28_
|
|
|
788
803
|
- feat: `ButtonPrimary`, `ButtonSecondary`, `ButtonTertiary`:
|
|
789
804
|
- feat: Add prop `variant` with "destructive" option
|
|
790
805
|
- feat: Add prop `size` — deprecate prop `small`. Primary and Secondary
|
|
791
|
-
buttons now have a `wide` size variant
|
|
806
|
+
buttons now have a `wide` size variant
|
|
792
807
|
|
|
793
808
|
## 0.10.22
|
|
794
809
|
|
|
@@ -870,7 +885,7 @@ _2021-10-22_
|
|
|
870
885
|
- feat: Add component `RelatedLinks`
|
|
871
886
|
- feat: Add component `ContentImage`
|
|
872
887
|
- feat: Add component `ArticleMeta`
|
|
873
|
-
- feat: Add component `FooterBadges` for logos/badges/etc
|
|
888
|
+
- feat: Add component `FooterBadges` for logos/badges/etc
|
|
874
889
|
- feat: Add seen-effect props to `CenterColumn`
|
|
875
890
|
- feat: Export type `ProcessOverviewItemProps`
|
|
876
891
|
- feat: Export type `FooterInfoProps`, add prop `modifier` to
|
|
@@ -1088,7 +1103,7 @@ _2020-10-07_
|
|
|
1088
1103
|
- target: **Hanna 0.7** markup patterns
|
|
1089
1104
|
- `Tabs` changes:
|
|
1090
1105
|
- **BREAKING** feat: Make `Tabs` a "controlled"-only component — with no
|
|
1091
|
-
internal "activated" state
|
|
1106
|
+
internal "activated" state
|
|
1092
1107
|
- **BREAKING** feat: Rename type `TabsProps` to `TablistProps`
|
|
1093
1108
|
- **BREAKING** feat: Drop `defaultActiveIdx` prop from `TablistProps`
|
|
1094
1109
|
- feat: Add props `activeIdx`, `role`, `activateOnFocus`, `aria-label`,
|
package/FocusTrap.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ export type FocusTrapProps = {
|
|
|
11
11
|
depth?: number;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* A focus trap element that can be used to keep keyboard focus within a
|
|
14
|
+
* A focus trap element that can be used to keep keyboard focus within a
|
|
15
|
+
* container block.
|
|
15
16
|
*
|
|
16
|
-
* Make sure you only trap focus when a modal or
|
|
17
|
+
* Make sure you only trap focus when a modal or dialog is open
|
|
17
18
|
*/
|
|
18
19
|
export declare const FocusTrap: (props: FocusTrapProps) => JSX.Element;
|
package/FocusTrap.js
CHANGED
|
@@ -4,13 +4,14 @@ exports.FocusTrap = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
/**
|
|
7
|
-
* A focus trap element that can be used to keep keyboard focus within a
|
|
7
|
+
* A focus trap element that can be used to keep keyboard focus within a
|
|
8
|
+
* container block.
|
|
8
9
|
*
|
|
9
|
-
* Make sure you only trap focus when a modal or
|
|
10
|
+
* Make sure you only trap focus when a modal or dialog is open
|
|
10
11
|
*/
|
|
11
12
|
const FocusTrap = (props) => {
|
|
12
13
|
const Tag = props.Tag || 'span';
|
|
13
|
-
return (react_1.default.createElement(Tag, { tabIndex: 0, onFocus: (e) => {
|
|
14
|
+
return (react_1.default.createElement(Tag, { className: "FocusTrap", tabIndex: 0, onFocus: (e) => {
|
|
14
15
|
var _a;
|
|
15
16
|
let container = e.currentTarget;
|
|
16
17
|
let depth = Math.max(props.depth || 1, 1);
|
|
@@ -20,7 +21,7 @@ const FocusTrap = (props) => {
|
|
|
20
21
|
if (!container) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
const focusables = container.querySelectorAll('a,input, select, textarea,button, [tabindex]');
|
|
24
|
+
const focusables = container.querySelectorAll('a, input, select, textarea, button, [tabindex]:not(.FocusTrap):not([tabindex="-1"])');
|
|
24
25
|
const targetIdx = props.atTop ? focusables.length - 1 : 0;
|
|
25
26
|
(_a = focusables[targetIdx]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
26
27
|
} }));
|
|
@@ -45,9 +45,10 @@ export type AbstractModalProps = {
|
|
|
45
45
|
* defined then `stable` takes precedence.
|
|
46
46
|
*/
|
|
47
47
|
fickle?: boolean;
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Convenience callback that runs as soon as the `open` flag flips to `true` – including on initial opening.
|
|
49
50
|
*
|
|
50
|
-
* However, the initial `onOpen` is skipped
|
|
51
|
+
* However, the initial `onOpen` is skipped when `startOpen` is set to `true`.
|
|
51
52
|
*/
|
|
52
53
|
onOpen?: () => void;
|
|
53
54
|
/**
|
|
@@ -62,9 +62,9 @@ const AbstractModal = (props) => {
|
|
|
62
62
|
addToModalStack(privateDomId);
|
|
63
63
|
setTimeout(() => {
|
|
64
64
|
setOpen(true);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
65
|
+
(0, focusElm_1.focusElm)(modalElmRef.current, { delay: 50 });
|
|
66
|
+
props.onOpen && props.onOpen(); // allow onOpen to move focus to a new place....
|
|
67
|
+
}, 50);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
const closeModal = () => {
|
|
@@ -126,6 +126,6 @@ const AbstractModal = (props) => {
|
|
|
126
126
|
react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)(bem, modifier), ref: modalElmRef },
|
|
127
127
|
children,
|
|
128
128
|
isBrowser && !props.noCloseButton && (react_1.default.createElement("button", { className: `${bem}__closebutton`, type: "button", onClick: closeModal, "aria-label": closeButtonLabel, "aria-controls": domid, title: closeButtonLabel }, txt.closeButton))),
|
|
129
|
-
isBrowser && react_1.default.createElement(FocusTrap_js_1.FocusTrap,
|
|
129
|
+
isBrowser && react_1.default.createElement(FocusTrap_js_1.FocusTrap, null))));
|
|
130
130
|
};
|
|
131
131
|
exports.AbstractModal = AbstractModal;
|
package/esm/AutosuggestSearch.js
CHANGED
|
@@ -5,6 +5,8 @@ import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
|
5
5
|
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
6
6
|
import SearchInput from './SearchInput.js';
|
|
7
7
|
import { useMixedControlState } from './utils.js';
|
|
8
|
+
/** Change methods/types that should update the input value */
|
|
9
|
+
const inputChangeMethods = new Set(['type', 'enter', 'click']);
|
|
8
10
|
export const defaultAutosuggestSearchTexts = {
|
|
9
11
|
is: {
|
|
10
12
|
label: 'Leit á vefnum',
|
|
@@ -73,7 +75,10 @@ export const AutosuggestSearch = (props) => {
|
|
|
73
75
|
}, inputProps: {
|
|
74
76
|
ref: inputRef,
|
|
75
77
|
value: inputValue,
|
|
76
|
-
onChange: (_, { newValue }) => {
|
|
78
|
+
onChange: (_, { newValue, method }) => {
|
|
79
|
+
if (!inputChangeMethods.has(method)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
77
82
|
onInput(newValue);
|
|
78
83
|
setInputValue(newValue);
|
|
79
84
|
},
|
package/esm/FocusTrap.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ export type FocusTrapProps = {
|
|
|
11
11
|
depth?: number;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* A focus trap element that can be used to keep keyboard focus within a
|
|
14
|
+
* A focus trap element that can be used to keep keyboard focus within a
|
|
15
|
+
* container block.
|
|
15
16
|
*
|
|
16
|
-
* Make sure you only trap focus when a modal or
|
|
17
|
+
* Make sure you only trap focus when a modal or dialog is open
|
|
17
18
|
*/
|
|
18
19
|
export declare const FocusTrap: (props: FocusTrapProps) => JSX.Element;
|
package/esm/FocusTrap.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* A focus trap element that can be used to keep keyboard focus within a
|
|
3
|
+
* A focus trap element that can be used to keep keyboard focus within a
|
|
4
|
+
* container block.
|
|
4
5
|
*
|
|
5
|
-
* Make sure you only trap focus when a modal or
|
|
6
|
+
* Make sure you only trap focus when a modal or dialog is open
|
|
6
7
|
*/
|
|
7
8
|
export const FocusTrap = (props) => {
|
|
8
9
|
const Tag = props.Tag || 'span';
|
|
9
|
-
return (React.createElement(Tag, { tabIndex: 0, onFocus: (e) => {
|
|
10
|
+
return (React.createElement(Tag, { className: "FocusTrap", tabIndex: 0, onFocus: (e) => {
|
|
10
11
|
var _a;
|
|
11
12
|
let container = e.currentTarget;
|
|
12
13
|
let depth = Math.max(props.depth || 1, 1);
|
|
@@ -16,7 +17,7 @@ export const FocusTrap = (props) => {
|
|
|
16
17
|
if (!container) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
const focusables = container.querySelectorAll('a,input, select, textarea,button, [tabindex]');
|
|
20
|
+
const focusables = container.querySelectorAll('a, input, select, textarea, button, [tabindex]:not(.FocusTrap):not([tabindex="-1"])');
|
|
20
21
|
const targetIdx = props.atTop ? focusables.length - 1 : 0;
|
|
21
22
|
(_a = focusables[targetIdx]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
22
23
|
} }));
|
|
@@ -45,9 +45,10 @@ export type AbstractModalProps = {
|
|
|
45
45
|
* defined then `stable` takes precedence.
|
|
46
46
|
*/
|
|
47
47
|
fickle?: boolean;
|
|
48
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Convenience callback that runs as soon as the `open` flag flips to `true` – including on initial opening.
|
|
49
50
|
*
|
|
50
|
-
* However, the initial `onOpen` is skipped
|
|
51
|
+
* However, the initial `onOpen` is skipped when `startOpen` is set to `true`.
|
|
51
52
|
*/
|
|
52
53
|
onOpen?: () => void;
|
|
53
54
|
/**
|
|
@@ -58,9 +58,9 @@ export const AbstractModal = (props) => {
|
|
|
58
58
|
addToModalStack(privateDomId);
|
|
59
59
|
setTimeout(() => {
|
|
60
60
|
setOpen(true);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
61
|
+
focusElm(modalElmRef.current, { delay: 50 });
|
|
62
|
+
props.onOpen && props.onOpen(); // allow onOpen to move focus to a new place....
|
|
63
|
+
}, 50);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
const closeModal = () => {
|
|
@@ -122,5 +122,5 @@ export const AbstractModal = (props) => {
|
|
|
122
122
|
React.createElement("div", { className: modifiedClass(bem, modifier), ref: modalElmRef },
|
|
123
123
|
children,
|
|
124
124
|
isBrowser && !props.noCloseButton && (React.createElement("button", { className: `${bem}__closebutton`, type: "button", onClick: closeModal, "aria-label": closeButtonLabel, "aria-controls": domid, title: closeButtonLabel }, txt.closeButton))),
|
|
125
|
-
isBrowser && React.createElement(FocusTrap,
|
|
125
|
+
isBrowser && React.createElement(FocusTrap, null))));
|
|
126
126
|
};
|