@amsterdam/design-system-react 2.1.0 → 2.2.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/dist/Avatar/Avatar.d.ts +2 -2
- package/dist/Card/Card.d.ts +1 -1
- package/dist/Card/CardHeading.d.ts +1 -1
- package/dist/Checkbox/Checkbox.d.ts +1 -1
- package/dist/DateInput/DateInput.d.ts +1 -1
- package/dist/FieldSet/FieldSet.d.ts +11 -0
- package/dist/FieldSet/FieldSet.js +3 -3
- package/dist/Hint/Hint.d.ts +1 -0
- package/dist/Hint/Hint.js +2 -2
- package/dist/Image/Image.js +1 -1
- package/dist/Label/Label.d.ts +11 -0
- package/dist/Label/Label.js +2 -2
- package/dist/LinkList/LinkList.d.ts +1 -1
- package/dist/Menu/MenuLink.d.ts +2 -2
- package/dist/Page/Page.d.ts +6 -2
- package/dist/Page/Page.js +1 -1
- package/dist/PageHeader/PageHeader.d.ts +1 -0
- package/dist/PageHeader/PageHeaderMenuIcon.js +1 -1
- package/dist/PageHeader/PageHeaderMenuLink.d.ts +7 -0
- package/dist/PageHeader/PageHeaderMenuLink.js +3 -2
- package/dist/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/Radio/Radio.d.ts +1 -1
- package/dist/SearchField/SearchField.d.ts +1 -1
- package/dist/TimeInput/TimeInput.d.ts +1 -1
- package/dist/index.cjs.js +29 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1935 -61
- package/dist/index.esm.js +29 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/Accordion/Accordion.test.d.ts +0 -5
- package/dist/Accordion/Accordion.test.js +0 -44
- package/dist/Accordion/AccordionSection.test.d.ts +0 -5
- package/dist/Accordion/AccordionSection.test.js +0 -100
- package/dist/ActionGroup/ActionGroup.test.d.ts +0 -5
- package/dist/ActionGroup/ActionGroup.test.js +0 -33
- package/dist/Alert/Alert.test.d.ts +0 -5
- package/dist/Alert/Alert.test.js +0 -74
- package/dist/App/App.d.ts +0 -12
- package/dist/App/App.js +0 -8
- package/dist/App/App.test.d.ts +0 -5
- package/dist/App/App.test.js +0 -33
- package/dist/App/index.d.ts +0 -6
- package/dist/App/index.js +0 -5
- package/dist/AppNavigation/AppNavigation.d.ts +0 -45
- package/dist/AppNavigation/AppNavigation.js +0 -18
- package/dist/AppNavigation/AppNavigation.test.d.ts +0 -5
- package/dist/AppNavigation/AppNavigation.test.js +0 -33
- package/dist/AppNavigation/AppNavigationButton.d.ts +0 -18
- package/dist/AppNavigation/AppNavigationButton.js +0 -17
- package/dist/AppNavigation/AppNavigationLink.d.ts +0 -19
- package/dist/AppNavigation/AppNavigationLink.js +0 -19
- package/dist/AppNavigation/AppNavigationMenu.d.ts +0 -9
- package/dist/AppNavigation/AppNavigationMenu.js +0 -5
- package/dist/AppNavigation/index.d.ts +0 -6
- package/dist/AppNavigation/index.js +0 -5
- package/dist/Avatar/Avatar.test.d.ts +0 -5
- package/dist/Avatar/Avatar.test.js +0 -63
- package/dist/Badge/Badge.test.d.ts +0 -5
- package/dist/Badge/Badge.test.js +0 -43
- package/dist/Blockquote/Blockquote.test.d.ts +0 -5
- package/dist/Blockquote/Blockquote.test.js +0 -46
- package/dist/Breadcrumb/Breadcrumb.test.d.ts +0 -5
- package/dist/Breadcrumb/Breadcrumb.test.js +0 -45
- package/dist/Breadcrumb/BreadcrumbLink.test.d.ts +0 -5
- package/dist/Breadcrumb/BreadcrumbLink.test.js +0 -40
- package/dist/Breakout/Breakout.test.d.ts +0 -5
- package/dist/Breakout/Breakout.test.js +0 -62
- package/dist/Breakout/BreakoutCell.test.d.ts +0 -5
- package/dist/Breakout/BreakoutCell.test.js +0 -128
- package/dist/Button/Button.test.d.ts +0 -5
- package/dist/Button/Button.test.js +0 -114
- package/dist/CallToActionLink/CallToActionLink.test.d.ts +0 -5
- package/dist/CallToActionLink/CallToActionLink.test.js +0 -33
- package/dist/Card/Card.test.d.ts +0 -5
- package/dist/Card/Card.test.js +0 -33
- package/dist/Card/CardHeading.test.d.ts +0 -5
- package/dist/Card/CardHeading.test.js +0 -38
- package/dist/Card/CardHeadingGroup.test.d.ts +0 -5
- package/dist/Card/CardHeadingGroup.test.js +0 -38
- package/dist/Card/CardImage.test.d.ts +0 -5
- package/dist/Card/CardImage.test.js +0 -33
- package/dist/Card/CardLink.test.d.ts +0 -5
- package/dist/Card/CardLink.test.js +0 -33
- package/dist/CharacterCount/CharacterCount.test.d.ts +0 -5
- package/dist/CharacterCount/CharacterCount.test.js +0 -38
- package/dist/Checkbox/Checkbox.test.d.ts +0 -5
- package/dist/Checkbox/Checkbox.test.js +0 -142
- package/dist/Column/Column.test.d.ts +0 -5
- package/dist/Column/Column.test.js +0 -59
- package/dist/DateInput/DateInput.test.d.ts +0 -5
- package/dist/DateInput/DateInput.test.js +0 -58
- package/dist/DescriptionList/DescriptionList.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionList.test.js +0 -43
- package/dist/DescriptionList/DescriptionListDescription.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionListDescription.test.js +0 -33
- package/dist/DescriptionList/DescriptionListSection.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionListSection.test.js +0 -33
- package/dist/DescriptionList/DescriptionListTerm.test.d.ts +0 -5
- package/dist/DescriptionList/DescriptionListTerm.test.js +0 -33
- package/dist/Dialog/Dialog.test.d.ts +0 -5
- package/dist/Dialog/Dialog.test.js +0 -82
- package/dist/ErrorMessage/ErrorMessage.test.d.ts +0 -5
- package/dist/ErrorMessage/ErrorMessage.test.js +0 -53
- package/dist/Field/Field.test.d.ts +0 -5
- package/dist/Field/Field.test.js +0 -38
- package/dist/FieldSet/FieldSet.test.d.ts +0 -5
- package/dist/FieldSet/FieldSet.test.js +0 -70
- package/dist/Figure/Figure.test.d.ts +0 -5
- package/dist/Figure/Figure.test.js +0 -33
- package/dist/Figure/FigureCaption.test.d.ts +0 -5
- package/dist/Figure/FigureCaption.test.js +0 -38
- package/dist/FileInput/FileInput.test.d.ts +0 -5
- package/dist/FileInput/FileInput.test.js +0 -33
- package/dist/FileList/FileList.test.d.ts +0 -5
- package/dist/FileList/FileList.test.js +0 -33
- package/dist/FileList/FileListItem.test.d.ts +0 -5
- package/dist/FileList/FileListItem.test.js +0 -44
- package/dist/Grid/Grid.test.d.ts +0 -5
- package/dist/Grid/Grid.test.js +0 -69
- package/dist/Grid/GridCell.test.d.ts +0 -5
- package/dist/Grid/GridCell.test.js +0 -84
- package/dist/Heading/Heading.test.d.ts +0 -5
- package/dist/Heading/Heading.test.js +0 -70
- package/dist/Hint/Hint.test.d.ts +0 -5
- package/dist/Hint/Hint.test.js +0 -53
- package/dist/Icon/Icon.test.d.ts +0 -5
- package/dist/Icon/Icon.test.js +0 -60
- package/dist/IconButton/IconButton.test.d.ts +0 -5
- package/dist/IconButton/IconButton.test.js +0 -48
- package/dist/Image/Image.test.d.ts +0 -5
- package/dist/Image/Image.test.js +0 -43
- package/dist/ImageSlider/ImageSlider.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSlider.test.js +0 -70
- package/dist/ImageSlider/ImageSliderControls.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderControls.test.js +0 -25
- package/dist/ImageSlider/ImageSliderItem.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderItem.test.js +0 -37
- package/dist/ImageSlider/ImageSliderScroller.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderScroller.test.js +0 -37
- package/dist/ImageSlider/ImageSliderThumbnails.test.d.ts +0 -5
- package/dist/ImageSlider/ImageSliderThumbnails.test.js +0 -52
- package/dist/InvalidFormAlert/InvalidFormAlert.test.d.ts +0 -5
- package/dist/InvalidFormAlert/InvalidFormAlert.test.js +0 -108
- package/dist/Label/Label.test.d.ts +0 -5
- package/dist/Label/Label.test.js +0 -82
- package/dist/Link/Link.test.d.ts +0 -5
- package/dist/Link/Link.test.js +0 -43
- package/dist/LinkList/LinkList.test.d.ts +0 -5
- package/dist/LinkList/LinkList.test.js +0 -33
- package/dist/LinkList/LinkListLink.test.d.ts +0 -5
- package/dist/LinkList/LinkListLink.test.js +0 -54
- package/dist/Logo/Logo.test.d.ts +0 -5
- package/dist/Logo/Logo.test.js +0 -33
- package/dist/Mark/Mark.test.d.ts +0 -5
- package/dist/Mark/Mark.test.js +0 -33
- package/dist/Menu/Menu.test.d.ts +0 -5
- package/dist/Menu/Menu.test.js +0 -55
- package/dist/Menu/MenuLink.test.d.ts +0 -5
- package/dist/Menu/MenuLink.test.js +0 -56
- package/dist/OrderedList/OrderedList.test.d.ts +0 -5
- package/dist/OrderedList/OrderedList.test.js +0 -55
- package/dist/OrderedList/OrderedListItem.test.d.ts +0 -5
- package/dist/OrderedList/OrderedListItem.test.js +0 -32
- package/dist/Overlap/Overlap.test.d.ts +0 -5
- package/dist/Overlap/Overlap.test.js +0 -38
- package/dist/Page/Page.test.d.ts +0 -5
- package/dist/Page/Page.test.js +0 -33
- package/dist/PageFooter/PageFooter.test.d.ts +0 -5
- package/dist/PageFooter/PageFooter.test.js +0 -33
- package/dist/PageFooter/PageFooterMenu.test.d.ts +0 -5
- package/dist/PageFooter/PageFooterMenu.test.js +0 -35
- package/dist/PageFooter/PageFooterMenuLink.test.d.ts +0 -5
- package/dist/PageFooter/PageFooterMenuLink.test.js +0 -33
- package/dist/PageFooter/PageFooterSpotlight.test.d.ts +0 -5
- package/dist/PageFooter/PageFooterSpotlight.test.js +0 -33
- package/dist/PageHeader/PageHeader.test.d.ts +0 -6
- package/dist/PageHeader/PageHeader.test.js +0 -131
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.test.d.ts +0 -5
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.test.js +0 -38
- package/dist/PageHeader/PageHeaderMenuLink.test.d.ts +0 -5
- package/dist/PageHeader/PageHeaderMenuLink.test.js +0 -45
- package/dist/PageHeading/PageHeading.test.d.ts +0 -5
- package/dist/PageHeading/PageHeading.test.js +0 -40
- package/dist/Pagination/Pagination.test.d.ts +0 -5
- package/dist/Pagination/Pagination.test.js +0 -137
- package/dist/Paragraph/Paragraph.test.d.ts +0 -5
- package/dist/Paragraph/Paragraph.test.js +0 -62
- package/dist/PasswordInput/PasswordInput.test.d.ts +0 -5
- package/dist/PasswordInput/PasswordInput.test.js +0 -89
- package/dist/Radio/Radio.test.d.ts +0 -5
- package/dist/Radio/Radio.test.js +0 -134
- package/dist/Row/Row.test.d.ts +0 -5
- package/dist/Row/Row.test.js +0 -64
- package/dist/SearchField/SearchField.test.d.ts +0 -5
- package/dist/SearchField/SearchField.test.js +0 -33
- package/dist/SearchField/SearchFieldButton.test.d.ts +0 -5
- package/dist/SearchField/SearchFieldButton.test.js +0 -47
- package/dist/SearchField/SearchFieldInput.test.d.ts +0 -5
- package/dist/SearchField/SearchFieldInput.test.js +0 -65
- package/dist/Select/Select.test.d.ts +0 -5
- package/dist/Select/Select.test.js +0 -74
- package/dist/Select/SelectOption.test.d.ts +0 -5
- package/dist/Select/SelectOption.test.js +0 -45
- package/dist/Select/SelectOptionGroup.test.d.ts +0 -5
- package/dist/Select/SelectOptionGroup.test.js +0 -45
- package/dist/SkipLink/SkipLink.test.d.ts +0 -5
- package/dist/SkipLink/SkipLink.test.js +0 -33
- package/dist/Spotlight/Spotlight.test.d.ts +0 -5
- package/dist/Spotlight/Spotlight.test.js +0 -46
- package/dist/StandaloneLink/StandaloneLink.test.d.ts +0 -5
- package/dist/StandaloneLink/StandaloneLink.test.js +0 -46
- package/dist/Switch/Switch.test.d.ts +0 -5
- package/dist/Switch/Switch.test.js +0 -69
- package/dist/Table/Table.test.d.ts +0 -5
- package/dist/Table/Table.test.js +0 -33
- package/dist/Table/TableBody.test.d.ts +0 -5
- package/dist/Table/TableBody.test.js +0 -34
- package/dist/Table/TableCaption.test.d.ts +0 -5
- package/dist/Table/TableCaption.test.js +0 -45
- package/dist/Table/TableCell.test.d.ts +0 -5
- package/dist/Table/TableCell.test.js +0 -36
- package/dist/Table/TableFooter.test.d.ts +0 -5
- package/dist/Table/TableFooter.test.js +0 -34
- package/dist/Table/TableHeader.test.d.ts +0 -5
- package/dist/Table/TableHeader.test.js +0 -34
- package/dist/Table/TableHeaderCell.test.d.ts +0 -5
- package/dist/Table/TableHeaderCell.test.js +0 -42
- package/dist/Table/TableRow.test.d.ts +0 -5
- package/dist/Table/TableRow.test.js +0 -35
- package/dist/TableOfContents/TableOfContents.test.d.ts +0 -5
- package/dist/TableOfContents/TableOfContents.test.js +0 -44
- package/dist/TableOfContents/TableOfContentsLink.test.d.ts +0 -5
- package/dist/TableOfContents/TableOfContentsLink.test.js +0 -34
- package/dist/TableOfContents/TableOfContentsList.test.d.ts +0 -5
- package/dist/TableOfContents/TableOfContentsList.test.js +0 -40
- package/dist/Tabs/Tabs.test.d.ts +0 -5
- package/dist/Tabs/Tabs.test.js +0 -104
- package/dist/Tabs/TabsButton.test.d.ts +0 -5
- package/dist/Tabs/TabsButton.test.js +0 -57
- package/dist/Tabs/TabsList.test.d.ts +0 -5
- package/dist/Tabs/TabsList.test.js +0 -32
- package/dist/Tabs/TabsPanel.test.d.ts +0 -5
- package/dist/Tabs/TabsPanel.test.js +0 -42
- package/dist/TextArea/TextArea.test.d.ts +0 -5
- package/dist/TextArea/TextArea.test.js +0 -105
- package/dist/TextInput/TextInput.test.d.ts +0 -5
- package/dist/TextInput/TextInput.test.js +0 -92
- package/dist/TimeInput/TimeInput.test.d.ts +0 -5
- package/dist/TimeInput/TimeInput.test.js +0 -51
- package/dist/UnorderedList/UnorderedList.test.d.ts +0 -5
- package/dist/UnorderedList/UnorderedList.test.js +0 -55
- package/dist/UnorderedList/UnorderedListItem.test.d.ts +0 -5
- package/dist/UnorderedList/UnorderedListItem.test.js +0 -32
- package/dist/common/formatFileSize.test.d.ts +0 -5
- package/dist/common/formatFileSize.test.js +0 -22
- package/dist/common/formatFileType.test.d.ts +0 -5
- package/dist/common/formatFileType.test.js +0 -27
- package/dist/common/useKeyboardFocus.test.d.ts +0 -5
- package/dist/common/useKeyboardFocus.test.js +0 -79
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.2.0",
|
|
3
3
|
"author": "Design System Team, City of Amsterdam <designsystem@amsterdam.nl>",
|
|
4
4
|
"description": "All React components from the Amsterdam Design System. Use it to compose pages in your website or application.",
|
|
5
5
|
"homepage": "https://designsystem.amsterdam",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"postcss": "8.5.6",
|
|
58
58
|
"react": "18.3.1",
|
|
59
59
|
"react-dom": "18.3.1",
|
|
60
|
-
"rollup": "4.
|
|
60
|
+
"rollup": "4.53.2",
|
|
61
61
|
"rollup-plugin-dts": "6.2.3",
|
|
62
62
|
"rollup-plugin-filesize": "10.0.0",
|
|
63
|
-
"rollup-plugin-node-externals": "8.1.
|
|
63
|
+
"rollup-plugin-node-externals": "8.1.2",
|
|
64
64
|
"rollup-plugin-node-polyfills": "0.2.1",
|
|
65
65
|
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
66
66
|
"rollup-plugin-typescript2": "0.36.0",
|
|
67
|
-
"sass": "1.
|
|
67
|
+
"sass": "1.94.0",
|
|
68
68
|
"tslib": "2.8.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"react": "16 - 19",
|
|
72
72
|
"react-dom": "16 - 19",
|
|
73
|
-
"@amsterdam/design-system-css": "2.
|
|
73
|
+
"@amsterdam/design-system-css": "2.2.0"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build": "tsc --project ./tsconfig.build.json && rollup -c",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen } from '@testing-library/react';
|
|
7
|
-
import userEvent from '@testing-library/user-event';
|
|
8
|
-
import { createRef } from 'react';
|
|
9
|
-
import { Accordion } from './Accordion';
|
|
10
|
-
import '@testing-library/jest-dom';
|
|
11
|
-
describe('Accordion', () => {
|
|
12
|
-
it('renders an accordion', () => {
|
|
13
|
-
const { container } = render(_jsx(Accordion, { headingLevel: 2 }));
|
|
14
|
-
const accordion = container.querySelector('.ams-accordion');
|
|
15
|
-
expect(accordion).toBeInTheDocument();
|
|
16
|
-
expect(accordion).toBeVisible();
|
|
17
|
-
});
|
|
18
|
-
it('renders an extra class name', () => {
|
|
19
|
-
const { container } = render(_jsx(Accordion, { className: "test", headingLevel: 2 }));
|
|
20
|
-
const accordion = container.querySelector('.ams-accordion');
|
|
21
|
-
expect(accordion).toHaveClass('test');
|
|
22
|
-
});
|
|
23
|
-
it('sets focus on Accordion buttons when using arrow keys', async () => {
|
|
24
|
-
const user = userEvent.setup();
|
|
25
|
-
render(_jsxs(Accordion, { headingLevel: 2, children: [_jsx(Accordion.Section, { label: "one" }), _jsx(Accordion.Section, { label: "two" }), _jsx(Accordion.Section, { label: "three" })] }));
|
|
26
|
-
const firstButton = screen.getByRole('button', { name: 'one' });
|
|
27
|
-
const thirdButton = screen.getByRole('button', { name: 'three' });
|
|
28
|
-
await user.click(firstButton);
|
|
29
|
-
expect(firstButton).toHaveFocus();
|
|
30
|
-
// Click the down arrow key twice
|
|
31
|
-
await user.keyboard('{ArrowDown}');
|
|
32
|
-
await user.keyboard('{ArrowDown}');
|
|
33
|
-
expect(thirdButton).toHaveFocus();
|
|
34
|
-
expect(firstButton).not.toHaveFocus();
|
|
35
|
-
await user.keyboard('{ArrowDown}');
|
|
36
|
-
expect(firstButton).toHaveFocus();
|
|
37
|
-
});
|
|
38
|
-
it('supports ForwardRef in React', () => {
|
|
39
|
-
const ref = createRef();
|
|
40
|
-
const { container } = render(_jsx(Accordion, { headingLevel: 2, ref: ref }));
|
|
41
|
-
const accordion = container.querySelector('.ams-accordion');
|
|
42
|
-
expect(ref.current).toBe(accordion);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Accordion } from './Accordion';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Accordion section', () => {
|
|
11
|
-
const testLabel = 'Test title';
|
|
12
|
-
const testContent = 'Test content';
|
|
13
|
-
it('renders an accordion section', () => {
|
|
14
|
-
const { container } = render(_jsx(Accordion.Section, { label: testLabel, children: testContent }));
|
|
15
|
-
const accordionSection = container.querySelector('.ams-accordion__section');
|
|
16
|
-
expect(accordionSection).toBeInTheDocument();
|
|
17
|
-
expect(accordionSection).toBeVisible();
|
|
18
|
-
});
|
|
19
|
-
it('renders the accordion section BEM class names', () => {
|
|
20
|
-
const { container } = render(_jsx(Accordion.Section, { label: testLabel, children: testContent }));
|
|
21
|
-
const heading = screen.getByRole('heading', {
|
|
22
|
-
name: testLabel,
|
|
23
|
-
});
|
|
24
|
-
const button = screen.getByRole('button', {
|
|
25
|
-
name: testLabel,
|
|
26
|
-
});
|
|
27
|
-
const section = container.querySelector('.ams-accordion__panel');
|
|
28
|
-
expect(heading).toHaveClass('ams-heading ams-accordion__header');
|
|
29
|
-
expect(button).toHaveClass('ams-accordion__button');
|
|
30
|
-
expect(section).toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
it('adds and removes --expanded class when the button is clicked', () => {
|
|
33
|
-
const { getByText } = render(_jsx(Accordion.Section, { label: testLabel, children: testContent }));
|
|
34
|
-
const button = screen.getByRole('button', {
|
|
35
|
-
name: testLabel,
|
|
36
|
-
});
|
|
37
|
-
const sectionContent = getByText(testContent);
|
|
38
|
-
expect(sectionContent).not.toHaveClass('ams-accordion__panel--expanded');
|
|
39
|
-
fireEvent.click(button);
|
|
40
|
-
expect(sectionContent).toHaveClass('ams-accordion__panel--expanded');
|
|
41
|
-
fireEvent.click(button);
|
|
42
|
-
expect(sectionContent).not.toHaveClass('ams-accordion__panel--expanded');
|
|
43
|
-
});
|
|
44
|
-
it('adds --expanded class when expanded prop is true', () => {
|
|
45
|
-
const { getByText } = render(_jsx(Accordion.Section, { expanded: true, label: testLabel, children: testContent }));
|
|
46
|
-
const sectionContent = getByText(testContent);
|
|
47
|
-
expect(sectionContent).toHaveClass('ams-accordion__panel--expanded');
|
|
48
|
-
});
|
|
49
|
-
it('renders a section HTML tag by default', () => {
|
|
50
|
-
render(_jsx(Accordion, { headingLevel: 2, children: _jsx(Accordion.Section, { label: testLabel, children: testContent }) }));
|
|
51
|
-
const sectionQuery = screen.queryByRole('region');
|
|
52
|
-
expect(sectionQuery).toBeInTheDocument();
|
|
53
|
-
});
|
|
54
|
-
it('does not render a section HTML tag when the sectionAs is "div"', () => {
|
|
55
|
-
render(_jsx(Accordion, { headingLevel: 2, sectionAs: "div", children: _jsx(Accordion.Section, { label: testLabel, children: testContent }) }));
|
|
56
|
-
const sectionQuery = screen.queryByRole('region');
|
|
57
|
-
expect(sectionQuery).not.toBeInTheDocument();
|
|
58
|
-
});
|
|
59
|
-
it('renders an accessible heading', () => {
|
|
60
|
-
render(_jsx(Accordion, { headingLevel: 3, children: _jsx(Accordion.Section, { label: testLabel, children: testContent }) }));
|
|
61
|
-
const heading = screen.getByRole('heading', {
|
|
62
|
-
level: 3,
|
|
63
|
-
name: testLabel,
|
|
64
|
-
});
|
|
65
|
-
expect(heading).toBeInTheDocument();
|
|
66
|
-
expect(heading).toBeVisible();
|
|
67
|
-
});
|
|
68
|
-
it('renders the allowed levels correctly', () => {
|
|
69
|
-
render(_jsxs(_Fragment, { children: [_jsx(Accordion, { headingLevel: 2, children: _jsx(Accordion.Section, { label: "Level 2", children: testContent }) }), _jsx(Accordion, { headingLevel: 4, children: _jsx(Accordion.Section, { label: "Level 4", children: testContent }) })] }));
|
|
70
|
-
const headingLevel2 = screen.getByRole('heading', {
|
|
71
|
-
level: 2,
|
|
72
|
-
name: 'Level 2',
|
|
73
|
-
});
|
|
74
|
-
const headingLevel4 = screen.getByRole('heading', {
|
|
75
|
-
level: 4,
|
|
76
|
-
name: 'Level 4',
|
|
77
|
-
});
|
|
78
|
-
expect(headingLevel2).toBeInTheDocument();
|
|
79
|
-
expect(headingLevel4).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
it('renders an icon', () => {
|
|
82
|
-
render(_jsx(Accordion.Section, { label: testLabel, children: testContent }));
|
|
83
|
-
const button = screen.getByRole('button', {
|
|
84
|
-
name: testLabel,
|
|
85
|
-
});
|
|
86
|
-
const icon = button ? button.querySelector('svg:only-child') : null;
|
|
87
|
-
expect(icon).toBeInTheDocument();
|
|
88
|
-
});
|
|
89
|
-
it('renders an extra class name', () => {
|
|
90
|
-
const { container } = render(_jsx(Accordion.Section, { className: "test", label: testLabel, children: testContent }));
|
|
91
|
-
const accordionSection = container.querySelector('.ams-accordion__section');
|
|
92
|
-
expect(accordionSection).toHaveClass('test');
|
|
93
|
-
});
|
|
94
|
-
it('supports ForwardRef in React', () => {
|
|
95
|
-
const ref = createRef();
|
|
96
|
-
const { container } = render(_jsx(Accordion.Section, { label: testLabel, ref: ref, children: testContent }));
|
|
97
|
-
const accordionSection = container.querySelector('.ams-accordion__section');
|
|
98
|
-
expect(ref.current).toBe(accordionSection);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { ActionGroup } from './ActionGroup';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Action Group', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(ActionGroup, {}));
|
|
13
|
-
const component = screen.getByRole('group');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
render(_jsx(ActionGroup, {}));
|
|
19
|
-
const component = screen.getByRole('group');
|
|
20
|
-
expect(component).toHaveClass('ams-action-group');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
render(_jsx(ActionGroup, { className: "extra" }));
|
|
24
|
-
const component = screen.getByRole('group');
|
|
25
|
-
expect(component).toHaveClass('ams-action-group extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
render(_jsx(ActionGroup, { ref: ref }));
|
|
30
|
-
const component = screen.getByRole('group');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/dist/Alert/Alert.test.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { Alert } from './Alert';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('Alert', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
render(_jsx(Alert, { heading: "Let op!", headingLevel: 2 }));
|
|
13
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
14
|
-
const icon = component?.querySelector('.ams-alert__severity-indicator > .ams-icon');
|
|
15
|
-
expect(component).toBeInTheDocument();
|
|
16
|
-
expect(component).toBeVisible();
|
|
17
|
-
expect(icon).toBeInTheDocument();
|
|
18
|
-
expect(icon).not.toBeVisible(); // The icon is hidden by default, and only shown when the CSS loads.
|
|
19
|
-
});
|
|
20
|
-
it('renders a design system BEM class name', () => {
|
|
21
|
-
render(_jsx(Alert, { heading: "Let op!", headingLevel: 2 }));
|
|
22
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
23
|
-
expect(component).toHaveClass('ams-alert');
|
|
24
|
-
});
|
|
25
|
-
it('renders an extra class name', () => {
|
|
26
|
-
render(_jsx(Alert, { className: "extra", heading: "Let op!", headingLevel: 2 }));
|
|
27
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
28
|
-
expect(component).toHaveClass('ams-alert extra');
|
|
29
|
-
});
|
|
30
|
-
it('supports ForwardRef in React', () => {
|
|
31
|
-
const ref = createRef();
|
|
32
|
-
render(_jsx(Alert, { heading: "Let op!", headingLevel: 2, ref: ref }));
|
|
33
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
34
|
-
expect(ref.current).toBe(component);
|
|
35
|
-
});
|
|
36
|
-
it('renders a heading', () => {
|
|
37
|
-
render(_jsx(Alert, { heading: "Test heading", headingLevel: 2 }));
|
|
38
|
-
const heading = screen.getByRole('heading', {
|
|
39
|
-
name: 'Test heading',
|
|
40
|
-
});
|
|
41
|
-
expect(heading).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
it('renders the close button', () => {
|
|
44
|
-
render(_jsx(Alert, { closeable: true, heading: "Let op!", headingLevel: 2 }));
|
|
45
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
46
|
-
const closeButton = component?.querySelector('.ams-icon-button');
|
|
47
|
-
expect(closeButton).toBeInTheDocument();
|
|
48
|
-
expect(closeButton).toBeVisible();
|
|
49
|
-
});
|
|
50
|
-
it('renders the close button with a label', () => {
|
|
51
|
-
render(_jsx(Alert, { closeable: true, closeButtonLabel: "Close", heading: "Let op!", headingLevel: 2 }));
|
|
52
|
-
const closeButton = screen.getByRole('button', { name: 'Close' });
|
|
53
|
-
expect(closeButton).toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
it('fires the onClose event when the close button is clicked', () => {
|
|
56
|
-
const onClose = jest.fn();
|
|
57
|
-
render(_jsx(Alert, { closeable: true, heading: "Let op!", headingLevel: 2, onClose: onClose }));
|
|
58
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
59
|
-
const closeButton = component?.querySelector('.ams-icon-button');
|
|
60
|
-
fireEvent.click(closeButton);
|
|
61
|
-
expect(onClose).toHaveBeenCalled();
|
|
62
|
-
});
|
|
63
|
-
it('uses a custom headingId to label the Alert', () => {
|
|
64
|
-
render(_jsx(Alert, { heading: "Let op!", headingId: "custom-heading-id", headingLevel: 2 }));
|
|
65
|
-
const component = screen.getByRole('region', { name: 'Let op!' });
|
|
66
|
-
expect(component).toBeInTheDocument();
|
|
67
|
-
expect(component).toHaveAttribute('aria-labelledby', 'custom-heading-id');
|
|
68
|
-
});
|
|
69
|
-
it('does not label the Alert when headingId is set to null', () => {
|
|
70
|
-
const { container } = render(_jsx(Alert, { heading: "Let op!", headingId: null, headingLevel: 2 }));
|
|
71
|
-
const component = container.querySelector(':only-child');
|
|
72
|
-
expect(component).not.toHaveAttribute('aria-labelledby');
|
|
73
|
-
});
|
|
74
|
-
});
|
package/dist/App/App.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license EUPL-1.2+
|
|
3
|
-
* Copyright Gemeente Amsterdam
|
|
4
|
-
*/
|
|
5
|
-
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
-
export type AppProps = PropsWithChildren<HTMLAttributes<HTMLDivElement>>;
|
|
7
|
-
/**
|
|
8
|
-
* @see {@link https://designsystem.amsterdam/?path=/docs/components-TODO-ADD-GROUP-app--docs App docs at Amsterdam Design System}
|
|
9
|
-
*/
|
|
10
|
-
export declare const App: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
11
|
-
children?: import("react").ReactNode | undefined;
|
|
12
|
-
} & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/App/App.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
/**
|
|
5
|
-
* @see {@link https://designsystem.amsterdam/?path=/docs/components-TODO-ADD-GROUP-app--docs App docs at Amsterdam Design System}
|
|
6
|
-
*/
|
|
7
|
-
export const App = forwardRef(({ children, className, ...restProps }, ref) => (_jsx("div", { ...restProps, className: clsx('ams-app', className), ref: ref, children: children })));
|
|
8
|
-
App.displayName = 'App';
|
package/dist/App/App.test.d.ts
DELETED
package/dist/App/App.test.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { App } from './App';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('App', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(App, {}));
|
|
13
|
-
const component = container.querySelector(':only-child');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
const { container } = render(_jsx(App, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-app');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(App, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-app extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(App, { ref: ref }));
|
|
30
|
-
const component = container.querySelector(':only-child');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/dist/App/index.d.ts
DELETED
package/dist/App/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license EUPL-1.2+
|
|
3
|
-
* Copyright Gemeente Amsterdam
|
|
4
|
-
*/
|
|
5
|
-
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
-
export type AppNavigationProps = PropsWithChildren<HTMLAttributes<HTMLElement>> & {
|
|
7
|
-
expandable?: boolean;
|
|
8
|
-
expanded?: boolean;
|
|
9
|
-
onToggle?: () => void;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @see {@link https://designsystem.amsterdam/?path=/docs/components-TODO-ADD-GROUP-app-navigation--docs AppNavigation docs at Amsterdam Design System}
|
|
13
|
-
*/
|
|
14
|
-
export declare const AppNavigationRoot: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
|
|
15
|
-
children?: import("react").ReactNode | undefined;
|
|
16
|
-
} & {
|
|
17
|
-
expandable?: boolean;
|
|
18
|
-
expanded?: boolean;
|
|
19
|
-
onToggle?: () => void;
|
|
20
|
-
} & import("react").RefAttributes<HTMLElement>>;
|
|
21
|
-
export declare const AppNavigation: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & {
|
|
22
|
-
children?: import("react").ReactNode | undefined;
|
|
23
|
-
} & {
|
|
24
|
-
expandable?: boolean;
|
|
25
|
-
expanded?: boolean;
|
|
26
|
-
onToggle?: () => void;
|
|
27
|
-
} & import("react").RefAttributes<HTMLElement>> & {
|
|
28
|
-
Button: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLButtonElement> & {
|
|
29
|
-
children?: import("react").ReactNode | undefined;
|
|
30
|
-
} & {
|
|
31
|
-
active?: boolean;
|
|
32
|
-
icon?: import("..").IconProps["svg"];
|
|
33
|
-
label: string;
|
|
34
|
-
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
|
-
Link: import("react").ForwardRefExoticComponent<import("react").AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
36
|
-
children?: import("react").ReactNode | undefined;
|
|
37
|
-
} & {
|
|
38
|
-
active?: boolean;
|
|
39
|
-
icon?: import("..").IconProps["svg"];
|
|
40
|
-
label: string;
|
|
41
|
-
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
42
|
-
Menu: import("react").ForwardRefExoticComponent<import("react").OlHTMLAttributes<HTMLOListElement> & {
|
|
43
|
-
children?: import("react").ReactNode | undefined;
|
|
44
|
-
} & import("react").RefAttributes<HTMLOListElement>>;
|
|
45
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronForwardIcon } from '@amsterdam/design-system-react-icons';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
5
|
-
import { IconButton } from '../IconButton';
|
|
6
|
-
import { AppNavigationMenuButton } from './AppNavigationButton';
|
|
7
|
-
import { AppNavigationMenuLink } from './AppNavigationLink';
|
|
8
|
-
import { AppNavigationMenu } from './AppNavigationMenu';
|
|
9
|
-
/**
|
|
10
|
-
* @see {@link https://designsystem.amsterdam/?path=/docs/components-TODO-ADD-GROUP-app-navigation--docs AppNavigation docs at Amsterdam Design System}
|
|
11
|
-
*/
|
|
12
|
-
export const AppNavigationRoot = forwardRef(({ children, className, expandable, expanded, onToggle, ...restProps }, ref) => (_jsxs("nav", { ...restProps, className: clsx('ams-app-navigation', expanded && 'ams-app-navigation--expanded', className), ref: ref, children: [expandable && (_jsx(IconButton, { className: "ams-app-navigation__toggle", color: "inverse", label: "Toggle navigation", onClick: onToggle, size: "large", svg: ChevronForwardIcon })), _jsx("ol", { className: "ams-app-navigation__menu", children: children })] })));
|
|
13
|
-
AppNavigationRoot.displayName = 'AppNavigation';
|
|
14
|
-
export const AppNavigation = Object.assign(AppNavigationRoot, {
|
|
15
|
-
Button: AppNavigationMenuButton,
|
|
16
|
-
Link: AppNavigationMenuLink,
|
|
17
|
-
Menu: AppNavigationMenu,
|
|
18
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* @license EUPL-1.2+
|
|
4
|
-
* Copyright Gemeente Amsterdam
|
|
5
|
-
*/
|
|
6
|
-
import { render } from '@testing-library/react';
|
|
7
|
-
import { createRef } from 'react';
|
|
8
|
-
import { AppNavigation } from './AppNavigation';
|
|
9
|
-
import '@testing-library/jest-dom';
|
|
10
|
-
describe('AppNavigation', () => {
|
|
11
|
-
it('renders', () => {
|
|
12
|
-
const { container } = render(_jsx(AppNavigation, {}));
|
|
13
|
-
const component = container.querySelector(':only-child');
|
|
14
|
-
expect(component).toBeInTheDocument();
|
|
15
|
-
expect(component).toBeVisible();
|
|
16
|
-
});
|
|
17
|
-
it('renders a design system BEM class name', () => {
|
|
18
|
-
const { container } = render(_jsx(AppNavigation, {}));
|
|
19
|
-
const component = container.querySelector(':only-child');
|
|
20
|
-
expect(component).toHaveClass('ams-app-navigation');
|
|
21
|
-
});
|
|
22
|
-
it('renders an extra class name', () => {
|
|
23
|
-
const { container } = render(_jsx(AppNavigation, { className: "extra" }));
|
|
24
|
-
const component = container.querySelector(':only-child');
|
|
25
|
-
expect(component).toHaveClass('ams-app-navigation extra');
|
|
26
|
-
});
|
|
27
|
-
it('supports ForwardRef in React', () => {
|
|
28
|
-
const ref = createRef();
|
|
29
|
-
const { container } = render(_jsx(AppNavigation, { ref: ref }));
|
|
30
|
-
const component = container.querySelector(':only-child');
|
|
31
|
-
expect(ref.current).toBe(component);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license EUPL-1.2+
|
|
3
|
-
* Copyright Gemeente Amsterdam
|
|
4
|
-
*/
|
|
5
|
-
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
-
import type { IconProps } from '../Icon';
|
|
7
|
-
export type AppNavigationMenuButtonProps = PropsWithChildren<HTMLAttributes<HTMLButtonElement>> & {
|
|
8
|
-
active?: boolean;
|
|
9
|
-
icon?: IconProps['svg'];
|
|
10
|
-
label: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const AppNavigationMenuButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLButtonElement> & {
|
|
13
|
-
children?: import("react").ReactNode | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
active?: boolean;
|
|
16
|
-
icon?: IconProps["svg"];
|
|
17
|
-
label: string;
|
|
18
|
-
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronDownIcon } from '@amsterdam/design-system-react-icons';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { Children, isValidElement } from 'react';
|
|
5
|
-
import { forwardRef } from 'react';
|
|
6
|
-
import { Icon } from '../Icon';
|
|
7
|
-
export const AppNavigationMenuButton = forwardRef(({ active, children, className, icon, label, ...restProps }, ref) => {
|
|
8
|
-
// const [submenuOpen, setSubmenuOpen] = useState(false)
|
|
9
|
-
// Check if children contain an element with type 'AppNavigation.Menu'
|
|
10
|
-
const hasSubMenu = Children.toArray(children).some((child) => isValidElement(child) && child.type?.displayName === 'AppNavigation.Menu');
|
|
11
|
-
return (_jsxs("li", { className: clsx('ams-app-navigation__menu-item'), children: [_jsxs("button", { ...restProps,
|
|
12
|
-
// aria-expanded={hasSubMenu ? submenuOpen : undefined}
|
|
13
|
-
className: clsx('ams-app-navigation__menu-link', active && 'ams-app-navigation__menu-link--active', className),
|
|
14
|
-
// onClick={handleClick}
|
|
15
|
-
ref: ref, children: [icon && _jsx(Icon, { size: "large", svg: icon }), _jsx("span", { className: "ams-app-navigation__menu-link-label", children: label }), hasSubMenu && _jsx(Icon, { className: "ams-app-navigation__menu-link-chevron", size: "small", svg: ChevronDownIcon })] }), children] }));
|
|
16
|
-
});
|
|
17
|
-
AppNavigationMenuButton.displayName = 'AppNavigation.MenuButton';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license EUPL-1.2+
|
|
3
|
-
* Copyright Gemeente Amsterdam
|
|
4
|
-
*/
|
|
5
|
-
import type { AnchorHTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import type { IconProps } from '../Icon';
|
|
8
|
-
export type AppNavigationMenuLinkProps = PropsWithChildren<AnchorHTMLAttributes<HTMLAnchorElement>> & {
|
|
9
|
-
active?: boolean;
|
|
10
|
-
icon?: IconProps['svg'];
|
|
11
|
-
label: string;
|
|
12
|
-
};
|
|
13
|
-
export declare const AppNavigationMenuLink: React.ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
14
|
-
children?: React.ReactNode | undefined;
|
|
15
|
-
} & {
|
|
16
|
-
active?: boolean;
|
|
17
|
-
icon?: IconProps["svg"];
|
|
18
|
-
label: string;
|
|
19
|
-
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronDownIcon } from '@amsterdam/design-system-react-icons';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { Children, isValidElement, useState } from 'react';
|
|
5
|
-
import { forwardRef } from 'react';
|
|
6
|
-
import { Icon } from '../Icon';
|
|
7
|
-
export const AppNavigationMenuLink = forwardRef(({ active, children, className, icon, label, ...restProps }, ref) => {
|
|
8
|
-
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
9
|
-
// Check if children contain an element with type 'AppNavigation.Menu'
|
|
10
|
-
const hasSubMenu = Children.toArray(children).some((child) => isValidElement(child) && child.type?.displayName === 'AppNavigation.Menu');
|
|
11
|
-
const handleClick = (e) => {
|
|
12
|
-
if (hasSubMenu) {
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
setSubmenuOpen((open) => !open);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return (_jsxs("li", { className: clsx('ams-app-navigation__menu-item', submenuOpen && 'ams-app-navigation__menu-item--open'), children: [_jsxs("a", { ...restProps, "aria-expanded": hasSubMenu ? submenuOpen : undefined, className: clsx('ams-app-navigation__menu-link', active && 'ams-app-navigation__menu-link--active', className), onClick: handleClick, ref: ref, children: [icon && _jsx(Icon, { size: "large", svg: icon }), _jsx("span", { className: "ams-app-navigation__menu-link-label", children: label }), hasSubMenu && _jsx(Icon, { className: "ams-app-navigation__menu-link-chevron", size: "small", svg: ChevronDownIcon })] }), children] }));
|
|
18
|
-
});
|
|
19
|
-
AppNavigationMenuLink.displayName = 'AppNavigation.MenuLink';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license EUPL-1.2+
|
|
3
|
-
* Copyright Gemeente Amsterdam
|
|
4
|
-
*/
|
|
5
|
-
import type { OlHTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
-
export type AppNavigationMenuProps = PropsWithChildren<OlHTMLAttributes<HTMLOListElement>>;
|
|
7
|
-
export declare const AppNavigationMenu: import("react").ForwardRefExoticComponent<OlHTMLAttributes<HTMLOListElement> & {
|
|
8
|
-
children?: import("react").ReactNode | undefined;
|
|
9
|
-
} & import("react").RefAttributes<HTMLOListElement>>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
export const AppNavigationMenu = forwardRef(({ children, className, ...restProps }, ref) => (_jsx("ol", { className: clsx('ams-app-navigation__menu', className), ref: ref, ...restProps, children: children })));
|
|
5
|
-
AppNavigationMenu.displayName = 'AppNavigation.Menu';
|