@amsterdam/design-system-react 1.0.0 → 2.0.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 +0 -13
- package/dist/Accordion/Accordion.d.ts +7 -7
- package/dist/Accordion/Accordion.js +2 -6
- package/dist/Accordion/Accordion.test.js +4 -4
- package/dist/Accordion/AccordionContext.d.ts +1 -2
- package/dist/Accordion/AccordionContext.js +3 -2
- package/dist/Accordion/AccordionSection.d.ts +5 -5
- package/dist/Accordion/AccordionSection.js +6 -9
- package/dist/Accordion/AccordionSection.test.js +18 -5
- package/dist/ActionGroup/ActionGroup.js +1 -5
- package/dist/Alert/Alert.d.ts +16 -4
- package/dist/Alert/Alert.js +3 -7
- package/dist/Alert/Alert.test.js +24 -13
- package/dist/Avatar/Avatar.js +1 -5
- package/dist/Avatar/Avatar.test.js +2 -1
- package/dist/Badge/Badge.d.ts +4 -4
- package/dist/Badge/Badge.js +1 -5
- package/dist/Blockquote/Blockquote.d.ts +5 -5
- package/dist/Blockquote/Blockquote.js +1 -5
- package/dist/Breadcrumb/Breadcrumb.js +0 -4
- package/dist/Breadcrumb/Breadcrumb.test.js +1 -1
- package/dist/Breadcrumb/BreadcrumbLink.js +0 -4
- package/dist/Breakout/Breakout.js +2 -6
- package/dist/Breakout/Breakout.test.js +1 -1
- package/dist/Breakout/BreakoutCell.d.ts +3 -3
- package/dist/Breakout/BreakoutCell.js +1 -5
- package/dist/Breakout/BreakoutCell.test.js +2 -2
- package/dist/Button/Button.d.ts +4 -4
- package/dist/Button/Button.js +1 -5
- package/dist/CallToActionLink/CallToActionLink.d.ts +12 -0
- package/dist/CallToActionLink/CallToActionLink.js +8 -0
- package/dist/CallToActionLink/CallToActionLink.test.d.ts +5 -0
- package/dist/CallToActionLink/CallToActionLink.test.js +33 -0
- package/dist/CallToActionLink/index.d.ts +6 -0
- package/dist/CallToActionLink/index.js +5 -0
- package/dist/Card/Card.d.ts +8 -8
- package/dist/Card/Card.js +1 -5
- package/dist/Card/CardHeading.d.ts +3 -3
- package/dist/Card/CardHeading.js +2 -6
- package/dist/Card/CardHeading.test.js +1 -1
- package/dist/Card/CardHeadingGroup.d.ts +5 -5
- package/dist/Card/CardHeadingGroup.js +1 -5
- package/dist/Card/CardImage.d.ts +2 -2
- package/dist/Card/CardImage.js +1 -5
- package/dist/Card/CardLink.js +1 -5
- package/dist/CharacterCount/CharacterCount.d.ts +4 -4
- package/dist/CharacterCount/CharacterCount.js +1 -5
- package/dist/Checkbox/Checkbox.d.ts +15 -9
- package/dist/Checkbox/Checkbox.js +4 -8
- package/dist/Checkbox/Checkbox.test.js +9 -0
- package/dist/Column/Column.d.ts +5 -5
- package/dist/Column/Column.js +1 -5
- package/dist/Column/Column.test.js +1 -1
- package/dist/DateInput/DateInput.d.ts +4 -4
- package/dist/DateInput/DateInput.js +1 -5
- package/dist/DescriptionList/DescriptionList.d.ts +5 -5
- package/dist/DescriptionList/DescriptionList.js +1 -5
- package/dist/DescriptionList/DescriptionListDescription.js +1 -5
- package/dist/DescriptionList/DescriptionListSection.js +1 -5
- package/dist/DescriptionList/DescriptionListTerm.js +1 -5
- package/dist/DescriptionList/index.d.ts +1 -1
- package/dist/Dialog/Dialog.d.ts +6 -6
- package/dist/Dialog/Dialog.js +2 -6
- package/dist/ErrorMessage/ErrorMessage.d.ts +11 -4
- package/dist/ErrorMessage/ErrorMessage.js +2 -6
- package/dist/Field/Field.d.ts +5 -5
- package/dist/Field/Field.js +1 -5
- package/dist/FieldSet/FieldSet.d.ts +7 -7
- package/dist/FieldSet/FieldSet.js +1 -5
- package/dist/Figure/Figure.d.ts +3 -3
- package/dist/Figure/Figure.js +1 -5
- package/dist/Figure/FigureCaption.d.ts +5 -5
- package/dist/Figure/FigureCaption.js +1 -5
- package/dist/FileInput/FileInput.js +1 -5
- package/dist/FileList/FileList.d.ts +3 -3
- package/dist/FileList/FileList.js +1 -5
- package/dist/FileList/FileListItem.d.ts +4 -4
- package/dist/FileList/FileListItem.js +2 -6
- package/dist/Grid/Grid.d.ts +2 -2
- package/dist/Grid/Grid.js +1 -5
- package/dist/Grid/Grid.test.js +1 -1
- package/dist/Grid/GridCell.d.ts +2 -2
- package/dist/Grid/GridCell.js +1 -5
- package/dist/Grid/GridCell.test.js +1 -1
- package/dist/Heading/Heading.d.ts +18 -7
- package/dist/Heading/Heading.js +1 -10
- package/dist/Heading/Heading.test.js +1 -3
- package/dist/Hint/Hint.d.ts +3 -3
- package/dist/Hint/Hint.js +1 -5
- package/dist/Icon/Icon.d.ts +15 -3
- package/dist/Icon/Icon.js +14 -13
- package/dist/Icon/Icon.test.js +5 -0
- package/dist/IconButton/IconButton.js +1 -5
- package/dist/Image/Image.d.ts +4 -4
- package/dist/Image/Image.js +2 -6
- package/dist/Image/Image.test.js +2 -2
- package/dist/Image/index.d.ts +1 -1
- package/dist/Image/index.js +1 -1
- package/dist/ImageSlider/ImageSlider.d.ts +3 -3
- package/dist/ImageSlider/ImageSlider.js +2 -6
- package/dist/ImageSlider/ImageSliderControls.js +2 -6
- package/dist/ImageSlider/ImageSliderItem.d.ts +5 -5
- package/dist/ImageSlider/ImageSliderItem.js +1 -5
- package/dist/ImageSlider/ImageSliderScroller.js +1 -5
- package/dist/ImageSlider/ImageSliderThumbnails.d.ts +4 -4
- package/dist/ImageSlider/ImageSliderThumbnails.js +2 -6
- package/dist/InvalidFormAlert/InvalidFormAlert.d.ts +4 -4
- package/dist/InvalidFormAlert/InvalidFormAlert.js +0 -4
- package/dist/InvalidFormAlert/InvalidFormAlertWithErrors.js +5 -6
- package/dist/Label/Label.d.ts +10 -5
- package/dist/Label/Label.js +1 -10
- package/dist/Link/Link.d.ts +4 -4
- package/dist/Link/Link.js +1 -5
- package/dist/LinkList/LinkList.d.ts +1 -1
- package/dist/LinkList/LinkList.js +1 -5
- package/dist/LinkList/LinkListLink.d.ts +13 -4
- package/dist/LinkList/LinkListLink.js +3 -7
- package/dist/LinkList/LinkListLink.test.js +1 -1
- package/dist/Logo/Logo.d.ts +2 -2
- package/dist/Logo/Logo.js +29 -14
- package/dist/Logo/brand/LogoAmsterdam.js +2 -5
- package/dist/Logo/brand/LogoGgdAmsterdam.js +2 -5
- package/dist/Logo/brand/LogoMuseumWeesp.js +2 -5
- package/dist/Logo/brand/LogoStadsarchief.js +2 -5
- package/dist/Logo/brand/LogoStadsbankVanLening.js +2 -5
- package/dist/Logo/brand/LogoVgaVerzekeringen.js +2 -5
- package/dist/Logo/index.d.ts +1 -1
- package/dist/Mark/Mark.js +1 -5
- package/dist/Menu/Menu.d.ts +28 -0
- package/dist/Menu/Menu.js +10 -0
- package/dist/Menu/Menu.test.d.ts +5 -0
- package/dist/Menu/Menu.test.js +38 -0
- package/dist/Menu/MenuLink.d.ts +20 -0
- package/dist/Menu/MenuLink.js +8 -0
- package/dist/Menu/MenuLink.test.d.ts +5 -0
- package/dist/Menu/MenuLink.test.js +56 -0
- package/dist/Menu/index.d.ts +7 -0
- package/dist/Menu/index.js +5 -0
- package/dist/OrderedList/OrderedList.d.ts +5 -5
- package/dist/OrderedList/OrderedList.js +1 -5
- package/dist/OrderedList/OrderedList.test.js +1 -1
- package/dist/OrderedList/OrderedListItem.js +1 -5
- package/dist/Overlap/Overlap.js +1 -5
- package/dist/Page/Page.js +1 -5
- package/dist/PageFooter/PageFooter.js +1 -5
- package/dist/PageFooter/PageFooterMenu.js +1 -5
- package/dist/PageFooter/PageFooterMenuLink.js +1 -5
- package/dist/PageFooter/PageFooterSpotlight.js +1 -5
- package/dist/PageHeader/PageHeader.d.ts +11 -7
- package/dist/PageHeader/PageHeader.js +5 -9
- package/dist/PageHeader/PageHeader.test.js +8 -3
- package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.js +1 -1
- package/dist/PageHeader/PageHeaderMenuLink.d.ts +5 -5
- package/dist/PageHeader/PageHeaderMenuLink.js +1 -1
- package/dist/PageHeading/PageHeading.d.ts +6 -5
- package/dist/PageHeading/PageHeading.js +2 -5
- package/dist/Pagination/Pagination.d.ts +52 -10
- package/dist/Pagination/Pagination.js +5 -9
- package/dist/Pagination/Pagination.test.js +23 -10
- package/dist/Pagination/getRange.js +4 -2
- package/dist/Paragraph/Paragraph.d.ts +10 -5
- package/dist/Paragraph/Paragraph.js +1 -10
- package/dist/PasswordInput/PasswordInput.d.ts +4 -4
- package/dist/PasswordInput/PasswordInput.js +1 -5
- package/dist/PasswordInput/PasswordInput.test.js +1 -1
- package/dist/Radio/Radio.d.ts +15 -9
- package/dist/Radio/Radio.js +4 -8
- package/dist/Radio/Radio.test.js +9 -0
- package/dist/Row/Row.d.ts +5 -5
- package/dist/Row/Row.js +1 -5
- package/dist/Row/Row.test.js +1 -1
- package/dist/SearchField/SearchField.d.ts +3 -5
- package/dist/SearchField/SearchField.js +1 -5
- package/dist/SearchField/SearchFieldButton.js +0 -4
- package/dist/SearchField/SearchFieldInput.d.ts +2 -2
- package/dist/SearchField/SearchFieldInput.js +1 -5
- package/dist/Select/Select.d.ts +5 -5
- package/dist/Select/Select.js +1 -5
- package/dist/Select/SelectOption.js +1 -5
- package/dist/Select/SelectOptionGroup.js +1 -5
- package/dist/SkipLink/SkipLink.js +1 -5
- package/dist/Spotlight/Spotlight.d.ts +5 -5
- package/dist/Spotlight/Spotlight.js +1 -1
- package/dist/Spotlight/Spotlight.test.js +1 -1
- package/dist/StandaloneLink/StandaloneLink.d.ts +15 -8
- package/dist/StandaloneLink/StandaloneLink.js +4 -6
- package/dist/StandaloneLink/StandaloneLink.test.js +6 -4
- package/dist/Switch/Switch.js +1 -5
- package/dist/Table/Table.js +1 -5
- package/dist/Table/TableBody.js +1 -5
- package/dist/Table/TableCaption.d.ts +5 -0
- package/dist/Table/TableCaption.js +1 -10
- package/dist/Table/TableCell.js +1 -5
- package/dist/Table/TableFooter.js +1 -5
- package/dist/Table/TableHeader.js +1 -5
- package/dist/Table/TableHeaderCell.js +1 -5
- package/dist/Table/TableRow.js +1 -5
- package/dist/TableOfContents/TableOfContents.d.ts +9 -9
- package/dist/TableOfContents/TableOfContents.js +4 -7
- package/dist/TableOfContents/TableOfContentsLink.d.ts +4 -4
- package/dist/TableOfContents/TableOfContentsLink.js +0 -4
- package/dist/TableOfContents/TableOfContentsList.js +1 -5
- package/dist/TableOfContents/TableOfContentsList.test.js +1 -1
- package/dist/Tabs/Tabs.d.ts +11 -11
- package/dist/Tabs/Tabs.js +1 -5
- package/dist/Tabs/TabsButton.d.ts +5 -5
- package/dist/Tabs/TabsButton.js +1 -5
- package/dist/Tabs/TabsList.js +1 -5
- package/dist/Tabs/TabsPanel.d.ts +5 -5
- package/dist/Tabs/TabsPanel.js +1 -5
- package/dist/Tabs/index.d.ts +2 -2
- package/dist/TextArea/TextArea.d.ts +4 -4
- package/dist/TextArea/TextArea.js +1 -5
- package/dist/TextInput/TextInput.d.ts +4 -4
- package/dist/TextInput/TextInput.js +1 -5
- package/dist/TimeInput/TimeInput.d.ts +4 -4
- package/dist/TimeInput/TimeInput.js +1 -5
- package/dist/UnorderedList/UnorderedList.d.ts +5 -5
- package/dist/UnorderedList/UnorderedList.js +1 -5
- package/dist/UnorderedList/UnorderedList.test.js +1 -1
- package/dist/UnorderedList/UnorderedListItem.js +1 -5
- package/dist/common/formatFileType.d.ts +1 -1
- package/dist/common/formatFileType.js +10 -10
- package/dist/common/useKeyboardFocus.js +6 -6
- package/dist/common/useKeyboardFocus.test.js +2 -6
- package/dist/index.cjs.js +775 -638
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +398 -267
- package/dist/index.esm.js +677 -542
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Copyright Gemeente Amsterdam
|
|
4
4
|
*/
|
|
5
5
|
import type { InputHTMLAttributes } from 'react';
|
|
6
|
-
export type TimeInputProps = {
|
|
6
|
+
export type TimeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'aria-invalid' | 'type'> & {
|
|
7
7
|
/** Whether the value fails a validation rule. */
|
|
8
8
|
invalid?: boolean;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
/**
|
|
11
11
|
* @see {@link https://designsystem.amsterdam/?path=/docs/components-forms-time-input--docs Time Input docs at Amsterdam Design System}
|
|
12
12
|
*/
|
|
13
|
-
export declare const TimeInput: import("react").ForwardRefExoticComponent<{
|
|
13
|
+
export declare const TimeInput: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "aria-invalid" | "type"> & {
|
|
14
14
|
/** Whether the value fails a validation rule. */
|
|
15
15
|
invalid?: boolean;
|
|
16
|
-
} &
|
|
16
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
7
3
|
import { forwardRef } from 'react';
|
|
8
4
|
/**
|
|
9
5
|
* @see {@link https://designsystem.amsterdam/?path=/docs/components-forms-time-input--docs Time Input docs at Amsterdam Design System}
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
* Copyright Gemeente Amsterdam
|
|
4
4
|
*/
|
|
5
5
|
import type { HTMLAttributes, PropsWithChildren } from 'react';
|
|
6
|
-
export type UnorderedListProps = {
|
|
6
|
+
export type UnorderedListProps = PropsWithChildren<HTMLAttributes<HTMLUListElement>> & {
|
|
7
7
|
/** Changes the text colour for readability on a dark background. */
|
|
8
8
|
color?: 'inverse';
|
|
9
9
|
/** Whether the list items show a marker. */
|
|
10
10
|
markers?: boolean;
|
|
11
11
|
/** The size of the text. */
|
|
12
12
|
size?: 'small';
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
/**
|
|
15
15
|
* @see {@link https://designsystem.amsterdam/?path=/docs/components-text-unordered-list--docs Unordered List docs at Amsterdam Design System}
|
|
16
16
|
*/
|
|
17
|
-
export declare const UnorderedList: import("react").ForwardRefExoticComponent<{
|
|
17
|
+
export declare const UnorderedList: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLUListElement> & {
|
|
18
|
+
children?: import("react").ReactNode | undefined;
|
|
19
|
+
} & {
|
|
18
20
|
/** Changes the text colour for readability on a dark background. */
|
|
19
21
|
color?: "inverse";
|
|
20
22
|
/** Whether the list items show a marker. */
|
|
21
23
|
markers?: boolean;
|
|
22
24
|
/** The size of the text. */
|
|
23
25
|
size?: "small";
|
|
24
|
-
} & HTMLAttributes<HTMLUListElement> & {
|
|
25
|
-
children?: import("react").ReactNode | undefined;
|
|
26
26
|
} & import("react").RefAttributes<HTMLUListElement>> & {
|
|
27
27
|
Item: import("react").ForwardRefExoticComponent<import("react").LiHTMLAttributes<HTMLLIElement> & {
|
|
28
28
|
children?: import("react").ReactNode | undefined;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
7
3
|
import { forwardRef } from 'react';
|
|
8
4
|
import { UnorderedListItem } from './UnorderedListItem';
|
|
9
5
|
const UnorderedListRoot = forwardRef(({ children, className, color, markers = true, size, ...restProps }, ref) => {
|
|
@@ -35,7 +35,7 @@ describe('Unordered list', () => {
|
|
|
35
35
|
});
|
|
36
36
|
it('renders its subcomponent', () => {
|
|
37
37
|
const listItems = ['Item 1', 'Item 2', 'Item 3'];
|
|
38
|
-
const { container } = render(_jsx(UnorderedList, { children: listItems.map((item
|
|
38
|
+
const { container } = render(_jsx(UnorderedList, { children: listItems.map((item) => (_jsx(UnorderedList.Item, { children: item }, item))) }));
|
|
39
39
|
const list = screen.getByRole('list');
|
|
40
40
|
const items = container.querySelectorAll('.ams-unordered-list__item');
|
|
41
41
|
expect(list).toBeInTheDocument();
|
|
@@ -1,9 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
7
3
|
import { forwardRef } from 'react';
|
|
8
4
|
export const UnorderedListItem = forwardRef(({ children, className, ...restProps }, ref) => (_jsx("li", { className: clsx('ams-unordered-list__item', className), ref: ref, ...restProps, children: children })));
|
|
9
5
|
UnorderedListItem.displayName = 'UnorderedList.Item';
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* @param fileType
|
|
8
8
|
* @returns Human readable file type
|
|
9
9
|
*/
|
|
10
|
-
export declare const formatFileType: (fileType: string) => "
|
|
10
|
+
export declare const formatFileType: (fileType: string) => "Word" | "pdf" | "Excel" | "PowerPoint" | "gif" | "jpg" | "png" | "txt" | "Document";
|
|
@@ -9,25 +9,25 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export const formatFileType = (fileType) => {
|
|
11
11
|
switch (fileType) {
|
|
12
|
-
case 'image/gif':
|
|
13
|
-
return 'gif';
|
|
14
|
-
case 'image/jpeg':
|
|
15
|
-
return 'jpg';
|
|
16
|
-
case 'image/png':
|
|
17
|
-
return 'png';
|
|
18
|
-
case 'text/plain':
|
|
19
|
-
return 'txt';
|
|
20
|
-
case 'application/pdf':
|
|
21
|
-
return 'pdf';
|
|
22
12
|
case 'application/msword':
|
|
23
13
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
|
24
14
|
return 'Word';
|
|
15
|
+
case 'application/pdf':
|
|
16
|
+
return 'pdf';
|
|
25
17
|
case 'application/vnd.ms-excel':
|
|
26
18
|
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
|
27
19
|
return 'Excel';
|
|
28
20
|
case 'application/vnd.ms-powerpoint':
|
|
29
21
|
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
|
|
30
22
|
return 'PowerPoint';
|
|
23
|
+
case 'image/gif':
|
|
24
|
+
return 'gif';
|
|
25
|
+
case 'image/jpeg':
|
|
26
|
+
return 'jpg';
|
|
27
|
+
case 'image/png':
|
|
28
|
+
return 'png';
|
|
29
|
+
case 'text/plain':
|
|
30
|
+
return 'txt';
|
|
31
31
|
default:
|
|
32
32
|
return 'Document';
|
|
33
33
|
}
|
|
@@ -33,6 +33,12 @@ export const useKeyboardFocus = (ref, options) => {
|
|
|
33
33
|
const getIndex = (el) => (el && focusableEls.includes(el) ? focusableEls.indexOf(el) : -1);
|
|
34
34
|
let targetElement;
|
|
35
35
|
switch (e.key) {
|
|
36
|
+
case KeyboardKeys.End:
|
|
37
|
+
targetElement = focusableEls[focusableEls.length - 1];
|
|
38
|
+
break;
|
|
39
|
+
case KeyboardKeys.Home:
|
|
40
|
+
targetElement = focusableEls[0];
|
|
41
|
+
break;
|
|
36
42
|
case nextKey:
|
|
37
43
|
targetElement = focusableEls[getIndex(activeElement) + 1] || (rotating ? focusableEls[0] : undefined);
|
|
38
44
|
break;
|
|
@@ -40,12 +46,6 @@ export const useKeyboardFocus = (ref, options) => {
|
|
|
40
46
|
targetElement =
|
|
41
47
|
focusableEls[getIndex(activeElement) - 1] || (rotating ? focusableEls[focusableEls.length - 1] : undefined);
|
|
42
48
|
break;
|
|
43
|
-
case KeyboardKeys.Home:
|
|
44
|
-
targetElement = focusableEls[0];
|
|
45
|
-
break;
|
|
46
|
-
case KeyboardKeys.End:
|
|
47
|
-
targetElement = focusableEls[focusableEls.length - 1];
|
|
48
|
-
break;
|
|
49
49
|
}
|
|
50
50
|
if (targetElement instanceof HTMLElement) {
|
|
51
51
|
targetElement.focus();
|
|
@@ -10,7 +10,7 @@ describe('use focus with arrows', () => {
|
|
|
10
10
|
const onFocusOneMock = jest.fn();
|
|
11
11
|
const onFocusTwoMock = jest.fn();
|
|
12
12
|
const onFocusThreeMock = jest.fn();
|
|
13
|
-
const
|
|
13
|
+
const Component = ({ rotate = undefined }) => {
|
|
14
14
|
const ref = useRef(null);
|
|
15
15
|
const { keyDown } = useKeyboardFocus(ref, {
|
|
16
16
|
rotating: rotate,
|
|
@@ -23,7 +23,6 @@ describe('use focus with arrows', () => {
|
|
|
23
23
|
onFocusThreeMock.mockReset();
|
|
24
24
|
});
|
|
25
25
|
it('sets focus when using arrow keys', () => {
|
|
26
|
-
const Component = getComponent();
|
|
27
26
|
const { container } = render(_jsx(Component, {}));
|
|
28
27
|
const firstChild = container.firstChild;
|
|
29
28
|
expect(onFocusOneMock).not.toHaveBeenCalled();
|
|
@@ -46,8 +45,7 @@ describe('use focus with arrows', () => {
|
|
|
46
45
|
expect(onFocusOneMock).toHaveBeenCalledTimes(2);
|
|
47
46
|
});
|
|
48
47
|
it('rotates focused elements', () => {
|
|
49
|
-
const
|
|
50
|
-
const { container } = render(_jsx(Component, {}));
|
|
48
|
+
const { container } = render(_jsx(Component, { rotate: true }));
|
|
51
49
|
const firstChild = container.firstChild;
|
|
52
50
|
Array.from(Array(9).keys()).forEach(() => {
|
|
53
51
|
fireEvent.keyDown(firstChild, {
|
|
@@ -63,7 +61,6 @@ describe('use focus with arrows', () => {
|
|
|
63
61
|
expect(onFocusOneMock).toHaveBeenCalledTimes(6);
|
|
64
62
|
});
|
|
65
63
|
it('sets focus to first element when using "Home" key', () => {
|
|
66
|
-
const Component = getComponent();
|
|
67
64
|
const { container } = render(_jsx(Component, {}));
|
|
68
65
|
const firstChild = container.firstChild;
|
|
69
66
|
fireEvent.keyDown(firstChild, {
|
|
@@ -72,7 +69,6 @@ describe('use focus with arrows', () => {
|
|
|
72
69
|
expect(onFocusOneMock).toHaveBeenCalledTimes(1);
|
|
73
70
|
});
|
|
74
71
|
it('sets focus to last element when using "End" key', () => {
|
|
75
|
-
const Component = getComponent();
|
|
76
72
|
const { container } = render(_jsx(Component, {}));
|
|
77
73
|
const firstChild = container.firstChild;
|
|
78
74
|
fireEvent.keyDown(firstChild, {
|