@scottish-government/designsystem-react 0.7.1 → 0.8.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/@types/common/AbstractNotificationBanner.d.ts +2 -2
- package/@types/common/ActionLink.d.ts +8 -0
- package/@types/common/FileIcon.d.ts +1 -1
- package/@types/common/Icon.d.ts +1 -1
- package/@types/components/Breadcrumbs.d.ts +2 -5
- package/@types/components/Checkbox.d.ts +0 -2
- package/@types/components/ConfirmationMessage.d.ts +1 -1
- package/@types/components/ContentsNav.d.ts +4 -6
- package/@types/components/DatePicker.d.ts +1 -1
- package/@types/components/ErrorSummary.d.ts +3 -4
- package/@types/components/NotificationPanel.d.ts +1 -1
- package/@types/components/Pagination.d.ts +5 -4
- package/@types/components/PhaseBanner.d.ts +0 -1
- package/@types/components/Question.d.ts +1 -1
- package/@types/components/RadioButton.d.ts +0 -1
- package/@types/components/Select.d.ts +0 -7
- package/@types/components/SequentialNavigation.d.ts +4 -4
- package/@types/components/SideNavigation.d.ts +4 -5
- package/@types/components/SiteFooter.d.ts +25 -0
- package/@types/components/SiteHeader.d.ts +10 -3
- package/@types/components/SiteNavigation.d.ts +2 -3
- package/@types/components/SkipLinks.d.ts +3 -4
- package/@types/components/SummaryCard.d.ts +0 -2
- package/@types/components/SummaryList.d.ts +0 -13
- package/@types/components/Tabs.d.ts +0 -1
- package/@types/components/Tag.d.ts +1 -3
- package/@types/components/TaskList.d.ts +1 -0
- package/@types/sgds.d.ts +13 -2
- package/CHANGELOG.md +63 -1
- package/dist/common/AbstractNotificationBanner.jsx +8 -6
- package/dist/common/ActionLink.jsx +19 -0
- package/dist/common/FileIcon.jsx +2 -7
- package/dist/common/Icon.jsx +3 -9
- package/dist/components/Accordion/Accordion.jsx +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +20 -15
- package/dist/components/Checkbox/Checkbox.jsx +2 -30
- package/dist/components/Checkbox/CheckboxGroup.jsx +69 -0
- package/dist/components/ContentsNav/ContentsNav.jsx +27 -16
- package/dist/components/CookieBanner/CookieBanner.jsx +1 -0
- package/dist/components/DatePicker/DatePicker.jsx +5 -5
- package/dist/components/ErrorSummary/ErrorSummary.jsx +28 -18
- package/dist/components/NotificationBanner/NotificationBanner.jsx +2 -2
- package/dist/components/Pagination/Pagination.jsx +42 -22
- package/dist/components/PhaseBanner/PhaseBanner.jsx +3 -3
- package/dist/components/Question/Question.jsx +3 -3
- package/dist/components/RadioButton/RadioButton.jsx +3 -17
- package/dist/components/RadioButton/RadioGroup.jsx +61 -0
- package/dist/components/Select/Select.jsx +4 -7
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +31 -18
- package/dist/components/SideNavigation/SideNavigation.jsx +17 -16
- package/dist/components/SiteFooter/SiteFooter.jsx +104 -0
- package/dist/components/SiteHeader/SiteHeader.jsx +113 -32
- package/dist/components/SiteNavigation/SiteNavigation.jsx +20 -7
- package/dist/components/SkipLinks/SkipLinks.jsx +10 -10
- package/dist/components/SummaryCard/SummaryCard.jsx +25 -14
- package/dist/components/SummaryList/SummaryList.jsx +65 -47
- package/dist/components/Tabs/Tabs.jsx +6 -6
- package/dist/components/Tag/Tag.jsx +2 -2
- package/dist/components/TaskList/TaskList.jsx +14 -3
- package/dist/components/TextInput/TextInput.jsx +3 -3
- package/dist/components/Textarea/Textarea.jsx +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/AbstractNotificationBanner.test.tsx +1 -1
- package/src/common/AbstractNotificationBanner.tsx +14 -13
- package/src/common/ActionLink.test.tsx +80 -0
- package/src/common/ActionLink.tsx +27 -0
- package/src/common/ConditionalWrapper.tsx +1 -1
- package/src/common/FileIcon.tsx +7 -11
- package/src/common/HintText.tsx +2 -2
- package/src/common/Icon.tsx +13 -17
- package/src/common/ScreenReaderText.tsx +2 -2
- package/src/common/WrapperTag.tsx +2 -2
- package/src/components/Accordion/Accordion.test.tsx +1 -1
- package/src/components/Accordion/Accordion.tsx +6 -7
- package/src/components/AspectBox/AspectBox.tsx +2 -2
- package/src/components/BackToTop/BackToTop.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +79 -47
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +31 -31
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/Checkbox/Checkbox.test.tsx +1 -96
- package/src/components/Checkbox/Checkbox.tsx +3 -55
- package/src/components/Checkbox/CheckboxGroup.test.tsx +37 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +46 -0
- package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +2 -2
- package/src/components/ContentsNav/ContentsNav.test.tsx +40 -51
- package/src/components/ContentsNav/ContentsNav.tsx +32 -25
- package/src/components/CookieBanner/CookieBanner.tsx +3 -3
- package/src/components/DatePicker/DatePicker.test.tsx +1 -1
- package/src/components/DatePicker/DatePicker.tsx +7 -7
- package/src/components/Details/Details.tsx +2 -2
- package/src/components/ErrorMessage/ErrorMessage.tsx +2 -2
- package/src/components/ErrorSummary/ErrorSummary.test.tsx +40 -34
- package/src/components/ErrorSummary/ErrorSummary.tsx +40 -32
- package/src/components/FileDownload/FileDownload.tsx +2 -2
- package/src/components/HideThisPage/HideThisPage.tsx +2 -2
- package/src/components/InsetText/InsetText.tsx +2 -2
- package/src/components/NotificationBanner/NotificationBanner.tsx +6 -7
- package/src/components/NotificationPanel/NotificationPanel.tsx +2 -2
- package/src/components/PageHeader/PageHeader.tsx +2 -2
- package/src/components/PageMetadata/PageMetadata.tsx +4 -5
- package/src/components/Pagination/Pagination.test.tsx +26 -7
- package/src/components/Pagination/Pagination.tsx +70 -36
- package/src/components/PhaseBanner/PhaseBanner.tsx +4 -5
- package/src/components/Question/Question.test.tsx +1 -1
- package/src/components/Question/Question.tsx +5 -5
- package/src/components/RadioButton/RadioButton.test.tsx +7 -126
- package/src/components/RadioButton/RadioButton.tsx +4 -41
- package/src/components/RadioButton/RadioGroup.test.tsx +65 -0
- package/src/components/RadioButton/RadioGroup.tsx +38 -0
- package/src/components/Select/Select.test.tsx +39 -37
- package/src/components/Select/Select.tsx +7 -22
- package/src/components/SequentialNavigation/SequentialNavigation.test.tsx +32 -21
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +52 -30
- package/src/components/SideNavigation/SideNavigation.test.tsx +39 -85
- package/src/components/SideNavigation/SideNavigation.tsx +27 -29
- package/src/components/SiteFooter/SiteFooter.test.tsx +153 -0
- package/src/components/SiteFooter/SiteFooter.tsx +107 -0
- package/src/components/SiteHeader/SiteHeader.test.tsx +87 -79
- package/src/components/SiteHeader/SiteHeader.tsx +103 -40
- package/src/components/SiteNavigation/SiteNavigation.test.tsx +42 -23
- package/src/components/SiteNavigation/SiteNavigation.tsx +28 -16
- package/src/components/SiteSearch/SiteSearch.tsx +2 -2
- package/src/components/SkipLinks/SkipLinks.test.tsx +22 -10
- package/src/components/SkipLinks/SkipLinks.tsx +16 -15
- package/src/components/SummaryCard/SummaryCard.test.tsx +31 -35
- package/src/components/SummaryCard/SummaryCard.tsx +39 -28
- package/src/components/SummaryList/SummaryList.test.tsx +49 -148
- package/src/components/SummaryList/SummaryList.tsx +54 -92
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/Tabs/Tabs.tsx +14 -15
- package/src/components/Tag/Tag.test.tsx +4 -4
- package/src/components/Tag/Tag.tsx +4 -4
- package/src/components/TaskList/TaskList.test.tsx +26 -0
- package/src/components/TaskList/TaskList.tsx +21 -11
- package/src/components/TextInput/TextInput.test.tsx +1 -1
- package/src/components/TextInput/TextInput.tsx +5 -5
- package/src/components/Textarea/Textarea.test.tsx +1 -1
- package/src/components/Textarea/Textarea.tsx +5 -5
- package/src/components/WarningText/WarningText.tsx +2 -2
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const BreadcrumbItem = ({ children, isHidden, href, linkComponent, ...props }) => {
|
|
4
|
+
const BREADCRUMB_LINK_CLASSNAME = 'ds_breadcrumbs__link';
|
|
5
|
+
function processChildren(children) {
|
|
6
|
+
if (linkComponent) {
|
|
7
|
+
return linkComponent({ className: BREADCRUMB_LINK_CLASSNAME, href, children });
|
|
8
|
+
}
|
|
9
|
+
else if (href) {
|
|
10
|
+
return <a href={href} className={BREADCRUMB_LINK_CLASSNAME}>{children}</a>;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return children;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
4
16
|
return (<li className={[
|
|
5
17
|
'ds_breadcrumbs__item',
|
|
6
|
-
|
|
7
|
-
].join(' ')}>
|
|
8
|
-
|
|
9
|
-
{href ? (<a className="ds_breadcrumbs__link" href={href}>
|
|
10
|
-
{title}
|
|
11
|
-
</a>) : (title)}
|
|
18
|
+
isHidden && 'visually-hidden'
|
|
19
|
+
].join(' ')} {...props}>
|
|
20
|
+
{processChildren(children)}
|
|
12
21
|
</li>);
|
|
13
22
|
};
|
|
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 }) => {
|
|
23
|
+
const Breadcrumbs = ({ children, ...props }) => {
|
|
21
24
|
return (<nav aria-label="Breadcrumb" {...props}>
|
|
22
25
|
<ol className="ds_breadcrumbs">
|
|
23
|
-
{
|
|
26
|
+
{children}
|
|
24
27
|
</ol>
|
|
25
28
|
</nav>);
|
|
26
29
|
};
|
|
27
30
|
Breadcrumbs.displayName = 'Breadcrumbs';
|
|
31
|
+
BreadcrumbItem.displayName = 'Breadcrumbs.Item';
|
|
32
|
+
Breadcrumbs.Item = BreadcrumbItem;
|
|
28
33
|
exports.default = Breadcrumbs;
|
|
@@ -3,10 +3,6 @@ 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
|
-
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
6
|
const HintText_1 = __importDefault(require("../../common/HintText"));
|
|
11
7
|
const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onChange, small }) => {
|
|
12
8
|
const hintTextId = `hint-text-${id}`;
|
|
@@ -34,29 +30,5 @@ const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onCha
|
|
|
34
30
|
</div>
|
|
35
31
|
</>);
|
|
36
32
|
};
|
|
37
|
-
|
|
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;
|
|
33
|
+
Checkbox.displayName = 'Checkbox';
|
|
34
|
+
exports.default = Checkbox;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.CheckboxGroup = void 0;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const Checkbox_1 = __importDefault(require("./Checkbox"));
|
|
42
|
+
// @ts-ignore
|
|
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
|
+
}
|
|
53
|
+
const ref = (0, react_1.useRef)(null);
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
if (ref.current) {
|
|
56
|
+
new checkboxes_1.default(ref.current).init();
|
|
57
|
+
}
|
|
58
|
+
}, [ref]);
|
|
59
|
+
return (<div className={[
|
|
60
|
+
'ds_checkboxes',
|
|
61
|
+
'ds_field-group',
|
|
62
|
+
className
|
|
63
|
+
].join(' ')} data-module="ds-checkboxes" ref={ref} {...props}>
|
|
64
|
+
{react_1.Children.map(children, child => processChild(child))}
|
|
65
|
+
</div>);
|
|
66
|
+
};
|
|
67
|
+
exports.CheckboxGroup = CheckboxGroup;
|
|
68
|
+
exports.CheckboxGroup.displayName = 'CheckboxGroup';
|
|
69
|
+
exports.default = exports.CheckboxGroup;
|
|
@@ -3,31 +3,42 @@ 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
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const ContentsNavItem = ({ children, current, href, linkComponent }) => {
|
|
8
|
+
const classNames = ['ds_contents-nav__link'];
|
|
9
|
+
let ariaCurrent;
|
|
10
|
+
if (current) {
|
|
11
|
+
classNames.push('ds_current');
|
|
12
|
+
ariaCurrent = 'page';
|
|
13
|
+
}
|
|
14
|
+
function processChildren(children) {
|
|
15
|
+
if (linkComponent) {
|
|
16
|
+
return linkComponent({ className: classNames.join(' '), href, children });
|
|
17
|
+
}
|
|
18
|
+
else if (href) {
|
|
19
|
+
return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNames.join(' ')}>{children}</a>;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return <span aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNames.join(' ')}>{children}</span>;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return (<li className="ds_contents-nav__item">
|
|
26
|
+
{processChildren(children)}
|
|
18
27
|
</li>);
|
|
19
28
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (<nav aria-label={label} className={[
|
|
29
|
+
const ContentsNav = ({ ariaLabel = 'Pages in this section', children, className, title = 'Contents', ...props }) => {
|
|
30
|
+
return (<nav aria-label={ariaLabel} className={[
|
|
23
31
|
'ds_contents-nav',
|
|
24
32
|
className
|
|
25
33
|
].join(' ')} {...props}>
|
|
26
34
|
<h2 className="ds_contents-nav__title">{title}</h2>
|
|
35
|
+
|
|
27
36
|
<ul className="ds_contents-nav__list">
|
|
28
|
-
{
|
|
37
|
+
{children}
|
|
29
38
|
</ul>
|
|
30
39
|
</nav>);
|
|
31
40
|
};
|
|
32
41
|
ContentsNav.displayName = 'ContentsNav';
|
|
42
|
+
ContentsNavItem.displayName = 'ContentsNav.Item';
|
|
43
|
+
ContentsNav.Item = ContentsNavItem;
|
|
33
44
|
exports.default = ContentsNav;
|
|
@@ -18,4 +18,5 @@ const CookieBanner = ({ children, className, title, ...props }) => {
|
|
|
18
18
|
};
|
|
19
19
|
CookieBanner.displayName = 'CookieBanner';
|
|
20
20
|
CookieBanner.Buttons = AbstractNotificationBanner_1.default.Buttons;
|
|
21
|
+
CookieBanner.Buttons.displayName = 'CookieBanner.Buttons';
|
|
21
22
|
exports.default = CookieBanner;
|
|
@@ -8,7 +8,7 @@ const react_1 = require("react");
|
|
|
8
8
|
const date_picker_1 = __importDefault(require("@scottish-government/design-system/src/components/date-picker/date-picker"));
|
|
9
9
|
const ErrorMessage_1 = __importDefault(require("../ErrorMessage/ErrorMessage"));
|
|
10
10
|
const TextInput_1 = __importDefault(require("../TextInput/TextInput"));
|
|
11
|
-
const DatePicker = ({ className, dateSelectCallback, disabledDates,
|
|
11
|
+
const DatePicker = ({ className, dateSelectCallback, disabledDates, errorMessage, hasError, hintText, id, iconPath = './', label, maxDate, minDate, multiple, name, onBlur, onChange, value, width = 'fixed-10', ...props }) => {
|
|
12
12
|
const ref = (0, react_1.useRef)(null);
|
|
13
13
|
(0, react_1.useEffect)(() => {
|
|
14
14
|
if (ref.current) {
|
|
@@ -37,17 +37,17 @@ const DatePicker = ({ className, dateSelectCallback, disabledDates, error, error
|
|
|
37
37
|
<legend>{label}</legend>
|
|
38
38
|
{errorMessage && <ErrorMessage_1.default text={errorMessage}/>}
|
|
39
39
|
<div>
|
|
40
|
-
<TextInput_1.default className="js-datepicker-date"
|
|
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>
|
|
42
42
|
|
|
43
43
|
<div>
|
|
44
|
-
<TextInput_1.default className="js-datepicker-month"
|
|
44
|
+
<TextInput_1.default className="js-datepicker-month" hasError={!!hasError} id={id + "-month"} hintText={hintText} label="Month" name={name + "-month"} onBlur={handleBlur} onChange={handleChange} value={value?.split('/')[1]} width="fixed-2"/>
|
|
45
45
|
</div>
|
|
46
46
|
|
|
47
47
|
<div>
|
|
48
|
-
<TextInput_1.default className="js-datepicker-year"
|
|
48
|
+
<TextInput_1.default className="js-datepicker-year" hasError={!!hasError} id={id + "-year"} hintText={hintText} label="Year" name={name + "-year"} onBlur={handleBlur} onChange={handleChange} value={value?.split('/')[2]} width="fixed-4"/>
|
|
49
49
|
</div>
|
|
50
|
-
</fieldset>) : (<TextInput_1.default
|
|
50
|
+
</fieldset>) : (<TextInput_1.default hasError={!!hasError} errorMessage={errorMessage} id={id} hasButton hintText={hintText} label={label} name={name} onBlur={handleBlur} onChange={handleChange} placeholder="dd/mm/yyyy" value={value} width={width}/>))}
|
|
51
51
|
</div>);
|
|
52
52
|
};
|
|
53
53
|
DatePicker.displayName = 'DatePicker';
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const ErrorSummaryItem = ({ children, fragmentId, linkComponent }) => {
|
|
5
|
+
const HREF = '#' + fragmentId;
|
|
6
|
+
function processChildren(children) {
|
|
7
|
+
if (linkComponent) {
|
|
8
|
+
return linkComponent({ className: '', href: HREF, children });
|
|
9
|
+
}
|
|
10
|
+
else if (fragmentId) {
|
|
11
|
+
return <a href={HREF}>{children}</a>;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return children;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
return (<li>
|
|
9
|
-
|
|
18
|
+
{processChildren(children)}
|
|
10
19
|
</li>);
|
|
11
20
|
};
|
|
12
|
-
const ErrorSummary = ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
const ErrorSummary = ({ children, className, title = 'There is a problem', ...props }) => {
|
|
22
|
+
const summaryTitleId = (0, react_1.useId)();
|
|
23
|
+
return (<div className={[
|
|
24
|
+
'ds_error-summary',
|
|
25
|
+
className
|
|
26
|
+
].join(' ')} aria-labelledby={summaryTitleId} role="alert" {...props}>
|
|
27
|
+
<h2 className="ds_error-summary__title" id={summaryTitleId}>{title}</h2>
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
</>);
|
|
29
|
+
<ul className="ds_error-summary__list">
|
|
30
|
+
{children}
|
|
31
|
+
</ul>
|
|
32
|
+
</div>);
|
|
25
33
|
};
|
|
26
34
|
ErrorSummary.displayName = 'ErrorSummary';
|
|
35
|
+
ErrorSummaryItem.displayName = 'ErrorSummary.Item';
|
|
36
|
+
ErrorSummary.Item = ErrorSummaryItem;
|
|
27
37
|
exports.default = ErrorSummary;
|
|
@@ -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,
|
|
10
|
+
const NotificationBanner = ({ children, className, close, hasColourIcon, hasInverseIcon, icon, 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, icon, iconColour, icon
|
|
|
17
17
|
return (<AbstractNotificationBanner_1.default className={[
|
|
18
18
|
'ds_reversed',
|
|
19
19
|
className
|
|
20
|
-
].join(' ')} close={close} icon={icon ? "PriorityHigh" : undefined}
|
|
20
|
+
].join(' ')} close={close} icon={icon ? "PriorityHigh" : undefined} hasColourIcon={hasColourIcon} hasInverseIcon={hasInverseIcon} ref={ref} title="Information" {...props}>
|
|
21
21
|
{children}
|
|
22
22
|
</AbstractNotificationBanner_1.default>);
|
|
23
23
|
};
|
|
@@ -5,19 +5,37 @@ 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, current = false, href,
|
|
8
|
+
const Page = ({ ariaLabel, children, className, current = false, href, linkComponent, onClick }) => {
|
|
9
9
|
function handleClick(event) {
|
|
10
10
|
if (typeof onClick === 'function') {
|
|
11
11
|
onClick(event);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
function processChildren(children) {
|
|
15
|
+
const classNames = [
|
|
16
16
|
'ds_pagination__link',
|
|
17
|
+
className,
|
|
17
18
|
current ? 'ds_current' : undefined
|
|
18
|
-
].join(' ')
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
].join(' ');
|
|
20
|
+
const linkProps = {
|
|
21
|
+
'aria-label': ariaLabel,
|
|
22
|
+
href: href,
|
|
23
|
+
onClick: handleClick
|
|
24
|
+
};
|
|
25
|
+
if (current) {
|
|
26
|
+
linkProps['aria-current'] = 'page';
|
|
27
|
+
}
|
|
28
|
+
if (linkComponent) {
|
|
29
|
+
return linkComponent({ className: classNames, children: children, ...linkProps });
|
|
30
|
+
}
|
|
31
|
+
else if (href) {
|
|
32
|
+
return (<a href={href} className={classNames} {...linkProps}>
|
|
33
|
+
{children}
|
|
34
|
+
</a>);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return (<li className="ds_pagination__item">
|
|
38
|
+
{processChildren(children)}
|
|
21
39
|
</li>);
|
|
22
40
|
};
|
|
23
41
|
exports.Page = Page;
|
|
@@ -27,7 +45,7 @@ const Ellipsis = () => {
|
|
|
27
45
|
</li>);
|
|
28
46
|
};
|
|
29
47
|
exports.Ellipsis = Ellipsis;
|
|
30
|
-
const Pagination = ({ ariaLabel = 'Pages', className, onClick, padding = 1, page = 1, pattern = '/search?page=$1', totalPages, ...props }) => {
|
|
48
|
+
const Pagination = ({ ariaLabel = 'Pages', className, onClick, padding = 1, page = 1, pattern = '/search?page=$1', totalPages, linkComponent, ...props }) => {
|
|
31
49
|
padding = Number(padding);
|
|
32
50
|
page = Number(page);
|
|
33
51
|
const minToShow = padding + 2;
|
|
@@ -64,31 +82,33 @@ const Pagination = ({ ariaLabel = 'Pages', className, onClick, padding = 1, page
|
|
|
64
82
|
className
|
|
65
83
|
].join(' ')} aria-label={ariaLabel} {...props}>
|
|
66
84
|
<ul className="ds_pagination__list">
|
|
67
|
-
{page > 1 && (<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
</a>
|
|
72
|
-
</li>)}
|
|
85
|
+
{page > 1 && (<exports.Page ariaLabel="Previous page" className="ds_pagination__link--text ds_pagination__link--icon" data-search="pagination-previous" href={pattern.replace('$1', String(page - 1))} onClick={onClick}>
|
|
86
|
+
<Icon_1.default icon="ChevronLeft"/>
|
|
87
|
+
<span className="ds_pagination__link-label">Previous</span>
|
|
88
|
+
</exports.Page>)}
|
|
73
89
|
|
|
74
90
|
{includeFirst && (<>
|
|
75
|
-
<exports.Page ariaLabel="Page 1" href={pattern.replace('$1', String(1))} onClick={onClick}
|
|
91
|
+
<exports.Page ariaLabel="Page 1" href={pattern.replace('$1', String(1))} onClick={onClick} linkComponent={linkComponent}>
|
|
92
|
+
<span className="ds_pagination__link-label">1</span>
|
|
93
|
+
</exports.Page>
|
|
76
94
|
<exports.Ellipsis />
|
|
77
95
|
</>)}
|
|
78
96
|
|
|
79
|
-
{pages && pages.map((item, index) => (<exports.Page ariaLabel={`Page ${item}`}
|
|
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}>
|
|
98
|
+
<span className="ds_pagination__link-label">{item.toString()}</span>
|
|
99
|
+
</exports.Page>))}
|
|
80
100
|
|
|
81
101
|
{includeLast && (<>
|
|
82
102
|
<exports.Ellipsis />
|
|
83
|
-
<exports.Page ariaLabel={`Page ${totalPages}`} href={pattern.replace('$1', String(totalPages))} onClick={onClick} pattern={pattern}
|
|
103
|
+
<exports.Page ariaLabel={`Page ${totalPages}`} href={pattern.replace('$1', String(totalPages))} linkComponent={linkComponent} onClick={onClick} pattern={pattern}>
|
|
104
|
+
<span className="ds_pagination__link-label">{totalPages.toString()}</span>
|
|
105
|
+
</exports.Page>
|
|
84
106
|
</>)}
|
|
85
107
|
|
|
86
|
-
{page < totalPages && (<
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</a>
|
|
91
|
-
</li>)}
|
|
108
|
+
{page < totalPages && (<exports.Page ariaLabel="Next page" href={pattern.replace('$1', String(page + 1))} className="ds_pagination__link ds_pagination__link--text ds_pagination__link--icon" onClick={onClick}>
|
|
109
|
+
<span className="ds_pagination__link-label">Next</span>
|
|
110
|
+
<Icon_1.default icon="ChevronRight"/>
|
|
111
|
+
</exports.Page>)}
|
|
92
112
|
|
|
93
113
|
</ul>
|
|
94
114
|
</nav>);
|
|
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Tag_1 = __importDefault(require("../Tag/Tag"));
|
|
7
|
-
const PhaseBanner = ({ children, className,
|
|
7
|
+
const PhaseBanner = ({ children, className, phaseName, ...props }) => {
|
|
8
8
|
return (<div className={[
|
|
9
9
|
'ds_phase-banner',
|
|
10
10
|
className
|
|
11
11
|
].join(' ')} {...props}>
|
|
12
12
|
<div className="ds_wrapper">
|
|
13
13
|
<p className="ds_phase-banner__content">
|
|
14
|
-
{phaseName && <Tag_1.default
|
|
14
|
+
{phaseName && <Tag_1.default className="ds_phase-banner__tag">{phaseName}</Tag_1.default>}
|
|
15
15
|
<span className="ds_phase-banner__text">
|
|
16
|
-
{
|
|
16
|
+
{children || "This is a new service"}
|
|
17
17
|
</span>
|
|
18
18
|
</p>
|
|
19
19
|
</div>
|
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const ErrorMessage_1 = __importDefault(require("../ErrorMessage/ErrorMessage"));
|
|
7
7
|
const HintText_1 = __importDefault(require("../../common/HintText"));
|
|
8
8
|
const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
|
|
9
|
-
const Question = function ({ children, className,
|
|
9
|
+
const Question = function ({ children, className, errorMessage, hasError, hintText, legend, tagName = 'div', ...props }) {
|
|
10
10
|
return (<WrapperTag_1.default tagName={tagName} className={[
|
|
11
11
|
'ds_question',
|
|
12
|
-
|
|
12
|
+
hasError && 'ds_question--error',
|
|
13
13
|
className
|
|
14
14
|
].join(' ')} {...props}>
|
|
15
15
|
{legend && <legend>{legend}</legend>}
|
|
16
16
|
{hintText && <HintText_1.default text={hintText}/>}
|
|
17
|
-
{
|
|
17
|
+
{hasError && errorMessage && <ErrorMessage_1.default text={errorMessage}/>}
|
|
18
18
|
{children}
|
|
19
19
|
</WrapperTag_1.default>);
|
|
20
20
|
};
|
|
@@ -3,9 +3,8 @@ 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
|
-
exports.Radio = void 0;
|
|
7
6
|
const HintText_1 = __importDefault(require("../../common/HintText"));
|
|
8
|
-
const
|
|
7
|
+
const RadioButton = ({ checked, hintText, id, label, name, onBlur, onChange, small }) => {
|
|
9
8
|
const hintTextId = `hint-text-${id}`;
|
|
10
9
|
function handleBlur(event) {
|
|
11
10
|
if (typeof onBlur === 'function') {
|
|
@@ -26,18 +25,5 @@ const Radio = ({ checked, hintText, id, label, name, onBlur, onChange, small })
|
|
|
26
25
|
{hintText && <HintText_1.default id={hintTextId} text={hintText}/>}
|
|
27
26
|
</div>);
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return (<div className={[
|
|
32
|
-
'ds_radios',
|
|
33
|
-
'ds_field-group',
|
|
34
|
-
inline && 'ds_field-group--inline',
|
|
35
|
-
className
|
|
36
|
-
].join(' ')} {...props}>
|
|
37
|
-
|
|
38
|
-
{items && items.map((item, index) => (<exports.Radio checked={item.checked} hintText={item.hintText} id={item.id} key={'radio' + index} label={item.label} name={name} onBlur={item.onBlur} onChange={item.onChange} small={small || item.small}/>))}
|
|
39
|
-
</div>);
|
|
40
|
-
};
|
|
41
|
-
exports.Radio.displayName = 'Radio';
|
|
42
|
-
RadioGroup.displayName = 'RadioGroup';
|
|
43
|
-
exports.default = RadioGroup;
|
|
28
|
+
RadioButton.displayName = 'RadioButton';
|
|
29
|
+
exports.default = RadioButton;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 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
|
+
}
|
|
50
|
+
return (<div className={[
|
|
51
|
+
'ds_radios',
|
|
52
|
+
'ds_field-group',
|
|
53
|
+
inline && 'ds_field-group--inline',
|
|
54
|
+
className
|
|
55
|
+
].join(' ')} {...props}>
|
|
56
|
+
|
|
57
|
+
{react_1.Children.map(children, child => processChild(child))}
|
|
58
|
+
</div>);
|
|
59
|
+
};
|
|
60
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
61
|
+
exports.default = RadioGroup;
|
|
@@ -5,10 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ErrorMessage_1 = __importDefault(require("../ErrorMessage/ErrorMessage"));
|
|
7
7
|
const HintText_1 = __importDefault(require("../../common/HintText"));
|
|
8
|
-
const
|
|
9
|
-
return (<option value={value}>{text}</option>);
|
|
10
|
-
};
|
|
11
|
-
const Select = function ({ className, defaultValue, error, errorMessage, hintText, id, label, name, onBlur, onChange, options, placeholder, width, ...props }) {
|
|
8
|
+
const Select = function ({ children, className, defaultValue, errorMessage, hasError, hintText, id, label, name, onBlur, onChange, placeholder, width, ...props }) {
|
|
12
9
|
const errorMessageId = `error-message-${id}`;
|
|
13
10
|
const hintTextId = `hint-text-${id}`;
|
|
14
11
|
const describedbys = [];
|
|
@@ -36,13 +33,13 @@ const Select = function ({ className, defaultValue, error, errorMessage, hintTex
|
|
|
36
33
|
{errorMessage && <ErrorMessage_1.default id={errorMessageId} text={errorMessage}/>}
|
|
37
34
|
<div className={[
|
|
38
35
|
"ds_select-wrapper",
|
|
39
|
-
|
|
36
|
+
hasError && 'ds_input--error',
|
|
40
37
|
width && `ds_input--${width}`,
|
|
41
38
|
className
|
|
42
39
|
].join(' ')} {...props}>
|
|
43
|
-
<select aria-describedby={describedbys.join(' ')} aria-invalid={
|
|
40
|
+
<select aria-describedby={describedbys.join(' ')} aria-invalid={hasError} className="ds_select" defaultValue={defaultValue} id={id} name={name || id} onBlur={handleBlur} onChange={handleChange}>
|
|
44
41
|
<option value="">{placeholder}</option>
|
|
45
|
-
{
|
|
42
|
+
{children}
|
|
46
43
|
</select>
|
|
47
44
|
<span className="ds_select-arrow" aria-hidden="true"></span>
|
|
48
45
|
</div>
|