@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
package/package.json CHANGED
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^3.20.1-alpha.3",
10
- "@lumx/icons": "^3.20.1-alpha.3",
9
+ "@lumx/core": "^3.20.1-alpha.5",
10
+ "@lumx/icons": "^3.20.1-alpha.5",
11
11
  "@popperjs/core": "^2.5.4",
12
12
  "body-scroll-lock": "^3.1.5",
13
13
  "classnames": "^2.3.2",
@@ -34,18 +34,20 @@
34
34
  "@storybook/addon-a11y": "^9.1.4",
35
35
  "@storybook/addon-docs": "^9.1.4",
36
36
  "@storybook/react-vite": "^9.1.4",
37
- "@testing-library/dom": "^10.4.1",
37
+ "@testing-library/dom": "^9.3.4",
38
+ "@testing-library/jest-dom": "^5.16.4",
38
39
  "@testing-library/react": "^12.1.2",
39
40
  "@testing-library/user-event": "^14.4.3",
40
41
  "@types/body-scroll-lock": "^2.6.1",
41
42
  "@types/classnames": "^2.2.9",
42
43
  "@types/dom-view-transitions": "^1.0.5",
44
+ "@types/jest": "^29.2.1",
43
45
  "@types/lodash": "^4.14.149",
44
46
  "@types/react": "^17.0.2",
45
47
  "@types/react-dom": "^17.0.2",
46
48
  "@types/react-is": "^17.0.2",
47
- "@vitest/ui": "^1.0.0",
48
49
  "autoprefixer": "^9.7.4",
50
+ "babel-jest": "29.1.2",
49
51
  "babel-loader": "^8.0.6",
50
52
  "chromatic": "^13.1.4",
51
53
  "core-js": "^3.6.4",
@@ -53,7 +55,8 @@
53
55
  "glob": "^7.1.6",
54
56
  "install-peers-cli": "^2.2.0",
55
57
  "is-ci": "^2.0.0",
56
- "jsdom": "^27.2.0",
58
+ "jest": "29.1.2",
59
+ "jest-environment-jsdom": "29.1.2",
57
60
  "node-notifier": "^10.0.1",
58
61
  "react": "^17.0.2",
59
62
  "react-dom": "^17.0.2",
@@ -68,13 +71,12 @@
68
71
  "typescript": "^5.4.3",
69
72
  "vite": "^6.3.5",
70
73
  "vite-tsconfig-paths": "^5.1.4",
71
- "vitest": "^1.0.0",
72
74
  "yargs": "^15.4.1"
73
75
  },
74
76
  "peerDependencies": {
75
77
  "lodash": "4.17.21",
76
- "react": ">= 17.0.2",
77
- "react-dom": ">= 17.0.2"
78
+ "react": ">= 17.0.0",
79
+ "react-dom": ">= 17.0.0"
78
80
  },
79
81
  "description": "The official LumApps Design System (LumX) for React applications",
80
82
  "homepage": "https://github.com/lumapps/design-system",
@@ -99,10 +101,10 @@
99
101
  "scripts": {
100
102
  "build": "rollup -c",
101
103
  "prepare": "install-peers || exit 0",
102
- "test": "vitest run",
104
+ "test": "jest --config jest/index.js --coverage --notify --passWithNoTests --detectOpenHandles --runInBand",
103
105
  "start:storybook": "storybook dev -p 9000",
104
106
  "build:storybook": "storybook build"
105
107
  },
106
108
  "sideEffects": false,
107
- "version": "3.20.1-alpha.3"
109
+ "version": "3.20.1-alpha.5"
108
110
  }
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react-hooks/rules-of-hooks */
2
- import { RefObject, useRef } from 'react';
2
+ import React, { RefObject, useRef } from 'react';
3
3
  import { Button, Link, Kind } from '@lumx/react';
4
4
  import { DIALOG_TRANSITION_DURATION } from '@lumx/core/js/constants';
5
5
  import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
@@ -1,10 +1,11 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
2
4
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
3
5
  import { render } from '@testing-library/react';
4
- import { vi } from 'vitest';
5
6
  import { AlertDialog, AlertDialogProps } from './AlertDialog';
6
7
 
7
- vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
8
+ jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
8
9
 
9
10
  const CLASSNAME = AlertDialog.className as string;
10
11
 
@@ -16,7 +17,7 @@ const setup = (propsOverride: Partial<AlertDialogProps> = {}) => {
16
17
  title: 'Alert',
17
18
  isOpen: true,
18
19
  description: 'Deserunt et sunt qui consequat sint sit.',
19
- confirmProps: { onClick: vi.fn(), label: 'OK' },
20
+ confirmProps: { onClick: jest.fn(), label: 'OK' },
20
21
  ...propsOverride,
21
22
  };
22
23
  render(<AlertDialog {...props} />);
@@ -1,4 +1,4 @@
1
- import { useMemo, useRef, useState } from 'react';
1
+ import React, { useMemo, useRef, useState } from 'react';
2
2
 
3
3
  import { Autocomplete, List, ListItem, Size } from '@lumx/react';
4
4
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Dropdown, List, ListItem, Size, TextField } from '@lumx/react';
2
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
5
  import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -51,7 +53,7 @@ describe(`<${Autocomplete.displayName}>`, () => {
51
53
  describe('Events', () => {
52
54
  it('should trigger the onChange callback when there is a change on the Text Field', async () => {
53
55
  const name = 'autocomplete-name';
54
- const onChange = vi.fn();
56
+ const onChange = jest.fn();
55
57
  const { inputNative } = setup({
56
58
  name,
57
59
  onChange,
@@ -66,8 +68,8 @@ describe(`<${Autocomplete.displayName}>`, () => {
66
68
  });
67
69
 
68
70
  it('should trigger the onFocus/onBlur callback when the text field is focused and blurred', async () => {
69
- const onFocus = vi.fn();
70
- const onBlur = vi.fn();
71
+ const onFocus = jest.fn();
72
+ const onBlur = jest.fn();
71
73
  const { inputNative } = setup({
72
74
  onFocus,
73
75
  onBlur,
@@ -1,4 +1,4 @@
1
- import { ReactNode, SyntheticEvent, useRef } from 'react';
1
+ import React, { ReactNode, SyntheticEvent, useRef } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,4 +1,4 @@
1
- import { useMemo, useRef, useState } from 'react';
1
+ import React, { useMemo, useRef, useState } from 'react';
2
2
 
3
3
  import { AutocompleteMultiple, Chip, ChipGroup, Icon, List, ListItem, Size } from '@lumx/react';
4
4
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Dropdown, List, ListItem, Size, TextField } from '@lumx/react';
2
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
5
  import { getByClassName, 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
 
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable react/display-name */
2
+ import React from 'react';
3
+
2
4
  import { mdiDelete, mdiEye, mdiPencil, mdiStar } from '@lumx/icons';
3
5
  import { AvatarSize, Badge, ColorPalette, FlexBox, Icon, IconButton, Size } from '@lumx/react';
4
6
  import { avatarImageArgType, AVATAR_IMAGES } from '@lumx/react/stories/controls/image';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
4
  import { render } from '@testing-library/react';
3
5
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import { KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode } from 'react';
1
+ import React, { KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,5 +1,6 @@
1
1
  import { mdiHeart } from '@lumx/icons';
2
2
  import { AspectRatio, Badge, ColorPalette, Icon, Size, Thumbnail, ThumbnailVariant } from '@lumx/react';
3
+ import React from 'react';
3
4
  import { colorArgType } from '@lumx/react/stories/controls/color';
4
5
  import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
5
6
  import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { ColorPalette } from '@lumx/react';
2
4
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
5
  import { getByClassName } 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
 
@@ -1,5 +1,6 @@
1
1
  import { mdiAccount, mdiBee, mdiHeart } from '@lumx/icons';
2
2
  import { Badge, BadgeWrapper, Button, Chip, ColorPalette, FlexBox, Icon, Orientation, Size } from '@lumx/react';
3
+ import React from 'react';
3
4
 
4
5
  export default {
5
6
  title: 'LumX components/badge/BadgeWrapper',
@@ -1,4 +1,6 @@
1
1
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
2
+ import React from 'react';
3
+
2
4
  import omit from 'lodash/omit';
3
5
  import last from 'lodash/last';
4
6
 
@@ -1,4 +1,4 @@
1
- import { ReactElement, ReactNode } from 'react';
1
+ import React, { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import omit from 'lodash/omit';
2
3
  import pick from 'lodash/pick';
3
4
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { mdiCheck, mdiPlus } from '@lumx/icons';
2
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
5
  import { render, screen, within } from '@testing-library/react';
@@ -66,7 +68,7 @@ describe(`<${Button.displayName}>`, () => {
66
68
 
67
69
  describe('Disabled state', () => {
68
70
  it('should render disabled button', async () => {
69
- const onClick = vi.fn();
71
+ const onClick = jest.fn();
70
72
  const { button } = setup({ children: 'Label', disabled: true, onClick });
71
73
  expect(button).toHaveAttribute('disabled');
72
74
  await userEvent.click(button);
@@ -74,18 +76,17 @@ describe(`<${Button.displayName}>`, () => {
74
76
  });
75
77
 
76
78
  it('should render disabled link', async () => {
77
- const onClick = vi.fn();
79
+ const onClick = jest.fn();
78
80
  const { button } = setup({ children: 'Label', disabled: true, href: 'https://example.com', onClick });
79
- expect(screen.queryByRole('link')).toBeInTheDocument();
80
- expect(button).toHaveAttribute('aria-disabled', 'true');
81
- // Simulate standard disabled state (not focusable)
82
- expect(button).toHaveAttribute('tabindex', '-1');
81
+ // Disabled link do not exist so we fallback to a button
82
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
83
+ expect(button).toHaveAttribute('disabled');
83
84
  await userEvent.click(button);
84
85
  expect(onClick).not.toHaveBeenCalled();
85
86
  });
86
87
 
87
88
  it('should render aria-disabled button', async () => {
88
- const onClick = vi.fn();
89
+ const onClick = jest.fn();
89
90
  const { button } = setup({ children: 'Label', 'aria-disabled': true, onClick });
90
91
  expect(button).toHaveAttribute('aria-disabled');
91
92
  await userEvent.click(button);
@@ -93,7 +94,7 @@ describe(`<${Button.displayName}>`, () => {
93
94
  });
94
95
 
95
96
  it('should render aria-disabled link', async () => {
96
- const onClick = vi.fn();
97
+ const onClick = jest.fn();
97
98
  const { button } = setup({
98
99
  children: 'Label',
99
100
  'aria-disabled': true,
@@ -101,7 +102,8 @@ describe(`<${Button.displayName}>`, () => {
101
102
  onClick,
102
103
  });
103
104
  expect(button).toHaveAccessibleName('Label');
104
- expect(screen.queryByRole('link')).toBeInTheDocument();
105
+ // Disabled link do not exist so we fallback to a button
106
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
105
107
  expect(button).toHaveAttribute('aria-disabled', 'true');
106
108
  await userEvent.click(button);
107
109
  expect(onClick).not.toHaveBeenCalled();
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
4
  import isEmpty from 'lodash/isEmpty';
3
5
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Button, ButtonGroup, Emphasis, IconButton, Size } from '@lumx/react';
2
4
  import { mdiAbjadArabic, mdiFoodApple, mdiMenuDown } from '@lumx/icons';
3
5
  import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { mdiPlus } from '@lumx/icons';
2
4
  import { Button, IconButton } from '@lumx/react';
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 { GenericProps } from '@lumx/react/utils/type';
@@ -1,4 +1,6 @@
1
- import { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, RefObject } from 'react';
1
+ import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, RefObject } from 'react';
2
+
3
+ import isEmpty from 'lodash/isEmpty';
2
4
 
3
5
  import classNames from 'classnames';
4
6
 
@@ -6,10 +8,10 @@ import { ColorPalette, Emphasis, Size, Theme } from '@lumx/react';
6
8
  import { CSS_PREFIX } from '@lumx/react/constants';
7
9
  import { GenericProps, HasTheme } from '@lumx/react/utils/type';
8
10
  import { handleBasicClasses } from '@lumx/core/js/utils/className';
11
+ import { renderLink } from '@lumx/react/utils/react/renderLink';
9
12
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
13
+ import { useDisableStateProps } from '@lumx/react/utils/disabled/useDisableStateProps';
10
14
  import { HasAriaDisabled } from '@lumx/react/utils/type/HasAriaDisabled';
11
- import { RawClickable } from '@lumx/react/utils/react/RawClickable';
12
- import { useDisableStateProps } from '@lumx/react/utils/disabled';
13
15
 
14
16
  type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
15
17
 
@@ -105,14 +107,18 @@ export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAn
105
107
  color,
106
108
  emphasis,
107
109
  hasBackground,
110
+ href,
108
111
  isSelected,
109
112
  isActive,
110
113
  isFocused,
111
114
  isHovered,
112
115
  linkAs,
116
+ name,
113
117
  size,
118
+ target,
114
119
  theme,
115
120
  variant,
121
+ type = 'button',
116
122
  fullWidth,
117
123
  ...forwardedProps
118
124
  } = otherProps;
@@ -133,7 +139,7 @@ export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAn
133
139
  color: adaptedColor,
134
140
  emphasis,
135
141
  isSelected,
136
- isDisabled: props.isDisabled || props['aria-disabled'],
142
+ isDisabled: isAnyDisabled,
137
143
  isActive,
138
144
  isFocused,
139
145
  isHovered,
@@ -145,18 +151,42 @@ export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAn
145
151
  }),
146
152
  );
147
153
 
154
+ /**
155
+ * If the linkAs prop is used, we use the linkAs component instead of a <button>.
156
+ * If there is an href attribute, we display an <a> instead of a <button>.
157
+ *
158
+ * However, in any case, if the component is disabled, we returned a <button> since disabled is not compatible with <a>.
159
+ */
160
+ if ((linkAs || !isEmpty(props.href)) && !isAnyDisabled) {
161
+ return renderLink(
162
+ {
163
+ linkAs,
164
+ ...forwardedProps,
165
+ 'aria-label': ariaLabel,
166
+ href,
167
+ target,
168
+ className: buttonClassName,
169
+ ref: ref as RefObject<HTMLAnchorElement>,
170
+ },
171
+ children,
172
+ );
173
+ }
148
174
  return (
149
- <RawClickable
150
- as={linkAs || (forwardedProps.href ? 'a' : 'button')}
175
+ <button
151
176
  {...forwardedProps}
152
177
  {...disabledStateProps}
153
178
  aria-disabled={isAnyDisabled}
154
179
  aria-label={ariaLabel}
155
180
  ref={ref as RefObject<HTMLButtonElement>}
156
181
  className={buttonClassName}
182
+ name={name}
183
+ type={
184
+ // eslint-disable-next-line react/button-has-type
185
+ type
186
+ }
157
187
  >
158
188
  {children}
159
- </RawClickable>
189
+ </button>
160
190
  );
161
191
  });
162
192
  ButtonRoot.displayName = COMPONENT_NAME;
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
4
  import { Button } from '@lumx/react';
3
5
  import { render, screen } from '@testing-library/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Emphasis, Icon, Size, Theme, ThemeProvider, Tooltip, TooltipProps } from '@lumx/react';
2
4
  import { BaseButtonProps, ButtonRoot } from '@lumx/react/components/button/ButtonRoot';
3
5
  import { getRootClassName } from '@lumx/core/js/utils/className';
@@ -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 { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -96,7 +98,7 @@ describe(`<${Checkbox.displayName}>`, () => {
96
98
  });
97
99
 
98
100
  describe('Events', () => {
99
- const onChange = vi.fn();
101
+ const onChange = jest.fn();
100
102
 
101
103
  it('should trigger `onChange` when checkbox is clicked', async () => {
102
104
  const value = 'value';
@@ -112,7 +114,7 @@ describe(`<${Checkbox.displayName}>`, () => {
112
114
 
113
115
  describe('Disabled state', () => {
114
116
  it('should be disabled with isDisabled', async () => {
115
- const onChange = vi.fn();
117
+ const onChange = jest.fn();
116
118
  const { checkbox, input } = setup({ isDisabled: true, onChange });
117
119
 
118
120
  expect(checkbox).toHaveClass('lumx-checkbox--is-disabled');
@@ -124,7 +126,7 @@ describe(`<${Checkbox.displayName}>`, () => {
124
126
  });
125
127
 
126
128
  it('should be disabled with aria-disabled', async () => {
127
- const onChange = vi.fn();
129
+ const onChange = jest.fn();
128
130
  const { checkbox, input } = setup({ 'aria-disabled': true, onChange });
129
131
 
130
132
  expect(checkbox).toHaveClass('lumx-checkbox--is-disabled');
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import omit from 'lodash/omit';
2
4
  import { mdiClose, mdiViewList } from '@lumx/icons';
3
5
  import { Chip, ChipProps, ColorPalette, Icon, Size, Theme } from '@lumx/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Theme } from '@lumx/react';
2
4
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
3
5
  import { fireEvent, render, screen } from '@testing-library/react';
@@ -40,7 +42,7 @@ describe('<Chip />', () => {
40
42
  });
41
43
 
42
44
  it('should render clickable', () => {
43
- const onClick = vi.fn();
45
+ const onClick = jest.fn();
44
46
  const { chip } = setup({ children: 'Chip text', onClick });
45
47
  expect(chip).toHaveAttribute('role', 'button');
46
48
  expect(chip.className).toMatchInlineSnapshot(
@@ -68,13 +70,11 @@ describe('<Chip />', () => {
68
70
  });
69
71
 
70
72
  describe('Events', () => {
71
- const onClick = vi.fn();
72
- const onAfterClick = vi.fn();
73
- const onBeforeClick = vi.fn();
73
+ const onClick = jest.fn();
74
+ const onAfterClick = jest.fn();
75
+ const onBeforeClick = jest.fn();
74
76
 
75
- beforeEach(() => {
76
- vi.clearAllMocks();
77
- });
77
+ beforeEach(jest.clearAllMocks);
78
78
 
79
79
  it('should trigger onBeforeClick only when clicking on the "before" element', async () => {
80
80
  const { after, before, chip } = setup({
@@ -88,12 +88,12 @@ describe('<Chip />', () => {
88
88
  await userEvent.click(chip);
89
89
  expect(onBeforeClick).not.toHaveBeenCalled();
90
90
 
91
- vi.clearAllMocks();
91
+ jest.clearAllMocks();
92
92
 
93
93
  await userEvent.click(after as any);
94
94
  expect(onBeforeClick).not.toHaveBeenCalled();
95
95
 
96
- vi.clearAllMocks();
96
+ jest.clearAllMocks();
97
97
 
98
98
  await userEvent.click(before as any);
99
99
  expect(onBeforeClick).toHaveBeenCalled();
@@ -111,12 +111,12 @@ describe('<Chip />', () => {
111
111
  await userEvent.click(chip);
112
112
  expect(onClick).toHaveBeenCalled();
113
113
 
114
- vi.clearAllMocks();
114
+ jest.clearAllMocks();
115
115
 
116
116
  await userEvent.click(after as any);
117
117
  expect(onClick).not.toHaveBeenCalled();
118
118
 
119
- vi.clearAllMocks();
119
+ jest.clearAllMocks();
120
120
 
121
121
  await userEvent.click(before as any);
122
122
  expect(onClick).not.toHaveBeenCalled();
@@ -134,12 +134,12 @@ describe('<Chip />', () => {
134
134
  await userEvent.click(chip);
135
135
  expect(onAfterClick).not.toHaveBeenCalled();
136
136
 
137
- vi.clearAllMocks();
137
+ jest.clearAllMocks();
138
138
 
139
139
  await userEvent.click(after as any);
140
140
  expect(onAfterClick).toHaveBeenCalled();
141
141
 
142
- vi.clearAllMocks();
142
+ jest.clearAllMocks();
143
143
 
144
144
  await userEvent.click(before as any);
145
145
  expect(onAfterClick).not.toHaveBeenCalled();
@@ -162,7 +162,7 @@ describe('<Chip />', () => {
162
162
  });
163
163
 
164
164
  it('should forward key down event', async () => {
165
- const onKeyDown = vi.fn();
165
+ const onKeyDown = jest.fn();
166
166
  const { chip } = setup({ onClick, onKeyDown });
167
167
 
168
168
  fireEvent.keyDown(chip, { key: 'A', code: 'KeyA' });
@@ -171,7 +171,7 @@ describe('<Chip />', () => {
171
171
 
172
172
  it('should forward key down event and trigger `onClick` when pressing Enter', async () => {
173
173
  const user = userEvent.setup();
174
- const onKeyDown = vi.fn();
174
+ const onKeyDown = jest.fn();
175
175
  const { chip } = setup({ onClick, onKeyDown });
176
176
 
177
177
  await user.tab();
@@ -187,7 +187,7 @@ describe('<Chip />', () => {
187
187
 
188
188
  describe('Disabled state', () => {
189
189
  it('should render disabled chip button', async () => {
190
- const onClick = vi.fn();
190
+ const onClick = jest.fn();
191
191
  const { chip } = setup({ children: 'Label', isDisabled: true, onClick });
192
192
  expect(chip).toHaveAttribute('aria-disabled', 'true');
193
193
  await userEvent.click(chip);
@@ -195,7 +195,7 @@ describe('<Chip />', () => {
195
195
  });
196
196
 
197
197
  it('should render disabled chip link', async () => {
198
- const onClick = vi.fn();
198
+ const onClick = jest.fn();
199
199
  const { chip } = setup({ children: 'Label', isDisabled: true, href: 'https://example.com', onClick });
200
200
  // Disabled link should not have an href.
201
201
  expect(chip).not.toHaveAttribute('href');
@@ -205,7 +205,7 @@ describe('<Chip />', () => {
205
205
  });
206
206
 
207
207
  it('should render aria-disabled chip button', async () => {
208
- const onClick = vi.fn();
208
+ const onClick = jest.fn();
209
209
  const { chip } = setup({ children: 'Label', 'aria-disabled': true, onClick });
210
210
  expect(chip).toHaveAttribute('aria-disabled', 'true');
211
211
  await userEvent.click(chip);
@@ -214,7 +214,7 @@ describe('<Chip />', () => {
214
214
  });
215
215
 
216
216
  it('should render aria-disabled chip link', async () => {
217
- const onClick = vi.fn();
217
+ const onClick = jest.fn();
218
218
  const { chip } = setup({
219
219
  children: 'Label',
220
220
  'aria-disabled': true,
@@ -1,4 +1,4 @@
1
- import { MouseEventHandler, ReactNode } from 'react';
1
+ import React, { MouseEventHandler, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import isFunction from 'lodash/isFunction';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Chip, ChipGroup, Size } from '@lumx/react';
2
4
 
3
5
  export default {
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { render } from '@testing-library/react';
2
4
  import { getByClassName } from '@lumx/react/testing/utils/queries';
3
5
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
@@ -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,5 @@
1
1
  /* eslint-disable react/jsx-key,react/display-name */
2
+ import React from 'react';
2
3
  import { mdiDotsHorizontal, mdiHeart, mdiReply } from '@lumx/icons';
3
4
  import { Button, CommentBlock } from '@lumx/react';
4
5
  import { IconButton } from '@lumx/react/components/button/IconButton';
@@ -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';