@scottish-government/designsystem-react 0.6.0 → 0.7.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.
Files changed (151) hide show
  1. package/@types/components/Accordion.d.ts +2 -2
  2. package/@types/components/ConfirmationMessage.d.ts +1 -1
  3. package/@types/components/NotificationPanel.d.ts +1 -1
  4. package/@types/components/SummaryCard.d.ts +1 -1
  5. package/@types/components/Tabs.d.ts +1 -1
  6. package/@types/sgds.d.ts +1 -1
  7. package/CHANGELOG.md +81 -0
  8. package/README.md +4 -0
  9. package/dist/common/AbstractNotificationBanner.jsx +63 -0
  10. package/dist/common/ConditionalWrapper.jsx +8 -0
  11. package/dist/common/FileIcon.jsx +51 -0
  12. package/dist/common/HintText.jsx +9 -0
  13. package/dist/common/Icon.jsx +57 -0
  14. package/dist/common/ScreenReaderText.jsx +9 -0
  15. package/dist/common/WrapperTag.jsx +11 -0
  16. package/dist/components/Accordion/Accordion.jsx +102 -0
  17. package/dist/components/AspectBox/AspectBox.jsx +79 -0
  18. package/dist/components/BackToTop/BackToTop.jsx +27 -0
  19. package/dist/components/Breadcrumbs/Breadcrumbs.jsx +28 -0
  20. package/dist/components/Button/Button.jsx +30 -0
  21. package/dist/components/Checkbox/Checkbox.jsx +62 -0
  22. package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +24 -0
  23. package/dist/components/ContentsNav/ContentsNav.jsx +33 -0
  24. package/dist/components/CookieBanner/CookieBanner.jsx +21 -0
  25. package/dist/components/DatePicker/DatePicker.jsx +54 -0
  26. package/dist/components/Details/Details.jsx +17 -0
  27. package/dist/components/ErrorMessage/ErrorMessage.jsx +12 -0
  28. package/dist/components/ErrorSummary/ErrorSummary.jsx +27 -0
  29. package/dist/components/FileDownload/FileDownload.jsx +50 -0
  30. package/dist/components/HideThisPage/HideThisPage.jsx +71 -0
  31. package/dist/components/InsetText/InsetText.jsx +14 -0
  32. package/dist/components/NotificationBanner/NotificationBanner.jsx +26 -0
  33. package/dist/components/NotificationPanel/NotificationPanel.jsx +21 -0
  34. package/dist/components/PageHeader/PageHeader.jsx +15 -0
  35. package/dist/components/PageMetadata/PageMetadata.jsx +26 -0
  36. package/dist/components/Pagination/Pagination.jsx +97 -0
  37. package/dist/components/PhaseBanner/PhaseBanner.jsx +23 -0
  38. package/dist/components/Question/Question.jsx +22 -0
  39. package/dist/components/RadioButton/RadioButton.jsx +43 -0
  40. package/dist/components/Select/Select.jsx +52 -0
  41. package/dist/components/SequentialNavigation/SequentialNavigation.jsx +31 -0
  42. package/dist/components/SideNavigation/SideNavigation.jsx +52 -0
  43. package/dist/components/SiteHeader/SiteHeader.jsx +68 -0
  44. package/dist/components/SiteNavigation/SiteNavigation.jsx +22 -0
  45. package/dist/components/SiteSearch/SiteSearch.jsx +55 -0
  46. package/dist/components/SkipLinks/SkipLinks.jsx +21 -0
  47. package/dist/components/SummaryCard/SummaryCard.jsx +67 -0
  48. package/dist/components/SummaryList/SummaryList.jsx +75 -0
  49. package/dist/components/Table/Table.jsx +24 -0
  50. package/dist/components/Tabs/Tabs.jsx +99 -0
  51. package/dist/components/Tag/Tag.jsx +13 -0
  52. package/dist/components/TaskList/TaskList.jsx +95 -0
  53. package/dist/components/TextInput/TextInput.jsx +58 -0
  54. package/dist/components/Textarea/Textarea.jsx +54 -0
  55. package/dist/components/WarningText/WarningText.jsx +16 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +1 -1
  58. package/src/common/{abstract-notification-banner.test.tsx → AbstractNotificationBanner.test.tsx} +11 -11
  59. package/src/common/{abstract-notification-banner.tsx → AbstractNotificationBanner.tsx} +2 -2
  60. package/src/common/{conditional-wrapper.test.tsx → ConditionalWrapper.test.tsx} +1 -1
  61. package/src/common/{file-icon.test.tsx → FileIcon.test.tsx} +10 -10
  62. package/src/common/{hint-text.test.tsx → HintText.test.tsx} +12 -12
  63. package/src/common/{icon.test.tsx → Icon.test.tsx} +16 -16
  64. package/src/common/{screen-reader-text.test.tsx → ScreenReaderText.test.tsx} +5 -5
  65. package/src/common/{wrapper-tag.test.tsx → WrapperTag.test.tsx} +5 -5
  66. package/src/components/{accordion/accordion.test.tsx → Accordion/Accordion.test.tsx} +35 -35
  67. package/src/components/{accordion/accordion.tsx → Accordion/Accordion.tsx} +5 -5
  68. package/src/components/{aspect-box/aspect-box.test.tsx → AspectBox/AspectBox.test.tsx} +2 -2
  69. package/src/components/{back-to-top/back-to-top.test.tsx → BackToTop/BackToTop.test.tsx} +1 -1
  70. package/src/components/{back-to-top/back-to-top.tsx → BackToTop/BackToTop.tsx} +1 -1
  71. package/src/components/{breadcrumbs/breadcrumbs.test.tsx → Breadcrumbs/Breadcrumbs.test.tsx} +7 -7
  72. package/src/components/{button/button.test.tsx → Button/Button.test.tsx} +1 -1
  73. package/src/components/{button/button.tsx → Button/Button.tsx} +3 -3
  74. package/src/components/{checkbox/checkbox.test.tsx → Checkbox/Checkbox.test.tsx} +16 -16
  75. package/src/components/{checkbox/checkbox.tsx → Checkbox/Checkbox.tsx} +1 -1
  76. package/src/components/{confirmation-message/confirmation-message.test.tsx → ConfirmationMessage/ConfirmationMessage.test.tsx} +12 -14
  77. package/src/components/{confirmation-message/confirmation-message.tsx → ConfirmationMessage/ConfirmationMessage.tsx} +4 -4
  78. package/src/components/{contents-nav/contents-nav.test.tsx → ContentsNav/ContentsNav.test.tsx} +21 -28
  79. package/src/components/{contents-nav/contents-nav.tsx → ContentsNav/ContentsNav.tsx} +1 -1
  80. package/src/components/{cookie-banner/cookie-banner.test.tsx → CookieBanner/CookieBanner.test.tsx} +3 -3
  81. package/src/components/{cookie-banner/cookie-banner.tsx → CookieBanner/CookieBanner.tsx} +1 -1
  82. package/src/components/{date-picker/date-picker.test.tsx → DatePicker/DatePicker.test.tsx} +76 -66
  83. package/src/components/{date-picker/date-picker.tsx → DatePicker/DatePicker.tsx} +2 -2
  84. package/src/components/{details/details.test.tsx → Details/Details.test.tsx} +10 -10
  85. package/src/components/{error-message/error-message.test.tsx → ErrorMessage/ErrorMessage.test.tsx} +10 -10
  86. package/src/components/{error-summary/error-summary.test.tsx → ErrorSummary/ErrorSummary.test.tsx} +13 -14
  87. package/src/components/{error-summary/error-summary.tsx → ErrorSummary/ErrorSummary.tsx} +1 -1
  88. package/src/components/{file-download/file-download.test.tsx → FileDownload/FileDownload.test.tsx} +21 -21
  89. package/src/components/{file-download/file-download.tsx → FileDownload/FileDownload.tsx} +1 -1
  90. package/src/components/{hide-this-page/hide-this-page.test.tsx → HideThisPage/HideThisPage.test.tsx} +4 -4
  91. package/src/components/{hide-this-page/hide-this-page.tsx → HideThisPage/HideThisPage.tsx} +3 -3
  92. package/src/components/{inset-text/inset-text.test.tsx → InsetText/InsetText.test.tsx} +1 -1
  93. package/src/components/{notification-banner/notification-banner.test.tsx → NotificationBanner/NotificationBanner.test.tsx} +4 -4
  94. package/src/components/{notification-banner/notification-banner.tsx → NotificationBanner/NotificationBanner.tsx} +1 -1
  95. package/src/components/{notification-panel/notification-panel.test.tsx → NotificationPanel/NotificationPanel.test.tsx} +24 -23
  96. package/src/components/{notification-panel/notification-panel.tsx → NotificationPanel/NotificationPanel.tsx} +3 -3
  97. package/src/components/{page-header/page-header.test.tsx → PageHeader/PageHeader.test.tsx} +9 -9
  98. package/src/components/{page-metadata/page-metadata.test.tsx → PageMetadata/PageMetadata.test.tsx} +9 -9
  99. package/src/components/{pagination/pagination.test.tsx → Pagination/Pagination.test.tsx} +56 -56
  100. package/src/components/{pagination/pagination.tsx → Pagination/Pagination.tsx} +1 -1
  101. package/src/components/{phase-banner/phase-banner.test.tsx → PhaseBanner/PhaseBanner.test.tsx} +9 -9
  102. package/src/components/{phase-banner/phase-banner.tsx → PhaseBanner/PhaseBanner.tsx} +1 -1
  103. package/src/components/{question/question.test.tsx → Question/Question.test.tsx} +10 -10
  104. package/src/components/{question/question.tsx → Question/Question.tsx} +3 -3
  105. package/src/components/{radio-button/radio-button.test.tsx → RadioButton/RadioButton.test.tsx} +23 -23
  106. package/src/components/{radio-button/radio-button.tsx → RadioButton/RadioButton.tsx} +1 -1
  107. package/src/components/{select/select.test.tsx → Select/Select.test.tsx} +67 -64
  108. package/src/components/{select/select.tsx → Select/Select.tsx} +2 -2
  109. package/src/components/{sequential-navigation/sequential-navigation.test.tsx → SequentialNavigation/SequentialNavigation.test.tsx} +18 -18
  110. package/src/components/{side-navigation/side-navigation.test.tsx → SideNavigation/SideNavigation.test.tsx} +8 -8
  111. package/src/components/{site-header/site-header.test.tsx → SiteHeader/SiteHeader.test.tsx} +25 -25
  112. package/src/components/{site-header/site-header.tsx → SiteHeader/SiteHeader.tsx} +4 -4
  113. package/src/components/{site-navigation/site-navigation.test.tsx → SiteNavigation/SiteNavigation.test.tsx} +8 -8
  114. package/src/components/{site-search/site-search.test.tsx → SiteSearch/SiteSearch.test.tsx} +16 -16
  115. package/src/components/{site-search/site-search.tsx → SiteSearch/SiteSearch.tsx} +1 -1
  116. package/src/components/{skip-links/skip-links.test.tsx → SkipLinks/SkipLinks.test.tsx} +15 -15
  117. package/src/components/{summary-card/summary-card.test.tsx → SummaryCard/SummaryCard.test.tsx} +28 -28
  118. package/src/components/{summary-card/summary-card.tsx → SummaryCard/SummaryCard.tsx} +4 -4
  119. package/src/components/{summary-list/summary-list.test.tsx → SummaryList/SummaryList.test.tsx} +55 -56
  120. package/src/components/{summary-list/summary-list.tsx → SummaryList/SummaryList.tsx} +2 -2
  121. package/src/components/{table/table.test.tsx → Table/Table.test.tsx} +4 -4
  122. package/src/components/{tabs/tabs.test.tsx → Tabs/Tabs.test.tsx} +22 -42
  123. package/src/components/{tabs/tabs.tsx → Tabs/Tabs.tsx} +3 -3
  124. package/src/components/{tag/tag.test.tsx → Tag/Tag.test.tsx} +10 -10
  125. package/src/components/{task-list/task-list.test.tsx → TaskList/TaskList.test.tsx} +109 -108
  126. package/src/components/{task-list/task-list.tsx → TaskList/TaskList.tsx} +4 -4
  127. package/src/components/{text-input/text-input.test.tsx → TextInput/TextInput.test.tsx} +92 -87
  128. package/src/components/{text-input/text-input.tsx → TextInput/TextInput.tsx} +4 -4
  129. package/src/components/{textarea/textarea.test.tsx → Textarea/Textarea.test.tsx} +71 -67
  130. package/src/components/{textarea/textarea.tsx → Textarea/Textarea.tsx} +3 -3
  131. package/src/components/{warning-text/warning-text.test.tsx → WarningText/WarningText.test.tsx} +1 -1
  132. /package/src/common/{conditional-wrapper.tsx → ConditionalWrapper.tsx} +0 -0
  133. /package/src/common/{file-icon.tsx → FileIcon.tsx} +0 -0
  134. /package/src/common/{hint-text.tsx → HintText.tsx} +0 -0
  135. /package/src/common/{icon.tsx → Icon.tsx} +0 -0
  136. /package/src/common/{screen-reader-text.tsx → ScreenReaderText.tsx} +0 -0
  137. /package/src/common/{wrapper-tag.tsx → WrapperTag.tsx} +0 -0
  138. /package/src/components/{aspect-box/aspect-box.tsx → AspectBox/AspectBox.tsx} +0 -0
  139. /package/src/components/{breadcrumbs/breadcrumbs.tsx → Breadcrumbs/Breadcrumbs.tsx} +0 -0
  140. /package/src/components/{details/details.tsx → Details/Details.tsx} +0 -0
  141. /package/src/components/{error-message/error-message.tsx → ErrorMessage/ErrorMessage.tsx} +0 -0
  142. /package/src/components/{inset-text/inset-text.tsx → InsetText/InsetText.tsx} +0 -0
  143. /package/src/components/{page-header/page-header.tsx → PageHeader/PageHeader.tsx} +0 -0
  144. /package/src/components/{page-metadata/page-metadata.tsx → PageMetadata/PageMetadata.tsx} +0 -0
  145. /package/src/components/{sequential-navigation/sequential-navigation.tsx → SequentialNavigation/SequentialNavigation.tsx} +0 -0
  146. /package/src/components/{side-navigation/side-navigation.tsx → SideNavigation/SideNavigation.tsx} +0 -0
  147. /package/src/components/{site-navigation/site-navigation.tsx → SiteNavigation/SiteNavigation.tsx} +0 -0
  148. /package/src/components/{skip-links/skip-links.tsx → SkipLinks/SkipLinks.tsx} +0 -0
  149. /package/src/components/{table/table.tsx → Table/Table.tsx} +0 -0
  150. /package/src/components/{tag/tag.tsx → Tag/Tag.tsx} +0 -0
  151. /package/src/components/{warning-text/warning-text.tsx → WarningText/WarningText.tsx} +0 -0
@@ -0,0 +1,43 @@
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 HintText_1 = __importDefault(require("../../common/HintText"));
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 && <HintText_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;
@@ -0,0 +1,52 @@
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 ErrorMessage_1 = __importDefault(require("../ErrorMessage/ErrorMessage"));
7
+ const HintText_1 = __importDefault(require("../../common/HintText"));
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 && <HintText_1.default id={hintTextId} text={hintText}/>}
36
+ {errorMessage && <ErrorMessage_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;
@@ -0,0 +1,31 @@
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;
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,68 @@
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 PhaseBanner_1 = __importDefault(require("../PhaseBanner/PhaseBanner"));
10
+ const SiteNavigation_1 = __importDefault(require("../SiteNavigation/SiteNavigation"));
11
+ const SiteSearch_1 = __importDefault(require("../SiteSearch/SiteSearch"));
12
+ // @ts-ignore
13
+ const site_navigation_1 = __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_1.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
+ <SiteNavigation_1.default id="mobile-navigation" className="ds_site-navigation--mobile" items={navigationItems} ref={mobileMenuRef}/>}
48
+
49
+ {siteSearch &&
50
+ <SiteSearch_1.default className="ds_site-header__search" {...siteSearch}/>}
51
+ </div>
52
+ </div>
53
+
54
+ {phaseBanner &&
55
+ <PhaseBanner_1.default phaseName={phaseBanner.phaseName}>
56
+ {phaseBanner.content}
57
+ </PhaseBanner_1.default>}
58
+
59
+ {navigationItems &&
60
+ <div className="ds_site-header__navigation">
61
+ <div className="ds_wrapper">
62
+ <SiteNavigation_1.default items={navigationItems}/>
63
+ </div>
64
+ </div>}
65
+ </header>);
66
+ };
67
+ SiteHeader.displayName = 'SiteHeader';
68
+ exports.default = SiteHeader;
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,55 @@
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;
@@ -0,0 +1,21 @@
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;
@@ -0,0 +1,67 @@
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 SummaryList_1 = __importStar(require("../SummaryList/SummaryList"));
40
+ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
41
+ function convertToSlug(string) {
42
+ return string.toLowerCase()
43
+ .replace(/[^\w ]+/g, "")
44
+ .replace(/ +/g, "-");
45
+ }
46
+ const SummaryCard = ({ actions, className, headingLevel = '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
+ <WrapperTag_1.default className="ds_summary-card__header-title" id={describedById} tagName={headingLevel}>{title}</WrapperTag_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
+ <SummaryList_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
+ <SummaryList_1.default items={items}/>
63
+ </div>
64
+ </div>);
65
+ };
66
+ SummaryCard.displayName = 'SummaryCard';
67
+ exports.default = SummaryCard;
@@ -0,0 +1,75 @@
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.Item = exports.Action = exports.Answer = void 0;
7
+ const ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
8
+ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
9
+ function escapedNewLineToLineBreakTag(string) {
10
+ if (typeof string === 'string') {
11
+ // @ts-ignore
12
+ return string.split('\n').map((item, index) => {
13
+ return (index === 0) ? item : [<br key={index}/>, item];
14
+ });
15
+ }
16
+ }
17
+ function convertToSlug(string) {
18
+ return string.toLowerCase()
19
+ .replace(/[^\w ]+/g, "")
20
+ .replace(/ +/g, "-");
21
+ }
22
+ const Answer = ({ value }) => {
23
+ const processedValue = escapedNewLineToLineBreakTag(value.toString());
24
+ return (<q className="ds_summary-list__answer">{processedValue}</q>);
25
+ };
26
+ exports.Answer = Answer;
27
+ const Action = ({ describedby, href, onclick, title, }) => {
28
+ let tagName = 'button';
29
+ if (href) {
30
+ tagName = 'a';
31
+ }
32
+ return (<WrapperTag_1.default aria-describedby={describedby} className="ds_link" href={href} onClick={onclick} tagName={tagName} type={tagName === 'button' ? 'button' : undefined}>
33
+ {title}
34
+ </WrapperTag_1.default>);
35
+ };
36
+ exports.Action = Action;
37
+ const Item = ({ actions, index = 1, title, value }) => {
38
+ let values = [];
39
+ if (Array.isArray(value)) {
40
+ values = value;
41
+ }
42
+ else {
43
+ values = [value || ''];
44
+ }
45
+ const describedById = `q${index + 1}-${convertToSlug(title)}`;
46
+ return (<li className="ds_summary-list__item">
47
+ <span className="ds_summary-list__key" id={describedById}>{title}</span>
48
+ <span className="ds_summary-list__value">
49
+ <ConditionalWrapper_1.default condition={values.length > 1} wrapper={(children) => <ul className="ds_no-bullets">{children}</ul>}>
50
+ {values && values.map((value, index) => (<ConditionalWrapper_1.default condition={values.length > 1} wrapper={(children) => <li>{children}</li>} key={'answer' + index}>
51
+ <exports.Answer value={value}/>
52
+ </ConditionalWrapper_1.default>))}
53
+ </ConditionalWrapper_1.default>
54
+ </span>
55
+ {actions &&
56
+ <div className="ds_summary-list__actions">
57
+ {actions && actions.map((action, index) => (<exports.Action describedby={describedById} href={action.href} onclick={action.onclick} title={action.title} key={'summarylistaction' + index}/>))}
58
+ </div>}
59
+ </li>);
60
+ };
61
+ exports.Item = Item;
62
+ const SummaryList = ({ className, items, noBorder, ...props }) => {
63
+ return (<ol className={[
64
+ 'ds_summary-list',
65
+ noBorder && 'ds_summary-list--no-border',
66
+ className
67
+ ].join(' ')} {...props}>
68
+ {items && items.map((item, index) => (<exports.Item actions={item.actions} title={item.title} value={item.value} index={index} key={'summarylistitem' + index}/>))}
69
+ </ol>);
70
+ };
71
+ SummaryList.displayName = 'SummaryList';
72
+ exports.Action.displayName = 'SummaryListAction';
73
+ exports.Answer.displayName = 'SumaryListAnswer';
74
+ exports.Item.displayName = 'SummaryListItem';
75
+ exports.default = SummaryList;
@@ -0,0 +1,24 @@
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 table_1 = __importDefault(require("@scottish-government/design-system/src/components/table/table"));
9
+ const Table = ({ children, className, smallscreen, ...props }) => {
10
+ const ref = (0, react_1.useRef)(null);
11
+ (0, react_1.useEffect)(() => {
12
+ if (ref.current) {
13
+ new table_1.default().init();
14
+ }
15
+ }, [ref]);
16
+ return (<table className={[
17
+ 'ds_table',
18
+ className
19
+ ].join(' ')} data-smallscreen={smallscreen} ref={ref} {...props}>
20
+ {children}
21
+ </table>);
22
+ };
23
+ Table.displayName = 'Table';
24
+ exports.default = Table;
@@ -0,0 +1,99 @@
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 WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
41
+ // @ts-ignore
42
+ const tabs_1 = __importDefault(require("@scottish-government/design-system/src/components/tabs/tabs"));
43
+ const slugify_1 = __importDefault(require("../../utils/slugify"));
44
+ const TabItem = ({ bordered, children, className, id, tabLabel, ...props }) => {
45
+ return (<div className={[
46
+ 'ds_tabs__content',
47
+ bordered && 'ds_tabs__content--bordered',
48
+ className
49
+ ].join(' ')} id={id} {...props}>
50
+ {children}
51
+ </div>);
52
+ };
53
+ const TabListItem = ({ title, href }) => {
54
+ return (<li className="ds_tabs__tab">
55
+ <a className="ds_tabs__tab-link" href={href}>{title}</a>
56
+ </li>);
57
+ };
58
+ const Tabs = ({ baseId = 'tabs', bordered = true, children, className, headingLevel = 'h2', manual = false, title = 'Contents', ...props }) => {
59
+ const ref = (0, react_1.useRef)(null);
60
+ const headingId = `${baseId}-heading`;
61
+ (0, react_1.useEffect)(() => {
62
+ if (ref.current) {
63
+ new tabs_1.default(ref.current).init();
64
+ }
65
+ }, [ref]);
66
+ const processedItems = react_1.Children.map(children, child => {
67
+ if ((0, react_1.isValidElement)(child) && child.type === TabItem) {
68
+ let thisChild = child;
69
+ return react_1.default.cloneElement(thisChild, {
70
+ bordered: bordered,
71
+ id: thisChild.props.id || `${baseId}-${(0, slugify_1.default)(thisChild.props.tabLabel)}`,
72
+ });
73
+ }
74
+ });
75
+ const tabListItems = react_1.Children.map(processedItems, child => {
76
+ if ((0, react_1.isValidElement)(child) && child.type === TabItem) {
77
+ return react_1.default.createElement(TabListItem, { title: child.props.tabLabel, href: `#${child.props.id}` });
78
+ }
79
+ });
80
+ return (<div className={[
81
+ 'ds_tabs',
82
+ manual && 'ds_tabs--manual',
83
+ className
84
+ ].join(' ')} ref={ref} {...props}>
85
+ <WrapperTag_1.default id={headingId} className="ds_tabs__title" tagName={headingLevel}>
86
+ {title}
87
+ </WrapperTag_1.default>
88
+
89
+ <ul className="ds_tabs__list" aria-labelledby={headingId}>
90
+ {tabListItems}
91
+ </ul>
92
+
93
+ {processedItems}
94
+ </div>);
95
+ };
96
+ Tabs.displayName = 'Tabs';
97
+ TabItem.displayName = 'Tabs.Item';
98
+ Tabs.Item = TabItem;
99
+ exports.default = Tabs;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Tag = ({ className, colour, title, ...props }) => {
4
+ return (<span className={[
5
+ 'ds_tag',
6
+ className,
7
+ colour && `ds_tag--${colour}`,
8
+ ].join(' ')} {...props}>
9
+ {title}
10
+ </span>);
11
+ };
12
+ Tag.displayName = 'Tag';
13
+ exports.default = Tag;