@lumx/react 3.20.1-alpha.2 → 3.20.1-alpha.21

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 (234) hide show
  1. package/CONTRIBUTING.md +1 -5
  2. package/README.md +0 -2
  3. package/_internal/index.js +20 -13
  4. package/_internal/index.js.map +1 -1
  5. package/index.d.ts +35 -35
  6. package/index.js +2407 -2447
  7. package/index.js.map +1 -1
  8. package/package.json +10 -13
  9. package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
  10. package/src/components/alert-dialog/AlertDialog.test.tsx +3 -4
  11. package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
  12. package/src/components/autocomplete/Autocomplete.test.tsx +3 -5
  13. package/src/components/autocomplete/Autocomplete.tsx +1 -1
  14. package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
  15. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +0 -2
  16. package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
  17. package/src/components/avatar/Avatar.stories.tsx +0 -2
  18. package/src/components/avatar/Avatar.test.tsx +0 -2
  19. package/src/components/avatar/Avatar.tsx +1 -1
  20. package/src/components/badge/Badge.stories.tsx +0 -1
  21. package/src/components/badge/Badge.test.tsx +0 -2
  22. package/src/components/badge/Badge.tsx +1 -1
  23. package/src/components/badge/BadgeWrapper.stories.tsx +0 -1
  24. package/src/components/badge/BadgeWrapper.test.tsx +0 -2
  25. package/src/components/badge/BadgeWrapper.tsx +1 -1
  26. package/src/components/button/Button.stories.tsx +0 -1
  27. package/src/components/button/Button.test.tsx +9 -11
  28. package/src/components/button/Button.tsx +0 -2
  29. package/src/components/button/ButtonGroup.stories.tsx +0 -2
  30. package/src/components/button/ButtonGroup.test.tsx +0 -2
  31. package/src/components/button/ButtonGroup.tsx +0 -2
  32. package/src/components/button/ButtonRoot.tsx +7 -37
  33. package/src/components/button/IconButton.test.tsx +0 -2
  34. package/src/components/button/IconButton.tsx +0 -2
  35. package/src/components/checkbox/Checkbox.test.tsx +3 -5
  36. package/src/components/chip/Chip.stories.tsx +0 -2
  37. package/src/components/chip/Chip.test.tsx +19 -19
  38. package/src/components/chip/Chip.tsx +1 -1
  39. package/src/components/chip/ChipGroup.stories.tsx +0 -2
  40. package/src/components/chip/ChipGroup.test.tsx +0 -2
  41. package/src/components/chip/ChipGroup.tsx +1 -1
  42. package/src/components/comment-block/CommentBlock.stories.tsx +0 -1
  43. package/src/components/comment-block/CommentBlock.test.tsx +0 -1
  44. package/src/components/comment-block/CommentBlock.tsx +1 -1
  45. package/src/components/date-picker/DatePicker.test.tsx +3 -5
  46. package/src/components/date-picker/DatePicker.tsx +1 -1
  47. package/src/components/date-picker/DatePickerControlled.test.tsx +6 -8
  48. package/src/components/date-picker/DatePickerField.test.tsx +3 -5
  49. package/src/components/dialog/Dialog.test.tsx +4 -6
  50. package/src/components/divider/Divider.test.tsx +0 -2
  51. package/src/components/divider/Divider.tsx +0 -2
  52. package/src/components/drag-handle/DragHandle.test.tsx +0 -2
  53. package/src/components/drag-handle/DragHandle.tsx +0 -2
  54. package/src/components/dropdown/Dropdown.stories.tsx +1 -1
  55. package/src/components/dropdown/Dropdown.test.tsx +3 -3
  56. package/src/components/dropdown/Dropdown.tsx +1 -1
  57. package/src/components/expansion-panel/ExpansionPanel.test.tsx +6 -7
  58. package/src/components/flag/Flag.test.tsx +0 -2
  59. package/src/components/flag/Flag.tsx +0 -2
  60. package/src/components/flex-box/FlexBox.stories.tsx +0 -2
  61. package/src/components/flex-box/FlexBox.test.tsx +0 -1
  62. package/src/components/flex-box/FlexBox.tsx +1 -1
  63. package/src/components/generic-block/GenericBlock.test.tsx +1 -1
  64. package/src/components/grid/Grid.tsx +0 -2
  65. package/src/components/grid/GridItem.tsx +0 -2
  66. package/src/components/grid-column/GridColumn.stories.tsx +0 -1
  67. package/src/components/grid-column/GridColumn.test.jsx +0 -2
  68. package/src/components/grid-column/GridColumn.tsx +1 -1
  69. package/src/components/heading/Heading.stories.tsx +0 -1
  70. package/src/components/heading/Heading.test.tsx +0 -2
  71. package/src/components/heading/Heading.tsx +0 -2
  72. package/src/components/heading/HeadingLevelProvider.tsx +1 -1
  73. package/src/components/icon/Icon.stories.tsx +30 -4
  74. package/src/components/icon/Icon.test.tsx +85 -4
  75. package/src/components/icon/Icon.tsx +118 -9
  76. package/src/components/image-block/ImageBlock.stories.tsx +0 -2
  77. package/src/components/image-block/ImageBlock.test.tsx +0 -1
  78. package/src/components/image-block/ImageBlock.tsx +1 -1
  79. package/src/components/image-block/ImageCaption.tsx +1 -1
  80. package/src/components/image-lightbox/ImageLightbox.stories.tsx +0 -1
  81. package/src/components/image-lightbox/ImageLightbox.test.tsx +11 -9
  82. package/src/components/image-lightbox/types.ts +0 -2
  83. package/src/components/inline-list/InlineList.stories.tsx +0 -1
  84. package/src/components/inline-list/InlineList.test.tsx +0 -2
  85. package/src/components/inline-list/InlineList.tsx +1 -1
  86. package/src/components/input-helper/InputHelper.test.tsx +0 -2
  87. package/src/components/input-helper/InputHelper.tsx +1 -1
  88. package/src/components/input-label/InputLabel.stories.tsx +0 -2
  89. package/src/components/input-label/InputLabel.test.tsx +0 -2
  90. package/src/components/input-label/InputLabel.tsx +1 -1
  91. package/src/components/lightbox/Lightbox.test.tsx +0 -2
  92. package/src/components/lightbox/Lightbox.tsx +1 -1
  93. package/src/components/link/Link.stories.tsx +0 -1
  94. package/src/components/link/Link.test.tsx +13 -13
  95. package/src/components/link/Link.tsx +9 -22
  96. package/src/components/link-preview/LinkPreview.test.tsx +0 -2
  97. package/src/components/link-preview/LinkPreview.tsx +0 -2
  98. package/src/components/list/List.stories.tsx +1 -1
  99. package/src/components/list/List.test.tsx +0 -2
  100. package/src/components/list/List.tsx +1 -1
  101. package/src/components/list/ListDivider.test.tsx +0 -2
  102. package/src/components/list/ListDivider.tsx +0 -2
  103. package/src/components/list/ListItem.test.tsx +5 -7
  104. package/src/components/list/ListItem.tsx +1 -1
  105. package/src/components/list/ListSubheader.test.tsx +0 -2
  106. package/src/components/list/ListSubheader.tsx +1 -1
  107. package/src/components/message/Message.test.tsx +1 -2
  108. package/src/components/message/Message.tsx +1 -1
  109. package/src/components/mosaic/Mosaic.test.tsx +3 -5
  110. package/src/components/mosaic/Mosaic.tsx +1 -1
  111. package/src/components/navigation/Navigation.stories.tsx +0 -2
  112. package/src/components/navigation/Navigation.test.tsx +0 -2
  113. package/src/components/navigation/Navigation.tsx +0 -2
  114. package/src/components/navigation/NavigationItem.test.tsx +0 -2
  115. package/src/components/navigation/NavigationItem.tsx +7 -11
  116. package/src/components/navigation/NavigationSection.test.tsx +0 -2
  117. package/src/components/navigation/NavigationSection.tsx +5 -4
  118. package/src/components/notification/Notification.test.tsx +4 -5
  119. package/src/components/notification/Notification.tsx +1 -1
  120. package/src/components/popover/Popover.test.tsx +0 -2
  121. package/src/components/popover/Popover.tsx +1 -1
  122. package/src/components/popover/usePopoverStyle.tsx +1 -1
  123. package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -2
  124. package/src/components/popover-dialog/PopoverDialog.tsx +0 -2
  125. package/src/components/post-block/PostBlock.test.tsx +0 -2
  126. package/src/components/post-block/PostBlock.tsx +1 -1
  127. package/src/components/progress/Progress.tsx +0 -2
  128. package/src/components/progress/ProgressCircular.stories.tsx +0 -1
  129. package/src/components/progress/ProgressCircular.test.tsx +0 -2
  130. package/src/components/progress/ProgressCircular.tsx +0 -2
  131. package/src/components/progress/ProgressLinear.test.tsx +0 -2
  132. package/src/components/progress/ProgressLinear.tsx +0 -2
  133. package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
  134. package/src/components/progress-tracker/ProgressTracker.test.tsx +0 -2
  135. package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +0 -2
  136. package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
  137. package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +0 -2
  138. package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
  139. package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +0 -2
  140. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +0 -2
  141. package/src/components/radio-button/RadioButton.test.tsx +3 -5
  142. package/src/components/radio-button/RadioButton.tsx +1 -1
  143. package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
  144. package/src/components/radio-button/RadioGroup.test.tsx +0 -2
  145. package/src/components/radio-button/RadioGroup.tsx +1 -1
  146. package/src/components/select/Select.stories.tsx +1 -1
  147. package/src/components/select/Select.test.tsx +8 -9
  148. package/src/components/select/Select.tsx +1 -1
  149. package/src/components/select/SelectMultiple.stories.tsx +1 -1
  150. package/src/components/select/SelectMultiple.test.tsx +5 -7
  151. package/src/components/select/SelectMultiple.tsx +1 -1
  152. package/src/components/select/WithSelectContext.tsx +1 -1
  153. package/src/components/select/constants.ts +1 -1
  154. package/src/components/side-navigation/SideNavigation.test.tsx +0 -2
  155. package/src/components/side-navigation/SideNavigation.tsx +1 -1
  156. package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -4
  157. package/src/components/side-navigation/SideNavigationItem.tsx +23 -28
  158. package/src/components/skeleton/SkeletonCircle.test.tsx +0 -2
  159. package/src/components/skeleton/SkeletonCircle.tsx +0 -2
  160. package/src/components/skeleton/SkeletonRectangle.test.tsx +0 -2
  161. package/src/components/skeleton/SkeletonRectangle.tsx +0 -2
  162. package/src/components/skeleton/SkeletonTypography.stories.tsx +0 -2
  163. package/src/components/skeleton/SkeletonTypography.test.tsx +0 -2
  164. package/src/components/skeleton/SkeletonTypography.tsx +1 -1
  165. package/src/components/slider/Slider.test.tsx +1 -3
  166. package/src/components/slider/Slider.tsx +1 -1
  167. package/src/components/slideshow/Slideshow.stories.tsx +0 -1
  168. package/src/components/slideshow/Slideshow.test.tsx +0 -2
  169. package/src/components/slideshow/SlideshowControls.stories.tsx +0 -2
  170. package/src/components/slideshow/SlideshowItem.tsx +0 -2
  171. package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
  172. package/src/components/switch/Switch.test.tsx +5 -7
  173. package/src/components/switch/Switch.tsx +1 -1
  174. package/src/components/table/Table.test.tsx +0 -2
  175. package/src/components/table/Table.tsx +0 -2
  176. package/src/components/table/TableBody.test.tsx +0 -2
  177. package/src/components/table/TableBody.tsx +0 -2
  178. package/src/components/table/TableCell.test.tsx +1 -3
  179. package/src/components/table/TableCell.tsx +0 -2
  180. package/src/components/table/TableHeader.test.tsx +0 -2
  181. package/src/components/table/TableHeader.tsx +0 -2
  182. package/src/components/table/TableRow.test.tsx +0 -2
  183. package/src/components/table/TableRow.tsx +0 -2
  184. package/src/components/tabs/Tab.test.tsx +0 -2
  185. package/src/components/tabs/Tab.tsx +1 -1
  186. package/src/components/tabs/TabList.test.tsx +0 -2
  187. package/src/components/tabs/TabPanel.test.tsx +0 -2
  188. package/src/components/tabs/TabPanel.tsx +0 -2
  189. package/src/components/tabs/TabProvider.test.tsx +0 -2
  190. package/src/components/tabs/TabProvider.tsx +1 -1
  191. package/src/components/tabs/Tabs.stories.tsx +1 -1
  192. package/src/components/text/Text.stories.tsx +1 -1
  193. package/src/components/text/Text.test.tsx +0 -2
  194. package/src/components/text/Text.tsx +0 -2
  195. package/src/components/text-field/TextField.test.tsx +9 -10
  196. package/src/components/text-field/TextField.tsx +1 -1
  197. package/src/components/thumbnail/Thumbnail.test.tsx +29 -7
  198. package/src/components/thumbnail/Thumbnail.tsx +11 -11
  199. package/src/components/toolbar/Toolbar.tsx +1 -1
  200. package/src/components/tooltip/Tooltip.stories.tsx +2 -1
  201. package/src/components/tooltip/Tooltip.test.tsx +14 -8
  202. package/src/components/uploader/Uploader.test.tsx +2 -4
  203. package/src/components/user-block/UserBlock.stories.tsx +0 -2
  204. package/src/components/user-block/UserBlock.test.tsx +1 -3
  205. package/src/hooks/useId.test.tsx +0 -1
  206. package/src/hooks/useInfiniteScroll.tsx +1 -1
  207. package/src/hooks/usePreviousValue.ts +0 -1
  208. package/src/stories/decorators/withChromaticForceScreenSize.tsx +0 -1
  209. package/src/stories/decorators/withNestedProps.tsx +0 -1
  210. package/src/stories/decorators/withThemedBackground.tsx +0 -2
  211. package/src/stories/decorators/withWrapper.tsx +0 -2
  212. package/src/stories/utils/CustomLink.tsx +0 -1
  213. package/src/testing/utils/ThemeSentinel.tsx +0 -1
  214. package/src/untypped-modules.d.ts +4 -0
  215. package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
  216. package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
  217. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  218. package/src/utils/Portal/Portal.test.tsx +0 -1
  219. package/src/utils/Portal/PortalProvider.stories.jsx +0 -1
  220. package/src/utils/Portal/PortalProvider.test.tsx +1 -2
  221. package/src/utils/date/getYearDisplayName.test.ts +1 -1
  222. package/src/utils/disabled/DisabledStateProvider.stories.tsx +0 -2
  223. package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
  224. package/src/utils/react/OnBeforeUnmount.tsx +1 -1
  225. package/src/utils/react/RawClickable.test.tsx +153 -0
  226. package/src/utils/react/RawClickable.tsx +65 -0
  227. package/src/utils/react/skipRender.tsx +2 -2
  228. package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
  229. package/src/utils/type/HasPolymorphicAs.ts +0 -2
  230. package/src/utils/type/HasRequiredLinkHref.ts +1 -0
  231. package/src/utils/type/index.ts +1 -0
  232. package/utils/index.d.ts +6 -6
  233. package/utils/index.js +1 -1
  234. package/src/utils/react/renderButtonOrLink.tsx +0 -16
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
2
 
4
3
  import { render } from '@testing-library/react';
@@ -1,4 +1,4 @@
1
- import React, { Children, ReactNode } from 'react';
1
+ import { Children, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { DatePickerProps } from '@lumx/react';
4
2
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
5
3
  import { getByClassName } from '@lumx/react/testing/utils/queries';
@@ -9,15 +7,15 @@ import { DatePicker } from '.';
9
7
  import { CLASSNAME } from './constants';
10
8
 
11
9
  const mockedDate = new Date(1487721600000);
12
- Date.now = jest.fn(() => mockedDate.valueOf());
13
- jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
10
+ Date.now = vi.fn(() => mockedDate.valueOf());
11
+ vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
14
12
  getYearDisplayName: () => 'année',
15
13
  }));
16
14
 
17
15
  const setup = (propsOverride: Partial<DatePickerProps> = {}) => {
18
16
  const props: DatePickerProps = {
19
17
  locale: 'fr',
20
- onChange: jest.fn(),
18
+ onChange: vi.fn(),
21
19
  value: mockedDate,
22
20
  nextButtonProps: { label: 'Next month' },
23
21
  previousButtonProps: { label: 'Previous month' },
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import { useState } from 'react';
2
2
 
3
3
  import { addMonthResetDay } from '@lumx/react/utils/date/addMonthResetDay';
4
4
  import { isDateValid } from '@lumx/react/utils/date/isDateValid';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { render, screen, waitFor } from '@testing-library/react';
4
2
  import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
5
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
@@ -10,8 +8,8 @@ import { DatePickerControlled, DatePickerControlledProps } from './DatePickerCon
10
8
  import { CLASSNAME } from './constants';
11
9
 
12
10
  const mockedDate = new Date(1487721600000);
13
- Date.now = jest.fn(() => mockedDate.valueOf());
14
- jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
11
+ Date.now = vi.fn(() => mockedDate.valueOf());
12
+ vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
15
13
  getYearDisplayName: () => 'année',
16
14
  }));
17
15
 
@@ -20,14 +18,14 @@ type SetupProps = Partial<DatePickerControlledProps>;
20
18
  const setup = (propsOverride: SetupProps = {}) => {
21
19
  const props: DatePickerControlledProps = {
22
20
  locale: 'fr',
23
- onChange: jest.fn(),
24
- onNextMonthChange: jest.fn(),
25
- onPrevMonthChange: jest.fn(),
21
+ onChange: vi.fn(),
22
+ onNextMonthChange: vi.fn(),
23
+ onPrevMonthChange: vi.fn(),
26
24
  selectedMonth: mockedDate,
27
25
  value: mockedDate,
28
26
  nextButtonProps: { label: 'Next month' },
29
27
  previousButtonProps: { label: 'Previous month' },
30
- onMonthChange: jest.fn(),
28
+ onMonthChange: vi.fn(),
31
29
  ...propsOverride,
32
30
  };
33
31
  render(<DatePickerControlled {...props} />);
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { render, screen } from '@testing-library/react';
5
3
  import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -10,8 +8,8 @@ import { DatePickerField, DatePickerFieldProps } from './DatePickerField';
10
8
  import { CLASSNAME } from './constants';
11
9
 
12
10
  const mockedDate = new Date(1487721600000);
13
- Date.now = jest.fn(() => mockedDate.valueOf());
14
- jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
11
+ Date.now = vi.fn(() => mockedDate.valueOf());
12
+ vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
15
13
  getYearDisplayName: () => 'année',
16
14
  }));
17
15
 
@@ -19,7 +17,7 @@ const setup = (propsOverride: Partial<DatePickerFieldProps> = {}, { wrapper }: S
19
17
  const props: DatePickerFieldProps = {
20
18
  label: 'DatePickerField',
21
19
  locale: 'fr',
22
- onChange: jest.fn(),
20
+ onChange: vi.fn(),
23
21
  value: mockedDate,
24
22
  nextButtonProps: { label: 'Next month' },
25
23
  previousButtonProps: { label: 'Previous month' },
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { Dialog, DialogProps } from '@lumx/react/components/dialog/Dialog';
4
2
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
5
3
  import { render, screen } from '@testing-library/react';
@@ -51,7 +49,7 @@ describe(`<${Dialog.displayName}>`, () => {
51
49
 
52
50
  describe('Events', () => {
53
51
  it('should trigger `onClose` when pressing `escape` key', async () => {
54
- const onClose = jest.fn();
52
+ const onClose = vi.fn();
55
53
  setup({ isOpen: true, onClose });
56
54
 
57
55
  await userEvent.keyboard('[Escape]');
@@ -59,7 +57,7 @@ describe(`<${Dialog.displayName}>`, () => {
59
57
  });
60
58
 
61
59
  it('should not trigger `onClose` when pressing any other key', async () => {
62
- const onClose = jest.fn();
60
+ const onClose = vi.fn();
63
61
  setup({ isOpen: true, onClose });
64
62
 
65
63
  await userEvent.keyboard('a');
@@ -67,7 +65,7 @@ describe(`<${Dialog.displayName}>`, () => {
67
65
  });
68
66
 
69
67
  it('should not trigger `onClose` when pressing `escape` key with `preventAutoClose` set to `true`', async () => {
70
- const onClose = jest.fn();
68
+ const onClose = vi.fn();
71
69
  setup({ isOpen: true, onClose, preventAutoClose: true });
72
70
 
73
71
  await userEvent.keyboard('[Escape]');
@@ -75,7 +73,7 @@ describe(`<${Dialog.displayName}>`, () => {
75
73
  });
76
74
 
77
75
  it('should not trigger `onClose` when pressing `escape` key with `preventCloseOnEscape` set to `true`', async () => {
78
- const onClose = jest.fn();
76
+ const onClose = vi.fn();
79
77
  setup({ isOpen: true, onClose, preventCloseOnEscape: true });
80
78
 
81
79
  await userEvent.keyboard('[Escape]');
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
 
5
3
  import { Theme } from '@lumx/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { Theme } from '@lumx/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
 
5
3
  import { render } from '@testing-library/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { mdiDragVertical } from '@lumx/icons';
@@ -1,5 +1,5 @@
1
1
  import range from 'lodash/range';
2
- import React, { useRef, useState } from 'react';
2
+ import { useRef, useState } from 'react';
3
3
 
4
4
  import { Button, Dropdown, List, ListItem } from '@lumx/react';
5
5
 
@@ -28,7 +28,7 @@ const setup = (propsOverride: Partial<DropdownProps> = {}) => {
28
28
  describe(`<${Dropdown.displayName}>`, () => {
29
29
  describe('Events', () => {
30
30
  it('should trigger `onClose` when pressing `escape` key', async () => {
31
- const onClose = jest.fn();
31
+ const onClose = vi.fn();
32
32
  setup({
33
33
  closeOnEscape: true,
34
34
  onClose,
@@ -40,7 +40,7 @@ describe(`<${Dropdown.displayName}>`, () => {
40
40
  });
41
41
 
42
42
  it('should not trigger `onClose` when pressing any other key', async () => {
43
- const onClose = jest.fn();
43
+ const onClose = vi.fn();
44
44
  setup({ isOpen: true, onClose, closeOnEscape: true });
45
45
 
46
46
  await userEvent.keyboard('a');
@@ -48,7 +48,7 @@ describe(`<${Dropdown.displayName}>`, () => {
48
48
  });
49
49
 
50
50
  it('should not trigger `onClose` when pressing `escape` key with `closeOnEscape` set to `false`', async () => {
51
- const onClose = jest.fn();
51
+ const onClose = vi.fn();
52
52
  setup({ isOpen: true, onClose, closeOnEscape: false });
53
53
 
54
54
  await userEvent.keyboard('[Escape]');
@@ -1,4 +1,4 @@
1
- import React, { cloneElement, useMemo, useRef } from 'react';
1
+ import { cloneElement, useMemo, useRef } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
-
1
+ import { Mock } from 'vitest';
3
2
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
3
  import { queryByRole, render, screen } from '@testing-library/react';
5
4
  import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -11,7 +10,7 @@ import { ExpansionPanel, ExpansionPanelProps } from '.';
11
10
 
12
11
  const CLASSNAME = ExpansionPanel.className as string;
13
12
 
14
- jest.mock('@lumx/react/utils/browser/isFocusVisible');
13
+ vi.mock('@lumx/react/utils/browser/isFocusVisible');
15
14
 
16
15
  const mockChildrenContent = 'children content';
17
16
 
@@ -55,7 +54,7 @@ const setup = (
55
54
  };
56
55
 
57
56
  describe(`<${ExpansionPanel.displayName}>`, () => {
58
- (isFocusVisible as jest.Mock).mockReturnValue(false);
57
+ (isFocusVisible as Mock).mockReturnValue(false);
59
58
 
60
59
  describe('Render', () => {
61
60
  it('should render default', () => {
@@ -100,9 +99,9 @@ describe(`<${ExpansionPanel.displayName}>`, () => {
100
99
  });
101
100
 
102
101
  describe('Events', () => {
103
- const onOpen = jest.fn();
104
- const onClose = jest.fn();
105
- const onToggleOpen = jest.fn();
102
+ const onOpen = vi.fn();
103
+ const onClose = vi.fn();
104
+ const onToggleOpen = vi.fn();
106
105
 
107
106
  beforeEach(onOpen.mockClear);
108
107
  beforeEach(onClose.mockClear);
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { ColorPalette, Theme } from '@lumx/react';
4
2
  import { mdiAbTesting } from '@lumx/icons';
5
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { ColorPalette, Icon, Size, Theme, Text } from '@lumx/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { Alignment, Button, IconButton, Orientation, Size, Text } from '@lumx/react';
4
2
 
5
3
  import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
2
 
4
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import castArray from 'lodash/castArray';
@@ -1,4 +1,4 @@
1
- import React, { createRef } from 'react';
1
+ import { createRef } from 'react';
2
2
 
3
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
4
  import { render } from '@testing-library/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { Alignment, Orientation, Size } from '@lumx/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { Alignment } from '@lumx/react';
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable react/display-name */
2
- import React from 'react';
3
2
  import range from 'lodash/range';
4
3
 
5
4
  import { GridColumn, GridColumnProps } from '@lumx/react/components/grid-column/GridColumn';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
2
  import { render } from '@testing-library/react';
5
3
  import { getByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import React, { ReactElement, ReactNode } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import isInteger from 'lodash/isInteger';
4
4
  import classNames from 'classnames';
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { headingElementArgType, HEADING_ELEMENTS } from '@lumx/react/stories/controls/element';
3
2
  import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
4
3
  import { ALL_TYPOGRAPHY } from '@lumx/react/stories/controls/typography';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { render, screen } from '@testing-library/react';
4
2
 
5
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { HeadingElement } from '@lumx/react/utils/type';
@@ -1,5 +1,5 @@
1
1
  import { HeadingElement } from '@lumx/react/utils/type';
2
- import React, { ReactNode } from 'react';
2
+ import { ReactNode } from 'react';
3
3
  import { MAX_HEADING_LEVEL } from './constants';
4
4
  import { HeadingLevelContext } from './context';
5
5
  import { useHeadingLevel } from './useHeadingLevel';
@@ -1,21 +1,47 @@
1
- import DefaultStory, { SizeAndShape as DefaultSizeAndShape } from '@lumx/core/js/components/Icon/Stories';
2
1
  import { mdiEmail } from '@lumx/icons';
3
- import { ColorPalette, ColorVariant, GridColumn, Icon, Size } from '@lumx/react';
2
+ import { ColorPalette, ColorVariant, GridColumn, Icon, IconSizes, Size } from '@lumx/react';
4
3
  import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
5
4
  import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
5
+ import { iconArgType } from '@lumx/react/stories/controls/icons';
6
+ import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
6
7
  import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
7
8
 
9
+ const iconSizes: Array<IconSizes> = [Size.xxs, Size.xs, Size.s, Size.m, Size.l, Size.xl, Size.xxl];
10
+
8
11
  export default {
9
12
  title: 'LumX components/icon/Icon',
10
13
  component: Icon,
11
- ...DefaultStory,
14
+ args: Icon.defaultProps,
15
+ argTypes: {
16
+ icon: iconArgType,
17
+ hasShape: { control: 'boolean' },
18
+ color: colorArgType,
19
+ colorVariant: colorVariantArgType,
20
+ },
12
21
  };
13
22
 
14
23
  /**
15
24
  * All combinations of size and shape
16
25
  */
17
26
  export const SizeAndShape = {
18
- ...DefaultSizeAndShape,
27
+ args: {
28
+ icon: mdiEmail,
29
+ },
30
+ argTypes: {
31
+ hasShape: { control: false },
32
+ size: { control: false },
33
+ },
34
+ decorators: [
35
+ withCombinations({
36
+ combinations: {
37
+ cols: { key: 'size', options: withUndefined(iconSizes) },
38
+ rows: {
39
+ Default: {},
40
+ 'Has shape': { hasShape: true },
41
+ },
42
+ },
43
+ }),
44
+ ],
19
45
  };
20
46
 
21
47
  /**
@@ -1,10 +1,9 @@
1
- import React from 'react';
2
-
1
+ import { mdiAlertCircle } from '@lumx/icons';
2
+ import { ColorPalette, ColorVariant, Size, Theme } from '@lumx/react';
3
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
 
5
5
  import { getByClassName, getByTagName } from '@lumx/react/testing/utils/queries';
6
6
  import { render } from '@testing-library/react';
7
- import Tests from '@lumx/core/js/components/Icon/Tests';
8
7
  import { Icon, IconProps } from './Icon';
9
8
 
10
9
  const CLASSNAME = Icon.className as string;
@@ -28,7 +27,89 @@ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions =
28
27
  };
29
28
 
30
29
  describe(`<${Icon.displayName}>`, () => {
31
- Tests((props: IconProps, { wrapper }: any) => render(<Icon {...props} />, { wrapper }));
30
+ describe('Props', () => {
31
+ it('should render default', () => {
32
+ const { i, svg, path, props } = setup();
33
+
34
+ expect(i).toBeInTheDocument();
35
+ expect(i).toHaveClass(CLASSNAME);
36
+ expect(i?.className).toMatchInlineSnapshot('"lumx-icon lumx-icon--no-shape lumx-icon--path"');
37
+
38
+ expect(svg).toBeInTheDocument();
39
+ expect(svg).toHaveAttribute('aria-hidden', 'true');
40
+ expect(svg).not.toHaveAttribute('role');
41
+
42
+ expect(path).toBeInTheDocument();
43
+ expect(path).toHaveAttribute('d', props.icon);
44
+ });
45
+
46
+ it('should adapt svg with alternate text', () => {
47
+ const { svg, props } = setup({ alt: 'Alternate text' });
48
+ expect(svg).toHaveAttribute('aria-label', props.alt);
49
+ expect(svg).not.toHaveAttribute('aria-hidden');
50
+ expect(svg).toHaveAttribute('role');
51
+ });
52
+
53
+ describe('size', () => {
54
+ it('should render size', () => {
55
+ const { i } = setup({ size: Size.s });
56
+ expect(i).toHaveClass('lumx-icon--size-s');
57
+ });
58
+
59
+ it('should adapt xxs size with hasShape', () => {
60
+ const { i } = setup({ hasShape: true, size: Size.xxs });
61
+ expect(i).toHaveClass('lumx-icon--size-s');
62
+ });
63
+
64
+ it('should adapt xs size with hasShape', () => {
65
+ const { i } = setup({ hasShape: true, size: Size.xs });
66
+ expect(i).toHaveClass('lumx-icon--size-s');
67
+ });
68
+
69
+ it('should adapt xxl size with hasShape', () => {
70
+ const { i } = setup({ hasShape: true, size: Size.xxl });
71
+ expect(i).toHaveClass('lumx-icon--size-xl');
72
+ });
73
+
74
+ it('should add default size with hasShape', () => {
75
+ const { i } = setup({ hasShape: true });
76
+ expect(i).toHaveClass('lumx-icon--size-m');
77
+ });
78
+ });
79
+
80
+ describe('color', () => {
81
+ it('should render color and color variant', () => {
82
+ const { i } = setup({
83
+ color: ColorPalette.primary,
84
+ colorVariant: ColorVariant.D1,
85
+ });
86
+ expect(i).toHaveClass('lumx-icon--color-primary lumx-icon--color-variant-D1');
87
+ });
88
+
89
+ it('should improve yellow icon color contrast with alert circle icon', () => {
90
+ const { i } = setup({
91
+ color: ColorPalette.yellow,
92
+ icon: mdiAlertCircle,
93
+ });
94
+ expect(i).toHaveClass('lumx-icon--color-yellow lumx-icon--has-dark-layer');
95
+ });
96
+
97
+ it('should set a default color on dark theme', () => {
98
+ const { i } = setup({ theme: Theme.dark });
99
+ expect(i).toHaveClass('lumx-icon--color-light lumx-icon--theme-dark');
100
+ });
101
+
102
+ it('should set a default color on has shape', () => {
103
+ const { i } = setup({ hasShape: true });
104
+ expect(i).toHaveClass('lumx-icon--color-dark lumx-icon--has-shape');
105
+ });
106
+
107
+ it('should set a default color variant on has shape & dark color', () => {
108
+ const { i } = setup({ color: ColorPalette.dark, hasShape: true });
109
+ expect(i).toHaveClass('lumx-icon--color-variant-L2 lumx-icon--color-dark lumx-icon--has-shape');
110
+ });
111
+ });
112
+ });
32
113
 
33
114
  // Common tests suite.
34
115
  commonTestsSuiteRTL(setup, {