@scottish-government/designsystem-react 0.7.0 → 0.8.0-beta.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/Accordion.d.ts +0 -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 +12 -7
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +20 -15
- package/dist/components/Checkbox/Checkbox.jsx +4 -29
- package/dist/components/{aspect-box/aspect-box.jsx → Checkbox/CheckboxGroup.jsx} +14 -30
- 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 +7 -17
- package/dist/components/RadioButton/RadioGroup.jsx +21 -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/hooks/useTracking.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context.js +5 -0
- package/package.json +2 -2
- 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 +17 -4
- package/src/components/Accordion/Accordion.tsx +19 -14
- package/src/components/AspectBox/AspectBox.tsx +2 -2
- package/src/components/BackToTop/BackToTop.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +79 -48
- 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 +8 -55
- package/src/components/Checkbox/CheckboxGroup.test.tsx +37 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +41 -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 +10 -41
- package/src/components/RadioButton/RadioGroup.test.tsx +65 -0
- package/src/components/RadioButton/RadioGroup.tsx +31 -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
- package/src/hooks/useTracking.test.tsx +64 -0
- package/src/hooks/useTracking.ts +19 -0
- package/src/utils/context.ts +3 -0
- package/tsconfig.json +1 -1
- package/dist/common/abstract-notification-banner.jsx +0 -63
- package/dist/common/conditional-wrapper.jsx +0 -8
- package/dist/common/file-icon.jsx +0 -51
- package/dist/common/hint-text.jsx +0 -9
- package/dist/common/icon.jsx +0 -57
- package/dist/common/screen-reader-text.jsx +0 -9
- package/dist/common/wrapper-tag.jsx +0 -11
- package/dist/components/accordion/accordion.jsx +0 -102
- package/dist/components/back-to-top/back-to-top.jsx +0 -27
- package/dist/components/breadcrumbs/breadcrumbs.jsx +0 -28
- package/dist/components/button/button.jsx +0 -30
- package/dist/components/checkbox/checkbox.jsx +0 -62
- package/dist/components/confirmation-message/confirmation-message.jsx +0 -24
- package/dist/components/contents-nav/contents-nav.jsx +0 -33
- package/dist/components/cookie-banner/cookie-banner.jsx +0 -21
- package/dist/components/date-picker/date-picker.jsx +0 -54
- package/dist/components/details/details.jsx +0 -17
- package/dist/components/error-message/error-message.jsx +0 -12
- package/dist/components/error-summary/error-summary.jsx +0 -27
- package/dist/components/file-download/file-download.jsx +0 -50
- package/dist/components/hide-this-page/hide-this-page.jsx +0 -71
- package/dist/components/inset-text/inset-text.jsx +0 -14
- package/dist/components/notification-banner/notification-banner.jsx +0 -26
- package/dist/components/notification-panel/notification-panel.jsx +0 -21
- package/dist/components/page-header/page-header.jsx +0 -15
- package/dist/components/page-metadata/page-metadata.jsx +0 -26
- package/dist/components/pagination/pagination.jsx +0 -97
- package/dist/components/phase-banner/phase-banner.jsx +0 -23
- package/dist/components/question/question.jsx +0 -22
- package/dist/components/radio-button/radio-button.jsx +0 -43
- package/dist/components/select/select.jsx +0 -52
- package/dist/components/sequential-navigation/sequential-navigation.jsx +0 -31
- package/dist/components/side-navigation/side-navigation.jsx +0 -52
- package/dist/components/site-header/site-header.jsx +0 -68
- package/dist/components/site-navigation/site-navigation.jsx +0 -22
- package/dist/components/site-search/site-search.jsx +0 -55
- package/dist/components/skip-links/skip-links.jsx +0 -21
- package/dist/components/summary-card/summary-card.jsx +0 -67
- package/dist/components/summary-list/summary-list.jsx +0 -75
- package/dist/components/table/table.jsx +0 -24
- package/dist/components/tabs/tabs.jsx +0 -99
- package/dist/components/tag/tag.jsx +0 -13
- package/dist/components/task-list/task-list.jsx +0 -95
- package/dist/components/text-input/text-input.jsx +0 -58
- package/dist/components/textarea/textarea.jsx +0 -54
- package/dist/components/warning-text/warning-text.jsx +0 -16
- package/dist/icons/ArrowUpward.jsx +0 -41
- package/dist/icons/CalendarToday.jsx +0 -41
- package/dist/icons/Cancel.jsx +0 -40
- package/dist/icons/CheckCircle.jsx +0 -41
- package/dist/icons/ChevronLeft.jsx +0 -41
- package/dist/icons/ChevronRight.jsx +0 -41
- package/dist/icons/Close.jsx +0 -41
- package/dist/icons/Description.jsx +0 -41
- package/dist/icons/DoubleChevronLeft.jsx +0 -40
- package/dist/icons/DoubleChevronRight.jsx +0 -40
- package/dist/icons/Error.jsx +0 -41
- package/dist/icons/ExpandLess.jsx +0 -41
- package/dist/icons/ExpandMore.jsx +0 -41
- package/dist/icons/List.jsx +0 -44
- package/dist/icons/Menu.jsx +0 -41
- package/dist/icons/PriorityHigh.jsx +0 -42
- package/dist/icons/Search.jsx +0 -41
- package/dist/icons/index.js +0 -40
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const MetadataItem = ({ children, className, name, ...props }) => {
|
|
4
|
-
return (<div className={[
|
|
5
|
-
'ds_metadata__item',
|
|
6
|
-
className
|
|
7
|
-
].join(' ')} {...props}>
|
|
8
|
-
<dt className="ds_metadata__key">{name}</dt>{' '}
|
|
9
|
-
<dd className="ds_metadata__value">
|
|
10
|
-
{children}
|
|
11
|
-
</dd>
|
|
12
|
-
</div>);
|
|
13
|
-
};
|
|
14
|
-
const Metadata = ({ children, className, inline, ...props }) => {
|
|
15
|
-
return (<dl className={[
|
|
16
|
-
'ds_metadata',
|
|
17
|
-
inline && 'ds_metadata--inline',
|
|
18
|
-
className
|
|
19
|
-
].join(' ')} {...props}>
|
|
20
|
-
{children}
|
|
21
|
-
</dl>);
|
|
22
|
-
};
|
|
23
|
-
Metadata.displayName = 'Metadata';
|
|
24
|
-
MetadataItem.displayName = 'Metadata.Item';
|
|
25
|
-
Metadata.Item = MetadataItem;
|
|
26
|
-
exports.default = Metadata;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Ellipsis = exports.Page = void 0;
|
|
7
|
-
const icon_1 = __importDefault(require("../../common/icon"));
|
|
8
|
-
const Page = ({ ariaLabel, current = false, href, onClick, text }) => {
|
|
9
|
-
function handleClick(event) {
|
|
10
|
-
if (typeof onClick === 'function') {
|
|
11
|
-
onClick(event);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return (<li className="ds_pagination__item">
|
|
15
|
-
<a aria-label={ariaLabel} className={[
|
|
16
|
-
'ds_pagination__link',
|
|
17
|
-
current ? 'ds_current' : undefined
|
|
18
|
-
].join(' ')} href={href} aria-current={current ? "page" : undefined} onClick={handleClick}>
|
|
19
|
-
<span className="ds_pagination__link-label">{text}</span>
|
|
20
|
-
</a>
|
|
21
|
-
</li>);
|
|
22
|
-
};
|
|
23
|
-
exports.Page = Page;
|
|
24
|
-
const Ellipsis = () => {
|
|
25
|
-
return (<li className="ds_pagination__item" aria-hidden="true">
|
|
26
|
-
<span className="ds_pagination__link ds_pagination__link--ellipsis">…</span>
|
|
27
|
-
</li>);
|
|
28
|
-
};
|
|
29
|
-
exports.Ellipsis = Ellipsis;
|
|
30
|
-
const Pagination = ({ ariaLabel = 'Pages', className, onClick, padding = 1, page = 1, pattern = '/search?page=$1', totalPages, ...props }) => {
|
|
31
|
-
padding = Number(padding);
|
|
32
|
-
page = Number(page);
|
|
33
|
-
const minToShow = padding + 2;
|
|
34
|
-
let includeFirst, includeLast;
|
|
35
|
-
let pages = [];
|
|
36
|
-
if (page <= minToShow) {
|
|
37
|
-
for (let i = 1; i <= minToShow + 1; i++) {
|
|
38
|
-
pages.push(Number(i));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (page <= totalPages - minToShow) {
|
|
42
|
-
pages = [page];
|
|
43
|
-
for (let i = 0; i < padding; i++) {
|
|
44
|
-
pages.unshift(page - 1 - i);
|
|
45
|
-
pages.push(Number(page) + 1 + i);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
for (let i = totalPages; i > totalPages - minToShow - 1; i--) {
|
|
50
|
-
pages.push(Number(i));
|
|
51
|
-
}
|
|
52
|
-
pages.reverse();
|
|
53
|
-
}
|
|
54
|
-
// filter out pages that are out of bounds
|
|
55
|
-
pages = pages.filter(item => item > 0 && item <= totalPages);
|
|
56
|
-
if ((page - padding) > 2) {
|
|
57
|
-
includeFirst = true;
|
|
58
|
-
}
|
|
59
|
-
if ((page + padding < totalPages - 1)) {
|
|
60
|
-
includeLast = true;
|
|
61
|
-
}
|
|
62
|
-
return (<nav className={[
|
|
63
|
-
'ds_pagination',
|
|
64
|
-
className
|
|
65
|
-
].join(' ')} aria-label={ariaLabel} {...props}>
|
|
66
|
-
<ul className="ds_pagination__list">
|
|
67
|
-
{page > 1 && (<li className="ds_pagination__item">
|
|
68
|
-
<a aria-label="Previous page" className="ds_pagination__link ds_pagination__link--text ds_pagination__link--icon" href={pattern.replace('$1', String(page - 1))} data-search="pagination-previous" onClick={onClick}>
|
|
69
|
-
<icon_1.default icon="ChevronLeft"/>
|
|
70
|
-
<span className="ds_pagination__link-label">Previous</span>
|
|
71
|
-
</a>
|
|
72
|
-
</li>)}
|
|
73
|
-
|
|
74
|
-
{includeFirst && (<>
|
|
75
|
-
<exports.Page ariaLabel="Page 1" href={pattern.replace('$1', String(1))} onClick={onClick} text="1"/>
|
|
76
|
-
<exports.Ellipsis />
|
|
77
|
-
</>)}
|
|
78
|
-
|
|
79
|
-
{pages && pages.map((item, index) => (<exports.Page ariaLabel={`Page ${item}`} current={item === page} href={pattern.replace('$1', String(item))} key={`pagination${index}`} onClick={onClick} pattern={pattern} text={item.toString()}/>))}
|
|
80
|
-
|
|
81
|
-
{includeLast && (<>
|
|
82
|
-
<exports.Ellipsis />
|
|
83
|
-
<exports.Page ariaLabel={`Page ${totalPages}`} href={pattern.replace('$1', String(totalPages))} onClick={onClick} pattern={pattern} text={totalPages.toString()}/>
|
|
84
|
-
</>)}
|
|
85
|
-
|
|
86
|
-
{page < totalPages && (<li className="ds_pagination__item">
|
|
87
|
-
<a aria-label="Next page" className="ds_pagination__link ds_pagination__link--text ds_pagination__link--icon" href={pattern.replace('$1', String(page + 1))} data-search="pagination-next" onClick={onClick}>
|
|
88
|
-
<span className="ds_pagination__link-label">Next</span>
|
|
89
|
-
<icon_1.default icon="ChevronRight"/>
|
|
90
|
-
</a>
|
|
91
|
-
</li>)}
|
|
92
|
-
|
|
93
|
-
</ul>
|
|
94
|
-
</nav>);
|
|
95
|
-
};
|
|
96
|
-
Pagination.displayName = 'Pagination';
|
|
97
|
-
exports.default = Pagination;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const tag_1 = __importDefault(require("../tag/tag"));
|
|
7
|
-
const PhaseBanner = ({ children, className, content, phaseName, ...props }) => {
|
|
8
|
-
return (<div className={[
|
|
9
|
-
'ds_phase-banner',
|
|
10
|
-
className
|
|
11
|
-
].join(' ')} {...props}>
|
|
12
|
-
<div className="ds_wrapper">
|
|
13
|
-
<p className="ds_phase-banner__content">
|
|
14
|
-
{phaseName && <tag_1.default title={phaseName} className="ds_phase-banner__tag"/>}
|
|
15
|
-
<span className="ds_phase-banner__text">
|
|
16
|
-
{content ? content : children || "This is a new service"}
|
|
17
|
-
</span>
|
|
18
|
-
</p>
|
|
19
|
-
</div>
|
|
20
|
-
</div>);
|
|
21
|
-
};
|
|
22
|
-
PhaseBanner.displayName = 'PhaseBanner';
|
|
23
|
-
exports.default = PhaseBanner;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const error_message_1 = __importDefault(require("../error-message/error-message"));
|
|
7
|
-
const hint_text_1 = __importDefault(require("../../common/hint-text"));
|
|
8
|
-
const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
|
|
9
|
-
const Question = function ({ children, className, error, errorMessage, hintText, legend, tagName = 'div', ...props }) {
|
|
10
|
-
return (<wrapper_tag_1.default tagName={tagName} className={[
|
|
11
|
-
'ds_question',
|
|
12
|
-
error && 'ds_question--error',
|
|
13
|
-
className
|
|
14
|
-
].join(' ')} {...props}>
|
|
15
|
-
{legend && <legend>{legend}</legend>}
|
|
16
|
-
{hintText && <hint_text_1.default text={hintText}/>}
|
|
17
|
-
{error && errorMessage && <error_message_1.default text={errorMessage}/>}
|
|
18
|
-
{children}
|
|
19
|
-
</wrapper_tag_1.default>);
|
|
20
|
-
};
|
|
21
|
-
Question.displayName = 'Question';
|
|
22
|
-
exports.default = Question;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Radio = void 0;
|
|
7
|
-
const hint_text_1 = __importDefault(require("../../common/hint-text"));
|
|
8
|
-
const Radio = ({ checked, hintText, id, label, name, onBlur, onChange, small }) => {
|
|
9
|
-
const hintTextId = `hint-text-${id}`;
|
|
10
|
-
function handleBlur(event) {
|
|
11
|
-
if (typeof onBlur === 'function') {
|
|
12
|
-
onBlur(event);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function handleChange(event) {
|
|
16
|
-
if (typeof onChange === 'function') {
|
|
17
|
-
onChange(event);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return (<div className={[
|
|
21
|
-
'ds_radio',
|
|
22
|
-
small && 'ds_radio--small'
|
|
23
|
-
].join(' ')}>
|
|
24
|
-
<input aria-describedby={hintText ? hintTextId : undefined} className="ds_radio__input" defaultChecked={!!checked} id={id} name={name} onBlur={handleBlur} onChange={handleChange} type="radio"/>
|
|
25
|
-
<label className="ds_radio__label" htmlFor={id}>{label}</label>
|
|
26
|
-
{hintText && <hint_text_1.default id={hintTextId} text={hintText}/>}
|
|
27
|
-
</div>);
|
|
28
|
-
};
|
|
29
|
-
exports.Radio = Radio;
|
|
30
|
-
const RadioGroup = ({ className, inline, items, name, small, ...props }) => {
|
|
31
|
-
return (<div className={[
|
|
32
|
-
'ds_radios',
|
|
33
|
-
'ds_field-group',
|
|
34
|
-
inline && 'ds_field-group--inline',
|
|
35
|
-
className
|
|
36
|
-
].join(' ')} {...props}>
|
|
37
|
-
|
|
38
|
-
{items && items.map((item, index) => (<exports.Radio checked={item.checked} hintText={item.hintText} id={item.id} key={'radio' + index} label={item.label} name={name} onBlur={item.onBlur} onChange={item.onChange} small={small || item.small}/>))}
|
|
39
|
-
</div>);
|
|
40
|
-
};
|
|
41
|
-
exports.Radio.displayName = 'Radio';
|
|
42
|
-
RadioGroup.displayName = 'RadioGroup';
|
|
43
|
-
exports.default = RadioGroup;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const error_message_1 = __importDefault(require("../error-message/error-message"));
|
|
7
|
-
const hint_text_1 = __importDefault(require("../../common/hint-text"));
|
|
8
|
-
const Option = function ({ text, value }) {
|
|
9
|
-
return (<option value={value}>{text}</option>);
|
|
10
|
-
};
|
|
11
|
-
const Select = function ({ className, defaultValue, error, errorMessage, hintText, id, label, name, onBlur, onChange, options, placeholder, width, ...props }) {
|
|
12
|
-
const errorMessageId = `error-message-${id}`;
|
|
13
|
-
const hintTextId = `hint-text-${id}`;
|
|
14
|
-
const describedbys = [];
|
|
15
|
-
if (hintText) {
|
|
16
|
-
describedbys.push(hintTextId);
|
|
17
|
-
}
|
|
18
|
-
;
|
|
19
|
-
if (errorMessage) {
|
|
20
|
-
describedbys.push(errorMessageId);
|
|
21
|
-
}
|
|
22
|
-
;
|
|
23
|
-
function handleBlur(event) {
|
|
24
|
-
if (typeof onBlur === 'function') {
|
|
25
|
-
onBlur(event);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function handleChange(event) {
|
|
29
|
-
if (typeof onChange === 'function') {
|
|
30
|
-
onChange(event);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return (<>
|
|
34
|
-
<label className="ds_label" htmlFor={id}>{label}</label>
|
|
35
|
-
{hintText && <hint_text_1.default id={hintTextId} text={hintText}/>}
|
|
36
|
-
{errorMessage && <error_message_1.default id={errorMessageId} text={errorMessage}/>}
|
|
37
|
-
<div className={[
|
|
38
|
-
"ds_select-wrapper",
|
|
39
|
-
error && 'ds_input--error',
|
|
40
|
-
width && `ds_input--${width}`,
|
|
41
|
-
className
|
|
42
|
-
].join(' ')} {...props}>
|
|
43
|
-
<select aria-describedby={describedbys.join(' ')} aria-invalid={error} className="ds_select" defaultValue={defaultValue} id={id} name={name || id} onBlur={handleBlur} onChange={handleChange}>
|
|
44
|
-
<option value="">{placeholder}</option>
|
|
45
|
-
{options && options.map((option, index) => (<Option value={option.value} text={option.text} key={`option-${index}`}/>))}
|
|
46
|
-
</select>
|
|
47
|
-
<span className="ds_select-arrow" aria-hidden="true"></span>
|
|
48
|
-
</div>
|
|
49
|
-
</>);
|
|
50
|
-
};
|
|
51
|
-
Select.displayName = 'Select';
|
|
52
|
-
exports.default = Select;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const NextLink = ({ href, title }) => {
|
|
4
|
-
return (<div className="ds_sequential-nav__item ds_sequential-nav__item--next">
|
|
5
|
-
<a href={href} className="ds_sequential-nav__button ds_sequential-nav__button--right">
|
|
6
|
-
<span className="ds_sequential-nav__text" data-label="Next">
|
|
7
|
-
{title}
|
|
8
|
-
</span>
|
|
9
|
-
</a>
|
|
10
|
-
</div>);
|
|
11
|
-
};
|
|
12
|
-
const PrevLink = ({ href, title, }) => {
|
|
13
|
-
return (<div className="ds_sequential-nav__item ds_sequential-nav__item--prev">
|
|
14
|
-
<a href={href} className="ds_sequential-nav__button ds_sequential-nav__button--left">
|
|
15
|
-
<span className="ds_sequential-nav__text" data-label="Previous">
|
|
16
|
-
{title}
|
|
17
|
-
</span>
|
|
18
|
-
</a>
|
|
19
|
-
</div>);
|
|
20
|
-
};
|
|
21
|
-
const SequentialNavigation = ({ ariaLabel = 'Article navigation', className, next, previous, ...props }) => {
|
|
22
|
-
return (<nav className={[
|
|
23
|
-
'ds_sequential-nav',
|
|
24
|
-
className
|
|
25
|
-
].join(' ')} aria-label={ariaLabel} {...props}>
|
|
26
|
-
{previous && <PrevLink href={previous.href} title={previous.title}></PrevLink>}
|
|
27
|
-
{next && <NextLink href={next.href} title={next.title}></NextLink>}
|
|
28
|
-
</nav>);
|
|
29
|
-
};
|
|
30
|
-
SequentialNavigation.displayName = 'SequentialNavigation';
|
|
31
|
-
exports.default = SequentialNavigation;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Link = exports.List = void 0;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const side_navigation_1 = __importDefault(require("@scottish-government/design-system/src/components/side-navigation/side-navigation"));
|
|
10
|
-
const List = function ({ items, root }) {
|
|
11
|
-
return (<ul className="ds_side-navigation__list" id={root ? 'side-navigation-root' : undefined}>
|
|
12
|
-
{items && items.map((item, index) => (<exports.Link title={item.title} href={item.href} items={item.items} current={item.current} key={'sidenavitem' + index}/>))}
|
|
13
|
-
</ul>);
|
|
14
|
-
};
|
|
15
|
-
exports.List = List;
|
|
16
|
-
const Link = function ({ current = false, href, items, title }) {
|
|
17
|
-
return (<li className={[
|
|
18
|
-
'ds_side-navigation__item',
|
|
19
|
-
items && 'ds_side-navigation__item--has-children'
|
|
20
|
-
].join(' ')}>
|
|
21
|
-
{current ?
|
|
22
|
-
<span className="ds_side-navigation__link ds_current">{title}</span> :
|
|
23
|
-
<a href={href} className="ds_side-navigation__link">{title}</a>}
|
|
24
|
-
|
|
25
|
-
{items && <exports.List items={items}/>}
|
|
26
|
-
</li>);
|
|
27
|
-
};
|
|
28
|
-
exports.Link = Link;
|
|
29
|
-
const SideNavigation = function ({ children, className, items, ...props }) {
|
|
30
|
-
const ref = (0, react_1.useRef)(null);
|
|
31
|
-
(0, react_1.useEffect)(() => {
|
|
32
|
-
if (ref.current) {
|
|
33
|
-
new side_navigation_1.default(ref.current).init();
|
|
34
|
-
}
|
|
35
|
-
}, [ref]);
|
|
36
|
-
return (<nav aria-label="Sections" className={[
|
|
37
|
-
'ds_side-navigation',
|
|
38
|
-
className
|
|
39
|
-
].join(' ')} data-module="ds-side-navigation" ref={ref} {...props}>
|
|
40
|
-
<input type="checkbox" className="fully-hidden js-toggle-side-navigation" id="show-side-navigation" aria-controls="side-navigation-root"/>
|
|
41
|
-
<label className="ds_side-navigation__expand ds_link" htmlFor="show-side-navigation">
|
|
42
|
-
<span className="visually-hidden">Show all</span> Pages in this section
|
|
43
|
-
<span className="ds_side-navigation__expand-indicator"></span>
|
|
44
|
-
</label>
|
|
45
|
-
|
|
46
|
-
{items && <exports.List root items={items}/>}
|
|
47
|
-
</nav>);
|
|
48
|
-
};
|
|
49
|
-
SideNavigation.displayName = 'SideNavigation';
|
|
50
|
-
exports.Link.displayName = 'SideNavLink';
|
|
51
|
-
exports.List.displayName = 'SideNavList';
|
|
52
|
-
exports.default = SideNavigation;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const icon_1 = __importDefault(require("../../common/icon"));
|
|
9
|
-
const phase_banner_1 = __importDefault(require("../phase-banner/phase-banner"));
|
|
10
|
-
const site_navigation_1 = __importDefault(require("../site-navigation/site-navigation"));
|
|
11
|
-
const site_search_1 = __importDefault(require("../site-search/site-search"));
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
const site_navigation_2 = __importDefault(require("@scottish-government/design-system/src/components/site-navigation/site-navigation"));
|
|
14
|
-
const SiteHeader = ({ logo = {}, navigationItems, phaseBanner, siteSearch, siteTitle, ...props }) => {
|
|
15
|
-
const mobileMenuRef = (0, react_1.useRef)(null);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
if (mobileMenuRef.current) {
|
|
18
|
-
new site_navigation_2.default(mobileMenuRef.current).init();
|
|
19
|
-
}
|
|
20
|
-
}, [mobileMenuRef]);
|
|
21
|
-
return (<header className="ds_site-header" {...props}>
|
|
22
|
-
<div className="ds_wrapper">
|
|
23
|
-
<div className="ds_site-header__content">
|
|
24
|
-
<div className="ds_site-branding">
|
|
25
|
-
{logo &&
|
|
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>}
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
{navigationItems &&
|
|
36
|
-
<div className="ds_site-header__controls">
|
|
37
|
-
<label aria-controls="mobile-navigation" className="ds_site-header__control js-toggle-menu" htmlFor="menu">
|
|
38
|
-
<span className="ds_site-header__control-text">Menu</span>
|
|
39
|
-
<icon_1.default fill className="ds_site-header__control-icon" icon="Menu" aria-hidden="true"/>
|
|
40
|
-
<icon_1.default fill className="ds_site-header__control-icon ds_site-header__control-icon--active-icon" icon="Close" aria-hidden="true"/>
|
|
41
|
-
</label>
|
|
42
|
-
</div>}
|
|
43
|
-
|
|
44
|
-
{navigationItems &&
|
|
45
|
-
<input className="ds_site-navigation__toggle" id="menu" type="checkbox"/>}
|
|
46
|
-
{navigationItems &&
|
|
47
|
-
<site_navigation_1.default id="mobile-navigation" className="ds_site-navigation--mobile" items={navigationItems} ref={mobileMenuRef}/>}
|
|
48
|
-
|
|
49
|
-
{siteSearch &&
|
|
50
|
-
<site_search_1.default className="ds_site-header__search" {...siteSearch}/>}
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
{phaseBanner &&
|
|
55
|
-
<phase_banner_1.default phaseName={phaseBanner.phaseName}>
|
|
56
|
-
{phaseBanner.content}
|
|
57
|
-
</phase_banner_1.default>}
|
|
58
|
-
|
|
59
|
-
{navigationItems &&
|
|
60
|
-
<div className="ds_site-header__navigation">
|
|
61
|
-
<div className="ds_wrapper">
|
|
62
|
-
<site_navigation_1.default items={navigationItems}/>
|
|
63
|
-
</div>
|
|
64
|
-
</div>}
|
|
65
|
-
</header>);
|
|
66
|
-
};
|
|
67
|
-
SiteHeader.displayName = 'SiteHeader';
|
|
68
|
-
exports.default = SiteHeader;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const SiteNavLink = ({ current = false, href, title }) => {
|
|
4
|
-
return (<li className="ds_site-navigation__item">
|
|
5
|
-
<a href={href} className={[
|
|
6
|
-
'ds_site-navigation__link',
|
|
7
|
-
current ? 'ds_current' : undefined
|
|
8
|
-
].join(' ')}>{title}</a>
|
|
9
|
-
</li>);
|
|
10
|
-
};
|
|
11
|
-
const SiteNavigation = ({ className, items, ...props }) => {
|
|
12
|
-
return (<nav className={[
|
|
13
|
-
'ds_site-navigation',
|
|
14
|
-
className
|
|
15
|
-
].join(' ')} {...props}>
|
|
16
|
-
<ul className="ds_site-navigation__list">
|
|
17
|
-
{items && items.map((item, index) => (<SiteNavLink current={item.current} href={item.href} title={item.title} key={`link-${index}`}/>))}
|
|
18
|
-
</ul>
|
|
19
|
-
</nav>);
|
|
20
|
-
};
|
|
21
|
-
SiteNavigation.displayName = 'SiteNavigation';
|
|
22
|
-
exports.default = SiteNavigation;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const autocomplete_1 = __importDefault(require("@scottish-government/design-system/src/components/autocomplete/autocomplete"));
|
|
9
|
-
const button_1 = __importDefault(require("../button/button"));
|
|
10
|
-
const SiteSearch = function ({ action = '/search', autocompleteEndpoint, autocompleteSuggestionMappingFunction, className, id = 'site-search', method = 'GET', minLength = 3, name = 'q', placeholder = 'Search', ...props }) {
|
|
11
|
-
const ref = (0, react_1.useRef)(null);
|
|
12
|
-
const hasAutocomplete = !!autocompleteEndpoint;
|
|
13
|
-
let autocompleteId = hasAutocomplete ? id + '-autocomplete' : '';
|
|
14
|
-
(0, react_1.useEffect)(() => {
|
|
15
|
-
if (hasAutocomplete && ref.current) {
|
|
16
|
-
const options = {};
|
|
17
|
-
if (minLength) {
|
|
18
|
-
options.minLength = minLength;
|
|
19
|
-
}
|
|
20
|
-
if (autocompleteSuggestionMappingFunction) {
|
|
21
|
-
options.suggestionMappingFunction = autocompleteSuggestionMappingFunction;
|
|
22
|
-
}
|
|
23
|
-
const autocomplete = new autocomplete_1.default(document.getElementById(autocompleteId), autocompleteEndpoint, options);
|
|
24
|
-
autocomplete.init();
|
|
25
|
-
}
|
|
26
|
-
}, [ref, autocompleteEndpoint, autocompleteId, hasAutocomplete, minLength, autocompleteSuggestionMappingFunction]);
|
|
27
|
-
return (<div className={[
|
|
28
|
-
'ds_site-search', ,
|
|
29
|
-
className,
|
|
30
|
-
hasAutocomplete ? 'ds_autocomplete' : undefined
|
|
31
|
-
].join(' ')} id={autocompleteId ? autocompleteId : undefined} ref={ref} {...props}>
|
|
32
|
-
|
|
33
|
-
<form role="search" className="ds_site-search__form" method={method} action={action}>
|
|
34
|
-
<label className="ds_label visually-hidden" htmlFor={id} id={id + '-label'}>Search</label>
|
|
35
|
-
|
|
36
|
-
{hasAutocomplete && (<div role="status" aria-live="polite" id="autocomplete-status" className="visually-hidden"></div>)}
|
|
37
|
-
|
|
38
|
-
<div className="ds_input__wrapper ds_input__wrapper--has-icon">
|
|
39
|
-
<input aria-autocomplete={hasAutocomplete ? 'list' : undefined} aria-owns={hasAutocomplete ? 'autocomplete-suggestions' : undefined} autoComplete={hasAutocomplete ? 'off' : undefined} className={[
|
|
40
|
-
'ds_input',
|
|
41
|
-
'ds_site-search__input',
|
|
42
|
-
hasAutocomplete ? 'js-autocomplete-input' : undefined
|
|
43
|
-
].join(' ')} id={id} name={name} placeholder={placeholder} required spellCheck="false" type="search"/>
|
|
44
|
-
|
|
45
|
-
<button_1.default type="submit" icon="Search" iconOnly>Search</button_1.default>
|
|
46
|
-
|
|
47
|
-
{hasAutocomplete && (<div id="autocomplete-suggestions" className="ds_autocomplete__suggestions">
|
|
48
|
-
<ol className="ds_autocomplete__suggestions-list" role="listbox" aria-labelledby="site-search-label"></ol>
|
|
49
|
-
</div>)}
|
|
50
|
-
</div>
|
|
51
|
-
</form>
|
|
52
|
-
</div>);
|
|
53
|
-
};
|
|
54
|
-
SiteSearch.displayName = 'SiteSearch';
|
|
55
|
-
exports.default = SiteSearch;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SkipLink = void 0;
|
|
4
|
-
const SkipLink = ({ targetId, title }) => {
|
|
5
|
-
return (<li className="ds_skip-links__item">
|
|
6
|
-
<a href={`#${targetId}`} className="ds_skip-links__link">{title}</a>
|
|
7
|
-
</li>);
|
|
8
|
-
};
|
|
9
|
-
exports.SkipLink = SkipLink;
|
|
10
|
-
const SkipLinks = ({ items, mainContentId = 'main-content', mainLinkText = 'Skip to main content', ...props }) => {
|
|
11
|
-
return (<div className="ds_skip-links" {...props}>
|
|
12
|
-
<ul className="ds_skip-links__list">
|
|
13
|
-
<exports.SkipLink title={mainLinkText} targetId={mainContentId}/>
|
|
14
|
-
|
|
15
|
-
{items && items.map((item, index) => (<exports.SkipLink title={item.title} targetId={item.targetId} key={`skiplink-${index}`}/>))}
|
|
16
|
-
</ul>
|
|
17
|
-
</div>);
|
|
18
|
-
};
|
|
19
|
-
SkipLinks.displayName = 'SkipLinks';
|
|
20
|
-
exports.SkipLink.displayName = 'SkipLink';
|
|
21
|
-
exports.default = SkipLinks;
|
|
@@ -1,67 +0,0 @@
|
|
|
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 summary_list_1 = __importStar(require("../summary-list/summary-list"));
|
|
40
|
-
const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
|
|
41
|
-
function convertToSlug(string) {
|
|
42
|
-
return string.toLowerCase()
|
|
43
|
-
.replace(/[^\w ]+/g, "")
|
|
44
|
-
.replace(/ +/g, "-");
|
|
45
|
-
}
|
|
46
|
-
const SummaryCard = ({ actions, className, headerLevel = 'h3', items, title, ...props }) => {
|
|
47
|
-
const describedById = `summary-card-${convertToSlug(title)}`;
|
|
48
|
-
return (<div className={[
|
|
49
|
-
'ds_summary-card',
|
|
50
|
-
className
|
|
51
|
-
].join(' ')} {...props}>
|
|
52
|
-
<div className="ds_summary-card__header">
|
|
53
|
-
<wrapper_tag_1.default className="ds_summary-card__header-title" id={describedById} tagName={headerLevel}>{title}</wrapper_tag_1.default>
|
|
54
|
-
|
|
55
|
-
<ul className="ds_summary-card__actions-list">
|
|
56
|
-
{actions && actions.map((action, index) => (<li className="ds_summary-card__actions-list-item" key={'summarylistaction' + index}>
|
|
57
|
-
<summary_list_1.Action describedby={describedById} href={action.href} onclick={action.onclick} title={action.title}/>
|
|
58
|
-
</li>))}
|
|
59
|
-
</ul>
|
|
60
|
-
</div>
|
|
61
|
-
<div className="ds_summary-card__content">
|
|
62
|
-
<summary_list_1.default items={items}/>
|
|
63
|
-
</div>
|
|
64
|
-
</div>);
|
|
65
|
-
};
|
|
66
|
-
SummaryCard.displayName = 'SummaryCard';
|
|
67
|
-
exports.default = SummaryCard;
|