@scottish-government/designsystem-react 0.7.0 → 0.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/Accordion.d.ts +0 -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 +12 -7
- package/dist/components/Breadcrumbs/Breadcrumbs.jsx +20 -15
- package/dist/components/Checkbox/Checkbox.jsx +4 -29
- package/dist/components/{aspect-box/aspect-box.jsx → Checkbox/CheckboxGroup.jsx} +14 -30
- 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 +7 -17
- package/dist/components/RadioButton/RadioGroup.jsx +21 -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/hooks/useTracking.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/context.js +5 -0
- package/package.json +2 -2
- 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 +17 -4
- package/src/components/Accordion/Accordion.tsx +19 -14
- package/src/components/AspectBox/AspectBox.tsx +2 -2
- package/src/components/BackToTop/BackToTop.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +79 -48
- 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 +8 -55
- package/src/components/Checkbox/CheckboxGroup.test.tsx +37 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +41 -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 +10 -41
- package/src/components/RadioButton/RadioGroup.test.tsx +65 -0
- package/src/components/RadioButton/RadioGroup.tsx +31 -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
- package/src/hooks/useTracking.test.tsx +64 -0
- package/src/hooks/useTracking.ts +19 -0
- package/src/utils/context.ts +3 -0
- package/tsconfig.json +1 -1
- package/dist/common/abstract-notification-banner.jsx +0 -63
- package/dist/common/conditional-wrapper.jsx +0 -8
- package/dist/common/file-icon.jsx +0 -51
- package/dist/common/hint-text.jsx +0 -9
- package/dist/common/icon.jsx +0 -57
- package/dist/common/screen-reader-text.jsx +0 -9
- package/dist/common/wrapper-tag.jsx +0 -11
- package/dist/components/accordion/accordion.jsx +0 -102
- package/dist/components/back-to-top/back-to-top.jsx +0 -27
- package/dist/components/breadcrumbs/breadcrumbs.jsx +0 -28
- package/dist/components/button/button.jsx +0 -30
- package/dist/components/checkbox/checkbox.jsx +0 -62
- package/dist/components/confirmation-message/confirmation-message.jsx +0 -24
- package/dist/components/contents-nav/contents-nav.jsx +0 -33
- package/dist/components/cookie-banner/cookie-banner.jsx +0 -21
- package/dist/components/date-picker/date-picker.jsx +0 -54
- package/dist/components/details/details.jsx +0 -17
- package/dist/components/error-message/error-message.jsx +0 -12
- package/dist/components/error-summary/error-summary.jsx +0 -27
- package/dist/components/file-download/file-download.jsx +0 -50
- package/dist/components/hide-this-page/hide-this-page.jsx +0 -71
- package/dist/components/inset-text/inset-text.jsx +0 -14
- package/dist/components/notification-banner/notification-banner.jsx +0 -26
- package/dist/components/notification-panel/notification-panel.jsx +0 -21
- package/dist/components/page-header/page-header.jsx +0 -15
- package/dist/components/page-metadata/page-metadata.jsx +0 -26
- package/dist/components/pagination/pagination.jsx +0 -97
- package/dist/components/phase-banner/phase-banner.jsx +0 -23
- package/dist/components/question/question.jsx +0 -22
- package/dist/components/radio-button/radio-button.jsx +0 -43
- package/dist/components/select/select.jsx +0 -52
- package/dist/components/sequential-navigation/sequential-navigation.jsx +0 -31
- package/dist/components/side-navigation/side-navigation.jsx +0 -52
- package/dist/components/site-header/site-header.jsx +0 -68
- package/dist/components/site-navigation/site-navigation.jsx +0 -22
- package/dist/components/site-search/site-search.jsx +0 -55
- package/dist/components/skip-links/skip-links.jsx +0 -21
- package/dist/components/summary-card/summary-card.jsx +0 -67
- package/dist/components/summary-list/summary-list.jsx +0 -75
- package/dist/components/table/table.jsx +0 -24
- package/dist/components/tabs/tabs.jsx +0 -99
- package/dist/components/tag/tag.jsx +0 -13
- package/dist/components/task-list/task-list.jsx +0 -95
- package/dist/components/text-input/text-input.jsx +0 -58
- package/dist/components/textarea/textarea.jsx +0 -54
- package/dist/components/warning-text/warning-text.jsx +0 -16
- package/dist/icons/ArrowUpward.jsx +0 -41
- package/dist/icons/CalendarToday.jsx +0 -41
- package/dist/icons/Cancel.jsx +0 -40
- package/dist/icons/CheckCircle.jsx +0 -41
- package/dist/icons/ChevronLeft.jsx +0 -41
- package/dist/icons/ChevronRight.jsx +0 -41
- package/dist/icons/Close.jsx +0 -41
- package/dist/icons/Description.jsx +0 -41
- package/dist/icons/DoubleChevronLeft.jsx +0 -40
- package/dist/icons/DoubleChevronRight.jsx +0 -40
- package/dist/icons/Error.jsx +0 -41
- package/dist/icons/ExpandLess.jsx +0 -41
- package/dist/icons/ExpandMore.jsx +0 -41
- package/dist/icons/List.jsx +0 -44
- package/dist/icons/Menu.jsx +0 -41
- package/dist/icons/PriorityHigh.jsx +0 -42
- package/dist/icons/Search.jsx +0 -41
- package/dist/icons/index.js +0 -40
|
@@ -41,9 +41,15 @@ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
|
|
|
41
41
|
// @ts-ignore
|
|
42
42
|
const accordion_1 = __importDefault(require("@scottish-government/design-system/src/components/accordion/accordion"));
|
|
43
43
|
let accordionItemCounter = 0;
|
|
44
|
-
const
|
|
44
|
+
const AccordionHeadingLevelContext = (0, react_1.createContext)('h3');
|
|
45
|
+
const AccordionItem = ({ children, className, id: rawId, open = false, title, ...props }) => {
|
|
45
46
|
accordionItemCounter = accordionItemCounter + 1;
|
|
46
47
|
const processedId = rawId || `accordion-item-${accordionItemCounter}`;
|
|
48
|
+
const DEFAULT_HEADING_LEVEL = 'h3';
|
|
49
|
+
let headingLevel = (0, react_1.useContext)(AccordionHeadingLevelContext);
|
|
50
|
+
if (!['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(headingLevel)) {
|
|
51
|
+
headingLevel = DEFAULT_HEADING_LEVEL;
|
|
52
|
+
}
|
|
47
53
|
return (<div className={[
|
|
48
54
|
'ds_accordion-item',
|
|
49
55
|
className
|
|
@@ -56,7 +62,7 @@ const AccordionItem = ({ children, className, headingLevel = 'h3', id: rawId, op
|
|
|
56
62
|
<WrapperTag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headingLevel}>
|
|
57
63
|
{title}
|
|
58
64
|
</WrapperTag_1.default>
|
|
59
|
-
<span className=
|
|
65
|
+
<span className="ds_accordion-item__indicator"/>
|
|
60
66
|
<label className="ds_accordion-item__label" htmlFor={`${processedId}-control`}>
|
|
61
67
|
<span className="visually-hidden">Show this section</span>
|
|
62
68
|
</label>
|
|
@@ -76,9 +82,6 @@ const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...p
|
|
|
76
82
|
if (!children) {
|
|
77
83
|
hideOpenAll = true;
|
|
78
84
|
}
|
|
79
|
-
function processChild(child) {
|
|
80
|
-
return react_1.default.cloneElement(child, { headingLevel: headingLevel });
|
|
81
|
-
}
|
|
82
85
|
return (<div className={[
|
|
83
86
|
'ds_accordion',
|
|
84
87
|
className
|
|
@@ -93,10 +96,12 @@ const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...p
|
|
|
93
96
|
<span className="visually-hidden">sections</span>
|
|
94
97
|
</button>)}
|
|
95
98
|
|
|
96
|
-
{
|
|
99
|
+
<AccordionHeadingLevelContext value={headingLevel}>
|
|
100
|
+
{children}
|
|
101
|
+
</AccordionHeadingLevelContext>
|
|
97
102
|
</div>);
|
|
98
103
|
};
|
|
99
104
|
Accordion.displayName = 'Accordion';
|
|
100
|
-
AccordionItem.displayName = '
|
|
105
|
+
AccordionItem.displayName = 'Accordion.Item';
|
|
101
106
|
Accordion.Item = AccordionItem;
|
|
102
107
|
exports.default = Accordion;
|
|
@@ -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,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.CheckboxGroup = exports.Checkbox = void 0;
|
|
7
6
|
const react_1 = require("react");
|
|
8
|
-
|
|
9
|
-
const checkboxes_1 = __importDefault(require("@scottish-government/design-system/src/forms/checkbox/checkboxes"));
|
|
7
|
+
const context_1 = require("../../utils/context");
|
|
10
8
|
const HintText_1 = __importDefault(require("../../common/HintText"));
|
|
11
9
|
const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onChange, small }) => {
|
|
12
10
|
const hintTextId = `hint-text-${id}`;
|
|
@@ -21,6 +19,7 @@ const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onCha
|
|
|
21
19
|
onChange(event);
|
|
22
20
|
}
|
|
23
21
|
}
|
|
22
|
+
small = small || (0, react_1.useContext)(context_1.CheckboxRadioContext).small;
|
|
24
23
|
return (<>
|
|
25
24
|
{exclusive && <p className="ds_checkbox-separator">or</p>}
|
|
26
25
|
<div className={[
|
|
@@ -34,29 +33,5 @@ const Checkbox = ({ checked, hintText, id, exclusive, label, name, onBlur, onCha
|
|
|
34
33
|
</div>
|
|
35
34
|
</>);
|
|
36
35
|
};
|
|
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;
|
|
36
|
+
Checkbox.displayName = 'Checkbox';
|
|
37
|
+
exports.default = Checkbox;
|
|
@@ -36,44 +36,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.CheckboxGroup = void 0;
|
|
39
40
|
const react_1 = __importStar(require("react"));
|
|
41
|
+
const context_1 = require("../../utils/context");
|
|
40
42
|
// @ts-ignore
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
+
const checkboxes_1 = __importDefault(require("@scottish-government/design-system/src/forms/checkbox/checkboxes"));
|
|
44
|
+
const CheckboxGroup = ({ children, className, small = false, ...props }) => {
|
|
43
45
|
const ref = (0, react_1.useRef)(null);
|
|
44
46
|
(0, react_1.useEffect)(() => {
|
|
45
47
|
if (ref.current) {
|
|
46
|
-
new
|
|
48
|
+
new checkboxes_1.default(ref.current).init();
|
|
47
49
|
}
|
|
48
50
|
}, [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
51
|
return (<div className={[
|
|
71
|
-
'
|
|
72
|
-
|
|
52
|
+
'ds_checkboxes',
|
|
53
|
+
'ds_field-group',
|
|
73
54
|
className
|
|
74
|
-
].join(' ')} ref={ref} {...props}>
|
|
75
|
-
{
|
|
55
|
+
].join(' ')} data-module="ds-checkboxes" ref={ref} {...props}>
|
|
56
|
+
<context_1.CheckboxRadioContext value={{ small, name: '' }}>
|
|
57
|
+
{children}
|
|
58
|
+
</context_1.CheckboxRadioContext>
|
|
76
59
|
</div>);
|
|
77
60
|
};
|
|
78
|
-
|
|
79
|
-
exports.
|
|
61
|
+
exports.CheckboxGroup = CheckboxGroup;
|
|
62
|
+
exports.CheckboxGroup.displayName = 'CheckboxGroup';
|
|
63
|
+
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,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const react_1 = require("react");
|
|
7
7
|
const HintText_1 = __importDefault(require("../../common/HintText"));
|
|
8
|
-
const
|
|
8
|
+
const context_1 = require("../../utils/context");
|
|
9
|
+
const RadioButton = ({ checked, hintText, id, label, name, onBlur, onChange, small }) => {
|
|
9
10
|
const hintTextId = `hint-text-${id}`;
|
|
10
11
|
function handleBlur(event) {
|
|
11
12
|
if (typeof onBlur === 'function') {
|
|
@@ -17,6 +18,8 @@ const Radio = ({ checked, hintText, id, label, name, onBlur, onChange, small })
|
|
|
17
18
|
onChange(event);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
small = small || (0, react_1.useContext)(context_1.CheckboxRadioContext).small;
|
|
22
|
+
name = name || (0, react_1.useContext)(context_1.CheckboxRadioContext).name;
|
|
20
23
|
return (<div className={[
|
|
21
24
|
'ds_radio',
|
|
22
25
|
small && 'ds_radio--small'
|
|
@@ -26,18 +29,5 @@ const Radio = ({ checked, hintText, id, label, name, onBlur, onChange, small })
|
|
|
26
29
|
{hintText && <HintText_1.default id={hintTextId} text={hintText}/>}
|
|
27
30
|
</div>);
|
|
28
31
|
};
|
|
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;
|
|
32
|
+
RadioButton.displayName = 'RadioButton';
|
|
33
|
+
exports.default = RadioButton;
|
|
@@ -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 react_1 = __importDefault(require("react"));
|
|
7
|
+
const context_1 = require("../../utils/context");
|
|
8
|
+
const RadioGroup = ({ children, className, inline, name, small = false, ...props }) => {
|
|
9
|
+
return (<div className={[
|
|
10
|
+
'ds_radios',
|
|
11
|
+
'ds_field-group',
|
|
12
|
+
inline && 'ds_field-group--inline',
|
|
13
|
+
className
|
|
14
|
+
].join(' ')} {...props}>
|
|
15
|
+
<context_1.CheckboxRadioContext value={{ small, name }}>
|
|
16
|
+
{children}
|
|
17
|
+
</context_1.CheckboxRadioContext>
|
|
18
|
+
</div>);
|
|
19
|
+
};
|
|
20
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
21
|
+
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>
|