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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/CONTRIBUTING.md +1 -5
  2. package/README.md +0 -2
  3. package/_internal/index.js +20 -13
  4. package/_internal/index.js.map +1 -1
  5. package/index.d.ts +35 -35
  6. package/index.js +2407 -2447
  7. package/index.js.map +1 -1
  8. package/package.json +10 -13
  9. package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
  10. package/src/components/alert-dialog/AlertDialog.test.tsx +3 -4
  11. package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
  12. package/src/components/autocomplete/Autocomplete.test.tsx +3 -5
  13. package/src/components/autocomplete/Autocomplete.tsx +1 -1
  14. package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
  15. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +0 -2
  16. package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
  17. package/src/components/avatar/Avatar.stories.tsx +0 -2
  18. package/src/components/avatar/Avatar.test.tsx +0 -2
  19. package/src/components/avatar/Avatar.tsx +1 -1
  20. package/src/components/badge/Badge.stories.tsx +0 -1
  21. package/src/components/badge/Badge.test.tsx +0 -2
  22. package/src/components/badge/Badge.tsx +1 -1
  23. package/src/components/badge/BadgeWrapper.stories.tsx +0 -1
  24. package/src/components/badge/BadgeWrapper.test.tsx +0 -2
  25. package/src/components/badge/BadgeWrapper.tsx +1 -1
  26. package/src/components/button/Button.stories.tsx +0 -1
  27. package/src/components/button/Button.test.tsx +9 -11
  28. package/src/components/button/Button.tsx +0 -2
  29. package/src/components/button/ButtonGroup.stories.tsx +0 -2
  30. package/src/components/button/ButtonGroup.test.tsx +0 -2
  31. package/src/components/button/ButtonGroup.tsx +0 -2
  32. package/src/components/button/ButtonRoot.tsx +7 -37
  33. package/src/components/button/IconButton.test.tsx +0 -2
  34. package/src/components/button/IconButton.tsx +0 -2
  35. package/src/components/checkbox/Checkbox.test.tsx +3 -5
  36. package/src/components/chip/Chip.stories.tsx +0 -2
  37. package/src/components/chip/Chip.test.tsx +19 -19
  38. package/src/components/chip/Chip.tsx +1 -1
  39. package/src/components/chip/ChipGroup.stories.tsx +0 -2
  40. package/src/components/chip/ChipGroup.test.tsx +0 -2
  41. package/src/components/chip/ChipGroup.tsx +1 -1
  42. package/src/components/comment-block/CommentBlock.stories.tsx +0 -1
  43. package/src/components/comment-block/CommentBlock.test.tsx +0 -1
  44. package/src/components/comment-block/CommentBlock.tsx +1 -1
  45. package/src/components/date-picker/DatePicker.test.tsx +3 -5
  46. package/src/components/date-picker/DatePicker.tsx +1 -1
  47. package/src/components/date-picker/DatePickerControlled.test.tsx +6 -8
  48. package/src/components/date-picker/DatePickerField.test.tsx +3 -5
  49. package/src/components/dialog/Dialog.test.tsx +4 -6
  50. package/src/components/divider/Divider.test.tsx +0 -2
  51. package/src/components/divider/Divider.tsx +0 -2
  52. package/src/components/drag-handle/DragHandle.test.tsx +0 -2
  53. package/src/components/drag-handle/DragHandle.tsx +0 -2
  54. package/src/components/dropdown/Dropdown.stories.tsx +1 -1
  55. package/src/components/dropdown/Dropdown.test.tsx +3 -3
  56. package/src/components/dropdown/Dropdown.tsx +1 -1
  57. package/src/components/expansion-panel/ExpansionPanel.test.tsx +6 -7
  58. package/src/components/flag/Flag.test.tsx +0 -2
  59. package/src/components/flag/Flag.tsx +0 -2
  60. package/src/components/flex-box/FlexBox.stories.tsx +0 -2
  61. package/src/components/flex-box/FlexBox.test.tsx +0 -1
  62. package/src/components/flex-box/FlexBox.tsx +1 -1
  63. package/src/components/generic-block/GenericBlock.test.tsx +1 -1
  64. package/src/components/grid/Grid.tsx +0 -2
  65. package/src/components/grid/GridItem.tsx +0 -2
  66. package/src/components/grid-column/GridColumn.stories.tsx +0 -1
  67. package/src/components/grid-column/GridColumn.test.jsx +0 -2
  68. package/src/components/grid-column/GridColumn.tsx +1 -1
  69. package/src/components/heading/Heading.stories.tsx +0 -1
  70. package/src/components/heading/Heading.test.tsx +0 -2
  71. package/src/components/heading/Heading.tsx +0 -2
  72. package/src/components/heading/HeadingLevelProvider.tsx +1 -1
  73. package/src/components/icon/Icon.stories.tsx +30 -4
  74. package/src/components/icon/Icon.test.tsx +85 -4
  75. package/src/components/icon/Icon.tsx +118 -9
  76. package/src/components/image-block/ImageBlock.stories.tsx +0 -2
  77. package/src/components/image-block/ImageBlock.test.tsx +0 -1
  78. package/src/components/image-block/ImageBlock.tsx +1 -1
  79. package/src/components/image-block/ImageCaption.tsx +1 -1
  80. package/src/components/image-lightbox/ImageLightbox.stories.tsx +0 -1
  81. package/src/components/image-lightbox/ImageLightbox.test.tsx +11 -9
  82. package/src/components/image-lightbox/types.ts +0 -2
  83. package/src/components/inline-list/InlineList.stories.tsx +0 -1
  84. package/src/components/inline-list/InlineList.test.tsx +0 -2
  85. package/src/components/inline-list/InlineList.tsx +1 -1
  86. package/src/components/input-helper/InputHelper.test.tsx +0 -2
  87. package/src/components/input-helper/InputHelper.tsx +1 -1
  88. package/src/components/input-label/InputLabel.stories.tsx +0 -2
  89. package/src/components/input-label/InputLabel.test.tsx +0 -2
  90. package/src/components/input-label/InputLabel.tsx +1 -1
  91. package/src/components/lightbox/Lightbox.test.tsx +0 -2
  92. package/src/components/lightbox/Lightbox.tsx +1 -1
  93. package/src/components/link/Link.stories.tsx +0 -1
  94. package/src/components/link/Link.test.tsx +13 -13
  95. package/src/components/link/Link.tsx +9 -22
  96. package/src/components/link-preview/LinkPreview.test.tsx +0 -2
  97. package/src/components/link-preview/LinkPreview.tsx +0 -2
  98. package/src/components/list/List.stories.tsx +1 -1
  99. package/src/components/list/List.test.tsx +0 -2
  100. package/src/components/list/List.tsx +1 -1
  101. package/src/components/list/ListDivider.test.tsx +0 -2
  102. package/src/components/list/ListDivider.tsx +0 -2
  103. package/src/components/list/ListItem.test.tsx +5 -7
  104. package/src/components/list/ListItem.tsx +1 -1
  105. package/src/components/list/ListSubheader.test.tsx +0 -2
  106. package/src/components/list/ListSubheader.tsx +1 -1
  107. package/src/components/message/Message.test.tsx +1 -2
  108. package/src/components/message/Message.tsx +1 -1
  109. package/src/components/mosaic/Mosaic.test.tsx +3 -5
  110. package/src/components/mosaic/Mosaic.tsx +1 -1
  111. package/src/components/navigation/Navigation.stories.tsx +0 -2
  112. package/src/components/navigation/Navigation.test.tsx +0 -2
  113. package/src/components/navigation/Navigation.tsx +0 -2
  114. package/src/components/navigation/NavigationItem.test.tsx +0 -2
  115. package/src/components/navigation/NavigationItem.tsx +7 -11
  116. package/src/components/navigation/NavigationSection.test.tsx +0 -2
  117. package/src/components/navigation/NavigationSection.tsx +5 -4
  118. package/src/components/notification/Notification.test.tsx +4 -5
  119. package/src/components/notification/Notification.tsx +1 -1
  120. package/src/components/popover/Popover.test.tsx +0 -2
  121. package/src/components/popover/Popover.tsx +1 -1
  122. package/src/components/popover/usePopoverStyle.tsx +1 -1
  123. package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -2
  124. package/src/components/popover-dialog/PopoverDialog.tsx +0 -2
  125. package/src/components/post-block/PostBlock.test.tsx +0 -2
  126. package/src/components/post-block/PostBlock.tsx +1 -1
  127. package/src/components/progress/Progress.tsx +0 -2
  128. package/src/components/progress/ProgressCircular.stories.tsx +0 -1
  129. package/src/components/progress/ProgressCircular.test.tsx +0 -2
  130. package/src/components/progress/ProgressCircular.tsx +0 -2
  131. package/src/components/progress/ProgressLinear.test.tsx +0 -2
  132. package/src/components/progress/ProgressLinear.tsx +0 -2
  133. package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
  134. package/src/components/progress-tracker/ProgressTracker.test.tsx +0 -2
  135. package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +0 -2
  136. package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
  137. package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +0 -2
  138. package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
  139. package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +0 -2
  140. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +0 -2
  141. package/src/components/radio-button/RadioButton.test.tsx +3 -5
  142. package/src/components/radio-button/RadioButton.tsx +1 -1
  143. package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
  144. package/src/components/radio-button/RadioGroup.test.tsx +0 -2
  145. package/src/components/radio-button/RadioGroup.tsx +1 -1
  146. package/src/components/select/Select.stories.tsx +1 -1
  147. package/src/components/select/Select.test.tsx +8 -9
  148. package/src/components/select/Select.tsx +1 -1
  149. package/src/components/select/SelectMultiple.stories.tsx +1 -1
  150. package/src/components/select/SelectMultiple.test.tsx +5 -7
  151. package/src/components/select/SelectMultiple.tsx +1 -1
  152. package/src/components/select/WithSelectContext.tsx +1 -1
  153. package/src/components/select/constants.ts +1 -1
  154. package/src/components/side-navigation/SideNavigation.test.tsx +0 -2
  155. package/src/components/side-navigation/SideNavigation.tsx +1 -1
  156. package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -4
  157. package/src/components/side-navigation/SideNavigationItem.tsx +23 -28
  158. package/src/components/skeleton/SkeletonCircle.test.tsx +0 -2
  159. package/src/components/skeleton/SkeletonCircle.tsx +0 -2
  160. package/src/components/skeleton/SkeletonRectangle.test.tsx +0 -2
  161. package/src/components/skeleton/SkeletonRectangle.tsx +0 -2
  162. package/src/components/skeleton/SkeletonTypography.stories.tsx +0 -2
  163. package/src/components/skeleton/SkeletonTypography.test.tsx +0 -2
  164. package/src/components/skeleton/SkeletonTypography.tsx +1 -1
  165. package/src/components/slider/Slider.test.tsx +1 -3
  166. package/src/components/slider/Slider.tsx +1 -1
  167. package/src/components/slideshow/Slideshow.stories.tsx +0 -1
  168. package/src/components/slideshow/Slideshow.test.tsx +0 -2
  169. package/src/components/slideshow/SlideshowControls.stories.tsx +0 -2
  170. package/src/components/slideshow/SlideshowItem.tsx +0 -2
  171. package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
  172. package/src/components/switch/Switch.test.tsx +5 -7
  173. package/src/components/switch/Switch.tsx +1 -1
  174. package/src/components/table/Table.test.tsx +0 -2
  175. package/src/components/table/Table.tsx +0 -2
  176. package/src/components/table/TableBody.test.tsx +0 -2
  177. package/src/components/table/TableBody.tsx +0 -2
  178. package/src/components/table/TableCell.test.tsx +1 -3
  179. package/src/components/table/TableCell.tsx +0 -2
  180. package/src/components/table/TableHeader.test.tsx +0 -2
  181. package/src/components/table/TableHeader.tsx +0 -2
  182. package/src/components/table/TableRow.test.tsx +0 -2
  183. package/src/components/table/TableRow.tsx +0 -2
  184. package/src/components/tabs/Tab.test.tsx +0 -2
  185. package/src/components/tabs/Tab.tsx +1 -1
  186. package/src/components/tabs/TabList.test.tsx +0 -2
  187. package/src/components/tabs/TabPanel.test.tsx +0 -2
  188. package/src/components/tabs/TabPanel.tsx +0 -2
  189. package/src/components/tabs/TabProvider.test.tsx +0 -2
  190. package/src/components/tabs/TabProvider.tsx +1 -1
  191. package/src/components/tabs/Tabs.stories.tsx +1 -1
  192. package/src/components/text/Text.stories.tsx +1 -1
  193. package/src/components/text/Text.test.tsx +0 -2
  194. package/src/components/text/Text.tsx +0 -2
  195. package/src/components/text-field/TextField.test.tsx +9 -10
  196. package/src/components/text-field/TextField.tsx +1 -1
  197. package/src/components/thumbnail/Thumbnail.test.tsx +29 -7
  198. package/src/components/thumbnail/Thumbnail.tsx +11 -11
  199. package/src/components/toolbar/Toolbar.tsx +1 -1
  200. package/src/components/tooltip/Tooltip.stories.tsx +2 -1
  201. package/src/components/tooltip/Tooltip.test.tsx +14 -8
  202. package/src/components/uploader/Uploader.test.tsx +2 -4
  203. package/src/components/user-block/UserBlock.stories.tsx +0 -2
  204. package/src/components/user-block/UserBlock.test.tsx +1 -3
  205. package/src/hooks/useId.test.tsx +0 -1
  206. package/src/hooks/useInfiniteScroll.tsx +1 -1
  207. package/src/hooks/usePreviousValue.ts +0 -1
  208. package/src/stories/decorators/withChromaticForceScreenSize.tsx +0 -1
  209. package/src/stories/decorators/withNestedProps.tsx +0 -1
  210. package/src/stories/decorators/withThemedBackground.tsx +0 -2
  211. package/src/stories/decorators/withWrapper.tsx +0 -2
  212. package/src/stories/utils/CustomLink.tsx +0 -1
  213. package/src/testing/utils/ThemeSentinel.tsx +0 -1
  214. package/src/untypped-modules.d.ts +4 -0
  215. package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
  216. package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
  217. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  218. package/src/utils/Portal/Portal.test.tsx +0 -1
  219. package/src/utils/Portal/PortalProvider.stories.jsx +0 -1
  220. package/src/utils/Portal/PortalProvider.test.tsx +1 -2
  221. package/src/utils/date/getYearDisplayName.test.ts +1 -1
  222. package/src/utils/disabled/DisabledStateProvider.stories.tsx +0 -2
  223. package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
  224. package/src/utils/react/OnBeforeUnmount.tsx +1 -1
  225. package/src/utils/react/RawClickable.test.tsx +153 -0
  226. package/src/utils/react/RawClickable.tsx +65 -0
  227. package/src/utils/react/skipRender.tsx +2 -2
  228. package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
  229. package/src/utils/type/HasPolymorphicAs.ts +0 -2
  230. package/src/utils/type/HasRequiredLinkHref.ts +1 -0
  231. package/src/utils/type/index.ts +1 -0
  232. package/utils/index.d.ts +6 -6
  233. package/utils/index.js +1 -1
  234. package/src/utils/react/renderButtonOrLink.tsx +0 -16
@@ -1,4 +1,4 @@
1
- import React, { Children, ReactNode } from 'react';
1
+ import { Children, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import isEmpty from 'lodash/isEmpty';
@@ -7,10 +7,9 @@ import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
7
7
  import { Emphasis, Icon, Size, IconButton, IconButtonProps } from '@lumx/react';
8
8
  import { GenericProps, HasCloseMode, isComponent } from '@lumx/react/utils/type';
9
9
  import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
10
- import { renderLink } from '@lumx/react/utils/react/renderLink';
11
- import { renderButtonOrLink } from '@lumx/react/utils/react/renderButtonOrLink';
12
10
  import { useId } from '@lumx/react/hooks/useId';
13
11
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
12
+ import { RawClickable } from '@lumx/react/utils/react/RawClickable';
14
13
 
15
14
  /**
16
15
  * Defines the props of the component.
@@ -113,17 +112,15 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
113
112
  >
114
113
  {shouldSplitActions ? (
115
114
  <div className={`${CLASSNAME}__wrapper`}>
116
- {renderLink(
117
- {
118
- linkAs,
119
- ...linkProps,
120
- className: `${CLASSNAME}__link`,
121
- onClick,
122
- tabIndex: 0,
123
- },
124
- icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />,
125
- <span>{label}</span>,
126
- )}
115
+ <RawClickable
116
+ as={linkAs || (linkProps?.href ? 'a' : 'button')}
117
+ {...(linkProps as any)}
118
+ className={`${CLASSNAME}__link`}
119
+ onClick={onClick}
120
+ >
121
+ {icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />}
122
+ <span>{label}</span>
123
+ </RawClickable>
127
124
 
128
125
  <IconButton
129
126
  {...toggleButtonProps}
@@ -136,25 +133,23 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
136
133
  />
137
134
  </div>
138
135
  ) : (
139
- renderButtonOrLink(
140
- {
141
- linkAs,
142
- ...linkProps,
143
- className: `${CLASSNAME}__link`,
144
- tabIndex: 0,
145
- onClick,
146
- ...ariaProps,
147
- },
148
- icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />,
149
- <span>{label}</span>,
150
- hasContent && (
136
+ <RawClickable
137
+ as={linkAs || (linkProps?.href ? 'a' : 'button')}
138
+ {...linkProps}
139
+ className={`${CLASSNAME}__link`}
140
+ onClick={onClick}
141
+ {...ariaProps}
142
+ >
143
+ {icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />}
144
+ <span>{label}</span>
145
+ {hasContent && (
151
146
  <Icon
152
147
  className={`${CLASSNAME}__chevron`}
153
148
  icon={isOpen ? mdiChevronUp : mdiChevronDown}
154
149
  size={Size.xs}
155
150
  />
156
- ),
157
- )
151
+ )}
152
+ </RawClickable>
158
153
  )}
159
154
 
160
155
  {(closeMode === 'hide' || showChildren) && (
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { render } from '@testing-library/react';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { GlobalSize, Theme, ColorPalette } 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
  import { render } from '@testing-library/react';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { AspectRatio, GlobalSize, Theme, ColorPalette } from '@lumx/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { SkeletonTypography, Typography, ColorPalette } from '@lumx/react';
4
2
 
5
3
  export default { title: 'LumX components/skeleton/Skeleton Typography' };
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { render } from '@testing-library/react';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import React, { CSSProperties } from 'react';
1
+ import { CSSProperties } 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 { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { render } from '@testing-library/react';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -7,7 +5,7 @@ import { Slider, SliderProps } from './Slider';
7
5
 
8
6
  const CLASSNAME = Slider.className as string;
9
7
 
10
- jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
8
+ vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
11
9
 
12
10
  const setup = (props: Partial<SliderProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
13
11
  render(<Slider {...(props as any)} />, { wrapper });
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable jsx-a11y/no-static-element-interactions */
2
- import React, { SyntheticEvent, useMemo, useRef } from 'react';
2
+ import { SyntheticEvent, useMemo, useRef } from 'react';
3
3
 
4
4
  import classNames from 'classnames';
5
5
 
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import range from 'lodash/range';
3
2
  import { AspectRatio, Button, FlexBox, ImageBlock, Slideshow, SlideshowItem, Orientation } from '@lumx/react';
4
3
  import { IMAGES, LANDSCAPE_IMAGES } from '@lumx/react/stories/controls/image';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { render } from '@testing-library/react';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { AspectRatio, ImageBlock, Slides, SlideshowControls, SlideshowItem } from '@lumx/react';
4
2
  import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
5
3
  import { LANDSCAPE_IMAGES } from '@lumx/react/stories/controls/image';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { GenericProps } from '@lumx/react/utils/type';
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
2
  import { getFocusableElements } from '@lumx/react/utils/browser/focus/getFocusableElements';
3
3
 
4
4
  export interface UseSlideFocusManagementProps {
@@ -1,9 +1,7 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { render } from '@testing-library/react';
5
3
  import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
6
- import userEvent from '@testing-library/user-event/';
4
+ import userEvent from '@testing-library/user-event';
7
5
 
8
6
  import { Switch, SwitchProps } from './Switch';
9
7
 
@@ -24,7 +22,7 @@ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions =
24
22
  return { switchWrapper, input, helper, label, props };
25
23
  };
26
24
 
27
- jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
25
+ vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
28
26
 
29
27
  describe(`<${Switch.displayName}>`, () => {
30
28
  describe('Props', () => {
@@ -86,7 +84,7 @@ describe(`<${Switch.displayName}>`, () => {
86
84
  });
87
85
 
88
86
  describe('Events', () => {
89
- const onChange = jest.fn();
87
+ const onChange = vi.fn();
90
88
 
91
89
  it('should trigger `onChange` when switchWrapper is clicked', async () => {
92
90
  const value = 'value';
@@ -102,7 +100,7 @@ describe(`<${Switch.displayName}>`, () => {
102
100
 
103
101
  describe('Disabled state', () => {
104
102
  it('should be disabled with isDisabled', async () => {
105
- const onChange = jest.fn();
103
+ const onChange = vi.fn();
106
104
  const { switchWrapper, input } = setup({ isDisabled: true, onChange });
107
105
 
108
106
  expect(switchWrapper).toHaveClass('lumx-switch--is-disabled');
@@ -115,7 +113,7 @@ describe(`<${Switch.displayName}>`, () => {
115
113
  });
116
114
 
117
115
  it('should be disabled with aria-disabled', async () => {
118
- const onChange = jest.fn();
116
+ const onChange = vi.fn();
119
117
  const { switchWrapper, input } = setup({ 'aria-disabled': true, onChange });
120
118
 
121
119
  expect(switchWrapper).toHaveClass('lumx-switch--is-disabled');
@@ -1,4 +1,4 @@
1
- import React, { Children, InputHTMLAttributes, SyntheticEvent } from 'react';
1
+ import { Children, InputHTMLAttributes, SyntheticEvent } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import isEmpty from 'lodash/isEmpty';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
2
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
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 { Theme } from '@lumx/react';
@@ -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 { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { GenericProps } from '@lumx/react/utils/type';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { getByClassName } from '@lumx/react/testing/utils/queries';
4
2
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
5
3
  import { render, screen, within } from '@testing-library/react';
@@ -42,7 +40,7 @@ describe(`<${TableCell.displayName}>`, () => {
42
40
 
43
41
  it('should render header variant clickable', async () => {
44
42
  const content = 'Content';
45
- const onHeaderClick = jest.fn();
43
+ const onHeaderClick = vi.fn();
46
44
  const { tableCell } = setup({ children: content, variant: 'head', onHeaderClick });
47
45
 
48
46
  const headerButton = within(tableCell).getByRole('button', { name: content });
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { mdiArrowDown, mdiArrowUp } from '@lumx/icons';
@@ -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 { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { GenericProps } from '@lumx/react/utils/type';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
2
 
5
3
  import { render, screen } 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 { GenericProps } from '@lumx/react/utils/type';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
2
  import { render, screen } from '@testing-library/react';
5
3
  import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import React, { FocusEventHandler, KeyboardEventHandler, ReactNode, useCallback } from 'react';
1
+ import { FocusEventHandler, KeyboardEventHandler, ReactNode, useCallback } 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 { Tab } from '@lumx/react';
4
2
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
5
3
  import { render, screen } from '@testing-library/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
2
  import { getByClassName } from '@lumx/react/testing/utils/queries';
5
3
  import { render, screen } 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 { forwardRef } from '@lumx/react/utils/react/forwardRef';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { Tab, TabList, TabPanel, TabProvider, TabProviderProps } from '@lumx/react';
4
2
  import { render } from '@testing-library/react';
5
3
  import userEvent from '@testing-library/user-event';
@@ -1,5 +1,5 @@
1
1
  import ReactDOM from 'react-dom';
2
- import React, { ReactNode, useEffect, useReducer } from 'react';
2
+ import { 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 React, { useState } from 'react';
11
+ import { 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';
2
1
  import React from 'react';
3
2
 
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,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
4
2
  import { mdiEarth } from '@lumx/icons';
5
3
  import { Icon } from '@lumx/react';
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  import classNames from 'classnames';
4
2
 
5
3
  import { ColorWithVariants, ColorVariant, Typography, WhiteSpace } from '@lumx/react';
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
-
1
+ import { Mock } from 'vitest';
3
2
  import camelCase from 'lodash/camelCase';
4
3
 
5
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
@@ -20,7 +19,7 @@ import { TextField, TextFieldProps } from './TextField';
20
19
 
21
20
  const CLASSNAME = TextField.className as string;
22
21
 
23
- jest.mock('@lumx/react/utils/browser/isFocusVisible');
22
+ vi.mock('@lumx/react/utils/browser/isFocusVisible');
24
23
 
25
24
  /**
26
25
  * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
@@ -49,7 +48,7 @@ const setup = (propsOverride: Partial<TextFieldProps> = {}, { wrapper }: SetupRe
49
48
  };
50
49
 
51
50
  describe(`<${TextField.displayName}>`, () => {
52
- (isFocusVisible as jest.Mock).mockReturnValue(false);
51
+ (isFocusVisible as Mock).mockReturnValue(false);
53
52
 
54
53
  describe('Render', () => {
55
54
  it('should render defaults', () => {
@@ -180,7 +179,7 @@ describe(`<${TextField.displayName}>`, () => {
180
179
 
181
180
  describe('Events', () => {
182
181
  it('should trigger `onChange` when text field is changed', async () => {
183
- const onChange = jest.fn();
182
+ const onChange = vi.fn();
184
183
  const { inputNative } = setup({ value: '', name: 'name', onChange });
185
184
 
186
185
  await userEvent.tab();
@@ -192,7 +191,7 @@ describe(`<${TextField.displayName}>`, () => {
192
191
  });
193
192
 
194
193
  it('should trigger `onChange` with empty value when text field is cleared', async () => {
195
- const onChange = jest.fn();
194
+ const onChange = vi.fn();
196
195
  const { clearButton } = setup({
197
196
  value: 'initial value',
198
197
  name: 'name',
@@ -208,8 +207,8 @@ describe(`<${TextField.displayName}>`, () => {
208
207
  });
209
208
 
210
209
  it('should trigger `onChange` with empty value and `onClear` when text field is cleared', async () => {
211
- const onChange = jest.fn();
212
- const onClear = jest.fn();
210
+ const onChange = vi.fn();
211
+ const onClear = vi.fn();
213
212
  const { clearButton } = setup({
214
213
  value: 'initial value',
215
214
  name: 'name',
@@ -229,7 +228,7 @@ describe(`<${TextField.displayName}>`, () => {
229
228
 
230
229
  describe('Disabled state', () => {
231
230
  it('should render with "isDisabled"', async () => {
232
- const onChange = jest.fn();
231
+ const onChange = vi.fn();
233
232
  const { element, inputNative } = setup({
234
233
  label: 'Label',
235
234
  isDisabled: true,
@@ -255,7 +254,7 @@ describe(`<${TextField.displayName}>`, () => {
255
254
  });
256
255
 
257
256
  it('should render with "aria-disabled"', async () => {
258
- const onChange = jest.fn();
257
+ const onChange = vi.fn();
259
258
  const { element, inputNative } = setup({
260
259
  label: 'Label',
261
260
  'aria-disabled': true,
@@ -1,4 +1,4 @@
1
- import React, { ReactNode, Ref, RefObject, SyntheticEvent, useEffect, useRef, useState } from 'react';
1
+ import { 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,9 +1,7 @@
1
- import React from 'react';
2
-
3
1
  import { DisabledStateProvider } from '@lumx/react/utils';
4
2
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
5
3
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
6
- import { fireEvent, render } from '@testing-library/react';
4
+ import { fireEvent, render, screen } from '@testing-library/react';
7
5
  import { Thumbnail, ThumbnailProps } from './Thumbnail';
8
6
 
9
7
  const CLASSNAME = Thumbnail.className as string;
@@ -28,9 +26,20 @@ describe(`<${Thumbnail.displayName}>`, () => {
28
26
  },
29
27
  });
30
28
 
31
- describe('disabled state', () => {
32
- it('should not be clickable when disabled from context', () => {
33
- const onClick = jest.fn();
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();
34
43
  const { thumbnail, container } = setup(
35
44
  { onClick, 'aria-label': 'thumbnail' },
36
45
  {
@@ -47,8 +56,21 @@ describe(`<${Thumbnail.displayName}>`, () => {
47
56
  fireEvent.click(thumbnail as HTMLElement);
48
57
  expect(onClick).not.toHaveBeenCalled();
49
58
  });
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
+ });
50
72
 
51
- it('should have no href when disabled from context', () => {
73
+ it('should not render link in disabled context', () => {
52
74
  const { container, thumbnail } = setup(
53
75
  { linkAs: 'a', linkProps: { href: '#' }, 'aria-label': 'thumbnail' },
54
76
  {
@@ -22,6 +22,7 @@ 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';
25
26
  import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
26
27
 
27
28
  type ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;
@@ -100,7 +101,7 @@ const DEFAULT_PROPS: Partial<ThumbnailProps> = {
100
101
  * @return React element.
101
102
  */
102
103
  export const Thumbnail = forwardRef<ThumbnailProps>((props, ref) => {
103
- const { isAnyDisabled, otherProps } = useDisableStateProps(props);
104
+ const { isAnyDisabled, otherProps, disabledStateProps } = useDisableStateProps(props);
104
105
  const defaultTheme = useTheme() || Theme.light;
105
106
  const {
106
107
  align,
@@ -151,18 +152,17 @@ export const Thumbnail = forwardRef<ThumbnailProps>((props, ref) => {
151
152
  }
152
153
 
153
154
  const isLink = Boolean(linkProps?.href || linkAs);
154
- const isButton = !!forwardedProps.onClick;
155
- const isClickable = !isAnyDisabled && (isButton || isLink);
155
+ const isClickable = !isAnyDisabled && Boolean(isLink || !!forwardedProps.onClick);
156
156
 
157
- let Wrapper: any = 'div';
157
+ const Wrapper: any = isClickable ? RawClickable : 'div';
158
158
  const wrapperProps = { ...forwardedProps };
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;
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
+ }
166
166
  }
167
167
 
168
168
  // If we have a loading placeholder image that is really loaded (complete)
@@ -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,5 +1,6 @@
1
- import { Button, Dialog, Dropdown, Placement, Tooltip } from '@lumx/react';
2
1
  import React, { useState } from 'react';
2
+
3
+ import { Button, Dialog, Dropdown, Placement, Tooltip } from '@lumx/react';
3
4
  import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
4
5
  import { withChromaticForceScreenSize } from '@lumx/react/stories/decorators/withChromaticForceScreenSize';
5
6
  import { ARIA_LINK_MODES } from '@lumx/react/components/tooltip/constants';