@scottish-government/designsystem-react 0.0.2 → 0.1.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.
- package/dist/common/conditional-wrapper.jsx +8 -0
- package/dist/common/hint-text.jsx +9 -0
- package/dist/common/icon.jsx +14 -0
- package/dist/common/screen-reader-text.jsx +9 -0
- package/dist/common/wrapper-tag.jsx +11 -0
- package/dist/components/accordion/accordion.jsx +97 -0
- package/dist/components/aspect-box/aspect-box.jsx +78 -0
- package/dist/components/back-to-top/back-to-top.jsx +24 -0
- package/dist/components/breadcrumbs/breadcrumbs.jsx +28 -0
- package/dist/components/button/button.jsx +29 -0
- package/dist/components/checkbox/checkbox.jsx +58 -0
- package/dist/components/confirmation-message/confirmation-message.jsx +21 -0
- package/dist/components/contents-nav/contents-nav.jsx +30 -0
- package/dist/components/date-picker/date-picker.jsx +49 -0
- package/dist/components/details/details.jsx +16 -0
- package/dist/components/error-message/error-message.jsx +11 -0
- package/dist/components/inset-text/inset-text.jsx +11 -0
- package/dist/components/notification-banner/notification-banner.jsx +50 -0
- package/dist/components/notification-panel/notification-panel.jsx +18 -0
- package/dist/components/page-header/page-header.jsx +12 -0
- package/dist/components/page-metadata/page-metadata.jsx +23 -0
- package/dist/components/phase-banner/phase-banner.jsx +20 -0
- package/dist/components/question/question.jsx +21 -0
- package/dist/components/radio-button/radio-button.jsx +42 -0
- package/dist/components/select/select.jsx +51 -0
- package/dist/components/sequential-navigation/sequential-navigation.jsx +28 -0
- package/dist/components/side-navigation/side-navigation.jsx +49 -0
- package/dist/components/site-navigation/site-navigation.jsx +19 -0
- package/dist/components/site-search/site-search.jsx +54 -0
- package/dist/components/skip-links/skip-links.jsx +21 -0
- package/dist/components/tag/tag.jsx +13 -0
- package/dist/components/task-list/task-list.jsx +90 -0
- package/dist/components/text-input/text-input.jsx +58 -0
- package/dist/components/textarea/textarea.jsx +53 -0
- package/dist/components/warning-text/warning-text.jsx +13 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/.github/workflows/release-package.yml +0 -96
|
@@ -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,97 @@
|
|
|
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, headerLevel = 'h3', id: rawId, open = false, title, ...props }) => {
|
|
46
|
+
accordionItemCounter = accordionItemCounter + 1;
|
|
47
|
+
const processedId = rawId || `accordion-item-${accordionItemCounter}`;
|
|
48
|
+
return (<div className="ds_accordion-item" id={processedId} {...props}>
|
|
49
|
+
<input aria-labelledby={`panel-${processedId}-heading`} className={[
|
|
50
|
+
'ds_accordion-item__control',
|
|
51
|
+
'visually-hidden'
|
|
52
|
+
].join(' ')} defaultChecked={open} id={`${processedId}-control`} type="checkbox"/>
|
|
53
|
+
<div className="ds_accordion-item__header">
|
|
54
|
+
<wrapper_tag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headerLevel}>
|
|
55
|
+
{title}
|
|
56
|
+
</wrapper_tag_1.default>
|
|
57
|
+
<span className='ds_accordion-item__indicator'/>
|
|
58
|
+
<label className="ds_accordion-item__label" htmlFor={`${processedId}-control`}>
|
|
59
|
+
<span className="visually-hidden">Show this section</span>
|
|
60
|
+
</label>
|
|
61
|
+
</div>
|
|
62
|
+
<div className="ds_accordion-item__body">
|
|
63
|
+
{children}
|
|
64
|
+
</div>
|
|
65
|
+
</div>);
|
|
66
|
+
};
|
|
67
|
+
exports.AccordionItem = AccordionItem;
|
|
68
|
+
const Accordion = ({ children, headerLevel = 'h3', hideOpenAll, ...props }) => {
|
|
69
|
+
const ref = (0, react_1.useRef)(null);
|
|
70
|
+
(0, react_1.useEffect)(() => {
|
|
71
|
+
if (ref.current) {
|
|
72
|
+
new accordion_1.default(ref.current).init();
|
|
73
|
+
}
|
|
74
|
+
}, [ref]);
|
|
75
|
+
if (!children) {
|
|
76
|
+
hideOpenAll = true;
|
|
77
|
+
}
|
|
78
|
+
function processChild(child) {
|
|
79
|
+
return react_1.default.cloneElement(child, { headerLevel: headerLevel });
|
|
80
|
+
}
|
|
81
|
+
return (<div className='ds_accordion' ref={ref} {...props}>
|
|
82
|
+
{!hideOpenAll && (<button className={[
|
|
83
|
+
'ds_accordion__open-all',
|
|
84
|
+
'ds_link',
|
|
85
|
+
'js-open-all'
|
|
86
|
+
].join(' ')} type='button'>
|
|
87
|
+
Open all
|
|
88
|
+
{' '}
|
|
89
|
+
<span className="visually-hidden">sections</span>
|
|
90
|
+
</button>)}
|
|
91
|
+
|
|
92
|
+
{react_1.Children.map(children, child => processChild(child))}
|
|
93
|
+
</div>);
|
|
94
|
+
};
|
|
95
|
+
Accordion.displayName = 'Accordion';
|
|
96
|
+
exports.AccordionItem.displayName = 'AccordionItem';
|
|
97
|
+
exports.default = Accordion;
|
|
@@ -0,0 +1,78 @@
|
|
|
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, 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
|
+
].join(' ')} ref={ref} {...props}>
|
|
74
|
+
{react_1.Children.map(children, child => processChild(child))}
|
|
75
|
+
</div>);
|
|
76
|
+
};
|
|
77
|
+
AspectBox.displayName = 'AspectBox';
|
|
78
|
+
exports.default = AspectBox;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const 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 = ({ 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='ds_back-to-top' ref={ref} {...props}>
|
|
18
|
+
<a href={href} className="ds_back-to-top__button">Back to top
|
|
19
|
+
<icon_1.default className="ds_back-to-top__icon" icon="arrow_upward"/>
|
|
20
|
+
</a>
|
|
21
|
+
</div>);
|
|
22
|
+
};
|
|
23
|
+
BackToTop.displayName = 'BackToTop';
|
|
24
|
+
exports.default = BackToTop;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Breadcrumb = ({ hidden, href, title }) => {
|
|
4
|
+
return (<li className={[
|
|
5
|
+
'ds_breadcrumbs__item',
|
|
6
|
+
hidden && 'visually-hidden'
|
|
7
|
+
].join(' ')}>
|
|
8
|
+
|
|
9
|
+
{href ? (<a className="ds_breadcrumbs__link" href={href}>
|
|
10
|
+
{title}
|
|
11
|
+
</a>) : (title)}
|
|
12
|
+
</li>);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @param {boolean} hideLastItem
|
|
16
|
+
* @param {Array} items
|
|
17
|
+
* @param {Object} props - Properties for the element
|
|
18
|
+
* @returns {JSX.Element} - The element
|
|
19
|
+
*/
|
|
20
|
+
const Breadcrumbs = ({ hideLastItem, items, ...props }) => {
|
|
21
|
+
return (<nav aria-label="Breadcrumb" {...props}>
|
|
22
|
+
<ol className="ds_breadcrumbs">
|
|
23
|
+
{items && items.map((item, index) => (<Breadcrumb title={item.title} href={item.href} hidden={(hideLastItem) && index + 1 === items.length} key={'breadcrumb' + index}/>))}
|
|
24
|
+
</ol>
|
|
25
|
+
</nav>);
|
|
26
|
+
};
|
|
27
|
+
Breadcrumbs.displayName = 'Breadcrumbs';
|
|
28
|
+
exports.default = Breadcrumbs;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 = ({ children, buttonStyle, 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
|
+
].join(' ')} href={href} {...(tagName === 'button' ? { type: type } : {})} {...props}>
|
|
23
|
+
{iconOnly ? <screen_reader_text_1.default>{children}</screen_reader_text_1.default> : children}
|
|
24
|
+
|
|
25
|
+
{icon && <icon_1.default icon={icon}/>}
|
|
26
|
+
</wrapper_tag_1.default>);
|
|
27
|
+
};
|
|
28
|
+
Button.displayName = 'Button';
|
|
29
|
+
exports.default = Button;
|
|
@@ -0,0 +1,58 @@
|
|
|
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 = ({ 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="ds_checkboxes ds_field-group" data-module="ds-checkboxes" ref={ref} {...props}>
|
|
52
|
+
{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
|
+
</div>);
|
|
54
|
+
};
|
|
55
|
+
exports.CheckboxGroup = CheckboxGroup;
|
|
56
|
+
exports.Checkbox.displayName = 'Checkbox';
|
|
57
|
+
exports.CheckboxGroup.displayName = 'CheckboxGroup';
|
|
58
|
+
exports.default = exports.CheckboxGroup;
|
|
@@ -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 icon_1 = __importDefault(require("../../common/icon"));
|
|
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">
|
|
10
|
+
<icon_1.default className="ds_confirmation-message__icon" icon="check_circle" iconSize="24"/>
|
|
11
|
+
|
|
12
|
+
<wrapper_tag_1.default className="ds_confirmation-message__title" tagName={headerLevel}>
|
|
13
|
+
{title}
|
|
14
|
+
</wrapper_tag_1.default>
|
|
15
|
+
{children && <div className="ds_confirmation-message__body">
|
|
16
|
+
{children}
|
|
17
|
+
</div>}
|
|
18
|
+
</div>);
|
|
19
|
+
};
|
|
20
|
+
ConfirmationMessage.displayName = 'ConfirmationMessage';
|
|
21
|
+
exports.default = ConfirmationMessage;
|
|
@@ -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
|
+
exports.Link = void 0;
|
|
7
|
+
const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
|
|
8
|
+
const Link = ({ title, current, href }) => {
|
|
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 ({ items, label = 'Pages in this section', title = 'Contents', ...props }) {
|
|
22
|
+
return (<nav aria-label={label} className="ds_contents-nav" {...props}>
|
|
23
|
+
<h2 className="ds_contents-nav__title">{title}</h2>
|
|
24
|
+
<ul className="ds_contents-nav__list">
|
|
25
|
+
{items && items.map((item, index) => (<exports.Link current={item.current} href={item.href} title={item.title} key={'link' + index}/>))}
|
|
26
|
+
</ul>
|
|
27
|
+
</nav>);
|
|
28
|
+
};
|
|
29
|
+
ContentsNav.displayName = 'ContentsNav';
|
|
30
|
+
exports.default = ContentsNav;
|
|
@@ -0,0 +1,49 @@
|
|
|
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 = ({ width = 'fixed-10', disabledDates, error, errorMessage, hintText, id, iconPath = './', label, maxDate, minDate, multiple, name, onBlur, onChange, value, ...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
|
+
].join(' ')} data-disableddates={disabledDates} data-maxdate={maxDate} data-mindate={minDate} data-module="ds-datepicker" ref={ref} {...props}>
|
|
32
|
+
{(multiple ? (<fieldset className="ds_datepicker__input-wrapper">
|
|
33
|
+
<legend>{label}</legend>
|
|
34
|
+
<div>
|
|
35
|
+
<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"/>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div>
|
|
39
|
+
<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"/>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div>
|
|
43
|
+
<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"/>
|
|
44
|
+
</div>
|
|
45
|
+
</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}/>))}
|
|
46
|
+
</div>);
|
|
47
|
+
};
|
|
48
|
+
DatePicker.displayName = 'DatePicker';
|
|
49
|
+
exports.default = DatePicker;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Details = ({ children, summary, ...props }) => {
|
|
4
|
+
return (<details className={[
|
|
5
|
+
"ds_details",
|
|
6
|
+
].join(' ')} {...props}>
|
|
7
|
+
<summary className="ds_details__summary">
|
|
8
|
+
{summary}
|
|
9
|
+
</summary>
|
|
10
|
+
<div className="ds_details__text">
|
|
11
|
+
{children}
|
|
12
|
+
</div>
|
|
13
|
+
</details>);
|
|
14
|
+
};
|
|
15
|
+
Details.displayName = 'Details';
|
|
16
|
+
exports.default = Details;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ErrorMessage = ({ children, id, text, ...props }) => {
|
|
4
|
+
return (<p className={[
|
|
5
|
+
'ds_question__error-message',
|
|
6
|
+
].join(' ')} dangerouslySetInnerHTML={text ? { __html: text } : undefined} id={id} {...props}>
|
|
7
|
+
{!text ? children : null}
|
|
8
|
+
</p>);
|
|
9
|
+
};
|
|
10
|
+
ErrorMessage.displayName = 'ErrorMessage';
|
|
11
|
+
exports.default = ErrorMessage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const InsetText = ({ children, ...props }) => {
|
|
4
|
+
return (<div className="ds_inset-text" {...props}>
|
|
5
|
+
<div className="ds_inset-text__text">
|
|
6
|
+
{children}
|
|
7
|
+
</div>
|
|
8
|
+
</div>);
|
|
9
|
+
};
|
|
10
|
+
InsetText.displayName = 'InsetText';
|
|
11
|
+
exports.default = InsetText;
|
|
@@ -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 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, 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="ds_notification ds_reversed" data-module="ds-notification" ref={ref} {...props}>
|
|
20
|
+
<div className="ds_wrapper">
|
|
21
|
+
<div className={[
|
|
22
|
+
'ds_notification__content',
|
|
23
|
+
close && 'ds_notification__content--has-close'
|
|
24
|
+
].join(' ')}>
|
|
25
|
+
<h2 className="visually-hidden">{title}</h2>
|
|
26
|
+
|
|
27
|
+
{icon &&
|
|
28
|
+
<span className={[
|
|
29
|
+
'ds_notification__icon',
|
|
30
|
+
iconInverse && 'ds_notification__icon--inverse',
|
|
31
|
+
iconColour && 'ds_notification__icon--colour'
|
|
32
|
+
].join(' ')} aria-hidden="true">
|
|
33
|
+
<icon_1.default icon="priority_high"/>
|
|
34
|
+
</span>}
|
|
35
|
+
|
|
36
|
+
<div className="ds_notification__text">
|
|
37
|
+
{children}
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
{close &&
|
|
41
|
+
<button_1.default className="ds_notification__close js-close-notification">
|
|
42
|
+
<screen_reader_text_1.default>Close this notification</screen_reader_text_1.default>
|
|
43
|
+
<icon_1.default fill icon="close" aria-hidden="true"/>
|
|
44
|
+
</button_1.default>}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>);
|
|
48
|
+
};
|
|
49
|
+
NotificationBanner.displayName = 'NotificationBanner';
|
|
50
|
+
exports.default = NotificationBanner;
|
|
@@ -0,0 +1,18 @@
|
|
|
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, headerLevel = 'h1', title, ...props }) {
|
|
8
|
+
return (<div aria-live={ariaLive} className="ds_notification-panel" {...props}>
|
|
9
|
+
<wrapper_tag_1.default className="ds_notification-panel__title" tagName={headerLevel}>
|
|
10
|
+
{title}
|
|
11
|
+
</wrapper_tag_1.default>
|
|
12
|
+
<div className="ds_notification-panel__content">
|
|
13
|
+
{children}
|
|
14
|
+
</div>
|
|
15
|
+
</div>);
|
|
16
|
+
};
|
|
17
|
+
NotificationPanel.displayName = 'NotificationPanel';
|
|
18
|
+
exports.default = NotificationPanel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const PageHeader = ({ children, label, title, ...props }) => {
|
|
4
|
+
return (<header className="ds_page-header" {...props}>
|
|
5
|
+
{label && <span className="ds_page-header__label ds_content-label">{label}</span>}
|
|
6
|
+
<h1 className="ds_page-header__title">{title}</h1>
|
|
7
|
+
|
|
8
|
+
{children}
|
|
9
|
+
</header>);
|
|
10
|
+
};
|
|
11
|
+
PageHeader.displayName = 'PageHeader';
|
|
12
|
+
exports.default = PageHeader;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetadataItem = void 0;
|
|
4
|
+
const MetadataItem = ({ children, name, ...props }) => {
|
|
5
|
+
return (<div className="ds_metadata__item" {...props}>
|
|
6
|
+
<dt className="ds_metadata__key">{name}</dt>{' '}
|
|
7
|
+
<dd className="ds_metadata__value">
|
|
8
|
+
{children}
|
|
9
|
+
</dd>
|
|
10
|
+
</div>);
|
|
11
|
+
};
|
|
12
|
+
exports.MetadataItem = MetadataItem;
|
|
13
|
+
const Metadata = ({ children, inline, ...props }) => {
|
|
14
|
+
return (<dl className={[
|
|
15
|
+
'ds_metadata',
|
|
16
|
+
inline && 'ds_metadata--inline',
|
|
17
|
+
].join(' ')} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</dl>);
|
|
20
|
+
};
|
|
21
|
+
Metadata.displayName = 'Metadata';
|
|
22
|
+
exports.MetadataItem.displayName = 'MetadataItem';
|
|
23
|
+
exports.default = Metadata;
|