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