@lumx/react 3.20.1-alpha.8 → 3.21.0

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 (231) hide show
  1. package/_internal/index.js +20 -13
  2. package/_internal/index.js.map +1 -1
  3. package/index.d.ts +60 -33
  4. package/index.js +2937 -3090
  5. package/index.js.map +1 -1
  6. package/package.json +5 -9
  7. package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
  8. package/src/components/alert-dialog/AlertDialog.test.tsx +2 -0
  9. package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
  10. package/src/components/autocomplete/Autocomplete.test.tsx +2 -0
  11. package/src/components/autocomplete/Autocomplete.tsx +1 -1
  12. package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
  13. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +2 -0
  14. package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
  15. package/src/components/avatar/Avatar.stories.tsx +2 -0
  16. package/src/components/avatar/Avatar.test.tsx +2 -0
  17. package/src/components/avatar/Avatar.tsx +1 -1
  18. package/src/components/badge/Badge.stories.tsx +1 -0
  19. package/src/components/badge/Badge.test.tsx +2 -0
  20. package/src/components/badge/Badge.tsx +1 -1
  21. package/src/components/badge/BadgeWrapper.stories.tsx +1 -0
  22. package/src/components/badge/BadgeWrapper.test.tsx +2 -0
  23. package/src/components/badge/BadgeWrapper.tsx +1 -1
  24. package/src/components/button/Button.stories.tsx +1 -0
  25. package/src/components/button/Button.test.tsx +2 -0
  26. package/src/components/button/Button.tsx +2 -0
  27. package/src/components/button/ButtonGroup.stories.tsx +2 -0
  28. package/src/components/button/ButtonGroup.test.tsx +2 -0
  29. package/src/components/button/ButtonGroup.tsx +2 -0
  30. package/src/components/button/ButtonRoot.tsx +1 -1
  31. package/src/components/button/IconButton.test.tsx +2 -0
  32. package/src/components/button/IconButton.tsx +2 -0
  33. package/src/components/checkbox/Checkbox.test.tsx +2 -0
  34. package/src/components/chip/Chip.stories.tsx +2 -0
  35. package/src/components/chip/Chip.test.tsx +2 -0
  36. package/src/components/chip/Chip.tsx +1 -1
  37. package/src/components/chip/ChipGroup.stories.tsx +2 -0
  38. package/src/components/chip/ChipGroup.test.tsx +2 -0
  39. package/src/components/chip/ChipGroup.tsx +1 -1
  40. package/src/components/comment-block/CommentBlock.stories.tsx +1 -0
  41. package/src/components/comment-block/CommentBlock.test.tsx +1 -0
  42. package/src/components/comment-block/CommentBlock.tsx +1 -1
  43. package/src/components/date-picker/DatePicker.test.tsx +2 -0
  44. package/src/components/date-picker/DatePicker.tsx +1 -1
  45. package/src/components/date-picker/DatePickerControlled.test.tsx +2 -0
  46. package/src/components/date-picker/DatePickerField.test.tsx +2 -0
  47. package/src/components/dialog/Dialog.test.tsx +2 -0
  48. package/src/components/divider/Divider.test.tsx +2 -0
  49. package/src/components/divider/Divider.tsx +2 -0
  50. package/src/components/drag-handle/DragHandle.test.tsx +2 -0
  51. package/src/components/drag-handle/DragHandle.tsx +2 -0
  52. package/src/components/dropdown/Dropdown.stories.tsx +1 -1
  53. package/src/components/dropdown/Dropdown.tsx +1 -1
  54. package/src/components/expansion-panel/ExpansionPanel.test.tsx +2 -0
  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.test.tsx +2 -0
  71. package/src/components/icon/Icon.tsx +120 -7
  72. package/src/components/image-block/ImageBlock.stories.tsx +2 -0
  73. package/src/components/image-block/ImageBlock.test.tsx +1 -0
  74. package/src/components/image-block/ImageBlock.tsx +1 -1
  75. package/src/components/image-block/ImageCaption.tsx +1 -1
  76. package/src/components/image-lightbox/ImageLightbox.stories.tsx +1 -0
  77. package/src/components/image-lightbox/ImageLightbox.test.tsx +2 -0
  78. package/src/components/image-lightbox/types.ts +2 -0
  79. package/src/components/inline-list/InlineList.stories.tsx +1 -0
  80. package/src/components/inline-list/InlineList.test.tsx +2 -0
  81. package/src/components/inline-list/InlineList.tsx +1 -1
  82. package/src/components/input-helper/InputHelper.test.tsx +2 -0
  83. package/src/components/input-helper/InputHelper.tsx +1 -1
  84. package/src/components/input-label/InputLabel.stories.tsx +2 -0
  85. package/src/components/input-label/InputLabel.test.tsx +2 -0
  86. package/src/components/input-label/InputLabel.tsx +1 -1
  87. package/src/components/lightbox/Lightbox.test.tsx +2 -0
  88. package/src/components/lightbox/Lightbox.tsx +1 -1
  89. package/src/components/link/Link.stories.tsx +1 -0
  90. package/src/components/link/Link.test.tsx +2 -0
  91. package/src/components/link/Link.tsx +2 -0
  92. package/src/components/link-preview/LinkPreview.test.tsx +2 -0
  93. package/src/components/link-preview/LinkPreview.tsx +2 -0
  94. package/src/components/list/List.stories.tsx +1 -1
  95. package/src/components/list/List.test.tsx +2 -0
  96. package/src/components/list/List.tsx +1 -1
  97. package/src/components/list/ListDivider.test.tsx +2 -0
  98. package/src/components/list/ListDivider.tsx +2 -0
  99. package/src/components/list/ListItem.test.tsx +2 -0
  100. package/src/components/list/ListItem.tsx +1 -1
  101. package/src/components/list/ListSubheader.test.tsx +2 -0
  102. package/src/components/list/ListSubheader.tsx +1 -1
  103. package/src/components/message/Message.test.tsx +1 -0
  104. package/src/components/message/Message.tsx +1 -1
  105. package/src/components/mosaic/Mosaic.test.tsx +2 -0
  106. package/src/components/mosaic/Mosaic.tsx +1 -1
  107. package/src/components/navigation/Navigation.stories.tsx +2 -0
  108. package/src/components/navigation/Navigation.test.tsx +2 -0
  109. package/src/components/navigation/Navigation.tsx +2 -0
  110. package/src/components/navigation/NavigationItem.test.tsx +2 -0
  111. package/src/components/navigation/NavigationItem.tsx +1 -1
  112. package/src/components/navigation/NavigationSection.test.tsx +2 -0
  113. package/src/components/navigation/NavigationSection.tsx +1 -1
  114. package/src/components/notification/Notification.test.tsx +2 -0
  115. package/src/components/notification/Notification.tsx +1 -1
  116. package/src/components/popover/Popover.test.tsx +2 -0
  117. package/src/components/popover/Popover.tsx +1 -1
  118. package/src/components/popover/usePopoverStyle.tsx +1 -1
  119. package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -0
  120. package/src/components/popover-dialog/PopoverDialog.tsx +2 -0
  121. package/src/components/post-block/PostBlock.test.tsx +2 -0
  122. package/src/components/post-block/PostBlock.tsx +1 -1
  123. package/src/components/progress/Progress.tsx +2 -0
  124. package/src/components/progress/ProgressCircular.stories.tsx +1 -0
  125. package/src/components/progress/ProgressCircular.test.tsx +2 -0
  126. package/src/components/progress/ProgressCircular.tsx +2 -0
  127. package/src/components/progress/ProgressLinear.test.tsx +2 -0
  128. package/src/components/progress/ProgressLinear.tsx +2 -0
  129. package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
  130. package/src/components/progress-tracker/ProgressTracker.test.tsx +2 -0
  131. package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +2 -0
  132. package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
  133. package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +2 -0
  134. package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
  135. package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +2 -0
  136. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +2 -0
  137. package/src/components/radio-button/RadioButton.test.tsx +2 -0
  138. package/src/components/radio-button/RadioButton.tsx +1 -1
  139. package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
  140. package/src/components/radio-button/RadioGroup.test.tsx +2 -0
  141. package/src/components/radio-button/RadioGroup.tsx +1 -1
  142. package/src/components/select/Select.stories.tsx +1 -1
  143. package/src/components/select/Select.test.tsx +2 -0
  144. package/src/components/select/Select.tsx +1 -1
  145. package/src/components/select/SelectMultiple.stories.tsx +1 -1
  146. package/src/components/select/SelectMultiple.test.tsx +2 -0
  147. package/src/components/select/SelectMultiple.tsx +1 -1
  148. package/src/components/select/WithSelectContext.tsx +1 -1
  149. package/src/components/select/constants.ts +1 -1
  150. package/src/components/side-navigation/SideNavigation.test.tsx +2 -0
  151. package/src/components/side-navigation/SideNavigation.tsx +1 -1
  152. package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -0
  153. package/src/components/side-navigation/SideNavigationItem.tsx +1 -1
  154. package/src/components/skeleton/SkeletonCircle.test.tsx +2 -0
  155. package/src/components/skeleton/SkeletonCircle.tsx +2 -0
  156. package/src/components/skeleton/SkeletonRectangle.test.tsx +2 -0
  157. package/src/components/skeleton/SkeletonRectangle.tsx +2 -0
  158. package/src/components/skeleton/SkeletonTypography.stories.tsx +2 -0
  159. package/src/components/skeleton/SkeletonTypography.test.tsx +2 -0
  160. package/src/components/skeleton/SkeletonTypography.tsx +1 -1
  161. package/src/components/slider/Slider.test.tsx +2 -0
  162. package/src/components/slider/Slider.tsx +1 -1
  163. package/src/components/slideshow/Slideshow.stories.tsx +1 -0
  164. package/src/components/slideshow/Slideshow.test.tsx +2 -0
  165. package/src/components/slideshow/SlideshowControls.stories.tsx +2 -0
  166. package/src/components/slideshow/SlideshowItem.tsx +2 -0
  167. package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
  168. package/src/components/switch/Switch.test.tsx +2 -0
  169. package/src/components/switch/Switch.tsx +1 -1
  170. package/src/components/table/Table.test.tsx +2 -0
  171. package/src/components/table/Table.tsx +2 -0
  172. package/src/components/table/TableBody.test.tsx +2 -0
  173. package/src/components/table/TableBody.tsx +2 -0
  174. package/src/components/table/TableCell.test.tsx +2 -0
  175. package/src/components/table/TableCell.tsx +2 -0
  176. package/src/components/table/TableHeader.test.tsx +2 -0
  177. package/src/components/table/TableHeader.tsx +2 -0
  178. package/src/components/table/TableRow.test.tsx +2 -0
  179. package/src/components/table/TableRow.tsx +2 -0
  180. package/src/components/tabs/Tab.test.tsx +2 -0
  181. package/src/components/tabs/Tab.tsx +1 -1
  182. package/src/components/tabs/TabList.test.tsx +2 -0
  183. package/src/components/tabs/TabPanel.test.tsx +2 -0
  184. package/src/components/tabs/TabPanel.tsx +2 -0
  185. package/src/components/tabs/TabProvider.test.tsx +2 -0
  186. package/src/components/tabs/TabProvider.tsx +1 -1
  187. package/src/components/tabs/Tabs.stories.tsx +1 -1
  188. package/src/components/text/Text.stories.tsx +1 -1
  189. package/src/components/text/Text.test.tsx +2 -0
  190. package/src/components/text/Text.tsx +2 -0
  191. package/src/components/text-field/RawInputText.stories.tsx +18 -0
  192. package/src/components/text-field/RawInputText.test.tsx +58 -0
  193. package/src/components/text-field/RawInputText.tsx +56 -0
  194. package/src/components/text-field/RawInputTextarea.stories.tsx +22 -0
  195. package/src/components/text-field/RawInputTextarea.test.tsx +63 -0
  196. package/src/components/text-field/RawInputTextarea.tsx +68 -0
  197. package/src/components/text-field/TextField.test.tsx +11 -2
  198. package/src/components/text-field/TextField.tsx +40 -210
  199. package/src/components/text-field/constants.ts +16 -0
  200. package/src/components/text-field/index.ts +3 -1
  201. package/src/components/text-field/useFitRowsToContent.ts +42 -0
  202. package/src/components/thumbnail/Thumbnail.test.tsx +2 -0
  203. package/src/components/toolbar/Toolbar.tsx +1 -1
  204. package/src/components/tooltip/Tooltip.stories.tsx +1 -2
  205. package/src/components/tooltip/Tooltip.test.tsx +1 -1
  206. package/src/components/uploader/Uploader.test.tsx +2 -0
  207. package/src/components/user-block/UserBlock.stories.tsx +2 -0
  208. package/src/components/user-block/UserBlock.test.tsx +2 -0
  209. package/src/hooks/useId.test.tsx +1 -0
  210. package/src/hooks/useInfiniteScroll.tsx +1 -1
  211. package/src/hooks/usePreviousValue.ts +1 -0
  212. package/src/stories/decorators/withChromaticForceScreenSize.tsx +1 -0
  213. package/src/stories/decorators/withNestedProps.tsx +1 -0
  214. package/src/stories/decorators/withThemedBackground.tsx +2 -0
  215. package/src/stories/decorators/withWrapper.tsx +2 -0
  216. package/src/stories/utils/CustomLink.tsx +1 -0
  217. package/src/testing/utils/ThemeSentinel.tsx +1 -0
  218. package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
  219. package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
  220. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  221. package/src/utils/Portal/Portal.test.tsx +1 -0
  222. package/src/utils/Portal/PortalProvider.stories.jsx +1 -0
  223. package/src/utils/Portal/PortalProvider.test.tsx +1 -0
  224. package/src/utils/disabled/DisabledStateProvider.stories.tsx +2 -0
  225. package/src/utils/react/OnBeforeUnmount.tsx +1 -1
  226. package/src/utils/react/RawClickable.tsx +1 -1
  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 +2 -0
  230. package/utils/index.d.ts +7 -7
  231. package/utils/index.js +1 -1
@@ -1,5 +1,5 @@
1
1
  import { RadioButton, RadioGroup } from '@lumx/react';
2
- import { useState } from 'react';
2
+ import React, { useState } from 'react';
3
3
 
4
4
  export default { title: 'LumX components/radio-button/Radio Group' };
5
5
 
@@ -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 } from '@testing-library/react';
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -3,7 +3,7 @@ import { List, ListItem, Select, Size, TextField } from '@lumx/react';
3
3
  import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
4
4
  import noop from 'lodash/noop';
5
5
  import range from 'lodash/range';
6
- import { SyntheticEvent, useState } from 'react';
6
+ import React, { SyntheticEvent, useState } from 'react';
7
7
  import { SelectVariant } from './constants';
8
8
 
9
9
  export default {
@@ -1,4 +1,6 @@
1
1
  import { Mock } from 'vitest';
2
+ import React from 'react';
3
+
2
4
  import { Theme } from '@lumx/core/js/constants';
3
5
  import { Chip } from '@lumx/react/components/chip/Chip';
4
6
  import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
@@ -1,4 +1,4 @@
1
- import { RefObject } from 'react';
1
+ import React, { RefObject } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import lodashIsEmpty from 'lodash/isEmpty';
@@ -14,7 +14,7 @@ import {
14
14
  } from '@lumx/react';
15
15
  import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
16
16
  import noop from 'lodash/noop';
17
- import { MouseEventHandler, SyntheticEvent, useRef, useState } from 'react';
17
+ import React, { MouseEventHandler, SyntheticEvent, useRef, useState } from 'react';
18
18
  import { SelectVariant } from './constants';
19
19
 
20
20
  export default { title: 'LumX components/select/Select Multiple' };
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { Theme } from '@lumx/core/js/constants';
2
4
  import { Chip } from '@lumx/react/components/chip/Chip';
3
5
  import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
@@ -1,4 +1,4 @@
1
- import { ReactNode, RefObject, SyntheticEvent } from 'react';
1
+ import React, { ReactNode, RefObject, SyntheticEvent } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Ref, useCallback, useRef } from 'react';
2
+ import React, { Ref, useCallback, useRef } from 'react';
3
3
 
4
4
  import { Placement } from '@lumx/react';
5
5
  import { Kind, Theme } from '@lumx/core/js/constants';
@@ -1,6 +1,6 @@
1
1
  import { IconButtonProps } from '@lumx/react';
2
2
  import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
3
- import { ReactNode, SyntheticEvent } from 'react';
3
+ import React, { ReactNode, SyntheticEvent } from 'react';
4
4
 
5
5
  /**
6
6
  * Select variants.
@@ -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 { Children, ReactNode } from 'react';
1
+ import React, { Children, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { getAllByClassName, queryAllByClassName } from '@lumx/react/testing/utils/queries';
2
4
  import { render, screen } from '@testing-library/react';
3
5
  import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
@@ -1,4 +1,4 @@
1
- import { Children, ReactNode } from 'react';
1
+ import React, { Children, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import isEmpty from 'lodash/isEmpty';
@@ -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,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
4
 
3
5
  import { GlobalSize, Theme, ColorPalette } from '@lumx/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
4
  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 { AspectRatio, GlobalSize, Theme, ColorPalette } from '@lumx/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { SkeletonTypography, Typography, ColorPalette } from '@lumx/react';
2
4
 
3
5
  export default { title: 'LumX components/skeleton/Skeleton Typography' };
@@ -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 { CSSProperties } from 'react';
1
+ import React, { CSSProperties } 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 { 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,5 +1,5 @@
1
1
  /* eslint-disable jsx-a11y/no-static-element-interactions */
2
- import { SyntheticEvent, useMemo, useRef } from 'react';
2
+ import React, { SyntheticEvent, useMemo, useRef } from 'react';
3
3
 
4
4
  import classNames from 'classnames';
5
5
 
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import range from 'lodash/range';
2
3
  import { AspectRatio, Button, FlexBox, ImageBlock, Slideshow, SlideshowItem, Orientation } from '@lumx/react';
3
4
  import { IMAGES, LANDSCAPE_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,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { AspectRatio, ImageBlock, Slides, SlideshowControls, SlideshowItem } from '@lumx/react';
2
4
  import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
3
5
  import { LANDSCAPE_IMAGES } from '@lumx/react/stories/controls/image';
@@ -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,4 @@
1
- import { useEffect } from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import { getFocusableElements } from '@lumx/react/utils/browser/focus/getFocusableElements';
3
3
 
4
4
  export interface UseSlideFocusManagementProps {
@@ -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 { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
@@ -1,4 +1,4 @@
1
- import { Children, InputHTMLAttributes, SyntheticEvent } from 'react';
1
+ import React, { Children, InputHTMLAttributes, SyntheticEvent } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import isEmpty from 'lodash/isEmpty';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
4
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
3
5
  import { render } from '@testing-library/react';
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
4
 
3
5
  import { Theme } from '@lumx/react';
@@ -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 { 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';
@@ -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';
@@ -0,0 +1,18 @@
1
+ import { withValueOnChange } from '@lumx/react/stories/decorators/withValueOnChange';
2
+ import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
3
+
4
+ import { RawInputText } from './RawInputText';
5
+
6
+ export default {
7
+ title: 'LumX components/text-field/RawInputText',
8
+ component: RawInputText,
9
+ decorators: [withValueOnChange(), withWrapper({ style: { border: '1px dashed red' } })],
10
+ };
11
+
12
+ export const Default = {};
13
+
14
+ export const WithPlaceholder = {
15
+ args: {
16
+ placeholder: 'Input placeholder',
17
+ },
18
+ };
@@ -0,0 +1,58 @@
1
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
+ import { render } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { getByClassName } from '@lumx/react/testing/utils/queries';
5
+
6
+ import { RawInputText, RawInputTextProps } from './RawInputText';
7
+ import { INPUT_NATIVE_CLASSNAME } from './constants';
8
+
9
+ /**
10
+ * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
11
+ */
12
+ const setup = (propsOverride: Partial<RawInputTextProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
13
+ const props: any = { ...propsOverride };
14
+ render(<RawInputText {...props} />, { wrapper });
15
+ const input = getByClassName(document.body, INPUT_NATIVE_CLASSNAME);
16
+ return { props, input };
17
+ };
18
+
19
+ describe(`<${RawInputText.displayName}>`, () => {
20
+ describe('Props', () => {
21
+ it('should render default', () => {
22
+ const { input } = setup();
23
+ expect(input).toBeInTheDocument();
24
+ expect(input?.tagName).toBe('INPUT');
25
+ expect(input).toHaveAttribute('type', 'text');
26
+ });
27
+
28
+ it('should render with custom type', () => {
29
+ const { input } = setup({ type: 'number' });
30
+ expect(input).toHaveAttribute('type', 'number');
31
+ });
32
+ });
33
+
34
+ describe('Events', () => {
35
+ it('should call onChange with correct value when typing', async () => {
36
+ const onChange = vi.fn();
37
+ const name = 'inputName';
38
+ const { input } = setup({ onChange, name });
39
+ await userEvent.type(input as Element, 'hello');
40
+ expect(onChange).toHaveBeenCalledWith('h', name, expect.any(Object));
41
+ expect(onChange).toHaveBeenCalledWith('hello', name, expect.any(Object));
42
+ });
43
+ });
44
+
45
+ // Common tests suite.
46
+ commonTestsSuiteRTL(setup, {
47
+ baseClassName: INPUT_NATIVE_CLASSNAME,
48
+ forwardClassName: 'input',
49
+ forwardAttributes: 'input',
50
+ forwardRef: 'input',
51
+ applyTheme: {
52
+ affects: [{ element: 'input' }],
53
+ viaProp: true,
54
+ viaContext: true,
55
+ defaultTheme: 'light',
56
+ },
57
+ });
58
+ });
@@ -0,0 +1,56 @@
1
+ import React, { ComponentProps, ChangeEventHandler, SyntheticEvent, useRef, useCallback } from 'react';
2
+
3
+ import classNames from 'classnames';
4
+
5
+ import { Theme, useTheme } from '@lumx/react';
6
+
7
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
8
+ import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
9
+ import { HasClassName, HasTheme } from '@lumx/react/utils/type';
10
+ import { handleBasicClasses } from '@lumx/core/js/utils';
11
+
12
+ import { INPUT_NATIVE_CLASSNAME } from './constants';
13
+
14
+ type NativeInputProps = Omit<ComponentProps<'input'>, 'value' | 'onChange'>;
15
+
16
+ /**
17
+ * Defines the props of the component.
18
+ */
19
+ export interface RawInputTextProps extends NativeInputProps, HasTheme, HasClassName {
20
+ value?: string;
21
+ onChange?: (value: string, name?: string, event?: SyntheticEvent) => void;
22
+ }
23
+ /**
24
+ * Component default props.
25
+ */
26
+ export const DEFAULT_PROPS: Partial<RawInputTextProps> = {
27
+ type: 'text',
28
+ };
29
+
30
+ /**
31
+ * Raw input text component
32
+ * (input element without any decoration)
33
+ */
34
+ export const RawInputText = forwardRef<RawInputTextProps, HTMLInputElement>((props, ref) => {
35
+ const defaultTheme = useTheme() || Theme.light;
36
+ const { className, theme = defaultTheme, value, onChange, type = DEFAULT_PROPS.type, ...forwardedProps } = props;
37
+ const textareaRef = useRef<HTMLInputElement>(null);
38
+
39
+ const handleChange: ChangeEventHandler<HTMLInputElement> = useCallback(
40
+ (evt) => {
41
+ onChange?.(evt.target.value, evt.target.name, evt);
42
+ },
43
+ [onChange],
44
+ );
45
+
46
+ return (
47
+ <input
48
+ {...forwardedProps}
49
+ type={type}
50
+ ref={useMergeRefs(ref, textareaRef)}
51
+ className={classNames(className, handleBasicClasses({ prefix: INPUT_NATIVE_CLASSNAME, theme }))}
52
+ onChange={handleChange}
53
+ value={value}
54
+ />
55
+ );
56
+ });
@@ -0,0 +1,22 @@
1
+ import { withValueOnChange } from '@lumx/react/stories/decorators/withValueOnChange';
2
+ import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
3
+
4
+ import { RawInputTextarea } from './RawInputTextarea';
5
+
6
+ export default {
7
+ title: 'LumX components/text-field/RawInputTextarea',
8
+ component: RawInputTextarea,
9
+ decorators: [withValueOnChange(), withWrapper({ style: { border: '1px dashed red' } })],
10
+ };
11
+
12
+ export const Default = {};
13
+
14
+ export const WithMinimumRows = {
15
+ args: { minimumRows: 3 },
16
+ };
17
+
18
+ export const WithPlaceholder = {
19
+ args: {
20
+ placeholder: 'Input placeholder',
21
+ },
22
+ };
@@ -0,0 +1,63 @@
1
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
2
+ import { render } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { getByClassName } from '@lumx/react/testing/utils/queries';
5
+
6
+ import { RawInputTextarea, RawInputTextareaProps, DEFAULT_PROPS } from './RawInputTextarea';
7
+ import { INPUT_NATIVE_CLASSNAME } from './constants';
8
+
9
+ /**
10
+ * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
11
+ */
12
+ const setup = (propsOverride: Partial<RawInputTextareaProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
13
+ const props: any = { ...propsOverride };
14
+ render(<RawInputTextarea {...props} />, { wrapper });
15
+ const textarea = getByClassName(document.body, INPUT_NATIVE_CLASSNAME);
16
+ return { props, textarea };
17
+ };
18
+
19
+ describe(`<${RawInputTextarea.displayName}>`, () => {
20
+ describe('Props', () => {
21
+ it('should render default', () => {
22
+ const { textarea } = setup();
23
+ expect(textarea).toBeInTheDocument();
24
+ expect(textarea?.tagName).toBe('TEXTAREA');
25
+ expect(textarea).toHaveAttribute('rows', String(DEFAULT_PROPS.minimumRows));
26
+ });
27
+
28
+ it('should render with custom minimumRows', () => {
29
+ const { textarea } = setup({ minimumRows: 5 });
30
+ expect(textarea).toHaveAttribute('rows', '5');
31
+ });
32
+
33
+ it('should render with placeholder', () => {
34
+ const { textarea } = setup({ placeholder: 'Test placeholder' });
35
+ expect(textarea).toHaveAttribute('placeholder', 'Test placeholder');
36
+ });
37
+ });
38
+
39
+ describe('Events', () => {
40
+ it('should call onChange with correct value when typing', async () => {
41
+ const onChange = vi.fn();
42
+ const name = 'textareaName';
43
+ const { textarea } = setup({ onChange, name });
44
+ await userEvent.type(textarea as Element, 'hello');
45
+ expect(onChange).toHaveBeenCalledWith('h', name, expect.any(Object));
46
+ expect(onChange).toHaveBeenCalledWith('hello', name, expect.any(Object));
47
+ });
48
+ });
49
+
50
+ // Common tests suite.
51
+ commonTestsSuiteRTL(setup, {
52
+ baseClassName: INPUT_NATIVE_CLASSNAME,
53
+ forwardClassName: 'textarea',
54
+ forwardAttributes: 'textarea',
55
+ forwardRef: 'textarea',
56
+ applyTheme: {
57
+ affects: [{ element: 'textarea' }],
58
+ viaProp: true,
59
+ viaContext: true,
60
+ defaultTheme: 'light',
61
+ },
62
+ });
63
+ });