@foxford/ui 2.76.1-beta-3d975b5-20250715 → 2.77.0-beta-90a741d-20250807

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 (402) hide show
  1. package/LICENSE +27 -0
  2. package/components/Accordion/Accordion.js +1 -1
  3. package/components/Accordion/Accordion.js.map +1 -1
  4. package/components/Accordion/Accordion.mjs +1 -1
  5. package/components/Accordion/Accordion.mjs.map +1 -1
  6. package/components/Accordion/hooks.js +1 -1
  7. package/components/Accordion/hooks.js.map +1 -1
  8. package/components/Accordion/hooks.mjs +1 -1
  9. package/components/Accordion/hooks.mjs.map +1 -1
  10. package/components/AccordionItem/AccordionItem.js +1 -1
  11. package/components/AccordionItem/AccordionItem.js.map +1 -1
  12. package/components/AccordionItem/AccordionItem.mjs +1 -1
  13. package/components/AccordionItem/AccordionItem.mjs.map +1 -1
  14. package/components/ActionBtn/ActionBtn.js +1 -1
  15. package/components/ActionBtn/ActionBtn.js.map +1 -1
  16. package/components/ActionBtn/ActionBtn.mjs +1 -1
  17. package/components/ActionBtn/ActionBtn.mjs.map +1 -1
  18. package/components/ActionBtn/style.js.map +1 -1
  19. package/components/ActionBtn/style.mjs.map +1 -1
  20. package/components/Alert/Alert.js +1 -1
  21. package/components/Alert/Alert.js.map +1 -1
  22. package/components/Alert/Alert.mjs +1 -1
  23. package/components/Alert/Alert.mjs.map +1 -1
  24. package/components/Amount/Amount.js +1 -1
  25. package/components/Amount/Amount.js.map +1 -1
  26. package/components/Amount/Amount.mjs +1 -1
  27. package/components/Amount/Amount.mjs.map +1 -1
  28. package/components/Amount/data/index.js.map +1 -1
  29. package/components/Amount/data/index.mjs.map +1 -1
  30. package/components/Amount/style.js.map +1 -1
  31. package/components/Amount/style.mjs.map +1 -1
  32. package/components/Anchor/Anchor.js +1 -1
  33. package/components/Anchor/Anchor.js.map +1 -1
  34. package/components/Anchor/Anchor.mjs +1 -1
  35. package/components/Anchor/Anchor.mjs.map +1 -1
  36. package/components/Arrow/Arrow.js.map +1 -1
  37. package/components/Arrow/Arrow.mjs.map +1 -1
  38. package/components/ArrowBadge/ArrowBadge.js.map +1 -1
  39. package/components/ArrowBadge/ArrowBadge.mjs.map +1 -1
  40. package/components/AspectRatio/style.js.map +1 -1
  41. package/components/AspectRatio/style.mjs.map +1 -1
  42. package/components/Avatar/Avatar.js +1 -1
  43. package/components/Avatar/Avatar.js.map +1 -1
  44. package/components/Avatar/Avatar.mjs +1 -1
  45. package/components/Avatar/Avatar.mjs.map +1 -1
  46. package/components/Avatar/utils.js.map +1 -1
  47. package/components/Avatar/utils.mjs.map +1 -1
  48. package/components/Badge/Badge.js +1 -1
  49. package/components/Badge/Badge.js.map +1 -1
  50. package/components/Badge/Badge.mjs +1 -1
  51. package/components/Badge/Badge.mjs.map +1 -1
  52. package/components/Button/Button.js +1 -1
  53. package/components/Button/Button.js.map +1 -1
  54. package/components/Button/Button.mjs +1 -1
  55. package/components/Button/Button.mjs.map +1 -1
  56. package/components/Button/hooks.js.map +1 -1
  57. package/components/Button/hooks.mjs.map +1 -1
  58. package/components/Button/style.js.map +1 -1
  59. package/components/Button/style.mjs.map +1 -1
  60. package/components/Checkbox/Checkbox.js +1 -1
  61. package/components/Checkbox/Checkbox.js.map +1 -1
  62. package/components/Checkbox/Checkbox.mjs +1 -1
  63. package/components/Checkbox/Checkbox.mjs.map +1 -1
  64. package/components/Chip/Chip.js +1 -1
  65. package/components/Chip/Chip.js.map +1 -1
  66. package/components/Chip/Chip.mjs +1 -1
  67. package/components/Chip/Chip.mjs.map +1 -1
  68. package/components/Container/Container.js.map +1 -1
  69. package/components/Container/Container.mjs.map +1 -1
  70. package/components/Container/style.js.map +1 -1
  71. package/components/Container/style.mjs.map +1 -1
  72. package/components/ContextMenu/ContextMenu.js +1 -1
  73. package/components/ContextMenu/ContextMenu.js.map +1 -1
  74. package/components/ContextMenu/ContextMenu.mjs +1 -1
  75. package/components/ContextMenu/ContextMenu.mjs.map +1 -1
  76. package/components/ContextMenu/Item.js.map +1 -1
  77. package/components/ContextMenu/Item.mjs.map +1 -1
  78. package/components/ContextMenu/style.js.map +1 -1
  79. package/components/ContextMenu/style.mjs.map +1 -1
  80. package/components/ContextMenu.Multilevel/ContextMenu.Multilevel.js +1 -1
  81. package/components/ContextMenu.Multilevel/ContextMenu.Multilevel.js.map +1 -1
  82. package/components/ContextMenu.Multilevel/ContextMenu.Multilevel.mjs +1 -1
  83. package/components/ContextMenu.Multilevel/ContextMenu.Multilevel.mjs.map +1 -1
  84. package/components/ContextMenu.Multilevel/Controls.js.map +1 -1
  85. package/components/ContextMenu.Multilevel/Controls.mjs.map +1 -1
  86. package/components/Dialog/Dialog.js.map +1 -1
  87. package/components/Dialog/Dialog.mjs.map +1 -1
  88. package/components/DialogComponent/DialogComponent.js +1 -1
  89. package/components/DialogComponent/DialogComponent.js.map +1 -1
  90. package/components/DialogComponent/DialogComponent.mjs +1 -1
  91. package/components/DialogComponent/DialogComponent.mjs.map +1 -1
  92. package/components/DialogComponent/style.js.map +1 -1
  93. package/components/DialogComponent/style.mjs.map +1 -1
  94. package/components/Divider/style.js.map +1 -1
  95. package/components/Divider/style.mjs.map +1 -1
  96. package/components/Dropdown/Dropdown.js +1 -1
  97. package/components/Dropdown/Dropdown.js.map +1 -1
  98. package/components/Dropdown/Dropdown.mjs +1 -1
  99. package/components/Dropdown/Dropdown.mjs.map +1 -1
  100. package/components/Dropdown/DropdownMenuNoOptions.js +1 -1
  101. package/components/Dropdown/DropdownMenuNoOptions.js.map +1 -1
  102. package/components/Dropdown/DropdownMenuNoOptions.mjs +1 -1
  103. package/components/Dropdown/DropdownMenuNoOptions.mjs.map +1 -1
  104. package/components/Dropdown/hooks.js.map +1 -1
  105. package/components/Dropdown/hooks.mjs.map +1 -1
  106. package/components/FormInput/FormInput.js.map +1 -1
  107. package/components/FormInput/FormInput.mjs.map +1 -1
  108. package/components/FormInputLabel/FormInputLabel.js +1 -1
  109. package/components/FormInputLabel/FormInputLabel.js.map +1 -1
  110. package/components/FormInputLabel/FormInputLabel.mjs +1 -1
  111. package/components/FormInputLabel/FormInputLabel.mjs.map +1 -1
  112. package/components/FormLabel/FormLabel.js +1 -1
  113. package/components/FormLabel/FormLabel.js.map +1 -1
  114. package/components/FormLabel/FormLabel.mjs +1 -1
  115. package/components/FormLabel/FormLabel.mjs.map +1 -1
  116. package/components/Icon/Icon.js +1 -1
  117. package/components/Icon/Icon.js.map +1 -1
  118. package/components/Icon/Icon.mjs +1 -1
  119. package/components/Icon/Icon.mjs.map +1 -1
  120. package/components/Icon/bg-worker.js.map +1 -1
  121. package/components/Icon/bg-worker.mjs.map +1 -1
  122. package/components/Icon/list/default.js.map +1 -1
  123. package/components/Icon/list/default.mjs.map +1 -1
  124. package/components/Icon/list/icon-pack.js.map +1 -1
  125. package/components/Icon/list/icon-pack.mjs.map +1 -1
  126. package/components/IconButton/IconButton.js.map +1 -1
  127. package/components/IconButton/IconButton.mjs.map +1 -1
  128. package/components/Indicator/Indicator.js +1 -1
  129. package/components/Indicator/Indicator.js.map +1 -1
  130. package/components/Indicator/Indicator.mjs +1 -1
  131. package/components/Indicator/Indicator.mjs.map +1 -1
  132. package/components/Input/Input.js.map +1 -1
  133. package/components/Input/Input.mjs.map +1 -1
  134. package/components/Input/helpers.js.map +1 -1
  135. package/components/Input/helpers.mjs.map +1 -1
  136. package/components/Input.Phone/Input.Phone.js.map +1 -1
  137. package/components/Input.Phone/Input.Phone.mjs.map +1 -1
  138. package/components/InputCheckbox/InputCheckbox.js.map +1 -1
  139. package/components/InputCheckbox/InputCheckbox.mjs.map +1 -1
  140. package/components/InputRadio/InputRadio.js.map +1 -1
  141. package/components/InputRadio/InputRadio.mjs.map +1 -1
  142. package/components/ListItem/ListItem.js +1 -1
  143. package/components/ListItem/ListItem.js.map +1 -1
  144. package/components/ListItem/ListItem.mjs +1 -1
  145. package/components/ListItem/ListItem.mjs.map +1 -1
  146. package/components/Menu/Menu.js.map +1 -1
  147. package/components/Menu/Menu.mjs.map +1 -1
  148. package/components/MenuComponent/MenuComponent.js.map +1 -1
  149. package/components/MenuComponent/MenuComponent.mjs.map +1 -1
  150. package/components/MenuComponent/style.js +1 -1
  151. package/components/MenuComponent/style.js.map +1 -1
  152. package/components/MenuComponent/style.mjs +1 -1
  153. package/components/MenuComponent/style.mjs.map +1 -1
  154. package/components/MenuContainer/MenuContainer.js +1 -1
  155. package/components/MenuContainer/MenuContainer.js.map +1 -1
  156. package/components/MenuContainer/MenuContainer.mjs +1 -1
  157. package/components/MenuContainer/MenuContainer.mjs.map +1 -1
  158. package/components/MenuDivider/MenuDivider.js +1 -1
  159. package/components/MenuDivider/MenuDivider.js.map +1 -1
  160. package/components/MenuDivider/MenuDivider.mjs +1 -1
  161. package/components/MenuDivider/MenuDivider.mjs.map +1 -1
  162. package/components/MenuList/MenuList.js.map +1 -1
  163. package/components/MenuList/MenuList.mjs.map +1 -1
  164. package/components/Modal/Modal.js.map +1 -1
  165. package/components/Modal/Modal.mjs.map +1 -1
  166. package/components/Modal/adapter.js.map +1 -1
  167. package/components/Modal/adapter.mjs.map +1 -1
  168. package/components/Modal/style.js +1 -1
  169. package/components/Modal/style.js.map +1 -1
  170. package/components/Modal/style.mjs +1 -1
  171. package/components/Modal/style.mjs.map +1 -1
  172. package/components/Notification/Notification.js +1 -1
  173. package/components/Notification/Notification.js.map +1 -1
  174. package/components/Notification/Notification.mjs +1 -1
  175. package/components/Notification/Notification.mjs.map +1 -1
  176. package/components/Paper/Paper.js.map +1 -1
  177. package/components/Paper/Paper.mjs.map +1 -1
  178. package/components/Paper/style.js.map +1 -1
  179. package/components/Paper/style.mjs.map +1 -1
  180. package/components/Popover/Popover.js.map +1 -1
  181. package/components/Popover/Popover.mjs.map +1 -1
  182. package/components/PopoverComponent/PopoverComponent.js +1 -1
  183. package/components/PopoverComponent/PopoverComponent.js.map +1 -1
  184. package/components/PopoverComponent/PopoverComponent.mjs +1 -1
  185. package/components/PopoverComponent/PopoverComponent.mjs.map +1 -1
  186. package/components/Progress/Progress.js.map +1 -1
  187. package/components/Progress/Progress.mjs.map +1 -1
  188. package/components/Progress/style.js +1 -1
  189. package/components/Progress/style.js.map +1 -1
  190. package/components/Progress/style.mjs +1 -1
  191. package/components/Progress/style.mjs.map +1 -1
  192. package/components/Progress.Circle/Progress.Circle.js +1 -1
  193. package/components/Progress.Circle/Progress.Circle.js.map +1 -1
  194. package/components/Progress.Circle/Progress.Circle.mjs +1 -1
  195. package/components/Progress.Circle/Progress.Circle.mjs.map +1 -1
  196. package/components/Progress.Circle/style.js +1 -1
  197. package/components/Progress.Circle/style.js.map +1 -1
  198. package/components/Progress.Circle/style.mjs +1 -1
  199. package/components/Progress.Circle/style.mjs.map +1 -1
  200. package/components/Progress.Segmented/Progress.Segmented.js.map +1 -1
  201. package/components/Progress.Segmented/Progress.Segmented.mjs.map +1 -1
  202. package/components/Progress.Segmented/style.js.map +1 -1
  203. package/components/Progress.Segmented/style.mjs.map +1 -1
  204. package/components/ProgressCircle/ProgressCircle.js +1 -1
  205. package/components/ProgressCircle/ProgressCircle.js.map +1 -1
  206. package/components/ProgressCircle/ProgressCircle.mjs +1 -1
  207. package/components/ProgressCircle/ProgressCircle.mjs.map +1 -1
  208. package/components/ProgressCircle/style.js +1 -1
  209. package/components/ProgressCircle/style.js.map +1 -1
  210. package/components/ProgressCircle/style.mjs +1 -1
  211. package/components/ProgressCircle/style.mjs.map +1 -1
  212. package/components/ProgressLine/ProgressLine.js +1 -1
  213. package/components/ProgressLine/ProgressLine.js.map +1 -1
  214. package/components/ProgressLine/ProgressLine.mjs +1 -1
  215. package/components/ProgressLine/ProgressLine.mjs.map +1 -1
  216. package/components/Radio/Group.js.map +1 -1
  217. package/components/Radio/Group.mjs.map +1 -1
  218. package/components/Radio/Radio.js +1 -1
  219. package/components/Radio/Radio.js.map +1 -1
  220. package/components/Radio/Radio.mjs +1 -1
  221. package/components/Radio/Radio.mjs.map +1 -1
  222. package/components/Radio/style.js.map +1 -1
  223. package/components/Radio/style.mjs.map +1 -1
  224. package/components/Scrollable/Scrollable.js +1 -1
  225. package/components/Scrollable/Scrollable.js.map +1 -1
  226. package/components/Scrollable/Scrollable.mjs +1 -1
  227. package/components/Scrollable/Scrollable.mjs.map +1 -1
  228. package/components/Section/Section.js.map +1 -1
  229. package/components/Section/Section.mjs.map +1 -1
  230. package/components/Section/style.js +1 -1
  231. package/components/Section/style.js.map +1 -1
  232. package/components/Section/style.mjs +1 -1
  233. package/components/Section/style.mjs.map +1 -1
  234. package/components/Select/Select.js.map +1 -1
  235. package/components/Select/Select.mjs.map +1 -1
  236. package/components/Select/style.js +1 -1
  237. package/components/Select/style.js.map +1 -1
  238. package/components/Select/style.mjs +1 -1
  239. package/components/Select/style.mjs.map +1 -1
  240. package/components/Separator/Separator.js.map +1 -1
  241. package/components/Separator/Separator.mjs.map +1 -1
  242. package/components/Separator/SeparatorText.js.map +1 -1
  243. package/components/Separator/SeparatorText.mjs.map +1 -1
  244. package/components/Separator/style.js +1 -1
  245. package/components/Separator/style.js.map +1 -1
  246. package/components/Separator/style.mjs +1 -1
  247. package/components/Separator/style.mjs.map +1 -1
  248. package/components/Spacer/Spacer.js.map +1 -1
  249. package/components/Spacer/Spacer.mjs.map +1 -1
  250. package/components/Spacer/style.js.map +1 -1
  251. package/components/Spacer/style.mjs.map +1 -1
  252. package/components/Spinner/Spinner.js.map +1 -1
  253. package/components/Spinner/Spinner.mjs.map +1 -1
  254. package/components/Spinner/style.js +1 -1
  255. package/components/Spinner/style.js.map +1 -1
  256. package/components/Spinner/style.mjs +1 -1
  257. package/components/Spinner/style.mjs.map +1 -1
  258. package/components/Switch/Switch.js.map +1 -1
  259. package/components/Switch/Switch.mjs.map +1 -1
  260. package/components/Switcher/style.js.map +1 -1
  261. package/components/Switcher/style.mjs.map +1 -1
  262. package/components/Tab/Tab.js +1 -1
  263. package/components/Tab/Tab.js.map +1 -1
  264. package/components/Tab/Tab.mjs +1 -1
  265. package/components/Tab/Tab.mjs.map +1 -1
  266. package/components/TabList/TabList.js +1 -1
  267. package/components/TabList/TabList.js.map +1 -1
  268. package/components/TabList/TabList.mjs +1 -1
  269. package/components/TabList/TabList.mjs.map +1 -1
  270. package/components/TabList/TabListMenuTab.js +1 -1
  271. package/components/TabList/TabListMenuTab.js.map +1 -1
  272. package/components/TabList/TabListMenuTab.mjs +1 -1
  273. package/components/TabList/TabListMenuTab.mjs.map +1 -1
  274. package/components/TabList/TabListPanel.js.map +1 -1
  275. package/components/TabList/TabListPanel.mjs.map +1 -1
  276. package/components/TabList/hooks.js +1 -1
  277. package/components/TabList/hooks.js.map +1 -1
  278. package/components/TabList/hooks.mjs +1 -1
  279. package/components/TabList/hooks.mjs.map +1 -1
  280. package/components/TabList/style.js +1 -1
  281. package/components/TabList/style.js.map +1 -1
  282. package/components/TabList/style.mjs +1 -1
  283. package/components/TabList/style.mjs.map +1 -1
  284. package/components/TabListTab/TabListTab.js.map +1 -1
  285. package/components/TabListTab/TabListTab.mjs.map +1 -1
  286. package/components/TabListTab/style.js +1 -1
  287. package/components/TabListTab/style.js.map +1 -1
  288. package/components/TabListTab/style.mjs +1 -1
  289. package/components/TabListTab/style.mjs.map +1 -1
  290. package/components/Tabs/Tabs.js.map +1 -1
  291. package/components/Tabs/Tabs.mjs.map +1 -1
  292. package/components/Tabs/style.js +1 -1
  293. package/components/Tabs/style.js.map +1 -1
  294. package/components/Tabs/style.mjs +1 -1
  295. package/components/Tabs/style.mjs.map +1 -1
  296. package/components/Tag/Tag.js +1 -1
  297. package/components/Tag/Tag.js.map +1 -1
  298. package/components/Tag/Tag.mjs +1 -1
  299. package/components/Tag/Tag.mjs.map +1 -1
  300. package/components/Tag/style.js +1 -1
  301. package/components/Tag/style.js.map +1 -1
  302. package/components/Tag/style.mjs +1 -1
  303. package/components/Tag/style.mjs.map +1 -1
  304. package/components/Text/Ellipsis.js +1 -1
  305. package/components/Text/Ellipsis.js.map +1 -1
  306. package/components/Text/Ellipsis.mjs +1 -1
  307. package/components/Text/Ellipsis.mjs.map +1 -1
  308. package/components/Text/Text.js.map +1 -1
  309. package/components/Text/Text.mjs.map +1 -1
  310. package/components/Text/style.js.map +1 -1
  311. package/components/Text/style.mjs.map +1 -1
  312. package/components/Text.Ellipse/Text.Ellipse.js +1 -1
  313. package/components/Text.Ellipse/Text.Ellipse.js.map +1 -1
  314. package/components/Text.Ellipse/Text.Ellipse.mjs +1 -1
  315. package/components/Text.Ellipse/Text.Ellipse.mjs.map +1 -1
  316. package/components/Textarea/Textarea.js +1 -1
  317. package/components/Textarea/Textarea.js.map +1 -1
  318. package/components/Textarea/Textarea.mjs +1 -1
  319. package/components/Textarea/Textarea.mjs.map +1 -1
  320. package/components/Tooltip/Tooltip.js.map +1 -1
  321. package/components/Tooltip/Tooltip.mjs.map +1 -1
  322. package/components/Tooltip/TooltipWrapper.js.map +1 -1
  323. package/components/Tooltip/TooltipWrapper.mjs.map +1 -1
  324. package/components/TooltipComponent/TooltipComponent.js +1 -1
  325. package/components/TooltipComponent/TooltipComponent.js.map +1 -1
  326. package/components/TooltipComponent/TooltipComponent.mjs +1 -1
  327. package/components/TooltipComponent/TooltipComponent.mjs.map +1 -1
  328. package/dts/index.d.ts +2630 -2557
  329. package/hocs/withMergedProps.js.map +1 -1
  330. package/hocs/withMergedProps.mjs.map +1 -1
  331. package/hocs/withTranslation.js +1 -1
  332. package/hocs/withTranslation.js.map +1 -1
  333. package/hocs/withTranslation.mjs +1 -1
  334. package/hocs/withTranslation.mjs.map +1 -1
  335. package/hooks/use-config-priority.js.map +1 -1
  336. package/hooks/use-config-priority.mjs +1 -1
  337. package/hooks/use-config-priority.mjs.map +1 -1
  338. package/hooks/useClickOutside.js.map +1 -1
  339. package/hooks/useClickOutside.mjs.map +1 -1
  340. package/hooks/useMergedPalette.js +1 -1
  341. package/hooks/useMergedPalette.js.map +1 -1
  342. package/hooks/useMergedPalette.mjs +1 -1
  343. package/hooks/useMergedPalette.mjs.map +1 -1
  344. package/hooks/useMergedProps.js.map +1 -1
  345. package/hooks/useMergedProps.mjs.map +1 -1
  346. package/hooks/useMergedSizes.js.map +1 -1
  347. package/hooks/useMergedSizes.mjs.map +1 -1
  348. package/hooks/useResizeObserver.js.map +1 -1
  349. package/hooks/useResizeObserver.mjs.map +1 -1
  350. package/hooks/useScrollMonitor.js +1 -1
  351. package/hooks/useScrollMonitor.js.map +1 -1
  352. package/hooks/useScrollMonitor.mjs +1 -1
  353. package/hooks/useScrollMonitor.mjs.map +1 -1
  354. package/hooks/useScrollThresholds.js.map +1 -1
  355. package/hooks/useScrollThresholds.mjs.map +1 -1
  356. package/mixins/color.js.map +1 -1
  357. package/mixins/color.mjs.map +1 -1
  358. package/mixins/create-responsive-props.js.map +1 -1
  359. package/mixins/create-responsive-props.mjs.map +1 -1
  360. package/mixins/display.js.map +1 -1
  361. package/mixins/display.mjs.map +1 -1
  362. package/mixins/responsive-margin.js.map +1 -1
  363. package/mixins/responsive-margin.mjs.map +1 -1
  364. package/mixins/responsive-property.js +1 -1
  365. package/mixins/responsive-property.js.map +1 -1
  366. package/mixins/responsive-property.mjs +1 -1
  367. package/mixins/responsive-property.mjs.map +1 -1
  368. package/mixins/screen.js +1 -1
  369. package/mixins/screen.js.map +1 -1
  370. package/mixins/screen.mjs +1 -1
  371. package/mixins/screen.mjs.map +1 -1
  372. package/mixins/shared.js +4 -4
  373. package/mixins/shared.js.map +1 -1
  374. package/mixins/shared.mjs +4 -4
  375. package/mixins/shared.mjs.map +1 -1
  376. package/mixins/vAlign.js.map +1 -1
  377. package/mixins/vAlign.mjs.map +1 -1
  378. package/package.json +7 -7
  379. package/shared/enums/sizeInput.js.map +1 -1
  380. package/shared/enums/sizeInput.mjs.map +1 -1
  381. package/shared/resize-observer.js.map +1 -1
  382. package/shared/resize-observer.mjs.map +1 -1
  383. package/shared/utils/colors.js.map +1 -1
  384. package/shared/utils/colors.mjs.map +1 -1
  385. package/shared/utils/dom.js.map +1 -1
  386. package/shared/utils/dom.mjs.map +1 -1
  387. package/shared/utils/react.js.map +1 -1
  388. package/shared/utils/react.mjs.map +1 -1
  389. package/shared/utils/rel-builder.js +1 -1
  390. package/shared/utils/rel-builder.js.map +1 -1
  391. package/shared/utils/rel-builder.mjs +1 -1
  392. package/shared/utils/rel-builder.mjs.map +1 -1
  393. package/theme/colors-dark.js.map +1 -1
  394. package/theme/colors-dark.mjs.map +1 -1
  395. package/theme/colors-light.js.map +1 -1
  396. package/theme/colors-light.mjs.map +1 -1
  397. package/theme/colors.js.map +1 -1
  398. package/theme/colors.mjs.map +1 -1
  399. package/theme/global-styled.js.map +1 -1
  400. package/theme/global-styled.mjs.map +1 -1
  401. package/theme/theme-provider.js.map +1 -1
  402. package/theme/theme-provider.mjs.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Text.Ellipse.mjs","sources":["../../../../src/components/Text.Ellipse/Text.Ellipse.tsx"],"sourcesContent":["import { Component } from 'react'\nimport type { TextProps } from 'components/Text'\nimport { Spacer } from '../Spacer/Spacer'\nimport { Anchor } from '../Anchor/Anchor'\nimport { Text } from '../Text'\nimport * as Styled from './style'\n\nexport interface TextEllipseProps extends Omit<TextProps, 'content'> {\n /** Toggle text for folded state */\n moreText?: string\n /** Toggle text for unfolded state */\n lessText?: string\n /** Classname */\n className?: string\n /** Text content */\n content: string | string[]\n /** Characters quantity for ellipsed text */\n chars?: number\n /** Wrap text in quotes */\n quoted?: boolean\n /** Flag to show toggler */\n showToggler?: boolean\n}\n\ninterface TextEllipseState {\n isUnFolded: boolean\n isEllipsed: boolean\n}\n\n/**\n * Расширен:\n * - [`BaseProps`](#/Миксины)\n * - [`Color`](#/Миксины)\n * - [`Display`](#/Миксины)\n * - [`ResponsiveNamedProperty<'size'>`](#/Миксины)\n */\nexport class TextEllipse extends Component<TextEllipseProps, TextEllipseState> {\n static displayName = 'Text.Ellipse'\n\n constructor(props: TextEllipseProps) {\n super(props)\n\n this.state = {\n isUnFolded: false,\n isEllipsed: false,\n }\n }\n\n componentDidUpdate({ content }: TextEllipseProps) {\n if (content !== this.props.content && this.state.isUnFolded) {\n this.toggle()\n }\n }\n\n getContent = (props: Omit<TextEllipseProps, 'className' | 'moreText' | 'lessText' | 'showToggler' | 'content'>) => {\n const { content, chars = 0 } = this.props\n\n if (!content) return ''\n\n let { isEllipsed } = this.state\n let text: string | string[] = typeof content === 'string' ? '' : []\n\n if (!this.state.isUnFolded) {\n if (typeof text === 'string') {\n isEllipsed = chars !== 0 && content.length > chars\n\n text = isEllipsed && chars !== 0 ? `${content.slice(0, chars)}...` : content\n } else {\n let leftChars = chars\n\n for (let index = 0; index < content.length; index++) {\n if (leftChars - content[index].length > 0) {\n leftChars -= content[index].length\n\n text[index] = content[index]\n } else {\n isEllipsed = true\n text[index] = `${content[index].slice(0, leftChars)}...`\n\n break\n }\n }\n }\n } else {\n text = content\n }\n\n if (this.state.isEllipsed !== isEllipsed) setTimeout(() => this.setState({ isEllipsed }))\n\n return typeof text === 'string' ? (\n <Text {...props}>{this.getQuted(text)}</Text>\n ) : (\n <Styled.Ul>\n {text.map((item, index) => (\n <Styled.Li key={index}>\n <Text {...props} display='inline'>\n {item}\n </Text>\n </Styled.Li>\n ))}\n </Styled.Ul>\n )\n }\n\n getQuted = (content: string) => (this.props.quoted ? `«${content}»` : content)\n\n toggle = () => {\n this.setState({ isUnFolded: !this.state.isUnFolded })\n }\n\n render() {\n const {\n className = '',\n style,\n moreText = 'Читать полностью',\n lessText = 'Свернуть',\n showToggler = true,\n ...restProps\n } = this.props\n const { isUnFolded, isEllipsed } = this.state\n\n return (\n <div className={className} style={style}>\n {this.getContent(restProps)}\n {showToggler && isEllipsed && (\n <Spacer marginTop={16} marginBottom={1}>\n <Anchor pseudo onClick={this.toggle}>\n {isUnFolded ? lessText : moreText}\n </Anchor>\n </Spacer>\n )}\n </div>\n )\n }\n}\n"],"names":["TextEllipse","Component","static","constructor","props","super","this","state","isUnFolded","isEllipsed","componentDidUpdate","content","toggle","getContent","chars","text","length","slice","leftChars","index","setTimeout","setState","_jsx","Text","children","getQuted","Styled","map","item","display","quoted","render","className","style","moreText","lessText","showToggler","restProps","_jsxs","Spacer","marginTop","marginBottom","Anchor","pseudo","onClick"],"mappings":"yNAoCO,MAAMA,oBAAoBC,UAC/BC,mBAAqB,eAErBC,WAAAA,CAAYC,GACVC,MAAMD,GAENE,KAAKC,MAAQ,CACXC,YAAY,EACZC,YAAY,EAEhB,CAEAC,kBAAAA,EAAmBC,QAAEA,IACfA,IAAYL,KAAKF,MAAMO,SAAWL,KAAKC,MAAMC,YAC/CF,KAAKM,QAET,CAEAC,WAAcT,IACZ,MAAMO,QAAEA,EAAOG,MAAEA,EAAQ,GAAMR,KAAKF,MAEpC,IAAKO,EAAS,MAAO,GAErB,IAAIF,WAAEA,GAAeH,KAAKC,MAC1B,IAAIQ,SAAiCJ,GAAY,SAAW,GAAK,GAEjE,GAAKL,KAAKC,MAAMC,WAsBdO,EAAOJ,OArBP,UAAWI,GAAS,SAClBN,EAAaK,IAAU,GAAKH,EAAQK,OAASF,EAE7CC,EAAON,GAAcK,IAAU,EAAI,GAAGH,EAAQM,MAAM,EAAGH,QAAcH,MAChE,CACL,IAAIO,EAAYJ,EAEhB,IAAK,IAAIK,EAAQ,EAAGA,EAAQR,EAAQK,OAAQG,IAAS,CACnD,KAAID,EAAYP,EAAQQ,GAAOH,OAAS,GAIjC,CACLP,GAAa,EACbM,EAAKI,GAAS,GAAGR,EAAQQ,GAAOF,MAAM,EAAGC,QAEzC,KACF,CAREA,GAAaP,EAAQQ,GAAOH,OAE5BD,EAAKI,GAASR,EAAQQ,EAO1B,CACF,CAOF,OAFIb,KAAKC,MAAME,aAAeA,GAAYW,YAAW,IAAMd,KAAKe,SAAS,CAAEZ,wBAE7DM,GAAS,SACrBO,IAACC,KAAI,IAAKnB,EAAKoB,SAAGlB,KAAKmB,SAASV,KAEhCO,IAACI,GAAS,CAAAF,SACPT,EAAKY,KAAI,CAACC,EAAMT,IACfG,IAACI,GAAS,CAAAF,SACRF,IAACC,KAAI,IAAKnB,EAAOyB,QAAQ,SAAQL,SAC9BI,KAFWT,MAOrB,EAGHM,SAAYd,GAAqBL,KAAKF,MAAM0B,OAAS,IAAInB,KAAaA,EAEtEC,OAASA,KACPN,KAAKe,SAAS,CAAEb,YAAaF,KAAKC,MAAMC,YAAa,EAGvDuB,MAAAA,GACE,MAAMC,UACJA,EAAY,GAAEC,MACdA,EAAKC,SACLA,EAAW,mBAAkBC,SAC7BA,EAAW,WAAUC,YACrBA,GAAc,KACXC,GACD/B,KAAKF,MACT,MAAMI,WAAEA,EAAUC,WAAEA,GAAeH,KAAKC,MAExC,OACE+B,KAAA,MAAA,CAAKN,UAAWA,EAAWC,MAAOA,EAAMT,SACrC,CAAAlB,KAAKO,WAAWwB,GAChBD,GAAe3B,GACda,IAACiB,OAAM,CAACC,UAAW,GAAIC,aAAc,EAAEjB,SACrCF,IAACoB,OAAM,CAACC,QAAM,EAACC,QAAStC,KAAKM,OAAOY,SACjChB,EAAa2B,EAAWD,QAMrC"}
1
+ {"version":3,"file":"Text.Ellipse.mjs","sources":["../../../../src/components/Text.Ellipse/Text.Ellipse.tsx"],"sourcesContent":["import { Component } from 'react'\nimport type { TextProps } from 'components/Text'\nimport { Spacer } from '../Spacer/Spacer'\nimport { Anchor } from '../Anchor/Anchor'\nimport { Text } from '../Text'\nimport * as Styled from './style'\n\nexport interface TextEllipseProps extends Omit<TextProps, 'content'> {\n /** Toggle text for folded state */\n moreText?: string\n /** Toggle text for unfolded state */\n lessText?: string\n /** Classname */\n className?: string\n /** Text content */\n content: string | string[]\n /** Characters quantity for ellipsed text */\n chars?: number\n /** Wrap text in quotes */\n quoted?: boolean\n /** Flag to show toggler */\n showToggler?: boolean\n}\n\ninterface TextEllipseState {\n isUnFolded: boolean\n isEllipsed: boolean\n}\n\n/**\n * Расширен:\n * - [`BaseProps`](#/Миксины)\n * - [`Color`](#/Миксины)\n * - [`Display`](#/Миксины)\n * - [`ResponsiveNamedProperty<'size'>`](#/Миксины)\n */\nexport class TextEllipse extends Component<TextEllipseProps, TextEllipseState> {\n static displayName = 'Text.Ellipse'\n\n constructor(props: TextEllipseProps) {\n super(props)\n\n this.state = {\n isUnFolded: false,\n isEllipsed: false,\n }\n }\n\n componentDidUpdate({ content }: TextEllipseProps) {\n if (content !== this.props.content && this.state.isUnFolded) {\n this.toggle()\n }\n }\n\n getContent = (props: Omit<TextEllipseProps, 'className' | 'moreText' | 'lessText' | 'showToggler' | 'content'>) => {\n const { content, chars = 0 } = this.props\n\n if (!content) return ''\n\n let { isEllipsed } = this.state\n let text: string | string[] = typeof content === 'string' ? '' : []\n\n if (!this.state.isUnFolded) {\n if (typeof text === 'string') {\n isEllipsed = chars !== 0 && content.length > chars\n\n text = isEllipsed && chars !== 0 ? `${content.slice(0, chars)}...` : content\n } else {\n let leftChars = chars\n\n for (let index = 0; index < content.length; index++) {\n if (leftChars - content[index].length > 0) {\n leftChars -= content[index].length\n\n text[index] = content[index]\n } else {\n isEllipsed = true\n text[index] = `${content[index].slice(0, leftChars)}...`\n\n break\n }\n }\n }\n } else {\n text = content\n }\n\n if (this.state.isEllipsed !== isEllipsed) setTimeout(() => this.setState({ isEllipsed }))\n\n return typeof text === 'string' ? (\n <Text {...props}>{this.getQuted(text)}</Text>\n ) : (\n <Styled.Ul>\n {text.map((item, index) => (\n <Styled.Li key={index}>\n <Text {...props} display='inline'>\n {item}\n </Text>\n </Styled.Li>\n ))}\n </Styled.Ul>\n )\n }\n\n getQuted = (content: string) => (this.props.quoted ? `«${content}»` : content)\n\n toggle = () => {\n this.setState({ isUnFolded: !this.state.isUnFolded })\n }\n\n render() {\n const {\n className = '',\n style,\n moreText = 'Читать полностью',\n lessText = 'Свернуть',\n showToggler = true,\n ...restProps\n } = this.props\n const { isUnFolded, isEllipsed } = this.state\n\n return (\n <div className={className} style={style}>\n {this.getContent(restProps)}\n {showToggler && isEllipsed ? (\n <Spacer marginTop={16} marginBottom={1}>\n {/* eslint-disable-next-line react/jsx-handler-names */}\n <Anchor pseudo onClick={this.toggle}>\n {isUnFolded ? lessText : moreText}\n </Anchor>\n </Spacer>\n ) : null}\n </div>\n )\n }\n}\n"],"names":["TextEllipse","Component","static","constructor","props","super","this","state","isUnFolded","isEllipsed","componentDidUpdate","content","toggle","getContent","chars","text","length","slice","leftChars","index","setTimeout","setState","_jsx","Text","children","getQuted","Styled","map","item","display","quoted","render","className","style","moreText","lessText","showToggler","restProps","_jsxs","Spacer","marginTop","marginBottom","Anchor","pseudo","onClick"],"mappings":"yNAoCO,MAAMA,oBAAoBC,UAC/BC,mBAAqB,eAErBC,WAAAA,CAAYC,GACVC,MAAMD,GAENE,KAAKC,MAAQ,CACXC,YAAY,EACZC,YAAY,EAEhB,CAEAC,kBAAAA,EAAmBC,QAAEA,IACfA,IAAYL,KAAKF,MAAMO,SAAWL,KAAKC,MAAMC,YAC/CF,KAAKM,QAET,CAEAC,WAAcT,IACZ,MAAMO,QAAEA,EAAOG,MAAEA,EAAQ,GAAMR,KAAKF,MAEpC,IAAKO,EAAS,MAAO,GAErB,IAAIF,WAAEA,GAAeH,KAAKC,MAC1B,IAAIQ,SAAiCJ,GAAY,SAAW,GAAK,GAEjE,GAAKL,KAAKC,MAAMC,WAsBdO,EAAOJ,OArBP,UAAWI,GAAS,SAClBN,EAAaK,IAAU,GAAKH,EAAQK,OAASF,EAE7CC,EAAON,GAAcK,IAAU,EAAI,GAAGH,EAAQM,MAAM,EAAGH,QAAcH,MAChE,CACL,IAAIO,EAAYJ,EAEhB,IAAK,IAAIK,EAAQ,EAAGA,EAAQR,EAAQK,OAAQG,IAAS,CACnD,KAAID,EAAYP,EAAQQ,GAAOH,OAAS,GAIjC,CACLP,GAAa,EACbM,EAAKI,GAAS,GAAGR,EAAQQ,GAAOF,MAAM,EAAGC,QAEzC,KACF,CAREA,GAAaP,EAAQQ,GAAOH,OAE5BD,EAAKI,GAASR,EAAQQ,EAO1B,CACF,CAOF,OAFIb,KAAKC,MAAME,aAAeA,GAAYW,YAAW,IAAMd,KAAKe,SAAS,CAAEZ,wBAE7DM,GAAS,SACrBO,IAACC,KAAI,IAAKnB,EAAKoB,SAAGlB,KAAKmB,SAASV,KAEhCO,IAACI,GAAS,CAAAF,SACPT,EAAKY,KAAI,CAACC,EAAMT,IACfG,IAACI,GAAS,CAAAF,SACRF,IAACC,KAAI,IAAKnB,EAAOyB,QAAQ,SAAQL,SAC9BI,KAFWT,MAOrB,EAGHM,SAAYd,GAAqBL,KAAKF,MAAM0B,OAAS,IAAInB,KAAaA,EAEtEC,OAASA,KACPN,KAAKe,SAAS,CAAEb,YAAaF,KAAKC,MAAMC,YAAa,EAGvDuB,MAAAA,GACE,MAAMC,UACJA,EAAY,GAAEC,MACdA,EAAKC,SACLA,EAAW,mBAAkBC,SAC7BA,EAAW,WAAUC,YACrBA,GAAc,KACXC,GACD/B,KAAKF,MACT,MAAMI,WAAEA,EAAUC,WAAEA,GAAeH,KAAKC,MAExC,OACE+B,KAAA,MAAA,CAAKN,UAAWA,EAAWC,MAAOA,EAAMT,SACrC,CAAAlB,KAAKO,WAAWwB,GAChBD,GAAe3B,EACda,IAACiB,OAAM,CAACC,UAAW,GAAIC,aAAc,EAAEjB,SAErCF,IAACoB,OAAM,CAACC,QAAM,EAACC,QAAStC,KAAKM,OAAOY,SACjChB,EAAa2B,EAAWD,MAG3B,OAGV"}
@@ -1,2 +1,2 @@
1
- 'use strict';var React=require('react');var styled=require('styled-components');var nanoid=require('nanoid');var iconPack=require('@foxford/icon-pack');var withMergedProps=require('../../hocs/withMergedProps.js');var useResizable=require('../../hooks/useResizable.js');var misc=require('../../shared/utils/misc.js');var constants=require('./constants.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');const Textarea=withMergedProps.withMergedProps(React.forwardRef(((e,r)=>{const t=styled.useTheme();const{size:a="m",rows:n=2,maxRows:i=30,labelPosition:o="dynamic",primary:s=!0,width:l=t.defaultInputControlsWidth,autosize:m=!0,rounded:c=!0,color:g="mineShaft",placeholderColor:u="silver",autoRows:d,resize:h,contrast:X,inline:p,secondary:L,success:R,error:b,sizeXXS:S,sizeXS:f,sizeS:x,sizeM:z,sizeL:w,sizeXL:v,sizes:M,sizeUnits:j,margin:T,marginXXS:C,marginXS:y,marginS:B,marginM:k,marginL:I,marginXL:D,marginTop:F,marginTopXXS:P,marginTopXS:q,marginTopS:N,marginTopM:E,marginTopL:H,marginTopXL:_,marginRight:A,marginRightXXS:O,marginRightXS:U,marginRightS:W,marginRightM:Z,marginRightL:G,marginRightXL:K,marginBottom:V,marginBottomXXS:J,marginBottomXS:Q,marginBottomS:Y,marginBottomM:$,marginBottomL:ee,marginBottomXL:re,marginLeft:te,marginLeftXXS:ae,marginLeftXS:ne,marginLeftS:ie,marginLeftM:oe,marginLeftL:se,marginLeftXL:le,widthXXS:me,widthXS:ce,widthS:ge,widthM:ue,widthL:de,widthXL:he,preset:Xe,palette:pe,label:Le,fluid:Re,className:be,style:Se,disabled:fe,...xe}=e;const ze=React.useRef(null);const we=React.useRef(null);const ve=React.useRef(null);React.useImperativeHandle(r,(()=>ze.current),[]);const[Me,je,Te]=useResizable.useResizable({target:ve,direction:h});const Ce=React.useMemo((()=>nanoid.nanoid()),[]);const[ye,Be]=React.useState((()=>{const e=xe.value??xe.defaultValue;return typeof e=='string'&&e.length>0}));const[ke,Ie]=React.useState((()=>Math.min(n,i)));const De=Xe==='brand'&&d||Xe!=='brand'&&m?ke:Math.min(n,i);const Fe=h==='horizontal'?'ew-resize':h==='vertical'?'ns-resize':'nwse-resize';const Pe=React.useCallback((()=>{if(!ze.current)return;if(Xe==='brand'){if(!we.current)return;we.current.value=ze.current.value;const e=Math.max(Math.round(we.current.scrollHeight/we.current.clientHeight),n);return void Ie(Math.min(e,i))}const e=getComputedStyle(ze.current);const r=parseFloat(e.lineHeight);const t=Math.max(Math.round((ze.current.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom))/(Number.isNaN(r)?parseFloat(e.fontSize)*1.2:r)),n);Ie((e=>t>e?Math.min(t,i):ze.current&&!ze.current.value?n:e))}),[Xe,n,i]);return React.useLayoutEffect((()=>{Xe==='brand'&&typeof xe.value=='string'&&ze.current&&ze.current!==document.activeElement&&Be(xe.value.length>0)}),[Xe,xe.value]),React.useEffect((()=>{const e=misc.createThrottledCallback(Pe,200);return(Xe==='brand'&&d||Xe!=='brand'&&m)&&(Pe(),window.addEventListener('resize',e)),()=>{window.removeEventListener('resize',e)}}),[Xe,d,m,Pe]),Xe!=='brand'?jsxRuntime.jsx(style.Root,{...xe,ref:ze,className:be,style:Se,onChange:e=>{m&&Pe(),xe.onChange&&xe.onChange(e)},rows:De,color:g,rounded:c,placeholderColor:u,disabled:fe,error:b,fluid:Re,width:l,widthXXS:me,widthXS:ce,widthS:ge,widthM:ue,widthL:de,widthXL:he}):jsxRuntime.jsx(FormInputLabel.FormInputLabel,{ref:ve,size:a,sizeXXS:S,sizeXS:f,sizeS:x,sizeM:z,sizeL:w,sizeXL:v,sizes:M,sizeUnits:j,margin:T,marginXXS:C,marginXS:y,marginS:B,marginM:k,marginL:I,marginXL:D,marginTop:F,marginTopXXS:P,marginTopXS:q,marginTopS:N,marginTopM:E,marginTopL:H,marginTopXL:_,marginRight:A,marginRightXXS:O,marginRightXS:U,marginRightS:W,marginRightM:Z,marginRightL:G,marginRightXL:K,marginBottom:V,marginBottomXXS:J,marginBottomXS:Q,marginBottomS:Y,marginBottomM:$,marginBottomL:ee,marginBottomXL:re,marginLeft:te,marginLeftXXS:ae,marginLeftXS:ne,marginLeftS:ie,marginLeftM:oe,marginLeftL:se,marginLeftXL:le,className:be,style:Se,contrast:X,error:b,inline:p,label:Le,labelId:Ce,labelPosition:o,disabled:fe,active:ye,primary:s,secondary:L,success:R,palette:{color:fe?pe.colorDisabled:pe.color,backgroundColor:fe?pe.backgroundColorDisabled:pe.backgroundColor,backgroundColorHover:fe?pe.backgroundColorDisabled:pe.backgroundColorHover,borderColor:fe?pe.borderColorDisabled:pe.borderColor},onClick:()=>{ze.current&&ze.current.focus()},onFocus:()=>{Be(!0)},onPointerDown:e=>{e.target!==ze.current&&e.target instanceof Node&&e.preventDefault()},onBlur:e=>{ze.current&&!e.currentTarget.contains(e.relatedTarget)&&Be(Boolean(ze.current.value))},overflow:"hidden",inputPosition:"stretch",input:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d&&jsxRuntime.jsx(style.TextareaMimic,{ref:we,rows:1}),jsxRuntime.jsx(style.Textarea,{...xe,ref:ze,"aria-labelledby":Le?Ce:void 0,disabled:fe,onChange:e=>{d&&Pe(),xe.onChange&&xe.onChange(e)},rows:De,palette:{color:pe.color,colorDisabled:pe.colorDisabled,placeholderColor:pe.placeholderColor,placeholderColorDisabled:pe.placeholderColorDisabled}})]}),addon:h?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Me&&jsxRuntime.jsx(style.ResizeGlobals,{cursor:Fe}),jsxRuntime.jsx(style.ResizeIcon,{size:"l",icon:jsxRuntime.jsx(iconPack.ResizeHandle,{}),color:"border-onmain-default-small",tabIndex:0,onPointerDown:je,onKeyDown:Te,cursor:Fe})]}):void 0})})),{displayName:"Textarea",sizes:e=>e.label?constants.SIZES_WITH_LABEL:constants.SIZES});exports.COMPONENT_NAME="Textarea",exports.Textarea=Textarea;
1
+ 'use strict';var React=require('react');var styled=require('styled-components');var nanoid=require('nanoid');var iconPack=require('@foxford/icon-pack');var withMergedProps=require('../../hocs/withMergedProps.js');var useResizable=require('../../hooks/useResizable.js');var misc=require('../../shared/utils/misc.js');var constants=require('./constants.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');const Textarea=withMergedProps.withMergedProps(React.forwardRef(((e,r)=>{const t=styled.useTheme();const{size:a="m",rows:n=2,maxRows:i=30,labelPosition:o="dynamic",primary:s=!0,width:l=t.defaultInputControlsWidth,autosize:m=!0,rounded:c=!0,color:g="mineShaft",placeholderColor:u="silver",autoRows:d,resize:h,contrast:X,inline:p,secondary:L,success:R,error:b,sizeXXS:S,sizeXS:f,sizeS:x,sizeM:z,sizeL:w,sizeXL:v,sizes:M,sizeUnits:j,margin:T,marginXXS:C,marginXS:y,marginS:B,marginM:k,marginL:I,marginXL:D,marginTop:F,marginTopXXS:P,marginTopXS:q,marginTopS:N,marginTopM:E,marginTopL:H,marginTopXL:_,marginRight:A,marginRightXXS:O,marginRightXS:U,marginRightS:W,marginRightM:Z,marginRightL:G,marginRightXL:K,marginBottom:V,marginBottomXXS:J,marginBottomXS:Q,marginBottomS:Y,marginBottomM:$,marginBottomL:ee,marginBottomXL:re,marginLeft:te,marginLeftXXS:ae,marginLeftXS:ne,marginLeftS:ie,marginLeftM:oe,marginLeftL:se,marginLeftXL:le,widthXXS:me,widthXS:ce,widthS:ge,widthM:ue,widthL:de,widthXL:he,preset:Xe,palette:pe,label:Le,fluid:Re,className:be,style:Se,disabled:fe,...xe}=e;const ze=React.useRef(null);const we=React.useRef(null);const ve=React.useRef(null);React.useImperativeHandle(r,(()=>ze.current),[]);const[Me,je,Te]=useResizable.useResizable({target:ve,direction:h});const Ce=React.useMemo((()=>nanoid.nanoid()),[]);const[ye,Be]=React.useState((()=>{const e=xe.value??xe.defaultValue;return typeof e=='string'&&e.length>0}));const[ke,Ie]=React.useState((()=>Math.min(n,i)));const De=Xe==='brand'&&d||Xe!=='brand'&&m?ke:Math.min(n,i);const Fe=h==='horizontal'?'ew-resize':h==='vertical'?'ns-resize':'nwse-resize';const Pe=React.useCallback((()=>{if(!ze.current)return;if(Xe==='brand'){if(!we.current)return;we.current.value=ze.current.value;const e=Math.max(Math.round(we.current.scrollHeight/we.current.clientHeight),n);return void Ie(Math.min(e,i))}const e=getComputedStyle(ze.current);const r=parseFloat(e.lineHeight);const t=Math.max(Math.round((ze.current.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom))/(Number.isNaN(r)?parseFloat(e.fontSize)*1.2:r)),n);Ie((e=>t>e?Math.min(t,i):ze.current&&!ze.current.value?n:e))}),[Xe,n,i]);return React.useLayoutEffect((()=>{Xe==='brand'&&typeof xe.value=='string'&&ze.current&&ze.current!==document.activeElement&&Be(xe.value.length>0)}),[Xe,xe.value]),React.useEffect((()=>{const e=misc.createThrottledCallback(Pe,200);return(Xe==='brand'&&d||Xe!=='brand'&&m)&&(Pe(),window.addEventListener('resize',e)),()=>{window.removeEventListener('resize',e)}}),[Xe,d,m,Pe]),Xe!=='brand'?jsxRuntime.jsx(style.Root,{...xe,ref:ze,className:be,style:Se,onChange:e=>{m&&Pe(),xe.onChange&&xe.onChange(e)},rows:De,color:g,rounded:c,placeholderColor:u,disabled:fe,error:b,fluid:Re,width:l,widthXXS:me,widthXS:ce,widthS:ge,widthM:ue,widthL:de,widthXL:he}):jsxRuntime.jsx(FormInputLabel.FormInputLabel,{ref:ve,size:a,sizeXXS:S,sizeXS:f,sizeS:x,sizeM:z,sizeL:w,sizeXL:v,sizes:M,sizeUnits:j,margin:T,marginXXS:C,marginXS:y,marginS:B,marginM:k,marginL:I,marginXL:D,marginTop:F,marginTopXXS:P,marginTopXS:q,marginTopS:N,marginTopM:E,marginTopL:H,marginTopXL:_,marginRight:A,marginRightXXS:O,marginRightXS:U,marginRightS:W,marginRightM:Z,marginRightL:G,marginRightXL:K,marginBottom:V,marginBottomXXS:J,marginBottomXS:Q,marginBottomS:Y,marginBottomM:$,marginBottomL:ee,marginBottomXL:re,marginLeft:te,marginLeftXXS:ae,marginLeftXS:ne,marginLeftS:ie,marginLeftM:oe,marginLeftL:se,marginLeftXL:le,className:be,style:Se,contrast:X,error:b,inline:p,label:Le,labelId:Ce,labelPosition:o,disabled:fe,active:ye,primary:s,secondary:L,success:R,palette:{color:fe?pe.colorDisabled:pe.color,backgroundColor:fe?pe.backgroundColorDisabled:pe.backgroundColor,backgroundColorHover:fe?pe.backgroundColorDisabled:pe.backgroundColorHover,borderColor:fe?pe.borderColorDisabled:pe.borderColor},onClick:()=>{ze.current&&ze.current.focus()},onFocus:()=>{Be(!0)},onPointerDown:e=>{e.target!==ze.current&&e.target instanceof Node&&e.preventDefault()},onBlur:e=>{ze.current&&!e.currentTarget.contains(e.relatedTarget)&&Be(Boolean(ze.current.value))},overflow:"hidden",inputPosition:"stretch",input:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d?jsxRuntime.jsx(style.TextareaMimic,{ref:we,rows:1}):null,jsxRuntime.jsx(style.Textarea,{...xe,ref:ze,"aria-labelledby":Le?Ce:void 0,disabled:fe,onChange:e=>{d&&Pe(),xe.onChange&&xe.onChange(e)},rows:De,palette:{color:pe.color,colorDisabled:pe.colorDisabled,placeholderColor:pe.placeholderColor,placeholderColorDisabled:pe.placeholderColorDisabled}})]}),addon:h?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Me?jsxRuntime.jsx(style.ResizeGlobals,{cursor:Fe}):null,jsxRuntime.jsx(style.ResizeIcon,{size:"l",icon:jsxRuntime.jsx(iconPack.ResizeHandle,{}),color:"border-onmain-default-small",tabIndex:0,onPointerDown:je,onKeyDown:Te,cursor:Fe})]}):void 0})})),{displayName:"Textarea",sizes:e=>e.label?constants.SIZES_WITH_LABEL:constants.SIZES});exports.COMPONENT_NAME="Textarea",exports.Textarea=Textarea;
2
2
  //# sourceMappingURL=Textarea.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.js","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n} from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { ResizeHandle } from '@foxford/icon-pack'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { useResizable } from 'hooks/useResizable'\nimport { createThrottledCallback } from 'shared/utils/misc'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { SIZES, SIZES_WITH_LABEL } from './constants'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<textarea\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<textarea\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Textarea/types.ts).\n */\nconst Textarea: React.ForwardRefExoticComponent<TextareaProps> = withMergedProps<TextareaProps, HTMLTextAreaElement>(\n forwardRef((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rows = 2,\n maxRows = 30,\n labelPosition = 'dynamic',\n primary = true,\n width = theme.defaultInputControlsWidth,\n autosize = true,\n rounded = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n autoRows,\n resize,\n contrast,\n inline,\n secondary,\n success,\n error,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n preset,\n palette,\n label,\n fluid,\n className,\n style,\n disabled,\n ...textareaProps\n } = props\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n\n const textareaMimicRef = useRef<HTMLTextAreaElement>(null)\n\n const formInputLabelRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(forwardedRef, () => textareaRef.current as HTMLTextAreaElement, [])\n\n const [resizing, handleResizeStart, handleResizeOnNudge] = useResizable<HTMLDivElement, HTMLSpanElement>({\n target: formInputLabelRef,\n direction: resize,\n })\n\n const labelId = useMemo(() => nanoid(), [])\n\n const [active, setActive] = useState(() => {\n const valueInit = textareaProps.value ?? textareaProps.defaultValue\n\n return typeof valueInit === 'string' && valueInit.length > 0\n })\n\n const [autoRowsCount, setAutoRowsCount] = useState(() => Math.min(rows, maxRows))\n\n const rowsVisible =\n (preset === 'brand' && autoRows) || (preset !== 'brand' && autosize) ? autoRowsCount : Math.min(rows, maxRows)\n\n const cursorResize = resize === 'horizontal' ? 'ew-resize' : resize === 'vertical' ? 'ns-resize' : 'nwse-resize'\n\n const updateAutoRowsCount = useCallback(() => {\n if (!textareaRef.current) return\n\n if (preset === 'brand') {\n if (!textareaMimicRef.current) return\n\n textareaMimicRef.current.value = textareaRef.current.value\n\n const nextRows = Math.max(\n Math.round(textareaMimicRef.current.scrollHeight / textareaMimicRef.current.clientHeight),\n rows\n )\n\n setAutoRowsCount(Math.min(nextRows, maxRows))\n\n return\n }\n\n const styles = getComputedStyle(textareaRef.current)\n\n const lineHeight = parseFloat(styles.lineHeight)\n\n const nextRows = Math.max(\n Math.round(\n (textareaRef.current.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom)) /\n (Number.isNaN(lineHeight) ? parseFloat(styles.fontSize) * 1.2 : lineHeight)\n ),\n rows\n )\n\n setAutoRowsCount((prevRows) => {\n if (nextRows > prevRows) return Math.min(nextRows, maxRows)\n if (textareaRef.current && !textareaRef.current.value) return rows\n\n return prevRows\n })\n }, [preset, rows, maxRows])\n\n useLayoutEffect(() => {\n if (\n preset === 'brand' &&\n typeof textareaProps.value === 'string' &&\n textareaRef.current &&\n textareaRef.current !== document.activeElement\n ) {\n setActive(textareaProps.value.length > 0)\n }\n }, [preset, textareaProps.value])\n\n useEffect(() => {\n const handleResize = createThrottledCallback<UIEvent>(updateAutoRowsCount, 200)\n\n if ((preset === 'brand' && autoRows) || (preset !== 'brand' && autosize)) {\n updateAutoRowsCount()\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [preset, autoRows, autosize, updateAutoRowsCount])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...textareaProps}\n ref={textareaRef}\n className={className}\n style={style}\n onChange={(evt) => {\n if (autosize) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n disabled={disabled}\n error={error}\n fluid={fluid}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n />\n )\n }\n\n return (\n <FormInputLabel\n ref={formInputLabelRef}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n className={className}\n style={style}\n contrast={contrast}\n error={error}\n inline={inline}\n label={label}\n labelId={labelId}\n labelPosition={labelPosition}\n disabled={disabled}\n active={active}\n primary={primary}\n secondary={secondary}\n success={success}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={() => {\n if (textareaRef.current) {\n textareaRef.current.focus()\n }\n }}\n onFocus={() => {\n setActive(true)\n }}\n onPointerDown={(evt) => {\n if (evt.target === textareaRef.current || !(evt.target instanceof Node)) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (textareaRef.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setActive(Boolean(textareaRef.current.value))\n }\n }}\n overflow='hidden'\n inputPosition='stretch'\n input={\n <>\n {autoRows && <Styled.TextareaMimic ref={textareaMimicRef} rows={1} />}\n <Styled.Textarea\n {...textareaProps}\n ref={textareaRef}\n aria-labelledby={label ? labelId : undefined}\n disabled={disabled}\n onChange={(evt) => {\n if (autoRows) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n />\n </>\n }\n addon={\n resize ? (\n <>\n {resizing && <Styled.ResizeGlobals cursor={cursorResize} />}\n <Styled.ResizeIcon\n size='l'\n icon={<ResizeHandle />}\n color='border-onmain-default-small'\n tabIndex={0}\n onPointerDown={handleResizeStart}\n onKeyDown={handleResizeOnNudge}\n cursor={cursorResize}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => (props.label ? SIZES_WITH_LABEL : SIZES),\n }\n)\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["Textarea","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rows","maxRows","labelPosition","primary","width","defaultInputControlsWidth","autosize","rounded","color","placeholderColor","autoRows","resize","contrast","inline","secondary","success","error","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","widthXXS","widthXS","widthS","widthM","widthL","widthXL","preset","palette","label","fluid","className","style","disabled","textareaProps","textareaRef","useRef","textareaMimicRef","formInputLabelRef","useImperativeHandle","current","resizing","handleResizeStart","handleResizeOnNudge","useResizable","target","direction","labelId","useMemo","nanoid","active","setActive","useState","valueInit","value","defaultValue","length","autoRowsCount","setAutoRowsCount","Math","min","rowsVisible","cursorResize","updateAutoRowsCount","useCallback","nextRows","max","round","scrollHeight","clientHeight","styles","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","Number","isNaN","fontSize","prevRows","useLayoutEffect","document","activeElement","useEffect","handleResize","createThrottledCallback","window","addEventListener","removeEventListener","_jsx","Styled","ref","onChange","evt","FormInputLabel","colorDisabled","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","focus","onFocus","onPointerDown","Node","preventDefault","onBlur","currentTarget","contains","relatedTarget","Boolean","overflow","inputPosition","input","_jsxs","jsxs","_Fragment","children","jsx","undefined","placeholderColorDisabled","addon","cursor","icon","ResizeHandle","tabIndex","onKeyDown","displayName","SIZES_WITH_LABEL","SIZES"],"mappings":"kfAiCMA,MAA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GAAU4F,KACV7B,GAAc0D,UAAU1D,GAAc0D,SAASC,EAAI,EAEzDpI,KAAMoG,GACNjC,QAAS,CACP3D,MAAO2D,GAAQ3D,MACf8H,cAAenE,GAAQmE,cACvB7H,iBAAkB0D,GAAQ1D,iBAC1BuJ,yBAA0B7F,GAAQ6F,+BAK1CC,MACEtJ,EACE+I,WAAAC,KAAAC,oBAAA,CAAAC,UACG7E,IAAYgD,WAAA8B,IAAC7B,oBAAoB,CAACiC,OAAQ7D,KAC3C2B,WAAA8B,IAAC7B,iBAAiB,CAChBlI,KAAK,IACLoK,KAAMnC,WAAAA,IAACoC,SAAYA,iBACnB5J,MAAM,8BACN6J,SAAU,EACVtB,cAAe9D,GACfqF,UAAWpF,GACXgF,OAAQ7D,aAGV0D,GAEN,IAGN,CACEQ,YArVmB,WAsVnBhJ,MAAQ5B,GAAWA,EAAMyE,MAAQoG,UAAgBA,iBAAGC,UAAAA,+BAtVjC"}
1
+ {"version":3,"file":"Textarea.js","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n} from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { ResizeHandle } from '@foxford/icon-pack'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useResizable } from 'hooks/useResizable'\nimport { createThrottledCallback } from 'shared/utils/misc'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { SIZES, SIZES_WITH_LABEL } from './constants'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<textarea\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<textarea\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Textarea/types.ts).\n */\nconst Textarea: React.ForwardRefExoticComponent<TextareaProps> = withMergedProps<TextareaProps, HTMLTextAreaElement>(\n forwardRef<HTMLTextAreaElement, MergedProps<TextareaProps>>((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rows = 2,\n maxRows = 30,\n labelPosition = 'dynamic',\n primary = true,\n width = theme.defaultInputControlsWidth,\n autosize = true,\n rounded = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n autoRows,\n resize,\n contrast,\n inline,\n secondary,\n success,\n error,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n preset,\n palette,\n label,\n fluid,\n className,\n style,\n disabled,\n ...textareaProps\n } = props\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n\n const textareaMimicRef = useRef<HTMLTextAreaElement>(null)\n\n const formInputLabelRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(forwardedRef, () => textareaRef.current as HTMLTextAreaElement, [])\n\n const [resizing, handleResizeStart, handleResizeOnNudge] = useResizable<HTMLDivElement, HTMLSpanElement>({\n target: formInputLabelRef,\n direction: resize,\n })\n\n const labelId = useMemo(() => nanoid(), [])\n\n const [active, setActive] = useState(() => {\n const valueInit = textareaProps.value ?? textareaProps.defaultValue\n\n return typeof valueInit === 'string' && valueInit.length > 0\n })\n\n const [autoRowsCount, setAutoRowsCount] = useState(() => Math.min(rows, maxRows))\n\n const rowsVisible =\n (preset === 'brand' && autoRows) || (preset !== 'brand' && autosize) ? autoRowsCount : Math.min(rows, maxRows)\n\n const cursorResize = resize === 'horizontal' ? 'ew-resize' : resize === 'vertical' ? 'ns-resize' : 'nwse-resize'\n\n const updateAutoRowsCount = useCallback(() => {\n if (!textareaRef.current) return\n\n if (preset === 'brand') {\n if (!textareaMimicRef.current) return\n\n textareaMimicRef.current.value = textareaRef.current.value\n\n const nextRows = Math.max(\n Math.round(textareaMimicRef.current.scrollHeight / textareaMimicRef.current.clientHeight),\n rows\n )\n\n setAutoRowsCount(Math.min(nextRows, maxRows))\n\n return\n }\n\n const styles = getComputedStyle(textareaRef.current)\n\n const lineHeight = parseFloat(styles.lineHeight)\n\n const nextRows = Math.max(\n Math.round(\n (textareaRef.current.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom)) /\n (Number.isNaN(lineHeight) ? parseFloat(styles.fontSize) * 1.2 : lineHeight)\n ),\n rows\n )\n\n setAutoRowsCount((prevRows) => {\n if (nextRows > prevRows) return Math.min(nextRows, maxRows)\n if (textareaRef.current && !textareaRef.current.value) return rows\n\n return prevRows\n })\n }, [preset, rows, maxRows])\n\n useLayoutEffect(() => {\n if (\n preset === 'brand' &&\n typeof textareaProps.value === 'string' &&\n textareaRef.current &&\n textareaRef.current !== document.activeElement\n ) {\n setActive(textareaProps.value.length > 0)\n }\n }, [preset, textareaProps.value])\n\n useEffect(() => {\n const handleResize = createThrottledCallback<UIEvent>(updateAutoRowsCount, 200)\n\n if ((preset === 'brand' && autoRows) || (preset !== 'brand' && autosize)) {\n updateAutoRowsCount()\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [preset, autoRows, autosize, updateAutoRowsCount])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...textareaProps}\n ref={textareaRef}\n className={className}\n style={style}\n onChange={(evt) => {\n if (autosize) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n disabled={disabled}\n error={error}\n fluid={fluid}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n />\n )\n }\n\n return (\n <FormInputLabel\n ref={formInputLabelRef}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n className={className}\n style={style}\n contrast={contrast}\n error={error}\n inline={inline}\n label={label}\n labelId={labelId}\n labelPosition={labelPosition}\n disabled={disabled}\n active={active}\n primary={primary}\n secondary={secondary}\n success={success}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={() => {\n if (textareaRef.current) {\n textareaRef.current.focus()\n }\n }}\n onFocus={() => {\n setActive(true)\n }}\n onPointerDown={(evt) => {\n if (evt.target === textareaRef.current || !(evt.target instanceof Node)) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (textareaRef.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setActive(Boolean(textareaRef.current.value))\n }\n }}\n overflow='hidden'\n inputPosition='stretch'\n input={\n <>\n {autoRows ? <Styled.TextareaMimic ref={textareaMimicRef} rows={1} /> : null}\n <Styled.Textarea\n {...textareaProps}\n ref={textareaRef}\n aria-labelledby={label ? labelId : undefined}\n disabled={disabled}\n onChange={(evt) => {\n if (autoRows) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n />\n </>\n }\n addon={\n resize ? (\n <>\n {resizing ? <Styled.ResizeGlobals cursor={cursorResize} /> : null}\n <Styled.ResizeIcon\n size='l'\n icon={<ResizeHandle />}\n color='border-onmain-default-small'\n tabIndex={0}\n onPointerDown={handleResizeStart}\n onKeyDown={handleResizeOnNudge}\n cursor={cursorResize}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => (props.label ? SIZES_WITH_LABEL : SIZES),\n }\n)\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["Textarea","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rows","maxRows","labelPosition","primary","width","defaultInputControlsWidth","autosize","rounded","color","placeholderColor","autoRows","resize","contrast","inline","secondary","success","error","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","widthXXS","widthXS","widthS","widthM","widthL","widthXL","preset","palette","label","fluid","className","style","disabled","textareaProps","textareaRef","useRef","textareaMimicRef","formInputLabelRef","useImperativeHandle","current","resizing","handleResizeStart","handleResizeOnNudge","useResizable","target","direction","labelId","useMemo","nanoid","active","setActive","useState","valueInit","value","defaultValue","length","autoRowsCount","setAutoRowsCount","Math","min","rowsVisible","cursorResize","updateAutoRowsCount","useCallback","nextRows","max","round","scrollHeight","clientHeight","styles","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","Number","isNaN","fontSize","prevRows","useLayoutEffect","document","activeElement","useEffect","handleResize","createThrottledCallback","window","addEventListener","removeEventListener","_jsx","Styled","ref","onChange","evt","FormInputLabel","colorDisabled","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","focus","onFocus","onPointerDown","Node","preventDefault","onBlur","currentTarget","contains","relatedTarget","Boolean","overflow","inputPosition","input","_jsxs","jsxs","_Fragment","children","jsx","undefined","placeholderColorDisabled","addon","cursor","icon","ResizeHandle","tabIndex","onKeyDown","displayName","SIZES_WITH_LABEL","SIZES"],"mappings":"kfAkCMA,MAAAA,SAA2DC,gBAAAA,gBAC/DC,MAAAA,YAA4D,CAACC,EAAOC,KAClE,MAAMC,EAAQC,OAAAA,WAEd,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,EAACC,QACRA,EAAU,GAAEC,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B0D,GAAQ1D,iBAC1BuJ,yBAA0B7F,GAAQ6F,+BAK1CC,MACEtJ,EACE+I,WAAAC,KAAAC,oBAAA,CAAAC,UACG7E,GAAWgD,WAAA8B,IAAC7B,oBAAoB,CAACiC,OAAQ7D,KAAmB,KAC7D2B,WAAA8B,IAAC7B,iBAAiB,CAChBlI,KAAK,IACLoK,KAAMnC,WAAAA,IAACoC,SAAYA,iBACnB5J,MAAM,8BACN6J,SAAU,EACVtB,cAAe9D,GACfqF,UAAWpF,GACXgF,OAAQ7D,aAGV0D,GAEN,IAGN,CACEQ,YArVmB,WAsVnBhJ,MAAQ5B,GAAWA,EAAMyE,MAAQoG,UAAgBA,iBAAGC,UAAAA,+BAtVjC"}
@@ -1,2 +1,2 @@
1
- import{forwardRef,useRef,useImperativeHandle,useMemo,useState,useCallback,useLayoutEffect,useEffect}from'react';import{useTheme}from'styled-components';import{nanoid}from'nanoid';import{ResizeHandle}from'@foxford/icon-pack';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useResizable}from'../../hooks/useResizable.mjs';import{createThrottledCallback}from'../../shared/utils/misc.mjs';import{SIZES_WITH_LABEL,SIZES}from'./constants.mjs';import{Root,TextareaMimic,Textarea as Textarea$1,ResizeGlobals,ResizeIcon}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{FormInputLabel}from'../FormInputLabel/FormInputLabel.mjs';const COMPONENT_NAME='Textarea';const Textarea=withMergedProps(forwardRef(((e,r)=>{const o=useTheme();const{size:t="m",rows:a=2,maxRows:n=30,labelPosition:i="dynamic",primary:s=!0,width:m=o.defaultInputControlsWidth,autosize:l=!0,rounded:g=!0,color:c="mineShaft",placeholderColor:d="silver",autoRows:u,resize:h,contrast:p,inline:f,secondary:S,success:X,error:L,sizeXXS:b,sizeXS:z,sizeS:w,sizeM:T,sizeL:M,sizeXL:R,sizes:C,sizeUnits:x,margin:v,marginXXS:B,marginXS:j,marginS:y,marginM:E,marginL:I,marginXL:N,marginTop:k,marginTopXXS:D,marginTopXS:F,marginTopS:H,marginTopM:P,marginTopL:_,marginTopXL:A,marginRight:O,marginRightXXS:Z,marginRightXS:W,marginRightS:G,marginRightM:U,marginRightL:$,marginRightXL:K,marginBottom:V,marginBottomXXS:q,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:oe,marginLeftXXS:te,marginLeftXS:ae,marginLeftS:ne,marginLeftM:ie,marginLeftL:se,marginLeftXL:me,widthXXS:le,widthXS:ge,widthS:ce,widthM:de,widthL:ue,widthXL:he,preset:pe,palette:fe,label:Se,fluid:Xe,className:Le,style:be,disabled:ze,...we}=e;const Te=useRef(null);const Me=useRef(null);const Re=useRef(null);useImperativeHandle(r,(()=>Te.current),[]);const[Ce,xe,ve]=useResizable({target:Re,direction:h});const Be=useMemo((()=>nanoid()),[]);const[je,ye]=useState((()=>{const e=we.value??we.defaultValue;return typeof e=='string'&&e.length>0}));const[Ee,Ie]=useState((()=>Math.min(a,n)));const Ne=pe==='brand'&&u||pe!=='brand'&&l?Ee:Math.min(a,n);const ke=h==='horizontal'?'ew-resize':h==='vertical'?'ns-resize':'nwse-resize';const De=useCallback((()=>{if(!Te.current)return;if(pe==='brand'){if(!Me.current)return;Me.current.value=Te.current.value;const e=Math.max(Math.round(Me.current.scrollHeight/Me.current.clientHeight),a);return void Ie(Math.min(e,n))}const e=getComputedStyle(Te.current);const r=parseFloat(e.lineHeight);const o=Math.max(Math.round((Te.current.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom))/(Number.isNaN(r)?parseFloat(e.fontSize)*1.2:r)),a);Ie((e=>o>e?Math.min(o,n):Te.current&&!Te.current.value?a:e))}),[pe,a,n]);return useLayoutEffect((()=>{pe==='brand'&&typeof we.value=='string'&&Te.current&&Te.current!==document.activeElement&&ye(we.value.length>0)}),[pe,we.value]),useEffect((()=>{const e=createThrottledCallback(De,200);return(pe==='brand'&&u||pe!=='brand'&&l)&&(De(),window.addEventListener('resize',e)),()=>{window.removeEventListener('resize',e)}}),[pe,u,l,De]),pe!=='brand'?jsx(Root,{...we,ref:Te,className:Le,style:be,onChange:e=>{l&&De(),we.onChange&&we.onChange(e)},rows:Ne,color:c,rounded:g,placeholderColor:d,disabled:ze,error:L,fluid:Xe,width:m,widthXXS:le,widthXS:ge,widthS:ce,widthM:de,widthL:ue,widthXL:he}):jsx(FormInputLabel,{ref:Re,size:t,sizeXXS:b,sizeXS:z,sizeS:w,sizeM:T,sizeL:M,sizeXL:R,sizes:C,sizeUnits:x,margin:v,marginXXS:B,marginXS:j,marginS:y,marginM:E,marginL:I,marginXL:N,marginTop:k,marginTopXXS:D,marginTopXS:F,marginTopS:H,marginTopM:P,marginTopL:_,marginTopXL:A,marginRight:O,marginRightXXS:Z,marginRightXS:W,marginRightS:G,marginRightM:U,marginRightL:$,marginRightXL:K,marginBottom:V,marginBottomXXS:q,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:oe,marginLeftXXS:te,marginLeftXS:ae,marginLeftS:ne,marginLeftM:ie,marginLeftL:se,marginLeftXL:me,className:Le,style:be,contrast:p,error:L,inline:f,label:Se,labelId:Be,labelPosition:i,disabled:ze,active:je,primary:s,secondary:S,success:X,palette:{color:ze?fe.colorDisabled:fe.color,backgroundColor:ze?fe.backgroundColorDisabled:fe.backgroundColor,backgroundColorHover:ze?fe.backgroundColorDisabled:fe.backgroundColorHover,borderColor:ze?fe.borderColorDisabled:fe.borderColor},onClick:()=>{Te.current&&Te.current.focus()},onFocus:()=>{ye(!0)},onPointerDown:e=>{e.target!==Te.current&&e.target instanceof Node&&e.preventDefault()},onBlur:e=>{Te.current&&!e.currentTarget.contains(e.relatedTarget)&&ye(Boolean(Te.current.value))},overflow:"hidden",inputPosition:"stretch",input:jsxs(Fragment,{children:[u&&jsx(TextareaMimic,{ref:Me,rows:1}),jsx(Textarea$1,{...we,ref:Te,"aria-labelledby":Se?Be:void 0,disabled:ze,onChange:e=>{u&&De(),we.onChange&&we.onChange(e)},rows:Ne,palette:{color:fe.color,colorDisabled:fe.colorDisabled,placeholderColor:fe.placeholderColor,placeholderColorDisabled:fe.placeholderColorDisabled}})]}),addon:h?jsxs(Fragment,{children:[Ce&&jsx(ResizeGlobals,{cursor:ke}),jsx(ResizeIcon,{size:"l",icon:jsx(ResizeHandle,{}),color:"border-onmain-default-small",tabIndex:0,onPointerDown:xe,onKeyDown:ve,cursor:ke})]}):void 0})})),{displayName:"Textarea",sizes:e=>e.label?SIZES_WITH_LABEL:SIZES});export{COMPONENT_NAME,Textarea};
1
+ import{forwardRef,useRef,useImperativeHandle,useMemo,useState,useCallback,useLayoutEffect,useEffect}from'react';import{useTheme}from'styled-components';import{nanoid}from'nanoid';import{ResizeHandle}from'@foxford/icon-pack';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useResizable}from'../../hooks/useResizable.mjs';import{createThrottledCallback}from'../../shared/utils/misc.mjs';import{SIZES_WITH_LABEL,SIZES}from'./constants.mjs';import{Root,TextareaMimic,Textarea as Textarea$1,ResizeGlobals,ResizeIcon}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{FormInputLabel}from'../FormInputLabel/FormInputLabel.mjs';const COMPONENT_NAME='Textarea';const Textarea=withMergedProps(forwardRef(((e,r)=>{const o=useTheme();const{size:t="m",rows:a=2,maxRows:n=30,labelPosition:i="dynamic",primary:s=!0,width:l=o.defaultInputControlsWidth,autosize:m=!0,rounded:g=!0,color:c="mineShaft",placeholderColor:d="silver",autoRows:u,resize:h,contrast:p,inline:f,secondary:S,success:X,error:L,sizeXXS:b,sizeXS:z,sizeS:w,sizeM:T,sizeL:M,sizeXL:R,sizes:C,sizeUnits:x,margin:v,marginXXS:B,marginXS:j,marginS:y,marginM:E,marginL:I,marginXL:N,marginTop:k,marginTopXXS:D,marginTopXS:F,marginTopS:H,marginTopM:P,marginTopL:_,marginTopXL:A,marginRight:O,marginRightXXS:Z,marginRightXS:W,marginRightS:G,marginRightM:U,marginRightL:$,marginRightXL:K,marginBottom:V,marginBottomXXS:q,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:oe,marginLeftXXS:te,marginLeftXS:ae,marginLeftS:ne,marginLeftM:ie,marginLeftL:se,marginLeftXL:le,widthXXS:me,widthXS:ge,widthS:ce,widthM:de,widthL:ue,widthXL:he,preset:pe,palette:fe,label:Se,fluid:Xe,className:Le,style:be,disabled:ze,...we}=e;const Te=useRef(null);const Me=useRef(null);const Re=useRef(null);useImperativeHandle(r,(()=>Te.current),[]);const[Ce,xe,ve]=useResizable({target:Re,direction:h});const Be=useMemo((()=>nanoid()),[]);const[je,ye]=useState((()=>{const e=we.value??we.defaultValue;return typeof e=='string'&&e.length>0}));const[Ee,Ie]=useState((()=>Math.min(a,n)));const Ne=pe==='brand'&&u||pe!=='brand'&&m?Ee:Math.min(a,n);const ke=h==='horizontal'?'ew-resize':h==='vertical'?'ns-resize':'nwse-resize';const De=useCallback((()=>{if(!Te.current)return;if(pe==='brand'){if(!Me.current)return;Me.current.value=Te.current.value;const e=Math.max(Math.round(Me.current.scrollHeight/Me.current.clientHeight),a);return void Ie(Math.min(e,n))}const e=getComputedStyle(Te.current);const r=parseFloat(e.lineHeight);const o=Math.max(Math.round((Te.current.scrollHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom))/(Number.isNaN(r)?parseFloat(e.fontSize)*1.2:r)),a);Ie((e=>o>e?Math.min(o,n):Te.current&&!Te.current.value?a:e))}),[pe,a,n]);return useLayoutEffect((()=>{pe==='brand'&&typeof we.value=='string'&&Te.current&&Te.current!==document.activeElement&&ye(we.value.length>0)}),[pe,we.value]),useEffect((()=>{const e=createThrottledCallback(De,200);return(pe==='brand'&&u||pe!=='brand'&&m)&&(De(),window.addEventListener('resize',e)),()=>{window.removeEventListener('resize',e)}}),[pe,u,m,De]),pe!=='brand'?jsx(Root,{...we,ref:Te,className:Le,style:be,onChange:e=>{m&&De(),we.onChange&&we.onChange(e)},rows:Ne,color:c,rounded:g,placeholderColor:d,disabled:ze,error:L,fluid:Xe,width:l,widthXXS:me,widthXS:ge,widthS:ce,widthM:de,widthL:ue,widthXL:he}):jsx(FormInputLabel,{ref:Re,size:t,sizeXXS:b,sizeXS:z,sizeS:w,sizeM:T,sizeL:M,sizeXL:R,sizes:C,sizeUnits:x,margin:v,marginXXS:B,marginXS:j,marginS:y,marginM:E,marginL:I,marginXL:N,marginTop:k,marginTopXXS:D,marginTopXS:F,marginTopS:H,marginTopM:P,marginTopL:_,marginTopXL:A,marginRight:O,marginRightXXS:Z,marginRightXS:W,marginRightS:G,marginRightM:U,marginRightL:$,marginRightXL:K,marginBottom:V,marginBottomXXS:q,marginBottomXS:J,marginBottomS:Q,marginBottomM:Y,marginBottomL:ee,marginBottomXL:re,marginLeft:oe,marginLeftXXS:te,marginLeftXS:ae,marginLeftS:ne,marginLeftM:ie,marginLeftL:se,marginLeftXL:le,className:Le,style:be,contrast:p,error:L,inline:f,label:Se,labelId:Be,labelPosition:i,disabled:ze,active:je,primary:s,secondary:S,success:X,palette:{color:ze?fe.colorDisabled:fe.color,backgroundColor:ze?fe.backgroundColorDisabled:fe.backgroundColor,backgroundColorHover:ze?fe.backgroundColorDisabled:fe.backgroundColorHover,borderColor:ze?fe.borderColorDisabled:fe.borderColor},onClick:()=>{Te.current&&Te.current.focus()},onFocus:()=>{ye(!0)},onPointerDown:e=>{e.target!==Te.current&&e.target instanceof Node&&e.preventDefault()},onBlur:e=>{Te.current&&!e.currentTarget.contains(e.relatedTarget)&&ye(Boolean(Te.current.value))},overflow:"hidden",inputPosition:"stretch",input:jsxs(Fragment,{children:[u?jsx(TextareaMimic,{ref:Me,rows:1}):null,jsx(Textarea$1,{...we,ref:Te,"aria-labelledby":Se?Be:void 0,disabled:ze,onChange:e=>{u&&De(),we.onChange&&we.onChange(e)},rows:Ne,palette:{color:fe.color,colorDisabled:fe.colorDisabled,placeholderColor:fe.placeholderColor,placeholderColorDisabled:fe.placeholderColorDisabled}})]}),addon:h?jsxs(Fragment,{children:[Ce?jsx(ResizeGlobals,{cursor:ke}):null,jsx(ResizeIcon,{size:"l",icon:jsx(ResizeHandle,{}),color:"border-onmain-default-small",tabIndex:0,onPointerDown:xe,onKeyDown:ve,cursor:ke})]}):void 0})})),{displayName:"Textarea",sizes:e=>e.label?SIZES_WITH_LABEL:SIZES});export{COMPONENT_NAME,Textarea};
2
2
  //# sourceMappingURL=Textarea.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.mjs","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n} from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { ResizeHandle } from '@foxford/icon-pack'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { useResizable } from 'hooks/useResizable'\nimport { createThrottledCallback } from 'shared/utils/misc'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { SIZES, SIZES_WITH_LABEL } from './constants'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<textarea\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<textarea\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Textarea/types.ts).\n */\nconst Textarea: React.ForwardRefExoticComponent<TextareaProps> = withMergedProps<TextareaProps, HTMLTextAreaElement>(\n forwardRef((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rows = 2,\n maxRows = 30,\n labelPosition = 'dynamic',\n primary = true,\n width = theme.defaultInputControlsWidth,\n autosize = true,\n rounded = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n autoRows,\n resize,\n contrast,\n inline,\n secondary,\n success,\n error,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n preset,\n palette,\n label,\n fluid,\n className,\n style,\n disabled,\n ...textareaProps\n } = props\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n\n const textareaMimicRef = useRef<HTMLTextAreaElement>(null)\n\n const formInputLabelRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(forwardedRef, () => textareaRef.current as HTMLTextAreaElement, [])\n\n const [resizing, handleResizeStart, handleResizeOnNudge] = useResizable<HTMLDivElement, HTMLSpanElement>({\n target: formInputLabelRef,\n direction: resize,\n })\n\n const labelId = useMemo(() => nanoid(), [])\n\n const [active, setActive] = useState(() => {\n const valueInit = textareaProps.value ?? textareaProps.defaultValue\n\n return typeof valueInit === 'string' && valueInit.length > 0\n })\n\n const [autoRowsCount, setAutoRowsCount] = useState(() => Math.min(rows, maxRows))\n\n const rowsVisible =\n (preset === 'brand' && autoRows) || (preset !== 'brand' && autosize) ? autoRowsCount : Math.min(rows, maxRows)\n\n const cursorResize = resize === 'horizontal' ? 'ew-resize' : resize === 'vertical' ? 'ns-resize' : 'nwse-resize'\n\n const updateAutoRowsCount = useCallback(() => {\n if (!textareaRef.current) return\n\n if (preset === 'brand') {\n if (!textareaMimicRef.current) return\n\n textareaMimicRef.current.value = textareaRef.current.value\n\n const nextRows = Math.max(\n Math.round(textareaMimicRef.current.scrollHeight / textareaMimicRef.current.clientHeight),\n rows\n )\n\n setAutoRowsCount(Math.min(nextRows, maxRows))\n\n return\n }\n\n const styles = getComputedStyle(textareaRef.current)\n\n const lineHeight = parseFloat(styles.lineHeight)\n\n const nextRows = Math.max(\n Math.round(\n (textareaRef.current.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom)) /\n (Number.isNaN(lineHeight) ? parseFloat(styles.fontSize) * 1.2 : lineHeight)\n ),\n rows\n )\n\n setAutoRowsCount((prevRows) => {\n if (nextRows > prevRows) return Math.min(nextRows, maxRows)\n if (textareaRef.current && !textareaRef.current.value) return rows\n\n return prevRows\n })\n }, [preset, rows, maxRows])\n\n useLayoutEffect(() => {\n if (\n preset === 'brand' &&\n typeof textareaProps.value === 'string' &&\n textareaRef.current &&\n textareaRef.current !== document.activeElement\n ) {\n setActive(textareaProps.value.length > 0)\n }\n }, [preset, textareaProps.value])\n\n useEffect(() => {\n const handleResize = createThrottledCallback<UIEvent>(updateAutoRowsCount, 200)\n\n if ((preset === 'brand' && autoRows) || (preset !== 'brand' && autosize)) {\n updateAutoRowsCount()\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [preset, autoRows, autosize, updateAutoRowsCount])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...textareaProps}\n ref={textareaRef}\n className={className}\n style={style}\n onChange={(evt) => {\n if (autosize) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n disabled={disabled}\n error={error}\n fluid={fluid}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n />\n )\n }\n\n return (\n <FormInputLabel\n ref={formInputLabelRef}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n className={className}\n style={style}\n contrast={contrast}\n error={error}\n inline={inline}\n label={label}\n labelId={labelId}\n labelPosition={labelPosition}\n disabled={disabled}\n active={active}\n primary={primary}\n secondary={secondary}\n success={success}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={() => {\n if (textareaRef.current) {\n textareaRef.current.focus()\n }\n }}\n onFocus={() => {\n setActive(true)\n }}\n onPointerDown={(evt) => {\n if (evt.target === textareaRef.current || !(evt.target instanceof Node)) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (textareaRef.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setActive(Boolean(textareaRef.current.value))\n }\n }}\n overflow='hidden'\n inputPosition='stretch'\n input={\n <>\n {autoRows && <Styled.TextareaMimic ref={textareaMimicRef} rows={1} />}\n <Styled.Textarea\n {...textareaProps}\n ref={textareaRef}\n aria-labelledby={label ? labelId : undefined}\n disabled={disabled}\n onChange={(evt) => {\n if (autoRows) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n />\n </>\n }\n addon={\n resize ? (\n <>\n {resizing && <Styled.ResizeGlobals cursor={cursorResize} />}\n <Styled.ResizeIcon\n size='l'\n icon={<ResizeHandle />}\n color='border-onmain-default-small'\n tabIndex={0}\n onPointerDown={handleResizeStart}\n onKeyDown={handleResizeOnNudge}\n cursor={cursorResize}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => (props.label ? SIZES_WITH_LABEL : SIZES),\n }\n)\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Textarea","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rows","maxRows","labelPosition","primary","width","defaultInputControlsWidth","autosize","rounded","color","placeholderColor","autoRows","resize","contrast","inline","secondary","success","error","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","widthXXS","widthXS","widthS","widthM","widthL","widthXL","preset","palette","label","fluid","className","style","disabled","textareaProps","textareaRef","useRef","textareaMimicRef","formInputLabelRef","useImperativeHandle","current","resizing","handleResizeStart","handleResizeOnNudge","useResizable","target","direction","labelId","useMemo","nanoid","active","setActive","useState","valueInit","value","defaultValue","length","autoRowsCount","setAutoRowsCount","Math","min","rowsVisible","cursorResize","updateAutoRowsCount","useCallback","nextRows","max","round","scrollHeight","clientHeight","styles","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","Number","isNaN","fontSize","prevRows","useLayoutEffect","document","activeElement","useEffect","handleResize","createThrottledCallback","window","addEventListener","removeEventListener","_jsx","Styled","ref","onChange","evt","FormInputLabel","colorDisabled","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","focus","onFocus","onPointerDown","Node","preventDefault","onBlur","currentTarget","contains","relatedTarget","Boolean","overflow","inputPosition","input","_jsxs","_Fragment","children","undefined","placeholderColorDisabled","addon","cursor","icon","ResizeHandle","tabIndex","onKeyDown","displayName","SIZES_WITH_LABEL","SIZES"],"mappings":"spBAqBMA,MAAAA,eAAiB,WAYjBC,MAAAA,SAA2DC,gBAC/DC,YAAW,CAACC,EAAOC,KACjB,MAAMC,EAAQC,WAEd,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,EAACC,QACRA,EAAU,GAAEC,cACZA,EAAgB,UAASC,QACzBA,GAAU,EAAIC,MACdA,EAAQP,EAAMQ,0BAAyBC,SACvCA,GAAW,EAAIC,QACfA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,SAC3BA,EAAQC,OACRA,EAAMC,SACNA,EAAQC,OACRA,EAAMC,UACNA,EAASC,QACTA,EAAOC,MACPA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACN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AAWL,GAAQqE,wBAA0BrE,GAAQsE,qBAC3EC,YAAalE,GAAWL,GAAQwE,oBAAsBxE,GAAQuE,aAEhEE,QAASA,KACHlE,GAAYK,SACdL,GAAYK,QAAQ8D,OACtB,EAEFC,QAASA,KACPpD,IAAU,EAAK,EAEjBqD,cAAgBX,IACVA,EAAIhD,SAAWV,GAAYK,SAAaqD,EAAIhD,kBAAkB4D,MAGlEZ,EAAIa,gBAAgB,EAEtBC,OAASd,IACH1D,GAAYK,UAAYqD,EAAIe,cAAcC,SAAShB,EAAIiB,gBACzD3D,GAAU4D,QAAQ5E,GAAYK,QAAQc,OACxC,EAEF0D,SAAS,SACTC,cAAc,UACdC,MACEC,KAAAC,SAAA,CAAAC,UACGlJ,GAAYsH,IAACC,cAAoB,CAACC,IAAKtD,GAAkB5E,KAAM,IAChEgI,IAACC,WAAe,IACVxD,GACJyD,IAAKxD,GACL,kBAAiBN,GAAQkB,QAAUuE,EACnCrF,SAAUA,GACV2D,SAAWC,IACL1H,GAAU4F,KACV7B,GAAc0D,UAAU1D,GAAc0D,SAASC,EAAI,EAEzDpI,KAAMoG,GACNjC,QAAS,CACP3D,MAAO2D,GAAQ3D,MACf8H,cAAenE,GAAQmE,cACvB7H,iBAAkB0D,GAAQ1D,iBAC1BqJ,yBAA0B3F,GAAQ2F,+BAK1CC,MACEpJ,EACE+I,KAAAC,SAAA,CAAAC,UACG5E,IAAYgD,IAACC,cAAoB,CAAC+B,OAAQ3D,KAC3C2B,IAACC,WAAiB,CAChBlI,KAAK,IACLkK,KAAMjC,IAACkC,iBACP1J,MAAM,8BACN2J,SAAU,EACVpB,cAAe9D,GACfmF,UAAWlF,GACX8E,OAAQ3D,aAGVwD,GAEN,IAGN,CACEQ,YArVmB,WAsVnB9I,MAAQ5B,GAAWA,EAAMyE,MAAQkG,iBAAmBC"}
1
+ {"version":3,"file":"Textarea.mjs","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n} from 'react'\nimport { useTheme } from 'styled-components'\nimport { nanoid } from 'nanoid'\nimport { ResizeHandle } from '@foxford/icon-pack'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useResizable } from 'hooks/useResizable'\nimport { createThrottledCallback } from 'shared/utils/misc'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { SIZES, SIZES_WITH_LABEL } from './constants'\nimport * as Styled from './style'\nimport type { TextareaProps } from './types'\n\nconst COMPONENT_NAME = 'Textarea'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<textarea\\> элемента.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Можно передать \"ref\", который будет ассоциирован с \\<textarea\\>.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Textarea/types.ts).\n */\nconst Textarea: React.ForwardRefExoticComponent<TextareaProps> = withMergedProps<TextareaProps, HTMLTextAreaElement>(\n forwardRef<HTMLTextAreaElement, MergedProps<TextareaProps>>((props, forwardedRef) => {\n const theme = useTheme()\n\n const {\n size = 'm',\n rows = 2,\n maxRows = 30,\n labelPosition = 'dynamic',\n primary = true,\n width = theme.defaultInputControlsWidth,\n autosize = true,\n rounded = true,\n color = 'mineShaft',\n placeholderColor = 'silver',\n autoRows,\n resize,\n contrast,\n inline,\n secondary,\n success,\n error,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizes,\n sizeUnits,\n margin,\n marginXXS,\n marginXS,\n marginS,\n marginM,\n marginL,\n marginXL,\n marginTop,\n marginTopXXS,\n marginTopXS,\n marginTopS,\n marginTopM,\n marginTopL,\n marginTopXL,\n marginRight,\n marginRightXXS,\n marginRightXS,\n marginRightS,\n marginRightM,\n marginRightL,\n marginRightXL,\n marginBottom,\n marginBottomXXS,\n marginBottomXS,\n marginBottomS,\n marginBottomM,\n marginBottomL,\n marginBottomXL,\n marginLeft,\n marginLeftXXS,\n marginLeftXS,\n marginLeftS,\n marginLeftM,\n marginLeftL,\n marginLeftXL,\n widthXXS,\n widthXS,\n widthS,\n widthM,\n widthL,\n widthXL,\n preset,\n palette,\n label,\n fluid,\n className,\n style,\n disabled,\n ...textareaProps\n } = props\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n\n const textareaMimicRef = useRef<HTMLTextAreaElement>(null)\n\n const formInputLabelRef = useRef<HTMLDivElement>(null)\n\n useImperativeHandle(forwardedRef, () => textareaRef.current as HTMLTextAreaElement, [])\n\n const [resizing, handleResizeStart, handleResizeOnNudge] = useResizable<HTMLDivElement, HTMLSpanElement>({\n target: formInputLabelRef,\n direction: resize,\n })\n\n const labelId = useMemo(() => nanoid(), [])\n\n const [active, setActive] = useState(() => {\n const valueInit = textareaProps.value ?? textareaProps.defaultValue\n\n return typeof valueInit === 'string' && valueInit.length > 0\n })\n\n const [autoRowsCount, setAutoRowsCount] = useState(() => Math.min(rows, maxRows))\n\n const rowsVisible =\n (preset === 'brand' && autoRows) || (preset !== 'brand' && autosize) ? autoRowsCount : Math.min(rows, maxRows)\n\n const cursorResize = resize === 'horizontal' ? 'ew-resize' : resize === 'vertical' ? 'ns-resize' : 'nwse-resize'\n\n const updateAutoRowsCount = useCallback(() => {\n if (!textareaRef.current) return\n\n if (preset === 'brand') {\n if (!textareaMimicRef.current) return\n\n textareaMimicRef.current.value = textareaRef.current.value\n\n const nextRows = Math.max(\n Math.round(textareaMimicRef.current.scrollHeight / textareaMimicRef.current.clientHeight),\n rows\n )\n\n setAutoRowsCount(Math.min(nextRows, maxRows))\n\n return\n }\n\n const styles = getComputedStyle(textareaRef.current)\n\n const lineHeight = parseFloat(styles.lineHeight)\n\n const nextRows = Math.max(\n Math.round(\n (textareaRef.current.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom)) /\n (Number.isNaN(lineHeight) ? parseFloat(styles.fontSize) * 1.2 : lineHeight)\n ),\n rows\n )\n\n setAutoRowsCount((prevRows) => {\n if (nextRows > prevRows) return Math.min(nextRows, maxRows)\n if (textareaRef.current && !textareaRef.current.value) return rows\n\n return prevRows\n })\n }, [preset, rows, maxRows])\n\n useLayoutEffect(() => {\n if (\n preset === 'brand' &&\n typeof textareaProps.value === 'string' &&\n textareaRef.current &&\n textareaRef.current !== document.activeElement\n ) {\n setActive(textareaProps.value.length > 0)\n }\n }, [preset, textareaProps.value])\n\n useEffect(() => {\n const handleResize = createThrottledCallback<UIEvent>(updateAutoRowsCount, 200)\n\n if ((preset === 'brand' && autoRows) || (preset !== 'brand' && autosize)) {\n updateAutoRowsCount()\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n }\n }, [preset, autoRows, autosize, updateAutoRowsCount])\n\n if (preset !== 'brand') {\n return (\n <Styled.Root\n {...textareaProps}\n ref={textareaRef}\n className={className}\n style={style}\n onChange={(evt) => {\n if (autosize) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n color={color}\n rounded={rounded}\n placeholderColor={placeholderColor}\n disabled={disabled}\n error={error}\n fluid={fluid}\n width={width}\n widthXXS={widthXXS}\n widthXS={widthXS}\n widthS={widthS}\n widthM={widthM}\n widthL={widthL}\n widthXL={widthXL}\n />\n )\n }\n\n return (\n <FormInputLabel\n ref={formInputLabelRef}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizes={sizes}\n sizeUnits={sizeUnits}\n margin={margin}\n marginXXS={marginXXS}\n marginXS={marginXS}\n marginS={marginS}\n marginM={marginM}\n marginL={marginL}\n marginXL={marginXL}\n marginTop={marginTop}\n marginTopXXS={marginTopXXS}\n marginTopXS={marginTopXS}\n marginTopS={marginTopS}\n marginTopM={marginTopM}\n marginTopL={marginTopL}\n marginTopXL={marginTopXL}\n marginRight={marginRight}\n marginRightXXS={marginRightXXS}\n marginRightXS={marginRightXS}\n marginRightS={marginRightS}\n marginRightM={marginRightM}\n marginRightL={marginRightL}\n marginRightXL={marginRightXL}\n marginBottom={marginBottom}\n marginBottomXXS={marginBottomXXS}\n marginBottomXS={marginBottomXS}\n marginBottomS={marginBottomS}\n marginBottomM={marginBottomM}\n marginBottomL={marginBottomL}\n marginBottomXL={marginBottomXL}\n marginLeft={marginLeft}\n marginLeftXXS={marginLeftXXS}\n marginLeftXS={marginLeftXS}\n marginLeftS={marginLeftS}\n marginLeftM={marginLeftM}\n marginLeftL={marginLeftL}\n marginLeftXL={marginLeftXL}\n className={className}\n style={style}\n contrast={contrast}\n error={error}\n inline={inline}\n label={label}\n labelId={labelId}\n labelPosition={labelPosition}\n disabled={disabled}\n active={active}\n primary={primary}\n secondary={secondary}\n success={success}\n palette={{\n color: disabled ? palette.colorDisabled : palette.color,\n backgroundColor: disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={() => {\n if (textareaRef.current) {\n textareaRef.current.focus()\n }\n }}\n onFocus={() => {\n setActive(true)\n }}\n onPointerDown={(evt) => {\n if (evt.target === textareaRef.current || !(evt.target instanceof Node)) {\n return\n }\n evt.preventDefault()\n }}\n onBlur={(evt) => {\n if (textareaRef.current && !evt.currentTarget.contains(evt.relatedTarget)) {\n setActive(Boolean(textareaRef.current.value))\n }\n }}\n overflow='hidden'\n inputPosition='stretch'\n input={\n <>\n {autoRows ? <Styled.TextareaMimic ref={textareaMimicRef} rows={1} /> : null}\n <Styled.Textarea\n {...textareaProps}\n ref={textareaRef}\n aria-labelledby={label ? labelId : undefined}\n disabled={disabled}\n onChange={(evt) => {\n if (autoRows) updateAutoRowsCount()\n if (textareaProps.onChange) textareaProps.onChange(evt)\n }}\n rows={rowsVisible}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n />\n </>\n }\n addon={\n resize ? (\n <>\n {resizing ? <Styled.ResizeGlobals cursor={cursorResize} /> : null}\n <Styled.ResizeIcon\n size='l'\n icon={<ResizeHandle />}\n color='border-onmain-default-small'\n tabIndex={0}\n onPointerDown={handleResizeStart}\n onKeyDown={handleResizeOnNudge}\n cursor={cursorResize}\n />\n </>\n ) : undefined\n }\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => (props.label ? SIZES_WITH_LABEL : SIZES),\n }\n)\n\nexport { Textarea, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Textarea","withMergedProps","forwardRef","props","forwardedRef","theme","useTheme","size","rows","maxRows","labelPosition","primary","width","defaultInputControlsWidth","autosize","rounded","color","placeholderColor","autoRows","resize","contrast","inline","secondary","success","error","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizes","sizeUnits","margin","marginXXS","marginXS","marginS","marginM","marginL","marginXL","marginTop","marginTopXXS","marginTopXS","marginTopS","marginTopM","marginTopL","marginTopXL","marginRight","marginRightXXS","marginRightXS","marginRightS","marginRightM","marginRightL","marginRightXL","marginBottom","marginBottomXXS","marginBottomXS","marginBottomS","marginBottomM","marginBottomL","marginBottomXL","marginLeft","marginLeftXXS","marginLeftXS","marginLeftS","marginLeftM","marginLeftL","marginLeftXL","widthXXS","widthXS","widthS","widthM","widthL","widthXL","preset","palette","label","fluid","className","style","disabled","textareaProps","textareaRef","useRef","textareaMimicRef","formInputLabelRef","useImperativeHandle","current","resizing","handleResizeStart","handleResizeOnNudge","useResizable","target","direction","labelId","useMemo","nanoid","active","setActive","useState","valueInit","value","defaultValue","length","autoRowsCount","setAutoRowsCount","Math","min","rowsVisible","cursorResize","updateAutoRowsCount","useCallback","nextRows","max","round","scrollHeight","clientHeight","styles","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","Number","isNaN","fontSize","prevRows","useLayoutEffect","document","activeElement","useEffect","handleResize","createThrottledCallback","window","addEventListener","removeEventListener","_jsx","Styled","ref","onChange","evt","FormInputLabel","colorDisabled","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","focus","onFocus","onPointerDown","Node","preventDefault","onBlur","currentTarget","contains","relatedTarget","Boolean","overflow","inputPosition","input","_jsxs","_Fragment","children","undefined","placeholderColorDisabled","addon","cursor","icon","ResizeHandle","tabIndex","onKeyDown","displayName","SIZES_WITH_LABEL","SIZES"],"mappings":"spBAsBMA,MAAAA,eAAiB,WAYjBC,MAAAA,SAA2DC,gBAC/DC,YAA4D,CAACC,EAAOC,KAClE,MAAMC,EAAQC,WAEd,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,EAACC,QACRA,EAAU,GAAEC,cACZA,EAAgB,UAASC,QACzBA,GAAU,EAAIC,MACdA,EAAQP,EAAMQ,0BAAyBC,SACvCA,GAAW,EAAIC,QACfA,GAAU,EAAIC,MACdA,EAAQ,YAAWC,iBACnBA,EAAmB,SAAQC,SAC3BA,EAAQC,OACRA,EAAMC,SACNA,EAAQC,OACRA,EAAMC,UACNA,EAASC,QACTA,EAAOC,MACPA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,UACLA,EAASC,OACTA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,QACPA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,UACRA,EAASC,aACTA,EAAYC,YACZA,EAAWC,WACXA,EAAUC,WACVA,EAAUC,WACVA,EAAUC,YACVA,EAAWC,YACXA,EAAWC,eACXA,EAAcC,cACdA,EAAaC,aACbA,EAAYC,aACZA,EAAYC,aACZA,EAAYC,cACZA,EAAaC,aACbA,EAAYC,gBACZA,EAAeC,eACfA,EAAcC,cACdA,EA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zD3D,GAAU4D,QAAQ5E,GAAYK,QAAQc,OACxC,EAEF0D,SAAS,SACTC,cAAc,UACdC,MACEC,KAAAC,SAAA,CAAAC,UACGlJ,EAAWsH,IAACC,cAAoB,CAACC,IAAKtD,GAAkB5E,KAAM,IAAQ,KACvEgI,IAACC,WAAe,IACVxD,GACJyD,IAAKxD,GACL,kBAAiBN,GAAQkB,QAAUuE,EACnCrF,SAAUA,GACV2D,SAAWC,IACL1H,GAAU4F,KACV7B,GAAc0D,UAAU1D,GAAc0D,SAASC,EAAI,EAEzDpI,KAAMoG,GACNjC,QAAS,CACP3D,MAAO2D,GAAQ3D,MACf8H,cAAenE,GAAQmE,cACvB7H,iBAAkB0D,GAAQ1D,iBAC1BqJ,yBAA0B3F,GAAQ2F,+BAK1CC,MACEpJ,EACE+I,KAAAC,SAAA,CAAAC,UACG5E,GAAWgD,IAACC,cAAoB,CAAC+B,OAAQ3D,KAAmB,KAC7D2B,IAACC,WAAiB,CAChBlI,KAAK,IACLkK,KAAMjC,IAACkC,iBACP1J,MAAM,8BACN2J,SAAU,EACVpB,cAAe9D,GACfmF,UAAWlF,GACX8E,OAAQ3D,aAGVwD,GAEN,IAGN,CACEQ,YArVmB,WAsVnB9I,MAAQ5B,GAAWA,EAAMyE,MAAQkG,iBAAmBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, useState, useLayoutEffect } from 'react'\nimport { useTheme } from 'styled-components'\nimport Floater from 'react-floater'\nimport type { Props as FloaterProps, PopperInstance, Styles } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { useResizeObserver } from 'hooks/useResizeObserver'\nimport { SIZES, TooltipComponent } from 'components/TooltipComponent'\nimport { deepmerge } from 'shared/utils/misc'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TOOLTIP_STYLES_DEFAULT } from './default-constants'\nimport type { TooltipProps } from './types'\n\nconst COMPONENT_NAME = 'Tooltip'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Компонент основан на [\"react-floater\"](https://www.npmjs.com/package/react-floater).\n *\n * Получить доступ к компоненту, не подключенному к библиотеке, можно через `Tooltip.Component`.\n *\n * Полный интерфейс `Tooltip` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Tooltip/types.ts), интерфейс `Tooltip.Component` [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n *\n */\nconst Tooltip: React.ForwardRefExoticComponent<TooltipProps> & { Component: typeof TooltipComponent } = Object.assign(\n withMergedProps<TooltipProps, HTMLDivElement>(\n forwardRef((props, ref) => {\n const {\n preset,\n size = 's',\n styles = {},\n closeOnClickOutside = false,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n palette,\n black,\n contrast,\n titleProps,\n contentProps,\n closeButtonProps,\n closeOnScroll,\n portalElement,\n zIndex,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n const [portal, setPortal] = useState<HTMLElement | null>(null)\n const [popper, setPopper] = useState<PopperInstance | null>(null)\n\n const floaterStyles: Partial<Styles> =\n typeof zIndex === 'number' ? deepmerge(styles, { options: { zIndex } }) : styles\n\n useLayoutEffect(() => {\n if (portalElement) {\n setPortal(null)\n } else if (document.body) {\n let popperPortal = document.querySelector<HTMLElement>('[data-popper-portal]')\n\n if (!popperPortal) {\n popperPortal = document.createElement('div')\n popperPortal.dataset.popperPortal = 'true'\n popperPortal.style.position = 'relative'\n\n document.body.appendChild(popperPortal)\n }\n\n setPortal(popperPortal)\n }\n }, [portalElement])\n\n useResizeObserver({\n target: document.body,\n onResize: () => {\n if (popper && popper.state.options.strategy === 'absolute') {\n popper.update()\n }\n },\n })\n\n if (!portalElement && !portal) {\n return null\n }\n\n if (preset !== 'brand') {\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n styles: deepmerge(TOOLTIP_STYLES_DEFAULT, floaterStyles),\n } as FloaterProps\n\n return (\n <Floater {...tooltipProps}>\n <span>{tooltipProps.children}</span>\n </Floater>\n )\n }\n\n let color = theme.colors['bg-onmain-primary']\n\n if (black) color = theme.colors['bg-onmain-inverse']\n if (contrast) color = theme.colors['bg-brand-primary-basic']\n if (palette?.backgroundColor) color = theme.colors[palette.backgroundColor] ?? palette.backgroundColor\n\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n getPopper: (popper, origin) => {\n setPopper(popper)\n if (restProps.getPopper) {\n restProps.getPopper(popper, origin)\n }\n },\n offset: restProps.offset ?? 8,\n styles: deepmerge(\n {\n arrow: {\n color,\n spread: 16,\n length: 8,\n },\n floater: {\n filter: `drop-shadow(0 6px 10px ${theme.colors['bg-oncolor-hover']})`,\n },\n },\n floaterStyles\n ),\n component: (\n <TooltipWrapper\n ref={ref}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizeUnits={sizeUnits}\n sizes={sizes}\n palette={palette}\n black={black}\n contrast={contrast}\n title={restProps.title}\n titleProps={titleProps}\n content={restProps.content}\n contentProps={contentProps}\n footer={restProps.footer}\n showCloseButton={restProps.showCloseButton}\n closeButtonProps={closeButtonProps}\n closeOnClickOutside={closeOnClickOutside}\n closeOnScroll={closeOnScroll}\n component={restProps.component}\n />\n ),\n } as FloaterProps\n\n return (\n <Floater\n {...tooltipProps}\n modifiers={{\n flip: {\n enabled: !tooltipProps.disableFlip,\n },\n }}\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n ),\n {\n Component: TooltipComponent,\n }\n)\n\nexport { Tooltip }\n\nexport { COMPONENT_NAME }\n"],"names":["Tooltip","Object","assign","withMergedProps","forwardRef","props","ref","preset","size","styles","closeOnClickOutside","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","palette","black","contrast","titleProps","contentProps","closeButtonProps","closeOnScroll","portalElement","zIndex","restProps","theme","useTheme","portal","setPortal","useState","popper","setPopper","floaterStyles","deepmerge","options","useLayoutEffect","document","body","popperPortal","querySelector","createElement","dataset","style","position","appendChild","useResizeObserver","target","onResize","state","strategy","update","tooltipProps","TOOLTIP_STYLES_DEFAULT","_jsx","Floater","children","jsx","color","colors","backgroundColor","getPopper","origin","offset","arrow","spread","length","floater","filter","component","TooltipWrapper","title","content","footer","showCloseButton","modifiers","flip","enabled","disableFlip","displayName","SIZES","Component","TooltipComponent"],"mappings":"yqBA6BA,MAAMA,QAAkGC,OAAOC,OAC7GC,gBAAAA,gBACEC,MAAAA,YAAW,CAACC,EAAOC,KACjB,MAAMC,OACJA,EAAMC,KACNA,EAAO,IAAGC,OACVA,EAAS,CAAE,EAAAC,oBACXA,GAAsB,EAAKC,QAC3BA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAAKC,QACLA,EAAOC,MACPA,EAAKC,SACLA,EAAQC,WACRA,EAAUC,aACVA,EAAYC,iBACZA,EAAgBC,cAChBA,EAAaC,cACbA,EAAaC,OACbA,KACGC,GACDvB,EAEJ,MAAMwB,EAAQC,OAAAA,WAEd,MAAOC,EAAQC,GAAaC,MAAQA,SAAqB,MACzD,MAAOC,EAAQC,GAAaF,MAAQA,SAAwB,MAE5D,MAAMG,SACGT,GAAW,SAAWU,KAAAA,UAAU5B,EAAQ,CAAE6B,QAAS,CAAEX,YAAclB,EA6B5E,GA3BA8B,MAAAA,iBAAgB,KACd,GAAIb,EACFM,EAAU,WACL,GAAIQ,SAASC,KAAM,CACxB,IAAIC,EAAeF,SAASG,cAA2B,wBAElDD,IACHA,EAAeF,SAASI,cAAc,OACtCF,EAAaG,QAA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MAAO9C,EAAU8C,MACjBpD,WAAYA,EACZqD,QAAS/C,EAAU+C,QACnBpD,aAAcA,EACdqD,OAAQhD,EAAUgD,OAClBC,gBAAiBjD,EAAUiD,gBAC3BrD,iBAAkBA,EAClBd,oBAAqBA,EACrBe,cAAeA,EACf+C,UAAW5C,EAAU4C,aAK3B,OACEf,WAAAA,IAACC,iBAAAA,QAAO,IACFH,EACJuB,UAAW,CACTC,KAAM,CACJC,SAAUzB,EAAa0B,eAG3B,IAGN,CACEC,YAxKiB,UAyKjBhE,MAAOiE,UAAAA,QAGX,CACEC,UAAWC,iBAAAA,0CA7KQ"}
1
+ {"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, useState, useLayoutEffect } from 'react'\nimport { useTheme } from 'styled-components'\nimport Floater from 'react-floater'\nimport type { Props as FloaterProps, PopperInstance, Styles } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useResizeObserver } from 'hooks/useResizeObserver'\nimport { SIZES, TooltipComponent } from 'components/TooltipComponent'\nimport { deepmerge } from 'shared/utils/misc'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TOOLTIP_STYLES_DEFAULT } from './default-constants'\nimport type { TooltipProps } from './types'\n\nconst COMPONENT_NAME = 'Tooltip'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Компонент основан на [\"react-floater\"](https://www.npmjs.com/package/react-floater).\n *\n * Получить доступ к компоненту, не подключенному к библиотеке, можно через `Tooltip.Component`.\n *\n * Полный интерфейс `Tooltip` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Tooltip/types.ts), интерфейс `Tooltip.Component` [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n *\n */\nconst Tooltip: React.ForwardRefExoticComponent<TooltipProps> & { Component: typeof TooltipComponent } = Object.assign(\n withMergedProps<TooltipProps, HTMLDivElement>(\n forwardRef<HTMLDivElement, MergedProps<TooltipProps>>((props, ref) => {\n const {\n preset,\n size = 's',\n styles = {},\n closeOnClickOutside = false,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n palette,\n black,\n contrast,\n titleProps,\n contentProps,\n closeButtonProps,\n closeOnScroll,\n portalElement,\n zIndex,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n const [portal, setPortal] = useState<HTMLElement | null>(null)\n const [popper, setPopper] = useState<PopperInstance | null>(null)\n\n const floaterStyles: Partial<Styles> =\n typeof zIndex === 'number' ? deepmerge(styles, { options: { zIndex } }) : styles\n\n useLayoutEffect(() => {\n if (portalElement) {\n setPortal(null)\n } else if (document.body) {\n let popperPortal = document.querySelector<HTMLElement>('[data-popper-portal]')\n\n if (!popperPortal) {\n popperPortal = document.createElement('div')\n popperPortal.dataset.popperPortal = 'true'\n popperPortal.style.position = 'relative'\n\n document.body.appendChild(popperPortal)\n }\n\n setPortal(popperPortal)\n }\n }, [portalElement])\n\n useResizeObserver({\n target: document.body,\n onResize: () => {\n if (popper && popper.state.options.strategy === 'absolute') {\n popper.update()\n }\n },\n })\n\n if (!portalElement && !portal) {\n return null\n }\n\n if (preset !== 'brand') {\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n styles: deepmerge(TOOLTIP_STYLES_DEFAULT, floaterStyles),\n } as FloaterProps\n\n return (\n <Floater {...tooltipProps}>\n <span>{tooltipProps.children}</span>\n </Floater>\n )\n }\n\n let color = theme.colors['bg-onmain-primary']\n\n if (black) color = theme.colors['bg-onmain-inverse']\n if (contrast) color = theme.colors['bg-brand-primary-basic']\n if (palette?.backgroundColor) {\n color = theme.colors[palette.backgroundColor as keyof typeof theme.colors] ?? palette.backgroundColor\n }\n\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n getPopper: (popperInstance, origin) => {\n setPopper(popperInstance)\n if (restProps.getPopper) {\n restProps.getPopper(popperInstance, origin)\n }\n },\n offset: restProps.offset ?? 8,\n styles: deepmerge(\n {\n arrow: {\n color,\n spread: 16,\n length: 8,\n },\n floater: {\n filter: `drop-shadow(0 6px 10px ${theme.colors['bg-oncolor-hover']})`,\n },\n },\n floaterStyles\n ),\n component: (\n <TooltipWrapper\n ref={ref}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizeUnits={sizeUnits}\n sizes={sizes}\n palette={palette}\n black={black}\n contrast={contrast}\n title={restProps.title}\n titleProps={titleProps}\n content={restProps.content}\n contentProps={contentProps}\n footer={restProps.footer}\n showCloseButton={restProps.showCloseButton}\n closeButtonProps={closeButtonProps}\n closeOnClickOutside={closeOnClickOutside}\n closeOnScroll={closeOnScroll}\n component={restProps.component}\n />\n ),\n } as FloaterProps\n\n return (\n <Floater\n {...tooltipProps}\n modifiers={{\n flip: {\n enabled: !tooltipProps.disableFlip,\n },\n }}\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n ),\n {\n Component: TooltipComponent,\n }\n)\n\nexport { Tooltip }\n\nexport { COMPONENT_NAME }\n"],"names":["Tooltip","Object","assign","withMergedProps","forwardRef","props","ref","preset","size","styles","closeOnClickOutside","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","palette","black","contrast","titleProps","contentProps","closeButtonProps","closeOnScroll","portalElement","zIndex","restProps","theme","useTheme","portal","setPortal","useState","popper","setPopper","floaterStyles","deepmerge","options","useLayoutEffect","document","body","popperPortal","querySelector","createElement","dataset","style","position","appendChild","useResizeObserver","target","onResize","state","strategy","update","tooltipProps","TOOLTIP_STYLES_DEFAULT","_jsx","Floater","children","jsx","color","colors","backgroundColor","getPopper","popperInstance","origin","offset","arrow","spread","length","floater","filter","component","TooltipWrapper","title","content","footer","showCloseButton","modifiers","flip","enabled","disableFlip","displayName","SIZES","Component","TooltipComponent"],"mappings":"yqBA8BA,MAAMA,QAAkGC,OAAOC,OAC7GC,gBAAAA,gBACEC,MAAAA,YAAsD,CAACC,EAAOC,KAC5D,MAAMC,OACJA,EAAMC,KACNA,EAAO,IAAGC,OACVA,EAAS,CAAE,EAAAC,oBACXA,GAAsB,EAAKC,QAC3BA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAAKC,QACLA,EAAOC,MACPA,EAAKC,SACLA,EAAQC,WACRA,EAAUC,aACVA,EAAYC,iBACZA,EAAgBC,cAChBA,EAAaC,cACbA,EAAaC,OACbA,KACGC,GACDvB,EAEJ,MAAMwB,EAAQC,OAAAA,WAEd,MAAOC,EAAQC,GAAaC,MAAQA,SAAqB,MACzD,MAAOC,EAAQC,GAAaF,MAAQA,SAAwB,MAE5D,MAAMG,SACGT,GAAW,SAAWU,KAAAA,UAAU5B,EAAQ,CAAE6B,QAAS,CAAEX,YAAclB,EA6B5E,GA3BA8B,MAAAA,iBAAgB,KACd,GAAIb,EACFM,EAAU,WACL,GAAIQ,SAASC,KAAM,CACxB,IAAIC,EAAeF,SAASG,cAA2B,wBAElDD,IACHA,EAAeF,SAASI,cAAc,OACtCF,EAAaG,QAAQH,aAAe,OACpCA,EAAaI,MAAMC,SAAW,WAE9BP,SAASC,KAAKO,YAAYN,IAG5BV,EAAUU,EACZ,IACC,CAAChB,IAEJuB,oCAAkB,CAChBC,OAAQV,SAASC,KACjBU,SAAUA,KACJjB,GAAUA,EAAOkB,MAAMd,QAAQe,WAAa,YAC9CnB,EAAOoB,QACT,KAIC5B,IAAkBK,EACrB,OAAO,KAGT,GAAIxB,IAAW,QAAS,CACtB,MAAMgD,EAAe,IAChB3B,EACHF,cAAeA,GAAiBK,EAChC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MAAOkE,UAAAA,QAGX,CACEC,UAAWC,iBAAAA,0CA/KQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.mjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, useState, useLayoutEffect } from 'react'\nimport { useTheme } from 'styled-components'\nimport Floater from 'react-floater'\nimport type { Props as FloaterProps, PopperInstance, Styles } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { useResizeObserver } from 'hooks/useResizeObserver'\nimport { SIZES, TooltipComponent } from 'components/TooltipComponent'\nimport { deepmerge } from 'shared/utils/misc'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TOOLTIP_STYLES_DEFAULT } from './default-constants'\nimport type { TooltipProps } from './types'\n\nconst COMPONENT_NAME = 'Tooltip'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Компонент основан на [\"react-floater\"](https://www.npmjs.com/package/react-floater).\n *\n * Получить доступ к компоненту, не подключенному к библиотеке, можно через `Tooltip.Component`.\n *\n * Полный интерфейс `Tooltip` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Tooltip/types.ts), интерфейс `Tooltip.Component` [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n *\n */\nconst Tooltip: React.ForwardRefExoticComponent<TooltipProps> & { Component: typeof TooltipComponent } = Object.assign(\n withMergedProps<TooltipProps, HTMLDivElement>(\n forwardRef((props, ref) => {\n const {\n preset,\n size = 's',\n styles = {},\n closeOnClickOutside = false,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n palette,\n black,\n contrast,\n titleProps,\n contentProps,\n closeButtonProps,\n closeOnScroll,\n portalElement,\n zIndex,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n const [portal, setPortal] = useState<HTMLElement | null>(null)\n const [popper, setPopper] = useState<PopperInstance | null>(null)\n\n const floaterStyles: Partial<Styles> =\n typeof zIndex === 'number' ? deepmerge(styles, { options: { zIndex } }) : styles\n\n useLayoutEffect(() => {\n if (portalElement) {\n setPortal(null)\n } else if (document.body) {\n let popperPortal = document.querySelector<HTMLElement>('[data-popper-portal]')\n\n if (!popperPortal) {\n popperPortal = document.createElement('div')\n popperPortal.dataset.popperPortal = 'true'\n popperPortal.style.position = 'relative'\n\n document.body.appendChild(popperPortal)\n }\n\n setPortal(popperPortal)\n }\n }, [portalElement])\n\n useResizeObserver({\n target: document.body,\n onResize: () => {\n if (popper && popper.state.options.strategy === 'absolute') {\n popper.update()\n }\n },\n })\n\n if (!portalElement && !portal) {\n return null\n }\n\n if (preset !== 'brand') {\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n styles: deepmerge(TOOLTIP_STYLES_DEFAULT, floaterStyles),\n } as FloaterProps\n\n return (\n <Floater {...tooltipProps}>\n <span>{tooltipProps.children}</span>\n </Floater>\n )\n }\n\n let color = theme.colors['bg-onmain-primary']\n\n if (black) color = theme.colors['bg-onmain-inverse']\n if (contrast) color = theme.colors['bg-brand-primary-basic']\n if (palette?.backgroundColor) color = theme.colors[palette.backgroundColor] ?? palette.backgroundColor\n\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n getPopper: (popper, origin) => {\n setPopper(popper)\n if (restProps.getPopper) {\n restProps.getPopper(popper, origin)\n }\n },\n offset: restProps.offset ?? 8,\n styles: deepmerge(\n {\n arrow: {\n color,\n spread: 16,\n length: 8,\n },\n floater: {\n filter: `drop-shadow(0 6px 10px ${theme.colors['bg-oncolor-hover']})`,\n },\n },\n floaterStyles\n ),\n component: (\n <TooltipWrapper\n ref={ref}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizeUnits={sizeUnits}\n sizes={sizes}\n palette={palette}\n black={black}\n contrast={contrast}\n title={restProps.title}\n titleProps={titleProps}\n content={restProps.content}\n contentProps={contentProps}\n footer={restProps.footer}\n showCloseButton={restProps.showCloseButton}\n closeButtonProps={closeButtonProps}\n closeOnClickOutside={closeOnClickOutside}\n closeOnScroll={closeOnScroll}\n component={restProps.component}\n />\n ),\n } as FloaterProps\n\n return (\n <Floater\n {...tooltipProps}\n modifiers={{\n flip: {\n enabled: !tooltipProps.disableFlip,\n },\n }}\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n ),\n {\n Component: TooltipComponent,\n }\n)\n\nexport { Tooltip }\n\nexport { COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Tooltip","Object","assign","withMergedProps","forwardRef","props","ref","preset","size","styles","closeOnClickOutside","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","palette","black","contrast","titleProps","contentProps","closeButtonProps","closeOnScroll","portalElement","zIndex","restProps","theme","useTheme","portal","setPortal","useState","popper","setPopper","floaterStyles","deepmerge","options","useLayoutEffect","document","body","popperPortal","querySelector","createElement","dataset","style","position","appendChild","useResizeObserver","target","onResize","state","strategy","update","tooltipProps","TOOLTIP_STYLES_DEFAULT","_jsx","Floater","children","color","colors","backgroundColor","getPopper","origin","offset","arrow","spread","length","floater","filter","component","TooltipWrapper","title","content","footer","showCloseButton","modifiers","flip","enabled","disableFlip","displayName","SIZES","Component","TooltipComponent"],"mappings":"8jBAYMA,MAAAA,eAAiB,UAiBvB,MAAMC,QAAkGC,OAAOC,OAC7GC,gBACEC,YAAW,CAACC,EAAOC,KACjB,MAAMC,OACJA,EAAMC,KACNA,EAAO,IAAGC,OACVA,EAAS,CAAE,EAAAC,oBACXA,GAAsB,EAAKC,QAC3BA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAA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AAUmC,WACZnC,EAAUmC,UAAU7B,EAAQ8B,EAC9B,EAEFC,OAAQrC,EAAUqC,QAAU,EAC5BxD,OAAQ4B,UACN,CACE6B,MAAO,CACLN,QACAO,OAAQ,GACRC,OAAQ,GAEVC,QAAS,CACPC,OAAQ,0BAA0BzC,EAAMgC,OAAO,yBAGnDzB,GAEFmC,UACEd,IAACe,eAAc,CACblE,IAAKA,EACLE,KAAMA,EACNG,QAASA,EACTC,OAAQA,EACRC,MAAOA,EACPC,MAAOA,EACPC,MAAOA,EACPC,OAAQA,EACRC,UAAWA,EACXC,MAAOA,EACPC,QAASA,EACTC,MAAOA,EACPC,SAAUA,EACVoD,MAAO7C,EAAU6C,MACjBnD,WAAYA,EACZoD,QAAS9C,EAAU8C,QACnBnD,aAAcA,EACdoD,OAAQ/C,EAAU+C,OAClBC,gBAAiBhD,EAAUgD,gBAC3BpD,iBAAkBA,EAClBd,oBAAqBA,EACrBe,cAAeA,EACf8C,UAAW3C,EAAU2C,aAK3B,OACEd,IAACC,QAAO,IACFH,EACJsB,UAAW,CACTC,KAAM,CACJC,SAAUxB,EAAayB,eAG3B,IAGN,CACEC,YAxKiB,UAyKjB/D,MAAOgE,QAGX,CACEC,UAAWC"}
1
+ {"version":3,"file":"Tooltip.mjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import { forwardRef, useState, useLayoutEffect } from 'react'\nimport { useTheme } from 'styled-components'\nimport Floater from 'react-floater'\nimport type { Props as FloaterProps, PopperInstance, Styles } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useResizeObserver } from 'hooks/useResizeObserver'\nimport { SIZES, TooltipComponent } from 'components/TooltipComponent'\nimport { deepmerge } from 'shared/utils/misc'\nimport { TooltipWrapper } from './TooltipWrapper'\nimport { TOOLTIP_STYLES_DEFAULT } from './default-constants'\nimport type { TooltipProps } from './types'\n\nconst COMPONENT_NAME = 'Tooltip'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Компонент основан на [\"react-floater\"](https://www.npmjs.com/package/react-floater).\n *\n * Получить доступ к компоненту, не подключенному к библиотеке, можно через `Tooltip.Component`.\n *\n * Полный интерфейс `Tooltip` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/Tooltip/types.ts), интерфейс `Tooltip.Component` [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n *\n */\nconst Tooltip: React.ForwardRefExoticComponent<TooltipProps> & { Component: typeof TooltipComponent } = Object.assign(\n withMergedProps<TooltipProps, HTMLDivElement>(\n forwardRef<HTMLDivElement, MergedProps<TooltipProps>>((props, ref) => {\n const {\n preset,\n size = 's',\n styles = {},\n closeOnClickOutside = false,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n sizeUnits,\n sizes,\n palette,\n black,\n contrast,\n titleProps,\n contentProps,\n closeButtonProps,\n closeOnScroll,\n portalElement,\n zIndex,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n const [portal, setPortal] = useState<HTMLElement | null>(null)\n const [popper, setPopper] = useState<PopperInstance | null>(null)\n\n const floaterStyles: Partial<Styles> =\n typeof zIndex === 'number' ? deepmerge(styles, { options: { zIndex } }) : styles\n\n useLayoutEffect(() => {\n if (portalElement) {\n setPortal(null)\n } else if (document.body) {\n let popperPortal = document.querySelector<HTMLElement>('[data-popper-portal]')\n\n if (!popperPortal) {\n popperPortal = document.createElement('div')\n popperPortal.dataset.popperPortal = 'true'\n popperPortal.style.position = 'relative'\n\n document.body.appendChild(popperPortal)\n }\n\n setPortal(popperPortal)\n }\n }, [portalElement])\n\n useResizeObserver({\n target: document.body,\n onResize: () => {\n if (popper && popper.state.options.strategy === 'absolute') {\n popper.update()\n }\n },\n })\n\n if (!portalElement && !portal) {\n return null\n }\n\n if (preset !== 'brand') {\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n styles: deepmerge(TOOLTIP_STYLES_DEFAULT, floaterStyles),\n } as FloaterProps\n\n return (\n <Floater {...tooltipProps}>\n <span>{tooltipProps.children}</span>\n </Floater>\n )\n }\n\n let color = theme.colors['bg-onmain-primary']\n\n if (black) color = theme.colors['bg-onmain-inverse']\n if (contrast) color = theme.colors['bg-brand-primary-basic']\n if (palette?.backgroundColor) {\n color = theme.colors[palette.backgroundColor as keyof typeof theme.colors] ?? palette.backgroundColor\n }\n\n const tooltipProps = {\n ...restProps,\n portalElement: portalElement ?? portal,\n getPopper: (popperInstance, origin) => {\n setPopper(popperInstance)\n if (restProps.getPopper) {\n restProps.getPopper(popperInstance, origin)\n }\n },\n offset: restProps.offset ?? 8,\n styles: deepmerge(\n {\n arrow: {\n color,\n spread: 16,\n length: 8,\n },\n floater: {\n filter: `drop-shadow(0 6px 10px ${theme.colors['bg-oncolor-hover']})`,\n },\n },\n floaterStyles\n ),\n component: (\n <TooltipWrapper\n ref={ref}\n size={size}\n sizeXXS={sizeXXS}\n sizeXS={sizeXS}\n sizeS={sizeS}\n sizeM={sizeM}\n sizeL={sizeL}\n sizeXL={sizeXL}\n sizeUnits={sizeUnits}\n sizes={sizes}\n palette={palette}\n black={black}\n contrast={contrast}\n title={restProps.title}\n titleProps={titleProps}\n content={restProps.content}\n contentProps={contentProps}\n footer={restProps.footer}\n showCloseButton={restProps.showCloseButton}\n closeButtonProps={closeButtonProps}\n closeOnClickOutside={closeOnClickOutside}\n closeOnScroll={closeOnScroll}\n component={restProps.component}\n />\n ),\n } as FloaterProps\n\n return (\n <Floater\n {...tooltipProps}\n modifiers={{\n flip: {\n enabled: !tooltipProps.disableFlip,\n },\n }}\n />\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: SIZES,\n }\n ),\n {\n Component: TooltipComponent,\n }\n)\n\nexport { Tooltip }\n\nexport { COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Tooltip","Object","assign","withMergedProps","forwardRef","props","ref","preset","size","styles","closeOnClickOutside","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","sizeUnits","sizes","palette","black","contrast","titleProps","contentProps","closeButtonProps","closeOnScroll","portalElement","zIndex","restProps","theme","useTheme","portal","setPortal","useState","popper","setPopper","floaterStyles","deepmerge","options","useLayoutEffect","document","body","popperPortal","querySelector","createElement","dataset","style","position","appendChild","useResizeObserver","target","onResize","state","strategy","update","tooltipProps","TOOLTIP_STYLES_DEFAULT","_jsx","Floater","children","color","colors","backgroundColor","getPopper","popperInstance","origin","offset","arrow","spread","length","floater","filter","component","TooltipWrapper","title","content","footer","showCloseButton","modifiers","flip","enabled","disableFlip","displayName","SIZES","Component","TooltipComponent"],"mappings":"8jBAaMA,MAAAA,eAAiB,UAiBvB,MAAMC,QAAkGC,OAAOC,OAC7GC,gBACEC,YAAsD,CAACC,EAAOC,KAC5D,MAAMC,OACJA,EAAMC,KACNA,EAAO,IAAGC,OACVA,EAAS,CAAE,EAAAC,oBACXA,GAAsB,EAAKC,QAC3BA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,MACTA,EAAKC,QACLA,EAAOC,MACPA,EAAKC,SACLA,EAAQC,WACRA,EAAUC,aACVA,EAAYC,iBACZA,EAAgBC,cAChBA,EAAaC,cACbA,EAAaC,OACbA,KACGC,GACDvB,EAEJ,MAAMwB,EAAQC,WAEd,MAAOC,EAAQC,GAAaC,SAA6B,MACzD,MAAOC,EAAQC,GAAaF,SAAgC,MAE5D,MAAMG,SACGT,GAAW,SAAWU,UAAU5B,EAAQ,CAAE6B,QAAS,CAAEX,YAAclB,EA6B5E,GA3BA8B,iBAAgB,KACd,GAAIb,EACFM,EAAU,WACL,GAAIQ,SAASC,KAAM,CACxB,IAAIC,EAAeF,SAASG,cAA2B,wBAElDD,IACHA,EAAeF,SAAS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AAYA,EACZqD,QAAS/C,EAAU+C,QACnBpD,aAAcA,EACdqD,OAAQhD,EAAUgD,OAClBC,gBAAiBjD,EAAUiD,gBAC3BrD,iBAAkBA,EAClBd,oBAAqBA,EACrBe,cAAeA,EACf+C,UAAW5C,EAAU4C,aAK3B,OACEf,IAACC,QAAO,IACFH,EACJuB,UAAW,CACTC,KAAM,CACJC,SAAUzB,EAAa0B,eAG3B,IAGN,CACEC,YA1KiB,UA2KjBhE,MAAOiE,QAGX,CACEC,UAAWC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipWrapper.js","sources":["../../../../src/components/Tooltip/TooltipWrapper.tsx"],"sourcesContent":["import { forwardRef, isValidElement, cloneElement, useRef, useImperativeHandle, useEffect } from 'react'\nimport { useKeyboardListener } from 'hooks/useKeyboardListener'\nimport { useClickOutside } from 'hooks/useClickOutside'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { keyboardKeys } from 'shared/constants'\nimport { TooltipComponent } from 'components/TooltipComponent'\nimport type { TooltipWrapperProps } from './types'\n\nconst closeFnNoop = () => undefined\n\nconst TooltipWrapper = forwardRef<HTMLDivElement, TooltipWrapperProps>((props, forwardedRef) => {\n const {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n closeOnClickOutside,\n closeOnScroll,\n id,\n role,\n closeFn = closeFnNoop,\n component,\n ...restProps\n } = props\n\n const ref = useRef<HTMLDivElement>(null)\n const tooltipChildRef = useRef<Element | null>(null)\n\n const closeFnTimerId = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useImperativeHandle(forwardedRef, () => ref.current as HTMLDivElement, [])\n\n useEffect(() => {\n if (closeOnClickOutside && ref.current) {\n const componentId = ref.current.getAttribute('id')\n\n if (componentId) {\n tooltipChildRef.current = document.querySelector(`[data-id=\"${componentId}\"]`)\n }\n }\n }, [closeOnClickOutside])\n\n useKeyboardListener('keyup', keyboardKeys.Esc.key, closeFn)\n\n useClickOutside(\n ref,\n (evt) => {\n if (!tooltipChildRef.current || !tooltipChildRef.current.contains(evt.target as Node)) {\n if (closeFnTimerId.current) {\n clearTimeout(closeFnTimerId.current)\n }\n\n closeFnTimerId.current = setTimeout(() => {\n closeFn()\n closeFnTimerId.current = null\n }, 0)\n }\n },\n {\n enabled: closeOnClickOutside,\n }\n )\n\n useScrollMonitor({\n onScrollStart: () => {\n if (closeOnScroll) closeFn()\n },\n })\n\n const injectionProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n id,\n role,\n closeFn,\n }\n\n if (isValidElement(component)) {\n const elementProps = typeof component.props === 'object' && component.props !== null ? component.props : {}\n\n return cloneElement(component, { ref, ...injectionProps, ...elementProps })\n }\n\n if (typeof component === 'function') {\n return component(injectionProps)\n }\n\n return <TooltipComponent ref={ref} {...injectionProps} {...restProps} />\n})\n\nexport { TooltipWrapper }\n"],"names":["closeFnNoop","forwardRef","props","forwardedRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","black","contrast","showCloseButton","closeButtonProps","closeOnClickOutside","closeOnScroll","id","role","closeFn","component","restProps","ref","useRef","tooltipChildRef","closeFnTimerId","useImperativeHandle","current","useEffect","componentId","getAttribute","document","querySelector","useKeyboardListener","keyboardKeys","Esc","key","useClickOutside","evt","contains","target","clearTimeout","setTimeout","enabled","useScrollMonitor","onScrollStart","injectionProps","isValidElement","elementProps","cloneElement","_jsx","TooltipComponent"],"mappings":"mZAQA,MAAMA,YAAcA,KAAe,yBAEZC,MAAUA,YAAsC,CAACC,EAAOC,KAC7E,MAAMC,KACJA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,gBACRA,EAAeC,iBACfA,EAAgBC,oBAChBA,EAAmBC,cACnBA,EAAaC,GACbA,EAAEC,KACFA,EAAIC,QACJA,EAAUnB,YAAWoB,UACrBA,KACGC,GACDnB,EAEJ,MAAMoB,EAAMC,aAAuB,MACnC,MAAMC,EAAkBD,aAAuB,MAE/C,MAAME,EAAiBF,aAA6C,MAEpEG,MAAAA,oBAAoBvB,GAAc,IAAMmB,EAAIK,SAA2B,IAEvEC,MAAAA,WAAU,KACR,GAAIb,GAAuBO,EAAIK,QAAS,CACtC,MAAME,EAAcP,EAAIK,QAAQG,aAAa,MAEzCD,IACFL,EAAgBG,QAAUI,SAASC,cAAc,aAAaH,OAElE,IACC,CAACd,IAEJkB,oBAAmBA,oBAAC,QAASC,UAAYA,aAACC,IAAIC,IAAKjB,GAEnDkB,gBAAeA,gBACbf,GACCgB,IACMd,EAAgBG,SAAYH,EAAgBG,QAAQY,SAASD,EAAIE,UAChEf,EAAeE,SACjBc,aAAahB,EAAeE,SAG9BF,EAAeE,QAAUe,YAAW,KAClCvB,IACAM,EAAeE,QAAU,IAAI,GAC5B,GACL,GAEF,CACEgB,QAAS5B,IAIb6B,kCAAiB,CACfC,cAAeA,KACT7B,GAAeG,GAAS,IAIhC,MAAM2B,EAAiB,CACrB1C,OACAC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,WACAC,kBACAC,mBACAG,KACAC,OACAC,WAGF,GAAI4B,MAAAA,eAAe3B,GAAY,CAC7B,MAAM4B,SAAsB5B,EAAUlB,OAAU,UAAYkB,EAAUlB,QAAU,KAAOkB,EAAUlB,MAAQ,CAAA,EAEzG,OAAO+C,MAAAA,aAAa7B,EAAW,CAAEE,SAAQwB,KAAmBE,GAC9D,CAEA,cAAW5B,GAAc,WAChBA,EAAU0B,GAGZI,WAAAA,IAACC,iBAAAA,iBAAgB,CAAC7B,IAAKA,KAASwB,KAAoBzB,GAAa"}
1
+ {"version":3,"file":"TooltipWrapper.js","sources":["../../../../src/components/Tooltip/TooltipWrapper.tsx"],"sourcesContent":["import { forwardRef, isValidElement, cloneElement, useRef, useImperativeHandle, useEffect } from 'react'\nimport { useKeyboardListener } from 'hooks/useKeyboardListener'\nimport { useClickOutside } from 'hooks/useClickOutside'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { keyboardKeys } from 'shared/constants'\nimport { TooltipComponent } from 'components/TooltipComponent'\nimport type { TooltipWrapperProps } from './types'\n\nconst closeFnNoop = () => undefined\n\nconst TooltipWrapper = forwardRef<HTMLDivElement, TooltipWrapperProps>((props, forwardedRef) => {\n const {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n closeOnClickOutside,\n closeOnScroll,\n id,\n role,\n closeFn = closeFnNoop,\n component,\n ...restProps\n } = props\n\n const ref = useRef<HTMLDivElement>(null)\n const tooltipChildRef = useRef<Element | null>(null)\n\n const closeFnTimerId = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useImperativeHandle(forwardedRef, () => ref.current as HTMLDivElement, [])\n\n useEffect(() => {\n if (closeOnClickOutside && ref.current) {\n const componentId = ref.current.getAttribute('id')\n\n if (componentId) {\n tooltipChildRef.current = document.querySelector(`[data-id=\"${componentId}\"]`)\n }\n }\n }, [closeOnClickOutside])\n\n useKeyboardListener('keyup', keyboardKeys.Esc.key, closeFn)\n\n useClickOutside(\n ref,\n (evt) => {\n if (!tooltipChildRef.current || !tooltipChildRef.current.contains(evt.target as Node)) {\n if (closeFnTimerId.current) {\n clearTimeout(closeFnTimerId.current)\n }\n\n closeFnTimerId.current = setTimeout(() => {\n closeFn()\n closeFnTimerId.current = null\n }, 0)\n }\n },\n {\n enabled: closeOnClickOutside,\n }\n )\n\n useScrollMonitor({\n onScrollStart: () => {\n if (closeOnScroll) closeFn()\n },\n })\n\n const injectionProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n id,\n role,\n closeFn,\n }\n\n if (isValidElement(component)) {\n const elementProps = typeof component.props === 'object' && component.props !== null ? component.props : {}\n\n return cloneElement(component as React.ReactElement<React.RefAttributes<HTMLElement>>, {\n ref,\n ...injectionProps,\n ...elementProps,\n })\n }\n\n if (typeof component === 'function') {\n return component(injectionProps)\n }\n\n return <TooltipComponent ref={ref} {...injectionProps} {...restProps} />\n})\n\nexport { TooltipWrapper }\n"],"names":["closeFnNoop","forwardRef","props","forwardedRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","black","contrast","showCloseButton","closeButtonProps","closeOnClickOutside","closeOnScroll","id","role","closeFn","component","restProps","ref","useRef","tooltipChildRef","closeFnTimerId","useImperativeHandle","current","useEffect","componentId","getAttribute","document","querySelector","useKeyboardListener","keyboardKeys","Esc","key","useClickOutside","evt","contains","target","clearTimeout","setTimeout","enabled","useScrollMonitor","onScrollStart","injectionProps","isValidElement","elementProps","cloneElement","_jsx","TooltipComponent"],"mappings":"mZAQA,MAAMA,YAAcA,KAAe,yBAEZC,MAAUA,YAAsC,CAACC,EAAOC,KAC7E,MAAMC,KACJA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,gBACRA,EAAeC,iBACfA,EAAgBC,oBAChBA,EAAmBC,cACnBA,EAAaC,GACbA,EAAEC,KACFA,EAAIC,QACJA,EAAUnB,YAAWoB,UACrBA,KACGC,GACDnB,EAEJ,MAAMoB,EAAMC,aAAuB,MACnC,MAAMC,EAAkBD,aAAuB,MAE/C,MAAME,EAAiBF,aAA6C,MAEpEG,MAAAA,oBAAoBvB,GAAc,IAAMmB,EAAIK,SAA2B,IAEvEC,MAAAA,WAAU,KACR,GAAIb,GAAuBO,EAAIK,QAAS,CACtC,MAAME,EAAcP,EAAIK,QAAQG,aAAa,MAEzCD,IACFL,EAAgBG,QAAUI,SAASC,cAAc,aAAaH,OAElE,IACC,CAACd,IAEJkB,oBAAmBA,oBAAC,QAASC,UAAYA,aAACC,IAAIC,IAAKjB,GAEnDkB,gBAAeA,gBACbf,GACCgB,IACMd,EAAgBG,SAAYH,EAAgBG,QAAQY,SAASD,EAAIE,UAChEf,EAAeE,SACjBc,aAAahB,EAAeE,SAG9BF,EAAeE,QAAUe,YAAW,KAClCvB,IACAM,EAAeE,QAAU,IAAI,GAC5B,GACL,GAEF,CACEgB,QAAS5B,IAIb6B,kCAAiB,CACfC,cAAeA,KACT7B,GAAeG,GAAS,IAIhC,MAAM2B,EAAiB,CACrB1C,OACAC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,WACAC,kBACAC,mBACAG,KACAC,OACAC,WAGF,GAAI4B,MAAAA,eAAe3B,GAAY,CAC7B,MAAM4B,SAAsB5B,EAAUlB,OAAU,UAAYkB,EAAUlB,QAAU,KAAOkB,EAAUlB,MAAQ,CAAA,EAEzG,OAAO+C,MAAAA,aAAa7B,EAAmE,CACrFE,SACGwB,KACAE,GAEP,CAEA,cAAW5B,GAAc,WAChBA,EAAU0B,GAGZI,WAAAA,IAACC,iBAAAA,iBAAgB,CAAC7B,IAAKA,KAASwB,KAAoBzB,GAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipWrapper.mjs","sources":["../../../../src/components/Tooltip/TooltipWrapper.tsx"],"sourcesContent":["import { forwardRef, isValidElement, cloneElement, useRef, useImperativeHandle, useEffect } from 'react'\nimport { useKeyboardListener } from 'hooks/useKeyboardListener'\nimport { useClickOutside } from 'hooks/useClickOutside'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { keyboardKeys } from 'shared/constants'\nimport { TooltipComponent } from 'components/TooltipComponent'\nimport type { TooltipWrapperProps } from './types'\n\nconst closeFnNoop = () => undefined\n\nconst TooltipWrapper = forwardRef<HTMLDivElement, TooltipWrapperProps>((props, forwardedRef) => {\n const {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n closeOnClickOutside,\n closeOnScroll,\n id,\n role,\n closeFn = closeFnNoop,\n component,\n ...restProps\n } = props\n\n const ref = useRef<HTMLDivElement>(null)\n const tooltipChildRef = useRef<Element | null>(null)\n\n const closeFnTimerId = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useImperativeHandle(forwardedRef, () => ref.current as HTMLDivElement, [])\n\n useEffect(() => {\n if (closeOnClickOutside && ref.current) {\n const componentId = ref.current.getAttribute('id')\n\n if (componentId) {\n tooltipChildRef.current = document.querySelector(`[data-id=\"${componentId}\"]`)\n }\n }\n }, [closeOnClickOutside])\n\n useKeyboardListener('keyup', keyboardKeys.Esc.key, closeFn)\n\n useClickOutside(\n ref,\n (evt) => {\n if (!tooltipChildRef.current || !tooltipChildRef.current.contains(evt.target as Node)) {\n if (closeFnTimerId.current) {\n clearTimeout(closeFnTimerId.current)\n }\n\n closeFnTimerId.current = setTimeout(() => {\n closeFn()\n closeFnTimerId.current = null\n }, 0)\n }\n },\n {\n enabled: closeOnClickOutside,\n }\n )\n\n useScrollMonitor({\n onScrollStart: () => {\n if (closeOnScroll) closeFn()\n },\n })\n\n const injectionProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n id,\n role,\n closeFn,\n }\n\n if (isValidElement(component)) {\n const elementProps = typeof component.props === 'object' && component.props !== null ? component.props : {}\n\n return cloneElement(component, { ref, ...injectionProps, ...elementProps })\n }\n\n if (typeof component === 'function') {\n return component(injectionProps)\n }\n\n return <TooltipComponent ref={ref} {...injectionProps} {...restProps} />\n})\n\nexport { TooltipWrapper }\n"],"names":["closeFnNoop","TooltipWrapper","forwardRef","props","forwardedRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","black","contrast","showCloseButton","closeButtonProps","closeOnClickOutside","closeOnScroll","id","role","closeFn","component","restProps","ref","useRef","tooltipChildRef","closeFnTimerId","useImperativeHandle","current","useEffect","componentId","getAttribute","document","querySelector","useKeyboardListener","keyboardKeys","Esc","key","useClickOutside","evt","contains","target","clearTimeout","setTimeout","enabled","useScrollMonitor","onScrollStart","injectionProps","isValidElement","elementProps","cloneElement","_jsx","TooltipComponent"],"mappings":"+bAQA,MAAMA,YAAcA,KAAe,EAE7BC,MAAAA,eAAiBC,YAAgD,CAACC,EAAOC,KAC7E,MAAMC,KACJA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,gBACRA,EAAeC,iBACfA,EAAgBC,oBAChBA,EAAmBC,cACnBA,EAAaC,GACbA,EAAEC,KACFA,EAAIC,QACJA,EAAUpB,YAAWqB,UACrBA,KACGC,GACDnB,EAEJ,MAAMoB,EAAMC,OAAuB,MACnC,MAAMC,EAAkBD,OAAuB,MAE/C,MAAME,EAAiBF,OAA6C,MAEpEG,oBAAoBvB,GAAc,IAAMmB,EAAIK,SAA2B,IAEvEC,WAAU,KACR,GAAIb,GAAuBO,EAAIK,QAAS,CACtC,MAAME,EAAcP,EAAIK,QAAQG,aAAa,MAEzCD,IACFL,EAAgBG,QAAUI,SAASC,cAAc,aAAaH,OAElE,IACC,CAACd,IAEJkB,oBAAoB,QAASC,aAAaC,IAAIC,IAAKjB,GAEnDkB,gBACEf,GACCgB,IACMd,EAAgBG,SAAYH,EAAgBG,QAAQY,SAASD,EAAIE,UAChEf,EAAeE,SACjBc,aAAahB,EAAeE,SAG9BF,EAAeE,QAAUe,YAAW,KAClCvB,IACAM,EAAeE,QAAU,IAAI,GAC5B,GACL,GAEF,CACEgB,QAAS5B,IAIb6B,iBAAiB,CACfC,cAAeA,KACT7B,GAAeG,GAAS,IAIhC,MAAM2B,EAAiB,CACrB1C,OACAC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,WACAC,kBACAC,mBACAG,KACAC,OACAC,WAGF,GAAI4B,eAAe3B,GAAY,CAC7B,MAAM4B,SAAsB5B,EAAUlB,OAAU,UAAYkB,EAAUlB,QAAU,KAAOkB,EAAUlB,MAAQ,CAAA,EAEzG,OAAO+C,aAAa7B,EAAW,CAAEE,SAAQwB,KAAmBE,GAC9D,CAEA,cAAW5B,GAAc,WAChBA,EAAU0B,GAGZI,IAACC,iBAAgB,CAAC7B,IAAKA,KAASwB,KAAoBzB,GAAa"}
1
+ {"version":3,"file":"TooltipWrapper.mjs","sources":["../../../../src/components/Tooltip/TooltipWrapper.tsx"],"sourcesContent":["import { forwardRef, isValidElement, cloneElement, useRef, useImperativeHandle, useEffect } from 'react'\nimport { useKeyboardListener } from 'hooks/useKeyboardListener'\nimport { useClickOutside } from 'hooks/useClickOutside'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { keyboardKeys } from 'shared/constants'\nimport { TooltipComponent } from 'components/TooltipComponent'\nimport type { TooltipWrapperProps } from './types'\n\nconst closeFnNoop = () => undefined\n\nconst TooltipWrapper = forwardRef<HTMLDivElement, TooltipWrapperProps>((props, forwardedRef) => {\n const {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n closeOnClickOutside,\n closeOnScroll,\n id,\n role,\n closeFn = closeFnNoop,\n component,\n ...restProps\n } = props\n\n const ref = useRef<HTMLDivElement>(null)\n const tooltipChildRef = useRef<Element | null>(null)\n\n const closeFnTimerId = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n useImperativeHandle(forwardedRef, () => ref.current as HTMLDivElement, [])\n\n useEffect(() => {\n if (closeOnClickOutside && ref.current) {\n const componentId = ref.current.getAttribute('id')\n\n if (componentId) {\n tooltipChildRef.current = document.querySelector(`[data-id=\"${componentId}\"]`)\n }\n }\n }, [closeOnClickOutside])\n\n useKeyboardListener('keyup', keyboardKeys.Esc.key, closeFn)\n\n useClickOutside(\n ref,\n (evt) => {\n if (!tooltipChildRef.current || !tooltipChildRef.current.contains(evt.target as Node)) {\n if (closeFnTimerId.current) {\n clearTimeout(closeFnTimerId.current)\n }\n\n closeFnTimerId.current = setTimeout(() => {\n closeFn()\n closeFnTimerId.current = null\n }, 0)\n }\n },\n {\n enabled: closeOnClickOutside,\n }\n )\n\n useScrollMonitor({\n onScrollStart: () => {\n if (closeOnScroll) closeFn()\n },\n })\n\n const injectionProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n black,\n contrast,\n showCloseButton,\n closeButtonProps,\n id,\n role,\n closeFn,\n }\n\n if (isValidElement(component)) {\n const elementProps = typeof component.props === 'object' && component.props !== null ? component.props : {}\n\n return cloneElement(component as React.ReactElement<React.RefAttributes<HTMLElement>>, {\n ref,\n ...injectionProps,\n ...elementProps,\n })\n }\n\n if (typeof component === 'function') {\n return component(injectionProps)\n }\n\n return <TooltipComponent ref={ref} {...injectionProps} {...restProps} />\n})\n\nexport { TooltipWrapper }\n"],"names":["closeFnNoop","TooltipWrapper","forwardRef","props","forwardedRef","size","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","black","contrast","showCloseButton","closeButtonProps","closeOnClickOutside","closeOnScroll","id","role","closeFn","component","restProps","ref","useRef","tooltipChildRef","closeFnTimerId","useImperativeHandle","current","useEffect","componentId","getAttribute","document","querySelector","useKeyboardListener","keyboardKeys","Esc","key","useClickOutside","evt","contains","target","clearTimeout","setTimeout","enabled","useScrollMonitor","onScrollStart","injectionProps","isValidElement","elementProps","cloneElement","_jsx","TooltipComponent"],"mappings":"+bAQA,MAAMA,YAAcA,KAAe,EAE7BC,MAAAA,eAAiBC,YAAgD,CAACC,EAAOC,KAC7E,MAAMC,KACJA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,gBACRA,EAAeC,iBACfA,EAAgBC,oBAChBA,EAAmBC,cACnBA,EAAaC,GACbA,EAAEC,KACFA,EAAIC,QACJA,EAAUpB,YAAWqB,UACrBA,KACGC,GACDnB,EAEJ,MAAMoB,EAAMC,OAAuB,MACnC,MAAMC,EAAkBD,OAAuB,MAE/C,MAAME,EAAiBF,OAA6C,MAEpEG,oBAAoBvB,GAAc,IAAMmB,EAAIK,SAA2B,IAEvEC,WAAU,KACR,GAAIb,GAAuBO,EAAIK,QAAS,CACtC,MAAME,EAAcP,EAAIK,QAAQG,aAAa,MAEzCD,IACFL,EAAgBG,QAAUI,SAASC,cAAc,aAAaH,OAElE,IACC,CAACd,IAEJkB,oBAAoB,QAASC,aAAaC,IAAIC,IAAKjB,GAEnDkB,gBACEf,GACCgB,IACMd,EAAgBG,SAAYH,EAAgBG,QAAQY,SAASD,EAAIE,UAChEf,EAAeE,SACjBc,aAAahB,EAAeE,SAG9BF,EAAeE,QAAUe,YAAW,KAClCvB,IACAM,EAAeE,QAAU,IAAI,GAC5B,GACL,GAEF,CACEgB,QAAS5B,IAIb6B,iBAAiB,CACfC,cAAeA,KACT7B,GAAeG,GAAS,IAIhC,MAAM2B,EAAiB,CACrB1C,OACAC,UACAC,SACAC,QACAC,QACAC,QACAC,SACAC,QACAC,WACAC,kBACAC,mBACAG,KACAC,OACAC,WAGF,GAAI4B,eAAe3B,GAAY,CAC7B,MAAM4B,SAAsB5B,EAAUlB,OAAU,UAAYkB,EAAUlB,QAAU,KAAOkB,EAAUlB,MAAQ,CAAA,EAEzG,OAAO+C,aAAa7B,EAAmE,CACrFE,SACGwB,KACAE,GAEP,CAEA,cAAW5B,GAAc,WAChBA,EAAU0B,GAGZI,IAACC,iBAAgB,CAAC7B,IAAKA,KAASwB,KAAoBzB,GAAa"}
@@ -1,2 +1,2 @@
1
- 'use strict';var React=require('react');var withMergedProps=require('../../hocs/withMergedProps.js');var constants=require('./constants.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Text=require('../Text/Text.js');const TooltipComponent=withMergedProps.withMergedProps(React.forwardRef(((e,t)=>{const{size:o="s",titleProps:s={},contentProps:i={},closeButtonProps:n={},sizeXXS:r,sizeXS:c,sizeS:a,sizeM:l,sizeL:p,sizeXL:m,title:x,content:u,footer:z,closeFn:T,showCloseButton:d,...S}=e;const h={size:o,sizeXXS:r,sizeXS:c,sizeS:a,sizeM:l,sizeL:p,sizeXL:m};return jsxRuntime.jsxs(style.Root,{...S,...h,ref:t,children:[d&&jsxRuntime.jsx(style.CloseButton,{size:"s",icon:"close",secondary:S.black,contrast:S.black||S.contrast,...n,onClick:e=>{typeof T=='function'&&T(),n.onClick&&n.onClick(e)}}),x&&jsxRuntime.jsx(Text.Text,{appearance:"body",color:"inherit",weight:700,marginRight:d?16:void 0,marginBottom:u||z?'0.3em':void 0,sizes:constants.SIZES_TEXT,...h,...s,children:x}),u&&jsxRuntime.jsx(Text.Text,{appearance:"body",color:"inherit",marginRight:!x&&d?16:void 0,marginBottom:z?'0.2em':void 0,sizes:constants.SIZES_TEXT,...h,...i,children:u}),typeof z=='function'?z(h):z]})})),{sizes:constants.SIZES,displayName:"TooltipComponent"});exports.SIZES=constants.SIZES,exports.COMPONENT_NAME="TooltipComponent",exports.TooltipComponent=TooltipComponent;
1
+ 'use strict';var React=require('react');var withMergedProps=require('../../hocs/withMergedProps.js');var constants=require('./constants.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Text=require('../Text/Text.js');const TooltipComponent=withMergedProps.withMergedProps(React.forwardRef(((e,t)=>{const{size:o="s",titleProps:s={},contentProps:i={},closeButtonProps:n={},sizeXXS:r,sizeXS:c,sizeS:a,sizeM:l,sizeL:p,sizeXL:u,title:m,content:x,footer:z,closeFn:T,showCloseButton:d,...S}=e;const h={size:o,sizeXXS:r,sizeXS:c,sizeS:a,sizeM:l,sizeL:p,sizeXL:u};return jsxRuntime.jsxs(style.Root,{...S,...h,ref:t,children:[d?jsxRuntime.jsx(style.CloseButton,{size:"s",icon:"close",secondary:S.black,contrast:S.black||S.contrast,...n,onClick:e=>{typeof T=='function'&&T(),n.onClick&&n.onClick(e)}}):null,m?jsxRuntime.jsx(Text.Text,{appearance:"body",color:"inherit",weight:700,marginRight:d?16:void 0,marginBottom:x||z?'0.3em':void 0,sizes:constants.SIZES_TEXT,...h,...s,children:m}):null,x?jsxRuntime.jsx(Text.Text,{appearance:"body",color:"inherit",marginRight:!m&&d?16:void 0,marginBottom:z?'0.2em':void 0,sizes:constants.SIZES_TEXT,...h,...i,children:x}):null,typeof z=='function'?z(h):z]})})),{sizes:constants.SIZES,displayName:"TooltipComponent"});exports.SIZES=constants.SIZES,exports.COMPONENT_NAME="TooltipComponent",exports.TooltipComponent=TooltipComponent;
2
2
  //# sourceMappingURL=TooltipComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipComponent.js","sources":["../../../../src/components/TooltipComponent/TooltipComponent.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { Text } from 'components/Text'\nimport { SIZES, SIZES_TEXT } from './constants'\nimport type { TooltipComponentProps } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'TooltipComponent'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс `TooltipComponent` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n */\nconst TooltipComponent: React.ForwardRefExoticComponent<TooltipComponentProps> = withMergedProps<\n TooltipComponentProps,\n HTMLDivElement\n>(\n forwardRef((props, ref) => {\n const {\n size = 's',\n titleProps = {},\n contentProps = {},\n closeButtonProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n title,\n content,\n footer,\n closeFn,\n showCloseButton,\n ...restProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n return (\n <Styled.Root {...restProps} {...sizeProps} ref={ref}>\n {showCloseButton && (\n <Styled.CloseButton\n size='s'\n icon='close'\n secondary={restProps.black}\n contrast={restProps.black || restProps.contrast}\n {...closeButtonProps}\n onClick={(evt) => {\n if (typeof closeFn === 'function') closeFn()\n if (closeButtonProps.onClick) closeButtonProps.onClick(evt)\n }}\n />\n )}\n {title && (\n <Text\n appearance='body'\n color='inherit'\n weight={700}\n marginRight={showCloseButton ? 16 : undefined}\n marginBottom={content || footer ? '0.3em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...titleProps}\n >\n {title}\n </Text>\n )}\n {content && (\n <Text\n appearance='body'\n color='inherit'\n marginRight={!title && showCloseButton ? 16 : undefined}\n marginBottom={footer ? '0.2em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...contentProps}\n >\n {content}\n </Text>\n )}\n {typeof footer === 'function' ? footer(sizeProps) : footer}\n </Styled.Root>\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { TooltipComponent }\n\nexport { COMPONENT_NAME, SIZES }\n"],"names":["TooltipComponent","withMergedProps","forwardRef","props","ref","size","titleProps","contentProps","closeButtonProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","title","content","footer","closeFn","showCloseButton","restProps","sizeProps","_jsxs","Styled","children","_jsx","jsx","icon","secondary","black","contrast","onClick","evt","Text","appearance","color","weight","marginRight","undefined","marginBottom","sizes","SIZES_TEXT","SIZES","displayName"],"mappings":"6PAmBMA,MAAAA,iBAA2EC,gBAAAA,gBAI/EC,MAAAA,YAAW,CAACC,EAAOC,KACjB,MAAMC,KACJA,EAAO,IAAGC,WACVA,EAAa,CAAE,EAAAC,aACfA,EAAe,CAAE,EAAAC,iBACjBA,EAAmB,CAAE,EAAAC,QACrBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,QACNA,EAAOC,gBACPA,KACGC,GACDjB,EAEJ,MAAMkB,EAAY,CAChBhB,OACAI,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,OACEQ,WAAAA,KAACC,MAAAA,KAAW,IAAKH,KAAeC,EAAWjB,IAAKA,EAAIoB,UACjDL,GACCM,WAAAC,IAACH,kBAAkB,CACjBlB,KAAK,IACLsB,KAAK,QACLC,UAAWR,EAAUS,MACrBC,SAAUV,EAAUS,OAAST,EAAUU,YACnCtB,EACJuB,QAAUC,WACGd,GAAY,YAAYA,IAC/BV,EAAiBuB,SAASvB,EAAiBuB,QAAQC,EAAI,IAIhEjB,GACCU,WAAAC,IAACO,UAAI,CACHC,WAAW,OACXC,MAAM,UACNC,OAAQ,IACRC,YAAalB,EAAkB,QAAKmB,EACpCC,aAAcvB,GAAWC,EAAS,aAAUqB,EAC5CE,MAAOC,UAAWA,cACdpB,KACAf,EAAUkB,SAEbT,IAGJC,GACCS,WAAAC,IAACO,UAAI,CACHC,WAAW,OACXC,MAAM,UACNE,aAActB,GAASI,EAAkB,QAAKmB,EAC9CC,aAActB,EAAS,aAAUqB,EACjCE,MAAOC,UAAWA,cACdpB,KACAd,EAAYiB,SAEfR,WAGGC,GAAW,WAAaA,EAAOI,GAAaJ,IACxC,IAGlB,CACEuB,MAAOE,UAAKA,MACZC,YA9FmB,0EAAA"}
1
+ {"version":3,"file":"TooltipComponent.js","sources":["../../../../src/components/TooltipComponent/TooltipComponent.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Text } from 'components/Text'\nimport { SIZES, SIZES_TEXT } from './constants'\nimport type { TooltipComponentProps } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'TooltipComponent'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс `TooltipComponent` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n */\nconst TooltipComponent: React.ForwardRefExoticComponent<TooltipComponentProps> = withMergedProps<\n TooltipComponentProps,\n HTMLDivElement\n>(\n forwardRef<HTMLDivElement, MergedProps<TooltipComponentProps>>((props, ref) => {\n const {\n size = 's',\n titleProps = {},\n contentProps = {},\n closeButtonProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n title,\n content,\n footer,\n closeFn,\n showCloseButton,\n ...restProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n return (\n <Styled.Root {...restProps} {...sizeProps} ref={ref}>\n {showCloseButton ? (\n <Styled.CloseButton\n size='s'\n icon='close'\n secondary={restProps.black}\n contrast={restProps.black || restProps.contrast}\n {...closeButtonProps}\n onClick={(evt) => {\n if (typeof closeFn === 'function') closeFn()\n if (closeButtonProps.onClick) closeButtonProps.onClick(evt)\n }}\n />\n ) : null}\n {title ? (\n <Text\n appearance='body'\n color='inherit'\n weight={700}\n marginRight={showCloseButton ? 16 : undefined}\n marginBottom={content || footer ? '0.3em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...titleProps}\n >\n {title}\n </Text>\n ) : null}\n {content ? (\n <Text\n appearance='body'\n color='inherit'\n marginRight={!title && showCloseButton ? 16 : undefined}\n marginBottom={footer ? '0.2em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...contentProps}\n >\n {content}\n </Text>\n ) : null}\n {typeof footer === 'function' ? footer(sizeProps) : footer}\n </Styled.Root>\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { TooltipComponent }\n\nexport { COMPONENT_NAME, SIZES }\n"],"names":["TooltipComponent","withMergedProps","forwardRef","props","ref","size","titleProps","contentProps","closeButtonProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","title","content","footer","closeFn","showCloseButton","restProps","sizeProps","_jsxs","Styled","children","_jsx","jsx","icon","secondary","black","contrast","onClick","evt","Text","appearance","color","weight","marginRight","undefined","marginBottom","sizes","SIZES_TEXT","SIZES","displayName"],"mappings":"6PAoBMA,MAAAA,iBAA2EC,gBAAAA,gBAI/EC,MAAAA,YAA+D,CAACC,EAAOC,KACrE,MAAMC,KACJA,EAAO,IAAGC,WACVA,EAAa,CAAE,EAAAC,aACfA,EAAe,CAAE,EAAAC,iBACjBA,EAAmB,CAAE,EAAAC,QACrBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,QACNA,EAAOC,gBACPA,KACGC,GACDjB,EAEJ,MAAMkB,EAAY,CAChBhB,OACAI,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,OACEQ,WAAAA,KAACC,MAAAA,KAAW,IAAKH,KAAeC,EAAWjB,IAAKA,EAAIoB,UACjDL,EACCM,WAAAC,IAACH,kBAAkB,CACjBlB,KAAK,IACLsB,KAAK,QACLC,UAAWR,EAAUS,MACrBC,SAAUV,EAAUS,OAAST,EAAUU,YACnCtB,EACJuB,QAAUC,WACGd,GAAY,YAAYA,IAC/BV,EAAiBuB,SAASvB,EAAiBuB,QAAQC,EAAI,IAG7D,KACHjB,EACCU,WAAAA,IAACQ,KAAAA,KAAI,CACHC,WAAW,OACXC,MAAM,UACNC,OAAQ,IACRC,YAAalB,EAAkB,QAAKmB,EACpCC,aAAcvB,GAAWC,EAAS,aAAUqB,EAC5CE,MAAOC,UAAWA,cACdpB,KACAf,EAAUkB,SAEbT,IAED,KACHC,EACCS,WAAAA,IAACQ,KAAAA,KAAI,CACHC,WAAW,OACXC,MAAM,UACNE,aAActB,GAASI,EAAkB,QAAKmB,EAC9CC,aAActB,EAAS,aAAUqB,EACjCE,MAAOC,UAAWA,cACdpB,KACAd,EAAYiB,SAEfR,IAED,YACIC,GAAW,WAAaA,EAAOI,GAAaJ,IACxC,IAGlB,CACEuB,MAAOE,UAAKA,MACZC,YA9FmB,0EAAA"}
@@ -1,2 +1,2 @@
1
- import{forwardRef}from'react';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{SIZES,SIZES_TEXT}from'./constants.mjs';import{Root,CloseButton}from'./style.mjs';import{jsxs,jsx}from'react/jsx-runtime';import{Text}from'../Text/Text.mjs';const COMPONENT_NAME='TooltipComponent';const TooltipComponent=withMergedProps(forwardRef(((o,t)=>{const{size:e="s",titleProps:s={},contentProps:i={},closeButtonProps:r={},sizeXXS:n,sizeXS:c,sizeS:m,sizeM:p,sizeL:l,sizeXL:a,title:z,content:S,footer:T,closeFn:d,showCloseButton:f,...h}=o;const x={size:e,sizeXXS:n,sizeXS:c,sizeS:m,sizeM:p,sizeL:l,sizeXL:a};return jsxs(Root,{...h,...x,ref:t,children:[f&&jsx(CloseButton,{size:"s",icon:"close",secondary:h.black,contrast:h.black||h.contrast,...r,onClick:o=>{typeof d=='function'&&d(),r.onClick&&r.onClick(o)}}),z&&jsx(Text,{appearance:"body",color:"inherit",weight:700,marginRight:f?16:void 0,marginBottom:S||T?'0.3em':void 0,sizes:SIZES_TEXT,...x,...s,children:z}),S&&jsx(Text,{appearance:"body",color:"inherit",marginRight:!z&&f?16:void 0,marginBottom:T?'0.2em':void 0,sizes:SIZES_TEXT,...x,...i,children:S}),typeof T=='function'?T(x):T]})})),{sizes:SIZES,displayName:"TooltipComponent"});export{COMPONENT_NAME,SIZES,TooltipComponent};
1
+ import{forwardRef}from'react';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{SIZES,SIZES_TEXT}from'./constants.mjs';import{Root,CloseButton}from'./style.mjs';import{jsxs,jsx}from'react/jsx-runtime';import{Text}from'../Text/Text.mjs';const COMPONENT_NAME='TooltipComponent';const TooltipComponent=withMergedProps(forwardRef(((o,t)=>{const{size:e="s",titleProps:s={},contentProps:i={},closeButtonProps:n={},sizeXXS:r,sizeXS:c,sizeS:l,sizeM:m,sizeL:p,sizeXL:a,title:z,content:S,footer:T,closeFn:d,showCloseButton:f,...h}=o;const x={size:e,sizeXXS:r,sizeXS:c,sizeS:l,sizeM:m,sizeL:p,sizeXL:a};return jsxs(Root,{...h,...x,ref:t,children:[f?jsx(CloseButton,{size:"s",icon:"close",secondary:h.black,contrast:h.black||h.contrast,...n,onClick:o=>{typeof d=='function'&&d(),n.onClick&&n.onClick(o)}}):null,z?jsx(Text,{appearance:"body",color:"inherit",weight:700,marginRight:f?16:void 0,marginBottom:S||T?'0.3em':void 0,sizes:SIZES_TEXT,...x,...s,children:z}):null,S?jsx(Text,{appearance:"body",color:"inherit",marginRight:!z&&f?16:void 0,marginBottom:T?'0.2em':void 0,sizes:SIZES_TEXT,...x,...i,children:S}):null,typeof T=='function'?T(x):T]})})),{sizes:SIZES,displayName:"TooltipComponent"});export{COMPONENT_NAME,SIZES,TooltipComponent};
2
2
  //# sourceMappingURL=TooltipComponent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipComponent.mjs","sources":["../../../../src/components/TooltipComponent/TooltipComponent.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { Text } from 'components/Text'\nimport { SIZES, SIZES_TEXT } from './constants'\nimport type { TooltipComponentProps } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'TooltipComponent'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс `TooltipComponent` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n */\nconst TooltipComponent: React.ForwardRefExoticComponent<TooltipComponentProps> = withMergedProps<\n TooltipComponentProps,\n HTMLDivElement\n>(\n forwardRef((props, ref) => {\n const {\n size = 's',\n titleProps = {},\n contentProps = {},\n closeButtonProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n title,\n content,\n footer,\n closeFn,\n showCloseButton,\n ...restProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n return (\n <Styled.Root {...restProps} {...sizeProps} ref={ref}>\n {showCloseButton && (\n <Styled.CloseButton\n size='s'\n icon='close'\n secondary={restProps.black}\n contrast={restProps.black || restProps.contrast}\n {...closeButtonProps}\n onClick={(evt) => {\n if (typeof closeFn === 'function') closeFn()\n if (closeButtonProps.onClick) closeButtonProps.onClick(evt)\n }}\n />\n )}\n {title && (\n <Text\n appearance='body'\n color='inherit'\n weight={700}\n marginRight={showCloseButton ? 16 : undefined}\n marginBottom={content || footer ? '0.3em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...titleProps}\n >\n {title}\n </Text>\n )}\n {content && (\n <Text\n appearance='body'\n color='inherit'\n marginRight={!title && showCloseButton ? 16 : undefined}\n marginBottom={footer ? '0.2em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...contentProps}\n >\n {content}\n </Text>\n )}\n {typeof footer === 'function' ? footer(sizeProps) : footer}\n </Styled.Root>\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { TooltipComponent }\n\nexport { COMPONENT_NAME, SIZES }\n"],"names":["COMPONENT_NAME","TooltipComponent","withMergedProps","forwardRef","props","ref","size","titleProps","contentProps","closeButtonProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","title","content","footer","closeFn","showCloseButton","restProps","sizeProps","_jsxs","Styled","children","_jsx","icon","secondary","black","contrast","onClick","evt","Text","appearance","color","weight","marginRight","undefined","marginBottom","sizes","SIZES_TEXT","SIZES","displayName"],"mappings":"6PAOMA,MAAAA,eAAiB,mBAYjBC,MAAAA,iBAA2EC,gBAI/EC,YAAW,CAACC,EAAOC,KACjB,MAAMC,KACJA,EAAO,IAAGC,WACVA,EAAa,CAAE,EAAAC,aACfA,EAAe,CAAE,EAAAC,iBACjBA,EAAmB,CAAE,EAAAC,QACrBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,QACNA,EAAOC,gBACPA,KACGC,GACDjB,EAEJ,MAAMkB,EAAY,CAChBhB,OACAI,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,OACEQ,KAACC,KAAW,IAAKH,KAAeC,EAAWjB,IAAKA,EAAIoB,UACjDL,GACCM,IAACF,YAAkB,CACjBlB,KAAK,IACLqB,KAAK,QACLC,UAAWP,EAAUQ,MACrBC,SAAUT,EAAUQ,OAASR,EAAUS,YACnCrB,EACJsB,QAAUC,WACGb,GAAY,YAAYA,IAC/BV,EAAiBsB,SAAStB,EAAiBsB,QAAQC,EAAI,IAIhEhB,GACCU,IAACO,KAAI,CACHC,WAAW,OACXC,MAAM,UACNC,OAAQ,IACRC,YAAajB,EAAkB,QAAKkB,EACpCC,aAActB,GAAWC,EAAS,aAAUoB,EAC5CE,MAAOC,cACHnB,KACAf,EAAUkB,SAEbT,IAGJC,GACCS,IAACO,KAAI,CACHC,WAAW,OACXC,MAAM,UACNE,aAAcrB,GAASI,EAAkB,QAAKkB,EAC9CC,aAAcrB,EAAS,aAAUoB,EACjCE,MAAOC,cACHnB,KACAd,EAAYiB,SAEfR,WAGGC,GAAW,WAAaA,EAAOI,GAAaJ,IACxC,IAGlB,CACEsB,MAAOE,MACPC,YA9FmB"}
1
+ {"version":3,"file":"TooltipComponent.mjs","sources":["../../../../src/components/TooltipComponent/TooltipComponent.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Text } from 'components/Text'\nimport { SIZES, SIZES_TEXT } from './constants'\nimport type { TooltipComponentProps } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'TooltipComponent'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс `TooltipComponent` можно посмотреть [тут](https://github.com/foxford/ui/blob/master/src/components/TooltipComponent/types.ts).\n */\nconst TooltipComponent: React.ForwardRefExoticComponent<TooltipComponentProps> = withMergedProps<\n TooltipComponentProps,\n HTMLDivElement\n>(\n forwardRef<HTMLDivElement, MergedProps<TooltipComponentProps>>((props, ref) => {\n const {\n size = 's',\n titleProps = {},\n contentProps = {},\n closeButtonProps = {},\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n title,\n content,\n footer,\n closeFn,\n showCloseButton,\n ...restProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n return (\n <Styled.Root {...restProps} {...sizeProps} ref={ref}>\n {showCloseButton ? (\n <Styled.CloseButton\n size='s'\n icon='close'\n secondary={restProps.black}\n contrast={restProps.black || restProps.contrast}\n {...closeButtonProps}\n onClick={(evt) => {\n if (typeof closeFn === 'function') closeFn()\n if (closeButtonProps.onClick) closeButtonProps.onClick(evt)\n }}\n />\n ) : null}\n {title ? (\n <Text\n appearance='body'\n color='inherit'\n weight={700}\n marginRight={showCloseButton ? 16 : undefined}\n marginBottom={content || footer ? '0.3em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...titleProps}\n >\n {title}\n </Text>\n ) : null}\n {content ? (\n <Text\n appearance='body'\n color='inherit'\n marginRight={!title && showCloseButton ? 16 : undefined}\n marginBottom={footer ? '0.2em' : undefined}\n sizes={SIZES_TEXT}\n {...sizeProps}\n {...contentProps}\n >\n {content}\n </Text>\n ) : null}\n {typeof footer === 'function' ? footer(sizeProps) : footer}\n </Styled.Root>\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { TooltipComponent }\n\nexport { COMPONENT_NAME, SIZES }\n"],"names":["COMPONENT_NAME","TooltipComponent","withMergedProps","forwardRef","props","ref","size","titleProps","contentProps","closeButtonProps","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","title","content","footer","closeFn","showCloseButton","restProps","sizeProps","_jsxs","Styled","children","_jsx","icon","secondary","black","contrast","onClick","evt","Text","appearance","color","weight","marginRight","undefined","marginBottom","sizes","SIZES_TEXT","SIZES","displayName"],"mappings":"6PAQMA,MAAAA,eAAiB,mBAYjBC,MAAAA,iBAA2EC,gBAI/EC,YAA+D,CAACC,EAAOC,KACrE,MAAMC,KACJA,EAAO,IAAGC,WACVA,EAAa,CAAE,EAAAC,aACfA,EAAe,CAAE,EAAAC,iBACjBA,EAAmB,CAAE,EAAAC,QACrBA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,MACNA,EAAKC,QACLA,EAAOC,OACPA,EAAMC,QACNA,EAAOC,gBACPA,KACGC,GACDjB,EAEJ,MAAMkB,EAAY,CAChBhB,OACAI,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,OACEQ,KAACC,KAAW,IAAKH,KAAeC,EAAWjB,IAAKA,EAAIoB,UACjDL,EACCM,IAACF,YAAkB,CACjBlB,KAAK,IACLqB,KAAK,QACLC,UAAWP,EAAUQ,MACrBC,SAAUT,EAAUQ,OAASR,EAAUS,YACnCrB,EACJsB,QAAUC,WACGb,GAAY,YAAYA,IAC/BV,EAAiBsB,SAAStB,EAAiBsB,QAAQC,EAAI,IAG7D,KACHhB,EACCU,IAACO,KAAI,CACHC,WAAW,OACXC,MAAM,UACNC,OAAQ,IACRC,YAAajB,EAAkB,QAAKkB,EACpCC,aAActB,GAAWC,EAAS,aAAUoB,EAC5CE,MAAOC,cACHnB,KACAf,EAAUkB,SAEbT,IAED,KACHC,EACCS,IAACO,KAAI,CACHC,WAAW,OACXC,MAAM,UACNE,aAAcrB,GAASI,EAAkB,QAAKkB,EAC9CC,aAAcrB,EAAS,aAAUoB,EACjCE,MAAOC,cACHnB,KACAd,EAAYiB,SAEfR,IAED,YACIC,GAAW,WAAaA,EAAOI,GAAaJ,IACxC,IAGlB,CACEsB,MAAOE,MACPC,YA9FmB"}