@scottish-government/designsystem-react 0.0.2 → 0.1.1

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 (98) hide show
  1. package/@types/components/InsetText.d.ts +5 -0
  2. package/@types/components/WarningText.d.ts +5 -0
  3. package/dist/common/conditional-wrapper.jsx +8 -0
  4. package/dist/common/hint-text.jsx +9 -0
  5. package/dist/common/icon.jsx +14 -0
  6. package/dist/common/screen-reader-text.jsx +9 -0
  7. package/dist/common/wrapper-tag.jsx +11 -0
  8. package/dist/components/accordion/accordion.jsx +103 -0
  9. package/dist/components/aspect-box/aspect-box.jsx +79 -0
  10. package/dist/components/back-to-top/back-to-top.jsx +27 -0
  11. package/dist/components/breadcrumbs/breadcrumbs.jsx +28 -0
  12. package/dist/components/button/button.jsx +30 -0
  13. package/dist/components/checkbox/checkbox.jsx +62 -0
  14. package/dist/components/confirmation-message/confirmation-message.jsx +24 -0
  15. package/dist/components/contents-nav/contents-nav.jsx +33 -0
  16. package/dist/components/date-picker/date-picker.jsx +50 -0
  17. package/dist/components/details/details.jsx +17 -0
  18. package/dist/components/error-message/error-message.jsx +12 -0
  19. package/dist/components/inset-text/inset-text.jsx +14 -0
  20. package/dist/components/notification-banner/notification-banner.jsx +54 -0
  21. package/dist/components/notification-panel/notification-panel.jsx +21 -0
  22. package/dist/components/page-header/page-header.jsx +15 -0
  23. package/dist/components/page-metadata/page-metadata.jsx +27 -0
  24. package/dist/components/phase-banner/phase-banner.jsx +23 -0
  25. package/dist/components/question/question.jsx +22 -0
  26. package/dist/components/radio-button/radio-button.jsx +43 -0
  27. package/dist/components/select/select.jsx +52 -0
  28. package/dist/components/sequential-navigation/sequential-navigation.jsx +31 -0
  29. package/dist/components/side-navigation/side-navigation.jsx +52 -0
  30. package/dist/components/site-navigation/site-navigation.jsx +22 -0
  31. package/dist/components/site-search/site-search.jsx +55 -0
  32. package/dist/components/skip-links/skip-links.jsx +21 -0
  33. package/dist/components/tag/tag.jsx +13 -0
  34. package/dist/components/task-list/task-list.jsx +96 -0
  35. package/dist/components/text-input/text-input.jsx +58 -0
  36. package/dist/components/textarea/textarea.jsx +54 -0
  37. package/dist/components/warning-text/warning-text.jsx +16 -0
  38. package/dist/tsconfig.tsbuildinfo +1 -0
  39. package/package.json +1 -1
  40. package/src/common/icon.test.tsx +1 -1
  41. package/src/components/accordion/accordion.test.tsx +25 -1
  42. package/src/components/accordion/accordion.tsx +10 -2
  43. package/src/components/aspect-box/aspect-box.test.tsx +12 -0
  44. package/src/components/aspect-box/aspect-box.tsx +3 -1
  45. package/src/components/back-to-top/back-to-top.test.tsx +10 -0
  46. package/src/components/back-to-top/back-to-top.tsx +5 -1
  47. package/src/components/breadcrumbs/breadcrumbs.test.tsx +12 -0
  48. package/src/components/breadcrumbs/breadcrumbs.tsx +2 -0
  49. package/src/components/button/button.test.tsx +9 -0
  50. package/src/components/button/button.tsx +4 -2
  51. package/src/components/checkbox/checkbox.test.tsx +13 -0
  52. package/src/components/checkbox/checkbox.tsx +6 -1
  53. package/src/components/confirmation-message/confirmation-message.test.tsx +22 -0
  54. package/src/components/confirmation-message/confirmation-message.tsx +8 -2
  55. package/src/components/contents-nav/contents-nav.test.tsx +13 -0
  56. package/src/components/contents-nav/contents-nav.tsx +8 -4
  57. package/src/components/date-picker/date-picker.test.tsx +13 -0
  58. package/src/components/date-picker/date-picker.tsx +4 -2
  59. package/src/components/details/details.test.tsx +12 -0
  60. package/src/components/details/details.tsx +2 -0
  61. package/src/components/error-message/error-message.test.tsx +9 -0
  62. package/src/components/error-message/error-message.tsx +2 -0
  63. package/src/components/inset-text/inset-text.test.tsx +11 -0
  64. package/src/components/inset-text/inset-text.tsx +6 -2
  65. package/src/components/notification-banner/notification-banner.test.tsx +11 -0
  66. package/src/components/notification-banner/notification-banner.tsx +6 -1
  67. package/src/components/notification-panel/notification-panel.test.tsx +12 -0
  68. package/src/components/notification-panel/notification-panel.tsx +5 -1
  69. package/src/components/page-header/page-header.test.tsx +9 -0
  70. package/src/components/page-header/page-header.tsx +5 -1
  71. package/src/components/page-metadata/page-metadata.test.tsx +15 -0
  72. package/src/components/page-metadata/page-metadata.tsx +7 -1
  73. package/src/components/phase-banner/phase-banner.test.tsx +11 -0
  74. package/src/components/phase-banner/phase-banner.tsx +5 -1
  75. package/src/components/question/question.test.tsx +10 -0
  76. package/src/components/question/question.tsx +3 -1
  77. package/src/components/radio-button/radio-button.test.tsx +13 -0
  78. package/src/components/radio-button/radio-button.tsx +3 -1
  79. package/src/components/select/select.test.tsx +15 -0
  80. package/src/components/select/select.tsx +2 -0
  81. package/src/components/sequential-navigation/sequential-navigation.test.tsx +13 -0
  82. package/src/components/sequential-navigation/sequential-navigation.tsx +5 -1
  83. package/src/components/side-navigation/side-navigation.test.tsx +18 -0
  84. package/src/components/side-navigation/side-navigation.tsx +5 -1
  85. package/src/components/site-navigation/site-navigation.test.tsx +9 -0
  86. package/src/components/site-navigation/site-navigation.tsx +5 -1
  87. package/src/components/site-search/site-search.test.tsx +10 -0
  88. package/src/components/site-search/site-search.tsx +3 -1
  89. package/src/components/tag/tag.test.tsx +7 -7
  90. package/src/components/task-list/task-list.test.tsx +46 -0
  91. package/src/components/task-list/task-list.tsx +18 -5
  92. package/src/components/text-input/text-input.test.tsx +13 -0
  93. package/src/components/textarea/textarea.test.tsx +13 -0
  94. package/src/components/textarea/textarea.tsx +2 -0
  95. package/src/components/warning-text/warning-text.test.tsx +11 -0
  96. package/src/components/warning-text/warning-text.tsx +6 -2
  97. package/.editorconfig +0 -12
  98. package/.github/workflows/release-package.yml +0 -96
@@ -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
+ }
@@ -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,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,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Icon = ({ className, fill, icon, iconPath = './icons.stack.svg', iconSize, title }) => {
4
+ return (<svg aria-hidden={title ? undefined : true} aria-label={title} className={[
5
+ 'ds_icon',
6
+ className,
7
+ fill && 'ds_icon--fill',
8
+ iconSize && `ds_icon--${iconSize}`
9
+ ].join(' ')} role="img">
10
+ <use xlinkHref={`${iconPath}#${icon}`}/>
11
+ </svg>);
12
+ };
13
+ Icon.displayName = 'Icon';
14
+ 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,103 @@
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
+ exports.AccordionItem = void 0;
40
+ const react_1 = __importStar(require("react"));
41
+ const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
42
+ // @ts-ignore
43
+ const accordion_1 = __importDefault(require("@scottish-government/design-system/src/components/accordion/accordion"));
44
+ let accordionItemCounter = 0;
45
+ const AccordionItem = ({ children, className, headerLevel = 'h3', id: rawId, open = false, title, ...props }) => {
46
+ accordionItemCounter = accordionItemCounter + 1;
47
+ const processedId = rawId || `accordion-item-${accordionItemCounter}`;
48
+ return (<div className={[
49
+ 'ds_accordion-item',
50
+ className
51
+ ].join(' ')} id={processedId} {...props}>
52
+ <input aria-labelledby={`panel-${processedId}-heading`} className={[
53
+ 'ds_accordion-item__control',
54
+ 'visually-hidden'
55
+ ].join(' ')} defaultChecked={open} id={`${processedId}-control`} type="checkbox"/>
56
+ <div className="ds_accordion-item__header">
57
+ <wrapper_tag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headerLevel}>
58
+ {title}
59
+ </wrapper_tag_1.default>
60
+ <span className='ds_accordion-item__indicator'/>
61
+ <label className="ds_accordion-item__label" htmlFor={`${processedId}-control`}>
62
+ <span className="visually-hidden">Show this section</span>
63
+ </label>
64
+ </div>
65
+ <div className="ds_accordion-item__body">
66
+ {children}
67
+ </div>
68
+ </div>);
69
+ };
70
+ exports.AccordionItem = AccordionItem;
71
+ const Accordion = ({ children, className, headerLevel = 'h3', hideOpenAll, ...props }) => {
72
+ const ref = (0, react_1.useRef)(null);
73
+ (0, react_1.useEffect)(() => {
74
+ if (ref.current) {
75
+ new accordion_1.default(ref.current).init();
76
+ }
77
+ }, [ref]);
78
+ if (!children) {
79
+ hideOpenAll = true;
80
+ }
81
+ function processChild(child) {
82
+ return react_1.default.cloneElement(child, { headerLevel: headerLevel });
83
+ }
84
+ return (<div className={[
85
+ 'ds_accordion',
86
+ className
87
+ ].join(' ')} ref={ref} {...props}>
88
+ {!hideOpenAll && (<button className={[
89
+ 'ds_accordion__open-all',
90
+ 'ds_link',
91
+ 'js-open-all'
92
+ ].join(' ')} type='button'>
93
+ Open all
94
+ {' '}
95
+ <span className="visually-hidden">sections</span>
96
+ </button>)}
97
+
98
+ {react_1.Children.map(children, child => processChild(child))}
99
+ </div>);
100
+ };
101
+ Accordion.displayName = 'Accordion';
102
+ exports.AccordionItem.displayName = 'AccordionItem';
103
+ 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
+ // @ts-ignore
8
+ const back_to_top_1 = __importDefault(require("@scottish-government/design-system/src/components/back-to-top/back-to-top"));
9
+ const icon_1 = __importDefault(require("../../common/icon"));
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="arrow_upward"/>
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 = ({ className, hideLastItem, items, ...props }) => {
21
+ return (<nav aria-label="Breadcrumb" className={className} {...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 screen_reader_text_1 = __importDefault(require("../../common/screen-reader-text"));
8
+ const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
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 (<wrapper_tag_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 ? <screen_reader_text_1.default>{children}</screen_reader_text_1.default> : children}
25
+
26
+ {icon && <icon_1.default icon={icon}/>}
27
+ </wrapper_tag_1.default>);
28
+ };
29
+ Button.displayName = 'Button';
30
+ exports.default = Button;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CheckboxGroup = exports.Checkbox = void 0;
7
+ const react_1 = require("react");
8
+ // @ts-ignore
9
+ const checkboxes_1 = __importDefault(require("@scottish-government/design-system/src/forms/checkbox/checkboxes"));
10
+ const hint_text_1 = __importDefault(require("../../common/hint-text"));
11
+ const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onChange, small }) => {
12
+ const hintTextId = `hint-text-${id}`;
13
+ const behaviour = exclusive && 'exclusive';
14
+ function handleBlur(event) {
15
+ if (typeof onBlur === 'function') {
16
+ onBlur(event);
17
+ }
18
+ }
19
+ function handleChange(event) {
20
+ if (typeof onChange === 'function') {
21
+ onChange(event);
22
+ }
23
+ }
24
+ return (<>
25
+ {exclusive && <p className="ds_checkbox-separator">or</p>}
26
+ <div className={[
27
+ 'ds_checkbox',
28
+ small && 'ds_checkbox--small'
29
+ ].join(' ')}>
30
+
31
+ <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"/>
32
+ <label className="ds_checkbox__label" htmlFor={id}>{label}</label>
33
+ {hintText && <hint_text_1.default id={hintTextId} text={hintText}/>}
34
+ </div>
35
+ </>);
36
+ };
37
+ exports.Checkbox = Checkbox;
38
+ /**
39
+ * @param {Object} props - Properties for the element
40
+ * @param {Array} items - Checkboxes
41
+ * @param {boolean} small - Use the small display style for all checkboxes
42
+ * @returns {JSX.Element} - The element
43
+ */
44
+ const CheckboxGroup = ({ className, items, small, ...props }) => {
45
+ const ref = (0, react_1.useRef)(null);
46
+ (0, react_1.useEffect)(() => {
47
+ if (ref.current) {
48
+ new checkboxes_1.default(ref.current).init();
49
+ }
50
+ }, [ref]);
51
+ return (<div className={[
52
+ 'ds_checkboxes',
53
+ 'ds_field-group',
54
+ className
55
+ ].join(' ')} data-module="ds-checkboxes" ref={ref} {...props}>
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}/>))}
57
+ </div>);
58
+ };
59
+ exports.CheckboxGroup = CheckboxGroup;
60
+ exports.Checkbox.displayName = 'Checkbox';
61
+ exports.CheckboxGroup.displayName = 'CheckboxGroup';
62
+ exports.default = exports.CheckboxGroup;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const icon_1 = __importDefault(require("../../common/icon"));
7
+ const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
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}>
13
+ <icon_1.default className="ds_confirmation-message__icon" icon="check_circle" iconSize="24"/>
14
+
15
+ <wrapper_tag_1.default className="ds_confirmation-message__title" tagName={headerLevel}>
16
+ {title}
17
+ </wrapper_tag_1.default>
18
+ {children && <div className="ds_confirmation-message__body">
19
+ {children}
20
+ </div>}
21
+ </div>);
22
+ };
23
+ ConfirmationMessage.displayName = 'ConfirmationMessage';
24
+ exports.default = ConfirmationMessage;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Link = void 0;
7
+ const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
8
+ const Link = ({ current, href, title }) => {
9
+ // determine which HTML tag to use
10
+ const tagName = href && !current ? 'a' : 'span';
11
+ return (<li aria-current={current && 'page' || undefined} className="ds_contents-nav__item">
12
+ <wrapper_tag_1.default tagName={tagName} className={[
13
+ 'ds_contents-nav__link',
14
+ current && 'ds_current'
15
+ ].join(' ')} href={!current ? href : undefined}>
16
+ {title}
17
+ </wrapper_tag_1.default>
18
+ </li>);
19
+ };
20
+ exports.Link = Link;
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}>
26
+ <h2 className="ds_contents-nav__title">{title}</h2>
27
+ <ul className="ds_contents-nav__list">
28
+ {items && items.map((item, index) => (<exports.Link current={item.current} href={item.href} title={item.title} key={'link' + index}/>))}
29
+ </ul>
30
+ </nav>);
31
+ };
32
+ ContentsNav.displayName = 'ContentsNav';
33
+ exports.default = ContentsNav;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("react");
7
+ // @ts-ignore
8
+ const date_picker_1 = __importDefault(require("@scottish-government/design-system/src/components/date-picker/date-picker"));
9
+ const text_input_1 = __importDefault(require("../text-input/text-input"));
10
+ const DatePicker = ({ className, disabledDates, error, errorMessage, hintText, id, iconPath = './', label, maxDate, minDate, multiple, name, onBlur, onChange, value, width = 'fixed-10', ...props }) => {
11
+ // todo: dateSelectCallback function
12
+ const ref = (0, react_1.useRef)(null);
13
+ (0, react_1.useEffect)(() => {
14
+ if (ref.current) {
15
+ new date_picker_1.default(ref.current, { imagePath: iconPath }).init();
16
+ }
17
+ }, [ref, iconPath]);
18
+ function handleBlur(event) {
19
+ if (typeof onBlur === 'function') {
20
+ onBlur(event);
21
+ }
22
+ }
23
+ function handleChange(event) {
24
+ if (typeof onChange === 'function') {
25
+ onChange(event);
26
+ }
27
+ }
28
+ return (<div className={[
29
+ "ds_datepicker",
30
+ multiple && "ds_datepicker--multiple",
31
+ className
32
+ ].join(' ')} data-disableddates={disabledDates} data-maxdate={maxDate} data-mindate={minDate} data-module="ds-datepicker" ref={ref} {...props}>
33
+ {(multiple ? (<fieldset className="ds_datepicker__input-wrapper">
34
+ <legend>{label}</legend>
35
+ <div>
36
+ <text_input_1.default className="js-datepicker-date" error={!!error} id={id + "-day"} hintText={hintText} label="Day" name={name + "-day"} onBlur={handleBlur} onChange={handleChange} value={value?.split('/')[0]} width="fixed-2"/>
37
+ </div>
38
+
39
+ <div>
40
+ <text_input_1.default className="js-datepicker-month" error={!!error} id={id + "-month"} hintText={hintText} label="Month" name={name + "-month"} onBlur={handleBlur} onChange={handleChange} value={value?.split('/')[1]} width="fixed-2"/>
41
+ </div>
42
+
43
+ <div>
44
+ <text_input_1.default className="js-datepicker-year" error={!!error} id={id + "-year"} hintText={hintText} label="Year" name={name + "-year"} onBlur={handleBlur} onChange={handleChange} value={value?.split('/')[2]} width="fixed-4"/>
45
+ </div>
46
+ </fieldset>) : (<text_input_1.default error={!!error} errorMessage={errorMessage} id={id} hasButton hintText={hintText} label={label} name={name} onBlur={handleBlur} onChange={handleChange} placeholder="dd/mm/yyyy" value={value} width={width}/>))}
47
+ </div>);
48
+ };
49
+ DatePicker.displayName = 'DatePicker';
50
+ exports.default = DatePicker;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Details = ({ children, className, summary, ...props }) => {
4
+ return (<details className={[
5
+ "ds_details",
6
+ className
7
+ ].join(' ')} {...props}>
8
+ <summary className="ds_details__summary">
9
+ {summary}
10
+ </summary>
11
+ <div className="ds_details__text">
12
+ {children}
13
+ </div>
14
+ </details>);
15
+ };
16
+ Details.displayName = 'Details';
17
+ exports.default = Details;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ErrorMessage = ({ children, className, id, text, ...props }) => {
4
+ return (<p className={[
5
+ 'ds_question__error-message',
6
+ className
7
+ ].join(' ')} dangerouslySetInnerHTML={text ? { __html: text } : undefined} id={id} {...props}>
8
+ {!text ? children : null}
9
+ </p>);
10
+ };
11
+ ErrorMessage.displayName = 'ErrorMessage';
12
+ exports.default = ErrorMessage;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const InsetText = ({ children, className, ...props }) => {
4
+ return (<div className={[
5
+ 'ds_inset-text',
6
+ className
7
+ ].join(' ')} {...props}>
8
+ <div className="ds_inset-text__text">
9
+ {children}
10
+ </div>
11
+ </div>);
12
+ };
13
+ InsetText.displayName = 'InsetText';
14
+ exports.default = InsetText;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("react");
7
+ // @ts-ignore
8
+ const notification_banner_1 = __importDefault(require("@scottish-government/design-system/src/components/notification-banner/notification-banner"));
9
+ const button_1 = __importDefault(require("../button/button"));
10
+ const icon_1 = __importDefault(require("../../common/icon"));
11
+ const screen_reader_text_1 = __importDefault(require("../../common/screen-reader-text"));
12
+ const NotificationBanner = ({ children, className, close, icon, iconColour, iconInverse, title = 'Information', ...props }) => {
13
+ const ref = (0, react_1.useRef)(null);
14
+ (0, react_1.useEffect)(() => {
15
+ if (ref.current) {
16
+ new notification_banner_1.default(ref.current).init();
17
+ }
18
+ }, [ref]);
19
+ return (<div className={[
20
+ 'ds_notification',
21
+ 'ds_reversed',
22
+ className
23
+ ].join(' ')} data-module="ds-notification" ref={ref} {...props}>
24
+ <div className="ds_wrapper">
25
+ <div className={[
26
+ 'ds_notification__content',
27
+ close && 'ds_notification__content--has-close'
28
+ ].join(' ')}>
29
+ <h2 className="visually-hidden">{title}</h2>
30
+
31
+ {icon &&
32
+ <span className={[
33
+ 'ds_notification__icon',
34
+ iconInverse && 'ds_notification__icon--inverse',
35
+ iconColour && 'ds_notification__icon--colour'
36
+ ].join(' ')} aria-hidden="true">
37
+ <icon_1.default icon="priority_high"/>
38
+ </span>}
39
+
40
+ <div className="ds_notification__text">
41
+ {children}
42
+ </div>
43
+
44
+ {close &&
45
+ <button_1.default className="ds_notification__close js-close-notification">
46
+ <screen_reader_text_1.default>Close this notification</screen_reader_text_1.default>
47
+ <icon_1.default fill icon="close" aria-hidden="true"/>
48
+ </button_1.default>}
49
+ </div>
50
+ </div>
51
+ </div>);
52
+ };
53
+ NotificationBanner.displayName = 'NotificationBanner';
54
+ exports.default = NotificationBanner;
@@ -0,0 +1,21 @@
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 wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
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}>
12
+ <wrapper_tag_1.default className="ds_notification-panel__title" tagName={headerLevel}>
13
+ {title}
14
+ </wrapper_tag_1.default>
15
+ <div className="ds_notification-panel__content">
16
+ {children}
17
+ </div>
18
+ </div>);
19
+ };
20
+ NotificationPanel.displayName = 'NotificationPanel';
21
+ exports.default = NotificationPanel;