@scottish-government/designsystem-react 0.1.0 → 0.1.2

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 (90) hide show
  1. package/@types/components/InsetText.d.ts +5 -0
  2. package/@types/components/WarningText.d.ts +5 -0
  3. package/README.md +26 -0
  4. package/dist/components/accordion/accordion.jsx +10 -4
  5. package/dist/components/aspect-box/aspect-box.jsx +3 -2
  6. package/dist/components/back-to-top/back-to-top.jsx +5 -2
  7. package/dist/components/breadcrumbs/breadcrumbs.jsx +2 -2
  8. package/dist/components/button/button.jsx +3 -2
  9. package/dist/components/checkbox/checkbox.jsx +6 -2
  10. package/dist/components/confirmation-message/confirmation-message.jsx +5 -2
  11. package/dist/components/contents-nav/contents-nav.jsx +6 -3
  12. package/dist/components/date-picker/date-picker.jsx +3 -2
  13. package/dist/components/details/details.jsx +2 -1
  14. package/dist/components/error-message/error-message.jsx +2 -1
  15. package/dist/components/inset-text/inset-text.jsx +5 -2
  16. package/dist/components/notification-banner/notification-banner.jsx +6 -2
  17. package/dist/components/notification-panel/notification-panel.jsx +5 -2
  18. package/dist/components/page-header/page-header.jsx +5 -2
  19. package/dist/components/page-metadata/page-metadata.jsx +7 -3
  20. package/dist/components/phase-banner/phase-banner.jsx +5 -2
  21. package/dist/components/question/question.jsx +3 -2
  22. package/dist/components/radio-button/radio-button.jsx +3 -2
  23. package/dist/components/select/select.jsx +2 -1
  24. package/dist/components/sequential-navigation/sequential-navigation.jsx +5 -2
  25. package/dist/components/side-navigation/side-navigation.jsx +5 -2
  26. package/dist/components/site-navigation/site-navigation.jsx +5 -2
  27. package/dist/components/site-search/site-search.jsx +3 -2
  28. package/dist/components/task-list/task-list.jsx +13 -7
  29. package/dist/components/textarea/textarea.jsx +2 -1
  30. package/dist/components/warning-text/warning-text.jsx +5 -2
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +1 -1
  33. package/src/common/icon.test.tsx +1 -1
  34. package/src/components/accordion/accordion.test.tsx +25 -1
  35. package/src/components/accordion/accordion.tsx +10 -2
  36. package/src/components/aspect-box/aspect-box.test.tsx +12 -0
  37. package/src/components/aspect-box/aspect-box.tsx +3 -1
  38. package/src/components/back-to-top/back-to-top.test.tsx +10 -0
  39. package/src/components/back-to-top/back-to-top.tsx +5 -1
  40. package/src/components/breadcrumbs/breadcrumbs.test.tsx +12 -0
  41. package/src/components/breadcrumbs/breadcrumbs.tsx +2 -0
  42. package/src/components/button/button.test.tsx +9 -0
  43. package/src/components/button/button.tsx +4 -2
  44. package/src/components/checkbox/checkbox.test.tsx +13 -0
  45. package/src/components/checkbox/checkbox.tsx +6 -1
  46. package/src/components/confirmation-message/confirmation-message.test.tsx +22 -0
  47. package/src/components/confirmation-message/confirmation-message.tsx +8 -2
  48. package/src/components/contents-nav/contents-nav.test.tsx +13 -0
  49. package/src/components/contents-nav/contents-nav.tsx +8 -4
  50. package/src/components/date-picker/date-picker.test.tsx +13 -0
  51. package/src/components/date-picker/date-picker.tsx +4 -2
  52. package/src/components/details/details.test.tsx +12 -0
  53. package/src/components/details/details.tsx +2 -0
  54. package/src/components/error-message/error-message.test.tsx +9 -0
  55. package/src/components/error-message/error-message.tsx +2 -0
  56. package/src/components/inset-text/inset-text.test.tsx +11 -0
  57. package/src/components/inset-text/inset-text.tsx +6 -2
  58. package/src/components/notification-banner/notification-banner.test.tsx +11 -0
  59. package/src/components/notification-banner/notification-banner.tsx +6 -1
  60. package/src/components/notification-panel/notification-panel.test.tsx +12 -0
  61. package/src/components/notification-panel/notification-panel.tsx +5 -1
  62. package/src/components/page-header/page-header.test.tsx +9 -0
  63. package/src/components/page-header/page-header.tsx +5 -1
  64. package/src/components/page-metadata/page-metadata.test.tsx +15 -0
  65. package/src/components/page-metadata/page-metadata.tsx +7 -1
  66. package/src/components/phase-banner/phase-banner.test.tsx +11 -0
  67. package/src/components/phase-banner/phase-banner.tsx +5 -1
  68. package/src/components/question/question.test.tsx +10 -0
  69. package/src/components/question/question.tsx +3 -1
  70. package/src/components/radio-button/radio-button.test.tsx +13 -0
  71. package/src/components/radio-button/radio-button.tsx +3 -1
  72. package/src/components/select/select.test.tsx +15 -0
  73. package/src/components/select/select.tsx +2 -0
  74. package/src/components/sequential-navigation/sequential-navigation.test.tsx +13 -0
  75. package/src/components/sequential-navigation/sequential-navigation.tsx +5 -1
  76. package/src/components/side-navigation/side-navigation.test.tsx +18 -0
  77. package/src/components/side-navigation/side-navigation.tsx +5 -1
  78. package/src/components/site-navigation/site-navigation.test.tsx +9 -0
  79. package/src/components/site-navigation/site-navigation.tsx +5 -1
  80. package/src/components/site-search/site-search.test.tsx +10 -0
  81. package/src/components/site-search/site-search.tsx +3 -1
  82. package/src/components/tag/tag.test.tsx +7 -7
  83. package/src/components/task-list/task-list.test.tsx +46 -0
  84. package/src/components/task-list/task-list.tsx +18 -5
  85. package/src/components/text-input/text-input.test.tsx +13 -0
  86. package/src/components/textarea/textarea.test.tsx +13 -0
  87. package/src/components/textarea/textarea.tsx +2 -0
  88. package/src/components/warning-text/warning-text.test.tsx +11 -0
  89. package/src/components/warning-text/warning-text.tsx +6 -2
  90. package/.editorconfig +0 -12
@@ -0,0 +1,5 @@
1
+ declare namespace SGDS.Component {
2
+ interface InsetText extends React.AllHTMLAttributes<HTMLElement> {
3
+
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ declare namespace SGDS.Component {
2
+ interface WarningText extends React.AllHTMLAttributes<HTMLElement> {
3
+
4
+ }
5
+ }
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @scottish-government/designsystem-react
2
+
3
+ This repository contains a React implementation of the [Scottish Government Design System](https://designsystem.gov.scot/).
4
+
5
+ There is a documentation site showing what is in this implementation and how to use it here: https://designsystem-react.vercel.app/
6
+
7
+ ## Feedback, help or support
8
+
9
+ 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).
10
+
11
+ ## Installation
12
+
13
+ We recommend installing the package using npm. The npm package includes the SG Design System as a dependency.
14
+
15
+ `npm install @scottish-government/designsystem-react`
16
+
17
+ ## Run tasks
18
+
19
+ `npm run tsc`
20
+ Compile the source code from TypeScript/TSX into JavaScript/JSX files, located in `/dist`
21
+
22
+ `npm run test`
23
+ Run unit tests
24
+
25
+ `npm run coverage`
26
+ Run unit tests and output a coverage report, located in `/coverage`
@@ -42,10 +42,13 @@ const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
42
42
  // @ts-ignore
43
43
  const accordion_1 = __importDefault(require("@scottish-government/design-system/src/components/accordion/accordion"));
44
44
  let accordionItemCounter = 0;
45
- const AccordionItem = ({ children, headerLevel = 'h3', id: rawId, open = false, title, ...props }) => {
45
+ const AccordionItem = ({ children, className, headerLevel = 'h3', id: rawId, open = false, title, ...props }) => {
46
46
  accordionItemCounter = accordionItemCounter + 1;
47
47
  const processedId = rawId || `accordion-item-${accordionItemCounter}`;
48
- return (<div className="ds_accordion-item" id={processedId} {...props}>
48
+ return (<div className={[
49
+ 'ds_accordion-item',
50
+ className
51
+ ].join(' ')} id={processedId} {...props}>
49
52
  <input aria-labelledby={`panel-${processedId}-heading`} className={[
50
53
  'ds_accordion-item__control',
51
54
  'visually-hidden'
@@ -65,7 +68,7 @@ const AccordionItem = ({ children, headerLevel = 'h3', id: rawId, open = false,
65
68
  </div>);
66
69
  };
67
70
  exports.AccordionItem = AccordionItem;
68
- const Accordion = ({ children, headerLevel = 'h3', hideOpenAll, ...props }) => {
71
+ const Accordion = ({ children, className, headerLevel = 'h3', hideOpenAll, ...props }) => {
69
72
  const ref = (0, react_1.useRef)(null);
70
73
  (0, react_1.useEffect)(() => {
71
74
  if (ref.current) {
@@ -78,7 +81,10 @@ const Accordion = ({ children, headerLevel = 'h3', hideOpenAll, ...props }) => {
78
81
  function processChild(child) {
79
82
  return react_1.default.cloneElement(child, { headerLevel: headerLevel });
80
83
  }
81
- return (<div className='ds_accordion' ref={ref} {...props}>
84
+ return (<div className={[
85
+ 'ds_accordion',
86
+ className
87
+ ].join(' ')} ref={ref} {...props}>
82
88
  {!hideOpenAll && (<button className={[
83
89
  'ds_accordion__open-all',
84
90
  'ds_link',
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const react_1 = __importStar(require("react"));
40
40
  // @ts-ignore
41
41
  const aspect_box_fallback_1 = __importDefault(require("@scottish-government/design-system/src/components/aspect-box/aspect-box-fallback"));
42
- const AspectBox = ({ children, ratio, ...props }) => {
42
+ const AspectBox = ({ children, className, ratio, ...props }) => {
43
43
  const ref = (0, react_1.useRef)(null);
44
44
  (0, react_1.useEffect)(() => {
45
45
  if (ref.current) {
@@ -69,7 +69,8 @@ const AspectBox = ({ children, ratio, ...props }) => {
69
69
  }
70
70
  return (<div className={[
71
71
  'ds_aspect-box',
72
- `${ratioClassName}`
72
+ ratioClassName,
73
+ className
73
74
  ].join(' ')} ref={ref} {...props}>
74
75
  {react_1.Children.map(children, child => processChild(child))}
75
76
  </div>);
@@ -7,14 +7,17 @@ const react_1 = require("react");
7
7
  // @ts-ignore
8
8
  const back_to_top_1 = __importDefault(require("@scottish-government/design-system/src/components/back-to-top/back-to-top"));
9
9
  const icon_1 = __importDefault(require("../../common/icon"));
10
- const BackToTop = ({ href = '#page-top', ...props }) => {
10
+ const BackToTop = ({ className, href = '#page-top', ...props }) => {
11
11
  const ref = (0, react_1.useRef)(null);
12
12
  (0, react_1.useEffect)(() => {
13
13
  if (ref.current) {
14
14
  new back_to_top_1.default(ref.current).init();
15
15
  }
16
16
  }, [ref]);
17
- return (<div className='ds_back-to-top' ref={ref} {...props}>
17
+ return (<div className={[
18
+ 'ds_back-to-top',
19
+ className
20
+ ].join(' ')} ref={ref} {...props}>
18
21
  <a href={href} className="ds_back-to-top__button">Back to top
19
22
  <icon_1.default className="ds_back-to-top__icon" icon="arrow_upward"/>
20
23
  </a>
@@ -17,8 +17,8 @@ const Breadcrumb = ({ hidden, href, title }) => {
17
17
  * @param {Object} props - Properties for the element
18
18
  * @returns {JSX.Element} - The element
19
19
  */
20
- const Breadcrumbs = ({ hideLastItem, items, ...props }) => {
21
- return (<nav aria-label="Breadcrumb" {...props}>
20
+ const Breadcrumbs = ({ className, hideLastItem, items, ...props }) => {
21
+ return (<nav aria-label="Breadcrumb" className={className} {...props}>
22
22
  <ol className="ds_breadcrumbs">
23
23
  {items && items.map((item, index) => (<Breadcrumb title={item.title} href={item.href} hidden={(hideLastItem) && index + 1 === items.length} key={'breadcrumb' + index}/>))}
24
24
  </ol>
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const icon_1 = __importDefault(require("../../common/icon"));
7
7
  const screen_reader_text_1 = __importDefault(require("../../common/screen-reader-text"));
8
8
  const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
9
- const Button = ({ children, buttonStyle, icon, iconLeft, iconOnly = false, href, small, styleAsLink, type = 'button', width, ...props }) => {
9
+ const Button = ({ buttonStyle, children, className, icon, iconLeft, iconOnly = false, href, small, styleAsLink, type = 'button', width, ...props }) => {
10
10
  // determine which HTML tag to use
11
11
  let tagName = 'button';
12
12
  if (href) {
@@ -18,7 +18,8 @@ const Button = ({ children, buttonStyle, icon, iconLeft, iconOnly = false, href,
18
18
  buttonStyle && `ds_button--${buttonStyle}`,
19
19
  small && 'ds_button--small',
20
20
  (icon && !iconOnly) ? 'ds_button--has-icon' : undefined,
21
- iconLeft && 'ds_button--has-icon--left'
21
+ iconLeft && 'ds_button--has-icon--left',
22
+ className
22
23
  ].join(' ')} href={href} {...(tagName === 'button' ? { type: type } : {})} {...props}>
23
24
  {iconOnly ? <screen_reader_text_1.default>{children}</screen_reader_text_1.default> : children}
24
25
 
@@ -41,14 +41,18 @@ exports.Checkbox = Checkbox;
41
41
  * @param {boolean} small - Use the small display style for all checkboxes
42
42
  * @returns {JSX.Element} - The element
43
43
  */
44
- const CheckboxGroup = ({ items, small, ...props }) => {
44
+ const CheckboxGroup = ({ className, items, small, ...props }) => {
45
45
  const ref = (0, react_1.useRef)(null);
46
46
  (0, react_1.useEffect)(() => {
47
47
  if (ref.current) {
48
48
  new checkboxes_1.default(ref.current).init();
49
49
  }
50
50
  }, [ref]);
51
- return (<div className="ds_checkboxes ds_field-group" data-module="ds-checkboxes" ref={ref} {...props}>
51
+ return (<div className={[
52
+ 'ds_checkboxes',
53
+ 'ds_field-group',
54
+ className
55
+ ].join(' ')} data-module="ds-checkboxes" ref={ref} {...props}>
52
56
  {items && items.map((item, index) => (<exports.Checkbox exclusive={item.exclusive} checked={item.checked} hintText={item.hintText} id={item.id} key={'checkbox' + index} label={item.label} onBlur={item.onBlur} onChange={item.onChange} small={small || item.small}/>))}
53
57
  </div>);
54
58
  };
@@ -5,8 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const icon_1 = __importDefault(require("../../common/icon"));
7
7
  const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
8
- const ConfirmationMessage = ({ ariaLive = 'polite', children, headerLevel = 'h3', title }) => {
9
- return (<div aria-live={ariaLive} className="ds_confirmation-message">
8
+ const ConfirmationMessage = ({ ariaLive = 'polite', children, className, headerLevel = 'h3', title, ...props }) => {
9
+ return (<div aria-live={ariaLive} className={[
10
+ 'ds_confirmation-message',
11
+ className
12
+ ].join(' ')} {...props}>
10
13
  <icon_1.default className="ds_confirmation-message__icon" icon="check_circle" iconSize="24"/>
11
14
 
12
15
  <wrapper_tag_1.default className="ds_confirmation-message__title" tagName={headerLevel}>
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Link = void 0;
7
7
  const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
8
- const Link = ({ title, current, href }) => {
8
+ const Link = ({ current, href, title }) => {
9
9
  // determine which HTML tag to use
10
10
  const tagName = href && !current ? 'a' : 'span';
11
11
  return (<li aria-current={current && 'page' || undefined} className="ds_contents-nav__item">
@@ -18,8 +18,11 @@ const Link = ({ title, current, href }) => {
18
18
  </li>);
19
19
  };
20
20
  exports.Link = Link;
21
- const ContentsNav = function ({ items, label = 'Pages in this section', title = 'Contents', ...props }) {
22
- return (<nav aria-label={label} className="ds_contents-nav" {...props}>
21
+ const ContentsNav = function ({ className, items, label = 'Pages in this section', title = 'Contents', ...props }) {
22
+ return (<nav aria-label={label} className={[
23
+ 'ds_contents-nav',
24
+ className
25
+ ].join(' ')} {...props}>
23
26
  <h2 className="ds_contents-nav__title">{title}</h2>
24
27
  <ul className="ds_contents-nav__list">
25
28
  {items && items.map((item, index) => (<exports.Link current={item.current} href={item.href} title={item.title} key={'link' + index}/>))}
@@ -7,7 +7,7 @@ const react_1 = require("react");
7
7
  // @ts-ignore
8
8
  const date_picker_1 = __importDefault(require("@scottish-government/design-system/src/components/date-picker/date-picker"));
9
9
  const text_input_1 = __importDefault(require("../text-input/text-input"));
10
- const DatePicker = ({ width = 'fixed-10', disabledDates, error, errorMessage, hintText, id, iconPath = './', label, maxDate, minDate, multiple, name, onBlur, onChange, value, ...props }) => {
10
+ const DatePicker = ({ className, disabledDates, error, errorMessage, hintText, id, iconPath = './', label, maxDate, minDate, multiple, name, onBlur, onChange, value, width = 'fixed-10', ...props }) => {
11
11
  // todo: dateSelectCallback function
12
12
  const ref = (0, react_1.useRef)(null);
13
13
  (0, react_1.useEffect)(() => {
@@ -27,7 +27,8 @@ const DatePicker = ({ width = 'fixed-10', disabledDates, error, errorMessage, hi
27
27
  }
28
28
  return (<div className={[
29
29
  "ds_datepicker",
30
- multiple && "ds_datepicker--multiple"
30
+ multiple && "ds_datepicker--multiple",
31
+ className
31
32
  ].join(' ')} data-disableddates={disabledDates} data-maxdate={maxDate} data-mindate={minDate} data-module="ds-datepicker" ref={ref} {...props}>
32
33
  {(multiple ? (<fieldset className="ds_datepicker__input-wrapper">
33
34
  <legend>{label}</legend>
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Details = ({ children, summary, ...props }) => {
3
+ const Details = ({ children, className, summary, ...props }) => {
4
4
  return (<details className={[
5
5
  "ds_details",
6
+ className
6
7
  ].join(' ')} {...props}>
7
8
  <summary className="ds_details__summary">
8
9
  {summary}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const ErrorMessage = ({ children, id, text, ...props }) => {
3
+ const ErrorMessage = ({ children, className, id, text, ...props }) => {
4
4
  return (<p className={[
5
5
  'ds_question__error-message',
6
+ className
6
7
  ].join(' ')} dangerouslySetInnerHTML={text ? { __html: text } : undefined} id={id} {...props}>
7
8
  {!text ? children : null}
8
9
  </p>);
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const InsetText = ({ children, ...props }) => {
4
- return (<div className="ds_inset-text" {...props}>
3
+ const InsetText = ({ children, className, ...props }) => {
4
+ return (<div className={[
5
+ 'ds_inset-text',
6
+ className
7
+ ].join(' ')} {...props}>
5
8
  <div className="ds_inset-text__text">
6
9
  {children}
7
10
  </div>
@@ -9,14 +9,18 @@ const notification_banner_1 = __importDefault(require("@scottish-government/desi
9
9
  const button_1 = __importDefault(require("../button/button"));
10
10
  const icon_1 = __importDefault(require("../../common/icon"));
11
11
  const screen_reader_text_1 = __importDefault(require("../../common/screen-reader-text"));
12
- const NotificationBanner = ({ children, close, icon, iconColour, iconInverse, title = 'Information', ...props }) => {
12
+ const NotificationBanner = ({ children, className, close, icon, iconColour, iconInverse, title = 'Information', ...props }) => {
13
13
  const ref = (0, react_1.useRef)(null);
14
14
  (0, react_1.useEffect)(() => {
15
15
  if (ref.current) {
16
16
  new notification_banner_1.default(ref.current).init();
17
17
  }
18
18
  }, [ref]);
19
- return (<div className="ds_notification ds_reversed" data-module="ds-notification" ref={ref} {...props}>
19
+ return (<div className={[
20
+ 'ds_notification',
21
+ 'ds_reversed',
22
+ className
23
+ ].join(' ')} data-module="ds-notification" ref={ref} {...props}>
20
24
  <div className="ds_wrapper">
21
25
  <div className={[
22
26
  'ds_notification__content',
@@ -4,8 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
7
- const NotificationPanel = function ({ ariaLive, children, headerLevel = 'h1', title, ...props }) {
8
- return (<div aria-live={ariaLive} className="ds_notification-panel" {...props}>
7
+ const NotificationPanel = function ({ ariaLive, children, className, headerLevel = 'h1', title, ...props }) {
8
+ return (<div aria-live={ariaLive} className={[
9
+ 'ds_notification-panel',
10
+ className
11
+ ].join(' ')} {...props}>
9
12
  <wrapper_tag_1.default className="ds_notification-panel__title" tagName={headerLevel}>
10
13
  {title}
11
14
  </wrapper_tag_1.default>
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const PageHeader = ({ children, label, title, ...props }) => {
4
- return (<header className="ds_page-header" {...props}>
3
+ const PageHeader = ({ children, className, label, title, ...props }) => {
4
+ return (<header className={[
5
+ 'ds_page-header',
6
+ className
7
+ ].join(' ')} {...props}>
5
8
  {label && <span className="ds_page-header__label ds_content-label">{label}</span>}
6
9
  <h1 className="ds_page-header__title">{title}</h1>
7
10
 
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MetadataItem = void 0;
4
- const MetadataItem = ({ children, name, ...props }) => {
5
- return (<div className="ds_metadata__item" {...props}>
4
+ const MetadataItem = ({ children, className, name, ...props }) => {
5
+ return (<div className={[
6
+ 'ds_metadata__item',
7
+ className
8
+ ].join(' ')} {...props}>
6
9
  <dt className="ds_metadata__key">{name}</dt>{' '}
7
10
  <dd className="ds_metadata__value">
8
11
  {children}
@@ -10,10 +13,11 @@ const MetadataItem = ({ children, name, ...props }) => {
10
13
  </div>);
11
14
  };
12
15
  exports.MetadataItem = MetadataItem;
13
- const Metadata = ({ children, inline, ...props }) => {
16
+ const Metadata = ({ children, className, inline, ...props }) => {
14
17
  return (<dl className={[
15
18
  'ds_metadata',
16
19
  inline && 'ds_metadata--inline',
20
+ className
17
21
  ].join(' ')} {...props}>
18
22
  {children}
19
23
  </dl>);
@@ -4,8 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tag_1 = __importDefault(require("../tag/tag"));
7
- const PhaseBanner = ({ children, phaseName, ...props }) => {
8
- return (<div className="ds_phase-banner" {...props}>
7
+ const PhaseBanner = ({ children, className, phaseName, ...props }) => {
8
+ return (<div className={[
9
+ 'ds_phase-banner',
10
+ className
11
+ ].join(' ')} {...props}>
9
12
  <div className="ds_wrapper">
10
13
  <p className="ds_phase-banner__content">
11
14
  {phaseName && <tag_1.default title={phaseName} className="ds_phase-banner__tag"/>}
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const error_message_1 = __importDefault(require("../error-message/error-message"));
7
7
  const hint_text_1 = __importDefault(require("../../common/hint-text"));
8
8
  const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
9
- const Question = function ({ children, error, errorMessage, hintText, legend, tagName = 'div', ...props }) {
9
+ const Question = function ({ children, className, error, errorMessage, hintText, legend, tagName = 'div', ...props }) {
10
10
  return (<wrapper_tag_1.default tagName={tagName} className={[
11
11
  'ds_question',
12
- error && 'ds_question--error'
12
+ error && 'ds_question--error',
13
+ className
13
14
  ].join(' ')} {...props}>
14
15
  {legend && <legend>{legend}</legend>}
15
16
  {hintText && <hint_text_1.default text={hintText}/>}
@@ -27,11 +27,12 @@ const Radio = ({ checked, hintText, id, label, name, onBlur, onChange, small })
27
27
  </div>);
28
28
  };
29
29
  exports.Radio = Radio;
30
- const RadioGroup = ({ inline, items, name, small, ...props }) => {
30
+ const RadioGroup = ({ className, inline, items, name, small, ...props }) => {
31
31
  return (<div className={[
32
32
  'ds_radios',
33
33
  'ds_field-group',
34
- inline && 'ds_field-group--inline'
34
+ inline && 'ds_field-group--inline',
35
+ className
35
36
  ].join(' ')} {...props}>
36
37
 
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}/>))}
@@ -8,7 +8,7 @@ const hint_text_1 = __importDefault(require("../../common/hint-text"));
8
8
  const Option = function ({ text, value }) {
9
9
  return (<option value={value}>{text}</option>);
10
10
  };
11
- const Select = function ({ defaultValue, error, errorMessage, hintText, id, label, name, onBlur, onChange, options, placeholder, width, ...props }) {
11
+ const Select = function ({ className, defaultValue, error, errorMessage, hintText, id, label, name, onBlur, onChange, options, placeholder, width, ...props }) {
12
12
  const errorMessageId = `error-message-${id}`;
13
13
  const hintTextId = `hint-text-${id}`;
14
14
  const describedbys = [];
@@ -38,6 +38,7 @@ const Select = function ({ defaultValue, error, errorMessage, hintText, id, labe
38
38
  "ds_select-wrapper",
39
39
  error && 'ds_input--error',
40
40
  width && `ds_input--${width}`,
41
+ className
41
42
  ].join(' ')} {...props}>
42
43
  <select aria-describedby={describedbys.join(' ')} className="ds_select" defaultValue={defaultValue} id={id} name={name || id} onBlur={handleBlur} onChange={handleChange}>
43
44
  <option value="">{placeholder}</option>
@@ -18,8 +18,11 @@ const PrevLink = ({ href, title, }) => {
18
18
  </a>
19
19
  </div>);
20
20
  };
21
- const SequentialNavigation = ({ ariaLabel = 'Article navigation', next, previous, ...props }) => {
22
- return (<nav className="ds_sequential-nav" aria-label={ariaLabel} {...props}>
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}>
23
26
  {previous && <PrevLink href={previous.href} title={previous.title}></PrevLink>}
24
27
  {next && <NextLink href={next.href} title={next.title}></NextLink>}
25
28
  </nav>);
@@ -26,14 +26,17 @@ const Link = function ({ current = false, href, items, title }) {
26
26
  </li>);
27
27
  };
28
28
  exports.Link = Link;
29
- const SideNavigation = function ({ children, items, ...props }) {
29
+ const SideNavigation = function ({ children, className, items, ...props }) {
30
30
  const ref = (0, react_1.useRef)(null);
31
31
  (0, react_1.useEffect)(() => {
32
32
  if (ref.current) {
33
33
  new side_navigation_1.default(ref.current).init();
34
34
  }
35
35
  }, [ref]);
36
- return (<nav aria-label="Sections" className="ds_side-navigation" data-module="ds-side-navigation" ref={ref} {...props}>
36
+ return (<nav aria-label="Sections" className={[
37
+ 'ds_side-navigation',
38
+ className
39
+ ].join(' ')} data-module="ds-side-navigation" ref={ref} {...props}>
37
40
  <input type="checkbox" className="fully-hidden js-toggle-side-navigation" id="show-side-navigation" aria-controls="side-navigation-root"/>
38
41
  <label className="ds_side-navigation__expand ds_link" htmlFor="show-side-navigation">
39
42
  <span className="visually-hidden">Show all</span> Pages in this section
@@ -8,8 +8,11 @@ const SiteNavLink = ({ current = false, href, title }) => {
8
8
  ].join(' ')}>{title}</a>
9
9
  </li>);
10
10
  };
11
- const SiteNavigation = ({ items, ...props }) => {
12
- return (<nav className="ds_site-navigation" {...props}>
11
+ const SiteNavigation = ({ className, items, ...props }) => {
12
+ return (<nav className={[
13
+ 'ds_site-navigation',
14
+ className
15
+ ].join(' ')} {...props}>
13
16
  <ul className="ds_site-navigation__list">
14
17
  {items && items.map((item, index) => (<SiteNavLink current={item.current} href={item.href} title={item.title} key={`link-${index}`}/>))}
15
18
  </ul>
@@ -7,7 +7,7 @@ const react_1 = require("react");
7
7
  // @ts-ignore
8
8
  const autocomplete_1 = __importDefault(require("@scottish-government/design-system/src/components/autocomplete/autocomplete"));
9
9
  const button_1 = __importDefault(require("../button/button"));
10
- const SiteSearch = function ({ action = '/search', autocompleteEndpoint, autocompleteSuggestionMappingFunction, id = 'site-search', method = 'GET', minLength = 3, name = 'q', placeholder = 'Search', ...props }) {
10
+ const SiteSearch = function ({ action = '/search', autocompleteEndpoint, autocompleteSuggestionMappingFunction, className, id = 'site-search', method = 'GET', minLength = 3, name = 'q', placeholder = 'Search', ...props }) {
11
11
  const ref = (0, react_1.useRef)(null);
12
12
  const hasAutocomplete = !!autocompleteEndpoint;
13
13
  let autocompleteId = hasAutocomplete ? id + '-autocomplete' : '';
@@ -25,7 +25,8 @@ const SiteSearch = function ({ action = '/search', autocompleteEndpoint, autocom
25
25
  }
26
26
  }, [ref, autocompleteEndpoint, autocompleteId, hasAutocomplete, minLength, autocompleteSuggestionMappingFunction]);
27
27
  return (<div className={[
28
- 'ds_site-search',
28
+ 'ds_site-search', ,
29
+ className,
29
30
  hasAutocomplete ? 'ds_autocomplete' : undefined
30
31
  ].join(' ')} id={autocompleteId ? autocompleteId : undefined} ref={ref} {...props}>
31
32
 
@@ -9,11 +9,14 @@ const conditional_wrapper_1 = __importDefault(require("../../common/conditional-
9
9
  const hint_text_1 = __importDefault(require("../../common/hint-text"));
10
10
  const screen_reader_text_1 = __importDefault(require("../../common/screen-reader-text"));
11
11
  const tag_1 = __importDefault(require("../tag/tag"));
12
- const Task = ({ children, href, id, isComplete = false, statusText, tagColour = 'grey', title, ...props }) => {
12
+ const Task = ({ children, className, href, id, isComplete = false, statusText, tagColour = 'grey', title, ...props }) => {
13
13
  if (isComplete) {
14
14
  tagColour = 'green';
15
15
  }
16
- return (<li className="ds_task-list__task" id={id} {...props}>
16
+ return (<li className={[
17
+ 'ds_task-list__task',
18
+ className
19
+ ].join(' ')} id={id} {...props}>
17
20
  <div className="ds_task-list__task-details">
18
21
  <h3 className="ds_task-list__task-heading">
19
22
  <conditional_wrapper_1.default condition={typeof href !== 'undefined'} wrapper={(children) => <a className="ds_task-list__task-link" href={href}>{children}</a>}>
@@ -35,8 +38,11 @@ exports.Task = Task;
35
38
  * @param {string} props.title - The title of the task group
36
39
  * @returns {JSX.Element} - The element
37
40
  */
38
- const TaskGroup = ({ children, intro, title, ...props }) => {
39
- return (<li className="ds_task-list-group__section" {...props}>
41
+ const TaskGroup = ({ children, className, intro, title, ...props }) => {
42
+ return (<li className={[
43
+ 'ds_task-list-group__section',
44
+ className
45
+ ].join(' ')} {...props}>
40
46
  <h2 className="ds_task-list-heading">{title}</h2>
41
47
  {intro && <p className="ds_task-list-intro">{intro}</p>}
42
48
  <ul className="ds_task-list">
@@ -45,7 +51,7 @@ const TaskGroup = ({ children, intro, title, ...props }) => {
45
51
  </li>);
46
52
  };
47
53
  exports.TaskGroup = TaskGroup;
48
- const TaskList = ({ children, headingId = 'task-list', title }) => {
54
+ const TaskList = ({ children, className, headingId = 'task-list', title, ...props }) => {
49
55
  let taskCount = 0;
50
56
  let incompleteTaskIds = [];
51
57
  let completedTasksCount = 0;
@@ -73,7 +79,7 @@ const TaskList = ({ children, headingId = 'task-list', title }) => {
73
79
  react_1.Children.forEach(children, child => {
74
80
  processChild(child);
75
81
  });
76
- return (<>
82
+ return (<div className={className} {...props}>
77
83
  <h2 id={`${headingId}-status`} className="ds_task-list-status-heading">{title}</h2>
78
84
  <nav aria-labelledby={`${headingId}-status`} className="ds_task-list-status">
79
85
  <p>You have completed {completedTasksCount} of {taskCount} sections.</p>
@@ -82,7 +88,7 @@ const TaskList = ({ children, headingId = 'task-list', title }) => {
82
88
  <ul className="ds_task-list">
83
89
  {children}
84
90
  </ul>
85
- </>);
91
+ </div>);
86
92
  };
87
93
  TaskList.displayName = 'TaskList';
88
94
  exports.Task.displayName = 'Task';
@@ -9,7 +9,7 @@ const character_count_1 = __importDefault(require("@scottish-government/design-s
9
9
  const conditional_wrapper_1 = __importDefault(require("../../common/conditional-wrapper"));
10
10
  const error_message_1 = __importDefault(require("../error-message/error-message"));
11
11
  const hint_text_1 = __importDefault(require("../../common/hint-text"));
12
- const Textarea = ({ countThreshold, error, errorMessage, hintText, id, label, maxlength, name, onBlur, onChange, placeholder, rows = 4, value, ...props }) => {
12
+ const Textarea = ({ className, countThreshold, error, errorMessage, hintText, id, label, maxlength, name, onBlur, onChange, placeholder, rows = 4, value, ...props }) => {
13
13
  const errorMessageId = `error-message-${id}`;
14
14
  const hintTextId = `hint-text-${id}`;
15
15
  const ref = (0, react_1.useRef)(null);
@@ -45,6 +45,7 @@ const Textarea = ({ countThreshold, error, errorMessage, hintText, id, label, ma
45
45
  <textarea aria-describedby={describedbys.join(' ')} className={[
46
46
  'ds_input',
47
47
  error && 'ds_input--error',
48
+ className
48
49
  ].join(' ')} defaultValue={value} id={id} maxLength={maxlength} name={name || id} onBlur={handleBlur} onChange={handleChange} placeholder={placeholder} rows={rows} {...props}/>
49
50
 
50
51
  </conditional_wrapper_1.default>);
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const WarningText = ({ children, ...props }) => {
4
- return (<div className="ds_warning-text" {...props}>
3
+ const WarningText = ({ children, className, ...props }) => {
4
+ return (<div className={[
5
+ 'ds_warning-text',
6
+ className
7
+ ].join(' ')} {...props}>
5
8
  <strong className="ds_warning-text__icon" aria-hidden="true"></strong>
6
9
  <strong className="visually-hidden">Warning</strong>
7
10
  <div className="ds_warning-text__text">