@scottish-government/designsystem-react 0.7.1 → 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/Checkbox/CheckboxGroup.jsx +63 -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 +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
|
@@ -4,12 +4,12 @@ import DSDatePicker from '@scottish-government/design-system/src/components/date
|
|
|
4
4
|
import ErrorMessage from '../ErrorMessage/ErrorMessage';
|
|
5
5
|
import TextInput from '../TextInput/TextInput';
|
|
6
6
|
|
|
7
|
-
const DatePicker
|
|
7
|
+
const DatePicker = ({
|
|
8
8
|
className,
|
|
9
9
|
dateSelectCallback,
|
|
10
10
|
disabledDates,
|
|
11
|
-
error,
|
|
12
11
|
errorMessage,
|
|
12
|
+
hasError,
|
|
13
13
|
hintText,
|
|
14
14
|
id,
|
|
15
15
|
iconPath = './',
|
|
@@ -23,7 +23,7 @@ const DatePicker: React.FC<SGDS.Component.DatePicker> = ({
|
|
|
23
23
|
value,
|
|
24
24
|
width = 'fixed-10',
|
|
25
25
|
...props
|
|
26
|
-
}) => {
|
|
26
|
+
}: SGDS.Component.DatePicker) => {
|
|
27
27
|
const ref = useRef(null);
|
|
28
28
|
|
|
29
29
|
useEffect(() => {
|
|
@@ -68,7 +68,7 @@ const DatePicker: React.FC<SGDS.Component.DatePicker> = ({
|
|
|
68
68
|
<div>
|
|
69
69
|
<TextInput
|
|
70
70
|
className="js-datepicker-date"
|
|
71
|
-
|
|
71
|
+
hasError={!!hasError}
|
|
72
72
|
id={id + "-day"}
|
|
73
73
|
hintText={hintText}
|
|
74
74
|
label="Day"
|
|
@@ -83,7 +83,7 @@ const DatePicker: React.FC<SGDS.Component.DatePicker> = ({
|
|
|
83
83
|
<div>
|
|
84
84
|
<TextInput
|
|
85
85
|
className="js-datepicker-month"
|
|
86
|
-
|
|
86
|
+
hasError={!!hasError}
|
|
87
87
|
id={id + "-month"}
|
|
88
88
|
hintText={hintText}
|
|
89
89
|
label="Month"
|
|
@@ -98,7 +98,7 @@ const DatePicker: React.FC<SGDS.Component.DatePicker> = ({
|
|
|
98
98
|
<div>
|
|
99
99
|
<TextInput
|
|
100
100
|
className="js-datepicker-year"
|
|
101
|
-
|
|
101
|
+
hasError={!!hasError}
|
|
102
102
|
id={id + "-year"}
|
|
103
103
|
hintText={hintText}
|
|
104
104
|
label="Year"
|
|
@@ -112,7 +112,7 @@ const DatePicker: React.FC<SGDS.Component.DatePicker> = ({
|
|
|
112
112
|
</fieldset>
|
|
113
113
|
) : (
|
|
114
114
|
<TextInput
|
|
115
|
-
|
|
115
|
+
hasError={!!hasError}
|
|
116
116
|
errorMessage={errorMessage}
|
|
117
117
|
id={id}
|
|
118
118
|
hasButton
|
|
@@ -2,24 +2,17 @@ import { test, expect } from 'vitest';
|
|
|
2
2
|
import { render, screen, within } from '@testing-library/react';
|
|
3
3
|
import ErrorSummary from './ErrorSummary';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
{ fragmentId: 'what-topics', title: 'What topics are you interested in?' },
|
|
8
|
-
{ fragmentId: 'more-detail', title: 'Please provide more detail' }
|
|
9
|
-
];
|
|
5
|
+
const ERROR_FRAGMENT_ID = 'did-resolve';
|
|
6
|
+
const ERROR_TEXT = 'Did this resolve your issue?';
|
|
10
7
|
|
|
11
8
|
test('error summary renders correctly', () => {
|
|
12
|
-
const TITLE_ID = 'error-summary-title';
|
|
13
|
-
|
|
14
9
|
render(
|
|
15
|
-
<ErrorSummary data-testid="errorsummary"
|
|
10
|
+
<ErrorSummary data-testid="errorsummary"/>
|
|
16
11
|
);
|
|
17
12
|
|
|
18
13
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
19
14
|
const errorSummaryTitle = within(errorSummaryElement).getByRole('heading');
|
|
20
15
|
const errorSummaryList = within(errorSummaryElement).getByRole('list');
|
|
21
|
-
const errorSummaryItems = within(errorSummaryList).getAllByRole('listitem');
|
|
22
|
-
const errorSummaryLink1 = within(errorSummaryItems[0]).getByRole('link');
|
|
23
16
|
|
|
24
17
|
expect(errorSummaryElement).toHaveClass('ds_error-summary');
|
|
25
18
|
expect(errorSummaryElement).toHaveAttribute('role', 'alert');
|
|
@@ -27,24 +20,19 @@ test('error summary renders correctly', () => {
|
|
|
27
20
|
expect(errorSummaryElement.tagName).toEqual('DIV');
|
|
28
21
|
|
|
29
22
|
expect(errorSummaryTitle).toHaveClass('ds_error-summary__title');
|
|
30
|
-
expect(errorSummaryTitle).toHaveAttribute('id'
|
|
23
|
+
expect(errorSummaryTitle).toHaveAttribute('id');
|
|
31
24
|
expect(errorSummaryTitle.tagName).toEqual('H2');
|
|
32
25
|
expect(errorSummaryTitle.textContent).toEqual('There is a problem');
|
|
33
26
|
|
|
34
27
|
expect(errorSummaryList).toHaveClass('ds_error-summary__list');
|
|
35
28
|
expect(errorSummaryList.tagName).toEqual('UL');
|
|
36
|
-
|
|
37
|
-
expect(errorSummaryItems.length).toEqual(ERRORS.length);
|
|
38
|
-
|
|
39
|
-
expect(errorSummaryLink1).toHaveAttribute('href', `#${ERRORS[0].fragmentId}`);
|
|
40
|
-
expect(errorSummaryLink1.textContent).toEqual(ERRORS[0].title);
|
|
41
29
|
});
|
|
42
30
|
|
|
43
31
|
test('error summary with custom title', () => {
|
|
44
32
|
const TITLE_TEXT = 'Foo';
|
|
45
33
|
|
|
46
34
|
render(
|
|
47
|
-
<ErrorSummary data-testid="errorsummary"
|
|
35
|
+
<ErrorSummary data-testid="errorsummary" title={TITLE_TEXT}/>
|
|
48
36
|
);
|
|
49
37
|
|
|
50
38
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
@@ -53,42 +41,60 @@ test('error summary with custom title', () => {
|
|
|
53
41
|
expect(errorSummaryTitle.textContent).toEqual(TITLE_TEXT);
|
|
54
42
|
});
|
|
55
43
|
|
|
56
|
-
test('error summary with
|
|
44
|
+
test('error summary item with link', () => {
|
|
57
45
|
render(
|
|
58
|
-
<ErrorSummary
|
|
46
|
+
<ErrorSummary.Item fragmentId={ERROR_FRAGMENT_ID}>{ERROR_TEXT}</ErrorSummary.Item>
|
|
59
47
|
);
|
|
60
48
|
|
|
61
|
-
const
|
|
49
|
+
const errorSummaryItem = screen.getByRole('listitem');
|
|
50
|
+
const errorSummaryLink = within(errorSummaryItem).queryByRole('link');
|
|
51
|
+
|
|
52
|
+
expect(errorSummaryItem.tagName).toEqual('LI');
|
|
62
53
|
|
|
63
|
-
expect(
|
|
54
|
+
expect(errorSummaryLink).toBeInTheDocument();
|
|
55
|
+
expect(errorSummaryLink).toHaveAttribute('href', '#' + ERROR_FRAGMENT_ID);
|
|
56
|
+
expect(errorSummaryLink?.tagName).toEqual('A');
|
|
57
|
+
expect(errorSummaryLink?.textContent).toEqual(ERROR_TEXT);
|
|
64
58
|
});
|
|
65
59
|
|
|
66
|
-
test('error summary with no
|
|
60
|
+
test('error summary item with no link', () => {
|
|
67
61
|
render(
|
|
68
|
-
<ErrorSummary
|
|
62
|
+
<ErrorSummary.Item>{ERROR_TEXT}</ErrorSummary.Item>
|
|
69
63
|
);
|
|
70
64
|
|
|
71
|
-
const
|
|
65
|
+
const errorSummaryItem = screen.getByRole('listitem');
|
|
66
|
+
const errorSummaryLink = within(errorSummaryItem).queryByRole('link');
|
|
72
67
|
|
|
73
|
-
expect(
|
|
68
|
+
expect(errorSummaryItem.tagName).toEqual('LI');
|
|
69
|
+
|
|
70
|
+
expect(errorSummaryLink).not.toBeInTheDocument();
|
|
71
|
+
expect(errorSummaryItem?.textContent).toEqual(ERROR_TEXT);
|
|
74
72
|
});
|
|
75
73
|
|
|
76
|
-
test('error
|
|
74
|
+
test('error summary item with custom element', () => {
|
|
77
75
|
render(
|
|
78
|
-
<ErrorSummary
|
|
76
|
+
<ErrorSummary.Item fragmentId={ERROR_FRAGMENT_ID} linkComponent={
|
|
77
|
+
({ className, ...props }) => (
|
|
78
|
+
<strong role="link" {...props}/>
|
|
79
|
+
)}>
|
|
80
|
+
{ERROR_TEXT}
|
|
81
|
+
</ErrorSummary.Item>
|
|
79
82
|
);
|
|
80
83
|
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
+
const errorSummaryItem = screen.getByRole('listitem');
|
|
85
|
+
const errorSummaryLink = within(errorSummaryItem).queryByRole('link');
|
|
86
|
+
|
|
87
|
+
expect(errorSummaryItem.tagName).toEqual('LI');
|
|
84
88
|
|
|
85
|
-
expect(
|
|
86
|
-
expect(
|
|
89
|
+
expect(errorSummaryLink).toBeInTheDocument();
|
|
90
|
+
expect(errorSummaryLink).toHaveAttribute('href', '#' + ERROR_FRAGMENT_ID);
|
|
91
|
+
expect(errorSummaryLink?.tagName).toEqual('STRONG');
|
|
92
|
+
expect(errorSummaryLink?.textContent).toEqual(ERROR_TEXT);
|
|
87
93
|
});
|
|
88
94
|
|
|
89
95
|
test('passing additional props', () => {
|
|
90
96
|
render(
|
|
91
|
-
<ErrorSummary data-testid="errorsummary"
|
|
97
|
+
<ErrorSummary data-testid="errorsummary" data-test="foo"/>
|
|
92
98
|
)
|
|
93
99
|
|
|
94
100
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
@@ -97,7 +103,7 @@ test('passing additional props', () => {
|
|
|
97
103
|
|
|
98
104
|
test('passing additional CSS classes', () => {
|
|
99
105
|
render(
|
|
100
|
-
<ErrorSummary data-testid="errorsummary"
|
|
106
|
+
<ErrorSummary data-testid="errorsummary" className="foo"/>
|
|
101
107
|
)
|
|
102
108
|
|
|
103
109
|
const errorSummaryElement = screen.getByTestId('errorsummary');
|
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useId } from 'react';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const ErrorSummaryItem = ({
|
|
4
|
+
children,
|
|
4
5
|
fragmentId,
|
|
5
|
-
|
|
6
|
-
}) => {
|
|
6
|
+
linkComponent
|
|
7
|
+
}: SGDS.Component.ErrorSummary.Item) => {
|
|
8
|
+
const HREF = '#' + fragmentId;
|
|
9
|
+
|
|
10
|
+
function processChildren(children: React.ReactNode) {
|
|
11
|
+
if (linkComponent) {
|
|
12
|
+
return linkComponent({ className: '', href: HREF, children });
|
|
13
|
+
} else if (fragmentId) {
|
|
14
|
+
return <a href={HREF}>{children}</a>;
|
|
15
|
+
} else {
|
|
16
|
+
return children;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
return (
|
|
8
21
|
<li>
|
|
9
|
-
|
|
10
|
-
condition={!!fragmentId}
|
|
11
|
-
wrapper={() => <a href={`#${fragmentId}`}>{title}</a>}
|
|
12
|
-
>{title}</ConditionalWrapper>
|
|
22
|
+
{processChildren(children)}
|
|
13
23
|
</li>
|
|
14
24
|
);
|
|
15
|
-
}
|
|
25
|
+
}
|
|
16
26
|
|
|
17
|
-
const ErrorSummary
|
|
27
|
+
const ErrorSummary = ({
|
|
28
|
+
children,
|
|
18
29
|
className,
|
|
19
|
-
errors,
|
|
20
30
|
title = 'There is a problem',
|
|
21
31
|
...props
|
|
22
|
-
}) => {
|
|
32
|
+
}: SGDS.Component.ErrorSummary) => {
|
|
33
|
+
const summaryTitleId = useId();
|
|
34
|
+
|
|
23
35
|
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<Error fragmentId={error.fragmentId} title={error.title} key={'error' + index} />
|
|
39
|
-
))}
|
|
40
|
-
</ul>
|
|
41
|
-
</div>
|
|
42
|
-
)}
|
|
43
|
-
</>
|
|
36
|
+
<div className={[
|
|
37
|
+
'ds_error-summary',
|
|
38
|
+
className
|
|
39
|
+
].join(' ')}
|
|
40
|
+
aria-labelledby={summaryTitleId}
|
|
41
|
+
role="alert"
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<h2 className="ds_error-summary__title" id={summaryTitleId}>{title}</h2>
|
|
45
|
+
|
|
46
|
+
<ul className="ds_error-summary__list">
|
|
47
|
+
{children}
|
|
48
|
+
</ul>
|
|
49
|
+
</div>
|
|
44
50
|
);
|
|
45
51
|
};
|
|
46
52
|
|
|
47
53
|
ErrorSummary.displayName = 'ErrorSummary';
|
|
54
|
+
ErrorSummaryItem.displayName = 'ErrorSummary.Item';
|
|
55
|
+
ErrorSummary.Item = ErrorSummaryItem;
|
|
48
56
|
|
|
49
57
|
export default ErrorSummary;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useId } from 'react';
|
|
2
2
|
import FileIcon from '../../common/FileIcon';
|
|
3
3
|
|
|
4
|
-
const FileDownload
|
|
4
|
+
const FileDownload = ({
|
|
5
5
|
className,
|
|
6
6
|
cover,
|
|
7
7
|
highlighted,
|
|
@@ -11,7 +11,7 @@ const FileDownload: React.FC<SGDS.Component.FileDownload> = ({
|
|
|
11
11
|
fileUrl,
|
|
12
12
|
title,
|
|
13
13
|
...props
|
|
14
|
-
}) => {
|
|
14
|
+
}: SGDS.Component.FileDownload) => {
|
|
15
15
|
const hasMetadata = !!fileType || !!fileSize;
|
|
16
16
|
const metaContainerId = `file-download-${useId()}`;
|
|
17
17
|
|
|
@@ -2,11 +2,11 @@ import React, { useEffect, useRef } from 'react';
|
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import DSHideThisPage from '@scottish-government/design-system/src/components/hide-this-page/hide-this-page';
|
|
4
4
|
|
|
5
|
-
const HideThisPage
|
|
5
|
+
const HideThisPage = ({
|
|
6
6
|
className,
|
|
7
7
|
escapeUrl = 'https://www.bbc.co.uk/weather',
|
|
8
8
|
...props
|
|
9
|
-
}) => {
|
|
9
|
+
}: SGDS.Component.HideThisPage) => {
|
|
10
10
|
const ref = useRef(null);
|
|
11
11
|
|
|
12
12
|
useEffect(() => {
|
|
@@ -3,17 +3,16 @@ import AbstractNotificationBanner from '../../common/AbstractNotificationBanner'
|
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import DSNotificationBanner from '@scottish-government/design-system/src/components/notification-banner/notification-banner';
|
|
5
5
|
|
|
6
|
-
const NotificationBanner
|
|
7
|
-
& { Buttons?: React.FC<SGDS.Common.AbstractNotificationBanner.Buttons> } = ({
|
|
6
|
+
const NotificationBanner = ({
|
|
8
7
|
children,
|
|
9
8
|
className,
|
|
10
9
|
close,
|
|
10
|
+
hasColourIcon,
|
|
11
|
+
hasInverseIcon,
|
|
11
12
|
icon,
|
|
12
|
-
iconColour,
|
|
13
|
-
iconInverse,
|
|
14
13
|
title,
|
|
15
14
|
...props
|
|
16
|
-
}) => {
|
|
15
|
+
}: SGDS.Common.AbstractNotificationBanner) => {
|
|
17
16
|
const ref = useRef(null);
|
|
18
17
|
|
|
19
18
|
useEffect(() => {
|
|
@@ -30,8 +29,8 @@ const NotificationBanner: React.FC<SGDS.Common.AbstractNotificationBanner>
|
|
|
30
29
|
].join(' ')}
|
|
31
30
|
close={close}
|
|
32
31
|
icon={icon ? "PriorityHigh" : undefined}
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
hasColourIcon={hasColourIcon}
|
|
33
|
+
hasInverseIcon={hasInverseIcon}
|
|
35
34
|
ref={ref}
|
|
36
35
|
title="Information"
|
|
37
36
|
{...props}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import WrapperTag from '../../common/WrapperTag';
|
|
2
2
|
|
|
3
|
-
const NotificationPanel
|
|
3
|
+
const NotificationPanel = function ({
|
|
4
4
|
ariaLive,
|
|
5
5
|
children,
|
|
6
6
|
className,
|
|
7
7
|
headingLevel = 'h1',
|
|
8
8
|
title,
|
|
9
9
|
...props
|
|
10
|
-
}) {
|
|
10
|
+
}: SGDS.Component.NotificationPanel) {
|
|
11
11
|
return (
|
|
12
12
|
<div
|
|
13
13
|
aria-live={ariaLive}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const MetadataItem
|
|
1
|
+
const MetadataItem= ({
|
|
2
2
|
children,
|
|
3
3
|
className,
|
|
4
4
|
name,
|
|
5
5
|
...props
|
|
6
|
-
}) => {
|
|
6
|
+
}: SGDS.Component.Metadata.Item) => {
|
|
7
7
|
return (
|
|
8
8
|
<div className={[
|
|
9
9
|
'ds_metadata__item',
|
|
@@ -19,13 +19,12 @@ const MetadataItem: React.FC<SGDS.Component.Metadata.Item> = ({
|
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const Metadata
|
|
23
|
-
& { Item: React.FC<SGDS.Component.Metadata.Item> } = ({
|
|
22
|
+
const Metadata = ({
|
|
24
23
|
children,
|
|
25
24
|
className,
|
|
26
25
|
inline,
|
|
27
26
|
...props
|
|
28
|
-
}) => {
|
|
27
|
+
}: SGDS.Component.Metadata) => {
|
|
29
28
|
return (
|
|
30
29
|
<dl
|
|
31
30
|
className={[
|
|
@@ -4,7 +4,8 @@ import Pagination, { Page, Ellipsis } from './Pagination';
|
|
|
4
4
|
|
|
5
5
|
const PAGE_ARIA_LABEL = 'Page 1';
|
|
6
6
|
const PAGE_HREF = '#foo';
|
|
7
|
-
const PAGE_TEXT =
|
|
7
|
+
const PAGE_TEXT = 1;
|
|
8
|
+
const PAGE_LABEL = <span className="ds_pagination__link-label">{PAGE_TEXT}</span>;
|
|
8
9
|
const CURRENT_PAGE = 10;
|
|
9
10
|
const TOTAL_PAGES = 21;
|
|
10
11
|
|
|
@@ -13,8 +14,7 @@ test('pagination page renders correctly', () => {
|
|
|
13
14
|
<Page
|
|
14
15
|
ariaLabel={PAGE_ARIA_LABEL}
|
|
15
16
|
href={PAGE_HREF}
|
|
16
|
-
|
|
17
|
-
/>
|
|
17
|
+
>{PAGE_LABEL}</Page>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const item = screen.getByRole('listitem');
|
|
@@ -25,6 +25,27 @@ test('pagination page renders correctly', () => {
|
|
|
25
25
|
expect(link).toHaveClass('ds_pagination__link');
|
|
26
26
|
expect(link).toHaveAttribute('aria-label', PAGE_ARIA_LABEL);
|
|
27
27
|
expect(link).toHaveAttribute('href', PAGE_HREF);
|
|
28
|
+
expect(link.tagName).toEqual('A');
|
|
29
|
+
expect(span).toHaveClass('ds_pagination__link-label');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('pagination page renders with custom link component', () => {
|
|
33
|
+
render(
|
|
34
|
+
<Page
|
|
35
|
+
ariaLabel={PAGE_ARIA_LABEL}
|
|
36
|
+
href={PAGE_HREF}
|
|
37
|
+
linkComponent={
|
|
38
|
+
({ className, ...props }) => (
|
|
39
|
+
<span role="link" className={className} {...props}/>
|
|
40
|
+
)}
|
|
41
|
+
>{PAGE_LABEL}</Page>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const item = screen.getByRole('listitem');
|
|
45
|
+
const link = within(item).getByRole('link');
|
|
46
|
+
const span = within(link).getByText(PAGE_TEXT);
|
|
47
|
+
|
|
48
|
+
expect(link.tagName).toEqual('SPAN');
|
|
28
49
|
expect(span).toHaveClass('ds_pagination__link-label');
|
|
29
50
|
});
|
|
30
51
|
|
|
@@ -33,9 +54,8 @@ test('current pagination page', () => {
|
|
|
33
54
|
<Page
|
|
34
55
|
ariaLabel={PAGE_ARIA_LABEL}
|
|
35
56
|
href={PAGE_HREF}
|
|
36
|
-
text={PAGE_TEXT}
|
|
37
57
|
current
|
|
38
|
-
|
|
58
|
+
>{PAGE_LABEL}</Page>
|
|
39
59
|
);
|
|
40
60
|
|
|
41
61
|
const item = screen.getByRole('listitem');
|
|
@@ -52,9 +72,8 @@ test('pagination page with click event', () => {
|
|
|
52
72
|
<Page
|
|
53
73
|
ariaLabel={PAGE_ARIA_LABEL}
|
|
54
74
|
href={PAGE_HREF}
|
|
55
|
-
text={PAGE_TEXT}
|
|
56
75
|
onClick={ONCLICK_FUNCTION}
|
|
57
|
-
|
|
76
|
+
>{PAGE_LABEL}</Page>
|
|
58
77
|
);
|
|
59
78
|
|
|
60
79
|
const item = screen.getByRole('listitem');
|