@digigov/react-core 2.0.0-a402a664 → 2.0.0-a594a958
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/AccordionSection/index.web.d.ts +0 -1
- package/AccordionSection/index.web.js.map +2 -2
- package/AccordionSectionSummaryHeading/index.d.ts +1 -0
- package/AccordionSectionSummaryHeading/index.js +3 -2
- package/AccordionSectionSummaryHeading/index.js.map +2 -2
- package/BannerContainer/index.js +1 -1
- package/BannerContainer/index.js.map +2 -2
- package/{CircularProgress → CircularProgressBase}/index.d.ts +5 -5
- package/{CircularProgress → CircularProgressBase}/index.js +4 -4
- package/CircularProgressBase/index.js.map +7 -0
- package/{CircularProgress → CircularProgressBase}/package.json +1 -1
- package/DetailsContent/index.d.ts +1 -0
- package/DetailsContent/index.js +3 -2
- package/DetailsContent/index.js.map +2 -2
- package/Grid/index.d.ts +1 -7
- package/Grid/index.js.map +2 -2
- package/NavListItemActionBase/index.js +2 -2
- package/NavListItemActionBase/index.js.map +2 -2
- package/SummaryList/index.d.ts +10 -2
- package/SummaryList/index.js +10 -2
- package/SummaryList/index.js.map +2 -2
- package/SummaryListItem/index.js +1 -1
- package/SummaryListItem/index.js.map +2 -2
- package/SummaryListItemKey/index.d.ts +14 -0
- package/SummaryListItemKey/index.js +14 -2
- package/SummaryListItemKey/index.js.map +2 -2
- package/SummaryListItemValue/index.d.ts +14 -0
- package/SummaryListItemValue/index.js +11 -2
- package/SummaryListItemValue/index.js.map +2 -2
- package/TableDataCell/index.d.ts +9 -0
- package/TableDataCell/index.js +8 -1
- package/TableDataCell/index.js.map +2 -2
- package/cjs/AccordionSection/index.web.js.map +2 -2
- package/cjs/AccordionSectionSummaryHeading/index.js +3 -2
- package/cjs/AccordionSectionSummaryHeading/index.js.map +2 -2
- package/cjs/BannerContainer/index.js +1 -1
- package/cjs/BannerContainer/index.js.map +2 -2
- package/cjs/{CircularProgress → CircularProgressBase}/index.js +8 -8
- package/cjs/CircularProgressBase/index.js.map +7 -0
- package/cjs/DetailsContent/index.js +3 -2
- package/cjs/DetailsContent/index.js.map +2 -2
- package/cjs/Grid/index.js.map +2 -2
- package/cjs/NavListItemActionBase/index.js +2 -2
- package/cjs/NavListItemActionBase/index.js.map +2 -2
- package/cjs/SummaryList/index.js +10 -2
- package/cjs/SummaryList/index.js.map +2 -2
- package/cjs/SummaryListItem/index.js +1 -1
- package/cjs/SummaryListItem/index.js.map +2 -2
- package/cjs/SummaryListItemKey/index.js +14 -2
- package/cjs/SummaryListItemKey/index.js.map +3 -3
- package/cjs/SummaryListItemValue/index.js +11 -2
- package/cjs/SummaryListItemValue/index.js.map +3 -3
- package/cjs/TableDataCell/index.js +8 -1
- package/cjs/TableDataCell/index.js.map +3 -3
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +2 -2
- package/cjs/lazy/index.js +1 -1
- package/cjs/lazy.js.map +2 -2
- package/cjs/registry/index.js +4 -4
- package/cjs/registry.js.map +2 -2
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/lazy/index.js +1 -1
- package/package.json +3 -3
- package/registry/index.js +4 -4
- package/src/Accordion/__snapshots__/index.test.tsx.snap +48 -0
- package/src/Accordion/index.test.tsx +24 -0
- package/src/AccordionSection/index.web.tsx +0 -1
- package/src/AccordionSectionSummaryHeading/__snapshots__/index.test.tsx.snap +17 -0
- package/src/AccordionSectionSummaryHeading/index.test.tsx +9 -0
- package/src/AccordionSectionSummaryHeading/index.tsx +9 -2
- package/src/BannerContainer/__snapshots__/index.test.tsx.snap +1 -1
- package/src/BannerContainer/index.tsx +1 -1
- package/src/{CircularProgress → CircularProgressBase}/__snapshots__/index.test.tsx.snap +6 -6
- package/src/CircularProgressBase/index.test.tsx +38 -0
- package/src/{CircularProgress → CircularProgressBase}/index.tsx +7 -7
- package/src/DetailsContent/index.tsx +11 -2
- package/src/Grid/index.tsx +1 -7
- package/src/NavListItemActionBase/__snapshots__/index.test.tsx.snap +0 -1
- package/src/NavListItemActionBase/index.tsx +2 -2
- package/src/SummaryList/__snapshots__/index.test.tsx.snap +36 -0
- package/src/SummaryList/index.test.tsx +15 -0
- package/src/SummaryList/index.tsx +20 -3
- package/src/SummaryListItem/index.tsx +1 -1
- package/src/SummaryListItemKey/__snapshots__/index.test.tsx.snap +70 -0
- package/src/SummaryListItemKey/index.test.tsx +29 -0
- package/src/SummaryListItemKey/index.tsx +29 -1
- package/src/SummaryListItemValue/__snapshots__/index.test.tsx.snap +34 -0
- package/src/SummaryListItemValue/index.test.tsx +14 -0
- package/src/SummaryListItemValue/index.tsx +30 -2
- package/src/TableDataCell/__snapshots__/index.test.tsx.snap +77 -0
- package/src/TableDataCell/index.test.tsx +42 -0
- package/src/TableDataCell/index.tsx +33 -0
- package/src/TableRow/__snapshots__/index.test.tsx.snap +1 -1
- package/src/TableRow/index.test.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/lazy.js +1 -1
- package/src/registry.js +4 -4
- package/CircularProgress/index.js.map +0 -7
- package/cjs/CircularProgress/index.js.map +0 -7
- package/src/CircularProgress/index.test.tsx +0 -34
- /package/{CircularProgress → CircularProgressBase}/index.test.d.ts +0 -0
|
@@ -6,3 +6,27 @@ import Accordion from '@digigov/react-core/Accordion';
|
|
|
6
6
|
it('renders the Accordion with no props', () => {
|
|
7
7
|
expect(render(<Accordion>hello</Accordion>).baseElement).toMatchSnapshot();
|
|
8
8
|
});
|
|
9
|
+
it('renders the Accordion with horizontalBorders=bottom prop', () => {
|
|
10
|
+
expect(
|
|
11
|
+
render(<Accordion horizontalBorders="bottom">hello</Accordion>).baseElement
|
|
12
|
+
).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
it('renders the Accordion with summaryColor=secondary prop', () => {
|
|
15
|
+
expect(
|
|
16
|
+
render(<Accordion summaryColor="secondary">hello</Accordion>).baseElement
|
|
17
|
+
).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
it('renders the Accordion with dense=true prop', () => {
|
|
20
|
+
expect(
|
|
21
|
+
render(<Accordion dense={true}>hello</Accordion>).baseElement
|
|
22
|
+
).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
it('renders the Accordion with all the props', () => {
|
|
25
|
+
expect(
|
|
26
|
+
render(
|
|
27
|
+
<Accordion horizontalBorders="none" summaryColor="secondary" dense={true}>
|
|
28
|
+
hello
|
|
29
|
+
</Accordion>
|
|
30
|
+
).baseElement
|
|
31
|
+
).toMatchSnapshot();
|
|
32
|
+
});
|
|
@@ -4,7 +4,6 @@ import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
|
4
4
|
export interface AccordionSectionProps extends BaseProps<'details'> {}
|
|
5
5
|
/**
|
|
6
6
|
* AccordionSection should be inside the Accordion component.
|
|
7
|
-
*
|
|
8
7
|
* Inside this component must place the Accordion and the AccordionSectionContent components.
|
|
9
8
|
*/
|
|
10
9
|
export const AccordionSection = React.forwardRef<
|
|
@@ -16,3 +16,20 @@ exports[`renders the AccordionSectionSummaryHeading with no props 1`] = `
|
|
|
16
16
|
</div>
|
|
17
17
|
</body>
|
|
18
18
|
`;
|
|
19
|
+
|
|
20
|
+
exports[`renders the AccordionSectionSummaryHeading with variant=arrows prop 1`] = `
|
|
21
|
+
<body>
|
|
22
|
+
<div>
|
|
23
|
+
<h2
|
|
24
|
+
class="ds-accordion__section-heading"
|
|
25
|
+
role="button"
|
|
26
|
+
>
|
|
27
|
+
<span
|
|
28
|
+
class="ds-accordion__section-button ds-accordion__section-button--arrows"
|
|
29
|
+
>
|
|
30
|
+
hello
|
|
31
|
+
</span>
|
|
32
|
+
</h2>
|
|
33
|
+
</div>
|
|
34
|
+
</body>
|
|
35
|
+
`;
|
|
@@ -10,3 +10,12 @@ it('renders the AccordionSectionSummaryHeading with no props', () => {
|
|
|
10
10
|
).baseElement
|
|
11
11
|
).toMatchSnapshot();
|
|
12
12
|
});
|
|
13
|
+
it('renders the AccordionSectionSummaryHeading with variant=arrows prop', () => {
|
|
14
|
+
expect(
|
|
15
|
+
render(
|
|
16
|
+
<AccordionSectionSummaryHeading variant="arrows">
|
|
17
|
+
hello
|
|
18
|
+
</AccordionSectionSummaryHeading>
|
|
19
|
+
).baseElement
|
|
20
|
+
).toMatchSnapshot();
|
|
21
|
+
});
|
|
@@ -2,7 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
4
|
|
|
5
|
-
export interface AccordionSectionSummaryHeadingProps extends BaseProps<'h2'> {
|
|
5
|
+
export interface AccordionSectionSummaryHeadingProps extends BaseProps<'h2'> {
|
|
6
|
+
/*
|
|
7
|
+
* The type of the icon to be displayed on the right side of the heading.
|
|
8
|
+
* @default 'default'
|
|
9
|
+
*/
|
|
10
|
+
variant?: 'default' | 'arrows';
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* AccordionSectionSummaryHeading should be placed inside AccordionSectionSummary.
|
|
8
14
|
*/
|
|
@@ -10,7 +16,7 @@ export const AccordionSectionSummaryHeading = React.forwardRef<
|
|
|
10
16
|
HTMLHeadingElement,
|
|
11
17
|
AccordionSectionSummaryHeadingProps
|
|
12
18
|
>(function AccordionSectionSummaryHeading(
|
|
13
|
-
{ className, children, ...props },
|
|
19
|
+
{ variant, className, children, ...props },
|
|
14
20
|
ref
|
|
15
21
|
) {
|
|
16
22
|
return (
|
|
@@ -27,6 +33,7 @@ export const AccordionSectionSummaryHeading = React.forwardRef<
|
|
|
27
33
|
as="span"
|
|
28
34
|
className={clsx({
|
|
29
35
|
'ds-accordion__section-button': true,
|
|
36
|
+
'ds-accordion__section-button--arrows': variant === 'arrows',
|
|
30
37
|
})}
|
|
31
38
|
>
|
|
32
39
|
{children}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`renders the
|
|
3
|
+
exports[`renders the CircularProgressBase 1`] = `
|
|
4
4
|
<body>
|
|
5
5
|
<div>
|
|
6
6
|
<svg
|
|
@@ -22,7 +22,7 @@ exports[`renders the CircularProgress 1`] = `
|
|
|
22
22
|
</body>
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
|
-
exports[`renders the
|
|
25
|
+
exports[`renders the CircularProgressBase with color=secondary and size lg props 1`] = `
|
|
26
26
|
<body>
|
|
27
27
|
<div>
|
|
28
28
|
<svg
|
|
@@ -44,7 +44,7 @@ exports[`renders the CircularProgress with color=secondary and size lg props 1`]
|
|
|
44
44
|
</body>
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
|
-
exports[`renders the
|
|
47
|
+
exports[`renders the CircularProgressBase with color=secondary and size sm props 1`] = `
|
|
48
48
|
<body>
|
|
49
49
|
<div>
|
|
50
50
|
<svg
|
|
@@ -66,7 +66,7 @@ exports[`renders the CircularProgress with color=secondary and size sm props 1`]
|
|
|
66
66
|
</body>
|
|
67
67
|
`;
|
|
68
68
|
|
|
69
|
-
exports[`renders the
|
|
69
|
+
exports[`renders the CircularProgressBase with color=secondary prop 1`] = `
|
|
70
70
|
<body>
|
|
71
71
|
<div>
|
|
72
72
|
<svg
|
|
@@ -88,7 +88,7 @@ exports[`renders the CircularProgress with color=secondary prop 1`] = `
|
|
|
88
88
|
</body>
|
|
89
89
|
`;
|
|
90
90
|
|
|
91
|
-
exports[`renders the
|
|
91
|
+
exports[`renders the CircularProgressBase with size lg 1`] = `
|
|
92
92
|
<body>
|
|
93
93
|
<div>
|
|
94
94
|
<svg
|
|
@@ -110,7 +110,7 @@ exports[`renders the CircularProgress with size lg 1`] = `
|
|
|
110
110
|
</body>
|
|
111
111
|
`;
|
|
112
112
|
|
|
113
|
-
exports[`renders the
|
|
113
|
+
exports[`renders the CircularProgressBase with size sm 1`] = `
|
|
114
114
|
<body>
|
|
115
115
|
<div>
|
|
116
116
|
<svg
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import CircularProgressBase from '@digigov/react-core/CircularProgressBase';
|
|
5
|
+
|
|
6
|
+
it('renders the CircularProgressBase', () => {
|
|
7
|
+
expect(render(<CircularProgressBase />).baseElement).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('renders the CircularProgressBase with size sm', () => {
|
|
11
|
+
expect(
|
|
12
|
+
render(<CircularProgressBase size="sm" />).baseElement
|
|
13
|
+
).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('renders the CircularProgressBase with size lg', () => {
|
|
17
|
+
expect(
|
|
18
|
+
render(<CircularProgressBase size="lg" />).baseElement
|
|
19
|
+
).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders the CircularProgressBase with color=secondary prop', () => {
|
|
23
|
+
expect(
|
|
24
|
+
render(<CircularProgressBase color={'secondary'} />).baseElement
|
|
25
|
+
).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders the CircularProgressBase with color=secondary and size sm props', () => {
|
|
29
|
+
expect(
|
|
30
|
+
render(<CircularProgressBase color={'secondary'} size="sm" />).baseElement
|
|
31
|
+
).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('renders the CircularProgressBase with color=secondary and size lg props', () => {
|
|
35
|
+
expect(
|
|
36
|
+
render(<CircularProgressBase color={'secondary'} size="lg" />).baseElement
|
|
37
|
+
).toMatchSnapshot();
|
|
38
|
+
});
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface CircularProgressBaseProps extends BaseProps<'svg'> {
|
|
6
6
|
/**
|
|
7
7
|
* color prop is optional.
|
|
8
8
|
* color prop is used to change the color of the loader.
|
|
@@ -22,12 +22,12 @@ export interface CircularProgressProps extends BaseProps<'svg'> {
|
|
|
22
22
|
size?: 'sm' | 'md' | 'lg';
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Use
|
|
26
|
-
*
|
|
25
|
+
* Use CircularProgressBase component as an animated loader.
|
|
26
|
+
* CircularProgressBase can be used inside LoaderContainer component.
|
|
27
27
|
*/
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export const CircularProgressBase = React.forwardRef<
|
|
29
|
+
SVGElement,
|
|
30
|
+
CircularProgressBaseProps
|
|
31
31
|
>(function CircularProgress(
|
|
32
32
|
{ color = 'primary', size = 'md', className, ...props },
|
|
33
33
|
ref
|
|
@@ -60,4 +60,4 @@ export const CircularProgress = React.forwardRef<
|
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
export default
|
|
63
|
+
export default CircularProgressBase;
|
|
@@ -2,7 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
4
|
|
|
5
|
-
export interface DetailsContentProps extends BaseProps<'div'> {
|
|
5
|
+
export interface DetailsContentProps extends BaseProps<'div'> {
|
|
6
|
+
/*
|
|
7
|
+
** color is optional. Default value is 'primary'.
|
|
8
|
+
* @value 'primary'
|
|
9
|
+
* @value 'secondary'
|
|
10
|
+
* @default 'primary'
|
|
11
|
+
* */
|
|
12
|
+
color?: 'primary' | 'secondary';
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
*DetailsContent component wraps the content text.
|
|
8
16
|
*It is used inside Details component as children
|
|
@@ -10,13 +18,14 @@ export interface DetailsContentProps extends BaseProps<'div'> {}
|
|
|
10
18
|
export const DetailsContent = React.forwardRef<
|
|
11
19
|
HTMLDivElement,
|
|
12
20
|
DetailsContentProps
|
|
13
|
-
>(function DetailsContent({ className, children, ...props }, ref) {
|
|
21
|
+
>(function DetailsContent({ color, className, children, ...props }, ref) {
|
|
14
22
|
return (
|
|
15
23
|
<Base
|
|
16
24
|
as="div"
|
|
17
25
|
ref={ref}
|
|
18
26
|
className={clsx(className, {
|
|
19
27
|
'ds-details__content': true,
|
|
28
|
+
'ds-details__content--secondary': color === 'secondary',
|
|
20
29
|
})}
|
|
21
30
|
{...props}
|
|
22
31
|
>
|
package/src/Grid/index.tsx
CHANGED
|
@@ -32,13 +32,7 @@ export interface GridProps extends BaseProps<'div' | 'aside' | 'main'> {
|
|
|
32
32
|
inline?: boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Defines the space between the type item components. It can only be used on a type container component.
|
|
35
|
-
* @value 1
|
|
36
|
-
* @value 2
|
|
37
|
-
* @value 4
|
|
38
|
-
* @value 6
|
|
39
|
-
* @value 8
|
|
40
|
-
* @value 10
|
|
41
|
-
* @value 12
|
|
35
|
+
* @value 1 - 12
|
|
42
36
|
* @value object
|
|
43
37
|
* @default undefined
|
|
44
38
|
*/
|
|
@@ -35,7 +35,7 @@ export const NavListItemActionBase = React.forwardRef<
|
|
|
35
35
|
HTMLButtonElement | HTMLAnchorElement,
|
|
36
36
|
NavListItemActionBaseProps
|
|
37
37
|
>(function NavListItemActionBase(
|
|
38
|
-
{ label, arrow = false, href, className, children, ...props },
|
|
38
|
+
{ label, arrow = false, href, className, children, badgeText, ...props },
|
|
39
39
|
ref
|
|
40
40
|
) {
|
|
41
41
|
return (
|
|
@@ -59,7 +59,7 @@ export const NavListItemActionBase = React.forwardRef<
|
|
|
59
59
|
{children || label}
|
|
60
60
|
</NavListItemButton>
|
|
61
61
|
)}
|
|
62
|
-
{
|
|
62
|
+
{badgeText && <NavListItemBadge text={badgeText} />}
|
|
63
63
|
</NavListItemActionContainer>
|
|
64
64
|
);
|
|
65
65
|
});
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`renders the SummaryList with border="true" 1`] = `
|
|
4
|
+
<body>
|
|
5
|
+
<div>
|
|
6
|
+
<dl
|
|
7
|
+
class="ds-summary-list"
|
|
8
|
+
>
|
|
9
|
+
hello
|
|
10
|
+
</dl>
|
|
11
|
+
</div>
|
|
12
|
+
</body>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`renders the SummaryList with error="true 1`] = `
|
|
16
|
+
<body>
|
|
17
|
+
<div>
|
|
18
|
+
<dl
|
|
19
|
+
class="ds-summary-list ds-summary-list--error"
|
|
20
|
+
>
|
|
21
|
+
hello
|
|
22
|
+
</dl>
|
|
23
|
+
</div>
|
|
24
|
+
</body>
|
|
25
|
+
`;
|
|
26
|
+
|
|
3
27
|
exports[`renders the SummaryList with no props 1`] = `
|
|
4
28
|
<body>
|
|
5
29
|
<div>
|
|
@@ -11,3 +35,15 @@ exports[`renders the SummaryList with no props 1`] = `
|
|
|
11
35
|
</div>
|
|
12
36
|
</body>
|
|
13
37
|
`;
|
|
38
|
+
|
|
39
|
+
exports[`renders the SummaryList with noLastBorder="true 1`] = `
|
|
40
|
+
<body>
|
|
41
|
+
<div>
|
|
42
|
+
<dl
|
|
43
|
+
class="ds-summary-list ds-summary-list--no-last-border"
|
|
44
|
+
>
|
|
45
|
+
hello
|
|
46
|
+
</dl>
|
|
47
|
+
</div>
|
|
48
|
+
</body>
|
|
49
|
+
`;
|
|
@@ -8,3 +8,18 @@ it('renders the SummaryList with no props', () => {
|
|
|
8
8
|
render(<SummaryList>hello</SummaryList>).baseElement
|
|
9
9
|
).toMatchSnapshot();
|
|
10
10
|
});
|
|
11
|
+
it('renders the SummaryList with border="true"', () => {
|
|
12
|
+
expect(
|
|
13
|
+
render(<SummaryList border>hello</SummaryList>).baseElement
|
|
14
|
+
).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
it('renders the SummaryList with noLastBorder="true', () => {
|
|
17
|
+
expect(
|
|
18
|
+
render(<SummaryList noLastBorder>hello</SummaryList>).baseElement
|
|
19
|
+
).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it('renders the SummaryList with error="true', () => {
|
|
22
|
+
expect(
|
|
23
|
+
render(<SummaryList error>hello</SummaryList>).baseElement
|
|
24
|
+
).toMatchSnapshot();
|
|
25
|
+
});
|
|
@@ -6,7 +6,7 @@ export interface SummaryListProps extends BaseProps<'dl'> {
|
|
|
6
6
|
/**
|
|
7
7
|
* border is optional.
|
|
8
8
|
* By default, SummaryList has borders. You can remove borders by using border prop.
|
|
9
|
-
* By default is true
|
|
9
|
+
* By default is true.
|
|
10
10
|
* @value true
|
|
11
11
|
* @value false
|
|
12
12
|
* @default true
|
|
@@ -15,12 +15,21 @@ export interface SummaryListProps extends BaseProps<'dl'> {
|
|
|
15
15
|
/**
|
|
16
16
|
* noLastBorder is optional.
|
|
17
17
|
* By default, SummaryList has borders. You can remove last border by using noLastBorder prop.
|
|
18
|
-
* By default is
|
|
18
|
+
* By default is false.
|
|
19
19
|
* @value true
|
|
20
20
|
* @value false
|
|
21
21
|
* @default false
|
|
22
22
|
*/
|
|
23
23
|
noLastBorder?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* error is optional.
|
|
27
|
+
* If true, the SummaryList will be styled to indicate an error state.
|
|
28
|
+
* @value true
|
|
29
|
+
* @value false
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
error?: boolean;
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
35
|
* SummaryList used as a table with summary information.
|
|
@@ -28,7 +37,14 @@ export interface SummaryListProps extends BaseProps<'dl'> {
|
|
|
28
37
|
*/
|
|
29
38
|
export const SummaryList = React.forwardRef<HTMLDListElement, SummaryListProps>(
|
|
30
39
|
function SummaryList(
|
|
31
|
-
{
|
|
40
|
+
{
|
|
41
|
+
border = true,
|
|
42
|
+
noLastBorder = false,
|
|
43
|
+
error = false,
|
|
44
|
+
className,
|
|
45
|
+
children,
|
|
46
|
+
...props
|
|
47
|
+
},
|
|
32
48
|
ref
|
|
33
49
|
) {
|
|
34
50
|
return (
|
|
@@ -39,6 +55,7 @@ export const SummaryList = React.forwardRef<HTMLDListElement, SummaryListProps>(
|
|
|
39
55
|
'ds-summary-list': true,
|
|
40
56
|
'ds-summary-list--no-border': !border,
|
|
41
57
|
'ds-summary-list--no-last-border': noLastBorder,
|
|
58
|
+
'ds-summary-list--error': error === true,
|
|
42
59
|
})}
|
|
43
60
|
{...props}
|
|
44
61
|
>
|
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`renders the SummaryListItemKey with error="true" 1`] = `
|
|
4
|
+
<body>
|
|
5
|
+
<div>
|
|
6
|
+
<dt
|
|
7
|
+
class="ds-summary-list__key ds-summary-list__key--sm-3 ds-summary-list__key--error"
|
|
8
|
+
>
|
|
9
|
+
<span
|
|
10
|
+
class="ds-visually-hidden"
|
|
11
|
+
>
|
|
12
|
+
Λανθασμένο πεδίο
|
|
13
|
+
</span>
|
|
14
|
+
hello
|
|
15
|
+
</dt>
|
|
16
|
+
</div>
|
|
17
|
+
</body>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`renders the SummaryListItemKey with error="true" and errorAssistiveText="wrong" 1`] = `
|
|
21
|
+
<body>
|
|
22
|
+
<div>
|
|
23
|
+
<dt
|
|
24
|
+
class="ds-summary-list__key ds-summary-list__key--sm-3 ds-summary-list__key--error"
|
|
25
|
+
>
|
|
26
|
+
<span
|
|
27
|
+
class="ds-visually-hidden"
|
|
28
|
+
>
|
|
29
|
+
wrong
|
|
30
|
+
</span>
|
|
31
|
+
hello
|
|
32
|
+
</dt>
|
|
33
|
+
</div>
|
|
34
|
+
</body>
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
exports[`renders the SummaryListItemKey with lg=9 1`] = `
|
|
38
|
+
<body>
|
|
39
|
+
<div>
|
|
40
|
+
<dt
|
|
41
|
+
class="ds-summary-list__key ds-summary-list__key--sm-3 ds-summary-list__key--lg-9"
|
|
42
|
+
>
|
|
43
|
+
hello
|
|
44
|
+
</dt>
|
|
45
|
+
</div>
|
|
46
|
+
</body>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
exports[`renders the SummaryListItemKey with md=6 1`] = `
|
|
50
|
+
<body>
|
|
51
|
+
<div>
|
|
52
|
+
<dt
|
|
53
|
+
class="ds-summary-list__key ds-summary-list__key--sm-3 ds-summary-list__key--md-6"
|
|
54
|
+
>
|
|
55
|
+
hello
|
|
56
|
+
</dt>
|
|
57
|
+
</div>
|
|
58
|
+
</body>
|
|
59
|
+
`;
|
|
60
|
+
|
|
3
61
|
exports[`renders the SummaryListItemKey with no props 1`] = `
|
|
4
62
|
<body>
|
|
5
63
|
<div>
|
|
@@ -11,3 +69,15 @@ exports[`renders the SummaryListItemKey with no props 1`] = `
|
|
|
11
69
|
</div>
|
|
12
70
|
</body>
|
|
13
71
|
`;
|
|
72
|
+
|
|
73
|
+
exports[`renders the SummaryListItemKey with sm=4 1`] = `
|
|
74
|
+
<body>
|
|
75
|
+
<div>
|
|
76
|
+
<dt
|
|
77
|
+
class="ds-summary-list__key ds-summary-list__key--sm-4"
|
|
78
|
+
>
|
|
79
|
+
hello
|
|
80
|
+
</dt>
|
|
81
|
+
</div>
|
|
82
|
+
</body>
|
|
83
|
+
`;
|
|
@@ -8,3 +8,32 @@ it('renders the SummaryListItemKey with no props', () => {
|
|
|
8
8
|
render(<SummaryListItemKey>hello</SummaryListItemKey>).baseElement
|
|
9
9
|
).toMatchSnapshot();
|
|
10
10
|
});
|
|
11
|
+
it('renders the SummaryListItemKey with sm=4', () => {
|
|
12
|
+
expect(
|
|
13
|
+
render(<SummaryListItemKey sm={4}>hello</SummaryListItemKey>).baseElement
|
|
14
|
+
).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
it('renders the SummaryListItemKey with md=6', () => {
|
|
17
|
+
expect(
|
|
18
|
+
render(<SummaryListItemKey md={6}>hello</SummaryListItemKey>).baseElement
|
|
19
|
+
).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it('renders the SummaryListItemKey with lg=9', () => {
|
|
22
|
+
expect(
|
|
23
|
+
render(<SummaryListItemKey lg={9}>hello</SummaryListItemKey>).baseElement
|
|
24
|
+
).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
it('renders the SummaryListItemKey with error="true"', () => {
|
|
27
|
+
expect(
|
|
28
|
+
render(<SummaryListItemKey error>hello</SummaryListItemKey>).baseElement
|
|
29
|
+
).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
it('renders the SummaryListItemKey with error="true" and errorAssistiveText="wrong"', () => {
|
|
32
|
+
expect(
|
|
33
|
+
render(
|
|
34
|
+
<SummaryListItemKey error errorAssistiveText="wrong">
|
|
35
|
+
hello
|
|
36
|
+
</SummaryListItemKey>
|
|
37
|
+
).baseElement
|
|
38
|
+
).toMatchSnapshot();
|
|
39
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
|
+
import VisuallyHidden from '@digigov/react-core/VisuallyHidden';
|
|
4
5
|
|
|
5
6
|
export interface SummaryListItemKeyProps extends BaseProps<'dt'> {
|
|
6
7
|
/**
|
|
@@ -16,6 +17,22 @@ export interface SummaryListItemKeyProps extends BaseProps<'dt'> {
|
|
|
16
17
|
* lg shows the width of the key column for large screens.
|
|
17
18
|
*/
|
|
18
19
|
lg?: WidthValues;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* error is optional.
|
|
23
|
+
* Use error prop to highlight the SummaryListItemKey when there is an error in the corresponding field.
|
|
24
|
+
* @value true
|
|
25
|
+
* @value false
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
error?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* errorAssistiveText is optional.
|
|
32
|
+
* Default value is "Λανθασμένο πεδίο".
|
|
33
|
+
* errorAssistiveText is used to provide a textual warning for assistive technologies like screen readers.
|
|
34
|
+
*/
|
|
35
|
+
errorAssistiveText?: string;
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
export type WidthValues = 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
@@ -27,7 +44,16 @@ export const SummaryListItemKey = React.forwardRef<
|
|
|
27
44
|
HTMLElement,
|
|
28
45
|
SummaryListItemKeyProps
|
|
29
46
|
>(function SummaryListItemKey(
|
|
30
|
-
{
|
|
47
|
+
{
|
|
48
|
+
sm = 3,
|
|
49
|
+
md,
|
|
50
|
+
lg,
|
|
51
|
+
error,
|
|
52
|
+
errorAssistiveText = 'Λανθασμένο πεδίο',
|
|
53
|
+
className,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
56
|
+
},
|
|
31
57
|
ref
|
|
32
58
|
) {
|
|
33
59
|
return (
|
|
@@ -39,9 +65,11 @@ export const SummaryListItemKey = React.forwardRef<
|
|
|
39
65
|
[`ds-summary-list__key--sm-${sm}`]: sm !== undefined,
|
|
40
66
|
[`ds-summary-list__key--md-${md}`]: md !== undefined,
|
|
41
67
|
[`ds-summary-list__key--lg-${lg}`]: lg !== undefined,
|
|
68
|
+
'ds-summary-list__key--error': error === true,
|
|
42
69
|
})}
|
|
43
70
|
{...props}
|
|
44
71
|
>
|
|
72
|
+
{error === true && <VisuallyHidden>{errorAssistiveText}</VisuallyHidden>}
|
|
45
73
|
{children}
|
|
46
74
|
</Base>
|
|
47
75
|
);
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`renders the SummaryListItemValue with error="true 1`] = `
|
|
4
|
+
<body>
|
|
5
|
+
<div>
|
|
6
|
+
<dd
|
|
7
|
+
class="ds-summary-list__value ds-summary-list__value--error"
|
|
8
|
+
>
|
|
9
|
+
<span
|
|
10
|
+
class="ds-visually-hidden"
|
|
11
|
+
>
|
|
12
|
+
Λανθασμένο πεδίο
|
|
13
|
+
</span>
|
|
14
|
+
hello
|
|
15
|
+
</dd>
|
|
16
|
+
</div>
|
|
17
|
+
</body>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`renders the SummaryListItemValue with error="true and errorAssistiveText="wrong 1`] = `
|
|
21
|
+
<body>
|
|
22
|
+
<div>
|
|
23
|
+
<dd
|
|
24
|
+
class="ds-summary-list__value ds-summary-list__value--error"
|
|
25
|
+
>
|
|
26
|
+
<span
|
|
27
|
+
class="ds-visually-hidden"
|
|
28
|
+
>
|
|
29
|
+
wrong
|
|
30
|
+
</span>
|
|
31
|
+
hello
|
|
32
|
+
</dd>
|
|
33
|
+
</div>
|
|
34
|
+
</body>
|
|
35
|
+
`;
|
|
36
|
+
|
|
3
37
|
exports[`renders the SummaryListItemValue with no props 1`] = `
|
|
4
38
|
<body>
|
|
5
39
|
<div>
|