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

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,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { getByClassName } from '@lumx/react/testing/utils/queries';
2
4
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
5
  import { render, screen, within } from '@testing-library/react';
@@ -40,7 +42,7 @@ describe(`<${TableCell.displayName}>`, () => {
40
42
 
41
43
  it('should render header variant clickable', async () => {
42
44
  const content = 'Content';
43
- const onHeaderClick = vi.fn();
45
+ const onHeaderClick = jest.fn();
44
46
  const { tableCell } = setup({ children: content, variant: 'head', onHeaderClick });
45
47
 
46
48
  const headerButton = within(tableCell).getByRole('button', { name: content });
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
4
 
3
5
  import { mdiArrowDown, mdiArrowUp } from '@lumx/icons';
@@ -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 { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
4
 
3
5
  import { GenericProps } from '@lumx/react/utils/type';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
2
4
 
3
5
  import { render, screen } 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 { GenericProps } from '@lumx/react/utils/type';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
2
4
  import { render, screen } from '@testing-library/react';
3
5
  import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import { FocusEventHandler, KeyboardEventHandler, ReactNode, useCallback } from 'react';
1
+ import React, { FocusEventHandler, KeyboardEventHandler, ReactNode, useCallback } 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 { Tab } from '@lumx/react';
2
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
5
  import { render, screen } from '@testing-library/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
2
4
  import { getByClassName } from '@lumx/react/testing/utils/queries';
3
5
  import { render, screen } 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 { forwardRef } from '@lumx/react/utils/react/forwardRef';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Tab, TabList, TabPanel, TabProvider, TabProviderProps } from '@lumx/react';
2
4
  import { render } from '@testing-library/react';
3
5
  import userEvent from '@testing-library/user-event';
@@ -1,5 +1,5 @@
1
1
  import ReactDOM from 'react-dom';
2
- import { ReactNode, useEffect, useReducer } from 'react';
2
+ import React, { ReactNode, useEffect, useReducer } from 'react';
3
3
  import { INIT_STATE, TabProviderContext, reducer } from './state';
4
4
 
5
5
  export interface TabProviderProps {
@@ -8,7 +8,7 @@ import { toFlattenProps } from '@lumx/react/stories/utils/toFlattenProps';
8
8
  import { withCategory } from '@lumx/react/stories/utils/withCategory';
9
9
  import get from 'lodash/get';
10
10
  import times from 'lodash/times';
11
- import { useState } from 'react';
11
+ import React, { useState } from 'react';
12
12
 
13
13
  export default {
14
14
  title: 'LumX components/tabs',
@@ -1,6 +1,6 @@
1
+ import { ALL_TYPOGRAPHY, allTypographyArgType } from '@lumx/react/stories/controls/typography';
1
2
  import React from 'react';
2
3
 
3
- import { ALL_TYPOGRAPHY, allTypographyArgType } from '@lumx/react/stories/controls/typography';
4
4
  import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
5
5
  import { textElementArgType } from '@lumx/react/stories/controls/element';
6
6
  import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
2
4
  import { mdiEarth } from '@lumx/icons';
3
5
  import { Icon } from '@lumx/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
4
 
3
5
  import { ColorWithVariants, ColorVariant, Typography, WhiteSpace } from '@lumx/react';
@@ -1,4 +1,5 @@
1
- import { Mock } from 'vitest';
1
+ import React from 'react';
2
+
2
3
  import camelCase from 'lodash/camelCase';
3
4
 
4
5
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
@@ -19,7 +20,7 @@ import { TextField, TextFieldProps } from './TextField';
19
20
 
20
21
  const CLASSNAME = TextField.className as string;
21
22
 
22
- vi.mock('@lumx/react/utils/browser/isFocusVisible');
23
+ jest.mock('@lumx/react/utils/browser/isFocusVisible');
23
24
 
24
25
  /**
25
26
  * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
@@ -48,7 +49,7 @@ const setup = (propsOverride: Partial<TextFieldProps> = {}, { wrapper }: SetupRe
48
49
  };
49
50
 
50
51
  describe(`<${TextField.displayName}>`, () => {
51
- (isFocusVisible as Mock).mockReturnValue(false);
52
+ (isFocusVisible as jest.Mock).mockReturnValue(false);
52
53
 
53
54
  describe('Render', () => {
54
55
  it('should render defaults', () => {
@@ -179,7 +180,7 @@ describe(`<${TextField.displayName}>`, () => {
179
180
 
180
181
  describe('Events', () => {
181
182
  it('should trigger `onChange` when text field is changed', async () => {
182
- const onChange = vi.fn();
183
+ const onChange = jest.fn();
183
184
  const { inputNative } = setup({ value: '', name: 'name', onChange });
184
185
 
185
186
  await userEvent.tab();
@@ -191,7 +192,7 @@ describe(`<${TextField.displayName}>`, () => {
191
192
  });
192
193
 
193
194
  it('should trigger `onChange` with empty value when text field is cleared', async () => {
194
- const onChange = vi.fn();
195
+ const onChange = jest.fn();
195
196
  const { clearButton } = setup({
196
197
  value: 'initial value',
197
198
  name: 'name',
@@ -207,8 +208,8 @@ describe(`<${TextField.displayName}>`, () => {
207
208
  });
208
209
 
209
210
  it('should trigger `onChange` with empty value and `onClear` when text field is cleared', async () => {
210
- const onChange = vi.fn();
211
- const onClear = vi.fn();
211
+ const onChange = jest.fn();
212
+ const onClear = jest.fn();
212
213
  const { clearButton } = setup({
213
214
  value: 'initial value',
214
215
  name: 'name',
@@ -228,7 +229,7 @@ describe(`<${TextField.displayName}>`, () => {
228
229
 
229
230
  describe('Disabled state', () => {
230
231
  it('should render with "isDisabled"', async () => {
231
- const onChange = vi.fn();
232
+ const onChange = jest.fn();
232
233
  const { element, inputNative } = setup({
233
234
  label: 'Label',
234
235
  isDisabled: true,
@@ -254,7 +255,7 @@ describe(`<${TextField.displayName}>`, () => {
254
255
  });
255
256
 
256
257
  it('should render with "aria-disabled"', async () => {
257
- const onChange = vi.fn();
258
+ const onChange = jest.fn();
258
259
  const { element, inputNative } = setup({
259
260
  label: 'Label',
260
261
  'aria-disabled': true,
@@ -1,4 +1,4 @@
1
- import { ReactNode, Ref, RefObject, SyntheticEvent, useEffect, useRef, useState } from 'react';
1
+ import React, { ReactNode, Ref, RefObject, SyntheticEvent, useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import get from 'lodash/get';
@@ -1,7 +1,9 @@
1
+ import React from 'react';
2
+
1
3
  import { DisabledStateProvider } from '@lumx/react/utils';
2
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
5
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
4
- import { fireEvent, render, screen } from '@testing-library/react';
6
+ import { fireEvent, render } from '@testing-library/react';
5
7
  import { Thumbnail, ThumbnailProps } from './Thumbnail';
6
8
 
7
9
  const CLASSNAME = Thumbnail.className as string;
@@ -26,20 +28,9 @@ describe(`<${Thumbnail.displayName}>`, () => {
26
28
  },
27
29
  });
28
30
 
29
- describe('clickable button', () => {
30
- it('should render clickable button', async () => {
31
- const onClick = vi.fn();
32
- const { thumbnail } = setup({ onClick, alt: 'Name' });
33
- const button = screen.getByRole('button', { name: 'Name' });
34
- expect(button).toBe(thumbnail);
35
- expect(button).toHaveAttribute('type', 'button');
36
-
37
- fireEvent.click(thumbnail as HTMLElement);
38
- expect(onClick).toHaveBeenCalled();
39
- });
40
-
41
- it('should not render button in disabled context', () => {
42
- const onClick = vi.fn();
31
+ describe('disabled state', () => {
32
+ it('should not be clickable when disabled from context', () => {
33
+ const onClick = jest.fn();
43
34
  const { thumbnail, container } = setup(
44
35
  { onClick, 'aria-label': 'thumbnail' },
45
36
  {
@@ -56,21 +47,8 @@ describe(`<${Thumbnail.displayName}>`, () => {
56
47
  fireEvent.click(thumbnail as HTMLElement);
57
48
  expect(onClick).not.toHaveBeenCalled();
58
49
  });
59
- });
60
-
61
- describe('clickable link', () => {
62
- it('should render clickable link', async () => {
63
- const onClick = vi.fn((evt: any) => evt.preventDefault());
64
- const { thumbnail } = setup({ linkProps: { href: '#' }, onClick, alt: 'Name' });
65
- const link = screen.getByRole('link');
66
- expect(link).toBe(thumbnail);
67
- expect(link).toHaveAttribute('href', '#');
68
-
69
- fireEvent.click(thumbnail as HTMLElement);
70
- expect(onClick).toHaveBeenCalled();
71
- });
72
50
 
73
- it('should not render link in disabled context', () => {
51
+ it('should have no href when disabled from context', () => {
74
52
  const { container, thumbnail } = setup(
75
53
  { linkAs: 'a', linkProps: { href: '#' }, 'aria-label': 'thumbnail' },
76
54
  {
@@ -22,7 +22,6 @@ import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
22
22
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
23
23
 
24
24
  import { useDisableStateProps } from '@lumx/react/utils/disabled';
25
- import { RawClickable } from '@lumx/react/utils/react/RawClickable';
26
25
  import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
27
26
 
28
27
  type ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;
@@ -101,7 +100,7 @@ const DEFAULT_PROPS: Partial<ThumbnailProps> = {
101
100
  * @return React element.
102
101
  */
103
102
  export const Thumbnail = forwardRef<ThumbnailProps>((props, ref) => {
104
- const { isAnyDisabled, otherProps, disabledStateProps } = useDisableStateProps(props);
103
+ const { isAnyDisabled, otherProps } = useDisableStateProps(props);
105
104
  const defaultTheme = useTheme() || Theme.light;
106
105
  const {
107
106
  align,
@@ -152,17 +151,18 @@ export const Thumbnail = forwardRef<ThumbnailProps>((props, ref) => {
152
151
  }
153
152
 
154
153
  const isLink = Boolean(linkProps?.href || linkAs);
155
- const isClickable = !isAnyDisabled && Boolean(isLink || !!forwardedProps.onClick);
154
+ const isButton = !!forwardedProps.onClick;
155
+ const isClickable = !isAnyDisabled && (isButton || isLink);
156
156
 
157
- const Wrapper: any = isClickable ? RawClickable : 'div';
157
+ let Wrapper: any = 'div';
158
158
  const wrapperProps = { ...forwardedProps };
159
- if (isClickable) {
160
- Object.assign(wrapperProps, { as: linkAs || (linkProps?.href ? 'a' : 'button') }, disabledStateProps);
161
- if (isLink) {
162
- Object.assign(wrapperProps, linkProps);
163
- } else {
164
- wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
165
- }
159
+ if (!isAnyDisabled && isLink) {
160
+ Wrapper = linkAs || 'a';
161
+ Object.assign(wrapperProps, linkProps);
162
+ } else if (!isAnyDisabled && isButton) {
163
+ Wrapper = 'button';
164
+ wrapperProps.type = forwardedProps.type || 'button';
165
+ wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
166
166
  }
167
167
 
168
168
  // If we have a loading placeholder image that is really loaded (complete)
@@ -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,6 +1,5 @@
1
- import React, { useState } from 'react';
2
-
3
1
  import { Button, Dialog, Dropdown, Placement, Tooltip } from '@lumx/react';
2
+ import React, { useState } from 'react';
4
3
  import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
5
4
  import { withChromaticForceScreenSize } from '@lumx/react/stories/decorators/withChromaticForceScreenSize';
6
5
  import { ARIA_LINK_MODES } from '@lumx/react/components/tooltip/constants';
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
 
3
- import { MockInstance } from 'vitest';
4
3
  import { Button } from '@lumx/react';
5
4
  import { screen, render } from '@testing-library/react';
6
5
  import { queryAllByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -13,18 +12,13 @@ import { Tooltip, TooltipProps } from './Tooltip';
13
12
 
14
13
  const CLASSNAME = Tooltip.className as string;
15
14
 
16
- vi.mock('@lumx/react/utils/browser/isFocusVisible');
17
- vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
15
+ jest.mock('@lumx/react/utils/browser/isFocusVisible');
16
+ jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
18
17
  // Skip delays
19
- vi.mock('@lumx/react/constants', async (importActual) => {
20
- const actual = (await importActual()) as Record<string, any>;
21
- return {
22
- ...actual,
23
- TOOLTIP_HOVER_DELAY: { open: 0, close: 0 },
24
- VISUALLY_HIDDEN: actual.VISUALLY_HIDDEN,
25
- CSS_PREFIX: actual.CSS_PREFIX,
26
- };
27
- });
18
+ jest.mock('@lumx/react/constants', () => ({
19
+ ...jest.requireActual('@lumx/react/constants'),
20
+ TOOLTIP_HOVER_DELAY: { open: 0, close: 0 },
21
+ }));
28
22
 
29
23
  /**
30
24
  * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
@@ -352,7 +346,7 @@ describe(`<${Tooltip.displayName}>`, () => {
352
346
  });
353
347
 
354
348
  it('should activate on anchor focus visible and close on escape', async () => {
355
- (isFocusVisible as unknown as MockInstance).mockReturnValue(true);
349
+ (isFocusVisible as jest.Mock).mockReturnValue(true);
356
350
  let { tooltip } = await setup({
357
351
  label: 'Tooltip label',
358
352
  children: <Button>Anchor</Button>,
@@ -387,7 +381,7 @@ describe(`<${Tooltip.displayName}>`, () => {
387
381
  });
388
382
 
389
383
  it('should not activate on anchor focus if not visible', async () => {
390
- (isFocusVisible as unknown as MockInstance).mockReturnValue(false);
384
+ (isFocusVisible as jest.Mock).mockReturnValue(false);
391
385
  let { tooltip } = await setup({
392
386
  label: 'Tooltip label',
393
387
  children: <Button>Anchor</Button>,
@@ -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, screen } from '@testing-library/react';
@@ -87,9 +89,9 @@ describe(`<${Uploader.displayName}>`, () => {
87
89
  ${'button'} | ${{}}
88
90
  ${'button isDisabled '} | ${{ isDisabled: true }}
89
91
  ${'button aria-disabled'} | ${{ 'aria-disabled': true }}
90
- ${'file input '} | ${{ fileInputProps: { onChange: vi.fn() } }}
92
+ ${'file input '} | ${{ fileInputProps: { onChange: jest.fn() } }}
91
93
  `('Events $name', ({ props }) => {
92
- const onClick = vi.fn();
94
+ const onClick = jest.fn();
93
95
  beforeEach(() => onClick.mockClear());
94
96
  const assertClick = () => {
95
97
  if (props.isDisabled || props['aria-disabled']) {
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable jsx-a11y/anchor-is-valid */
2
+ import React from 'react';
3
+
2
4
  import { mdiMenuDown, mdiStar } from '@lumx/icons';
3
5
  import { Badge, ColorPalette, Icon, IconButton, Link, Orientation, Size, Text } from '@lumx/react';
4
6
  import { CustomLink } from '@lumx/react/stories/utils/CustomLink';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
4
  import { render, within, screen } from '@testing-library/react';
3
5
  import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -34,7 +36,7 @@ describe(`<${UserBlock.displayName}>`, () => {
34
36
  });
35
37
 
36
38
  it('should render button', async () => {
37
- const onClick = vi.fn();
39
+ const onClick = jest.fn();
38
40
  const { name, thumbnail } = setup({
39
41
  onClick,
40
42
  name: 'John Doe',
@@ -1,5 +1,6 @@
1
1
  import { useId } from '@lumx/react/hooks/useId';
2
2
  import { render } from '@testing-library/react';
3
+ import React from 'react';
3
4
 
4
5
  function setup() {
5
6
  const Component = (): any => useId();
@@ -1,4 +1,4 @@
1
- import { useEffect } from 'react';
1
+ import React, { useEffect } from 'react';
2
2
 
3
3
  type useInfiniteScrollType = (
4
4
  ref: React.RefObject<HTMLElement>,
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+
2
3
  /**
3
4
  * Returns the value from the previous render.
4
5
  */
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import isChromatic from 'chromatic/isChromatic';
2
3
 
3
4
  /** Story decorator used to force a minimum screen size when running in chromatic */
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import set from 'lodash/set';
2
3
 
3
4
  /**
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  const LIGHT_BACKGROUND_COLOR = '#EEE';
2
4
  const DARK_BACKGROUND_COLOR = '#333';
3
5
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  /**
2
4
  * SB decorator adding a wrapping div around the story
3
5
  */
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+
2
3
  /**
3
4
  * Example custom link that can be used in linkAs props.
4
5
  */
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
2
3
 
3
4
  const TEST_ID = 'theme-sentinel';
@@ -1,7 +1,3 @@
1
- // Extend CSSStyleDeclaration to support viewTransitionName for view transitions
2
- interface CSSStyleDeclaration {
3
- viewTransitionName: string | null;
4
- }
5
1
  /**
6
2
  * List untypped modules here to declare them as explicit any.
7
3
  */
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/rules-of-hooks */
2
2
  /* eslint-disable @typescript-eslint/no-use-before-define */
3
- import { useCallback, useRef, useState } from 'react';
3
+ import React, { useCallback, useRef, useState } from 'react';
4
4
  import { Button } from '@lumx/react';
5
5
  import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
6
6
  import { initDemoShadowDOMPortal } from '@lumx/react/stories/utils/initDemoShadowDOMPortal';
@@ -1,4 +1,4 @@
1
- import { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';
1
+ import React, { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';
2
2
  import { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';
3
3
 
4
4
  interface ContextValue {
@@ -1,4 +1,4 @@
1
- import { useCallback, useState } from 'react';
1
+ import React, { useCallback, useState } from 'react';
2
2
  import { Switch } from '@lumx/react/components/switch';
3
3
  import { Alignment } from '@lumx/react';
4
4
 
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import { Portal } from './Portal';
3
4
 
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { Button } from '@lumx/react';
2
3
  import { initDemoShadowDOMPortal } from '@lumx/react/stories/utils/initDemoShadowDOMPortal';
3
4
  import { PortalProvider } from './PortalProvider';
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { render, screen } from '@testing-library/react';
2
3
  import { PortalInit, PortalProvider } from './PortalProvider';
3
4
  import { Portal } from './Portal';
@@ -29,7 +30,7 @@ describe('PortalProvider', () => {
29
30
  });
30
31
 
31
32
  it('should call teardown on unmount', () => {
32
- const teardownMock = vi.fn();
33
+ const teardownMock = jest.fn();
33
34
  const portalContainer = document.createElement('div');
34
35
  portalContainer.id = PORTAL_CONTAINER_ID;
35
36
  document.body.appendChild(portalContainer);
@@ -4,7 +4,7 @@ describe(getYearDisplayName, () => {
4
4
  beforeEach(() => {
5
5
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
6
  // @ts-ignore
7
- vi.spyOn(Intl, 'DisplayNames').mockImplementation(() => ({
7
+ jest.spyOn(Intl, 'DisplayNames').mockImplementation(() => ({
8
8
  resolvedOptions: () => ({
9
9
  fallback: 'code',
10
10
  locale: 'fr',
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import {
2
4
  Button,
3
5
  Checkbox,
@@ -59,14 +59,14 @@ describe(useDisableStateProps.name, () => {
59
59
  });
60
60
 
61
61
  it('should forward onClick when not disabled', () => {
62
- const onClick = vi.fn();
62
+ const onClick = jest.fn();
63
63
  const { element } = setup({ onClick });
64
64
  fireEvent.click(element);
65
65
  expect(onClick).toHaveBeenCalled();
66
66
  });
67
67
 
68
68
  it('should not forward onClick when disabled', () => {
69
- const onClick = vi.fn();
69
+ const onClick = jest.fn();
70
70
  const { element } = setup({ disabled: true, onClick });
71
71
  fireEvent.click(element);
72
72
  expect(onClick).not.toHaveBeenCalled();
@@ -1,4 +1,4 @@
1
- import { useLayoutEffect } from 'react';
1
+ import React, { useLayoutEffect } from 'react';
2
2
 
3
3
  /**
4
4
  * Helper component using useLayoutEffect to trigger a callback on before unmount.
@@ -0,0 +1,16 @@
1
+ import React, { ReactElement, ReactNode } from 'react';
2
+ import { renderLink } from './renderLink';
3
+
4
+ interface Props {
5
+ linkAs?: any;
6
+ href?: any;
7
+ }
8
+
9
+ /**
10
+ * Render <button> HTML component, fallbacks to `<a>` when a `href` is provided or a custom component with `linkAs`.
11
+ */
12
+ export const renderButtonOrLink = <P extends Props>(props: P, ...children: ReactNode[]): ReactElement => {
13
+ const { linkAs, href, ...forwardedProps } = props;
14
+ if (linkAs || href) return renderLink(props, ...children);
15
+ return React.createElement('button', { type: 'button', ...forwardedProps }, ...children);
16
+ };
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
-
3
1
  import { DOCUMENT } from '@lumx/react/constants';
4
2
  import type { Comp } from '@lumx/react/utils/type';
3
+ import React from 'react';
4
+
5
5
  /**
6
6
  * HOC component wrapping a component to skip render if predicate return falsy
7
7
  */
@@ -1,4 +1,4 @@
1
- import { Fragment } from 'react';
1
+ import React, { Fragment } from 'react';
2
2
 
3
3
  import { Icon } from '@lumx/react';
4
4
  import { mdiEarth, mdiFoodApple, mdiPencil } from '@lumx/icons';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  export type HasPolymorphicAs<E extends React.ElementType> = React.ComponentPropsWithoutRef<E> & {
2
4
  /**
3
5
  * Customize the rendered component.