@scottish-government/designsystem-react 0.8.0 → 0.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/.storybook/main.ts +20 -0
  2. package/.storybook/manager.ts +13 -0
  3. package/.storybook/preview-head.html +1 -0
  4. package/.storybook/preview.tsx +56 -0
  5. package/.storybook/sgdsArgTypes.ts +123 -0
  6. package/.storybook/sgdsTheme.ts +9 -0
  7. package/.storybook/vitest.setup.ts +7 -0
  8. package/@types/common/AbstractNotificationBanner.d.ts +2 -2
  9. package/@types/common/ActionLink.d.ts +1 -1
  10. package/@types/common/Icon.d.ts +1 -1
  11. package/@types/components/Accordion.d.ts +2 -3
  12. package/@types/components/Button.d.ts +5 -5
  13. package/@types/components/CategoryItem.d.ts +10 -0
  14. package/@types/components/CategoryList.d.ts +7 -0
  15. package/@types/components/Checkbox.d.ts +2 -2
  16. package/@types/components/ContentsNav.d.ts +1 -1
  17. package/@types/components/DatePicker.d.ts +1 -1
  18. package/@types/components/ErrorMessage.d.ts +1 -2
  19. package/@types/components/ErrorSummary.d.ts +1 -1
  20. package/@types/components/FileDownload.d.ts +2 -2
  21. package/@types/components/Metadata.d.ts +1 -1
  22. package/@types/components/Pagination.d.ts +1 -1
  23. package/@types/components/RadioButton.d.ts +2 -2
  24. package/@types/components/SideNavigation.d.ts +1 -1
  25. package/@types/components/SiteNavigation.d.ts +1 -1
  26. package/@types/components/SummaryList.d.ts +1 -1
  27. package/@types/components/Tabs.d.ts +3 -3
  28. package/@types/components/TextInput.d.ts +1 -1
  29. package/@types/sgds.d.ts +2 -1
  30. package/CHANGELOG.md +29 -0
  31. package/dist/common/AbstractNotificationBanner.jsx +4 -4
  32. package/dist/common/Icon.jsx +2 -2
  33. package/dist/components/Accordion/Accordion.jsx +8 -7
  34. package/dist/components/Button/Button.jsx +6 -6
  35. package/dist/components/CategoryItem/CategoryItem.jsx +35 -0
  36. package/dist/components/CategoryList/CategoryList.jsx +55 -0
  37. package/dist/components/Checkbox/Checkbox.jsx +7 -4
  38. package/dist/components/Checkbox/CheckboxGroup.jsx +5 -11
  39. package/dist/components/ContentsNav/ContentsNav.jsx +2 -2
  40. package/dist/components/DatePicker/DatePicker.jsx +1 -1
  41. package/dist/components/ErrorMessage/ErrorMessage.jsx +3 -3
  42. package/dist/components/FileDownload/FileDownload.jsx +2 -2
  43. package/dist/components/NotificationBanner/NotificationBanner.jsx +2 -2
  44. package/dist/components/PageMetadata/PageMetadata.jsx +4 -4
  45. package/dist/components/Pagination/Pagination.jsx +4 -4
  46. package/dist/components/Question/Question.jsx +1 -1
  47. package/dist/components/RadioButton/RadioButton.jsx +6 -2
  48. package/dist/components/RadioButton/RadioGroup.jsx +7 -47
  49. package/dist/components/Select/Select.jsx +1 -1
  50. package/dist/components/SideNavigation/SideNavigation.jsx +2 -2
  51. package/dist/components/SiteHeader/SiteHeader.jsx +3 -3
  52. package/dist/components/SiteNavigation/SiteNavigation.jsx +2 -2
  53. package/dist/components/SiteSearch/SiteSearch.jsx +1 -1
  54. package/dist/components/SkipLinks/SkipLinks.jsx +1 -1
  55. package/dist/components/SummaryList/SummaryList.jsx +3 -3
  56. package/dist/components/Tabs/Tabs.jsx +6 -7
  57. package/dist/components/TextInput/TextInput.jsx +5 -5
  58. package/dist/components/Textarea/Textarea.jsx +1 -1
  59. package/dist/hooks/useTracking.js +21 -0
  60. package/dist/tsconfig.tsbuildinfo +1 -1
  61. package/dist/utils/context.js +5 -0
  62. package/package.json +15 -4
  63. package/src/common/AbstractNotificationBanner.test.tsx +1 -1
  64. package/src/common/AbstractNotificationBanner.tsx +4 -4
  65. package/src/common/Icon.test.tsx +1 -1
  66. package/src/common/Icon.tsx +2 -2
  67. package/src/components/Accordion/Accordion.stories.tsx +111 -0
  68. package/src/components/Accordion/Accordion.test.tsx +5 -17
  69. package/src/components/Accordion/Accordion.tsx +11 -10
  70. package/src/components/AspectBox/AspectBox.stories.tsx +64 -0
  71. package/src/components/BackToTop/BackToTop.stories.tsx +36 -0
  72. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +49 -0
  73. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -1
  74. package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
  75. package/src/components/Button/Button.stories.tsx +194 -0
  76. package/src/components/Button/Button.test.tsx +4 -4
  77. package/src/components/Button/Button.tsx +9 -9
  78. package/src/components/CategoryItem/CategoryItem.stories.tsx +55 -0
  79. package/src/components/CategoryItem/CategoryItem.test.tsx +93 -0
  80. package/src/components/CategoryItem/CategoryItem.tsx +56 -0
  81. package/src/components/CategoryList/CategoryList.stories.tsx +65 -0
  82. package/src/components/CategoryList/CategoryList.test.tsx +59 -0
  83. package/src/components/CategoryList/CategoryList.tsx +33 -0
  84. package/src/components/Checkbox/Checkbox.stories.tsx +85 -0
  85. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  86. package/src/components/Checkbox/Checkbox.tsx +11 -6
  87. package/src/components/Checkbox/CheckboxGroup.stories.tsx +68 -0
  88. package/src/components/Checkbox/CheckboxGroup.tsx +7 -12
  89. package/src/components/ConfirmationMessage/ConfirmationMessage.stories.tsx +38 -0
  90. package/src/components/ContentsNav/ContentsNav.stories.tsx +43 -0
  91. package/src/components/ContentsNav/ContentsNav.test.tsx +2 -2
  92. package/src/components/ContentsNav/ContentsNav.tsx +2 -2
  93. package/src/components/CookieBanner/CookieBanner.stories.tsx +33 -0
  94. package/src/components/DatePicker/DatePicker.stories.tsx +113 -0
  95. package/src/components/DatePicker/DatePicker.tsx +1 -1
  96. package/src/components/Details/Details.stories.tsx +36 -0
  97. package/src/components/ErrorMessage/ErrorMessage.stories.tsx +19 -0
  98. package/src/components/ErrorMessage/ErrorMessage.test.tsx +3 -15
  99. package/src/components/ErrorMessage/ErrorMessage.tsx +1 -3
  100. package/src/components/ErrorSummary/ErrorSummary.stories.tsx +38 -0
  101. package/src/components/FileDownload/FileDownload.stories.tsx +75 -0
  102. package/src/components/FileDownload/FileDownload.test.tsx +1 -1
  103. package/src/components/FileDownload/FileDownload.tsx +2 -2
  104. package/src/components/HideThisPage/HideThisPage.stories.tsx +20 -0
  105. package/src/components/InsetText/InsetText.stories.tsx +21 -0
  106. package/src/components/NotificationBanner/NotificationBanner.stories.tsx +57 -0
  107. package/src/components/NotificationBanner/NotificationBanner.test.tsx +1 -1
  108. package/src/components/NotificationBanner/NotificationBanner.tsx +4 -4
  109. package/src/components/NotificationPanel/NotificationPanel.stories.tsx +32 -0
  110. package/src/components/PageHeader/PageHeader.stories.tsx +60 -0
  111. package/src/components/PageMetadata/PageMetadata.stories.tsx +58 -0
  112. package/src/components/PageMetadata/PageMetadata.test.tsx +2 -2
  113. package/src/components/PageMetadata/PageMetadata.tsx +4 -4
  114. package/src/components/Pagination/Pagination.stories.tsx +69 -0
  115. package/src/components/Pagination/Pagination.test.tsx +1 -1
  116. package/src/components/Pagination/Pagination.tsx +4 -4
  117. package/src/components/PhaseBanner/PhaseBanner.stories.tsx +38 -0
  118. package/src/components/Question/Question.stories.tsx +78 -0
  119. package/src/components/Question/Question.tsx +1 -1
  120. package/src/components/RadioButton/RadioButton.stories.tsx +67 -0
  121. package/src/components/RadioButton/RadioButton.test.tsx +2 -1
  122. package/src/components/RadioButton/RadioButton.tsx +9 -3
  123. package/src/components/RadioButton/RadioGroup.stories.tsx +77 -0
  124. package/src/components/RadioButton/RadioGroup.test.tsx +2 -2
  125. package/src/components/RadioButton/RadioGroup.tsx +8 -15
  126. package/src/components/Select/Select.stories.tsx +76 -0
  127. package/src/components/Select/Select.tsx +1 -1
  128. package/src/components/SequentialNavigation/SequentialNavigation.stories.tsx +31 -0
  129. package/src/components/SideNavigation/SideNavigation.stories.tsx +92 -0
  130. package/src/components/SideNavigation/SideNavigation.test.tsx +2 -2
  131. package/src/components/SideNavigation/SideNavigation.tsx +2 -2
  132. package/src/components/SiteFooter/SiteFooter.stories.tsx +65 -0
  133. package/src/components/SiteHeader/SiteHeader.stories.tsx +92 -0
  134. package/src/components/SiteHeader/SiteHeader.tsx +2 -7
  135. package/src/components/SiteNavigation/SiteNavigation.stories.tsx +45 -0
  136. package/src/components/SiteNavigation/SiteNavigation.test.tsx +1 -1
  137. package/src/components/SiteNavigation/SiteNavigation.tsx +2 -2
  138. package/src/components/SiteSearch/SiteSearch.stories.tsx +81 -0
  139. package/src/components/SiteSearch/SiteSearch.tsx +1 -1
  140. package/src/components/SkipLinks/SkipLinks.stories.tsx +57 -0
  141. package/src/components/SkipLinks/SkipLinks.tsx +1 -1
  142. package/src/components/SummaryCard/SummaryCard.stories.tsx +46 -0
  143. package/src/components/SummaryList/SummaryList.stories.tsx +75 -0
  144. package/src/components/SummaryList/SummaryList.test.tsx +1 -1
  145. package/src/components/SummaryList/SummaryList.tsx +3 -3
  146. package/src/components/Table/Table.stories.tsx +96 -0
  147. package/src/components/Tabs/Tabs.stories.tsx +90 -0
  148. package/src/components/Tabs/Tabs.test.tsx +6 -8
  149. package/src/components/Tabs/Tabs.tsx +8 -9
  150. package/src/components/Tag/Tag.stories.tsx +25 -0
  151. package/src/components/TaskList/TaskList.stories.tsx +129 -0
  152. package/src/components/TextInput/TextInput.stories.tsx +123 -0
  153. package/src/components/TextInput/TextInput.test.tsx +2 -2
  154. package/src/components/TextInput/TextInput.tsx +5 -5
  155. package/src/components/Textarea/Textarea.stories.tsx +71 -0
  156. package/src/components/Textarea/Textarea.tsx +1 -1
  157. package/src/components/WarningText/WarningText.stories.tsx +21 -0
  158. package/src/hooks/useTracking.test.tsx +64 -0
  159. package/src/hooks/useTracking.ts +19 -0
  160. package/src/utils/context.ts +3 -0
  161. package/static/data/autocomplete-dummy-data.json +2361 -0
  162. package/static/images/highland-cow.jpg +0 -0
  163. package/static/images/scottish-government--min.svg +11 -0
  164. package/static/images/scottish-government.svg +6 -0
  165. package/tsconfig.json +3 -2
  166. package/vite.config.ts +45 -11
  167. package/vitest-setup.ts +1 -0
  168. package/vitest.shims.d.ts +1 -0
  169. package/src/utils/slugify.ts +0 -13
@@ -6,22 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Icon_1 = __importDefault(require("../../common/Icon"));
7
7
  const ScreenReaderText_1 = __importDefault(require("../../common/ScreenReaderText"));
8
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 }) => {
9
+ const Button = ({ buttonStyle, children, className, icon, hasLinkStyle, href, isIconLeft, isIconOnly = false, isSmall, type = 'button', width, ...props }) => {
10
10
  // determine which HTML tag to use
11
11
  let tagName = 'button';
12
12
  if (href) {
13
13
  tagName = 'a';
14
14
  }
15
15
  return (<WrapperTag_1.default tagName={tagName} className={[
16
- !styleAsLink ? 'ds_button' : 'ds_link',
16
+ !hasLinkStyle ? 'ds_button' : 'ds_link',
17
17
  width && `ds_button--${width}`,
18
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',
19
+ isSmall && 'ds_button--small',
20
+ (icon && !isIconOnly) ? 'ds_button--has-icon' : undefined,
21
+ isIconLeft && 'ds_button--has-icon--left',
22
22
  className
23
23
  ].join(' ')} href={href} {...(tagName === 'button' ? { type: type } : {})} {...props}>
24
- {iconOnly ? <ScreenReaderText_1.default>{children}</ScreenReaderText_1.default> : children}
24
+ {isIconOnly ? <ScreenReaderText_1.default>{children}</ScreenReaderText_1.default> : children}
25
25
 
26
26
  {icon && <Icon_1.default icon={icon}/>}
27
27
  </WrapperTag_1.default>);
@@ -0,0 +1,35 @@
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 ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
7
+ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
8
+ const CategoryItem = ({ children, className, headingLevel = 'h2', href, linkComponent, tagName = 'div', title, ...props }) => {
9
+ const LINK_CLASS = 'ds_category-item__link';
10
+ function getLinkElement(children) {
11
+ if (linkComponent) {
12
+ return linkComponent({ className: LINK_CLASS, href, children });
13
+ }
14
+ else if (href) {
15
+ return <a href={href} className={LINK_CLASS}>{children}</a>;
16
+ }
17
+ }
18
+ return (<WrapperTag_1.default tagName={tagName} className={[
19
+ 'ds_category-item',
20
+ className
21
+ ].join(' ')} {...props}>
22
+ <WrapperTag_1.default className="ds_category-item__title" tagName={headingLevel}>
23
+ <ConditionalWrapper_1.default condition={typeof href !== 'undefined'} wrapper={(children) => getLinkElement(children)}>
24
+ {title}
25
+ </ConditionalWrapper_1.default>
26
+ </WrapperTag_1.default>
27
+
28
+ {children &&
29
+ <p className="ds_category-item__summary">
30
+ {children}
31
+ </p>}
32
+ </WrapperTag_1.default>);
33
+ };
34
+ CategoryItem.displayName = 'CategoryItem';
35
+ exports.default = CategoryItem;
@@ -0,0 +1,55 @@
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
+ const CategoryList = ({ children, className, isGrid, isOrdered, ...props }) => {
42
+ function processChild(child) {
43
+ const thisChild = child;
44
+ return react_1.default.cloneElement(thisChild, { tagName: 'li' });
45
+ }
46
+ return (<WrapperTag_1.default tagName={isOrdered ? 'ol' : 'ul'} className={[
47
+ 'ds_category-list',
48
+ isGrid && 'ds_category-list--grid',
49
+ className
50
+ ].join(' ')} {...props}>
51
+ {react_1.Children.map(children, child => processChild(child))}
52
+ </WrapperTag_1.default>);
53
+ };
54
+ CategoryList.displayName = 'CategoryList';
55
+ exports.default = CategoryList;
@@ -3,10 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("react");
7
+ const context_1 = require("../../utils/context");
6
8
  const HintText_1 = __importDefault(require("../../common/HintText"));
7
- const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onChange, small }) => {
9
+ const Checkbox = ({ checked, hintText, id, isSmall, isExclusive, label, name, onBlur, onChange }) => {
8
10
  const hintTextId = `hint-text-${id}`;
9
- const behaviour = exclusive && 'exclusive';
11
+ const behaviour = isExclusive && 'exclusive';
10
12
  function handleBlur(event) {
11
13
  if (typeof onBlur === 'function') {
12
14
  onBlur(event);
@@ -17,11 +19,12 @@ const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onCha
17
19
  onChange(event);
18
20
  }
19
21
  }
22
+ isSmall = isSmall || (0, react_1.useContext)(context_1.CheckboxRadioContext).isSmall;
20
23
  return (<>
21
- {exclusive && <p className="ds_checkbox-separator">or</p>}
24
+ {isExclusive && <p className="ds_checkbox-separator">or</p>}
22
25
  <div className={[
23
26
  'ds_checkbox',
24
- small && 'ds_checkbox--small'
27
+ isSmall && 'ds_checkbox--small'
25
28
  ].join(' ')}>
26
29
 
27
30
  <input aria-describedby={hintText ? hintTextId : undefined} className="ds_checkbox__input" data-behaviour={behaviour} defaultChecked={!!checked} id={id} name={name || id} onBlur={handleBlur} onChange={handleChange} type="checkbox"/>
@@ -38,18 +38,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.CheckboxGroup = void 0;
40
40
  const react_1 = __importStar(require("react"));
41
- const Checkbox_1 = __importDefault(require("./Checkbox"));
41
+ const context_1 = require("../../utils/context");
42
42
  // @ts-ignore
43
43
  const checkboxes_1 = __importDefault(require("@scottish-government/design-system/src/forms/checkbox/checkboxes"));
44
- const CheckboxGroup = ({ children, className, small, ...props }) => {
45
- function processChild(child) {
46
- if (child && child.type === Checkbox_1.default) {
47
- return react_1.default.cloneElement(child, { small: small });
48
- }
49
- else {
50
- return child;
51
- }
52
- }
44
+ const CheckboxGroup = ({ children, className, isSmall, ...props }) => {
53
45
  const ref = (0, react_1.useRef)(null);
54
46
  (0, react_1.useEffect)(() => {
55
47
  if (ref.current) {
@@ -61,7 +53,9 @@ const CheckboxGroup = ({ children, className, small, ...props }) => {
61
53
  'ds_field-group',
62
54
  className
63
55
  ].join(' ')} data-module="ds-checkboxes" ref={ref} {...props}>
64
- {react_1.Children.map(children, child => processChild(child))}
56
+ <context_1.CheckboxRadioContext value={{ isSmall: !!isSmall, name: '' }}>
57
+ {children}
58
+ </context_1.CheckboxRadioContext>
65
59
  </div>);
66
60
  };
67
61
  exports.CheckboxGroup = CheckboxGroup;
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const ContentsNavItem = ({ children, current, href, linkComponent }) => {
7
+ const ContentsNavItem = ({ children, isCurrent, href, linkComponent }) => {
8
8
  const classNames = ['ds_contents-nav__link'];
9
9
  let ariaCurrent;
10
- if (current) {
10
+ if (isCurrent) {
11
11
  classNames.push('ds_current');
12
12
  ariaCurrent = 'page';
13
13
  }
@@ -35,7 +35,7 @@ const DatePicker = ({ className, dateSelectCallback, disabledDates, errorMessage
35
35
  ].join(' ')} data-disableddates={disabledDates} data-maxdate={maxDate} data-mindate={minDate} data-module="ds-datepicker" ref={ref} {...props}>
36
36
  {(multiple ? (<fieldset className="ds_datepicker__input-wrapper">
37
37
  <legend>{label}</legend>
38
- {errorMessage && <ErrorMessage_1.default text={errorMessage}/>}
38
+ {errorMessage && <ErrorMessage_1.default>{errorMessage}</ErrorMessage_1.default>}
39
39
  <div>
40
40
  <TextInput_1.default className="js-datepicker-date" hasError={!!hasError} id={id + "-day"} hintText={hintText} label="Day" name={name + "-day"} onBlur={handleBlur} onChange={handleChange} value={value?.split('/')[0]} width="fixed-2"/>
41
41
  </div>
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const ErrorMessage = ({ children, className, id, text, ...props }) => {
3
+ const ErrorMessage = ({ children, className, id, ...props }) => {
4
4
  return (<p className={[
5
5
  'ds_question__error-message',
6
6
  className
7
- ].join(' ')} dangerouslySetInnerHTML={text ? { __html: text } : undefined} id={id} {...props}>
8
- {!text ? children : null}
7
+ ].join(' ')} id={id} {...props}>
8
+ {children}
9
9
  </p>);
10
10
  };
11
11
  ErrorMessage.displayName = 'ErrorMessage';
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = require("react");
7
7
  const FileIcon_1 = __importDefault(require("../../common/FileIcon"));
8
- const FileDownload = ({ className, cover, highlighted, icon = 'Generic', fileSize, fileType, fileUrl, title, ...props }) => {
8
+ const FileDownload = ({ className, cover, icon = 'Generic', isHighlighted, fileSize, fileType, fileUrl, title, ...props }) => {
9
9
  const hasMetadata = !!fileType || !!fileSize;
10
10
  const metaContainerId = `file-download-${(0, react_1.useId)()}`;
11
11
  return (<div className={[
12
12
  'ds_file-download',
13
- highlighted && 'ds_file-download--highlighted',
13
+ isHighlighted && 'ds_file-download--highlighted',
14
14
  className
15
15
  ].join(' ')} {...props}>
16
16
  <div className="ds_file-download__thumbnail">
@@ -7,7 +7,7 @@ const react_1 = require("react");
7
7
  const AbstractNotificationBanner_1 = __importDefault(require("../../common/AbstractNotificationBanner"));
8
8
  // @ts-ignore
9
9
  const notification_banner_1 = __importDefault(require("@scottish-government/design-system/src/components/notification-banner/notification-banner"));
10
- const NotificationBanner = ({ children, className, close, hasColourIcon, hasInverseIcon, icon, title, ...props }) => {
10
+ const NotificationBanner = ({ children, className, hasColourIcon, hasIcon, hasInverseIcon, isDismissable, title, ...props }) => {
11
11
  const ref = (0, react_1.useRef)(null);
12
12
  (0, react_1.useEffect)(() => {
13
13
  if (ref.current) {
@@ -17,7 +17,7 @@ const NotificationBanner = ({ children, className, close, hasColourIcon, hasInve
17
17
  return (<AbstractNotificationBanner_1.default className={[
18
18
  'ds_reversed',
19
19
  className
20
- ].join(' ')} close={close} icon={icon ? "PriorityHigh" : undefined} hasColourIcon={hasColourIcon} hasInverseIcon={hasInverseIcon} ref={ref} title="Information" {...props}>
20
+ ].join(' ')} isDismissable={isDismissable} icon={hasIcon ? "PriorityHigh" : undefined} hasColourIcon={hasColourIcon} hasInverseIcon={hasInverseIcon} ref={ref} title="Information" {...props}>
21
21
  {children}
22
22
  </AbstractNotificationBanner_1.default>);
23
23
  };
@@ -5,16 +5,16 @@ const MetadataItem = ({ children, className, name, ...props }) => {
5
5
  'ds_metadata__item',
6
6
  className
7
7
  ].join(' ')} {...props}>
8
- <dt className="ds_metadata__key">{name}</dt>{' '}
8
+ <dt className="ds_metadata__key">{name}</dt>
9
9
  <dd className="ds_metadata__value">
10
- {children}
10
+ {children}{' '}
11
11
  </dd>
12
12
  </div>);
13
13
  };
14
- const Metadata = ({ children, className, inline, ...props }) => {
14
+ const Metadata = ({ children, className, isInline, ...props }) => {
15
15
  return (<dl className={[
16
16
  'ds_metadata',
17
- inline && 'ds_metadata--inline',
17
+ isInline && 'ds_metadata--inline',
18
18
  className
19
19
  ].join(' ')} {...props}>
20
20
  {children}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Ellipsis = exports.Page = void 0;
7
7
  const Icon_1 = __importDefault(require("../../common/Icon"));
8
- const Page = ({ ariaLabel, children, className, current = false, href, linkComponent, onClick }) => {
8
+ const Page = ({ ariaLabel, children, className, href, isCurrent = false, linkComponent, onClick }) => {
9
9
  function handleClick(event) {
10
10
  if (typeof onClick === 'function') {
11
11
  onClick(event);
@@ -15,14 +15,14 @@ const Page = ({ ariaLabel, children, className, current = false, href, linkCompo
15
15
  const classNames = [
16
16
  'ds_pagination__link',
17
17
  className,
18
- current ? 'ds_current' : undefined
18
+ isCurrent ? 'ds_current' : undefined
19
19
  ].join(' ');
20
20
  const linkProps = {
21
21
  'aria-label': ariaLabel,
22
22
  href: href,
23
23
  onClick: handleClick
24
24
  };
25
- if (current) {
25
+ if (isCurrent) {
26
26
  linkProps['aria-current'] = 'page';
27
27
  }
28
28
  if (linkComponent) {
@@ -94,7 +94,7 @@ const Pagination = ({ ariaLabel = 'Pages', className, onClick, padding = 1, page
94
94
  <exports.Ellipsis />
95
95
  </>)}
96
96
 
97
- {pages && pages.map((item, index) => (<exports.Page ariaLabel={`Page ${item}`} href={pattern.replace('$1', String(item))} current={item === page} key={`pagination${index}`} linkComponent={linkComponent} onClick={onClick} pattern={pattern}>
97
+ {pages && pages.map((item, index) => (<exports.Page ariaLabel={`Page ${item}`} href={pattern.replace('$1', String(item))} isCurrent={item === page} key={`pagination${index}`} linkComponent={linkComponent} onClick={onClick} pattern={pattern}>
98
98
  <span className="ds_pagination__link-label">{item.toString()}</span>
99
99
  </exports.Page>))}
100
100
 
@@ -14,7 +14,7 @@ const Question = function ({ children, className, errorMessage, hasError, hintTe
14
14
  ].join(' ')} {...props}>
15
15
  {legend && <legend>{legend}</legend>}
16
16
  {hintText && <HintText_1.default text={hintText}/>}
17
- {hasError && errorMessage && <ErrorMessage_1.default text={errorMessage}/>}
17
+ {hasError && errorMessage && <ErrorMessage_1.default>{errorMessage}</ErrorMessage_1.default>}
18
18
  {children}
19
19
  </WrapperTag_1.default>);
20
20
  };
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("react");
6
7
  const HintText_1 = __importDefault(require("../../common/HintText"));
7
- const RadioButton = ({ checked, hintText, id, label, name, onBlur, onChange, small }) => {
8
+ const context_1 = require("../../utils/context");
9
+ const RadioButton = ({ checked, hintText, id, isSmall, label, name, onBlur, onChange }) => {
8
10
  const hintTextId = `hint-text-${id}`;
9
11
  function handleBlur(event) {
10
12
  if (typeof onBlur === 'function') {
@@ -16,9 +18,11 @@ const RadioButton = ({ checked, hintText, id, label, name, onBlur, onChange, sma
16
18
  onChange(event);
17
19
  }
18
20
  }
21
+ isSmall = isSmall || (0, react_1.useContext)(context_1.CheckboxRadioContext).isSmall;
22
+ name = name || (0, react_1.useContext)(context_1.CheckboxRadioContext).name;
19
23
  return (<div className={[
20
24
  'ds_radio',
21
- small && 'ds_radio--small'
25
+ isSmall && 'ds_radio--small'
22
26
  ].join(' ')}>
23
27
  <input aria-describedby={hintText ? hintTextId : undefined} className="ds_radio__input" defaultChecked={!!checked} id={id} name={name} onBlur={handleBlur} onChange={handleChange} type="radio"/>
24
28
  <label className="ds_radio__label" htmlFor={id}>{label}</label>
@@ -1,60 +1,20 @@
1
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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
- const react_1 = __importStar(require("react"));
40
- const RadioButton_1 = __importDefault(require("./RadioButton"));
41
- const RadioGroup = ({ children, className, inline, name, small, ...props }) => {
42
- function processChild(child) {
43
- if (child && child.type === RadioButton_1.default) {
44
- return react_1.default.cloneElement(child, { small: small, name: name });
45
- }
46
- else {
47
- return child;
48
- }
49
- }
6
+ const react_1 = __importDefault(require("react"));
7
+ const context_1 = require("../../utils/context");
8
+ const RadioGroup = ({ children, className, isInline, isSmall, name, ...props }) => {
50
9
  return (<div className={[
51
10
  'ds_radios',
52
11
  'ds_field-group',
53
- inline && 'ds_field-group--inline',
12
+ isInline && 'ds_field-group--inline',
54
13
  className
55
14
  ].join(' ')} {...props}>
56
-
57
- {react_1.Children.map(children, child => processChild(child))}
15
+ <context_1.CheckboxRadioContext value={{ isSmall: !!isSmall, name }}>
16
+ {children}
17
+ </context_1.CheckboxRadioContext>
58
18
  </div>);
59
19
  };
60
20
  RadioGroup.displayName = 'RadioGroup';
@@ -30,7 +30,7 @@ const Select = function ({ children, className, defaultValue, errorMessage, hasE
30
30
  return (<>
31
31
  <label className="ds_label" htmlFor={id}>{label}</label>
32
32
  {hintText && <HintText_1.default id={hintTextId} text={hintText}/>}
33
- {errorMessage && <ErrorMessage_1.default id={errorMessageId} text={errorMessage}/>}
33
+ {errorMessage && <ErrorMessage_1.default id={errorMessageId}>{errorMessage}</ErrorMessage_1.default>}
34
34
  <div className={[
35
35
  "ds_select-wrapper",
36
36
  hasError && 'ds_input--error',
@@ -11,13 +11,13 @@ const SideNavigationList = function ({ children, isRoot }) {
11
11
  {children}
12
12
  </ul>);
13
13
  };
14
- const SideNavigationItem = function ({ children, href, current = false, linkComponent, title }) {
14
+ const SideNavigationItem = function ({ children, href, isCurrent = false, linkComponent, title }) {
15
15
  const LINK_CLASS = 'ds_side-navigation__link';
16
16
  return (<li className={[
17
17
  'ds_side-navigation__item',
18
18
  children && 'ds_side-navigation__item--has-children'
19
19
  ].join(' ')}>
20
- {current ?
20
+ {isCurrent ?
21
21
  <span className={LINK_CLASS + ' ds_current'}>{title}</span> :
22
22
  linkComponent ? linkComponent({ className: LINK_CLASS, href, children: title }) :
23
23
  <a href={href} className={LINK_CLASS}>{title}</a>}
@@ -70,7 +70,7 @@ const Phase = ({ children }) => {
70
70
  const Search = ({ children }) => {
71
71
  return children;
72
72
  };
73
- const SiteHeader = ({ children, logo = {}, navigationItems, phaseBanner, siteSearch, siteTitle, ...props }) => {
73
+ const SiteHeader = ({ children, ...props }) => {
74
74
  const mobileMenuRef = (0, react_1.useRef)(null);
75
75
  let branding;
76
76
  let navigation;
@@ -113,8 +113,8 @@ const SiteHeader = ({ children, logo = {}, navigationItems, phaseBanner, siteSea
113
113
  <div className="ds_site-header__controls">
114
114
  <label aria-controls="mobile-navigation" className="ds_site-header__control js-toggle-menu" htmlFor="menu">
115
115
  <span className="ds_site-header__control-text">Menu</span>
116
- <Icon_1.default fill className="ds_site-header__control-icon" icon="Menu" aria-hidden="true"/>
117
- <Icon_1.default fill className="ds_site-header__control-icon ds_site-header__control-icon--active-icon" icon="Close" aria-hidden="true"/>
116
+ <Icon_1.default isFilled className="ds_site-header__control-icon" icon="Menu" aria-hidden="true"/>
117
+ <Icon_1.default isFilled className="ds_site-header__control-icon ds_site-header__control-icon--active-icon" icon="Close" aria-hidden="true"/>
118
118
  </label>
119
119
  </div>
120
120
 
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Item = ({ children, current = false, href, linkComponent }) => {
3
+ const Item = ({ children, isCurrent = false, href, linkComponent }) => {
4
4
  const classNames = ['ds_site-navigation__link'];
5
5
  let ariaCurrent;
6
- if (current) {
6
+ if (isCurrent) {
7
7
  classNames.push('ds_current');
8
8
  ariaCurrent = 'page';
9
9
  }
@@ -42,7 +42,7 @@ const SiteSearch = function ({ action = '/search', autocompleteEndpoint, autocom
42
42
  hasAutocomplete ? 'js-autocomplete-input' : undefined
43
43
  ].join(' ')} id={id} name={name} placeholder={placeholder} required spellCheck="false" type="search"/>
44
44
 
45
- <Button_1.default type="submit" icon="Search" iconOnly>Search</Button_1.default>
45
+ <Button_1.default type="submit" icon="Search" isIconOnly>Search</Button_1.default>
46
46
 
47
47
  {hasAutocomplete && (<div id="autocomplete-suggestions" className="ds_autocomplete__suggestions">
48
48
  <ol className="ds_autocomplete__suggestions-list" role="listbox" aria-labelledby="site-search-label"></ol>
@@ -16,6 +16,6 @@ const SkipLinks = ({ children, mainContentId = 'main-content', mainLinkText = 'S
16
16
  </div>);
17
17
  };
18
18
  SkipLinks.displayName = 'SkipLinks';
19
- Link.displayName = 'SkipLink';
19
+ Link.displayName = 'SkipLinks.Link';
20
20
  SkipLinks.Link = Link;
21
21
  exports.default = SkipLinks;
@@ -74,10 +74,10 @@ const Item = ({ children, title }) => {
74
74
  const Value = ({ children }) => {
75
75
  return (<q className="ds_summary-list__answer">{children}</q>);
76
76
  };
77
- const SummaryList = ({ children, className, noBorder, ...props }) => {
77
+ const SummaryList = ({ children, className, isBorderless, ...props }) => {
78
78
  return (<ol className={[
79
79
  'ds_summary-list',
80
- noBorder && 'ds_summary-list--no-border',
80
+ isBorderless && 'ds_summary-list--no-border',
81
81
  className
82
82
  ].join(' ')} {...props}>
83
83
  {children}
@@ -89,5 +89,5 @@ SummaryList.Value = Value;
89
89
  SummaryList.displayName = 'SummaryList';
90
90
  SummaryList.Action.displayName = 'SummaryList.Action';
91
91
  Item.displayName = 'SummaryList.Item';
92
- Value.displayName = 'SumaryList.Value';
92
+ Value.displayName = 'SummaryList.Value';
93
93
  exports.default = SummaryList;
@@ -40,11 +40,10 @@ const react_1 = __importStar(require("react"));
40
40
  const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
41
41
  // @ts-ignore
42
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 }) => {
43
+ const TabItem = ({ isBorderless, children, className, id, tabLabel, ...props }) => {
45
44
  return (<div className={[
46
45
  'ds_tabs__content',
47
- bordered && 'ds_tabs__content--bordered',
46
+ !isBorderless && 'ds_tabs__content--bordered',
48
47
  className
49
48
  ].join(' ')} id={id} {...props}>
50
49
  {children}
@@ -55,7 +54,7 @@ const TabListItem = ({ children, href }) => {
55
54
  <a className="ds_tabs__tab-link" href={href}>{children}</a>
56
55
  </li>);
57
56
  };
58
- const Tabs = ({ baseId = 'tabs', bordered = true, children, className, headingLevel = 'h2', manual = false, title = 'Contents', ...props }) => {
57
+ const Tabs = ({ baseId = 'tabs', children, className, headingLevel = 'h2', isBorderless, isManual = false, title = 'Contents', ...props }) => {
59
58
  const ref = (0, react_1.useRef)(null);
60
59
  const headingId = `${baseId}-heading`;
61
60
  (0, react_1.useEffect)(() => {
@@ -67,8 +66,8 @@ const Tabs = ({ baseId = 'tabs', bordered = true, children, className, headingLe
67
66
  const thisChild = child;
68
67
  if (thisChild && thisChild.type === TabItem) {
69
68
  return react_1.default.cloneElement(thisChild, {
70
- bordered: bordered,
71
- id: thisChild.props.id || `${baseId}-${(0, slugify_1.default)(thisChild.props.tabLabel)}`,
69
+ isBorderless: !!isBorderless,
70
+ id: thisChild.props.id || `${baseId}-${(0, react_1.useId)()}`,
72
71
  });
73
72
  }
74
73
  });
@@ -79,7 +78,7 @@ const Tabs = ({ baseId = 'tabs', bordered = true, children, className, headingLe
79
78
  });
80
79
  return (<div className={[
81
80
  'ds_tabs',
82
- manual && 'ds_tabs--manual',
81
+ isManual && 'ds_tabs--manual',
83
82
  className
84
83
  ].join(' ')} ref={ref} {...props}>
85
84
  <WrapperTag_1.default id={headingId} className="ds_tabs__title" tagName={headingLevel}>
@@ -10,11 +10,11 @@ const Button_1 = __importDefault(require("../Button/Button"));
10
10
  const ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
11
11
  const ErrorMessage_1 = __importDefault(require("../ErrorMessage/ErrorMessage"));
12
12
  const HintText_1 = __importDefault(require("../../common/HintText"));
13
- const TextInput = ({ buttonIcon, buttonText, children, className, countThreshold, width, currency, currencySymbol, errorMessage, hasButton = false, hasError, hintText, id, label, maxlength, name, onBlur, onChange, placeholder, type = 'text', value, ...props }) => {
13
+ const TextInput = ({ buttonIcon, buttonText, children, className, countThreshold, width, isCurrency, currencySymbol, errorMessage, hasButton = false, hasError, hintText, id, label, maxlength, name, onBlur, onChange, placeholder, type = 'text', value, ...props }) => {
14
14
  const errorMessageId = `error-message-${id}`;
15
15
  const hintTextId = `hint-text-${id}`;
16
16
  const ref = (0, react_1.useRef)(null);
17
- const inputWrapperClasses = `${hasButton ? 'ds_input__wrapper ds_input__wrapper--has-icon' : ''} ${currency ? 'ds_currency-wrapper' : ''}`;
17
+ const inputWrapperClasses = `${hasButton ? 'ds_input__wrapper ds_input__wrapper--has-icon' : ''} ${isCurrency ? 'ds_currency-wrapper' : ''}`;
18
18
  const describedbys = [];
19
19
  if (hintText) {
20
20
  describedbys.push(hintTextId);
@@ -42,15 +42,15 @@ const TextInput = ({ buttonIcon, buttonText, children, className, countThreshold
42
42
  return (<ConditionalWrapper_1.default condition={typeof maxlength !== 'undefined' && maxlength > 0} wrapper={(children) => <div ref={ref} data-threshold={countThreshold} data-module="ds-character-count">{children}</div>}>
43
43
  <label className="ds_label" htmlFor={id}>{label}</label>
44
44
  {hintText && <HintText_1.default id={hintTextId} text={hintText}/>}
45
- {errorMessage && <ErrorMessage_1.default id={errorMessageId} text={errorMessage}/>}
46
- <ConditionalWrapper_1.default condition={hasButton || typeof currency !== 'undefined' && currency} wrapper={(children) => <div className={inputWrapperClasses} data-symbol={currencySymbol}>{children}</div>}>
45
+ {errorMessage && <ErrorMessage_1.default id={errorMessageId}>{errorMessage}</ErrorMessage_1.default>}
46
+ <ConditionalWrapper_1.default condition={hasButton || typeof isCurrency !== 'undefined' && isCurrency} wrapper={(children) => <div className={inputWrapperClasses} data-symbol={currencySymbol}>{children}</div>}>
47
47
  <input aria-describedby={describedbys.join(' ')} aria-invalid={hasError} className={[
48
48
  'ds_input',
49
49
  className,
50
50
  hasError ? 'ds_input--error' : '',
51
51
  width ? `ds_input--${width}` : '',
52
52
  ].join(' ')} defaultValue={value} id={id} maxLength={maxlength} name={name || id} onBlur={handleBlur} onChange={handleChange} placeholder={placeholder} type={type} {...props}/>
53
- {hasButton && (buttonText || buttonIcon) && <Button_1.default iconOnly icon={buttonIcon}>{buttonText}</Button_1.default>}
53
+ {hasButton && (buttonText || buttonIcon) && <Button_1.default isIconOnly icon={buttonIcon}>{buttonText}</Button_1.default>}
54
54
  </ConditionalWrapper_1.default>
55
55
  </ConditionalWrapper_1.default>);
56
56
  };
@@ -40,7 +40,7 @@ const Textarea = ({ className, countThreshold, errorMessage, hasError, hintText,
40
40
  return (<ConditionalWrapper_1.default condition={typeof maxlength !== 'undefined' && maxlength > 0} wrapper={(children) => <div ref={ref} data-threshold={countThreshold} data-module="ds-character-count">{children}</div>}>
41
41
  <label className="ds_label" htmlFor={id}>{label}</label>
42
42
  {hintText && <HintText_1.default id={hintTextId} text={hintText}/>}
43
- {errorMessage && <ErrorMessage_1.default id={errorMessageId} text={errorMessage}/>}
43
+ {errorMessage && <ErrorMessage_1.default id={errorMessageId}>{errorMessage}</ErrorMessage_1.default>}
44
44
 
45
45
  <textarea aria-describedby={describedbys.join(' ')} aria-invalid={hasError} className={[
46
46
  'ds_input',