@amsterdam/design-system-react 1.1.0 → 2.0.1

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.
Files changed (232) hide show
  1. package/dist/Accordion/Accordion.d.ts +7 -7
  2. package/dist/Accordion/Accordion.js +2 -6
  3. package/dist/Accordion/Accordion.test.js +4 -4
  4. package/dist/Accordion/AccordionContext.d.ts +1 -2
  5. package/dist/Accordion/AccordionContext.js +3 -2
  6. package/dist/Accordion/AccordionSection.d.ts +5 -5
  7. package/dist/Accordion/AccordionSection.js +6 -9
  8. package/dist/Accordion/AccordionSection.test.js +18 -5
  9. package/dist/ActionGroup/ActionGroup.js +1 -5
  10. package/dist/Alert/Alert.d.ts +16 -4
  11. package/dist/Alert/Alert.js +3 -7
  12. package/dist/Alert/Alert.test.js +24 -13
  13. package/dist/Avatar/Avatar.js +1 -5
  14. package/dist/Avatar/Avatar.test.js +2 -1
  15. package/dist/Badge/Badge.d.ts +4 -4
  16. package/dist/Badge/Badge.js +1 -5
  17. package/dist/Blockquote/Blockquote.d.ts +5 -5
  18. package/dist/Blockquote/Blockquote.js +1 -5
  19. package/dist/Breadcrumb/Breadcrumb.js +0 -4
  20. package/dist/Breadcrumb/Breadcrumb.test.js +1 -1
  21. package/dist/Breadcrumb/BreadcrumbLink.js +0 -4
  22. package/dist/Breakout/Breakout.js +2 -6
  23. package/dist/Breakout/Breakout.test.js +1 -1
  24. package/dist/Breakout/BreakoutCell.d.ts +3 -3
  25. package/dist/Breakout/BreakoutCell.js +1 -5
  26. package/dist/Breakout/BreakoutCell.test.js +2 -2
  27. package/dist/Button/Button.d.ts +4 -4
  28. package/dist/Button/Button.js +1 -5
  29. package/dist/CallToActionLink/CallToActionLink.d.ts +12 -0
  30. package/dist/CallToActionLink/CallToActionLink.js +8 -0
  31. package/dist/CallToActionLink/CallToActionLink.test.d.ts +5 -0
  32. package/dist/CallToActionLink/CallToActionLink.test.js +33 -0
  33. package/dist/CallToActionLink/index.d.ts +6 -0
  34. package/dist/CallToActionLink/index.js +5 -0
  35. package/dist/Card/Card.d.ts +8 -8
  36. package/dist/Card/Card.js +1 -5
  37. package/dist/Card/CardHeading.d.ts +3 -3
  38. package/dist/Card/CardHeading.js +2 -6
  39. package/dist/Card/CardHeading.test.js +1 -1
  40. package/dist/Card/CardHeadingGroup.d.ts +5 -5
  41. package/dist/Card/CardHeadingGroup.js +1 -5
  42. package/dist/Card/CardImage.d.ts +2 -2
  43. package/dist/Card/CardImage.js +1 -5
  44. package/dist/Card/CardLink.js +1 -5
  45. package/dist/CharacterCount/CharacterCount.d.ts +4 -4
  46. package/dist/CharacterCount/CharacterCount.js +1 -5
  47. package/dist/Checkbox/Checkbox.d.ts +15 -9
  48. package/dist/Checkbox/Checkbox.js +4 -8
  49. package/dist/Checkbox/Checkbox.test.js +9 -0
  50. package/dist/Column/Column.d.ts +5 -5
  51. package/dist/Column/Column.js +1 -5
  52. package/dist/Column/Column.test.js +1 -1
  53. package/dist/DateInput/DateInput.d.ts +4 -4
  54. package/dist/DateInput/DateInput.js +1 -5
  55. package/dist/DescriptionList/DescriptionList.d.ts +5 -5
  56. package/dist/DescriptionList/DescriptionList.js +1 -5
  57. package/dist/DescriptionList/DescriptionListDescription.js +1 -5
  58. package/dist/DescriptionList/DescriptionListSection.js +1 -5
  59. package/dist/DescriptionList/DescriptionListTerm.js +1 -5
  60. package/dist/DescriptionList/index.d.ts +1 -1
  61. package/dist/Dialog/Dialog.d.ts +6 -6
  62. package/dist/Dialog/Dialog.js +2 -6
  63. package/dist/ErrorMessage/ErrorMessage.d.ts +11 -4
  64. package/dist/ErrorMessage/ErrorMessage.js +2 -6
  65. package/dist/Field/Field.d.ts +5 -5
  66. package/dist/Field/Field.js +1 -5
  67. package/dist/FieldSet/FieldSet.d.ts +7 -7
  68. package/dist/FieldSet/FieldSet.js +1 -5
  69. package/dist/Figure/Figure.d.ts +3 -3
  70. package/dist/Figure/Figure.js +1 -5
  71. package/dist/Figure/FigureCaption.d.ts +5 -5
  72. package/dist/Figure/FigureCaption.js +1 -5
  73. package/dist/FileInput/FileInput.js +1 -5
  74. package/dist/FileList/FileList.d.ts +3 -3
  75. package/dist/FileList/FileList.js +1 -5
  76. package/dist/FileList/FileListItem.d.ts +4 -4
  77. package/dist/FileList/FileListItem.js +2 -6
  78. package/dist/Grid/Grid.d.ts +2 -2
  79. package/dist/Grid/Grid.js +1 -5
  80. package/dist/Grid/Grid.test.js +1 -1
  81. package/dist/Grid/GridCell.d.ts +2 -2
  82. package/dist/Grid/GridCell.js +1 -5
  83. package/dist/Grid/GridCell.test.js +1 -1
  84. package/dist/Heading/Heading.d.ts +18 -7
  85. package/dist/Heading/Heading.js +1 -10
  86. package/dist/Heading/Heading.test.js +1 -3
  87. package/dist/Hint/Hint.d.ts +3 -3
  88. package/dist/Hint/Hint.js +1 -5
  89. package/dist/Icon/Icon.d.ts +15 -3
  90. package/dist/Icon/Icon.js +14 -13
  91. package/dist/Icon/Icon.test.js +5 -0
  92. package/dist/IconButton/IconButton.js +1 -5
  93. package/dist/Image/Image.d.ts +4 -4
  94. package/dist/Image/Image.js +2 -6
  95. package/dist/Image/Image.test.js +2 -2
  96. package/dist/Image/index.d.ts +1 -1
  97. package/dist/Image/index.js +1 -1
  98. package/dist/ImageSlider/ImageSlider.d.ts +3 -3
  99. package/dist/ImageSlider/ImageSlider.js +2 -6
  100. package/dist/ImageSlider/ImageSliderControls.js +2 -6
  101. package/dist/ImageSlider/ImageSliderItem.d.ts +5 -5
  102. package/dist/ImageSlider/ImageSliderItem.js +1 -5
  103. package/dist/ImageSlider/ImageSliderScroller.js +1 -5
  104. package/dist/ImageSlider/ImageSliderThumbnails.d.ts +4 -4
  105. package/dist/ImageSlider/ImageSliderThumbnails.js +2 -6
  106. package/dist/InvalidFormAlert/InvalidFormAlert.d.ts +4 -4
  107. package/dist/InvalidFormAlert/InvalidFormAlert.js +0 -4
  108. package/dist/InvalidFormAlert/InvalidFormAlertWithErrors.js +5 -6
  109. package/dist/Label/Label.d.ts +10 -5
  110. package/dist/Label/Label.js +1 -10
  111. package/dist/Link/Link.d.ts +4 -4
  112. package/dist/Link/Link.js +1 -5
  113. package/dist/LinkList/LinkList.d.ts +1 -1
  114. package/dist/LinkList/LinkList.js +1 -5
  115. package/dist/LinkList/LinkListLink.d.ts +13 -4
  116. package/dist/LinkList/LinkListLink.js +3 -7
  117. package/dist/LinkList/LinkListLink.test.js +1 -1
  118. package/dist/Logo/Logo.d.ts +2 -2
  119. package/dist/Logo/Logo.js +1 -5
  120. package/dist/Logo/brand/LogoAmsterdam.js +2 -5
  121. package/dist/Logo/brand/LogoGgdAmsterdam.js +2 -5
  122. package/dist/Logo/brand/LogoMuseumWeesp.js +2 -5
  123. package/dist/Logo/brand/LogoStadsarchief.js +2 -5
  124. package/dist/Logo/brand/LogoStadsbankVanLening.js +2 -5
  125. package/dist/Logo/brand/LogoVgaVerzekeringen.js +2 -5
  126. package/dist/Logo/index.d.ts +1 -1
  127. package/dist/Mark/Mark.js +1 -5
  128. package/dist/Menu/Menu.d.ts +28 -0
  129. package/dist/Menu/Menu.js +10 -0
  130. package/dist/Menu/Menu.test.d.ts +5 -0
  131. package/dist/Menu/Menu.test.js +38 -0
  132. package/dist/Menu/MenuLink.d.ts +20 -0
  133. package/dist/Menu/MenuLink.js +8 -0
  134. package/dist/Menu/MenuLink.test.d.ts +5 -0
  135. package/dist/Menu/MenuLink.test.js +56 -0
  136. package/dist/Menu/index.d.ts +7 -0
  137. package/dist/Menu/index.js +5 -0
  138. package/dist/OrderedList/OrderedList.d.ts +5 -5
  139. package/dist/OrderedList/OrderedList.js +1 -5
  140. package/dist/OrderedList/OrderedList.test.js +1 -1
  141. package/dist/OrderedList/OrderedListItem.js +1 -5
  142. package/dist/Overlap/Overlap.js +1 -5
  143. package/dist/Page/Page.js +1 -5
  144. package/dist/PageFooter/PageFooter.js +1 -5
  145. package/dist/PageFooter/PageFooterMenu.js +1 -5
  146. package/dist/PageFooter/PageFooterMenuLink.js +1 -5
  147. package/dist/PageFooter/PageFooterSpotlight.js +1 -5
  148. package/dist/PageHeader/PageHeader.d.ts +7 -7
  149. package/dist/PageHeader/PageHeader.js +3 -7
  150. package/dist/PageHeader/PageHeader.test.js +1 -1
  151. package/dist/PageHeader/PageHeaderGridCellNarrowWindowOnly.js +1 -1
  152. package/dist/PageHeader/PageHeaderMenuLink.d.ts +5 -5
  153. package/dist/PageHeader/PageHeaderMenuLink.js +1 -1
  154. package/dist/PageHeading/PageHeading.d.ts +6 -5
  155. package/dist/PageHeading/PageHeading.js +2 -5
  156. package/dist/Pagination/Pagination.d.ts +52 -10
  157. package/dist/Pagination/Pagination.js +5 -9
  158. package/dist/Pagination/Pagination.test.js +23 -10
  159. package/dist/Pagination/getRange.js +4 -2
  160. package/dist/Paragraph/Paragraph.d.ts +10 -5
  161. package/dist/Paragraph/Paragraph.js +1 -10
  162. package/dist/PasswordInput/PasswordInput.d.ts +4 -4
  163. package/dist/PasswordInput/PasswordInput.js +1 -5
  164. package/dist/PasswordInput/PasswordInput.test.js +1 -1
  165. package/dist/Radio/Radio.d.ts +15 -9
  166. package/dist/Radio/Radio.js +4 -8
  167. package/dist/Radio/Radio.test.js +9 -0
  168. package/dist/Row/Row.d.ts +5 -5
  169. package/dist/Row/Row.js +1 -5
  170. package/dist/Row/Row.test.js +1 -1
  171. package/dist/SearchField/SearchField.d.ts +3 -5
  172. package/dist/SearchField/SearchField.js +1 -5
  173. package/dist/SearchField/SearchFieldButton.js +0 -4
  174. package/dist/SearchField/SearchFieldInput.d.ts +2 -2
  175. package/dist/SearchField/SearchFieldInput.js +1 -5
  176. package/dist/Select/Select.d.ts +5 -5
  177. package/dist/Select/Select.js +1 -5
  178. package/dist/Select/SelectOption.js +1 -5
  179. package/dist/Select/SelectOptionGroup.js +1 -5
  180. package/dist/SkipLink/SkipLink.js +1 -5
  181. package/dist/Spotlight/Spotlight.d.ts +5 -5
  182. package/dist/Spotlight/Spotlight.js +1 -1
  183. package/dist/Spotlight/Spotlight.test.js +1 -1
  184. package/dist/StandaloneLink/StandaloneLink.d.ts +15 -8
  185. package/dist/StandaloneLink/StandaloneLink.js +4 -6
  186. package/dist/StandaloneLink/StandaloneLink.test.js +6 -4
  187. package/dist/Switch/Switch.js +1 -5
  188. package/dist/Table/Table.js +1 -5
  189. package/dist/Table/TableBody.js +1 -5
  190. package/dist/Table/TableCaption.d.ts +5 -0
  191. package/dist/Table/TableCaption.js +1 -10
  192. package/dist/Table/TableCell.js +1 -5
  193. package/dist/Table/TableFooter.js +1 -5
  194. package/dist/Table/TableHeader.js +1 -5
  195. package/dist/Table/TableHeaderCell.js +1 -5
  196. package/dist/Table/TableRow.js +1 -5
  197. package/dist/TableOfContents/TableOfContents.d.ts +9 -9
  198. package/dist/TableOfContents/TableOfContents.js +4 -7
  199. package/dist/TableOfContents/TableOfContentsLink.d.ts +4 -4
  200. package/dist/TableOfContents/TableOfContentsLink.js +0 -4
  201. package/dist/TableOfContents/TableOfContentsList.js +1 -5
  202. package/dist/TableOfContents/TableOfContentsList.test.js +1 -1
  203. package/dist/Tabs/Tabs.d.ts +11 -11
  204. package/dist/Tabs/Tabs.js +1 -5
  205. package/dist/Tabs/TabsButton.d.ts +5 -5
  206. package/dist/Tabs/TabsButton.js +1 -5
  207. package/dist/Tabs/TabsList.js +1 -5
  208. package/dist/Tabs/TabsPanel.d.ts +5 -5
  209. package/dist/Tabs/TabsPanel.js +1 -5
  210. package/dist/Tabs/index.d.ts +2 -2
  211. package/dist/TextArea/TextArea.d.ts +4 -4
  212. package/dist/TextArea/TextArea.js +1 -5
  213. package/dist/TextInput/TextInput.d.ts +4 -4
  214. package/dist/TextInput/TextInput.js +1 -5
  215. package/dist/TimeInput/TimeInput.d.ts +4 -4
  216. package/dist/TimeInput/TimeInput.js +1 -5
  217. package/dist/UnorderedList/UnorderedList.d.ts +5 -5
  218. package/dist/UnorderedList/UnorderedList.js +1 -5
  219. package/dist/UnorderedList/UnorderedList.test.js +1 -1
  220. package/dist/UnorderedList/UnorderedListItem.js +1 -5
  221. package/dist/common/formatFileType.d.ts +1 -1
  222. package/dist/common/formatFileType.js +10 -10
  223. package/dist/common/useKeyboardFocus.js +6 -6
  224. package/dist/common/useKeyboardFocus.test.js +2 -6
  225. package/dist/index.cjs.js +731 -619
  226. package/dist/index.cjs.js.map +1 -1
  227. package/dist/index.d.ts +394 -267
  228. package/dist/index.esm.js +633 -523
  229. package/dist/index.esm.js.map +1 -1
  230. package/dist/index.js +2 -0
  231. package/dist/tsconfig.tsbuildinfo +1 -1
  232. package/package.json +23 -23
@@ -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
- } & PropsWithChildren<HTMLAttributes<HTMLUListElement>>;
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, index) => (_jsx(UnorderedList.Item, { children: item }, index))) }));
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) => "gif" | "jpg" | "png" | "txt" | "pdf" | "Word" | "Excel" | "PowerPoint" | "Document";
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 getComponent = (rotate = undefined) => function () {
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 Component = getComponent(true);
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, {