@amsterdam/design-system-react 0.15.0 → 0.16.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/README.md +1 -1
- package/dist/Accordion/Accordion.js +4 -1
- package/dist/Accordion/Accordion.test.js +19 -3
- package/dist/Accordion/AccordionSection.test.js +1 -1
- package/dist/ActionGroup/ActionGroup.test.js +1 -1
- package/dist/Alert/Alert.test.js +1 -1
- package/dist/Avatar/Avatar.test.js +1 -1
- package/dist/Badge/Badge.test.js +1 -1
- package/dist/Blockquote/Blockquote.test.js +3 -4
- package/dist/Breadcrumb/Breadcrumb.test.js +1 -1
- package/dist/Breadcrumb/BreadcrumbLink.test.js +1 -1
- package/dist/Breakout/Breakout.test.js +11 -19
- package/dist/Breakout/BreakoutCell.d.ts +3 -1
- package/dist/Breakout/BreakoutCell.js +1 -0
- package/dist/Breakout/BreakoutCell.test.js +20 -16
- package/dist/Button/Button.test.js +8 -1
- package/dist/Card/Card.d.ts +10 -0
- package/dist/Card/Card.js +8 -1
- package/dist/Card/Card.test.js +1 -1
- package/dist/Card/CardHeading.d.ts +11 -0
- package/dist/Card/CardHeading.js +10 -0
- package/dist/Card/CardHeading.test.js +34 -0
- package/dist/Card/CardHeadingGroup.test.js +1 -1
- package/dist/Card/CardImage.d.ts +7 -0
- package/dist/Card/CardImage.js +10 -0
- package/dist/{Footer/FooterSpotlight.test.js → Card/CardImage.test.js} +9 -9
- package/dist/Card/CardLink.test.js +1 -1
- package/dist/CharacterCount/CharacterCount.test.js +1 -1
- package/dist/Checkbox/Checkbox.test.js +2 -3
- package/dist/Column/Column.d.ts +4 -3
- package/dist/Column/Column.js +2 -1
- package/dist/Column/Column.test.js +10 -12
- package/dist/DateInput/DateInput.test.js +1 -1
- package/dist/DescriptionList/DescriptionList.test.js +1 -1
- package/dist/DescriptionList/DescriptionListDescription.test.js +1 -1
- package/dist/DescriptionList/DescriptionListSection.test.js +1 -1
- package/dist/DescriptionList/DescriptionListTerm.test.js +1 -1
- package/dist/Dialog/Dialog.test.js +1 -1
- package/dist/ErrorMessage/ErrorMessage.test.js +1 -1
- package/dist/Field/Field.test.js +1 -1
- package/dist/FieldSet/FieldSet.test.js +1 -1
- package/dist/Figure/Figure.test.js +1 -1
- package/dist/Figure/FigureCaption.test.js +1 -1
- package/dist/FileInput/FileInput.test.js +1 -1
- package/dist/FileList/FileList.test.js +1 -1
- package/dist/FileList/FileListItem.test.js +1 -1
- package/dist/Grid/Grid.d.ts +8 -5
- package/dist/Grid/Grid.js +2 -0
- package/dist/Grid/Grid.test.js +13 -29
- package/dist/Grid/GridCell.test.js +2 -8
- package/dist/Grid/paddingClasses.d.ts +2 -2
- package/dist/Heading/Heading.test.js +17 -11
- package/dist/Hint/Hint.test.js +1 -1
- package/dist/Icon/Icon.d.ts +1 -1
- package/dist/Icon/Icon.test.js +3 -4
- package/dist/IconButton/IconButton.js +1 -1
- package/dist/IconButton/IconButton.test.js +1 -1
- package/dist/Image/Image.d.ts +4 -8
- package/dist/Image/Image.test.js +1 -1
- package/dist/ImageSlider/ImageSlider.test.js +1 -1
- package/dist/ImageSlider/ImageSliderItem.test.js +1 -1
- package/dist/ImageSlider/ImageSliderScroller.test.js +1 -1
- package/dist/ImageSlider/ImageSliderThumbnails.js +1 -1
- package/dist/ImageSlider/ImageSliderThumbnails.test.js +1 -1
- package/dist/InvalidFormAlert/InvalidFormAlert.test.js +1 -1
- package/dist/Label/Label.test.js +3 -4
- package/dist/Link/Link.d.ts +0 -6
- package/dist/Link/Link.js +1 -1
- package/dist/Link/Link.test.js +22 -29
- package/dist/LinkList/LinkList.test.js +1 -1
- package/dist/LinkList/LinkListLink.test.js +1 -1
- package/dist/Logo/Logo.test.js +2 -3
- package/dist/Mark/Mark.test.js +1 -1
- package/dist/OrderedList/OrderedList.test.js +1 -1
- package/dist/OrderedList/OrderedListItem.test.js +1 -1
- package/dist/Overlap/Overlap.test.js +1 -1
- package/dist/{Footer/FooterSpotlight.d.ts → Page/Page.d.ts} +2 -2
- package/dist/Page/Page.js +9 -0
- package/dist/{MegaMenu/MegaMenu.test.js → Page/Page.test.js} +9 -9
- package/dist/Page/index.d.ts +2 -0
- package/dist/Page/index.js +1 -0
- package/dist/{Footer/Footer.d.ts → PageFooter/PageFooter.d.ts} +2 -2
- package/dist/PageFooter/PageFooter.js +17 -0
- package/dist/{Footer/Footer.test.js → PageFooter/PageFooter.test.js} +9 -9
- package/dist/{Footer/FooterMenu.d.ts → PageFooter/PageFooterMenu.d.ts} +2 -2
- package/dist/PageFooter/PageFooterMenu.js +9 -0
- package/dist/{Footer/FooterMenu.test.js → PageFooter/PageFooterMenu.test.js} +9 -9
- package/dist/{Footer/FooterMenuLink.d.ts → PageFooter/PageFooterMenuLink.d.ts} +2 -2
- package/dist/PageFooter/PageFooterMenuLink.js +9 -0
- package/dist/{Footer/FooterMenuLink.test.js → PageFooter/PageFooterMenuLink.test.js} +9 -9
- package/dist/PageFooter/PageFooterSpotlight.d.ts +9 -0
- package/dist/PageFooter/PageFooterSpotlight.js +9 -0
- package/dist/{MegaMenu/MegaMenuListCategory.test.js → PageFooter/PageFooterSpotlight.test.js} +9 -9
- package/dist/PageFooter/index.d.ts +5 -0
- package/dist/PageFooter/index.js +1 -0
- package/dist/{Header/Header.d.ts → PageHeader/PageHeader.d.ts} +4 -4
- package/dist/PageHeader/PageHeader.js +31 -0
- package/dist/{Header/Header.test.js → PageHeader/PageHeader.test.js} +37 -38
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.d.ts +2 -0
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.js +6 -0
- package/dist/{Header/HeaderGridCellNarrowWindowOnly.test.js → PageHeader/PageHeaderGridCellNarrowWindowOnly.test.js} +10 -10
- package/dist/PageHeader/PageHeaderMenuIcon.d.ts +2 -0
- package/dist/PageHeader/PageHeaderMenuIcon.js +2 -0
- package/dist/{Header/HeaderMenuLink.d.ts → PageHeader/PageHeaderMenuLink.d.ts} +2 -2
- package/dist/PageHeader/PageHeaderMenuLink.js +5 -0
- package/dist/{Header/HeaderMenuLink.test.js → PageHeader/PageHeaderMenuLink.test.js} +13 -13
- package/dist/PageHeader/index.d.ts +3 -0
- package/dist/PageHeader/index.js +1 -0
- package/dist/PageHeading/PageHeading.test.js +2 -3
- package/dist/Pagination/Pagination.test.js +1 -1
- package/dist/Paragraph/Paragraph.test.js +1 -1
- package/dist/PasswordInput/PasswordInput.test.js +1 -1
- package/dist/Radio/Radio.test.js +1 -1
- package/dist/Row/Row.d.ts +4 -3
- package/dist/Row/Row.js +2 -1
- package/dist/Row/Row.test.js +10 -12
- package/dist/SearchField/SearchField.d.ts +2 -0
- package/dist/SearchField/SearchField.test.js +2 -3
- package/dist/SearchField/SearchFieldInput.test.js +2 -3
- package/dist/Select/Select.test.js +1 -1
- package/dist/Select/SelectOption.test.js +1 -1
- package/dist/Select/SelectOptionGroup.test.js +1 -1
- package/dist/SkipLink/SkipLink.test.js +1 -1
- package/dist/Spotlight/Spotlight.d.ts +4 -2
- package/dist/Spotlight/Spotlight.js +1 -0
- package/dist/Spotlight/Spotlight.test.js +11 -9
- package/dist/StandaloneLink/StandaloneLink.d.ts +17 -0
- package/dist/StandaloneLink/StandaloneLink.js +10 -0
- package/dist/StandaloneLink/StandaloneLink.test.js +40 -0
- package/dist/StandaloneLink/index.d.ts +2 -0
- package/dist/StandaloneLink/index.js +1 -0
- package/dist/Switch/Switch.test.js +1 -1
- package/dist/Table/Table.test.js +1 -1
- package/dist/Table/TableBody.test.js +1 -1
- package/dist/Table/TableCaption.test.js +1 -1
- package/dist/Table/TableCell.test.js +1 -1
- package/dist/Table/TableFooter.test.js +1 -1
- package/dist/Table/TableHeader.test.js +1 -1
- package/dist/Table/TableHeaderCell.test.js +1 -1
- package/dist/Table/TableRow.test.js +1 -1
- package/dist/TableOfContents/TableOfContents.test.js +1 -1
- package/dist/TableOfContents/TableOfContentsLink.test.js +1 -1
- package/dist/TableOfContents/TableOfContentsList.test.js +1 -1
- package/dist/Tabs/Tabs.d.ts +6 -6
- package/dist/Tabs/Tabs.js +4 -5
- package/dist/Tabs/Tabs.test.js +21 -6
- package/dist/Tabs/TabsButton.d.ts +4 -4
- package/dist/Tabs/TabsButton.js +4 -4
- package/dist/Tabs/TabsButton.test.js +10 -10
- package/dist/Tabs/TabsContext.d.ts +2 -7
- package/dist/Tabs/TabsContext.js +0 -1
- package/dist/Tabs/TabsList.js +1 -1
- package/dist/Tabs/TabsList.test.js +1 -1
- package/dist/Tabs/TabsPanel.d.ts +4 -4
- package/dist/Tabs/TabsPanel.js +4 -4
- package/dist/Tabs/TabsPanel.test.js +10 -12
- package/dist/TextArea/TextArea.test.js +1 -1
- package/dist/TextInput/TextInput.test.js +2 -3
- package/dist/TimeInput/TimeInput.test.js +1 -1
- package/dist/UnorderedList/UnorderedList.test.js +1 -1
- package/dist/UnorderedList/UnorderedListItem.test.js +1 -1
- package/dist/common/accessibility.d.ts +9 -1
- package/dist/index.cjs.js +1000 -1057
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +164 -194
- package/dist/index.esm.js +998 -1053
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/dist/Footer/Footer.js +0 -17
- package/dist/Footer/FooterMenu.js +0 -9
- package/dist/Footer/FooterMenuLink.js +0 -9
- package/dist/Footer/FooterSpotlight.js +0 -9
- package/dist/Footer/index.d.ts +0 -5
- package/dist/Footer/index.js +0 -1
- package/dist/Header/Header.js +0 -31
- package/dist/Header/HeaderGridCellNarrowWindowOnly.d.ts +0 -2
- package/dist/Header/HeaderGridCellNarrowWindowOnly.js +0 -6
- package/dist/Header/HeaderMenuIcon.d.ts +0 -2
- package/dist/Header/HeaderMenuIcon.js +0 -2
- package/dist/Header/HeaderMenuLink.js +0 -5
- package/dist/Header/index.d.ts +0 -3
- package/dist/Header/index.js +0 -1
- package/dist/MegaMenu/MegaMenu.d.ts +0 -14
- package/dist/MegaMenu/MegaMenu.js +0 -12
- package/dist/MegaMenu/MegaMenuListCategory.d.ts +0 -9
- package/dist/MegaMenu/MegaMenuListCategory.js +0 -9
- package/dist/MegaMenu/index.d.ts +0 -3
- package/dist/MegaMenu/index.js +0 -1
- package/dist/PageMenu/PageMenu.d.ts +0 -25
- package/dist/PageMenu/PageMenu.js +0 -12
- package/dist/PageMenu/PageMenu.test.js +0 -45
- package/dist/PageMenu/PageMenuLink.d.ts +0 -13
- package/dist/PageMenu/PageMenuLink.js +0 -10
- package/dist/PageMenu/PageMenuLink.test.js +0 -40
- package/dist/PageMenu/index.d.ts +0 -3
- package/dist/PageMenu/index.js +0 -1
- package/dist/Screen/Screen.d.ts +0 -21
- package/dist/Screen/Screen.js +0 -9
- package/dist/Screen/Screen.test.d.ts +0 -1
- package/dist/Screen/Screen.test.js +0 -40
- package/dist/Screen/index.d.ts +0 -2
- package/dist/Screen/index.js +0 -1
- package/dist/TopTaskLink/TopTaskLink.d.ts +0 -17
- package/dist/TopTaskLink/TopTaskLink.js +0 -9
- package/dist/TopTaskLink/TopTaskLink.test.d.ts +0 -1
- package/dist/TopTaskLink/TopTaskLink.test.js +0 -42
- package/dist/TopTaskLink/index.d.ts +0 -1
- package/dist/TopTaskLink/index.js +0 -1
- /package/dist/{Footer/Footer.test.d.ts → Card/CardHeading.test.d.ts} +0 -0
- /package/dist/{Footer/FooterMenu.test.d.ts → Card/CardImage.test.d.ts} +0 -0
- /package/dist/{Footer/FooterMenuLink.test.d.ts → Page/Page.test.d.ts} +0 -0
- /package/dist/{Footer/FooterSpotlight.test.d.ts → PageFooter/PageFooter.test.d.ts} +0 -0
- /package/dist/{Header/HeaderGridCellNarrowWindowOnly.test.d.ts → PageFooter/PageFooterMenu.test.d.ts} +0 -0
- /package/dist/{Header/HeaderMenuLink.test.d.ts → PageFooter/PageFooterMenuLink.test.d.ts} +0 -0
- /package/dist/{MegaMenu/MegaMenu.test.d.ts → PageFooter/PageFooterSpotlight.test.d.ts} +0 -0
- /package/dist/{Header/Header.test.d.ts → PageHeader/PageHeader.test.d.ts} +0 -0
- /package/dist/{MegaMenu/MegaMenuListCategory.test.d.ts → PageHeader/PageHeaderGridCellNarrowWindowOnly.test.d.ts} +0 -0
- /package/dist/{PageMenu/PageMenu.test.d.ts → PageHeader/PageHeaderMenuLink.test.d.ts} +0 -0
- /package/dist/{Header → PageHeader}/matchMedia.mock.d.ts +0 -0
- /package/dist/{Header → PageHeader}/matchMedia.mock.js +0 -0
- /package/dist/{PageMenu/PageMenuLink.test.d.ts → StandaloneLink/StandaloneLink.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ npm install @amsterdam/design-system-assets @amsterdam/design-system-css @amster
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
The React components themselves are unstyled.
|
|
27
|
-
[Override the design tokens](https://github.com/Amsterdam/design-system/blob/main/proprietary/tokens/README.md) to use them with a different branding.
|
|
27
|
+
[Override the design tokens](https://github.com/Amsterdam/design-system/blob/main/packages-proprietary/tokens/README.md) to use them with a different branding.
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
@@ -12,7 +12,10 @@ const AccordionRoot = forwardRef(({ children, className, headingLevel, sectionAs
|
|
|
12
12
|
const innerRef = useRef(null);
|
|
13
13
|
// use a passed ref if it's there, otherwise use innerRef
|
|
14
14
|
useImperativeHandle(ref, () => innerRef.current);
|
|
15
|
-
const { keyDown } = useKeyboardFocus(innerRef, {
|
|
15
|
+
const { keyDown } = useKeyboardFocus(innerRef, {
|
|
16
|
+
focusableElements: ['.ams-accordion__button:not([disabled])'],
|
|
17
|
+
rotating: true,
|
|
18
|
+
});
|
|
16
19
|
return (_jsx(AccordionContext.Provider, { value: { headingLevel: headingLevel, sectionAs: sectionAs }, children: _jsx("div", { className: clsx('ams-accordion', className), onKeyDown: keyDown, ref: innerRef, children: children }) }));
|
|
17
20
|
});
|
|
18
21
|
AccordionRoot.displayName = 'Accordion';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { createRef } from 'react';
|
|
4
5
|
import { Accordion } from './Accordion';
|
|
5
6
|
import '@testing-library/jest-dom';
|
|
@@ -10,11 +11,26 @@ describe('Accordion', () => {
|
|
|
10
11
|
expect(accordion).toBeInTheDocument();
|
|
11
12
|
expect(accordion).toBeVisible();
|
|
12
13
|
});
|
|
13
|
-
it('renders an
|
|
14
|
+
it('renders an extra class name', () => {
|
|
14
15
|
const { container } = render(_jsx(Accordion, { className: "test", headingLevel: 1 }));
|
|
15
16
|
const accordion = container.querySelector('.ams-accordion');
|
|
16
17
|
expect(accordion).toHaveClass('test');
|
|
17
18
|
});
|
|
19
|
+
it('sets focus on Accordion buttons when using arrow keys', async () => {
|
|
20
|
+
const user = userEvent.setup();
|
|
21
|
+
render(_jsxs(Accordion, { headingLevel: 1, children: [_jsx(Accordion.Section, { label: "one" }), _jsx(Accordion.Section, { label: "two" }), _jsx(Accordion.Section, { label: "three" })] }));
|
|
22
|
+
const firstButton = screen.getByRole('button', { name: 'one' });
|
|
23
|
+
const thirdButton = screen.getByRole('button', { name: 'three' });
|
|
24
|
+
await user.click(firstButton);
|
|
25
|
+
expect(firstButton).toHaveFocus();
|
|
26
|
+
// Click the down arrow key twice
|
|
27
|
+
await user.keyboard('{ArrowDown}');
|
|
28
|
+
await user.keyboard('{ArrowDown}');
|
|
29
|
+
expect(thirdButton).toHaveFocus();
|
|
30
|
+
expect(firstButton).not.toHaveFocus();
|
|
31
|
+
await user.keyboard('{ArrowDown}');
|
|
32
|
+
expect(firstButton).toHaveFocus();
|
|
33
|
+
});
|
|
18
34
|
it('supports ForwardRef in React', () => {
|
|
19
35
|
const ref = createRef();
|
|
20
36
|
const { container } = render(_jsx(Accordion, { headingLevel: 1, ref: ref }));
|
|
@@ -69,7 +69,7 @@ describe('Accordion section', () => {
|
|
|
69
69
|
const icon = button ? button.querySelector('svg:only-child') : null;
|
|
70
70
|
expect(icon).toBeInTheDocument();
|
|
71
71
|
});
|
|
72
|
-
it('renders an
|
|
72
|
+
it('renders an extra class name', () => {
|
|
73
73
|
const { container } = render(_jsx(Accordion.Section, { className: "test", label: testLabel, children: testContent }));
|
|
74
74
|
const accordionSection = container.querySelector('.ams-accordion__section');
|
|
75
75
|
expect(accordionSection).toHaveClass('test');
|
|
@@ -15,7 +15,7 @@ describe('Action Group', () => {
|
|
|
15
15
|
const component = screen.getByRole('group');
|
|
16
16
|
expect(component).toHaveClass('ams-action-group');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(ActionGroup, { className: "extra" }));
|
|
20
20
|
const component = screen.getByRole('group');
|
|
21
21
|
expect(component).toHaveClass('ams-action-group extra');
|
package/dist/Alert/Alert.test.js
CHANGED
|
@@ -18,7 +18,7 @@ describe('Alert', () => {
|
|
|
18
18
|
const component = container.querySelector(':only-child');
|
|
19
19
|
expect(component).toHaveClass('ams-alert');
|
|
20
20
|
});
|
|
21
|
-
it('renders an
|
|
21
|
+
it('renders an extra class name', () => {
|
|
22
22
|
const { container } = render(_jsx(Alert, { className: "extra", heading: "Let op!", headingLevel: 2 }));
|
|
23
23
|
const component = container.querySelector(':only-child');
|
|
24
24
|
expect(component).toHaveClass('ams-alert extra');
|
|
@@ -15,7 +15,7 @@ describe('Avatar', () => {
|
|
|
15
15
|
const component = container.querySelector(':only-child');
|
|
16
16
|
expect(component).toHaveClass('ams-avatar');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
const { container } = render(_jsx(Avatar, { className: "extra", label: "VS" }));
|
|
20
20
|
const component = container.querySelector(':only-child');
|
|
21
21
|
expect(component).toHaveClass('ams-avatar extra');
|
package/dist/Badge/Badge.test.js
CHANGED
|
@@ -15,7 +15,7 @@ describe('Badge', () => {
|
|
|
15
15
|
const component = container.querySelector(':only-child');
|
|
16
16
|
expect(component).toHaveClass('ams-badge');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
const { container } = render(_jsx(Badge, { className: "extra", label: "test" }));
|
|
20
20
|
const component = container.querySelector(':only-child');
|
|
21
21
|
expect(component).toHaveClass('ams-badge extra');
|
|
@@ -23,15 +23,14 @@ describe('Blockquote', () => {
|
|
|
23
23
|
const quote = container.querySelector(':only-child');
|
|
24
24
|
expect(quote).toHaveClass('ams-blockquote');
|
|
25
25
|
});
|
|
26
|
-
it('renders an
|
|
26
|
+
it('renders an extra class name', () => {
|
|
27
27
|
const { container } = render(_jsx(Blockquote, { className: "extra" }));
|
|
28
28
|
const quote = container.querySelector(':only-child');
|
|
29
|
-
expect(quote).toHaveClass('extra');
|
|
30
|
-
expect(quote).toHaveClass('ams-blockquote');
|
|
29
|
+
expect(quote).toHaveClass('ams-blockquote extra');
|
|
31
30
|
});
|
|
32
31
|
it('renders the class name for inverse color', () => {
|
|
33
32
|
const { container } = render(_jsx(Blockquote, { color: "inverse" }));
|
|
34
|
-
const quote = container.querySelector('
|
|
33
|
+
const quote = container.querySelector(':only-child');
|
|
35
34
|
expect(quote).toHaveClass('ams-blockquote--inverse');
|
|
36
35
|
});
|
|
37
36
|
it('supports ForwardRef in React', () => {
|
|
@@ -15,7 +15,7 @@ describe('Breadcrumb', () => {
|
|
|
15
15
|
const component = screen.getByRole('navigation');
|
|
16
16
|
expect(component).toHaveClass('ams-breadcrumb');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(Breadcrumb, { className: "extra" }));
|
|
20
20
|
const component = screen.getByRole('navigation');
|
|
21
21
|
expect(component).toHaveClass('ams-breadcrumb extra');
|
|
@@ -17,7 +17,7 @@ describe('Breadcrumb link', () => {
|
|
|
17
17
|
const link = screen.getByRole('link');
|
|
18
18
|
expect(link).toHaveClass('ams-breadcrumb__link');
|
|
19
19
|
});
|
|
20
|
-
it('renders an
|
|
20
|
+
it('renders an extra class name', () => {
|
|
21
21
|
render(_jsx(BreadcrumbLink, { className: "extra", href: "/" }));
|
|
22
22
|
const component = screen.getByRole('link');
|
|
23
23
|
expect(component).toHaveClass('ams-breadcrumb__link extra');
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
4
|
import { Breakout } from './Breakout';
|
|
5
|
+
import { gridGaps, gridPaddings } from '../Grid/Grid';
|
|
5
6
|
import '@testing-library/jest-dom';
|
|
6
|
-
const paddingSizes = ['small', 'medium', 'large'];
|
|
7
7
|
describe('Breakout', () => {
|
|
8
8
|
it('renders', () => {
|
|
9
9
|
const { container } = render(_jsx(Breakout, {}));
|
|
@@ -16,41 +16,33 @@ describe('Breakout', () => {
|
|
|
16
16
|
const component = container.querySelector(':only-child');
|
|
17
17
|
expect(component).toHaveClass('ams-breakout');
|
|
18
18
|
});
|
|
19
|
-
it('renders an
|
|
19
|
+
it('renders an extra class name', () => {
|
|
20
20
|
const { container } = render(_jsx(Breakout, { className: "extra" }));
|
|
21
21
|
const component = container.querySelector(':only-child');
|
|
22
22
|
expect(component).toHaveClass('ams-breakout extra');
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const { container } = render(_jsx(Breakout, { gapVertical: "small" }));
|
|
31
|
-
const component = container.querySelector(':only-child');
|
|
32
|
-
expect(component).toHaveClass('ams-breakout--gap-vertical--small');
|
|
33
|
-
});
|
|
34
|
-
it(`renders the correct class name for a large gap`, () => {
|
|
35
|
-
const { container } = render(_jsx(Breakout, { gapVertical: "large" }));
|
|
36
|
-
const component = container.querySelector(':only-child');
|
|
37
|
-
expect(component).toHaveClass('ams-breakout--gap-vertical--large');
|
|
24
|
+
gridGaps.forEach((size) => {
|
|
25
|
+
it(`renders the correct class name for a ${size} vertical gap`, () => {
|
|
26
|
+
const { container } = render(_jsx(Breakout, { gapVertical: size }));
|
|
27
|
+
const component = container.querySelector(':only-child');
|
|
28
|
+
expect(component).toHaveClass(`ams-breakout--gap-vertical--${size}`);
|
|
29
|
+
});
|
|
38
30
|
});
|
|
39
|
-
|
|
31
|
+
gridPaddings.forEach((size) => {
|
|
40
32
|
it(`renders the correct class name for a ${size} bottom padding`, () => {
|
|
41
33
|
const { container } = render(_jsx(Breakout, { paddingBottom: size }));
|
|
42
34
|
const component = container.querySelector(':only-child');
|
|
43
35
|
expect(component).toHaveClass(`ams-breakout--padding-bottom--${size}`);
|
|
44
36
|
});
|
|
45
37
|
});
|
|
46
|
-
|
|
38
|
+
gridPaddings.forEach((size) => {
|
|
47
39
|
it(`renders the correct class name for a ${size} top padding`, () => {
|
|
48
40
|
const { container } = render(_jsx(Breakout, { paddingTop: size }));
|
|
49
41
|
const component = container.querySelector(':only-child');
|
|
50
42
|
expect(component).toHaveClass(`ams-breakout--padding-top--${size}`);
|
|
51
43
|
});
|
|
52
44
|
});
|
|
53
|
-
|
|
45
|
+
gridPaddings.forEach((size) => {
|
|
54
46
|
it(`renders the correct class name for a ${size} vertical padding`, () => {
|
|
55
47
|
const { container } = render(_jsx(Breakout, { paddingVertical: size }));
|
|
56
48
|
const component = container.querySelector(':only-child');
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
6
|
import type { BreakoutRowNumber, BreakoutRowNumbers } from './Breakout';
|
|
7
7
|
import type { GridColumnNumber, GridColumnNumbers } from '../Grid/Grid';
|
|
8
|
+
export declare const breakoutCellTags: readonly ["article", "div", "section"];
|
|
9
|
+
type BreakoutCellTag = (typeof breakoutCellTags)[number];
|
|
8
10
|
type BreakoutCellSpanAllProp = {
|
|
9
11
|
/** Lets the cell span the full width of all grid variants. */
|
|
10
12
|
colSpan: 'all';
|
|
@@ -29,7 +31,7 @@ type BreakoutCellRowSpanAndStartProps = {
|
|
|
29
31
|
};
|
|
30
32
|
export type BreakoutCellProps = {
|
|
31
33
|
/** The HTML element to use. */
|
|
32
|
-
as?:
|
|
34
|
+
as?: BreakoutCellTag;
|
|
33
35
|
} & (BreakoutCellSpanAllProp | BreakoutCellSpanAndStartProps) & BreakoutCellRowSpanAndStartProps & PropsWithChildren<HTMLAttributes<HTMLElement>>;
|
|
34
36
|
export declare const BreakoutCell: import("react").ForwardRefExoticComponent<BreakoutCellProps & import("react").RefAttributes<any>>;
|
|
35
37
|
export {};
|
|
@@ -6,5 +6,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
8
|
import { breakoutCellClasses } from './breakoutCellClasses';
|
|
9
|
+
export const breakoutCellTags = ['article', 'div', 'section'];
|
|
9
10
|
export const BreakoutCell = forwardRef(({ as: Tag = 'div', children, className, colSpan, colStart, has, rowSpan, rowStart, ...restProps }, ref) => (_jsx(Tag, { ...restProps, className: clsx('ams-breakout__cell', breakoutCellClasses(colSpan, colStart, rowSpan, rowStart), has && `ams-breakout__cell--has-${has}`, className), ref: ref, children: children })));
|
|
10
11
|
BreakoutCell.displayName = 'Breakout.Cell';
|
|
@@ -3,6 +3,8 @@ import { render, screen } from '@testing-library/react';
|
|
|
3
3
|
import { createRef } from 'react';
|
|
4
4
|
import { Breakout } from './Breakout';
|
|
5
5
|
import '@testing-library/jest-dom';
|
|
6
|
+
import { breakoutCellTags } from './BreakoutCell';
|
|
7
|
+
import { ariaRoleForTag } from '../common/accessibility';
|
|
6
8
|
describe('Breakout cell', () => {
|
|
7
9
|
it('renders', () => {
|
|
8
10
|
const { container } = render(_jsx(Breakout.Cell, {}));
|
|
@@ -15,11 +17,18 @@ describe('Breakout cell', () => {
|
|
|
15
17
|
const component = container.querySelector(':only-child');
|
|
16
18
|
expect(component).toHaveClass('ams-breakout__cell');
|
|
17
19
|
});
|
|
18
|
-
it('renders an
|
|
20
|
+
it('renders an extra class name', () => {
|
|
19
21
|
const { container } = render(_jsx(Breakout.Cell, { className: "extra" }));
|
|
20
22
|
const component = container.querySelector(':only-child');
|
|
21
23
|
expect(component).toHaveClass('ams-breakout__cell extra');
|
|
22
24
|
});
|
|
25
|
+
breakoutCellTags.forEach((tag) => {
|
|
26
|
+
it(`renders with a custom ${tag} tag`, () => {
|
|
27
|
+
const { container } = render(_jsx(Breakout.Cell, { "aria-label": tag === 'section' ? 'Accessible name' : undefined, as: tag }));
|
|
28
|
+
const component = tag === 'div' ? container.querySelector(tag) : screen.getByRole(ariaRoleForTag[tag]);
|
|
29
|
+
expect(component).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
23
32
|
it('supports ForwardRef in React', () => {
|
|
24
33
|
const ref = createRef();
|
|
25
34
|
const { container } = render(_jsx(Breakout.Cell, { ref: ref }));
|
|
@@ -102,19 +111,14 @@ describe('Breakout cell', () => {
|
|
|
102
111
|
const component = container.querySelector(':only-child');
|
|
103
112
|
expect(component).toHaveClass('ams-breakout__cell--row-span-2 ams-breakout__cell--row-span-3-medium ams-breakout__cell--row-span-4-wide ams-breakout__cell--row-start-1 ams-breakout__cell--row-start-2-medium ams-breakout__cell--row-start-3-wide');
|
|
104
113
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
it('renders a custom tag', () => {
|
|
117
|
-
render(_jsx(Breakout.Cell, { as: "article" }));
|
|
118
|
-
const cell = screen.getByRole('article');
|
|
119
|
-
expect(cell).toBeInTheDocument();
|
|
114
|
+
it(`renders the correct class if it has a Figure`, () => {
|
|
115
|
+
const { container } = render(_jsx(Breakout.Cell, { has: "figure" }));
|
|
116
|
+
const component = container.querySelector(':only-child');
|
|
117
|
+
expect(component).toHaveClass(`ams-breakout__cell--has-figure`);
|
|
118
|
+
});
|
|
119
|
+
it(`renders the correct class if it has a Spotlight`, () => {
|
|
120
|
+
const { container } = render(_jsx(Breakout.Cell, { colSpan: "all", has: "spotlight" }));
|
|
121
|
+
const component = container.querySelector(':only-child');
|
|
122
|
+
expect(component).toHaveClass(`ams-breakout__cell--has-spotlight`);
|
|
123
|
+
});
|
|
120
124
|
});
|
|
@@ -13,7 +13,14 @@ describe('Button', () => {
|
|
|
13
13
|
expect(button).toBeInTheDocument();
|
|
14
14
|
expect(button).toBeVisible();
|
|
15
15
|
});
|
|
16
|
-
it('renders
|
|
16
|
+
it('renders a design system BEM class name', () => {
|
|
17
|
+
render(_jsx(Button, { children: "Click me!" }));
|
|
18
|
+
const button = screen.getByRole('button', {
|
|
19
|
+
name: 'Click me!',
|
|
20
|
+
});
|
|
21
|
+
expect(button).toHaveClass('ams-button');
|
|
22
|
+
});
|
|
23
|
+
it('renders an extra class name', () => {
|
|
17
24
|
render(_jsx(Button, { className: "extra", children: "Click me!" }));
|
|
18
25
|
const button = screen.getByRole('button', {
|
|
19
26
|
name: 'Click me!',
|
package/dist/Card/Card.d.ts
CHANGED
|
@@ -7,11 +7,21 @@ export type CardProps = PropsWithChildren<HTMLAttributes<HTMLElement>>;
|
|
|
7
7
|
export declare const Card: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
|
|
8
8
|
children?: import("react").ReactNode | undefined;
|
|
9
9
|
} & import("react").RefAttributes<HTMLElement>> & {
|
|
10
|
+
Heading: import("react").ForwardRefExoticComponent<{
|
|
11
|
+
color?: "inverse";
|
|
12
|
+
level: 1 | 2 | 3 | 4;
|
|
13
|
+
size?: "level-1" | "level-2" | "level-3" | "level-4" | "level-5" | "level-6";
|
|
14
|
+
} & HTMLAttributes<HTMLHeadingElement> & {
|
|
15
|
+
children?: import("react").ReactNode | undefined;
|
|
16
|
+
} & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
10
17
|
HeadingGroup: import("react").ForwardRefExoticComponent<{
|
|
11
18
|
tagline: string;
|
|
12
19
|
} & HTMLAttributes<HTMLElement> & {
|
|
13
20
|
children?: import("react").ReactNode | undefined;
|
|
14
21
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
22
|
+
Image: import("react").ForwardRefExoticComponent<{
|
|
23
|
+
alt: string;
|
|
24
|
+
} & import("../common/types").AspectRatioProps & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>, "children"> & import("react").RefAttributes<HTMLImageElement>>;
|
|
15
25
|
Link: import("react").ForwardRefExoticComponent<import("react").AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
16
26
|
children?: import("react").ReactNode | undefined;
|
|
17
27
|
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
package/dist/Card/Card.js
CHANGED
|
@@ -5,8 +5,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
|
+
import { CardHeading } from './CardHeading';
|
|
8
9
|
import { CardHeadingGroup } from './CardHeadingGroup';
|
|
10
|
+
import { CardImage } from './CardImage';
|
|
9
11
|
import { CardLink } from './CardLink';
|
|
10
12
|
const CardRoot = forwardRef(({ children, className, ...restProps }, ref) => (_jsx("article", { ...restProps, className: clsx('ams-card', className), ref: ref, children: children })));
|
|
11
13
|
CardRoot.displayName = 'Card';
|
|
12
|
-
export const Card = Object.assign(CardRoot, {
|
|
14
|
+
export const Card = Object.assign(CardRoot, {
|
|
15
|
+
Heading: CardHeading,
|
|
16
|
+
HeadingGroup: CardHeadingGroup,
|
|
17
|
+
Image: CardImage,
|
|
18
|
+
Link: CardLink,
|
|
19
|
+
});
|
package/dist/Card/Card.test.js
CHANGED
|
@@ -15,7 +15,7 @@ describe('Card', () => {
|
|
|
15
15
|
const component = screen.getByRole('article');
|
|
16
16
|
expect(component).toHaveClass('ams-card');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(Card, { className: "extra" }));
|
|
20
20
|
const component = screen.getByRole('article');
|
|
21
21
|
expect(component).toHaveClass('ams-card extra');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license EUPL-1.2+
|
|
3
|
+
* Copyright Gemeente Amsterdam
|
|
4
|
+
*/
|
|
5
|
+
export declare const CardHeading: import("react").ForwardRefExoticComponent<{
|
|
6
|
+
color?: "inverse";
|
|
7
|
+
level: 1 | 2 | 3 | 4;
|
|
8
|
+
size?: "level-1" | "level-2" | "level-3" | "level-4" | "level-5" | "level-6";
|
|
9
|
+
} & import("react").HTMLAttributes<HTMLHeadingElement> & {
|
|
10
|
+
children?: import("react").ReactNode | undefined;
|
|
11
|
+
} & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license EUPL-1.2+
|
|
4
|
+
* Copyright Gemeente Amsterdam
|
|
5
|
+
*/
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
import { Heading } from '../Heading';
|
|
9
|
+
export const CardHeading = forwardRef(({ children, className, size = 'level-4', ...restProps }, ref) => (_jsx(Heading, { ...restProps, className: clsx('ams-card__heading', className), ref: ref, size: size, children: children })));
|
|
10
|
+
CardHeading.displayName = 'Card.Heading';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { createRef } from 'react';
|
|
4
|
+
import { CardHeading } from './CardHeading';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
describe('Card Heading', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
render(_jsx(CardHeading, { level: 1 }));
|
|
9
|
+
const component = screen.getByRole('heading');
|
|
10
|
+
expect(component).toBeInTheDocument();
|
|
11
|
+
expect(component).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
it('renders a design system BEM class name', () => {
|
|
14
|
+
render(_jsx(CardHeading, { level: 2 }));
|
|
15
|
+
const component = screen.getByRole('heading');
|
|
16
|
+
expect(component).toHaveClass('ams-card__heading');
|
|
17
|
+
});
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
|
+
render(_jsx(CardHeading, { className: "extra", level: 3 }));
|
|
20
|
+
const component = screen.getByRole('heading');
|
|
21
|
+
expect(component).toHaveClass('ams-card__heading extra');
|
|
22
|
+
});
|
|
23
|
+
it('renders the correct size level class', () => {
|
|
24
|
+
render(_jsx(CardHeading, { level: 4, size: "level-1", children: "Size level 1" }));
|
|
25
|
+
const component = screen.getByRole('heading');
|
|
26
|
+
expect(component).toHaveClass('ams-heading--1');
|
|
27
|
+
});
|
|
28
|
+
it('supports ForwardRef in React', () => {
|
|
29
|
+
const ref = createRef();
|
|
30
|
+
render(_jsx(CardHeading, { level: 4, ref: ref }));
|
|
31
|
+
const component = screen.getByRole('heading');
|
|
32
|
+
expect(ref.current).toBe(component);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -15,7 +15,7 @@ describe('Card heading group', () => {
|
|
|
15
15
|
const component = container.querySelector(':only-child');
|
|
16
16
|
expect(component).toHaveClass('ams-card__heading-group');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
const { container } = render(_jsx(CardHeadingGroup, { className: "extra", tagline: "test" }));
|
|
20
20
|
const component = container.querySelector(':only-child');
|
|
21
21
|
expect(component).toHaveClass('ams-card__heading-group extra');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license EUPL-1.2+
|
|
3
|
+
* Copyright Gemeente Amsterdam
|
|
4
|
+
*/
|
|
5
|
+
export declare const CardImage: import("react").ForwardRefExoticComponent<{
|
|
6
|
+
alt: string;
|
|
7
|
+
} & import("../common/types").AspectRatioProps & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>, "children"> & import("react").RefAttributes<HTMLImageElement>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license EUPL-1.2+
|
|
4
|
+
* Copyright Gemeente Amsterdam
|
|
5
|
+
*/
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
import { Image } from '../Image';
|
|
9
|
+
export const CardImage = forwardRef(({ className, ...restProps }, ref) => (_jsx(Image, { ...restProps, className: clsx('ams-card__image', className), ref: ref })));
|
|
10
|
+
CardImage.displayName = 'Card.Image';
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { CardImage } from './CardImage';
|
|
5
5
|
import '@testing-library/jest-dom';
|
|
6
|
-
describe('
|
|
6
|
+
describe('Card Image', () => {
|
|
7
7
|
it('renders', () => {
|
|
8
|
-
const { container } = render(_jsx(
|
|
8
|
+
const { container } = render(_jsx(CardImage, { alt: "" }));
|
|
9
9
|
const component = container.querySelector(':only-child');
|
|
10
10
|
expect(component).toBeInTheDocument();
|
|
11
11
|
expect(component).toBeVisible();
|
|
12
12
|
});
|
|
13
13
|
it('renders a design system BEM class name', () => {
|
|
14
|
-
const { container } = render(_jsx(
|
|
14
|
+
const { container } = render(_jsx(CardImage, { alt: "" }));
|
|
15
15
|
const component = container.querySelector(':only-child');
|
|
16
|
-
expect(component).toHaveClass('ams-
|
|
16
|
+
expect(component).toHaveClass('ams-card__image');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
19
|
-
const { container } = render(_jsx(
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
|
+
const { container } = render(_jsx(CardImage, { alt: "", className: "extra" }));
|
|
20
20
|
const component = container.querySelector(':only-child');
|
|
21
|
-
expect(component).toHaveClass('ams-
|
|
21
|
+
expect(component).toHaveClass('ams-card__image extra');
|
|
22
22
|
});
|
|
23
23
|
it('supports ForwardRef in React', () => {
|
|
24
24
|
const ref = createRef();
|
|
25
|
-
const { container } = render(_jsx(
|
|
25
|
+
const { container } = render(_jsx(CardImage, { alt: "", ref: ref }));
|
|
26
26
|
const component = container.querySelector(':only-child');
|
|
27
27
|
expect(ref.current).toBe(component);
|
|
28
28
|
});
|
|
@@ -15,7 +15,7 @@ describe('Card link', () => {
|
|
|
15
15
|
const component = screen.getByRole('link');
|
|
16
16
|
expect(component).toHaveClass('ams-card__link');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(CardLink, { className: "extra", href: "/" }));
|
|
20
20
|
const component = screen.getByRole('link');
|
|
21
21
|
expect(component).toHaveClass('ams-card__link extra');
|
|
@@ -15,7 +15,7 @@ describe('Character count', () => {
|
|
|
15
15
|
const component = screen.getByRole('status');
|
|
16
16
|
expect(component).toHaveClass('ams-character-count');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
render(_jsx(CharacterCount, { className: "extra", length: 10, maxLength: 100 }));
|
|
20
20
|
const component = screen.getByRole('status');
|
|
21
21
|
expect(component).toHaveClass('ams-character-count extra');
|
|
@@ -25,11 +25,10 @@ describe('Checkbox', () => {
|
|
|
25
25
|
expect(input).toHaveClass('ams-checkbox__input');
|
|
26
26
|
expect(label).toHaveClass('ams-checkbox__label');
|
|
27
27
|
});
|
|
28
|
-
it('renders an
|
|
28
|
+
it('renders an extra class name', () => {
|
|
29
29
|
const { container } = render(_jsx(Checkbox, { className: "extra" }));
|
|
30
30
|
const wrapper = container.querySelector(':only-child');
|
|
31
|
-
expect(wrapper).toHaveClass('extra');
|
|
32
|
-
expect(wrapper).toHaveClass('ams-checkbox');
|
|
31
|
+
expect(wrapper).toHaveClass('ams-checkbox extra');
|
|
33
32
|
});
|
|
34
33
|
describe('Checked state', () => {
|
|
35
34
|
it('is not checked by default', () => {
|
package/dist/Column/Column.d.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
6
|
import type { CrossAlignForColumn, MainAlign } from '../common/types';
|
|
7
|
-
export declare const
|
|
8
|
-
type
|
|
9
|
-
|
|
7
|
+
export declare const columnTags: readonly ["article", "div", "section"];
|
|
8
|
+
type ColumnTag = (typeof columnTags)[number];
|
|
9
|
+
export declare const columnGapSizes: readonly ["none", "x-small", "small", "large", "x-large"];
|
|
10
|
+
type ColumnGap = (typeof columnGapSizes)[number];
|
|
10
11
|
export type ColumnProps = {
|
|
11
12
|
/**
|
|
12
13
|
* The vertical alignment of the items in the column.
|
package/dist/Column/Column.js
CHANGED
|
@@ -5,6 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
|
-
export const
|
|
8
|
+
export const columnTags = ['article', 'div', 'section'];
|
|
9
|
+
export const columnGapSizes = ['none', 'x-small', 'small', 'large', 'x-large'];
|
|
9
10
|
export const Column = forwardRef(({ align, alignHorizontal, as: Tag = 'div', children, className, gap, ...restProps }, ref) => (_jsx(Tag, { ...restProps, className: clsx('ams-column', align && `ams-column--align-${align}`, alignHorizontal && `ams-column--align-horizontal-${alignHorizontal}`, gap && `ams-column--gap-${gap}`, className), ref: ref, children: children })));
|
|
10
11
|
Column.displayName = 'Column';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { createRef } from 'react';
|
|
4
|
-
import { Column,
|
|
4
|
+
import { Column, columnGapSizes, columnTags } from './Column';
|
|
5
|
+
import { ariaRoleForTag } from '../common/accessibility';
|
|
5
6
|
import { crossAlignOptionsForColumn, mainAlignOptions } from '../common/types';
|
|
6
7
|
import '@testing-library/jest-dom';
|
|
7
8
|
describe('Column', () => {
|
|
@@ -16,25 +17,22 @@ describe('Column', () => {
|
|
|
16
17
|
const component = container.querySelector(':only-child');
|
|
17
18
|
expect(component).toHaveClass('ams-column');
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
+
columnGapSizes.map((gap) => it(`renders with ‘${gap}’ gap`, () => {
|
|
20
21
|
const { container } = render(_jsx(Column, { gap: gap }));
|
|
21
22
|
const component = container.querySelector(':only-child');
|
|
22
23
|
expect(component).toHaveClass(`ams-column--gap-${gap}`);
|
|
23
24
|
}));
|
|
24
|
-
it('renders an
|
|
25
|
+
it('renders an extra class name', () => {
|
|
25
26
|
const { container } = render(_jsx(Column, { className: "extra" }));
|
|
26
27
|
const component = container.querySelector(':only-child');
|
|
27
28
|
expect(component).toHaveClass('ams-column extra');
|
|
28
29
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const { container } = render(_jsx(Column, { as: "section" }));
|
|
36
|
-
const component = container.querySelector('section');
|
|
37
|
-
expect(component).toBeInTheDocument();
|
|
30
|
+
columnTags.forEach((tag) => {
|
|
31
|
+
it(`renders with a custom ${tag} tag`, () => {
|
|
32
|
+
const { container } = render(_jsx(Column, { "aria-label": tag === 'section' ? 'Accessible name' : undefined, as: tag }));
|
|
33
|
+
const component = tag === 'div' ? container.querySelector(tag) : screen.getByRole(ariaRoleForTag[tag]);
|
|
34
|
+
expect(component).toBeInTheDocument();
|
|
35
|
+
});
|
|
38
36
|
});
|
|
39
37
|
it('supports ForwardRef in React', () => {
|
|
40
38
|
const ref = createRef();
|
|
@@ -15,7 +15,7 @@ describe('Date input', () => {
|
|
|
15
15
|
const component = container.querySelector(':only-child');
|
|
16
16
|
expect(component).toHaveClass('ams-date-input');
|
|
17
17
|
});
|
|
18
|
-
it('renders an
|
|
18
|
+
it('renders an extra class name', () => {
|
|
19
19
|
const { container } = render(_jsx(DateInput, { className: "extra" }));
|
|
20
20
|
const component = container.querySelector(':only-child');
|
|
21
21
|
expect(component).toHaveClass('ams-date-input extra');
|