@uncinc/uncinc-react-kitchen-sink 2.16.8 → 2.16.9
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.
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { RefObject } from 'react';
|
|
2
2
|
import './style.scss';
|
|
3
3
|
export type SkipNavProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
linkClassName?: string;
|
|
6
6
|
skipToSearch?: boolean;
|
|
7
7
|
mainContentId?: string;
|
|
8
|
-
searchId?: string;
|
|
9
8
|
skipToContentText?: string;
|
|
10
9
|
skipToSearchText?: string;
|
|
11
10
|
customLinks?: {
|
|
12
11
|
href: string;
|
|
13
12
|
text: string;
|
|
14
13
|
}[];
|
|
14
|
+
searchRef?: RefObject<HTMLInputElement>;
|
|
15
15
|
};
|
|
16
16
|
declare const SkipNav: React.FC<SkipNavProps>;
|
|
17
17
|
export default SkipNav;
|
|
@@ -6,32 +6,41 @@ var SkipNav = function SkipNav(_ref) {
|
|
|
6
6
|
var className = _ref.className,
|
|
7
7
|
linkClassName = _ref.linkClassName,
|
|
8
8
|
_ref$skipToSearch = _ref.skipToSearch,
|
|
9
|
-
skipToSearch = _ref$skipToSearch === void 0 ?
|
|
9
|
+
skipToSearch = _ref$skipToSearch === void 0 ? true : _ref$skipToSearch,
|
|
10
10
|
_ref$mainContentId = _ref.mainContentId,
|
|
11
11
|
mainContentId = _ref$mainContentId === void 0 ? 'main-content' : _ref$mainContentId,
|
|
12
|
-
_ref$searchId = _ref.searchId,
|
|
13
|
-
searchId = _ref$searchId === void 0 ? 'search' : _ref$searchId,
|
|
14
12
|
skipToContentText = _ref.skipToContentText,
|
|
15
13
|
skipToSearchText = _ref.skipToSearchText,
|
|
16
14
|
_ref$customLinks = _ref.customLinks,
|
|
17
|
-
customLinks = _ref$customLinks === void 0 ? [] : _ref$customLinks
|
|
15
|
+
customLinks = _ref$customLinks === void 0 ? [] : _ref$customLinks,
|
|
16
|
+
searchRef = _ref.searchRef;
|
|
18
17
|
var classes = c('SkipNav', className);
|
|
19
18
|
var linkClasses = c('focusable skip-link', linkClassName);
|
|
20
19
|
var _useTranslation = useTranslation(),
|
|
21
20
|
t = _useTranslation.t;
|
|
22
|
-
var defaultContentText = skipToContentText || t('atoms.skip_nav.
|
|
23
|
-
var defaultSearchText = skipToSearchText || t('atoms.skip_nav.
|
|
21
|
+
var defaultContentText = skipToContentText || t('atoms.skip_nav.skip_to_content');
|
|
22
|
+
var defaultSearchText = skipToSearchText || t('atoms.skip_nav.skip_to_search');
|
|
23
|
+
var main = document.getElementById(mainContentId);
|
|
24
24
|
var links = useMemo(function () {
|
|
25
25
|
var generatedLinks = [];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
if (main) {
|
|
27
|
+
generatedLinks.push( /*#__PURE__*/React.createElement("button", {
|
|
28
|
+
onClick: function onClick() {
|
|
29
|
+
return main.focus();
|
|
30
|
+
},
|
|
31
|
+
type: "button",
|
|
32
|
+
key: "skip-to".concat(mainContentId),
|
|
33
|
+
className: linkClasses
|
|
34
|
+
}, defaultContentText));
|
|
35
|
+
}
|
|
36
|
+
if (skipToSearch && searchRef && 'current' in searchRef && searchRef.current) {
|
|
37
|
+
generatedLinks.push( /*#__PURE__*/React.createElement("button", {
|
|
38
|
+
onClick: function onClick() {
|
|
39
|
+
var _searchRef$current;
|
|
40
|
+
return (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.focus();
|
|
41
|
+
},
|
|
42
|
+
type: "button",
|
|
33
43
|
key: "skip-to-search",
|
|
34
|
-
href: "#".concat(searchId),
|
|
35
44
|
className: linkClasses
|
|
36
45
|
}, defaultSearchText));
|
|
37
46
|
}
|
|
@@ -46,7 +55,7 @@ var SkipNav = function SkipNav(_ref) {
|
|
|
46
55
|
});
|
|
47
56
|
}
|
|
48
57
|
return generatedLinks;
|
|
49
|
-
}, [mainContentId, skipToSearch,
|
|
58
|
+
}, [mainContentId, main, skipToSearch, searchRef, defaultContentText, defaultSearchText, customLinks, linkClasses]);
|
|
50
59
|
return /*#__PURE__*/React.createElement("div", {
|
|
51
60
|
className: classes
|
|
52
61
|
}, links);
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"delete": "Verwijder tag"
|
|
67
67
|
},
|
|
68
68
|
"skip_nav": {
|
|
69
|
-
"
|
|
70
|
-
"
|
|
69
|
+
"skip_to_content": "Overslaan en naar de inhoud gaan",
|
|
70
|
+
"skip_to_search": "Naar zoekfunctie"
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"organisms": {
|