@ultraviolet/ui 3.0.0-beta.27 → 3.0.0-beta.28

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 (319) hide show
  1. package/dist/components/ActionBar/index.js +19 -7
  2. package/dist/components/Alert/index.d.ts +2 -1
  3. package/dist/components/Alert/index.js +98 -20
  4. package/dist/components/Alert/styles.css.d.ts +10 -1
  5. package/dist/components/Alert/styles.css.js +7 -5
  6. package/dist/components/Avatar/index.d.ts +1 -1
  7. package/dist/components/Avatar/index.js +46 -36
  8. package/dist/components/Badge/index.d.ts +1 -1
  9. package/dist/components/Badge/index.js +19 -8
  10. package/dist/components/Banner/index.d.ts +1 -1
  11. package/dist/components/Banner/index.js +87 -28
  12. package/dist/components/BarChart/Tooltip.d.ts +1 -1
  13. package/dist/components/BarChart/Tooltip.js +23 -10
  14. package/dist/components/BarChart/index.d.ts +1 -1
  15. package/dist/components/BarChart/index.js +51 -31
  16. package/dist/components/BarStack/index.d.ts +1 -1
  17. package/dist/components/BarStack/index.js +64 -19
  18. package/dist/components/Breadcrumbs/components/Item.d.ts +1 -1
  19. package/dist/components/Breadcrumbs/components/Item.js +48 -12
  20. package/dist/components/Breadcrumbs/index.js +11 -2
  21. package/dist/components/Bullet/index.d.ts +1 -1
  22. package/dist/components/Bullet/index.js +10 -7
  23. package/dist/components/Button/index.js +122 -72
  24. package/dist/components/Card/index.js +80 -20
  25. package/dist/components/Carousel/index.d.ts +3 -3
  26. package/dist/components/Carousel/index.js +72 -26
  27. package/dist/components/Checkbox/index.js +139 -43
  28. package/dist/components/CheckboxGroup/index.d.ts +3 -3
  29. package/dist/components/CheckboxGroup/index.js +77 -24
  30. package/dist/components/Chip/ChipIcon.d.ts +1 -1
  31. package/dist/components/Chip/ChipIcon.js +46 -12
  32. package/dist/components/Chip/index.d.ts +3 -3
  33. package/dist/components/Chip/index.js +36 -11
  34. package/dist/components/CopyButton/index.d.ts +1 -1
  35. package/dist/components/CopyButton/index.js +23 -8
  36. package/dist/components/DateInput/components/CalendarContent.d.ts +1 -1
  37. package/dist/components/DateInput/components/CalendarContent.js +61 -26
  38. package/dist/components/DateInput/components/CalendarDaily.d.ts +1 -1
  39. package/dist/components/DateInput/components/CalendarDaily.js +105 -62
  40. package/dist/components/DateInput/components/CalendarMonthly.d.ts +1 -1
  41. package/dist/components/DateInput/components/CalendarMonthly.js +62 -39
  42. package/dist/components/DateInput/components/Popup.d.ts +1 -1
  43. package/dist/components/DateInput/components/Popup.js +27 -4
  44. package/dist/components/DateInput/helpers.js +9 -2
  45. package/dist/components/DateInput/helpersLocale.js +3 -9
  46. package/dist/components/DateInput/index.d.ts +1 -1
  47. package/dist/components/DateInput/index.js +193 -62
  48. package/dist/components/Dialog/Context.js +3 -1
  49. package/dist/components/Dialog/components/Button.d.ts +1 -1
  50. package/dist/components/Dialog/components/Button.js +12 -2
  51. package/dist/components/Dialog/components/Buttons.d.ts +1 -1
  52. package/dist/components/Dialog/components/Buttons.js +1 -1
  53. package/dist/components/Dialog/components/CancelButton.d.ts +1 -1
  54. package/dist/components/Dialog/components/CancelButton.js +12 -2
  55. package/dist/components/Dialog/components/Stack.d.ts +1 -1
  56. package/dist/components/Dialog/components/Stack.js +2 -5
  57. package/dist/components/Dialog/components/Text.d.ts +1 -1
  58. package/dist/components/Dialog/components/Text.js +2 -5
  59. package/dist/components/Dialog/index.d.ts +7 -7
  60. package/dist/components/Dialog/index.js +43 -12
  61. package/dist/components/Drawer/index.d.ts +4 -4
  62. package/dist/components/Drawer/index.js +53 -15
  63. package/dist/components/EmptyState/index.d.ts +1 -1
  64. package/dist/components/EmptyState/index.js +63 -21
  65. package/dist/components/Expandable/index.d.ts +2 -2
  66. package/dist/components/Expandable/index.js +52 -15
  67. package/dist/components/ExpandableCard/components/Title.d.ts +1 -1
  68. package/dist/components/ExpandableCard/components/Title.js +12 -2
  69. package/dist/components/ExpandableCard/index.d.ts +1 -1
  70. package/dist/components/ExpandableCard/index.js +197 -96
  71. package/dist/components/GlobalAlert/GlobalAlertLink.d.ts +1 -1
  72. package/dist/components/GlobalAlert/GlobalAlertLink.js +21 -5
  73. package/dist/components/GlobalAlert/index.d.ts +2 -2
  74. package/dist/components/GlobalAlert/index.js +51 -11
  75. package/dist/components/InfiniteScroll/index.d.ts +1 -1
  76. package/dist/components/InfiniteScroll/index.js +40 -33
  77. package/dist/components/Key/index.d.ts +1 -1
  78. package/dist/components/Key/index.js +29 -8
  79. package/dist/components/Label/index.d.ts +1 -1
  80. package/dist/components/Label/index.js +67 -6
  81. package/dist/components/LineChart/CustomLegend.d.ts +1 -1
  82. package/dist/components/LineChart/CustomLegend.js +69 -45
  83. package/dist/components/LineChart/Tooltip.d.ts +1 -1
  84. package/dist/components/LineChart/Tooltip.js +31 -9
  85. package/dist/components/LineChart/helpers.js +13 -12
  86. package/dist/components/LineChart/index.d.ts +1 -1
  87. package/dist/components/LineChart/index.js +56 -40
  88. package/dist/components/Link/index.js +74 -57
  89. package/dist/components/List/Cell.js +24 -22
  90. package/dist/components/List/ColumnProvider.d.ts +1 -1
  91. package/dist/components/List/ColumnProvider.js +12 -6
  92. package/dist/components/List/HeaderCell.d.ts +1 -1
  93. package/dist/components/List/HeaderCell.js +36 -19
  94. package/dist/components/List/HeaderRow.d.ts +1 -1
  95. package/dist/components/List/HeaderRow.js +14 -12
  96. package/dist/components/List/ListContext.d.ts +1 -1
  97. package/dist/components/List/ListContext.js +128 -78
  98. package/dist/components/List/Row.js +166 -90
  99. package/dist/components/List/SelectBar.d.ts +1 -1
  100. package/dist/components/List/SelectBar.js +20 -10
  101. package/dist/components/List/SkeletonRows.d.ts +1 -1
  102. package/dist/components/List/SkeletonRows.js +26 -16
  103. package/dist/components/List/index.d.ts +1 -1
  104. package/dist/components/List/index.js +60 -22
  105. package/dist/components/Loader/index.d.ts +1 -1
  106. package/dist/components/Loader/index.js +47 -23
  107. package/dist/components/Menu/MenuContent.d.ts +1 -1
  108. package/dist/components/Menu/MenuContent.js +216 -162
  109. package/dist/components/Menu/MenuProvider.d.ts +1 -1
  110. package/dist/components/Menu/MenuProvider.js +26 -13
  111. package/dist/components/Menu/components/Group.d.ts +1 -1
  112. package/dist/components/Menu/components/Group.js +11 -2
  113. package/dist/components/Menu/components/Item.js +144 -82
  114. package/dist/components/Menu/helpers.js +3 -1
  115. package/dist/components/Menu/index.d.ts +2 -2
  116. package/dist/components/Menu/index.js +5 -11
  117. package/dist/components/Menu/types.d.ts +2 -2
  118. package/dist/components/Meter/index.d.ts +1 -1
  119. package/dist/components/Meter/index.js +43 -12
  120. package/dist/components/Modal/ModalContent.d.ts +1 -1
  121. package/dist/components/Modal/ModalContent.js +41 -11
  122. package/dist/components/Modal/ModalProvider.d.ts +1 -1
  123. package/dist/components/Modal/ModalProvider.js +14 -11
  124. package/dist/components/Modal/components/Dialog.js +91 -47
  125. package/dist/components/Modal/index.d.ts +1 -1
  126. package/dist/components/Modal/index.js +60 -3
  127. package/dist/components/Notice/index.d.ts +1 -1
  128. package/dist/components/Notice/index.js +24 -5
  129. package/dist/components/Notification/Notification.js +12 -2
  130. package/dist/components/Notification/NotificationContainer.d.ts +1 -1
  131. package/dist/components/Notification/NotificationContainer.js +18 -2
  132. package/dist/components/NumberInput/index.d.ts +1 -1
  133. package/dist/components/NumberInput/index.js +239 -130
  134. package/dist/components/Pagination/PaginationButtons.d.ts +1 -1
  135. package/dist/components/Pagination/PaginationButtons.js +75 -10
  136. package/dist/components/Pagination/PerPage.d.ts +1 -1
  137. package/dist/components/Pagination/PerPage.js +32 -17
  138. package/dist/components/Pagination/getPageNumbers.js +12 -13
  139. package/dist/components/Pagination/index.d.ts +1 -1
  140. package/dist/components/Pagination/index.js +26 -3
  141. package/dist/components/PasswordCheck/index.d.ts +1 -1
  142. package/dist/components/PasswordCheck/index.js +27 -5
  143. package/dist/components/PieChart/Legends.d.ts +1 -1
  144. package/dist/components/PieChart/Legends.js +52 -20
  145. package/dist/components/PieChart/Tooltip.d.ts +1 -1
  146. package/dist/components/PieChart/Tooltip.js +2 -4
  147. package/dist/components/PieChart/index.d.ts +1 -1
  148. package/dist/components/PieChart/index.js +80 -40
  149. package/dist/components/Popover/index.js +104 -46
  150. package/dist/components/Popup/helpers.d.ts +5 -1
  151. package/dist/components/Popup/helpers.js +49 -35
  152. package/dist/components/Popup/index.js +344 -254
  153. package/dist/components/Popup/styles.css.js +0 -1
  154. package/dist/components/Popup/variables.css.js +1 -0
  155. package/dist/components/ProgressBar/index.d.ts +1 -1
  156. package/dist/components/ProgressBar/index.js +74 -20
  157. package/dist/components/ProgressBar/styles.css.js +1 -0
  158. package/dist/components/ProgressBar/variables.css.js +0 -1
  159. package/dist/components/Radio/index.js +83 -51
  160. package/dist/components/RadioGroup/index.d.ts +2 -2
  161. package/dist/components/RadioGroup/index.js +74 -20
  162. package/dist/components/Row/index.d.ts +1 -1
  163. package/dist/components/Row/index.js +38 -27
  164. package/dist/components/SearchInput/KeyGroup.d.ts +1 -1
  165. package/dist/components/SearchInput/KeyGroup.js +2 -6
  166. package/dist/components/SearchInput/index.js +232 -164
  167. package/dist/components/SelectInput/SelectInputProvider.d.ts +1 -1
  168. package/dist/components/SelectInput/SelectInputProvider.js +91 -55
  169. package/dist/components/SelectInput/components/Dropdown.d.ts +1 -1
  170. package/dist/components/SelectInput/components/Dropdown.js +408 -95
  171. package/dist/components/SelectInput/components/DropdownOption.d.ts +1 -1
  172. package/dist/components/SelectInput/components/DropdownOption.js +176 -27
  173. package/dist/components/SelectInput/components/SearchBarDropdown.d.ts +1 -1
  174. package/dist/components/SelectInput/components/SearchBarDropdown.js +40 -14
  175. package/dist/components/SelectInput/components/SelectBar.d.ts +1 -1
  176. package/dist/components/SelectInput/components/SelectBar.js +252 -97
  177. package/dist/components/SelectInput/index.d.ts +1 -1
  178. package/dist/components/SelectInput/index.js +102 -10
  179. package/dist/components/SelectableCard/index.js +200 -114
  180. package/dist/components/SelectableCardGroup/index.d.ts +2 -2
  181. package/dist/components/SelectableCardGroup/index.js +67 -25
  182. package/dist/components/SelectableCardOptionGroup/Provider.js +3 -1
  183. package/dist/components/SelectableCardOptionGroup/components/Image.d.ts +1 -1
  184. package/dist/components/SelectableCardOptionGroup/components/Image.js +12 -8
  185. package/dist/components/SelectableCardOptionGroup/components/Option.d.ts +1 -1
  186. package/dist/components/SelectableCardOptionGroup/components/Option.js +96 -19
  187. package/dist/components/SelectableCardOptionGroup/index.d.ts +2 -2
  188. package/dist/components/SelectableCardOptionGroup/index.js +53 -17
  189. package/dist/components/Separator/index.d.ts +1 -1
  190. package/dist/components/Separator/index.js +43 -26
  191. package/dist/components/Skeleton/Block.d.ts +1 -1
  192. package/dist/components/Skeleton/Block.js +2 -6
  193. package/dist/components/Skeleton/Blocks.d.ts +1 -1
  194. package/dist/components/Skeleton/Blocks.js +14 -9
  195. package/dist/components/Skeleton/BoxWithIcon.d.ts +1 -1
  196. package/dist/components/Skeleton/BoxWithIcon.js +14 -9
  197. package/dist/components/Skeleton/Donut.d.ts +1 -1
  198. package/dist/components/Skeleton/Donut.js +10 -2
  199. package/dist/components/Skeleton/IconSkeleton.d.ts +1 -1
  200. package/dist/components/Skeleton/IconSkeleton.js +1 -1
  201. package/dist/components/Skeleton/Line.d.ts +1 -1
  202. package/dist/components/Skeleton/Line.js +10 -4
  203. package/dist/components/Skeleton/List.d.ts +1 -1
  204. package/dist/components/Skeleton/List.js +3 -9
  205. package/dist/components/Skeleton/Slider.d.ts +1 -1
  206. package/dist/components/Skeleton/Slider.js +11 -8
  207. package/dist/components/Skeleton/Square.d.ts +1 -1
  208. package/dist/components/Skeleton/Square.js +1 -1
  209. package/dist/components/Skeleton/index.d.ts +9 -9
  210. package/dist/components/Skeleton/index.js +16 -5
  211. package/dist/components/Slider/components/DoubleSlider.d.ts +1 -1
  212. package/dist/components/Slider/components/DoubleSlider.js +191 -88
  213. package/dist/components/Slider/components/Options.d.ts +1 -1
  214. package/dist/components/Slider/components/Options.js +44 -28
  215. package/dist/components/Slider/components/SingleSlider.d.ts +1 -1
  216. package/dist/components/Slider/components/SingleSlider.js +133 -53
  217. package/dist/components/Slider/index.d.ts +1 -1
  218. package/dist/components/Slider/index.js +82 -12
  219. package/dist/components/Snippet/index.d.ts +1 -1
  220. package/dist/components/Snippet/index.js +103 -19
  221. package/dist/components/Stack/index.d.ts +1 -1
  222. package/dist/components/Stack/index.js +20 -24
  223. package/dist/components/Status/index.d.ts +1 -1
  224. package/dist/components/Status/index.js +13 -11
  225. package/dist/components/StepList/index.d.ts +2 -2
  226. package/dist/components/StepList/index.js +31 -10
  227. package/dist/components/Stepper/Step.d.ts +1 -1
  228. package/dist/components/Stepper/Step.js +65 -30
  229. package/dist/components/Stepper/StepperProvider.d.ts +1 -1
  230. package/dist/components/Stepper/StepperProvider.js +13 -10
  231. package/dist/components/Stepper/index.d.ts +2 -2
  232. package/dist/components/Stepper/index.js +46 -26
  233. package/dist/components/SwitchButton/FocusOverlay.d.ts +1 -1
  234. package/dist/components/SwitchButton/FocusOverlay.js +11 -5
  235. package/dist/components/SwitchButton/Option.d.ts +1 -1
  236. package/dist/components/SwitchButton/Option.js +20 -2
  237. package/dist/components/SwitchButton/index.d.ts +2 -2
  238. package/dist/components/SwitchButton/index.js +95 -48
  239. package/dist/components/Table/Body.d.ts +1 -1
  240. package/dist/components/Table/Body.js +2 -4
  241. package/dist/components/Table/Cell.d.ts +1 -1
  242. package/dist/components/Table/Cell.js +20 -17
  243. package/dist/components/Table/Header.d.ts +1 -1
  244. package/dist/components/Table/Header.js +2 -4
  245. package/dist/components/Table/HeaderCell.d.ts +1 -1
  246. package/dist/components/Table/HeaderCell.js +46 -22
  247. package/dist/components/Table/HeaderRow.d.ts +1 -1
  248. package/dist/components/Table/HeaderRow.js +21 -12
  249. package/dist/components/Table/Row.d.ts +1 -1
  250. package/dist/components/Table/Row.js +70 -14
  251. package/dist/components/Table/SelectBar.d.ts +1 -1
  252. package/dist/components/Table/SelectBar.js +20 -10
  253. package/dist/components/Table/SkeletonRows.d.ts +1 -1
  254. package/dist/components/Table/SkeletonRows.js +17 -16
  255. package/dist/components/Table/TableContext.d.ts +1 -1
  256. package/dist/components/Table/TableContext.js +22 -13
  257. package/dist/components/Table/index.d.ts +6 -6
  258. package/dist/components/Table/index.js +64 -23
  259. package/dist/components/Tabs/Tab.js +79 -41
  260. package/dist/components/Tabs/TabMenu.js +39 -23
  261. package/dist/components/Tabs/TabMenuItem.d.ts +1 -1
  262. package/dist/components/Tabs/TabMenuItem.js +20 -11
  263. package/dist/components/Tabs/TabsContext.js +3 -1
  264. package/dist/components/Tabs/index.d.ts +3 -3
  265. package/dist/components/Tabs/index.js +34 -14
  266. package/dist/components/Tag/index.d.ts +1 -1
  267. package/dist/components/Tag/index.js +45 -12
  268. package/dist/components/TagInput/index.d.ts +1 -1
  269. package/dist/components/TagInput/index.js +131 -52
  270. package/dist/components/TagInput/styles.css.d.ts +3 -0
  271. package/dist/components/TagList/index.d.ts +1 -1
  272. package/dist/components/TagList/index.js +132 -59
  273. package/dist/components/Text/index.d.ts +1 -1
  274. package/dist/components/Text/index.js +21 -17
  275. package/dist/components/Text/style.css.js +0 -1
  276. package/dist/components/Text/variables.css.js +1 -0
  277. package/dist/components/TextArea/index.js +178 -103
  278. package/dist/components/TextInput/index.d.ts +1 -1
  279. package/dist/components/TextInput/index.js +286 -106
  280. package/dist/components/TimeInput/constants.js +1 -5
  281. package/dist/components/TimeInput/index.d.ts +1 -1
  282. package/dist/components/TimeInput/index.js +207 -118
  283. package/dist/components/Toaster/Toaster.js +1 -1
  284. package/dist/components/Toaster/ToasterContainer.d.ts +1 -1
  285. package/dist/components/Toaster/ToasterContainer.js +21 -2
  286. package/dist/components/Toaster/components/Button.d.ts +1 -1
  287. package/dist/components/Toaster/components/CloseButton.d.ts +1 -1
  288. package/dist/components/Toaster/components/CloseButton.js +12 -2
  289. package/dist/components/Toaster/components/Content.d.ts +1 -1
  290. package/dist/components/Toaster/components/Content.js +2 -4
  291. package/dist/components/Toaster/components/Link.d.ts +1 -1
  292. package/dist/components/Toaster/index.d.ts +2 -2
  293. package/dist/components/Toggle/index.js +101 -40
  294. package/dist/components/ToggleGroup/index.d.ts +3 -3
  295. package/dist/components/ToggleGroup/index.js +61 -22
  296. package/dist/components/Tooltip/index.js +42 -19
  297. package/dist/components/TreeMapChart/Tooltip.d.ts +1 -1
  298. package/dist/components/TreeMapChart/Tooltip.js +1 -1
  299. package/dist/components/TreeMapChart/index.d.ts +1 -1
  300. package/dist/components/TreeMapChart/index.js +33 -27
  301. package/dist/components/UnitInput/index.d.ts +1 -1
  302. package/dist/components/UnitInput/index.js +110 -29
  303. package/dist/components/VerificationCode/index.d.ts +1 -1
  304. package/dist/components/VerificationCode/index.js +80 -21
  305. package/dist/helpers/legend.js +4 -4
  306. package/dist/helpers/treeMap.d.ts +2 -1
  307. package/dist/index.d.ts +1 -1
  308. package/dist/index.js +2 -4
  309. package/dist/theme/ThemeProvider.d.ts +1 -1
  310. package/dist/theme/ThemeProvider.js +4 -2
  311. package/dist/theme/index.js +1 -8
  312. package/dist/ui.css +1 -1
  313. package/dist/utils/ids.js +1 -3
  314. package/dist/utils/index.d.ts +1 -1
  315. package/dist/utils/responsive/index.d.ts +0 -1
  316. package/dist/utils/responsive/style.css.d.ts +3 -0
  317. package/package.json +2 -7
  318. package/dist/utils/responsive/Breakpoint.d.ts +0 -9
  319. package/dist/utils/responsive/Breakpoint.js +0 -14
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs, jsx } from "@emotion/react/jsx-runtime";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import { assignInlineVars } from "@vanilla-extract/dynamic";
4
4
  import { useRef, useState, useMemo, useEffect } from "react";
5
5
  import { Popover } from "../Popover/index.js";
@@ -37,7 +37,10 @@ const TagList = ({
37
37
  while (tmpThreshold2 > 1 && tags.length > 0 && tags.slice(0, tmpThreshold2).reduce((acc, tag) => acc + getTagLabel(tag), "").length > maxLength) {
38
38
  tmpThreshold2 -= 1;
39
39
  }
40
- const potentiallyVisibleTagsLength = Math.max(1, tags.length > tmpThreshold2 || false ? tmpThreshold2 : tags.length);
40
+ const potentiallyVisibleTagsLength = Math.max(
41
+ 1,
42
+ tags.length > tmpThreshold2 || false ? tmpThreshold2 : tags.length
43
+ );
41
44
  const potentiallyVisibleTags2 = tags.slice(0, potentiallyVisibleTagsLength);
42
45
  const surelyHiddenTags2 = tags.slice(potentiallyVisibleTagsLength);
43
46
  return {
@@ -46,11 +49,7 @@ const TagList = ({
46
49
  tmpThreshold: tmpThreshold2
47
50
  };
48
51
  }, [maxLength, tags, threshold]);
49
- const {
50
- tmpThreshold,
51
- potentiallyVisibleTags,
52
- surelyHiddenTags
53
- } = memoizedResult;
52
+ const { tmpThreshold, potentiallyVisibleTags, surelyHiddenTags } = memoizedResult;
54
53
  useEffect(() => {
55
54
  if (tags.length === 0 || !containerRef.current || !measureRef.current) {
56
55
  return;
@@ -64,29 +63,42 @@ const TagList = ({
64
63
  const parentWidth = containerRef.current.parentElement?.offsetWidth || 0;
65
64
  const toMeasureElements = measureRef.current.children[0].children;
66
65
  const [firstTag, ...restOfToMeasureElements] = [...toMeasureElements];
67
- const {
68
- measuredVisibleTags,
69
- measuredHiddenTags
70
- } = restOfToMeasureElements.reduce((accumulator, currentValue, index) => {
71
- const newAccumulatedWidth = accumulator.accumulatedWidth + currentValue.offsetWidth + Number.parseInt(TAGS_GAP, 10);
72
- return {
73
- accumulatedWidth: newAccumulatedWidth,
74
- measuredHiddenTags: [...accumulator.measuredHiddenTags, newAccumulatedWidth > parentWidth && tags[index + 1]].filter(Boolean),
75
- measuredVisibleTags: [...accumulator.measuredVisibleTags, newAccumulatedWidth <= parentWidth && tags[index + 1]].filter(Boolean)
76
- };
77
- }, {
78
- accumulatedWidth: firstTag.offsetWidth + Number.parseInt(TAGS_GAP, 10),
79
- measuredHiddenTags: [],
80
- measuredVisibleTags: [tags[0]]
81
- // we need to always show one tag
82
- });
66
+ const { measuredVisibleTags, measuredHiddenTags } = restOfToMeasureElements.reduce(
67
+ (accumulator, currentValue, index) => {
68
+ const newAccumulatedWidth = accumulator.accumulatedWidth + currentValue.offsetWidth + Number.parseInt(TAGS_GAP, 10);
69
+ return {
70
+ accumulatedWidth: newAccumulatedWidth,
71
+ measuredHiddenTags: [
72
+ ...accumulator.measuredHiddenTags,
73
+ newAccumulatedWidth > parentWidth && tags[index + 1]
74
+ ].filter(Boolean),
75
+ measuredVisibleTags: [
76
+ ...accumulator.measuredVisibleTags,
77
+ newAccumulatedWidth <= parentWidth && tags[index + 1]
78
+ ].filter(Boolean)
79
+ };
80
+ },
81
+ {
82
+ accumulatedWidth: firstTag.offsetWidth + Number.parseInt(TAGS_GAP, 10),
83
+ measuredHiddenTags: [],
84
+ measuredVisibleTags: [tags[0]]
85
+ // we need to always show one tag
86
+ }
87
+ );
83
88
  const finalHiddenTags = [...measuredHiddenTags, ...surelyHiddenTags];
84
89
  setVisibleTags(measuredVisibleTags);
85
90
  setHiddenTags(finalHiddenTags);
86
91
  if (finalHiddenTags.length === 0) {
87
92
  setIsReady(true);
88
93
  }
89
- }, [multiline, potentiallyVisibleTags, surelyHiddenTags, tags, threshold, tmpThreshold]);
94
+ }, [
95
+ multiline,
96
+ potentiallyVisibleTags,
97
+ surelyHiddenTags,
98
+ tags,
99
+ threshold,
100
+ tmpThreshold
101
+ ]);
90
102
  useEffect(() => {
91
103
  if (!isReady && popoverTriggerRef.current?.offsetWidth) {
92
104
  const newPopoverTriggerWidth = popoverTriggerRef.current.offsetWidth;
@@ -95,8 +107,10 @@ const TagList = ({
95
107
  const tagsContainerWidth = containerRef.current?.offsetWidth || 0;
96
108
  const parentWidth = tagsContainer?.parentElement?.offsetWidth || 0;
97
109
  if (visibleTags.length > 1 && hiddenTags.length > 0 && tagsContainerWidth + newPopoverTriggerWidth > parentWidth) {
98
- const visibleTagsCopy = visibleTags.filter((_, index) => index < visibleTags.length - 1);
99
- const tagToMove = visibleTags[visibleTags.length - 1] ?? "";
110
+ const visibleTagsCopy = visibleTags.filter(
111
+ (_, index) => index < visibleTags.length - 1
112
+ );
113
+ const tagToMove = visibleTags.at(-1) ?? "";
100
114
  setVisibleTags(visibleTagsCopy);
101
115
  setHiddenTags([tagToMove, ...hiddenTags]);
102
116
  }
@@ -124,39 +138,98 @@ const TagList = ({
124
138
  ]
125
139
  },
126
140
  `${getTagLabel(tag)}-${index}`
127
- ) : /* @__PURE__ */ jsx(Tag, { className: isEllipsis ? "ellipsed" : "", copiable, copiedText, copyText, children: getTagLabel(tag) }, `${getTagLabel(tag)}-${index}`);
128
- return /* @__PURE__ */ jsxs("div", { className: `${className ? `${className} ` : ""}${tagListContainer}`, "data-testid": dataTestId, style: {
129
- visibility: isReady ? "visible" : "hidden",
130
- ...style
131
- }, children: [
132
- /* @__PURE__ */ jsx("div", { className: `${tagContainer({
133
- multiline
134
- })} ${visibleTags.length === 1 && hiddenTags.length === 0 || popoverTriggerWidth ? ellipsisContainer : ""}`, "data-testid": `${dataTestId ?? "taglist"}-container`, ref: containerRef, style: assignInlineVars({
135
- [popoverTriggerWidthVar]: `${popoverTriggerWidth || 0}px`
136
- }), children: visibleTags.map((tag, index) => renderTag(
137
- tag,
138
- index,
139
- // add ellipsis to last tag
140
- index === visibleTags.length - 1
141
- )) }),
142
- /* @__PURE__ */ jsx("div", { ref: measureRef, style: {
143
- position: "absolute",
144
- visibility: "hidden",
145
- whiteSpace: "nowrap"
146
- }, children: /* @__PURE__ */ jsx("div", { className: tagContainer({
147
- multiline
148
- }), "data-testid": `${dataTestId ?? "taglist"}-measure-container`, children: potentiallyVisibleTags.map((tag, index) => renderTag(tag, index)) }) }),
149
- hiddenTags.length > 0 && /* @__PURE__ */ jsx(Popover, { content: /* @__PURE__ */ jsx("div", { className: tagContainer({
150
- multiline: true
151
- }), children: hiddenTags.map((tag, index) => renderTag(tag, index)) }), maxHeight: popoverMaxHeight, onClose: () => setIsPopoverVisible(false), placement: popoverPlacement, size: "small", title: popoverTitle, visible: isPopoverVisible, children: /* @__PURE__ */ jsxs("span", { className: tagsWrapper, "data-testid": `${dataTestId ?? "taglist"}-open`, onClick: () => setIsPopoverVisible(true), onKeyDown: (event) => {
152
- if ([" ", "Enter"].includes(event.key)) {
153
- setIsPopoverVisible(true);
154
- }
155
- }, ref: popoverTriggerRef, tabIndex: 0, children: [
156
- "+",
157
- hiddenTags.length
158
- ] }) })
159
- ] });
141
+ ) : /* @__PURE__ */ jsx(
142
+ Tag,
143
+ {
144
+ className: isEllipsis ? "ellipsed" : "",
145
+ copiable,
146
+ copiedText,
147
+ copyText,
148
+ children: getTagLabel(tag)
149
+ },
150
+ `${getTagLabel(tag)}-${index}`
151
+ );
152
+ return /* @__PURE__ */ jsxs(
153
+ "div",
154
+ {
155
+ className: `${className ? `${className} ` : ""}${tagListContainer}`,
156
+ "data-testid": dataTestId,
157
+ style: { visibility: isReady ? "visible" : "hidden", ...style },
158
+ children: [
159
+ /* @__PURE__ */ jsx(
160
+ "div",
161
+ {
162
+ className: `${tagContainer({
163
+ multiline
164
+ })} ${visibleTags.length === 1 && hiddenTags.length === 0 || popoverTriggerWidth ? ellipsisContainer : ""}`,
165
+ "data-testid": `${dataTestId ?? "taglist"}-container`,
166
+ ref: containerRef,
167
+ style: assignInlineVars({
168
+ [popoverTriggerWidthVar]: `${popoverTriggerWidth || 0}px`
169
+ }),
170
+ children: visibleTags.map(
171
+ (tag, index) => renderTag(
172
+ tag,
173
+ index,
174
+ // add ellipsis to last tag
175
+ index === visibleTags.length - 1
176
+ )
177
+ )
178
+ }
179
+ ),
180
+ /* @__PURE__ */ jsx(
181
+ "div",
182
+ {
183
+ ref: measureRef,
184
+ style: {
185
+ position: "absolute",
186
+ visibility: "hidden",
187
+ whiteSpace: "nowrap"
188
+ },
189
+ children: /* @__PURE__ */ jsx(
190
+ "div",
191
+ {
192
+ className: tagContainer({ multiline }),
193
+ "data-testid": `${dataTestId ?? "taglist"}-measure-container`,
194
+ children: potentiallyVisibleTags.map((tag, index) => renderTag(tag, index))
195
+ }
196
+ )
197
+ }
198
+ ),
199
+ hiddenTags.length > 0 && /* @__PURE__ */ jsx(
200
+ Popover,
201
+ {
202
+ content: /* @__PURE__ */ jsx("div", { className: tagContainer({ multiline: true }), children: hiddenTags.map((tag, index) => renderTag(tag, index)) }),
203
+ maxHeight: popoverMaxHeight,
204
+ onClose: () => setIsPopoverVisible(false),
205
+ placement: popoverPlacement,
206
+ size: "small",
207
+ title: popoverTitle,
208
+ visible: isPopoverVisible,
209
+ children: /* @__PURE__ */ jsxs(
210
+ "span",
211
+ {
212
+ className: tagsWrapper,
213
+ "data-testid": `${dataTestId ?? "taglist"}-open`,
214
+ onClick: () => setIsPopoverVisible(true),
215
+ onKeyDown: (event) => {
216
+ if ([" ", "Enter"].includes(event.key)) {
217
+ setIsPopoverVisible(true);
218
+ }
219
+ },
220
+ ref: popoverTriggerRef,
221
+ tabIndex: 0,
222
+ children: [
223
+ "+",
224
+ hiddenTags.length
225
+ ]
226
+ }
227
+ )
228
+ }
229
+ )
230
+ ]
231
+ }
232
+ );
160
233
  };
161
234
  export {
162
235
  TagList
@@ -28,5 +28,5 @@ type TextProps = {
28
28
  /**
29
29
  * Text component is used to display text with different variants and sentiments.
30
30
  */
31
- export declare const Text: ({ variant, children, as: Component, sentiment, oneLine, placement, prominence, className, disabled, italic, underline, strikeThrough, id, dir, whiteSpace, htmlFor, "data-testid": dataTestId, "aria-hidden": ariaHidden, style, }: TextProps) => import("@emotion/react/jsx-runtime").JSX.Element;
31
+ export declare const Text: ({ variant, children, as: Component, sentiment, oneLine, placement, prominence, className, disabled, italic, underline, strikeThrough, id, dir, whiteSpace, htmlFor, "data-testid": dataTestId, "aria-hidden": ariaHidden, style, }: TextProps) => import("react/jsx-runtime").JSX.Element;
32
32
  export {};
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { jsx } from "react/jsx-runtime";
3
3
  import { assignInlineVars } from "@vanilla-extract/dynamic";
4
4
  import { useRef } from "react";
5
5
  import recursivelyGetChildrenString from "../../helpers/recursivelyGetChildrenString.js";
@@ -31,22 +31,26 @@ const Text = ({
31
31
  const elementRef = useRef(null);
32
32
  const isOverflowing = useIsOverflowing(elementRef);
33
33
  const finalStringChildren = recursivelyGetChildrenString(children);
34
- return /* @__PURE__ */ jsx(Tooltip, { text: oneLine && isOverflowing ? finalStringChildren : "", children: /* @__PURE__ */ jsx(Component, { "aria-hidden": ariaHidden, className: `${className ? `${className} ` : ""}${text({
35
- disabled,
36
- italic,
37
- oneLine,
38
- prominence,
39
- sentiment,
40
- strikeThrough,
41
- underline,
42
- variant
43
- })}`, "data-testid": dataTestId, dir, htmlFor, id, ref: elementRef, style: {
44
- ...assignInlineVars({
45
- [placementText]: placement,
46
- [whiteSpaceText]: whiteSpace
47
- }),
48
- ...style
49
- }, children }) });
34
+ return /* @__PURE__ */ jsx(Tooltip, { text: oneLine && isOverflowing ? finalStringChildren : "", children: /* @__PURE__ */ jsx(
35
+ Component,
36
+ {
37
+ "aria-hidden": ariaHidden,
38
+ className: `${className ? `${className} ` : ""}${text({ disabled, italic, oneLine, prominence, sentiment, strikeThrough, underline, variant })}`,
39
+ "data-testid": dataTestId,
40
+ dir,
41
+ htmlFor,
42
+ id,
43
+ ref: elementRef,
44
+ style: {
45
+ ...assignInlineVars({
46
+ [placementText]: placement,
47
+ [whiteSpaceText]: whiteSpace
48
+ }),
49
+ ...style
50
+ },
51
+ children
52
+ }
53
+ ) });
50
54
  };
51
55
  export {
52
56
  Text
@@ -1,4 +1,3 @@
1
- /* empty css */
2
1
  /* empty css */
3
2
  import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
4
3
  var text = createRuntimeFn({ defaultClassName: "uv_m4c9ow0", variantClassNames: { strikeThrough: { true: "uv_m4c9ow1", false: "uv_m4c9ow2" }, italic: { true: "uv_m4c9ow3", false: "uv_m4c9ow4" }, underline: { true: "uv_m4c9ow5", false: "uv_m4c9ow6" }, oneLine: { true: "uv_m4c9ow7", false: "uv_m4c9ow8" }, sentiment: { primary: "uv_m4c9ow9", secondary: "uv_m4c9owa", neutral: "uv_m4c9owb", success: "uv_m4c9owc", danger: "uv_m4c9owd", warning: "uv_m4c9owe", info: "uv_m4c9owf", black: "uv_m4c9owg", white: "uv_m4c9owh" }, prominence: { "default": "uv_m4c9owi", strong: "uv_m4c9owj", stronger: "uv_m4c9owk", weak: "uv_m4c9owl" }, variant: { body: "uv_m4c9owm", bodySmall: "uv_m4c9own", bodySmallStrong: "uv_m4c9owo", bodySmallStronger: "uv_m4c9owp", bodyStrong: "uv_m4c9owq", bodyStronger: "uv_m4c9owr", caption: "uv_m4c9ows", captionSmall: "uv_m4c9owt", captionSmallStrong: "uv_m4c9owu", captionSmallStronger: "uv_m4c9owv", captionStrong: "uv_m4c9oww", captionStronger: "uv_m4c9owx", code: "uv_m4c9owy", codeStrong: "uv_m4c9owz", codeStronger: "uv_m4c9ow10", heading: "uv_m4c9ow11", headingLarge: "uv_m4c9ow12", headingLargeStrong: "uv_m4c9ow13", headingLargeStronger: "uv_m4c9ow14", headingSmall: "uv_m4c9ow15", headingSmallStrong: "uv_m4c9ow16", headingSmallStronger: "uv_m4c9ow17", headingStrong: "uv_m4c9ow18", headingStronger: "uv_m4c9ow19" }, disabled: { true: "uv_m4c9ow1a", false: "uv_m4c9ow1b" } }, defaultVariants: { strikeThrough: false, italic: false, underline: false, oneLine: false, sentiment: void 0, prominence: "default", variant: "body", disabled: false }, compoundVariants: [[{ sentiment: "primary", prominence: "default", disabled: false }, "uv_m4c9ow1c"], [{ sentiment: "primary", prominence: "strong", disabled: false }, "uv_m4c9ow1d"], [{ sentiment: "primary", prominence: "stronger", disabled: false }, "uv_m4c9ow1e"], [{ sentiment: "primary", prominence: "weak", disabled: false }, "uv_m4c9ow1f"], [{ sentiment: "secondary", prominence: "default", disabled: false }, "uv_m4c9ow1g"], [{ sentiment: "secondary", prominence: "strong", disabled: false }, "uv_m4c9ow1h"], [{ sentiment: "secondary", prominence: "stronger", disabled: false }, "uv_m4c9ow1i"], [{ sentiment: "secondary", prominence: "weak", disabled: false }, "uv_m4c9ow1j"], [{ sentiment: "danger", prominence: "default", disabled: false }, "uv_m4c9ow1k"], [{ sentiment: "danger", prominence: "strong", disabled: false }, "uv_m4c9ow1l"], [{ sentiment: "danger", prominence: "stronger", disabled: false }, "uv_m4c9ow1m"], [{ sentiment: "danger", prominence: "weak", disabled: false }, "uv_m4c9ow1n"], [{ sentiment: "info", prominence: "default", disabled: false }, "uv_m4c9ow1o"], [{ sentiment: "info", prominence: "strong", disabled: false }, "uv_m4c9ow1p"], [{ sentiment: "info", prominence: "stronger", disabled: false }, "uv_m4c9ow1q"], [{ sentiment: "info", prominence: "weak", disabled: false }, "uv_m4c9ow1r"], [{ sentiment: "success", prominence: "default", disabled: false }, "uv_m4c9ow1s"], [{ sentiment: "success", prominence: "strong", disabled: false }, "uv_m4c9ow1t"], [{ sentiment: "success", prominence: "stronger", disabled: false }, "uv_m4c9ow1u"], [{ sentiment: "success", prominence: "weak", disabled: false }, "uv_m4c9ow1v"], [{ sentiment: "warning", prominence: "default", disabled: false }, "uv_m4c9ow1w"], [{ sentiment: "warning", prominence: "strong", disabled: false }, "uv_m4c9ow1x"], [{ sentiment: "warning", prominence: "stronger", disabled: false }, "uv_m4c9ow1y"], [{ sentiment: "warning", prominence: "weak", disabled: false }, "uv_m4c9ow1z"], [{ sentiment: "neutral", prominence: "default", disabled: false }, "uv_m4c9ow20"], [{ sentiment: "neutral", prominence: "strong", disabled: false }, "uv_m4c9ow21"], [{ sentiment: "neutral", prominence: "stronger", disabled: false }, "uv_m4c9ow22"], [{ sentiment: "neutral", prominence: "weak", disabled: false }, "uv_m4c9ow23"], [{ sentiment: "black", prominence: "default", disabled: false }, "uv_m4c9ow24"], [{ sentiment: "black", prominence: "strong", disabled: false }, "uv_m4c9ow25"], [{ sentiment: "black", prominence: "stronger", disabled: false }, "uv_m4c9ow26"], [{ sentiment: "black", prominence: "weak", disabled: false }, "uv_m4c9ow27"], [{ sentiment: "white", prominence: "default", disabled: false }, "uv_m4c9ow28"], [{ sentiment: "white", prominence: "strong", disabled: false }, "uv_m4c9ow29"], [{ sentiment: "white", prominence: "stronger", disabled: false }, "uv_m4c9ow2a"], [{ sentiment: "white", prominence: "weak", disabled: false }, "uv_m4c9ow2b"], [{ sentiment: "primary", prominence: "default", disabled: true }, "uv_m4c9ow2c"], [{ sentiment: "primary", prominence: "strong", disabled: true }, "uv_m4c9ow2d"], [{ sentiment: "primary", prominence: "stronger", disabled: true }, "uv_m4c9ow2e"], [{ sentiment: "primary", prominence: "weak", disabled: true }, "uv_m4c9ow2f"], [{ sentiment: "secondary", prominence: "default", disabled: true }, "uv_m4c9ow2g"], [{ sentiment: "secondary", prominence: "strong", disabled: true }, "uv_m4c9ow2h"], [{ sentiment: "secondary", prominence: "stronger", disabled: true }, "uv_m4c9ow2i"], [{ sentiment: "secondary", prominence: "weak", disabled: true }, "uv_m4c9ow2j"], [{ sentiment: "danger", prominence: "default", disabled: true }, "uv_m4c9ow2k"], [{ sentiment: "danger", prominence: "strong", disabled: true }, "uv_m4c9ow2l"], [{ sentiment: "danger", prominence: "stronger", disabled: true }, "uv_m4c9ow2m"], [{ sentiment: "danger", prominence: "weak", disabled: true }, "uv_m4c9ow2n"], [{ sentiment: "info", prominence: "default", disabled: true }, "uv_m4c9ow2o"], [{ sentiment: "info", prominence: "strong", disabled: true }, "uv_m4c9ow2p"], [{ sentiment: "info", prominence: "stronger", disabled: true }, "uv_m4c9ow2q"], [{ sentiment: "info", prominence: "weak", disabled: true }, "uv_m4c9ow2r"], [{ sentiment: "success", prominence: "default", disabled: true }, "uv_m4c9ow2s"], [{ sentiment: "success", prominence: "strong", disabled: true }, "uv_m4c9ow2t"], [{ sentiment: "success", prominence: "stronger", disabled: true }, "uv_m4c9ow2u"], [{ sentiment: "success", prominence: "weak", disabled: true }, "uv_m4c9ow2v"], [{ sentiment: "warning", prominence: "default", disabled: true }, "uv_m4c9ow2w"], [{ sentiment: "warning", prominence: "strong", disabled: true }, "uv_m4c9ow2x"], [{ sentiment: "warning", prominence: "stronger", disabled: true }, "uv_m4c9ow2y"], [{ sentiment: "warning", prominence: "weak", disabled: true }, "uv_m4c9ow2z"], [{ sentiment: "neutral", prominence: "default", disabled: true }, "uv_m4c9ow30"], [{ sentiment: "neutral", prominence: "strong", disabled: true }, "uv_m4c9ow31"], [{ sentiment: "neutral", prominence: "stronger", disabled: true }, "uv_m4c9ow32"], [{ sentiment: "neutral", prominence: "weak", disabled: true }, "uv_m4c9ow33"], [{ sentiment: "black", prominence: "default", disabled: true }, "uv_m4c9ow34"], [{ sentiment: "black", prominence: "strong", disabled: true }, "uv_m4c9ow35"], [{ sentiment: "black", prominence: "stronger", disabled: true }, "uv_m4c9ow36"], [{ sentiment: "black", prominence: "weak", disabled: true }, "uv_m4c9ow37"], [{ sentiment: "white", prominence: "default", disabled: true }, "uv_m4c9ow38"], [{ sentiment: "white", prominence: "strong", disabled: true }, "uv_m4c9ow39"], [{ sentiment: "white", prominence: "stronger", disabled: true }, "uv_m4c9ow3a"], [{ sentiment: "white", prominence: "weak", disabled: true }, "uv_m4c9ow3b"], [{ prominence: "default", disabled: false }, "uv_m4c9ow3c"], [{ prominence: "strong", disabled: false }, "uv_m4c9ow3d"], [{ prominence: "stronger", disabled: false }, "uv_m4c9ow3e"], [{ prominence: "weak", disabled: false }, "uv_m4c9ow3f"]] });
@@ -1,3 +1,4 @@
1
+ /* empty css */
1
2
  var placementText = "var(--uv_qabug40)";
2
3
  var whiteSpaceText = "var(--uv_qabug41)";
3
4
  export {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs, jsx } from "@emotion/react/jsx-runtime";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import { CloseIcon, CheckCircleIcon, AlertCircleIcon } from "@ultraviolet/icons";
4
4
  import { useTheme } from "@ultraviolet/themes";
5
5
  import { assignInlineVars } from "@vanilla-extract/dynamic";
@@ -13,111 +13,186 @@ import { Text } from "../Text/index.js";
13
13
  import { Tooltip } from "../Tooltip/index.js";
14
14
  import { textareaWrapper, textArea, paddingRightVar, textAreaClearableContainer } from "./styles.css.js";
15
15
  const STATE_ICON_SIZE = "small";
16
- const TextArea = forwardRef(({
17
- id,
18
- className,
19
- tabIndex,
20
- value,
21
- onChange,
22
- placeholder,
23
- rows = 3,
24
- maxRows,
25
- disabled = false,
26
- readOnly = false,
27
- success,
28
- error,
29
- helper,
30
- minLength,
31
- maxLength,
32
- tooltip,
33
- label,
34
- autoFocus,
35
- required = false,
36
- "data-testid": dataTestId,
37
- name,
38
- onFocus,
39
- onBlur,
40
- onKeyDown,
41
- clearable = false,
42
- labelDescription,
43
- "aria-label": ariaLabel,
44
- style
45
- }, ref) => {
46
- const localId = useId();
47
- const theme = useTheme();
48
- const textAreaRef = useRef(null);
49
- useImperativeHandle(ref, () => textAreaRef.current);
50
- useEffect(() => {
51
- const textArea2 = textAreaRef.current;
52
- const padding = theme.space["1.5"];
53
- if (!textArea2) {
54
- return;
55
- }
56
- const updateHeight = () => {
57
- if (textArea2 && rows === "auto" && !maxRows) {
58
- textArea2.style.height = "auto";
59
- textArea2.style.resize = "none";
60
- textArea2.style.height = `${textArea2.scrollHeight + 2}px`;
61
- } else if (textArea2 && maxRows) {
62
- const lineHeight = Number.parseFloat(getComputedStyle(textArea2).lineHeight);
63
- textArea2.style.height = "auto";
64
- const maxHeight = maxRows * lineHeight;
65
- textArea2.style.height = `${textArea2.scrollHeight + 2}px`;
66
- textArea2.style.maxHeight = `calc(${maxHeight}px + 2*${padding})`;
67
- if (typeof rows === "number") {
68
- const minHeight = rows * lineHeight;
69
- textArea2.style.minHeight = `calc(${minHeight}px + 2*${padding})`;
16
+ const TextArea = forwardRef(
17
+ ({
18
+ id,
19
+ className,
20
+ tabIndex,
21
+ value,
22
+ onChange,
23
+ placeholder,
24
+ rows = 3,
25
+ maxRows,
26
+ disabled = false,
27
+ readOnly = false,
28
+ success,
29
+ error,
30
+ helper,
31
+ minLength,
32
+ maxLength,
33
+ tooltip,
34
+ label,
35
+ autoFocus,
36
+ required = false,
37
+ "data-testid": dataTestId,
38
+ name,
39
+ onFocus,
40
+ onBlur,
41
+ onKeyDown,
42
+ clearable = false,
43
+ labelDescription,
44
+ "aria-label": ariaLabel,
45
+ style
46
+ }, ref) => {
47
+ const localId = useId();
48
+ const theme = useTheme();
49
+ const textAreaRef = useRef(null);
50
+ useImperativeHandle(ref, () => textAreaRef.current);
51
+ useEffect(() => {
52
+ const textArea2 = textAreaRef.current;
53
+ const padding = theme.space["1.5"];
54
+ if (!textArea2) {
55
+ return;
56
+ }
57
+ const updateHeight = () => {
58
+ if (textArea2 && rows === "auto" && !maxRows) {
59
+ textArea2.style.height = "auto";
60
+ textArea2.style.resize = "none";
61
+ textArea2.style.height = `${textArea2.scrollHeight + 2}px`;
62
+ } else if (textArea2 && maxRows) {
63
+ const lineHeight = Number.parseFloat(
64
+ getComputedStyle(textArea2).lineHeight
65
+ );
66
+ textArea2.style.height = "auto";
67
+ const maxHeight = maxRows * lineHeight;
68
+ textArea2.style.height = `${textArea2.scrollHeight + 2}px`;
69
+ textArea2.style.maxHeight = `calc(${maxHeight}px + 2*${padding})`;
70
+ if (typeof rows === "number") {
71
+ const minHeight = rows * lineHeight;
72
+ textArea2.style.minHeight = `calc(${minHeight}px + 2*${padding})`;
73
+ }
70
74
  }
75
+ };
76
+ requestAnimationFrame(updateHeight);
77
+ }, [value, rows, theme, maxRows, textAreaRef.current?.value]);
78
+ const sentiment = useMemo(() => {
79
+ if (error) {
80
+ return "danger";
81
+ }
82
+ if (success) {
83
+ return "success";
71
84
  }
72
- };
73
- requestAnimationFrame(updateHeight);
74
- }, [value, rows, theme, maxRows, textAreaRef.current?.value]);
75
- const sentiment = useMemo(() => {
76
- if (error) {
77
- return "danger";
78
- }
79
- if (success) {
80
- return "success";
81
- }
82
- return "neutral";
83
- }, [error, success]);
84
- const notice = success || error || helper;
85
- const computedClearable = clearable && !!value;
86
- return /* @__PURE__ */ jsxs(Stack, { className, gap: "0.5", children: [
87
- label || labelDescription ? /* @__PURE__ */ jsx(Label, { htmlFor: id ?? localId, labelDescription, required, children: label }) : null,
88
- /* @__PURE__ */ jsx(Tooltip, { text: tooltip, children: /* @__PURE__ */ jsxs("div", { className: textareaWrapper, children: [
89
- /* @__PURE__ */ jsx("textarea", { "aria-invalid": !!error, "aria-label": ariaLabel, autoFocus, className: textArea({
90
- error: !!error,
91
- success: !!success
92
- }), "data-testid": dataTestId, disabled, id: id ?? localId, maxLength, minLength, name, onBlur, onChange: (event) => {
93
- onChange(event.currentTarget.value);
94
- }, onFocus, onKeyDown, placeholder, readOnly: !!readOnly, ref: textAreaRef, rows: rows !== "auto" ? rows : 1, style: {
95
- ...assignInlineVars({
96
- [paddingRightVar]: `calc(${theme.space[computedClearable && (!!success || !!error) ? "4" : "3"]} + ${computedClearable ? `${SIZE_HEIGHT.xsmall}px` : "0px"} + ${!!success || !!error ? `${STATE_ICON_SIZE}px` : "0px"})`
97
- }),
98
- ...style
99
- }, tabIndex, value }),
100
- /* @__PURE__ */ jsxs(Stack, { alignItems: "center", className: textAreaClearableContainer, direction: "row", gap: "1", children: [
101
- computedClearable ? /* @__PURE__ */ jsx(Button, { "aria-label": "clear value", onClick: () => {
102
- onChange("");
103
- }, sentiment: "neutral", size: "xsmall", variant: "ghost", children: /* @__PURE__ */ jsx(CloseIcon, {}) }) : null,
104
- success && !error ? /* @__PURE__ */ jsx(CheckCircleIcon, { sentiment: "success", size: STATE_ICON_SIZE }) : null,
105
- error ? /* @__PURE__ */ jsx(AlertCircleIcon, { sentiment: "danger" }) : null
106
- ] })
107
- ] }) }),
108
- notice || maxLength ? /* @__PURE__ */ jsxs(Row, { gap: "1", templateColumns: "minmax(0, 1fr) min-content", children: [
109
- /* @__PURE__ */ jsxs("div", { children: [
110
- error || success || typeof helper === "string" ? /* @__PURE__ */ jsx(Text, { as: "p", disabled, prominence: !error && !success ? "weak" : "default", sentiment, variant: "caption", children: error || success || helper }) : null,
111
- !error && !success && typeof helper !== "string" && helper ? helper : null
112
- ] }),
113
- maxLength ? /* @__PURE__ */ jsxs(Text, { as: "div", prominence: "weak", sentiment: "neutral", variant: "caption", children: [
114
- value?.length ?? 0,
115
- "/",
116
- maxLength
85
+ return "neutral";
86
+ }, [error, success]);
87
+ const notice = success || error || helper;
88
+ const computedClearable = clearable && !!value;
89
+ return /* @__PURE__ */ jsxs(Stack, { className, gap: "0.5", children: [
90
+ label || labelDescription ? /* @__PURE__ */ jsx(
91
+ Label,
92
+ {
93
+ htmlFor: id ?? localId,
94
+ labelDescription,
95
+ required,
96
+ children: label
97
+ }
98
+ ) : null,
99
+ /* @__PURE__ */ jsx(Tooltip, { text: tooltip, children: /* @__PURE__ */ jsxs("div", { className: textareaWrapper, children: [
100
+ /* @__PURE__ */ jsx(
101
+ "textarea",
102
+ {
103
+ "aria-invalid": !!error,
104
+ "aria-label": ariaLabel,
105
+ autoFocus,
106
+ className: textArea({
107
+ error: !!error,
108
+ success: !!success
109
+ }),
110
+ "data-testid": dataTestId,
111
+ disabled,
112
+ id: id ?? localId,
113
+ maxLength,
114
+ minLength,
115
+ name,
116
+ onBlur,
117
+ onChange: (event) => {
118
+ onChange(event.currentTarget.value);
119
+ },
120
+ onFocus,
121
+ onKeyDown,
122
+ placeholder,
123
+ readOnly: !!readOnly,
124
+ ref: textAreaRef,
125
+ rows: rows !== "auto" ? rows : 1,
126
+ style: {
127
+ ...assignInlineVars({
128
+ [paddingRightVar]: `calc(${theme.space[computedClearable && (!!success || !!error) ? "4" : "3"]} + ${computedClearable ? `${SIZE_HEIGHT.xsmall}px` : "0px"} + ${!!success || !!error ? `${STATE_ICON_SIZE}px` : "0px"})`
129
+ }),
130
+ ...style
131
+ },
132
+ tabIndex,
133
+ value
134
+ }
135
+ ),
136
+ /* @__PURE__ */ jsxs(
137
+ Stack,
138
+ {
139
+ alignItems: "center",
140
+ className: textAreaClearableContainer,
141
+ direction: "row",
142
+ gap: "1",
143
+ children: [
144
+ computedClearable ? /* @__PURE__ */ jsx(
145
+ Button,
146
+ {
147
+ "aria-label": "clear value",
148
+ onClick: () => {
149
+ onChange("");
150
+ },
151
+ sentiment: "neutral",
152
+ size: "xsmall",
153
+ variant: "ghost",
154
+ children: /* @__PURE__ */ jsx(CloseIcon, {})
155
+ }
156
+ ) : null,
157
+ success && !error ? /* @__PURE__ */ jsx(CheckCircleIcon, { sentiment: "success", size: STATE_ICON_SIZE }) : null,
158
+ error ? /* @__PURE__ */ jsx(AlertCircleIcon, { sentiment: "danger" }) : null
159
+ ]
160
+ }
161
+ )
162
+ ] }) }),
163
+ notice || maxLength ? /* @__PURE__ */ jsxs(Row, { gap: "1", templateColumns: "minmax(0, 1fr) min-content", children: [
164
+ /* @__PURE__ */ jsxs("div", { children: [
165
+ error || success || typeof helper === "string" ? /* @__PURE__ */ jsx(
166
+ Text,
167
+ {
168
+ as: "p",
169
+ disabled,
170
+ prominence: !error && !success ? "weak" : "default",
171
+ sentiment,
172
+ variant: "caption",
173
+ children: error || success || helper
174
+ }
175
+ ) : null,
176
+ !error && !success && typeof helper !== "string" && helper ? helper : null
177
+ ] }),
178
+ maxLength ? /* @__PURE__ */ jsxs(
179
+ Text,
180
+ {
181
+ as: "div",
182
+ prominence: "weak",
183
+ sentiment: "neutral",
184
+ variant: "caption",
185
+ children: [
186
+ value?.length ?? 0,
187
+ "/",
188
+ maxLength
189
+ ]
190
+ }
191
+ ) : null
117
192
  ] }) : null
118
- ] }) : null
119
- ] });
120
- });
193
+ ] });
194
+ }
195
+ );
121
196
  export {
122
197
  TextArea
123
198
  };
@@ -26,4 +26,4 @@ export declare const TextInput: import("react").ForwardRefExoticComponent<{
26
26
  value?: string;
27
27
  defaultValue?: string;
28
28
  onChangeValue?: (value: string) => void;
29
- } & Pick<InputHTMLAttributes<HTMLInputElement>, "style" | "disabled" | "id" | "name" | "role" | "tabIndex" | "aria-atomic" | "aria-label" | "aria-labelledby" | "aria-live" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onKeyUp" | "autoComplete" | "autoFocus" | "placeholder" | "readOnly" | "required"> & import("react").RefAttributes<HTMLInputElement>>;
29
+ } & Pick<InputHTMLAttributes<HTMLInputElement>, "style" | "disabled" | "id" | "autoComplete" | "role" | "autoFocus" | "tabIndex" | "aria-atomic" | "aria-label" | "aria-labelledby" | "aria-live" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onKeyUp" | "name" | "placeholder" | "readOnly" | "required"> & import("react").RefAttributes<HTMLInputElement>>;