@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
|
@@ -4,21 +4,32 @@ import HintText from '../../common/HintText';
|
|
|
4
4
|
import ScreenReaderText from '../../common/ScreenReaderText';
|
|
5
5
|
import Tag from '../Tag/Tag';
|
|
6
6
|
|
|
7
|
-
const TaskItem
|
|
7
|
+
const TaskItem = ({
|
|
8
8
|
children,
|
|
9
9
|
className,
|
|
10
10
|
href,
|
|
11
11
|
id,
|
|
12
12
|
isComplete = false,
|
|
13
|
+
linkComponent,
|
|
13
14
|
statusText,
|
|
14
15
|
tagColour = 'grey',
|
|
15
16
|
title,
|
|
16
17
|
...props
|
|
17
|
-
}) => {
|
|
18
|
+
}: SGDS.Component.TaskList.Item) => {
|
|
18
19
|
if (isComplete) {
|
|
19
20
|
tagColour = 'green';
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
const LINK_CLASS = 'ds_task-list__task-link';
|
|
24
|
+
|
|
25
|
+
function getLinkElement(children: React.ReactNode) {
|
|
26
|
+
if (linkComponent) {
|
|
27
|
+
return linkComponent({ className: LINK_CLASS, href, children });
|
|
28
|
+
} else if (href) {
|
|
29
|
+
return <a href={href} className={LINK_CLASS}>{children}</a>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
return (
|
|
23
34
|
<li
|
|
24
35
|
className={[
|
|
@@ -32,7 +43,7 @@ const TaskItem: React.FC<SGDS.Component.TaskList.Item> = ({
|
|
|
32
43
|
<h3 className="ds_task-list__task-heading">
|
|
33
44
|
<ConditionalWrapper
|
|
34
45
|
condition={typeof href !== 'undefined'}
|
|
35
|
-
wrapper={(children: React.JSX.Element) =>
|
|
46
|
+
wrapper={(children: React.JSX.Element) => getLinkElement(children)}
|
|
36
47
|
>
|
|
37
48
|
{title}
|
|
38
49
|
{statusText && <ScreenReaderText>({statusText})</ScreenReaderText>}
|
|
@@ -45,8 +56,9 @@ const TaskItem: React.FC<SGDS.Component.TaskList.Item> = ({
|
|
|
45
56
|
<Tag
|
|
46
57
|
aria-hidden="true"
|
|
47
58
|
colour={tagColour}
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
>
|
|
60
|
+
{statusText}
|
|
61
|
+
</Tag>
|
|
50
62
|
}
|
|
51
63
|
</li>
|
|
52
64
|
);
|
|
@@ -58,13 +70,13 @@ const TaskItem: React.FC<SGDS.Component.TaskList.Item> = ({
|
|
|
58
70
|
* @param {string} props.title - The title of the task group
|
|
59
71
|
* @returns {JSX.Element} - The element
|
|
60
72
|
*/
|
|
61
|
-
const TaskGroup
|
|
73
|
+
const TaskGroup = ({
|
|
62
74
|
children,
|
|
63
75
|
className,
|
|
64
76
|
intro,
|
|
65
77
|
title,
|
|
66
78
|
...props
|
|
67
|
-
}) => {
|
|
79
|
+
}: SGDS.Component.TaskList.Group) => {
|
|
68
80
|
return (
|
|
69
81
|
<li
|
|
70
82
|
className={[
|
|
@@ -82,15 +94,13 @@ const TaskGroup: React.FC<SGDS.Component.TaskList.Group> = ({
|
|
|
82
94
|
);
|
|
83
95
|
};
|
|
84
96
|
|
|
85
|
-
const TaskList
|
|
86
|
-
& { Group: React.FC<SGDS.Component.TaskList.Group> }
|
|
87
|
-
& { Item: React.FC<SGDS.Component.TaskList.Item> } = ({
|
|
97
|
+
const TaskList = ({
|
|
88
98
|
children,
|
|
89
99
|
className,
|
|
90
100
|
headingId = 'task-list',
|
|
91
101
|
title,
|
|
92
102
|
...props
|
|
93
|
-
}) => {
|
|
103
|
+
}: SGDS.Component.TaskList) => {
|
|
94
104
|
let taskCount = 0;
|
|
95
105
|
let incompleteTaskIds: string[] = [];
|
|
96
106
|
let completedTasksCount = 0;
|
|
@@ -6,7 +6,7 @@ import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
|
6
6
|
import ErrorMessage from '../ErrorMessage/ErrorMessage';
|
|
7
7
|
import HintText from '../../common/HintText';
|
|
8
8
|
|
|
9
|
-
const TextInput
|
|
9
|
+
const TextInput = ({
|
|
10
10
|
buttonIcon,
|
|
11
11
|
buttonText,
|
|
12
12
|
children,
|
|
@@ -15,9 +15,9 @@ const TextInput: React.FC<SGDS.Component.TextInput> = ({
|
|
|
15
15
|
width,
|
|
16
16
|
currency,
|
|
17
17
|
currencySymbol,
|
|
18
|
-
error,
|
|
19
18
|
errorMessage,
|
|
20
19
|
hasButton = false,
|
|
20
|
+
hasError,
|
|
21
21
|
hintText,
|
|
22
22
|
id,
|
|
23
23
|
label,
|
|
@@ -29,7 +29,7 @@ const TextInput: React.FC<SGDS.Component.TextInput> = ({
|
|
|
29
29
|
type = 'text',
|
|
30
30
|
value,
|
|
31
31
|
...props
|
|
32
|
-
}) => {
|
|
32
|
+
}: SGDS.Component.TextInput) => {
|
|
33
33
|
const errorMessageId = `error-message-${id}`;
|
|
34
34
|
const hintTextId = `hint-text-${id}`;
|
|
35
35
|
const ref = useRef(null);
|
|
@@ -71,11 +71,11 @@ const TextInput: React.FC<SGDS.Component.TextInput> = ({
|
|
|
71
71
|
>
|
|
72
72
|
<input
|
|
73
73
|
aria-describedby={describedbys.join(' ')}
|
|
74
|
-
aria-invalid={
|
|
74
|
+
aria-invalid={hasError}
|
|
75
75
|
className={[
|
|
76
76
|
'ds_input',
|
|
77
77
|
className,
|
|
78
|
-
|
|
78
|
+
hasError ? 'ds_input--error' : '',
|
|
79
79
|
width ? `ds_input--${width}` : '',
|
|
80
80
|
].join(' ')}
|
|
81
81
|
defaultValue={value}
|
|
@@ -5,11 +5,11 @@ import ConditionalWrapper from '../../common/ConditionalWrapper';
|
|
|
5
5
|
import ErrorMessage from '../ErrorMessage/ErrorMessage';
|
|
6
6
|
import HintText from '../../common/HintText';
|
|
7
7
|
|
|
8
|
-
const Textarea
|
|
8
|
+
const Textarea = ({
|
|
9
9
|
className,
|
|
10
10
|
countThreshold,
|
|
11
|
-
error,
|
|
12
11
|
errorMessage,
|
|
12
|
+
hasError,
|
|
13
13
|
hintText,
|
|
14
14
|
id,
|
|
15
15
|
label,
|
|
@@ -21,7 +21,7 @@ const Textarea: React.FC<SGDS.Component.Textarea> = ({
|
|
|
21
21
|
rows = 4,
|
|
22
22
|
value,
|
|
23
23
|
...props
|
|
24
|
-
}) => {
|
|
24
|
+
}: SGDS.Component.Textarea) => {
|
|
25
25
|
const errorMessageId = `error-message-${id}`;
|
|
26
26
|
const hintTextId = `hint-text-${id}`;
|
|
27
27
|
const ref = useRef(null);
|
|
@@ -59,10 +59,10 @@ const Textarea: React.FC<SGDS.Component.Textarea> = ({
|
|
|
59
59
|
|
|
60
60
|
<textarea
|
|
61
61
|
aria-describedby={describedbys.join(' ')}
|
|
62
|
-
aria-invalid={
|
|
62
|
+
aria-invalid={hasError}
|
|
63
63
|
className={[
|
|
64
64
|
'ds_input',
|
|
65
|
-
|
|
65
|
+
hasError && 'ds_input--error',
|
|
66
66
|
className
|
|
67
67
|
].join(' ')}
|
|
68
68
|
defaultValue={value}
|