@lumx/react 3.20.1-alpha.5 → 3.20.1-alpha.6

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 (230) hide show
  1. package/_internal/index.js.map +1 -1
  2. package/index.d.ts +35 -34
  3. package/index.js +778 -651
  4. package/index.js.map +1 -1
  5. package/package.json +13 -12
  6. package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
  7. package/src/components/alert-dialog/AlertDialog.test.tsx +3 -4
  8. package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
  9. package/src/components/autocomplete/Autocomplete.test.tsx +3 -5
  10. package/src/components/autocomplete/Autocomplete.tsx +1 -1
  11. package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
  12. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +0 -2
  13. package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
  14. package/src/components/avatar/Avatar.stories.tsx +0 -2
  15. package/src/components/avatar/Avatar.test.tsx +0 -2
  16. package/src/components/avatar/Avatar.tsx +1 -1
  17. package/src/components/badge/Badge.stories.tsx +0 -1
  18. package/src/components/badge/Badge.test.tsx +0 -2
  19. package/src/components/badge/Badge.tsx +1 -1
  20. package/src/components/badge/BadgeWrapper.stories.tsx +0 -1
  21. package/src/components/badge/BadgeWrapper.test.tsx +0 -2
  22. package/src/components/badge/BadgeWrapper.tsx +1 -1
  23. package/src/components/button/Button.stories.tsx +0 -1
  24. package/src/components/button/Button.test.tsx +9 -11
  25. package/src/components/button/Button.tsx +0 -2
  26. package/src/components/button/ButtonGroup.stories.tsx +0 -2
  27. package/src/components/button/ButtonGroup.test.tsx +0 -2
  28. package/src/components/button/ButtonGroup.tsx +0 -2
  29. package/src/components/button/ButtonRoot.tsx +7 -37
  30. package/src/components/button/IconButton.test.tsx +0 -2
  31. package/src/components/button/IconButton.tsx +0 -2
  32. package/src/components/checkbox/Checkbox.test.tsx +3 -5
  33. package/src/components/chip/Chip.stories.tsx +0 -2
  34. package/src/components/chip/Chip.test.tsx +19 -19
  35. package/src/components/chip/Chip.tsx +1 -1
  36. package/src/components/chip/ChipGroup.stories.tsx +0 -2
  37. package/src/components/chip/ChipGroup.test.tsx +0 -2
  38. package/src/components/chip/ChipGroup.tsx +1 -1
  39. package/src/components/comment-block/CommentBlock.stories.tsx +0 -1
  40. package/src/components/comment-block/CommentBlock.test.tsx +0 -1
  41. package/src/components/comment-block/CommentBlock.tsx +1 -1
  42. package/src/components/date-picker/DatePicker.test.tsx +3 -5
  43. package/src/components/date-picker/DatePicker.tsx +1 -1
  44. package/src/components/date-picker/DatePickerControlled.test.tsx +6 -8
  45. package/src/components/date-picker/DatePickerField.test.tsx +3 -5
  46. package/src/components/dialog/Dialog.test.tsx +4 -6
  47. package/src/components/divider/Divider.test.tsx +0 -2
  48. package/src/components/divider/Divider.tsx +0 -2
  49. package/src/components/drag-handle/DragHandle.test.tsx +0 -2
  50. package/src/components/drag-handle/DragHandle.tsx +0 -2
  51. package/src/components/dropdown/Dropdown.stories.tsx +1 -1
  52. package/src/components/dropdown/Dropdown.test.tsx +3 -3
  53. package/src/components/dropdown/Dropdown.tsx +1 -1
  54. package/src/components/expansion-panel/ExpansionPanel.test.tsx +6 -7
  55. package/src/components/flag/Flag.test.tsx +0 -2
  56. package/src/components/flag/Flag.tsx +0 -2
  57. package/src/components/flex-box/FlexBox.stories.tsx +0 -2
  58. package/src/components/flex-box/FlexBox.test.tsx +0 -1
  59. package/src/components/flex-box/FlexBox.tsx +1 -1
  60. package/src/components/generic-block/GenericBlock.test.tsx +1 -1
  61. package/src/components/grid/Grid.tsx +0 -2
  62. package/src/components/grid/GridItem.tsx +0 -2
  63. package/src/components/grid-column/GridColumn.stories.tsx +0 -1
  64. package/src/components/grid-column/GridColumn.test.jsx +0 -2
  65. package/src/components/grid-column/GridColumn.tsx +1 -1
  66. package/src/components/heading/Heading.stories.tsx +0 -1
  67. package/src/components/heading/Heading.test.tsx +0 -2
  68. package/src/components/heading/Heading.tsx +0 -2
  69. package/src/components/heading/HeadingLevelProvider.tsx +1 -1
  70. package/src/components/icon/Icon.stories.tsx +30 -4
  71. package/src/components/icon/Icon.test.tsx +85 -4
  72. package/src/components/icon/Icon.tsx +0 -2
  73. package/src/components/image-block/ImageBlock.stories.tsx +0 -2
  74. package/src/components/image-block/ImageBlock.test.tsx +0 -1
  75. package/src/components/image-block/ImageBlock.tsx +1 -1
  76. package/src/components/image-block/ImageCaption.tsx +1 -1
  77. package/src/components/image-lightbox/ImageLightbox.stories.tsx +0 -1
  78. package/src/components/image-lightbox/ImageLightbox.test.tsx +11 -9
  79. package/src/components/image-lightbox/types.ts +0 -2
  80. package/src/components/inline-list/InlineList.stories.tsx +0 -1
  81. package/src/components/inline-list/InlineList.test.tsx +0 -2
  82. package/src/components/inline-list/InlineList.tsx +1 -1
  83. package/src/components/input-helper/InputHelper.test.tsx +0 -2
  84. package/src/components/input-helper/InputHelper.tsx +1 -1
  85. package/src/components/input-label/InputLabel.stories.tsx +0 -2
  86. package/src/components/input-label/InputLabel.test.tsx +0 -2
  87. package/src/components/input-label/InputLabel.tsx +1 -1
  88. package/src/components/lightbox/Lightbox.test.tsx +0 -2
  89. package/src/components/lightbox/Lightbox.tsx +1 -1
  90. package/src/components/link/Link.stories.tsx +0 -1
  91. package/src/components/link/Link.test.tsx +13 -13
  92. package/src/components/link/Link.tsx +9 -22
  93. package/src/components/link-preview/LinkPreview.test.tsx +0 -2
  94. package/src/components/link-preview/LinkPreview.tsx +0 -2
  95. package/src/components/list/List.stories.tsx +1 -1
  96. package/src/components/list/List.test.tsx +0 -2
  97. package/src/components/list/List.tsx +1 -1
  98. package/src/components/list/ListDivider.test.tsx +0 -2
  99. package/src/components/list/ListDivider.tsx +0 -2
  100. package/src/components/list/ListItem.test.tsx +5 -7
  101. package/src/components/list/ListItem.tsx +1 -1
  102. package/src/components/list/ListSubheader.test.tsx +0 -2
  103. package/src/components/list/ListSubheader.tsx +1 -1
  104. package/src/components/message/Message.test.tsx +1 -2
  105. package/src/components/message/Message.tsx +1 -1
  106. package/src/components/mosaic/Mosaic.test.tsx +3 -5
  107. package/src/components/mosaic/Mosaic.tsx +1 -1
  108. package/src/components/navigation/Navigation.stories.tsx +0 -2
  109. package/src/components/navigation/Navigation.test.tsx +0 -2
  110. package/src/components/navigation/Navigation.tsx +0 -2
  111. package/src/components/navigation/NavigationItem.test.tsx +0 -2
  112. package/src/components/navigation/NavigationItem.tsx +7 -11
  113. package/src/components/navigation/NavigationSection.test.tsx +0 -2
  114. package/src/components/navigation/NavigationSection.tsx +5 -4
  115. package/src/components/notification/Notification.test.tsx +4 -5
  116. package/src/components/notification/Notification.tsx +1 -1
  117. package/src/components/popover/Popover.test.tsx +0 -2
  118. package/src/components/popover/Popover.tsx +1 -1
  119. package/src/components/popover/usePopoverStyle.tsx +1 -1
  120. package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -2
  121. package/src/components/popover-dialog/PopoverDialog.tsx +0 -2
  122. package/src/components/post-block/PostBlock.test.tsx +0 -2
  123. package/src/components/post-block/PostBlock.tsx +1 -1
  124. package/src/components/progress/Progress.tsx +0 -2
  125. package/src/components/progress/ProgressCircular.stories.tsx +0 -1
  126. package/src/components/progress/ProgressCircular.test.tsx +0 -2
  127. package/src/components/progress/ProgressCircular.tsx +0 -2
  128. package/src/components/progress/ProgressLinear.test.tsx +0 -2
  129. package/src/components/progress/ProgressLinear.tsx +0 -2
  130. package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
  131. package/src/components/progress-tracker/ProgressTracker.test.tsx +0 -2
  132. package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +0 -2
  133. package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
  134. package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +0 -2
  135. package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
  136. package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +0 -2
  137. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +0 -2
  138. package/src/components/radio-button/RadioButton.test.tsx +3 -5
  139. package/src/components/radio-button/RadioButton.tsx +1 -1
  140. package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
  141. package/src/components/radio-button/RadioGroup.test.tsx +0 -2
  142. package/src/components/radio-button/RadioGroup.tsx +1 -1
  143. package/src/components/select/Select.stories.tsx +1 -1
  144. package/src/components/select/Select.test.tsx +8 -9
  145. package/src/components/select/Select.tsx +1 -1
  146. package/src/components/select/SelectMultiple.stories.tsx +1 -1
  147. package/src/components/select/SelectMultiple.test.tsx +5 -7
  148. package/src/components/select/SelectMultiple.tsx +1 -1
  149. package/src/components/select/WithSelectContext.tsx +1 -1
  150. package/src/components/select/constants.ts +1 -1
  151. package/src/components/side-navigation/SideNavigation.test.tsx +0 -2
  152. package/src/components/side-navigation/SideNavigation.tsx +1 -1
  153. package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -4
  154. package/src/components/side-navigation/SideNavigationItem.tsx +23 -28
  155. package/src/components/skeleton/SkeletonCircle.test.tsx +0 -2
  156. package/src/components/skeleton/SkeletonCircle.tsx +0 -2
  157. package/src/components/skeleton/SkeletonRectangle.test.tsx +0 -2
  158. package/src/components/skeleton/SkeletonRectangle.tsx +0 -2
  159. package/src/components/skeleton/SkeletonTypography.stories.tsx +0 -2
  160. package/src/components/skeleton/SkeletonTypography.test.tsx +0 -2
  161. package/src/components/skeleton/SkeletonTypography.tsx +1 -1
  162. package/src/components/slider/Slider.test.tsx +1 -3
  163. package/src/components/slider/Slider.tsx +1 -1
  164. package/src/components/slideshow/Slideshow.stories.tsx +0 -1
  165. package/src/components/slideshow/Slideshow.test.tsx +0 -2
  166. package/src/components/slideshow/SlideshowControls.stories.tsx +0 -2
  167. package/src/components/slideshow/SlideshowItem.tsx +0 -2
  168. package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
  169. package/src/components/switch/Switch.test.tsx +5 -7
  170. package/src/components/switch/Switch.tsx +1 -1
  171. package/src/components/table/Table.test.tsx +0 -2
  172. package/src/components/table/Table.tsx +0 -2
  173. package/src/components/table/TableBody.test.tsx +0 -2
  174. package/src/components/table/TableBody.tsx +0 -2
  175. package/src/components/table/TableCell.test.tsx +1 -3
  176. package/src/components/table/TableCell.tsx +0 -2
  177. package/src/components/table/TableHeader.test.tsx +0 -2
  178. package/src/components/table/TableHeader.tsx +0 -2
  179. package/src/components/table/TableRow.test.tsx +0 -2
  180. package/src/components/table/TableRow.tsx +0 -2
  181. package/src/components/tabs/Tab.test.tsx +0 -2
  182. package/src/components/tabs/Tab.tsx +1 -1
  183. package/src/components/tabs/TabList.test.tsx +0 -2
  184. package/src/components/tabs/TabPanel.test.tsx +0 -2
  185. package/src/components/tabs/TabPanel.tsx +0 -2
  186. package/src/components/tabs/TabProvider.test.tsx +0 -2
  187. package/src/components/tabs/TabProvider.tsx +1 -1
  188. package/src/components/tabs/Tabs.stories.tsx +1 -1
  189. package/src/components/text/Text.stories.tsx +1 -1
  190. package/src/components/text/Text.test.tsx +0 -2
  191. package/src/components/text/Text.tsx +0 -2
  192. package/src/components/text-field/TextField.test.tsx +9 -10
  193. package/src/components/text-field/TextField.tsx +1 -1
  194. package/src/components/thumbnail/Thumbnail.test.tsx +29 -7
  195. package/src/components/thumbnail/Thumbnail.tsx +11 -11
  196. package/src/components/toolbar/Toolbar.tsx +1 -1
  197. package/src/components/tooltip/Tooltip.stories.tsx +2 -1
  198. package/src/components/tooltip/Tooltip.test.tsx +14 -8
  199. package/src/components/uploader/Uploader.test.tsx +2 -4
  200. package/src/components/user-block/UserBlock.stories.tsx +0 -2
  201. package/src/components/user-block/UserBlock.test.tsx +1 -3
  202. package/src/hooks/useId.test.tsx +0 -1
  203. package/src/hooks/useInfiniteScroll.tsx +1 -1
  204. package/src/hooks/usePreviousValue.ts +0 -1
  205. package/src/stories/decorators/withChromaticForceScreenSize.tsx +0 -1
  206. package/src/stories/decorators/withNestedProps.tsx +0 -1
  207. package/src/stories/decorators/withThemedBackground.tsx +0 -2
  208. package/src/stories/decorators/withWrapper.tsx +0 -2
  209. package/src/stories/utils/CustomLink.tsx +0 -1
  210. package/src/testing/utils/ThemeSentinel.tsx +0 -1
  211. package/src/untypped-modules.d.ts +4 -0
  212. package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
  213. package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
  214. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  215. package/src/utils/Portal/Portal.test.tsx +0 -1
  216. package/src/utils/Portal/PortalProvider.stories.jsx +0 -1
  217. package/src/utils/Portal/PortalProvider.test.tsx +1 -2
  218. package/src/utils/date/getYearDisplayName.test.ts +1 -1
  219. package/src/utils/disabled/DisabledStateProvider.stories.tsx +0 -2
  220. package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
  221. package/src/utils/react/OnBeforeUnmount.tsx +1 -1
  222. package/src/utils/react/RawClickable.test.tsx +153 -0
  223. package/src/utils/react/RawClickable.tsx +65 -0
  224. package/src/utils/react/skipRender.tsx +2 -2
  225. package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
  226. package/src/utils/type/HasPolymorphicAs.ts +0 -2
  227. package/src/utils/type/HasRequiredLinkHref.ts +1 -0
  228. package/src/utils/type/index.ts +1 -0
  229. package/utils/index.d.ts +6 -6
  230. 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, {
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { Icon as UI, IconProps, IconSizes } from '@lumx/core/js/components/Icon';
4
2
 
5
3
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import {
4
2
  Alignment,
5
3
  AspectRatio,
@@ -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, { ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,4 +1,4 @@
1
- import React, { CSSProperties, ReactNode } from 'react';
1
+ import { CSSProperties, ReactNode } from 'react';
2
2
 
3
3
  import { FlexBox, HorizontalAlignment, Text, TextProps, useTheme } from '@lumx/react';
4
4
  import { HasPolymorphicAs, HasTheme } from '@lumx/react/utils/type';
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { IMAGES } from '@lumx/react/stories/controls/image';
3
2
  import { Button, Mosaic, ImageLightbox, ImageLightboxProps, Chip, ChipGroup } from '@lumx/react';
4
3
  import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
- import { render, within, screen } from '@testing-library/react';
2
+ import { render, within, screen, waitFor } from '@testing-library/react';
5
3
  import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
6
4
  import userEvent from '@testing-library/user-event';
7
5
  import { useImageSize } from '@lumx/react/hooks/useImageSize';
@@ -18,8 +16,8 @@ import Meta, {
18
16
  WithMosaicTrigger,
19
17
  } from './ImageLightbox.stories';
20
18
 
21
- jest.mock('@lumx/react/hooks/useImageSize');
22
- jest.mock('@lumx/react/hooks/useSizeOnWindowResize');
19
+ vi.mock('@lumx/react/hooks/useImageSize');
20
+ vi.mock('@lumx/react/hooks/useSizeOnWindowResize');
23
21
 
24
22
  const CLASSNAME = ImageLightbox.className as string;
25
23
  const baseProps = Meta.args;
@@ -56,7 +54,7 @@ const queries = {
56
54
  describe(`<${ImageLightbox.displayName}>`, () => {
57
55
  beforeEach(() => {
58
56
  (useImageSize as any).mockReturnValue(null);
59
- (useSizeOnWindowResize as any).mockReturnValue([null, jest.fn()]);
57
+ (useSizeOnWindowResize as any).mockReturnValue([null, vi.fn()]);
60
58
  });
61
59
 
62
60
  describe('render', () => {
@@ -159,7 +157,9 @@ describe(`<${ImageLightbox.displayName}>`, () => {
159
157
 
160
158
  // Close on escape
161
159
  await userEvent.keyboard('{escape}');
162
- expect(imageLightbox).not.toBeInTheDocument();
160
+ await waitFor(() => {
161
+ expect(imageLightbox).not.toBeInTheDocument();
162
+ });
163
163
 
164
164
  // Focus moved back to the trigger button
165
165
  expect(buttonTrigger).toHaveFocus();
@@ -185,7 +185,9 @@ describe(`<${ImageLightbox.displayName}>`, () => {
185
185
 
186
186
  // Close on escape
187
187
  await userEvent.keyboard('{escape}');
188
- expect(imageLightbox).not.toBeInTheDocument();
188
+ await waitFor(() => {
189
+ expect(imageLightbox).not.toBeInTheDocument();
190
+ });
189
191
 
190
192
  // Focus moved back to the trigger button
191
193
  expect(buttonTrigger).toHaveFocus();
@@ -196,7 +198,7 @@ describe(`<${ImageLightbox.displayName}>`, () => {
196
198
  const scrollAreaSize = { width: 600, height: 600 };
197
199
  beforeEach(() => {
198
200
  (useImageSize as any).mockImplementation((_: any, getInitialSize: any) => getInitialSize?.() || null);
199
- (useSizeOnWindowResize as any).mockReturnValue([scrollAreaSize, jest.fn()]);
201
+ (useSizeOnWindowResize as any).mockReturnValue([scrollAreaSize, vi.fn()]);
200
202
  });
201
203
 
202
204
  it('should use the image initial size', () => {
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import type { IconButtonProps, LightboxProps, SlideshowProps, ThumbnailProps } from '@lumx/react';
4
2
  import type { HasClassName } from '@lumx/react/utils/type';
5
3
  import type { ImageCaptionMetadata } from '@lumx/react/components/image-block/ImageCaption';
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { mdiEarth } from '@lumx/icons';
3
2
  import { Icon, Text } from '@lumx/react';
4
3
  import { withResizableBox } from '@lumx/react/stories/decorators/withResizableBox';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
2
  import { render, screen, within } from '@testing-library/react';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';