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

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