@reykjavik/hanna-react 0.10.139 → 0.10.140
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 +7 -0
- package/FocusTrap.js +2 -1
- package/Layout.js +1 -1
- package/esm/FocusTrap.js +2 -1
- package/esm/Layout.js +1 -1
- package/esm/utils/a11yHelpers.d.ts +2 -2
- package/esm/utils/a11yHelpers.js +2 -3
- package/package.json +2 -2
- package/utils/a11yHelpers.d.ts +2 -2
- package/utils/a11yHelpers.js +2 -3
package/CHANGELOG.md
CHANGED
package/FocusTrap.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FocusTrap = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const hanna_utils_1 = require("@reykjavik/hanna-utils");
|
|
6
7
|
/**
|
|
7
8
|
* A focus trap element that can be used to keep keyboard focus within a
|
|
8
9
|
* container block.
|
|
@@ -21,7 +22,7 @@ const FocusTrap = (props) => {
|
|
|
21
22
|
if (!container) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
const focusables = container.querySelectorAll(
|
|
25
|
+
const focusables = container.querySelectorAll(hanna_utils_1.focusElement.keyboardFocusableSelector);
|
|
25
26
|
const delta = props.atTop ? -1 : 1;
|
|
26
27
|
let i = delta < 0 ? focusables.length - 1 : 0;
|
|
27
28
|
let newTarget;
|
package/Layout.js
CHANGED
|
@@ -24,7 +24,7 @@ const Layout = (props) => {
|
|
|
24
24
|
react_1.default.createElement("div", { className: "Layout__header", role: "banner" },
|
|
25
25
|
(0, _Layouts_js_1.renderLayoutHomeLink)('Layout', logoLink, siteName),
|
|
26
26
|
' ',
|
|
27
|
-
navChildren && (react_1.default.createElement("a", { className: "Layout__header__navlink", href: "#pagenav", onClick: a11yHelpers_js_1.handleAnchorLinkClick, "aria-label": txt.skipLinkLabel }, txt.skipLinkLabel))),
|
|
27
|
+
navChildren && (react_1.default.createElement("a", { className: "Layout__header__navlink", href: "#pagenav", onClick: (e) => (0, a11yHelpers_js_1.handleAnchorLinkClick)(e, true), "aria-label": txt.skipLinkLabel }, txt.skipLinkLabel))),
|
|
28
28
|
react_1.default.createElement("div", { className: "Layout__main", role: "main" }, mainChildren || children),
|
|
29
29
|
navChildren && (react_1.default.createElement("div", { className: "Layout__nav", id: "pagenav", tabIndex: -1, role: "navigation" }, navChildren)),
|
|
30
30
|
react_1.default.createElement("div", { className: "Layout__footer", role: "complementary" }, footerChildren))));
|
package/esm/FocusTrap.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { focusElement } from '@reykjavik/hanna-utils';
|
|
2
3
|
/**
|
|
3
4
|
* A focus trap element that can be used to keep keyboard focus within a
|
|
4
5
|
* container block.
|
|
@@ -17,7 +18,7 @@ export const FocusTrap = (props) => {
|
|
|
17
18
|
if (!container) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
const focusables = container.querySelectorAll(
|
|
21
|
+
const focusables = container.querySelectorAll(focusElement.keyboardFocusableSelector);
|
|
21
22
|
const delta = props.atTop ? -1 : 1;
|
|
22
23
|
let i = delta < 0 ? focusables.length - 1 : 0;
|
|
23
24
|
let newTarget;
|
package/esm/Layout.js
CHANGED
|
@@ -20,7 +20,7 @@ export const Layout = (props) => {
|
|
|
20
20
|
React.createElement("div", { className: "Layout__header", role: "banner" },
|
|
21
21
|
renderLayoutHomeLink('Layout', logoLink, siteName),
|
|
22
22
|
' ',
|
|
23
|
-
navChildren && (React.createElement("a", { className: "Layout__header__navlink", href: "#pagenav", onClick: handleAnchorLinkClick, "aria-label": txt.skipLinkLabel }, txt.skipLinkLabel))),
|
|
23
|
+
navChildren && (React.createElement("a", { className: "Layout__header__navlink", href: "#pagenav", onClick: (e) => handleAnchorLinkClick(e, true), "aria-label": txt.skipLinkLabel }, txt.skipLinkLabel))),
|
|
24
24
|
React.createElement("div", { className: "Layout__main", role: "main" }, mainChildren || children),
|
|
25
25
|
navChildren && (React.createElement("div", { className: "Layout__nav", id: "pagenav", tabIndex: -1, role: "navigation" }, navChildren)),
|
|
26
26
|
React.createElement("div", { className: "Layout__footer", role: "complementary" }, footerChildren))));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const handleAnchorLinkClick:
|
|
1
|
+
import { MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
+
export declare const handleAnchorLinkClick: (e: ReactMouseEvent<HTMLAnchorElement>, forwardToFirstFocusable?: boolean) => void;
|
package/esm/utils/a11yHelpers.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { focusElement } from '@reykjavik/hanna-utils';
|
|
2
|
-
export const handleAnchorLinkClick = (e) => {
|
|
2
|
+
export const handleAnchorLinkClick = (e, forwardToFirstFocusable) => {
|
|
3
3
|
e.preventDefault();
|
|
4
4
|
const targetId = e.currentTarget.hash.slice(1);
|
|
5
5
|
const targetElm = targetId && document.getElementById(targetId);
|
|
6
6
|
if (!targetElm) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
targetElm
|
|
10
|
-
focusElement(targetElm);
|
|
9
|
+
focusElement(targetElm, forwardToFirstFocusable);
|
|
11
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/hanna-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.140",
|
|
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.16",
|
|
21
|
-
"@reykjavik/hanna-utils": "^0.2.
|
|
21
|
+
"@reykjavik/hanna-utils": "^0.2.19",
|
|
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",
|
package/utils/a11yHelpers.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const handleAnchorLinkClick:
|
|
1
|
+
import { MouseEvent as ReactMouseEvent } from 'react';
|
|
2
|
+
export declare const handleAnchorLinkClick: (e: ReactMouseEvent<HTMLAnchorElement>, forwardToFirstFocusable?: boolean) => void;
|
package/utils/a11yHelpers.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleAnchorLinkClick = void 0;
|
|
4
4
|
const hanna_utils_1 = require("@reykjavik/hanna-utils");
|
|
5
|
-
const handleAnchorLinkClick = (e) => {
|
|
5
|
+
const handleAnchorLinkClick = (e, forwardToFirstFocusable) => {
|
|
6
6
|
e.preventDefault();
|
|
7
7
|
const targetId = e.currentTarget.hash.slice(1);
|
|
8
8
|
const targetElm = targetId && document.getElementById(targetId);
|
|
9
9
|
if (!targetElm) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
targetElm
|
|
13
|
-
(0, hanna_utils_1.focusElement)(targetElm);
|
|
12
|
+
(0, hanna_utils_1.focusElement)(targetElm, forwardToFirstFocusable);
|
|
14
13
|
};
|
|
15
14
|
exports.handleAnchorLinkClick = handleAnchorLinkClick;
|