@scottish-government/designsystem-react 0.7.1 → 0.8.0
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/@types/common/AbstractNotificationBanner.d.ts +2 -2
- package/@types/common/ActionLink.d.ts +8 -0
- package/@types/common/FileIcon.d.ts +1 -1
- package/@types/common/Icon.d.ts +1 -1
- package/@types/components/Breadcrumbs.d.ts +2 -5
- package/@types/components/Checkbox.d.ts +0 -2
- package/@types/components/ConfirmationMessage.d.ts +1 -1
- package/@types/components/ContentsNav.d.ts +4 -6
- package/@types/components/DatePicker.d.ts +1 -1
- package/@types/components/ErrorSummary.d.ts +3 -4
- package/@types/components/NotificationPanel.d.ts +1 -1
- package/@types/components/Pagination.d.ts +5 -4
- package/@types/components/PhaseBanner.d.ts +0 -1
- package/@types/components/Question.d.ts +1 -1
- package/@types/components/RadioButton.d.ts +0 -1
- package/@types/components/Select.d.ts +0 -7
- package/@types/components/SequentialNavigation.d.ts +4 -4
- package/@types/components/SideNavigation.d.ts +4 -5
- package/@types/components/SiteFooter.d.ts +25 -0
- package/@types/components/SiteHeader.d.ts +10 -3
- package/@types/components/SiteNavigation.d.ts +2 -3
- package/@types/components/SkipLinks.d.ts +3 -4
- package/@types/components/SummaryCard.d.ts +0 -2
- package/@types/components/SummaryList.d.ts +0 -13
- package/@types/components/Tabs.d.ts +0 -1
- package/@types/components/Tag.d.ts +1 -3
- package/@types/components/TaskList.d.ts +1 -0
- package/@types/sgds.d.ts +13 -2
- package/CHANGELOG.md +63 -1
- package/dist/common/AbstractNotificationBanner.jsx +8 -6
- package/dist/common/ActionLink.jsx +19 -0
- package/dist/common/FileIcon.jsx +2 -7
- package/dist/common/Icon.jsx +3 -9
- package/dist/components/Accordion/Accordion.jsx +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +20 -15
- package/dist/components/Checkbox/Checkbox.jsx +2 -30
- package/dist/components/Checkbox/CheckboxGroup.jsx +69 -0
- package/dist/components/ContentsNav/ContentsNav.jsx +27 -16
- package/dist/components/CookieBanner/CookieBanner.jsx +1 -0
- package/dist/components/DatePicker/DatePicker.jsx +5 -5
- package/dist/components/ErrorSummary/ErrorSummary.jsx +28 -18
- package/dist/components/NotificationBanner/NotificationBanner.jsx +2 -2
- package/dist/components/Pagination/Pagination.jsx +42 -22
- package/dist/components/PhaseBanner/PhaseBanner.jsx +3 -3
- package/dist/components/Question/Question.jsx +3 -3
- package/dist/components/RadioButton/RadioButton.jsx +3 -17
- package/dist/components/RadioButton/RadioGroup.jsx +61 -0
- package/dist/components/Select/Select.jsx +4 -7
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +31 -18
- package/dist/components/SideNavigation/SideNavigation.jsx +17 -16
- package/dist/components/SiteFooter/SiteFooter.jsx +104 -0
- package/dist/components/SiteHeader/SiteHeader.jsx +113 -32
- package/dist/components/SiteNavigation/SiteNavigation.jsx +20 -7
- package/dist/components/SkipLinks/SkipLinks.jsx +10 -10
- package/dist/components/SummaryCard/SummaryCard.jsx +25 -14
- package/dist/components/SummaryList/SummaryList.jsx +65 -47
- package/dist/components/Tabs/Tabs.jsx +6 -6
- package/dist/components/Tag/Tag.jsx +2 -2
- package/dist/components/TaskList/TaskList.jsx +14 -3
- package/dist/components/TextInput/TextInput.jsx +3 -3
- package/dist/components/Textarea/Textarea.jsx +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/AbstractNotificationBanner.test.tsx +1 -1
- package/src/common/AbstractNotificationBanner.tsx +14 -13
- package/src/common/ActionLink.test.tsx +80 -0
- package/src/common/ActionLink.tsx +27 -0
- package/src/common/ConditionalWrapper.tsx +1 -1
- package/src/common/FileIcon.tsx +7 -11
- package/src/common/HintText.tsx +2 -2
- package/src/common/Icon.tsx +13 -17
- package/src/common/ScreenReaderText.tsx +2 -2
- package/src/common/WrapperTag.tsx +2 -2
- package/src/components/Accordion/Accordion.test.tsx +1 -1
- package/src/components/Accordion/Accordion.tsx +6 -7
- package/src/components/AspectBox/AspectBox.tsx +2 -2
- package/src/components/BackToTop/BackToTop.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +79 -47
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +31 -31
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/Checkbox/Checkbox.test.tsx +1 -96
- package/src/components/Checkbox/Checkbox.tsx +3 -55
- package/src/components/Checkbox/CheckboxGroup.test.tsx +37 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +46 -0
- package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +2 -2
- package/src/components/ContentsNav/ContentsNav.test.tsx +40 -51
- package/src/components/ContentsNav/ContentsNav.tsx +32 -25
- package/src/components/CookieBanner/CookieBanner.tsx +3 -3
- package/src/components/DatePicker/DatePicker.test.tsx +1 -1
- package/src/components/DatePicker/DatePicker.tsx +7 -7
- package/src/components/Details/Details.tsx +2 -2
- package/src/components/ErrorMessage/ErrorMessage.tsx +2 -2
- package/src/components/ErrorSummary/ErrorSummary.test.tsx +40 -34
- package/src/components/ErrorSummary/ErrorSummary.tsx +40 -32
- package/src/components/FileDownload/FileDownload.tsx +2 -2
- package/src/components/HideThisPage/HideThisPage.tsx +2 -2
- package/src/components/InsetText/InsetText.tsx +2 -2
- package/src/components/NotificationBanner/NotificationBanner.tsx +6 -7
- package/src/components/NotificationPanel/NotificationPanel.tsx +2 -2
- package/src/components/PageHeader/PageHeader.tsx +2 -2
- package/src/components/PageMetadata/PageMetadata.tsx +4 -5
- package/src/components/Pagination/Pagination.test.tsx +26 -7
- package/src/components/Pagination/Pagination.tsx +70 -36
- package/src/components/PhaseBanner/PhaseBanner.tsx +4 -5
- package/src/components/Question/Question.test.tsx +1 -1
- package/src/components/Question/Question.tsx +5 -5
- package/src/components/RadioButton/RadioButton.test.tsx +7 -126
- package/src/components/RadioButton/RadioButton.tsx +4 -41
- package/src/components/RadioButton/RadioGroup.test.tsx +65 -0
- package/src/components/RadioButton/RadioGroup.tsx +38 -0
- package/src/components/Select/Select.test.tsx +39 -37
- package/src/components/Select/Select.tsx +7 -22
- package/src/components/SequentialNavigation/SequentialNavigation.test.tsx +32 -21
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +52 -30
- package/src/components/SideNavigation/SideNavigation.test.tsx +39 -85
- package/src/components/SideNavigation/SideNavigation.tsx +27 -29
- package/src/components/SiteFooter/SiteFooter.test.tsx +153 -0
- package/src/components/SiteFooter/SiteFooter.tsx +107 -0
- package/src/components/SiteHeader/SiteHeader.test.tsx +87 -79
- package/src/components/SiteHeader/SiteHeader.tsx +103 -40
- package/src/components/SiteNavigation/SiteNavigation.test.tsx +42 -23
- package/src/components/SiteNavigation/SiteNavigation.tsx +28 -16
- package/src/components/SiteSearch/SiteSearch.tsx +2 -2
- package/src/components/SkipLinks/SkipLinks.test.tsx +22 -10
- package/src/components/SkipLinks/SkipLinks.tsx +16 -15
- package/src/components/SummaryCard/SummaryCard.test.tsx +31 -35
- package/src/components/SummaryCard/SummaryCard.tsx +39 -28
- package/src/components/SummaryList/SummaryList.test.tsx +49 -148
- package/src/components/SummaryList/SummaryList.tsx +54 -92
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +14 -15
- package/src/components/Tag/Tag.test.tsx +4 -4
- package/src/components/Tag/Tag.tsx +4 -4
- package/src/components/TaskList/TaskList.test.tsx +26 -0
- package/src/components/TaskList/TaskList.tsx +21 -11
- package/src/components/TextInput/TextInput.test.tsx +1 -1
- package/src/components/TextInput/TextInput.tsx +5 -5
- package/src/components/Textarea/Textarea.test.tsx +1 -1
- package/src/components/Textarea/Textarea.tsx +5 -5
- package/src/components/WarningText/WarningText.tsx +2 -2
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const SeqNavLink = ({ children, href, isPrev, linkComponent, textLabel }) => {
|
|
4
|
+
const LINK_CLASSES = [
|
|
5
|
+
'ds_sequential-nav__button',
|
|
6
|
+
isPrev ? 'ds_sequential-nav__button--left' : 'ds_sequential-nav__button--right'
|
|
7
|
+
].join(' ');
|
|
8
|
+
const ITEM_CLASSES = [
|
|
9
|
+
'ds_sequential-nav__item',
|
|
10
|
+
isPrev ? 'ds_sequential-nav__item--prev' : 'ds_sequential-nav__item--next'
|
|
11
|
+
].join(' ');
|
|
12
|
+
function processChildren(children) {
|
|
13
|
+
const linkInner = <span className="ds_sequential-nav__text" data-label={textLabel}>{children}</span>;
|
|
14
|
+
if (linkComponent) {
|
|
15
|
+
return linkComponent({ className: LINK_CLASSES, href, children: linkInner });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return <a href={href} className={LINK_CLASSES}>{linkInner}</a>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return (<div className={ITEM_CLASSES}>
|
|
22
|
+
{processChildren(children)}
|
|
10
23
|
</div>);
|
|
11
24
|
};
|
|
12
|
-
const
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</span>
|
|
18
|
-
</a>
|
|
19
|
-
</div>);
|
|
25
|
+
const NextLink = ({ children, href, linkComponent, textLabel = 'Next' }) => {
|
|
26
|
+
return <SeqNavLink href={href} linkComponent={linkComponent} textLabel={textLabel}>{children}</SeqNavLink>;
|
|
27
|
+
};
|
|
28
|
+
const PreviousLink = ({ children, href, linkComponent, textLabel = 'Previous' }) => {
|
|
29
|
+
return <SeqNavLink href={href} linkComponent={linkComponent} textLabel={textLabel} isPrev>{children}</SeqNavLink>;
|
|
20
30
|
};
|
|
21
|
-
const SequentialNavigation = ({ ariaLabel = 'Article navigation',
|
|
31
|
+
const SequentialNavigation = ({ ariaLabel = 'Article navigation', children, className, ...props }) => {
|
|
22
32
|
return (<nav className={[
|
|
23
33
|
'ds_sequential-nav',
|
|
24
34
|
className
|
|
25
35
|
].join(' ')} aria-label={ariaLabel} {...props}>
|
|
26
|
-
{
|
|
27
|
-
{next && <NextLink href={next.href} title={next.title}></NextLink>}
|
|
36
|
+
{children}
|
|
28
37
|
</nav>);
|
|
29
38
|
};
|
|
30
39
|
SequentialNavigation.displayName = 'SequentialNavigation';
|
|
40
|
+
SequentialNavigation.Next = NextLink;
|
|
41
|
+
SequentialNavigation.Previous = PreviousLink;
|
|
42
|
+
NextLink.displayName = 'SequentialNavigation.Next';
|
|
43
|
+
PreviousLink.displayName = 'SequentialNavigation.Previous';
|
|
31
44
|
exports.default = SequentialNavigation;
|
|
@@ -3,33 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Link = exports.List = void 0;
|
|
7
6
|
const react_1 = require("react");
|
|
8
7
|
// @ts-ignore
|
|
9
8
|
const side_navigation_1 = __importDefault(require("@scottish-government/design-system/src/components/side-navigation/side-navigation"));
|
|
10
|
-
const
|
|
11
|
-
return (<ul className="ds_side-navigation__list" id={
|
|
12
|
-
{
|
|
9
|
+
const SideNavigationList = function ({ children, isRoot }) {
|
|
10
|
+
return (<ul className="ds_side-navigation__list" id={isRoot ? 'side-navigation-root' : undefined}>
|
|
11
|
+
{children}
|
|
13
12
|
</ul>);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
const
|
|
14
|
+
const SideNavigationItem = function ({ children, href, current = false, linkComponent, title }) {
|
|
15
|
+
const LINK_CLASS = 'ds_side-navigation__link';
|
|
17
16
|
return (<li className={[
|
|
18
17
|
'ds_side-navigation__item',
|
|
19
|
-
|
|
18
|
+
children && 'ds_side-navigation__item--has-children'
|
|
20
19
|
].join(' ')}>
|
|
21
20
|
{current ?
|
|
22
|
-
<span className=
|
|
23
|
-
|
|
21
|
+
<span className={LINK_CLASS + ' ds_current'}>{title}</span> :
|
|
22
|
+
linkComponent ? linkComponent({ className: LINK_CLASS, href, children: title }) :
|
|
23
|
+
<a href={href} className={LINK_CLASS}>{title}</a>}
|
|
24
24
|
|
|
25
|
-
{
|
|
25
|
+
{children}
|
|
26
26
|
</li>);
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
const SideNavigation = function ({ children, className, items, ...props }) {
|
|
28
|
+
const SideNavigation = function ({ children, className, ...props }) {
|
|
30
29
|
const ref = (0, react_1.useRef)(null);
|
|
31
30
|
(0, react_1.useEffect)(() => {
|
|
32
|
-
if (ref.current) {
|
|
31
|
+
if (ref.current && children) {
|
|
33
32
|
new side_navigation_1.default(ref.current).init();
|
|
34
33
|
}
|
|
35
34
|
}, [ref]);
|
|
@@ -43,10 +42,12 @@ const SideNavigation = function ({ children, className, items, ...props }) {
|
|
|
43
42
|
<span className="ds_side-navigation__expand-indicator"></span>
|
|
44
43
|
</label>
|
|
45
44
|
|
|
46
|
-
{
|
|
45
|
+
{children}
|
|
47
46
|
</nav>);
|
|
48
47
|
};
|
|
49
48
|
SideNavigation.displayName = 'SideNavigation';
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
SideNavigationItem.displayName = 'SideNavigation.Item';
|
|
50
|
+
SideNavigationList.displayName = 'SideNavigation.List';
|
|
51
|
+
SideNavigation.Item = SideNavigationItem;
|
|
52
|
+
SideNavigation.List = SideNavigationList;
|
|
52
53
|
exports.default = SideNavigation;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
|
|
41
|
+
const License = ({ children, ...props }) => {
|
|
42
|
+
return (<div className="ds_site-footer__copyright" {...props}>
|
|
43
|
+
{children}
|
|
44
|
+
</div>);
|
|
45
|
+
};
|
|
46
|
+
const Links = ({ children, ...props }) => {
|
|
47
|
+
return (<ul className="ds_site-footer__site-items" {...props}>
|
|
48
|
+
{children}
|
|
49
|
+
</ul>);
|
|
50
|
+
};
|
|
51
|
+
const Link = ({ children, href, linkComponent, ...props }) => {
|
|
52
|
+
function processChildren(children) {
|
|
53
|
+
if (linkComponent) {
|
|
54
|
+
return linkComponent({ href, children });
|
|
55
|
+
}
|
|
56
|
+
else if (href) {
|
|
57
|
+
return <a href={href}>{children}</a>;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return children;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return <li className="ds_site-items__item" {...props}>
|
|
64
|
+
{processChildren(children)}
|
|
65
|
+
</li>;
|
|
66
|
+
};
|
|
67
|
+
const Org = ({ href, title, children, ...props }) => {
|
|
68
|
+
children = react_1.Children.map(children, child => {
|
|
69
|
+
let thisChild = child;
|
|
70
|
+
if (thisChild && ['img', 'svg', 'picture'].includes(thisChild.type)) {
|
|
71
|
+
return react_1.default.cloneElement(thisChild, { className: 'ds_site-footer__org-logo' });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return child;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return (<div className="ds_site-footer__org" {...props}>
|
|
78
|
+
<ConditionalWrapper_1.default condition={typeof href !== 'undefined'} wrapper={(children) => <a className="ds_site-footer__org-link" title={title} href={href}>{children}</a>}>
|
|
79
|
+
{children}
|
|
80
|
+
</ConditionalWrapper_1.default>
|
|
81
|
+
</div>);
|
|
82
|
+
};
|
|
83
|
+
const SiteFooter = ({ children, className, ...props }) => {
|
|
84
|
+
return (<footer className={[
|
|
85
|
+
"ds_site-footer",
|
|
86
|
+
className
|
|
87
|
+
].join(' ')} {...props}>
|
|
88
|
+
<div className="ds_wrapper">
|
|
89
|
+
<div className="ds_site-footer__content">
|
|
90
|
+
{children}
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</footer>);
|
|
94
|
+
};
|
|
95
|
+
SiteFooter.Links = Links;
|
|
96
|
+
SiteFooter.Link = Link;
|
|
97
|
+
SiteFooter.License = License;
|
|
98
|
+
SiteFooter.Org = Org;
|
|
99
|
+
SiteFooter.displayName = 'SiteFooter';
|
|
100
|
+
Links.displayName = 'SiteFooter.Links';
|
|
101
|
+
Link.displayName = 'SiteFooter.Link';
|
|
102
|
+
License.displayName = 'SiteFooter.License';
|
|
103
|
+
Org.displayName = 'SiteFooter.Org';
|
|
104
|
+
exports.default = SiteFooter;
|
|
@@ -1,18 +1,101 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
38
|
};
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const react_1 = require("react");
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
8
41
|
const Icon_1 = __importDefault(require("../../common/Icon"));
|
|
9
|
-
const PhaseBanner_1 = __importDefault(require("../PhaseBanner/PhaseBanner"));
|
|
10
42
|
const SiteNavigation_1 = __importDefault(require("../SiteNavigation/SiteNavigation"));
|
|
11
|
-
const SiteSearch_1 = __importDefault(require("../SiteSearch/SiteSearch"));
|
|
12
43
|
// @ts-ignore
|
|
13
44
|
const site_navigation_1 = __importDefault(require("@scottish-government/design-system/src/components/site-navigation/site-navigation"));
|
|
14
|
-
const
|
|
45
|
+
const Brand = ({ children, homeUrl = '/', linkComponent, siteTitle }) => {
|
|
46
|
+
function processChildren(children) {
|
|
47
|
+
const image = react_1.default.cloneElement(children, { className: 'ds_site-branding__logo-image' });
|
|
48
|
+
if (linkComponent) {
|
|
49
|
+
return linkComponent({ className: 'ds_site-branding__logo ds_site-branding__link', href: homeUrl, children: image });
|
|
50
|
+
}
|
|
51
|
+
else if (homeUrl) {
|
|
52
|
+
return <a href={homeUrl} className="ds_site-branding__logo ds_site-branding__link">{image}</a>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return (<>
|
|
56
|
+
{processChildren(children)}
|
|
57
|
+
|
|
58
|
+
{siteTitle &&
|
|
59
|
+
<div className="ds_site-branding__title">
|
|
60
|
+
{siteTitle}
|
|
61
|
+
</div>}
|
|
62
|
+
</>);
|
|
63
|
+
};
|
|
64
|
+
const Navigation = ({ children }) => {
|
|
65
|
+
return children;
|
|
66
|
+
};
|
|
67
|
+
const Phase = ({ children }) => {
|
|
68
|
+
return children;
|
|
69
|
+
};
|
|
70
|
+
const Search = ({ children }) => {
|
|
71
|
+
return children;
|
|
72
|
+
};
|
|
73
|
+
const SiteHeader = ({ children, logo = {}, navigationItems, phaseBanner, siteSearch, siteTitle, ...props }) => {
|
|
15
74
|
const mobileMenuRef = (0, react_1.useRef)(null);
|
|
75
|
+
let branding;
|
|
76
|
+
let navigation;
|
|
77
|
+
let mobileNavigation;
|
|
78
|
+
let phase;
|
|
79
|
+
let search;
|
|
80
|
+
// assign to slots
|
|
81
|
+
react_1.Children.forEach(children, (child) => {
|
|
82
|
+
const thisChild = child;
|
|
83
|
+
if (thisChild && thisChild.type === Brand) {
|
|
84
|
+
branding = thisChild;
|
|
85
|
+
}
|
|
86
|
+
else if (thisChild && thisChild.type === Navigation) {
|
|
87
|
+
navigation = thisChild;
|
|
88
|
+
if (thisChild.props.children.type === SiteNavigation_1.default) {
|
|
89
|
+
mobileNavigation = react_1.default.cloneElement(thisChild.props.children, { className: 'ds_site-navigation--mobile', id: 'mobile-navigation', ref: mobileMenuRef });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (thisChild && thisChild.type === Phase) {
|
|
93
|
+
phase = thisChild;
|
|
94
|
+
}
|
|
95
|
+
else if (thisChild && thisChild.type === Search) {
|
|
96
|
+
search = thisChild;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
16
99
|
(0, react_1.useEffect)(() => {
|
|
17
100
|
if (mobileMenuRef.current) {
|
|
18
101
|
new site_navigation_1.default(mobileMenuRef.current).init();
|
|
@@ -22,47 +105,45 @@ const SiteHeader = ({ logo = {}, navigationItems, phaseBanner, siteSearch, siteT
|
|
|
22
105
|
<div className="ds_wrapper">
|
|
23
106
|
<div className="ds_site-header__content">
|
|
24
107
|
<div className="ds_site-branding">
|
|
25
|
-
{
|
|
26
|
-
<a className="ds_site-branding__logo ds_site-branding__link" href={logo.href ? logo.href : '/'}>
|
|
27
|
-
<img className="ds_site-branding__logo-image" src={logo.src} alt={logo.alt}/>
|
|
28
|
-
</a>}
|
|
29
|
-
|
|
30
|
-
{siteTitle && <div className="ds_site-branding__title">
|
|
31
|
-
{siteTitle}
|
|
32
|
-
</div>}
|
|
108
|
+
{branding}
|
|
33
109
|
</div>
|
|
34
110
|
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
111
|
+
{mobileNavigation &&
|
|
112
|
+
<>
|
|
113
|
+
<div className="ds_site-header__controls">
|
|
114
|
+
<label aria-controls="mobile-navigation" className="ds_site-header__control js-toggle-menu" htmlFor="menu">
|
|
115
|
+
<span className="ds_site-header__control-text">Menu</span>
|
|
116
|
+
<Icon_1.default fill className="ds_site-header__control-icon" icon="Menu" aria-hidden="true"/>
|
|
117
|
+
<Icon_1.default fill className="ds_site-header__control-icon ds_site-header__control-icon--active-icon" icon="Close" aria-hidden="true"/>
|
|
118
|
+
</label>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<input className="ds_site-navigation__toggle" id="menu" type="checkbox"/>
|
|
122
|
+
</>}
|
|
43
123
|
|
|
44
|
-
{
|
|
45
|
-
<input className="ds_site-navigation__toggle" id="menu" type="checkbox"/>}
|
|
46
|
-
{navigationItems &&
|
|
47
|
-
<SiteNavigation_1.default id="mobile-navigation" className="ds_site-navigation--mobile" items={navigationItems} ref={mobileMenuRef}/>}
|
|
124
|
+
{mobileNavigation}
|
|
48
125
|
|
|
49
|
-
{
|
|
50
|
-
<SiteSearch_1.default className="ds_site-header__search" {...siteSearch}/>}
|
|
126
|
+
<div className="ds_site-header__search">{search}</div>
|
|
51
127
|
</div>
|
|
52
128
|
</div>
|
|
53
129
|
|
|
54
|
-
{
|
|
55
|
-
<PhaseBanner_1.default phaseName={phaseBanner.phaseName}>
|
|
56
|
-
{phaseBanner.content}
|
|
57
|
-
</PhaseBanner_1.default>}
|
|
130
|
+
{phase}
|
|
58
131
|
|
|
59
|
-
{
|
|
132
|
+
{navigation &&
|
|
60
133
|
<div className="ds_site-header__navigation">
|
|
61
134
|
<div className="ds_wrapper">
|
|
62
|
-
|
|
135
|
+
{navigation}
|
|
63
136
|
</div>
|
|
64
137
|
</div>}
|
|
65
138
|
</header>);
|
|
66
139
|
};
|
|
140
|
+
SiteHeader.Brand = Brand;
|
|
141
|
+
SiteHeader.Navigation = Navigation;
|
|
142
|
+
SiteHeader.Phase = Phase;
|
|
143
|
+
SiteHeader.Search = Search;
|
|
67
144
|
SiteHeader.displayName = 'SiteHeader';
|
|
145
|
+
Brand.displayName = 'SiteHeader.Brand';
|
|
146
|
+
Navigation.displayName = 'SiteHeader.Navigation';
|
|
147
|
+
Phase.displayName = 'SiteHeader.Phase';
|
|
148
|
+
Search.displayName = 'SiteHeader.Search';
|
|
68
149
|
exports.default = SiteHeader;
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const Item = ({ children, current = false, href, linkComponent }) => {
|
|
4
|
+
const classNames = ['ds_site-navigation__link'];
|
|
5
|
+
let ariaCurrent;
|
|
6
|
+
if (current) {
|
|
7
|
+
classNames.push('ds_current');
|
|
8
|
+
ariaCurrent = 'page';
|
|
9
|
+
}
|
|
10
|
+
function processChildren(children) {
|
|
11
|
+
if (linkComponent) {
|
|
12
|
+
return linkComponent({ className: classNames.join(' '), href, children });
|
|
13
|
+
}
|
|
14
|
+
else if (href) {
|
|
15
|
+
return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNames.join(' ')}>{children}</a>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
4
18
|
return (<li className="ds_site-navigation__item">
|
|
5
|
-
|
|
6
|
-
'ds_site-navigation__link',
|
|
7
|
-
current ? 'ds_current' : undefined
|
|
8
|
-
].join(' ')}>{title}</a>
|
|
19
|
+
{processChildren(children)}
|
|
9
20
|
</li>);
|
|
10
21
|
};
|
|
11
|
-
const SiteNavigation = ({
|
|
22
|
+
const SiteNavigation = ({ children, className, ...props }) => {
|
|
12
23
|
return (<nav className={[
|
|
13
24
|
'ds_site-navigation',
|
|
14
25
|
className
|
|
15
26
|
].join(' ')} {...props}>
|
|
16
27
|
<ul className="ds_site-navigation__list">
|
|
17
|
-
{
|
|
28
|
+
{children}
|
|
18
29
|
</ul>
|
|
19
30
|
</nav>);
|
|
20
31
|
};
|
|
21
32
|
SiteNavigation.displayName = 'SiteNavigation';
|
|
33
|
+
SiteNavigation.Item = Item;
|
|
34
|
+
Item.displayName = 'SiteNavigation.Item';
|
|
22
35
|
exports.default = SiteNavigation;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const SkipLink = ({ targetId, title }) => {
|
|
3
|
+
const Link = ({ children, fragmentId }) => {
|
|
5
4
|
return (<li className="ds_skip-links__item">
|
|
6
|
-
<a href={`#${
|
|
5
|
+
<a href={`#${fragmentId}`} className="ds_skip-links__link">{children}</a>
|
|
7
6
|
</li>);
|
|
8
7
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const SkipLinks = ({ children, mainContentId = 'main-content', mainLinkText = 'Skip to main content', isStatic, ...props }) => {
|
|
9
|
+
return (<div className={[
|
|
10
|
+
'ds_skip-links',
|
|
11
|
+
isStatic && 'ds_skip-links--static',
|
|
12
|
+
].join(' ')} {...props}>
|
|
12
13
|
<ul className="ds_skip-links__list">
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
{items && items.map((item, index) => (<exports.SkipLink title={item.title} targetId={item.targetId} key={`skiplink-${index}`}/>))}
|
|
14
|
+
{children ? children : <Link fragmentId={mainContentId}>{mainLinkText}</Link>}
|
|
16
15
|
</ul>
|
|
17
16
|
</div>);
|
|
18
17
|
};
|
|
19
18
|
SkipLinks.displayName = 'SkipLinks';
|
|
20
|
-
|
|
19
|
+
Link.displayName = 'SkipLink';
|
|
20
|
+
SkipLinks.Link = Link;
|
|
21
21
|
exports.default = SkipLinks;
|
|
@@ -36,15 +36,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const ActionLink_1 = __importDefault(require("../../common/ActionLink"));
|
|
41
|
+
const ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
|
|
40
42
|
const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
43
|
+
const SummaryCard = ({ children, className, headingLevel = 'h3', title, ...props }) => {
|
|
44
|
+
let actions = [];
|
|
45
|
+
let remainingChildren = [];
|
|
46
|
+
const describedById = (0, react_1.useId)();
|
|
47
|
+
react_1.Children.forEach(children, (child) => {
|
|
48
|
+
const thisChild = child;
|
|
49
|
+
if (thisChild && thisChild.type === ActionLink_1.default) {
|
|
50
|
+
actions.push(react_1.default.cloneElement(thisChild, { describedby: describedById }));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
remainingChildren.push(thisChild);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
48
56
|
return (<div className={[
|
|
49
57
|
'ds_summary-card',
|
|
50
58
|
className
|
|
@@ -52,16 +60,19 @@ const SummaryCard = ({ actions, className, headingLevel = 'h3', items, title, ..
|
|
|
52
60
|
<div className="ds_summary-card__header">
|
|
53
61
|
<WrapperTag_1.default className="ds_summary-card__header-title" id={describedById} tagName={headingLevel}>{title}</WrapperTag_1.default>
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
{actions &&
|
|
64
|
+
<ConditionalWrapper_1.default condition={actions.length > 1} wrapper={(children) => <ul className="ds_summary-card__actions-list">{children}</ul>}>
|
|
65
|
+
{actions && actions.map((action, index) => (<ConditionalWrapper_1.default condition={actions.length > 1} wrapper={(children) => <li className="ds_summary-card__actions-list-item">{children}</li>} key={'action' + index}>
|
|
66
|
+
{action}
|
|
67
|
+
</ConditionalWrapper_1.default>))}
|
|
68
|
+
</ConditionalWrapper_1.default>}
|
|
60
69
|
</div>
|
|
61
70
|
<div className="ds_summary-card__content">
|
|
62
|
-
|
|
71
|
+
{remainingChildren}
|
|
63
72
|
</div>
|
|
64
73
|
</div>);
|
|
65
74
|
};
|
|
66
75
|
SummaryCard.displayName = 'SummaryCard';
|
|
76
|
+
SummaryCard.Action = ActionLink_1.default;
|
|
77
|
+
SummaryCard.Action.displayName = 'SummaryCard.Action';
|
|
67
78
|
exports.default = SummaryCard;
|