@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
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace Accordion {
3
3
  interface Item extends React.AllHTMLAttributes<HTMLElement> {
4
- headerLevel?: SGDS.HeaderLevel,
4
+ headingLevel?: SGDS.HeadingLevel,
5
5
  id: string,
6
6
  open?: boolean,
7
7
  title: string
@@ -9,7 +9,7 @@ declare namespace SGDS.Component {
9
9
  }
10
10
 
11
11
  interface Accordion extends React.AllHTMLAttributes<HTMLElement> {
12
- headerLevel?: SGDS.HeaderLevel,
12
+ headingLevel?: SGDS.HeadingLevel,
13
13
  hideOpenAll?: boolean
14
14
  }
15
15
  }
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  interface ConfirmationMessage extends React.AllHTMLAttributes<HTMLElement> {
3
3
  ariaLive: AriaLive,
4
- headerLevel: HeaderLevel,
4
+ headingLevel: HeadingLevel,
5
5
  title: string
6
6
  }
7
7
  }
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  interface NotificationPanel extends React.AllHTMLAttributes<HTMLDivElement> {
3
3
  ariaLive?: AriaLive,
4
- headerLevel?: HeaderLevel,
4
+ headingLevel?: HeadingLevel,
5
5
  title: string
6
6
  }
7
7
  }
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  interface SummaryCard extends React.AllHTMLAttributes<HTMLElement> {
3
3
  actions?: SummaryList.Action[],
4
- headerLevel?: SGDS.HeaderLevel,
4
+ headingLevel?: SGDS.HeadingLevel,
5
5
  items: SummaryList.Item[],
6
6
  title: string
7
7
  }
@@ -15,7 +15,7 @@ declare namespace SGDS.Component {
15
15
  interface Tabs extends React.AllHTMLAttributes<HTMLElement> {
16
16
  baseId: string,
17
17
  bordered?: boolean,
18
- headerLevel?: SGDS.HeaderLevel,
18
+ headingLevel?: SGDS.HeadingLevel,
19
19
  manual?: boolean,
20
20
  title: string
21
21
  }
package/@types/sgds.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare namespace SGDS {
2
2
  type AriaLive = 'polite' | 'assertive';
3
- type HeaderLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
3
+ type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
4
  type IconName = 'ArrowUpward' | 'CalendarToday' | 'Cancel' | 'CheckCircle' | 'ChevronLeft' | 'ChevronRight' | 'Close' | 'Description' | 'DoubleChevronLeft' | 'DoubleChevronRight' | 'Error' | 'ExpandLess' | 'ExpandMore' | 'List' | 'Menu' | 'PriorityHigh' | 'Search';
5
5
  type DocumentIconName = 'Audio' | 'Csv' | 'Excel' | 'File' | 'Generic' | 'Geodata' | 'Ical' | 'Ico' | 'Image' | 'Odf' | 'Odg' | 'Odp' | 'Ods' | 'Odt' | 'Pdf' | 'Ppt' | 'Rtf' | 'Text' | 'Video' | 'Word' | 'Xml' | 'Zip';
6
6
  type InputWidth = 'fixed-20' | 'fixed-10' | 'fixed-5' | 'fixed-4' | 'fixed-3' | 'fixed-2' | 'fluid-three-quarters' | 'fluid-two-thirds' | 'fluid-half' | 'fluid-one-third' | 'fluid-one-quarter';
package/CHANGELOG.md ADDED
@@ -0,0 +1,81 @@
1
+ # Change log
2
+
3
+ All notable changes to the Scottish Government "Design System React" repository/package will be documented in this file.
4
+
5
+ Changes are grouped under the labels: `Added`, `Changed`, `Deprecated`, `Fixed`,
6
+ `Removed` and `Security`.
7
+
8
+ ---
9
+
10
+ ## [0.7.0]
11
+ ### Changed
12
+ - Change all component file names to Pascal case
13
+ - Use uppercase text for const variable names
14
+ - Nomenclature: prefer 'heading' over 'header' in variable names when referring to HTML headings (H1-H6)
15
+
16
+ ## [0.6.0] - 2025-07-29
17
+ ### Added
18
+ - Add 'File download' component
19
+ - Add 'File icon' component
20
+ ### Changed
21
+ - Reorganise SVG icon components into subfolders
22
+
23
+ ## [0.5.1] - 2025-07-28
24
+ ### Changed
25
+ - 'DisplayName' property of some compound components updated (Metadata.Item, TaskList.Item, TaskList.Group)
26
+
27
+ ## [0.5.0] - 2025-07-28
28
+ ### Added
29
+ - Add 'Tabs' component
30
+
31
+ ## [0.4.0] - 2025-07-23
32
+ ### Added
33
+ - Add 'Abstract notification banner' component
34
+ - Add 'Cookie banner' component
35
+ - Add 'Table' component
36
+ - Add code of conduct
37
+ ### Changed
38
+ - 'Notification banner' refactored to use AbstractNotificationBanner
39
+ ### Fixed
40
+ - Fixed miscellaneous type warnings in unit tests
41
+
42
+ ## [0.3.0] - 2025-07-15
43
+ ### Added
44
+ - Add 'Site header' component/pattern
45
+ ### Changed
46
+ - SiteNavigation: add useRef, to support mobile navigation
47
+ - DatePicker: add 'dateSelectCallback' prop
48
+
49
+ ## [0.2.0] - 2025-07-07
50
+ ### Added
51
+ - Add 'Error summary' component
52
+
53
+ ## [0.1.7] - 2025-06-27
54
+ ### Added
55
+ - Add 'Summary card' component
56
+ - Add 'Summary list' component
57
+
58
+ ## [0.1.6] - 2025-06-27
59
+ ### Added
60
+ - Add 'Hide this page' component
61
+
62
+ ## [0.1.5] - 2025-06-23
63
+ ### Added
64
+ - Add 'Pagination' component
65
+ ### Changed
66
+ - Icon: refactor to use icon components generated from DS source using SVGR
67
+ - Add 'aria-invalid' to form fields that are in an error state
68
+
69
+ ## [0.1.2] - 2025-06-17
70
+ ### Added
71
+ - Add readme file
72
+
73
+ ## [0.1.1] - 2025-06-13
74
+ ### Changed
75
+ - Allow all components to have additional CSS classes passed to them
76
+
77
+ ## [0.1.0] - 2025-06-13
78
+ ### Added
79
+ - Add npmignore file
80
+ ### Fixed
81
+ - Fix broken content navigation spec
package/README.md CHANGED
@@ -4,6 +4,10 @@ This repository contains a React implementation of the [Scottish Government Desi
4
4
 
5
5
  There is a documentation site showing what is in this implementation and how to use it here: https://designsystem-react.vercel.app/
6
6
 
7
+ ## 🚧 Under construction 🚧
8
+
9
+ Warning: This project is in an alpha state and could potentially receive large breaking changes with little warning while it is being developed.
10
+
7
11
  ## Feedback, help or support
8
12
 
9
13
  If you need any help or want to give any feedback you can e-mail the Design System team at: [designsystem@gov.scot](mailto:designsystem@gov.scot).
@@ -0,0 +1,63 @@
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
+ const Icon_1 = __importDefault(require("./Icon"));
8
+ const ScreenReaderText_1 = __importDefault(require("./ScreenReaderText"));
9
+ const Buttons = ({ children }) => {
10
+ return (<>{children}</>);
11
+ };
12
+ const AbstractNotificationBanner = ({ children, className, close, icon, iconColour, iconInverse, title = 'Information', ...props }) => {
13
+ let content = [];
14
+ let buttons;
15
+ react_1.Children.forEach(children, (child) => {
16
+ if ((0, react_1.isValidElement)(child) && child.type === Buttons) {
17
+ buttons = child;
18
+ }
19
+ else {
20
+ content.push(child);
21
+ }
22
+ });
23
+ return (<div className={[
24
+ 'ds_notification',
25
+ className
26
+ ].join(' ')} data-module="ds-notification" {...props}>
27
+ <div className="ds_wrapper">
28
+ <div className={[
29
+ 'ds_notification__content',
30
+ close && 'ds_notification__content--has-close'
31
+ ].join(' ')}>
32
+ <h2 className="visually-hidden">{title}</h2>
33
+
34
+ {icon &&
35
+ <span className={[
36
+ 'ds_notification__icon',
37
+ iconInverse && 'ds_notification__icon--inverse',
38
+ iconColour && 'ds_notification__icon--colour'
39
+ ].join(' ')} aria-hidden="true">
40
+ <Icon_1.default icon={icon}/>
41
+ </span>}
42
+
43
+ <div className="ds_notification__text">
44
+ {content}
45
+ </div>
46
+
47
+ {close &&
48
+ <button type="button" className="ds_notification__close js-close-notification">
49
+ <ScreenReaderText_1.default>Close this notification</ScreenReaderText_1.default>
50
+ <Icon_1.default fill icon="Close" aria-hidden="true"/>
51
+ </button>}
52
+
53
+ {buttons &&
54
+ <div className="ds_button-group">
55
+ {buttons}
56
+ </div>}
57
+ </div>
58
+ </div>
59
+ </div>);
60
+ };
61
+ AbstractNotificationBanner.displayName = 'AbstractNotificationBanner';
62
+ AbstractNotificationBanner.Buttons = Buttons;
63
+ exports.default = AbstractNotificationBanner;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Wraps all children in a specified HTML tag if a condition is met.
5
+ */
6
+ const ConditionalWrapper = ({ condition, wrapper, children }) => condition ? wrapper(children) : children;
7
+ ConditionalWrapper.displayName = 'ConditionalWrapper';
8
+ exports.default = ConditionalWrapper;
@@ -0,0 +1,51 @@
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 = __importDefault(require("react"));
40
+ const FileIcons = __importStar(require("../images/documents"));
41
+ const FileIcon = ({ ariaLabel = '', className, icon }) => {
42
+ const Component = react_1.default.createElement(FileIcons[icon], {
43
+ className: className,
44
+ 'aria-label': ariaLabel
45
+ });
46
+ return (<>
47
+ {Component}
48
+ </>);
49
+ };
50
+ FileIcon.displayName = 'FileIcon';
51
+ exports.default = FileIcon;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const HintText = ({ children, id, text, ...props }) => {
4
+ return (<p className="ds_hint-text" dangerouslySetInnerHTML={text ? { __html: text } : undefined} id={id} {...props}>
5
+ {!text ? children : null}
6
+ </p>);
7
+ };
8
+ HintText.displayName = 'HintText';
9
+ exports.default = HintText;
@@ -0,0 +1,57 @@
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 = __importDefault(require("react"));
40
+ const Icons = __importStar(require("../images/icons"));
41
+ const Icon = ({ ariaLabel, className, fill, icon, iconSize }) => {
42
+ const Component = react_1.default.createElement(Icons[icon], {
43
+ 'aria-hidden': ariaLabel ? undefined : true,
44
+ 'aria-label': ariaLabel,
45
+ className: [
46
+ 'ds_icon',
47
+ className,
48
+ fill && 'ds_icon--fill',
49
+ iconSize && `ds_icon--${iconSize}`
50
+ ].join(' ')
51
+ });
52
+ return (<>
53
+ {Component}
54
+ </>);
55
+ };
56
+ Icon.displayName = 'Icon';
57
+ exports.default = Icon;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ScreenReaderText = ({ children, ...props }) => {
4
+ return (<span className="visually-hidden" {...props}>
5
+ {children}
6
+ </span>);
7
+ };
8
+ ScreenReaderText.displayName = 'ScreenReaderText';
9
+ exports.default = ScreenReaderText;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Wraps all children in a specified HTML tag.
5
+ */
6
+ const WrapperTag = ({ children, tagName = 'div', ...props }) => {
7
+ const TagName = tagName;
8
+ return <TagName {...props}>{children}</TagName>;
9
+ };
10
+ WrapperTag.displayName = 'WrapperTag';
11
+ exports.default = WrapperTag;
@@ -0,0 +1,102 @@
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 accordion_1 = __importDefault(require("@scottish-government/design-system/src/components/accordion/accordion"));
43
+ let accordionItemCounter = 0;
44
+ const AccordionItem = ({ children, className, headingLevel = 'h3', id: rawId, open = false, title, ...props }) => {
45
+ accordionItemCounter = accordionItemCounter + 1;
46
+ const processedId = rawId || `accordion-item-${accordionItemCounter}`;
47
+ return (<div className={[
48
+ 'ds_accordion-item',
49
+ className
50
+ ].join(' ')} id={processedId} {...props}>
51
+ <input aria-labelledby={`panel-${processedId}-heading`} className={[
52
+ 'ds_accordion-item__control',
53
+ 'visually-hidden'
54
+ ].join(' ')} defaultChecked={open} id={`${processedId}-control`} type="checkbox"/>
55
+ <div className="ds_accordion-item__header">
56
+ <WrapperTag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headingLevel}>
57
+ {title}
58
+ </WrapperTag_1.default>
59
+ <span className='ds_accordion-item__indicator'/>
60
+ <label className="ds_accordion-item__label" htmlFor={`${processedId}-control`}>
61
+ <span className="visually-hidden">Show this section</span>
62
+ </label>
63
+ </div>
64
+ <div className="ds_accordion-item__body">
65
+ {children}
66
+ </div>
67
+ </div>);
68
+ };
69
+ const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...props }) => {
70
+ const ref = (0, react_1.useRef)(null);
71
+ (0, react_1.useEffect)(() => {
72
+ if (ref.current) {
73
+ new accordion_1.default(ref.current).init();
74
+ }
75
+ }, [ref]);
76
+ if (!children) {
77
+ hideOpenAll = true;
78
+ }
79
+ function processChild(child) {
80
+ return react_1.default.cloneElement(child, { headingLevel: headingLevel });
81
+ }
82
+ return (<div className={[
83
+ 'ds_accordion',
84
+ className
85
+ ].join(' ')} ref={ref} {...props}>
86
+ {!hideOpenAll && (<button className={[
87
+ 'ds_accordion__open-all',
88
+ 'ds_link',
89
+ 'js-open-all'
90
+ ].join(' ')} type='button'>
91
+ Open all
92
+ {' '}
93
+ <span className="visually-hidden">sections</span>
94
+ </button>)}
95
+
96
+ {react_1.Children.map(children, child => processChild(child))}
97
+ </div>);
98
+ };
99
+ Accordion.displayName = 'Accordion';
100
+ AccordionItem.displayName = 'AccordionItem';
101
+ Accordion.Item = AccordionItem;
102
+ exports.default = Accordion;
@@ -0,0 +1,79 @@
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
+ // @ts-ignore
41
+ const aspect_box_fallback_1 = __importDefault(require("@scottish-government/design-system/src/components/aspect-box/aspect-box-fallback"));
42
+ const AspectBox = ({ children, className, ratio, ...props }) => {
43
+ const ref = (0, react_1.useRef)(null);
44
+ (0, react_1.useEffect)(() => {
45
+ if (ref.current) {
46
+ new aspect_box_fallback_1.default(ref.current).init();
47
+ }
48
+ }, [ref]);
49
+ function processChild(child) {
50
+ if (['img', 'svg', 'picture'].includes(child.type)) {
51
+ return react_1.default.cloneElement(child, { className: 'ds_aspect-box__inner' });
52
+ }
53
+ }
54
+ let ratioClassName;
55
+ switch (ratio) {
56
+ case '1:1':
57
+ case 'square':
58
+ ratioClassName = 'ds_aspect-box--square';
59
+ break;
60
+ case '4:3':
61
+ ratioClassName = 'ds_aspect-box--43';
62
+ break;
63
+ case '21:9':
64
+ ratioClassName = 'ds_aspect-box--219';
65
+ break;
66
+ default:
67
+ ratioClassName = '';
68
+ break;
69
+ }
70
+ return (<div className={[
71
+ 'ds_aspect-box',
72
+ ratioClassName,
73
+ className
74
+ ].join(' ')} ref={ref} {...props}>
75
+ {react_1.Children.map(children, child => processChild(child))}
76
+ </div>);
77
+ };
78
+ AspectBox.displayName = 'AspectBox';
79
+ exports.default = AspectBox;
@@ -0,0 +1,27 @@
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
+ const Icon_1 = __importDefault(require("../../common/Icon"));
8
+ // @ts-ignore
9
+ const back_to_top_1 = __importDefault(require("@scottish-government/design-system/src/components/back-to-top/back-to-top"));
10
+ const BackToTop = ({ className, href = '#page-top', ...props }) => {
11
+ const ref = (0, react_1.useRef)(null);
12
+ (0, react_1.useEffect)(() => {
13
+ if (ref.current) {
14
+ new back_to_top_1.default(ref.current).init();
15
+ }
16
+ }, [ref]);
17
+ return (<div className={[
18
+ 'ds_back-to-top',
19
+ className
20
+ ].join(' ')} ref={ref} {...props}>
21
+ <a href={href} className="ds_back-to-top__button">Back to top
22
+ <Icon_1.default className="ds_back-to-top__icon" icon="ArrowUpward"/>
23
+ </a>
24
+ </div>);
25
+ };
26
+ BackToTop.displayName = 'BackToTop';
27
+ exports.default = BackToTop;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Breadcrumb = ({ hidden, href, title }) => {
4
+ return (<li className={[
5
+ 'ds_breadcrumbs__item',
6
+ hidden && 'visually-hidden'
7
+ ].join(' ')}>
8
+
9
+ {href ? (<a className="ds_breadcrumbs__link" href={href}>
10
+ {title}
11
+ </a>) : (title)}
12
+ </li>);
13
+ };
14
+ /**
15
+ * @param {boolean} hideLastItem
16
+ * @param {Array} items
17
+ * @param {Object} props - Properties for the element
18
+ * @returns {JSX.Element} - The element
19
+ */
20
+ const Breadcrumbs = ({ hideLastItem, items, ...props }) => {
21
+ return (<nav aria-label="Breadcrumb" {...props}>
22
+ <ol className="ds_breadcrumbs">
23
+ {items && items.map((item, index) => (<Breadcrumb title={item.title} href={item.href} hidden={(hideLastItem) && index + 1 === items.length} key={'breadcrumb' + index}/>))}
24
+ </ol>
25
+ </nav>);
26
+ };
27
+ Breadcrumbs.displayName = 'Breadcrumbs';
28
+ exports.default = Breadcrumbs;
@@ -0,0 +1,30 @@
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 Icon_1 = __importDefault(require("../../common/Icon"));
7
+ const ScreenReaderText_1 = __importDefault(require("../../common/ScreenReaderText"));
8
+ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
9
+ const Button = ({ buttonStyle, children, className, icon, iconLeft, iconOnly = false, href, small, styleAsLink, type = 'button', width, ...props }) => {
10
+ // determine which HTML tag to use
11
+ let tagName = 'button';
12
+ if (href) {
13
+ tagName = 'a';
14
+ }
15
+ return (<WrapperTag_1.default tagName={tagName} className={[
16
+ !styleAsLink ? 'ds_button' : 'ds_link',
17
+ width && `ds_button--${width}`,
18
+ buttonStyle && `ds_button--${buttonStyle}`,
19
+ small && 'ds_button--small',
20
+ (icon && !iconOnly) ? 'ds_button--has-icon' : undefined,
21
+ iconLeft && 'ds_button--has-icon--left',
22
+ className
23
+ ].join(' ')} href={href} {...(tagName === 'button' ? { type: type } : {})} {...props}>
24
+ {iconOnly ? <ScreenReaderText_1.default>{children}</ScreenReaderText_1.default> : children}
25
+
26
+ {icon && <Icon_1.default icon={icon}/>}
27
+ </WrapperTag_1.default>);
28
+ };
29
+ Button.displayName = 'Button';
30
+ exports.default = Button;