@pega/cosmos-react-core 2.0.0-dev.18.0 → 2.0.0-dev.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/lib/components/Actions/Actions.js +1 -1
  2. package/lib/components/Actions/Actions.js.map +1 -1
  3. package/lib/components/AppShell/AppHeader.js +1 -1
  4. package/lib/components/AppShell/AppHeader.js.map +1 -1
  5. package/lib/components/AppShell/AppShell.js +13 -13
  6. package/lib/components/AppShell/AppShell.js.map +1 -1
  7. package/lib/components/AppShell/AppShellList.js +6 -6
  8. package/lib/components/AppShell/AppShellList.js.map +1 -1
  9. package/lib/components/AppShell/Drawer.js +2 -2
  10. package/lib/components/AppShell/Drawer.js.map +1 -1
  11. package/lib/components/AppShell/Operator.js +3 -3
  12. package/lib/components/AppShell/Operator.js.map +1 -1
  13. package/lib/components/AppShell/SkipNavigation.js +2 -2
  14. package/lib/components/AppShell/SkipNavigation.js.map +1 -1
  15. package/lib/components/Avatar/Avatar.js +1 -1
  16. package/lib/components/Avatar/Avatar.js.map +1 -1
  17. package/lib/components/Backdrop/Backdrop.js +1 -1
  18. package/lib/components/Backdrop/Backdrop.js.map +1 -1
  19. package/lib/components/Badges/Alert.js +1 -1
  20. package/lib/components/Badges/Alert.js.map +1 -1
  21. package/lib/components/Badges/Count.js +1 -1
  22. package/lib/components/Badges/Count.js.map +1 -1
  23. package/lib/components/Badges/Selection.js +1 -1
  24. package/lib/components/Badges/Selection.js.map +1 -1
  25. package/lib/components/Badges/Status.js +1 -1
  26. package/lib/components/Badges/Status.js.map +1 -1
  27. package/lib/components/Badges/Tag.js +1 -1
  28. package/lib/components/Badges/Tag.js.map +1 -1
  29. package/lib/components/Banner/Banner.js +3 -3
  30. package/lib/components/Banner/Banner.js.map +1 -1
  31. package/lib/components/Boolean/BooleanDisplay.js +1 -1
  32. package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
  33. package/lib/components/Breadcrumbs/Breadcrumbs.js +5 -5
  34. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  35. package/lib/components/Button/BareButton.js +2 -2
  36. package/lib/components/Button/BareButton.js.map +1 -1
  37. package/lib/components/Button/BareRoleButton.d.ts +12 -0
  38. package/lib/components/Button/BareRoleButton.d.ts.map +1 -0
  39. package/lib/components/Button/BareRoleButton.js +20 -0
  40. package/lib/components/Button/BareRoleButton.js.map +1 -0
  41. package/lib/components/Button/Button.js +2 -2
  42. package/lib/components/Button/Button.js.map +1 -1
  43. package/lib/components/Card/Card.js +1 -1
  44. package/lib/components/Card/Card.js.map +1 -1
  45. package/lib/components/Card/CardContent.js +1 -1
  46. package/lib/components/Card/CardContent.js.map +1 -1
  47. package/lib/components/Card/CardFooter.js +2 -2
  48. package/lib/components/Card/CardFooter.js.map +1 -1
  49. package/lib/components/Card/CardHeader.js +1 -1
  50. package/lib/components/Card/CardHeader.js.map +1 -1
  51. package/lib/components/Card/CardMedia.js +1 -1
  52. package/lib/components/Card/CardMedia.js.map +1 -1
  53. package/lib/components/Card/CollapsibleCard.js +1 -1
  54. package/lib/components/Card/CollapsibleCard.js.map +1 -1
  55. package/lib/components/Card/SelectableCard.js +1 -1
  56. package/lib/components/Card/SelectableCard.js.map +1 -1
  57. package/lib/components/Checkbox/Checkbox.js +1 -1
  58. package/lib/components/Checkbox/Checkbox.js.map +1 -1
  59. package/lib/components/ColorPicker/ColorPicker.js +3 -3
  60. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  61. package/lib/components/ComboBox/ComboBox.js +12 -12
  62. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  63. package/lib/components/ComboBox/ComboBoxInput.js +4 -4
  64. package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
  65. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  66. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +14 -10
  67. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  68. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  69. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +15 -11
  70. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  71. package/lib/components/Configuration/Configuration.js +5 -5
  72. package/lib/components/Configuration/Configuration.js.map +1 -1
  73. package/lib/components/Currency/CurrencyDisplay.js +1 -1
  74. package/lib/components/Currency/CurrencyDisplay.js.map +1 -1
  75. package/lib/components/Currency/CurrencyInput.js +12 -12
  76. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  77. package/lib/components/DateTime/DateTimeDisplay.d.ts.map +1 -1
  78. package/lib/components/DateTime/DateTimeDisplay.js +2 -1
  79. package/lib/components/DateTime/DateTimeDisplay.js.map +1 -1
  80. package/lib/components/DateTime/DurationDisplay.d.ts.map +1 -1
  81. package/lib/components/DateTime/DurationDisplay.js +11 -6
  82. package/lib/components/DateTime/DurationDisplay.js.map +1 -1
  83. package/lib/components/DateTime/Input/DateInput.js +6 -6
  84. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  85. package/lib/components/DateTime/Input/DateRangeInput.js +1 -1
  86. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  87. package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
  88. package/lib/components/DateTime/Input/DateTime.styles.js +13 -2
  89. package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
  90. package/lib/components/DateTime/Input/DateTimeInput.js +9 -9
  91. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  92. package/lib/components/DateTime/Input/DayOfWeekInput.js +2 -2
  93. package/lib/components/DateTime/Input/DayOfWeekInput.js.map +1 -1
  94. package/lib/components/DateTime/Input/Duration/DurationInput.js +2 -2
  95. package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
  96. package/lib/components/DateTime/Input/Duration/NumberUnit.js +2 -2
  97. package/lib/components/DateTime/Input/Duration/NumberUnit.js.map +1 -1
  98. package/lib/components/DateTime/Input/Duration/Time.js +2 -2
  99. package/lib/components/DateTime/Input/Duration/Time.js.map +1 -1
  100. package/lib/components/DateTime/Input/MonthInput.js +6 -6
  101. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  102. package/lib/components/DateTime/Input/PartInput.js +1 -1
  103. package/lib/components/DateTime/Input/PartInput.js.map +1 -1
  104. package/lib/components/DateTime/Input/QuarterInput.js +6 -6
  105. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  106. package/lib/components/DateTime/Input/TimeInput.js +9 -9
  107. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  108. package/lib/components/DateTime/Input/WeekInput.js +6 -6
  109. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  110. package/lib/components/DateTime/Picker/Calendar.js +11 -11
  111. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  112. package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
  113. package/lib/components/DateTime/Picker/DatePicker.js +7 -9
  114. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  115. package/lib/components/DateTime/Picker/DateRangePicker.d.ts.map +1 -1
  116. package/lib/components/DateTime/Picker/DateRangePicker.js +7 -9
  117. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  118. package/lib/components/DateTime/Picker/TimePicker.js +4 -4
  119. package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
  120. package/lib/components/DateTime/Picker/Weeks.js +4 -4
  121. package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
  122. package/lib/components/DateTime/Picker/utils.d.ts +1 -0
  123. package/lib/components/DateTime/Picker/utils.d.ts.map +1 -1
  124. package/lib/components/DateTime/Picker/utils.js +3 -0
  125. package/lib/components/DateTime/Picker/utils.js.map +1 -1
  126. package/lib/components/Drawer/Drawer.js +1 -1
  127. package/lib/components/Drawer/Drawer.js.map +1 -1
  128. package/lib/components/Email/EmailDisplay.js +2 -2
  129. package/lib/components/Email/EmailDisplay.js.map +1 -1
  130. package/lib/components/EmojiPicker/EmojiDisplay.js +1 -1
  131. package/lib/components/EmojiPicker/EmojiDisplay.js.map +1 -1
  132. package/lib/components/EmojiPicker/EmojiPicker.js +1 -1
  133. package/lib/components/EmojiPicker/EmojiPicker.js.map +1 -1
  134. package/lib/components/EmptyState/EmptyState.js +1 -1
  135. package/lib/components/EmptyState/EmptyState.js.map +1 -1
  136. package/lib/components/ErrorState/ErrorState.js +1 -1
  137. package/lib/components/ErrorState/ErrorState.js.map +1 -1
  138. package/lib/components/ExpandCollapse/ExpandCollapse.js +1 -1
  139. package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
  140. package/lib/components/FieldGroup/FieldGroup.js +3 -3
  141. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  142. package/lib/components/FieldGroup/FieldGroupList.js +4 -4
  143. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  144. package/lib/components/FieldValueList/FieldValueList.js +5 -5
  145. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  146. package/lib/components/File/FileDisplay.js +7 -7
  147. package/lib/components/File/FileDisplay.js.map +1 -1
  148. package/lib/components/File/FileInput.js +10 -10
  149. package/lib/components/File/FileInput.js.map +1 -1
  150. package/lib/components/File/FileItem.js +1 -1
  151. package/lib/components/File/FileItem.js.map +1 -1
  152. package/lib/components/File/FileUploadItem.js +4 -4
  153. package/lib/components/File/FileUploadItem.js.map +1 -1
  154. package/lib/components/File/FileVisual.js +4 -4
  155. package/lib/components/File/FileVisual.js.map +1 -1
  156. package/lib/components/Flex/Flex.js +1 -1
  157. package/lib/components/Flex/Flex.js.map +1 -1
  158. package/lib/components/Form/Form.js +1 -1
  159. package/lib/components/Form/Form.js.map +1 -1
  160. package/lib/components/FormControl/FormControl.js +1 -1
  161. package/lib/components/FormControl/FormControl.js.map +1 -1
  162. package/lib/components/FormField/FormField.js +7 -7
  163. package/lib/components/FormField/FormField.js.map +1 -1
  164. package/lib/components/Grid/Grid.js +1 -1
  165. package/lib/components/Grid/Grid.js.map +1 -1
  166. package/lib/components/Icon/Icon.js +1 -1
  167. package/lib/components/Icon/Icon.js.map +1 -1
  168. package/lib/components/Image/Image.js +1 -1
  169. package/lib/components/Image/Image.js.map +1 -1
  170. package/lib/components/Input/Input.js +11 -11
  171. package/lib/components/Input/Input.js.map +1 -1
  172. package/lib/components/Label/Label.js +1 -1
  173. package/lib/components/Label/Label.js.map +1 -1
  174. package/lib/components/Link/Link.js +1 -1
  175. package/lib/components/Link/Link.js.map +1 -1
  176. package/lib/components/List/CommaSeparatedList.js +3 -3
  177. package/lib/components/List/CommaSeparatedList.js.map +1 -1
  178. package/lib/components/List/List.js +1 -1
  179. package/lib/components/List/List.js.map +1 -1
  180. package/lib/components/List/OrderedList.js +1 -1
  181. package/lib/components/List/OrderedList.js.map +1 -1
  182. package/lib/components/List/UnorderedList.js +1 -1
  183. package/lib/components/List/UnorderedList.js.map +1 -1
  184. package/lib/components/Location/CurrentLocationButton.js +1 -1
  185. package/lib/components/Location/CurrentLocationButton.js.map +1 -1
  186. package/lib/components/Location/LocationDisplay.js +7 -7
  187. package/lib/components/Location/LocationDisplay.js.map +1 -1
  188. package/lib/components/Location/LocationInput.js +19 -19
  189. package/lib/components/Location/LocationInput.js.map +1 -1
  190. package/lib/components/Location/LocationView.js +1 -1
  191. package/lib/components/Location/LocationView.js.map +1 -1
  192. package/lib/components/Menu/FlyoutMenuList.js +3 -3
  193. package/lib/components/Menu/FlyoutMenuList.js.map +1 -1
  194. package/lib/components/Menu/Menu.d.ts.map +1 -1
  195. package/lib/components/Menu/Menu.js +4 -3
  196. package/lib/components/Menu/Menu.js.map +1 -1
  197. package/lib/components/Menu/Menu.types.d.ts +3 -1
  198. package/lib/components/Menu/Menu.types.d.ts.map +1 -1
  199. package/lib/components/Menu/Menu.types.js.map +1 -1
  200. package/lib/components/Menu/MenuGroup.js +2 -2
  201. package/lib/components/Menu/MenuGroup.js.map +1 -1
  202. package/lib/components/Menu/MenuItem.js +11 -11
  203. package/lib/components/Menu/MenuItem.js.map +1 -1
  204. package/lib/components/Menu/MenuList.js +5 -5
  205. package/lib/components/Menu/MenuList.js.map +1 -1
  206. package/lib/components/Menu/MenuListHeader.js +2 -2
  207. package/lib/components/Menu/MenuListHeader.js.map +1 -1
  208. package/lib/components/MenuButton/MenuButton.js +3 -3
  209. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  210. package/lib/components/MetaList/MetaList.js +4 -4
  211. package/lib/components/MetaList/MetaList.js.map +1 -1
  212. package/lib/components/Modal/DockedModals.d.ts.map +1 -1
  213. package/lib/components/Modal/DockedModals.js +4 -6
  214. package/lib/components/Modal/DockedModals.js.map +1 -1
  215. package/lib/components/Modal/MinimizedModal.d.ts.map +1 -1
  216. package/lib/components/Modal/MinimizedModal.js +37 -34
  217. package/lib/components/Modal/MinimizedModal.js.map +1 -1
  218. package/lib/components/Modal/Modal.js +8 -8
  219. package/lib/components/Modal/Modal.js.map +1 -1
  220. package/lib/components/Modal/ModalManager.js +6 -6
  221. package/lib/components/Modal/ModalManager.js.map +1 -1
  222. package/lib/components/MultiStep/MultiStep.js +7 -7
  223. package/lib/components/MultiStep/MultiStep.js.map +1 -1
  224. package/lib/components/Number/NumberDisplay.js +1 -1
  225. package/lib/components/Number/NumberDisplay.js.map +1 -1
  226. package/lib/components/Number/NumberInput.js +5 -5
  227. package/lib/components/Number/NumberInput.js.map +1 -1
  228. package/lib/components/PageTemplates/CategorySubPage.js +7 -7
  229. package/lib/components/PageTemplates/CategorySubPage.js.map +1 -1
  230. package/lib/components/PageTemplates/DashboardPage.d.ts +4 -0
  231. package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
  232. package/lib/components/PageTemplates/DashboardPage.js +19 -12
  233. package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
  234. package/lib/components/PageTemplates/PageTemplates.js +20 -20
  235. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  236. package/lib/components/PageTemplates/index.d.ts +1 -0
  237. package/lib/components/PageTemplates/index.d.ts.map +1 -1
  238. package/lib/components/PageTemplates/index.js +1 -0
  239. package/lib/components/PageTemplates/index.js.map +1 -1
  240. package/lib/components/Pagination/Pagination.js +3 -3
  241. package/lib/components/Pagination/Pagination.js.map +1 -1
  242. package/lib/components/Phone/PhoneDisplay.js +2 -2
  243. package/lib/components/Phone/PhoneDisplay.js.map +1 -1
  244. package/lib/components/Phone/PhoneInput.js +3 -3
  245. package/lib/components/Phone/PhoneInput.js.map +1 -1
  246. package/lib/components/Popover/Popover.js +1 -1
  247. package/lib/components/Popover/Popover.js.map +1 -1
  248. package/lib/components/Popover/PopoverManager.js +2 -2
  249. package/lib/components/Popover/PopoverManager.js.map +1 -1
  250. package/lib/components/Progress/Bar.js +1 -1
  251. package/lib/components/Progress/Bar.js.map +1 -1
  252. package/lib/components/Progress/Ellipsis.js +1 -1
  253. package/lib/components/Progress/Ellipsis.js.map +1 -1
  254. package/lib/components/Progress/Progress.js +2 -2
  255. package/lib/components/Progress/Progress.js.map +1 -1
  256. package/lib/components/Progress/Ring.js +1 -1
  257. package/lib/components/Progress/Ring.js.map +1 -1
  258. package/lib/components/RadioButton/RadioButton.js +1 -1
  259. package/lib/components/RadioButton/RadioButton.js.map +1 -1
  260. package/lib/components/RadioCheck/RadioCheck.js +2 -2
  261. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  262. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +10 -10
  263. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  264. package/lib/components/Rating/Rating.js +2 -2
  265. package/lib/components/Rating/Rating.js.map +1 -1
  266. package/lib/components/SearchInput/SearchInput.js +2 -2
  267. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  268. package/lib/components/Select/Option.js +1 -1
  269. package/lib/components/Select/Option.js.map +1 -1
  270. package/lib/components/Select/Select.js +13 -13
  271. package/lib/components/Select/Select.js.map +1 -1
  272. package/lib/components/Sentiment/Sentiment.js +1 -1
  273. package/lib/components/Sentiment/Sentiment.js.map +1 -1
  274. package/lib/components/Skeleton/LineSkeleton.js +1 -1
  275. package/lib/components/Skeleton/LineSkeleton.js.map +1 -1
  276. package/lib/components/Skeleton/ParagraphSkeleton.js +1 -1
  277. package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
  278. package/lib/components/Skeleton/RectangleSkeleton.js +1 -1
  279. package/lib/components/Skeleton/RectangleSkeleton.js.map +1 -1
  280. package/lib/components/Slider/Slider.js +5 -5
  281. package/lib/components/Slider/Slider.js.map +1 -1
  282. package/lib/components/Slider/SliderTicks.js +4 -4
  283. package/lib/components/Slider/SliderTicks.js.map +1 -1
  284. package/lib/components/SummaryItem/SummaryItem.d.ts +1 -1
  285. package/lib/components/SummaryItem/SummaryItem.d.ts.map +1 -1
  286. package/lib/components/SummaryItem/SummaryItem.js +2 -2
  287. package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
  288. package/lib/components/SummaryList/SummaryList.js +3 -3
  289. package/lib/components/SummaryList/SummaryList.js.map +1 -1
  290. package/lib/components/SummaryList/ViewAll.js +1 -1
  291. package/lib/components/SummaryList/ViewAll.js.map +1 -1
  292. package/lib/components/Switch/Switch.js +1 -1
  293. package/lib/components/Switch/Switch.js.map +1 -1
  294. package/lib/components/Table/Table.d.ts.map +1 -1
  295. package/lib/components/Table/Table.js +13 -8
  296. package/lib/components/Table/Table.js.map +1 -1
  297. package/lib/components/Tabs/Tab.js +1 -1
  298. package/lib/components/Tabs/Tab.js.map +1 -1
  299. package/lib/components/Tabs/TabPanel.js +1 -1
  300. package/lib/components/Tabs/TabPanel.js.map +1 -1
  301. package/lib/components/Tabs/Tabs.js +4 -4
  302. package/lib/components/Tabs/Tabs.js.map +1 -1
  303. package/lib/components/Text/Text.js +1 -1
  304. package/lib/components/Text/Text.js.map +1 -1
  305. package/lib/components/TextArea/TextArea.js +23 -23
  306. package/lib/components/TextArea/TextArea.js.map +1 -1
  307. package/lib/components/Toaster/Toaster.js +4 -4
  308. package/lib/components/Toaster/Toaster.js.map +1 -1
  309. package/lib/components/Tooltip/Tooltip.js +1 -1
  310. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  311. package/lib/components/Tree/StandardTree.js +6 -6
  312. package/lib/components/Tree/StandardTree.js.map +1 -1
  313. package/lib/components/Tree/Tree.js +3 -3
  314. package/lib/components/Tree/Tree.js.map +1 -1
  315. package/lib/components/URL/URLDisplay.js +2 -2
  316. package/lib/components/URL/URLDisplay.js.map +1 -1
  317. package/lib/hooks/useFocusWithin.d.ts +1 -1
  318. package/lib/hooks/useFocusWithin.d.ts.map +1 -1
  319. package/lib/hooks/useFocusWithin.js +21 -16
  320. package/lib/hooks/useFocusWithin.js.map +1 -1
  321. package/lib/hooks/useI18n.d.ts +2 -1
  322. package/lib/hooks/useI18n.d.ts.map +1 -1
  323. package/lib/i18n/default.json +2 -1
  324. package/lib/i18n/i18n.d.ts +4 -2
  325. package/lib/i18n/i18n.d.ts.map +1 -1
  326. package/lib/theme/theme.d.ts +30 -30
  327. package/lib/utils/utils.d.ts +13 -0
  328. package/lib/utils/utils.d.ts.map +1 -1
  329. package/lib/utils/utils.js +15 -0
  330. package/lib/utils/utils.js.map +1 -1
  331. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,WAAW,EACX,QAAQ,EAER,SAAS,EACV,MAAM,OAAO,CAAC;AAGf,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,cAA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OAAO,EAAC,WAAW,eACR,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,gBAE1E,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,YACnE,CACR,CAAC,CAAC,CAAC,SAAS;QACf,QAAQ;QACR,QAAQ;KACT,cAEA,IAAI,YACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n FC,\n Ref,\n forwardRef,\n PropsWithoutRef,\n ChangeEvent,\n useCallback,\n useState,\n ChangeEventHandler,\n useEffect\n} from 'react';\n\nimport { ForwardProps } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { hasProp } from '../../utils';\nimport { useAutoResize, useConsolidatedRef, useI18n, useUID } from '../../hooks';\nimport Text from '../Text';\n\nimport StyledTextArea from './TextArea.styles';\n\nexport interface TextAreaProps extends FormControlProps {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default false\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<TextAreaProps>, ref: Ref<HTMLTextAreaElement>) => {\n const uid = useUID();\n const {\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = false,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(undefined, 100);\n const consolidatedRef = useConsolidatedRef(textAreaRef, ref);\n const [charCount, setCharCount] = useState(0);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n useEffect(() => {\n if (hasProp(props, 'value')) {\n setCharCount(props.value ? props.value.length : 0);\n } else if (hasProp(props, 'defaultValue')) {\n setCharCount(props.defaultValue ? props.defaultValue.length : 0);\n }\n }, [props]);\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n resizeTextArea();\n }\n },\n [onChangeProp, resizeTextArea, hardStop, maxLength]\n );\n\n const Comp = (\n <StyledFormControl\n {...{\n ref: autoResize ? consolidatedRef : ref,\n id,\n required,\n disabled,\n status,\n resizable,\n maxLength: hardStop ? maxLength : undefined,\n ...controlProp,\n ...restProps,\n onChange,\n as: StyledTextArea\n }}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n {...{\n label,\n labelHidden,\n id,\n info,\n status,\n charLimitDisplay:\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}\n </Text>\n ) : undefined,\n required,\n disabled\n }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default TextArea;\n"]}
1
+ {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;YACR,QAAQ;YACR,MAAM;YACN,SAAS;YACT,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YAC3C,GAAG,WAAW;YACd,GAAG,SAAS;YACZ,QAAQ;YACR,EAAE,EAAE,cAAc;SACnB,WACD,CACH,CAAC;IAEF,OAAO,KAAK,IAAI,gBAAgB,CAAC,CAAC,CAAC,CACjC,KAAC,SAAS,OACJ;YACF,KAAK;YACL,WAAW;YACX,EAAE;YACF,IAAI;YACJ,MAAM;YACN,gBAAgB,EACd,gBAAgB,IAAI,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAClD,KAAC,IAAI,IACH,OAAO,EAAC,WAAW,eACR,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,YAE1E,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,WACnE,CACR,CAAC,CAAC,CAAC,SAAS;YACf,QAAQ;YACR,QAAQ;SACT,YAEA,IAAI,WACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n FC,\n Ref,\n forwardRef,\n PropsWithoutRef,\n ChangeEvent,\n useCallback,\n useState,\n ChangeEventHandler,\n useEffect\n} from 'react';\n\nimport { ForwardProps } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { hasProp } from '../../utils';\nimport { useAutoResize, useConsolidatedRef, useI18n, useUID } from '../../hooks';\nimport Text from '../Text';\n\nimport StyledTextArea from './TextArea.styles';\n\nexport interface TextAreaProps extends FormControlProps {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default false\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<TextAreaProps>, ref: Ref<HTMLTextAreaElement>) => {\n const uid = useUID();\n const {\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = false,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(undefined, 100);\n const consolidatedRef = useConsolidatedRef(textAreaRef, ref);\n const [charCount, setCharCount] = useState(0);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n useEffect(() => {\n if (hasProp(props, 'value')) {\n setCharCount(props.value ? props.value.length : 0);\n } else if (hasProp(props, 'defaultValue')) {\n setCharCount(props.defaultValue ? props.defaultValue.length : 0);\n }\n }, [props]);\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n resizeTextArea();\n }\n },\n [onChangeProp, resizeTextArea, hardStop, maxLength]\n );\n\n const Comp = (\n <StyledFormControl\n {...{\n ref: autoResize ? consolidatedRef : ref,\n id,\n required,\n disabled,\n status,\n resizable,\n maxLength: hardStop ? maxLength : undefined,\n ...controlProp,\n ...restProps,\n onChange,\n as: StyledTextArea\n }}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n {...{\n label,\n labelHidden,\n id,\n info,\n status,\n charLimitDisplay:\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}\n </Text>\n ) : undefined,\n required,\n disabled\n }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default TextArea;\n"]}
@@ -110,11 +110,11 @@ const Toast = forwardRef(({ dispatch, topLevelDismiss, dismissAfter, ...message
110
110
  clearTimeout(timeoutRef.current);
111
111
  };
112
112
  }, []);
113
- return (_jsxs(Flex, Object.assign({ container: { alignItems: 'center', gap: 0.25 }, as: StyledToast, ref: ref, style: {
113
+ return (_jsxs(Flex, { container: { alignItems: 'center', gap: 0.25 }, as: StyledToast, ref: ref, style: {
114
114
  '--translateY': `${-translateY}px`,
115
115
  '--opacity': dismissed ? '0' : '1',
116
116
  '--scale': dismissed ? '0' : '1'
117
- }, onTransitionEnd: onTransitionEnd }, { children: [_jsx(Flex, Object.assign({ item: { grow: 1 }, as: StyledToastContent }, { children: content }), void 0), _jsx(Button, Object.assign({ as: StyledToastButton, variant: 'simple', onClick: dismiss, icon: true, "aria-label": t('dismiss') }, { children: _jsx(Icon, { name: 'times' }, void 0) }), void 0)] }), void 0));
117
+ }, onTransitionEnd: onTransitionEnd, children: [_jsx(Flex, { item: { grow: 1 }, as: StyledToastContent, children: content }, void 0), _jsx(Button, { as: StyledToastButton, variant: 'simple', onClick: dismiss, icon: true, "aria-label": t('dismiss'), children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)] }, void 0));
118
118
  });
119
119
  const Toaster = ({ children, dismissAfter = Infinity, onDismiss, context = ToasterContext }) => {
120
120
  const { portalTarget } = useConfiguration();
@@ -144,9 +144,9 @@ const Toaster = ({ children, dismissAfter = Infinity, onDismiss, context = Toast
144
144
  // Don't create additional ToasterContext.Providers.
145
145
  const priorCtx = useContext(context);
146
146
  if (priorCtx[initializedKey]) {
147
- return _jsx(ToasterContext.Provider, Object.assign({ value: priorCtx }, { children: children }), void 0);
147
+ return _jsx(ToasterContext.Provider, { value: priorCtx, children: children }, void 0);
148
148
  }
149
- return (_jsxs(_Fragment, { children: [_jsx(ToasterContext.Provider, Object.assign({ value: providerValue }, { children: children }), void 0), !!messages.length &&
149
+ return (_jsxs(_Fragment, { children: [_jsx(ToasterContext.Provider, { value: providerValue, children: children }, void 0), !!messages.length &&
150
150
  portalTarget &&
151
151
  createPortal(_jsx(StyledToaster, { children: messages.map((message, i) => {
152
152
  return (_createElement(Toast, { ...message, translateY: yOffsets[i] ?? 0, topLevelDismiss: onDismiss, dismissAfter: message.dismissAfter ?? dismissAfter, key: message.id, dispatch: dispatch, ref: el => {
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,OAAO,EACP,eAAe,EAMf,MAAM,EACN,QAAQ,EACR,UAAU,EAGV,SAAS,EAEV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OA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,CAAC;iCAC1C;4BACH,CAAC,GACD,CACH,CAAC;oBACJ,CAAC,CAAC,WACY,EAChB,YAAY,CACb,YACF,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n createContext,\n useContext,\n useReducer,\n useMemo,\n useLayoutEffect,\n FunctionComponent,\n ReactNode,\n CSSProperties,\n TransitionEvent,\n Context,\n useRef,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useEffect,\n Dispatch\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport { createUID } from '../../utils';\nimport { useConfiguration, useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\n\nregisterIcon(timesIcon);\n\nexport const initializedKey = Symbol.for('@pega/cosmos-react-core.toaster.initialized');\n\nexport interface ToasterContextValue {\n push: (message: ToastMessage) => void;\n [initializedKey]: boolean;\n}\n\nexport const ToasterContext = createContext<ToasterContextValue>({\n push: () => {},\n [initializedKey]: false\n});\n\nexport interface ToastMessage {\n /** String to identify the specific message. Used as onDismiss callback arg. */\n id?: string;\n /** A short message to provide feedback based upon a user action. */\n content: string;\n /**\n * Time in milliseconds to automatically dismiss toast.\n * Can be set globally on Toaster and overridden individually at a message level.\n * @default Infinity\n */\n dismissAfter?: number;\n /** Called when user or timer dismisses toasts. Callback is passed the message id and boolean indicating if the dismissal was timed. */\n onDismiss?: ({ id, timeout }: { id: ToastState['id']; timeout: boolean }) => void;\n}\n\nexport interface ToasterProps {\n /** The element(s) responsible for handling the Toaster state. */\n children: ReactNode;\n /**\n * Time in milliseconds to automatically dismiss Toast.\n * Can be set globally on Toaster and overridden individually at a message level.\n * @default Infinity\n */\n dismissAfter?: ToastMessage['dismissAfter'];\n /** Called when user or timer dismisses Toasts. Callback is passed the message id and boolean indicating if the dismissal was timed. */\n onDismiss?: ToastMessage['onDismiss'];\n /** Context to read previous values from. */\n context?: Context<ToasterContextValue>;\n}\n\ninterface ToastState extends ToastMessage {\n id: NonNullable<ToastMessage['id']>;\n}\n\ntype ToastReducerAction =\n | { type: 'push'; payload: ToastState }\n | { type: 'unmount'; payload: ToastState['id'] };\n\ninterface ToastProps extends ToastState {\n topLevelDismiss: ToasterProps['onDismiss'];\n translateY: number;\n dispatch: Dispatch<ToastReducerAction>;\n ref: Ref<HTMLDivElement>;\n}\n\nconst StyledToastButton = styled.button(\n ({ theme }) => css`\n border: none;\n color: inherit;\n padding: 0;\n font-size: 1rem;\n\n &:enabled:hover {\n background: #ffffff19;\n }\n\n &:enabled:focus {\n box-shadow: ${theme.base.shadow['focus-inverted']};\n }\n `\n);\n\nStyledToastButton.defaultProps = defaultThemeProp;\n\nconst StyledToastContent = styled.div(({ theme }) => {\n return css`\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: ${theme.base['font-size']};\n margin-inline-start: calc(${theme.base['border-radius']} / 2);\n `;\n});\n\nStyledToastContent.defaultProps = defaultThemeProp;\n\nconst StyledToast = styled.div(({ theme }) => {\n return css`\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 100%;\n padding: calc(${theme.base.spacing} / 2);\n background: ${theme.base.colors.slate['extra-dark']};\n color: ${theme.base.colors.white};\n border-radius: calc(${theme.base['border-radius']} / 2);\n opacity: var(--opacity);\n transform: translateY(var(--translateY)) scale(var(--scale));\n transition-property: transform, opacity;\n transition-duration: ${theme.base.animation.speed};\n transition-timing-function: ${theme.base.animation.timing.ease};\n `;\n});\n\nStyledToast.defaultProps = defaultThemeProp;\n\nconst StyledToaster = styled.div`\n position: fixed;\n z-index: ${({ theme }) => theme.base['z-index'].toast};\n width: min(40ch, calc(100% - 1rem));\n inset-inline-start: 50%;\n transform: translateX(-50%);\n top: 100%;\n`;\n\nStyledToaster.defaultProps = defaultThemeProp;\n\nfunction reducer(current: ToastState[], action: ToastReducerAction) {\n switch (action.type) {\n case 'push':\n return [\n ...current,\n {\n ...action.payload\n }\n ];\n\n case 'unmount':\n return current.filter(m => m.id !== action.payload);\n\n default:\n return current;\n }\n}\n\nconst Toast: FunctionComponent<ToastProps> = forwardRef(\n (\n { dispatch, topLevelDismiss, dismissAfter, ...message }: PropsWithoutRef<ToastProps>,\n ref: ToastProps['ref']\n ) => {\n const { content, translateY } = message;\n const [dismissed, setDismissed] = useState(false);\n const timeoutRef = useRef(NaN);\n const t = useI18n();\n\n const onTransitionEnd = (e: TransitionEvent<HTMLDivElement>) => {\n if (dismissed && e.propertyName === 'opacity' && e.target === e.currentTarget) {\n dispatch({ type: 'unmount', payload: message.id });\n }\n };\n\n const dismiss = () => {\n clearTimeout(timeoutRef.current);\n if (dismissed) return;\n setDismissed(true);\n topLevelDismiss?.({ id: message.id, timeout: false });\n };\n\n useEffect(() => {\n if (Number.isFinite(dismissAfter)) {\n timeoutRef.current = setTimeout(dismiss, dismissAfter);\n }\n\n return () => {\n clearTimeout(timeoutRef.current);\n };\n }, []);\n\n return (\n <Flex\n container={{ alignItems: 'center', gap: 0.25 }}\n as={StyledToast}\n ref={ref}\n style={\n {\n '--translateY': `${-translateY}px`,\n '--opacity': dismissed ? '0' : '1',\n '--scale': dismissed ? '0' : '1'\n } as CSSProperties\n }\n onTransitionEnd={onTransitionEnd}\n >\n <Flex item={{ grow: 1 }} as={StyledToastContent}>\n {content}\n </Flex>\n <Button\n as={StyledToastButton}\n variant='simple'\n onClick={dismiss}\n icon\n aria-label={t('dismiss')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n );\n }\n);\n\nconst Toaster: FunctionComponent<ToasterProps> = ({\n children,\n dismissAfter = Infinity,\n onDismiss,\n context = ToasterContext\n}: ToasterProps) => {\n const { portalTarget } = useConfiguration();\n const [messages, dispatch] = useReducer(reducer, []);\n const [yOffsets, setYOffsets] = useState<number[]>([]);\n const heightHashRef = useRef<{\n [id: string]: number;\n }>({});\n\n // This effect will cause a re-render with a translateY value set for each toast.\n useLayoutEffect(() => {\n const heights = [...messages].reverse().map(({ id }) => heightHashRef.current[id]);\n\n setYOffsets(\n heights\n .map((_, i) => heights.slice(0, i + 1).reduce((sum, cur) => sum + cur + 4, 0))\n .reverse()\n );\n }, [messages.length]);\n\n const providerValue = useMemo(\n () => ({\n push(incoming: ToastMessage) {\n const message: ToastState = {\n ...incoming,\n id: incoming.id ?? createUID()\n };\n\n dispatch({\n type: 'push',\n payload: message\n });\n },\n [initializedKey]: true\n }),\n [onDismiss, dismissAfter]\n );\n\n // Don't create additional ToasterContext.Providers.\n const priorCtx = useContext(context);\n if (priorCtx[initializedKey]) {\n return <ToasterContext.Provider value={priorCtx}>{children}</ToasterContext.Provider>;\n }\n\n return (\n <>\n <ToasterContext.Provider value={providerValue}>{children}</ToasterContext.Provider>\n {!!messages.length &&\n portalTarget &&\n createPortal(\n <StyledToaster>\n {messages.map((message, i) => {\n return (\n <Toast\n {...message}\n translateY={yOffsets[i] ?? 0}\n topLevelDismiss={onDismiss}\n dismissAfter={message.dismissAfter ?? dismissAfter}\n key={message.id}\n dispatch={dispatch}\n ref={el => {\n if (el) {\n heightHashRef.current[message.id] = el.offsetHeight;\n } else {\n delete heightHashRef.current[message.id];\n }\n }}\n />\n );\n })}\n </StyledToaster>,\n portalTarget\n )}\n </>\n );\n};\n\nexport default Toaster;\n"]}
1
+ {"version":3,"file":"Toaster.js","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,OAAO,EACP,eAAe,EAMf,MAAM,EACN,QAAQ,EACR,UAAU,EAGV,SAAS,EAEV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD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E,EACf,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,EAAE,CAAC,EAAE;gCACR,IAAI,EAAE,EAAE;oCACN,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;iCACrD;qCAAM;oCACL,OAAO,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;iCAC1C;4BACH,CAAC,GACD,CACH,CAAC;oBACJ,CAAC,CAAC,WACY,EAChB,YAAY,CACb,YACF,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n createContext,\n useContext,\n useReducer,\n useMemo,\n useLayoutEffect,\n FunctionComponent,\n ReactNode,\n CSSProperties,\n TransitionEvent,\n Context,\n useRef,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useEffect,\n Dispatch\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport { createUID } from '../../utils';\nimport { useConfiguration, useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\n\nregisterIcon(timesIcon);\n\nexport const initializedKey = Symbol.for('@pega/cosmos-react-core.toaster.initialized');\n\nexport interface ToasterContextValue {\n push: (message: ToastMessage) => void;\n [initializedKey]: boolean;\n}\n\nexport const ToasterContext = createContext<ToasterContextValue>({\n push: () => {},\n [initializedKey]: false\n});\n\nexport interface ToastMessage {\n /** String to identify the specific message. Used as onDismiss callback arg. */\n id?: string;\n /** A short message to provide feedback based upon a user action. */\n content: string;\n /**\n * Time in milliseconds to automatically dismiss toast.\n * Can be set globally on Toaster and overridden individually at a message level.\n * @default Infinity\n */\n dismissAfter?: number;\n /** Called when user or timer dismisses toasts. Callback is passed the message id and boolean indicating if the dismissal was timed. */\n onDismiss?: ({ id, timeout }: { id: ToastState['id']; timeout: boolean }) => void;\n}\n\nexport interface ToasterProps {\n /** The element(s) responsible for handling the Toaster state. */\n children: ReactNode;\n /**\n * Time in milliseconds to automatically dismiss Toast.\n * Can be set globally on Toaster and overridden individually at a message level.\n * @default Infinity\n */\n dismissAfter?: ToastMessage['dismissAfter'];\n /** Called when user or timer dismisses Toasts. Callback is passed the message id and boolean indicating if the dismissal was timed. */\n onDismiss?: ToastMessage['onDismiss'];\n /** Context to read previous values from. */\n context?: Context<ToasterContextValue>;\n}\n\ninterface ToastState extends ToastMessage {\n id: NonNullable<ToastMessage['id']>;\n}\n\ntype ToastReducerAction =\n | { type: 'push'; payload: ToastState }\n | { type: 'unmount'; payload: ToastState['id'] };\n\ninterface ToastProps extends ToastState {\n topLevelDismiss: ToasterProps['onDismiss'];\n translateY: number;\n dispatch: Dispatch<ToastReducerAction>;\n ref: Ref<HTMLDivElement>;\n}\n\nconst StyledToastButton = styled.button(\n ({ theme }) => css`\n border: none;\n color: inherit;\n padding: 0;\n font-size: 1rem;\n\n &:enabled:hover {\n background: #ffffff19;\n }\n\n &:enabled:focus {\n box-shadow: ${theme.base.shadow['focus-inverted']};\n }\n `\n);\n\nStyledToastButton.defaultProps = defaultThemeProp;\n\nconst StyledToastContent = styled.div(({ theme }) => {\n return css`\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: ${theme.base['font-size']};\n margin-inline-start: calc(${theme.base['border-radius']} / 2);\n `;\n});\n\nStyledToastContent.defaultProps = defaultThemeProp;\n\nconst StyledToast = styled.div(({ theme }) => {\n return css`\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 100%;\n padding: calc(${theme.base.spacing} / 2);\n background: ${theme.base.colors.slate['extra-dark']};\n color: ${theme.base.colors.white};\n border-radius: calc(${theme.base['border-radius']} / 2);\n opacity: var(--opacity);\n transform: translateY(var(--translateY)) scale(var(--scale));\n transition-property: transform, opacity;\n transition-duration: ${theme.base.animation.speed};\n transition-timing-function: ${theme.base.animation.timing.ease};\n `;\n});\n\nStyledToast.defaultProps = defaultThemeProp;\n\nconst StyledToaster = styled.div`\n position: fixed;\n z-index: ${({ theme }) => theme.base['z-index'].toast};\n width: min(40ch, calc(100% - 1rem));\n inset-inline-start: 50%;\n transform: translateX(-50%);\n top: 100%;\n`;\n\nStyledToaster.defaultProps = defaultThemeProp;\n\nfunction reducer(current: ToastState[], action: ToastReducerAction) {\n switch (action.type) {\n case 'push':\n return [\n ...current,\n {\n ...action.payload\n }\n ];\n\n case 'unmount':\n return current.filter(m => m.id !== action.payload);\n\n default:\n return current;\n }\n}\n\nconst Toast: FunctionComponent<ToastProps> = forwardRef(\n (\n { dispatch, topLevelDismiss, dismissAfter, ...message }: PropsWithoutRef<ToastProps>,\n ref: ToastProps['ref']\n ) => {\n const { content, translateY } = message;\n const [dismissed, setDismissed] = useState(false);\n const timeoutRef = useRef(NaN);\n const t = useI18n();\n\n const onTransitionEnd = (e: TransitionEvent<HTMLDivElement>) => {\n if (dismissed && e.propertyName === 'opacity' && e.target === e.currentTarget) {\n dispatch({ type: 'unmount', payload: message.id });\n }\n };\n\n const dismiss = () => {\n clearTimeout(timeoutRef.current);\n if (dismissed) return;\n setDismissed(true);\n topLevelDismiss?.({ id: message.id, timeout: false });\n };\n\n useEffect(() => {\n if (Number.isFinite(dismissAfter)) {\n timeoutRef.current = setTimeout(dismiss, dismissAfter);\n }\n\n return () => {\n clearTimeout(timeoutRef.current);\n };\n }, []);\n\n return (\n <Flex\n container={{ alignItems: 'center', gap: 0.25 }}\n as={StyledToast}\n ref={ref}\n style={\n {\n '--translateY': `${-translateY}px`,\n '--opacity': dismissed ? '0' : '1',\n '--scale': dismissed ? '0' : '1'\n } as CSSProperties\n }\n onTransitionEnd={onTransitionEnd}\n >\n <Flex item={{ grow: 1 }} as={StyledToastContent}>\n {content}\n </Flex>\n <Button\n as={StyledToastButton}\n variant='simple'\n onClick={dismiss}\n icon\n aria-label={t('dismiss')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n );\n }\n);\n\nconst Toaster: FunctionComponent<ToasterProps> = ({\n children,\n dismissAfter = Infinity,\n onDismiss,\n context = ToasterContext\n}: ToasterProps) => {\n const { portalTarget } = useConfiguration();\n const [messages, dispatch] = useReducer(reducer, []);\n const [yOffsets, setYOffsets] = useState<number[]>([]);\n const heightHashRef = useRef<{\n [id: string]: number;\n }>({});\n\n // This effect will cause a re-render with a translateY value set for each toast.\n useLayoutEffect(() => {\n const heights = [...messages].reverse().map(({ id }) => heightHashRef.current[id]);\n\n setYOffsets(\n heights\n .map((_, i) => heights.slice(0, i + 1).reduce((sum, cur) => sum + cur + 4, 0))\n .reverse()\n );\n }, [messages.length]);\n\n const providerValue = useMemo(\n () => ({\n push(incoming: ToastMessage) {\n const message: ToastState = {\n ...incoming,\n id: incoming.id ?? createUID()\n };\n\n dispatch({\n type: 'push',\n payload: message\n });\n },\n [initializedKey]: true\n }),\n [onDismiss, dismissAfter]\n );\n\n // Don't create additional ToasterContext.Providers.\n const priorCtx = useContext(context);\n if (priorCtx[initializedKey]) {\n return <ToasterContext.Provider value={priorCtx}>{children}</ToasterContext.Provider>;\n }\n\n return (\n <>\n <ToasterContext.Provider value={providerValue}>{children}</ToasterContext.Provider>\n {!!messages.length &&\n portalTarget &&\n createPortal(\n <StyledToaster>\n {messages.map((message, i) => {\n return (\n <Toast\n {...message}\n translateY={yOffsets[i] ?? 0}\n topLevelDismiss={onDismiss}\n dismissAfter={message.dismissAfter ?? dismissAfter}\n key={message.id}\n dispatch={dispatch}\n ref={el => {\n if (el) {\n heightHashRef.current[message.id] = el.offsetHeight;\n } else {\n delete heightHashRef.current[message.id];\n }\n }}\n />\n );\n })}\n </StyledToaster>,\n portalTarget\n )}\n </>\n );\n};\n\nexport default Toaster;\n"]}
@@ -81,7 +81,7 @@ const Tooltip = forwardRef(({ children, target, showDelay = 'short', hideDelay =
81
81
  target.setAttribute('aria-describedby', id);
82
82
  }
83
83
  }, [describeTarget, target]);
84
- return (_jsx(Popover, Object.assign({ id: id }, restProps, { show: show, showDelay: showDelay, hideDelay: hideDelay, groupId: 'tooltip', strategy: 'fixed', portal: portal, as: StyledTooltip, role: 'tooltip', target: target, arrow: true, placement: 'bottom', onMouseDown: onMouseDown, onMouseEnter: () => setTooltipHover(true), onMouseLeave: () => setTooltipHover(false), hideOnTargetHidden: true, ref: tooltipRef }, { children: children }), void 0));
84
+ return (_jsx(Popover, { id: id, ...restProps, show: show, showDelay: showDelay, hideDelay: hideDelay, groupId: 'tooltip', strategy: 'fixed', portal: portal, as: StyledTooltip, role: 'tooltip', target: target, arrow: true, placement: 'bottom', onMouseDown: onMouseDown, onMouseEnter: () => setTooltipHover(true), onMouseLeave: () => setTooltipHover(false), hideOnTargetHidden: true, ref: tooltipRef, children: children }, void 0));
85
85
  });
86
86
  export default Tooltip;
87
87
  //# sourceMappingURL=Tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAgC,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA8BjD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC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C,SAAS,EACd,MAAM,EAAE,MAAM,EACd,KAAK,QACL,SAAS,EAAC,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EACzC,YAAY,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EAC1C,kBAAkB,QAClB,GAAG,EAAE,UAAU,gBAEd,QAAQ,YACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n MutableRefObject,\n PropsWithoutRef,\n Ref,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Popover, { Delay, PopoverProps } from '../Popover';\nimport { useConsolidatedRef, useUID } from '../../hooks';\nimport { calculateFontSize } from '../../styles';\n\nexport interface TooltipProps extends BaseProps {\n /** Text content for the tooltip. */\n children: string | string[];\n /** Element to serve as the tooltip's target. */\n target: Element | null;\n /**\n * Delay showing the tooltip on mouseenter.\n * @default \"short\"\n */\n showDelay?: Delay;\n /**\n * Delay hiding the tooltip on mouseleave.\n * @default \"long\"\n */\n hideDelay?: Delay;\n /**\n * If true, the Tooltip will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: PopoverProps['portal'];\n /**\n * If true, the Tooltip will automatically apply an aria-describedby attribute to its target.\n * @default true\n */\n describeTarget?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTooltip = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n background-color: ${theme.components.tooltip['background-color']};\n color: ${theme.components.tooltip['foreground-color']};\n font-size: ${fontSize.xxs};\n max-width: 40ch;\n padding: ${theme.base.spacing};\n white-space: pre-line;\n word-break: break-word;\n `;\n});\n\nStyledTooltip.defaultProps = defaultThemeProp;\n\nconst Tooltip: FunctionComponent<TooltipProps & ForwardProps> = forwardRef(\n (\n {\n children,\n target,\n showDelay = 'short',\n hideDelay = 'long',\n portal = false,\n describeTarget = true,\n ...restProps\n }: PropsWithoutRef<TooltipProps>,\n ref: Ref<HTMLDivElement>\n ) => {\n const id = useUID();\n const [show, setShow] = useState(false);\n const [tooltipHover, setTooltipHover] = useState(false);\n const tooltipRef = useConsolidatedRef(ref);\n const lastClickedRef: MutableRefObject<EventTarget | null> = useRef(null);\n\n const showTooltip = useCallback(() => {\n setShow(true);\n }, []);\n\n const onMouseDown = useCallback(\n ({ target: eTarget }: MouseEvent) => {\n lastClickedRef.current = eTarget;\n if (eTarget === tooltipRef.current || eTarget === target) return;\n setShow(false);\n },\n [target]\n );\n\n const onFocusOut = useCallback(() => {\n if (lastClickedRef.current !== tooltipRef.current) {\n setShow(false);\n }\n lastClickedRef.current = null;\n }, []);\n\n const onMouseEnter = useCallback(() => {\n setShow(true);\n }, [target]);\n\n const onMouseLeave = useCallback(() => {\n if (document.activeElement !== target && !tooltipHover) {\n setShow(false);\n }\n }, [target, tooltipHover]);\n\n const onKeyDown = useCallback(\n ({ key }: KeyboardEvent) => {\n if (key === 'Escape' && document.activeElement === target) {\n setShow(false);\n }\n },\n [target]\n );\n\n useEffect(() => {\n if (tooltipHover) showTooltip();\n else onMouseLeave();\n }, [tooltipHover, onMouseLeave]);\n\n useEffect(() => {\n if (!target) return;\n\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onMouseDown);\n\n target.addEventListener('focusin', showTooltip);\n target.addEventListener('focusout', onFocusOut);\n\n target.addEventListener('mouseenter', onMouseEnter);\n target.addEventListener('mouseleave', onMouseLeave);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onMouseDown);\n\n target.removeEventListener('focusin', showTooltip);\n target.removeEventListener('focusout', onFocusOut);\n\n target.removeEventListener('mouseenter', onMouseEnter);\n target.removeEventListener('mouseleave', onMouseLeave);\n };\n }, [target, showTooltip, onMouseDown, onFocusOut, onMouseLeave, onKeyDown]);\n\n useEffect(() => {\n if (target && !target.getAttribute('aria-describedby') && describeTarget) {\n target.setAttribute('aria-describedby', id);\n }\n }, [describeTarget, target]);\n\n return (\n <Popover\n id={id}\n {...restProps}\n show={show}\n showDelay={showDelay}\n hideDelay={hideDelay}\n groupId='tooltip'\n strategy='fixed'\n portal={portal}\n as={StyledTooltip}\n role='tooltip'\n target={target}\n arrow\n placement='bottom'\n onMouseDown={onMouseDown}\n onMouseEnter={() => setTooltipHover(true)}\n onMouseLeave={() => setTooltipHover(false)}\n hideOnTargetHidden\n ref={tooltipRef}\n >\n {children}\n </Popover>\n );\n }\n);\n\nexport default Tooltip;\n"]}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAgC,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA8BjD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBA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AAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EACzC,YAAY,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EAC1C,kBAAkB,QAClB,GAAG,EAAE,UAAU,YAEd,QAAQ,WACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n MutableRefObject,\n PropsWithoutRef,\n Ref,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Popover, { Delay, PopoverProps } from '../Popover';\nimport { useConsolidatedRef, useUID } from '../../hooks';\nimport { calculateFontSize } from '../../styles';\n\nexport interface TooltipProps extends BaseProps {\n /** Text content for the tooltip. */\n children: string | string[];\n /** Element to serve as the tooltip's target. */\n target: Element | null;\n /**\n * Delay showing the tooltip on mouseenter.\n * @default \"short\"\n */\n showDelay?: Delay;\n /**\n * Delay hiding the tooltip on mouseleave.\n * @default \"long\"\n */\n hideDelay?: Delay;\n /**\n * If true, the Tooltip will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: PopoverProps['portal'];\n /**\n * If true, the Tooltip will automatically apply an aria-describedby attribute to its target.\n * @default true\n */\n describeTarget?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTooltip = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n background-color: ${theme.components.tooltip['background-color']};\n color: ${theme.components.tooltip['foreground-color']};\n font-size: ${fontSize.xxs};\n max-width: 40ch;\n padding: ${theme.base.spacing};\n white-space: pre-line;\n word-break: break-word;\n `;\n});\n\nStyledTooltip.defaultProps = defaultThemeProp;\n\nconst Tooltip: FunctionComponent<TooltipProps & ForwardProps> = forwardRef(\n (\n {\n children,\n target,\n showDelay = 'short',\n hideDelay = 'long',\n portal = false,\n describeTarget = true,\n ...restProps\n }: PropsWithoutRef<TooltipProps>,\n ref: Ref<HTMLDivElement>\n ) => {\n const id = useUID();\n const [show, setShow] = useState(false);\n const [tooltipHover, setTooltipHover] = useState(false);\n const tooltipRef = useConsolidatedRef(ref);\n const lastClickedRef: MutableRefObject<EventTarget | null> = useRef(null);\n\n const showTooltip = useCallback(() => {\n setShow(true);\n }, []);\n\n const onMouseDown = useCallback(\n ({ target: eTarget }: MouseEvent) => {\n lastClickedRef.current = eTarget;\n if (eTarget === tooltipRef.current || eTarget === target) return;\n setShow(false);\n },\n [target]\n );\n\n const onFocusOut = useCallback(() => {\n if (lastClickedRef.current !== tooltipRef.current) {\n setShow(false);\n }\n lastClickedRef.current = null;\n }, []);\n\n const onMouseEnter = useCallback(() => {\n setShow(true);\n }, [target]);\n\n const onMouseLeave = useCallback(() => {\n if (document.activeElement !== target && !tooltipHover) {\n setShow(false);\n }\n }, [target, tooltipHover]);\n\n const onKeyDown = useCallback(\n ({ key }: KeyboardEvent) => {\n if (key === 'Escape' && document.activeElement === target) {\n setShow(false);\n }\n },\n [target]\n );\n\n useEffect(() => {\n if (tooltipHover) showTooltip();\n else onMouseLeave();\n }, [tooltipHover, onMouseLeave]);\n\n useEffect(() => {\n if (!target) return;\n\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onMouseDown);\n\n target.addEventListener('focusin', showTooltip);\n target.addEventListener('focusout', onFocusOut);\n\n target.addEventListener('mouseenter', onMouseEnter);\n target.addEventListener('mouseleave', onMouseLeave);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onMouseDown);\n\n target.removeEventListener('focusin', showTooltip);\n target.removeEventListener('focusout', onFocusOut);\n\n target.removeEventListener('mouseenter', onMouseEnter);\n target.removeEventListener('mouseleave', onMouseLeave);\n };\n }, [target, showTooltip, onMouseDown, onFocusOut, onMouseLeave, onKeyDown]);\n\n useEffect(() => {\n if (target && !target.getAttribute('aria-describedby') && describeTarget) {\n target.setAttribute('aria-describedby', id);\n }\n }, [describeTarget, target]);\n\n return (\n <Popover\n id={id}\n {...restProps}\n show={show}\n showDelay={showDelay}\n hideDelay={hideDelay}\n groupId='tooltip'\n strategy='fixed'\n portal={portal}\n as={StyledTooltip}\n role='tooltip'\n target={target}\n arrow\n placement='bottom'\n onMouseDown={onMouseDown}\n onMouseEnter={() => setTooltipHover(true)}\n onMouseLeave={() => setTooltipHover(false)}\n hideOnTargetHidden\n ref={tooltipRef}\n >\n {children}\n </Popover>\n );\n }\n);\n\nexport default Tooltip;\n"]}
@@ -30,23 +30,23 @@ const NodeRenderer = ({ id, label, icon, depth, hasParentSibling, nodes, expande
30
30
  const labelContent = useMemo(() => {
31
31
  const internal = (
32
32
  // Wrapping in a div for handling of flex space-between when there are node actions.
33
- _jsxs(Flex, Object.assign({ container: { alignItems: 'center', gap: 0.5 }, as: StyledLabelContent }, { children: [icon && _jsx(StyledNodeIcon, { name: icon }, void 0), _jsx(StyledNodeText, { children: label }, void 0)] }), void 0));
34
- return !nodes && (onClick ?? onNodeClick) ? (_jsxs(Flex, Object.assign({ container: { alignItems: 'center', justify: 'between', gap: 2 }, as: StyledNodeInteraction, role: 'treeitem', "aria-current": current ? 'true' : undefined, onClick: (e) => {
33
+ _jsxs(Flex, { container: { alignItems: 'center', gap: 0.5 }, as: StyledLabelContent, children: [icon && _jsx(StyledNodeIcon, { name: icon }, void 0), _jsx(StyledNodeText, { children: label }, void 0)] }, void 0));
34
+ return !nodes && (onClick ?? onNodeClick) ? (_jsxs(Flex, { container: { alignItems: 'center', justify: 'between', gap: 2 }, as: StyledNodeInteraction, role: 'treeitem', "aria-current": current ? 'true' : undefined, onClick: (e) => {
35
35
  onClick?.(id, e);
36
36
  onNodeClick?.(id, e);
37
- } }, { children: [internal, actionsJSX] }), void 0)) : (internal);
37
+ }, children: [internal, actionsJSX] }, void 0)) : (internal);
38
38
  }, [id, label, icon, nodes, actions, onClick, onNodeClick, current]);
39
39
  const handleToggleClick = useCallback((e) => {
40
40
  onNodeClick?.(id, e);
41
41
  }, [id, onNodeClick]);
42
- return (_jsx(StyledStandardTreeNode, Object.assign({ id: id, style: { '--depth': depth, '--has-parent-sibling': Number(hasParentSibling) }, "aria-busy": loading }, { children: nodes ? (_jsxs(_Fragment, { children: [_jsxs(Flex, Object.assign({ container: { alignItems: 'center', justify: 'between', gap: 2 }, as: StyledStandardTreeParent, role: 'treeitem', "aria-current": current ? 'true' : undefined, variant: 'text', onClick: handleToggleClick, "aria-expanded": expanded ? 'true' : 'false', "aria-label": t(expanded ? 'collapse_noun' : 'expand_noun', [label]) }, { children: [_jsxs(Flex, Object.assign({ container: { alignItems: 'center', gap: 1 }, as: 'span' }, { children: [_jsx(StyledToggleIcon, { name: 'caret-right' }, void 0), labelContent] }), void 0), actionsJSX] }), void 0), _jsxs(StyledStandardTreeItemSubTree, Object.assign({ lined: lined }, { children: [subTree, loading && _jsx(Progress, { variant: 'ring', placement: 'inline' }, void 0)] }), void 0)] }, void 0)) : (_jsx(StyledStandardTreeLeaf, { children: labelContent }, void 0)) }), void 0));
42
+ return (_jsx(StyledStandardTreeNode, { id: id, style: { '--depth': depth, '--has-parent-sibling': Number(hasParentSibling) }, "aria-busy": loading, children: nodes ? (_jsxs(_Fragment, { children: [_jsxs(Flex, { container: { alignItems: 'center', justify: 'between', gap: 2 }, as: StyledStandardTreeParent, role: 'treeitem', "aria-current": current ? 'true' : undefined, variant: 'text', onClick: handleToggleClick, "aria-expanded": expanded ? 'true' : 'false', "aria-label": t(expanded ? 'collapse_noun' : 'expand_noun', [label]), children: [_jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, as: 'span', children: [_jsx(StyledToggleIcon, { name: 'caret-right' }, void 0), labelContent] }, void 0), actionsJSX] }, void 0), _jsxs(StyledStandardTreeItemSubTree, { lined: lined, children: [subTree, loading && _jsx(Progress, { variant: 'ring', placement: 'inline' }, void 0)] }, void 0)] }, void 0)) : (_jsx(StyledStandardTreeLeaf, { children: labelContent }, void 0)) }, void 0));
43
43
  };
44
44
  const StandardTree = forwardRef(({ nodes, currentNodeId, onNodeClick, lined = false, ...restProps }, ref) => {
45
- return (_jsx(StandardTreeContext.Provider, Object.assign({ value: useMemo(() => ({
45
+ return (_jsx(StandardTreeContext.Provider, { value: useMemo(() => ({
46
46
  currentNodeId,
47
47
  onNodeClick,
48
48
  lined
49
- }), [currentNodeId, onNodeClick, lined]) }, { children: _jsx(StyledStandardTree, Object.assign({}, restProps, { ref: ref, nodes: nodes, nodeRenderer: NodeRenderer }), void 0) }), void 0));
49
+ }), [currentNodeId, onNodeClick, lined]), children: _jsx(StyledStandardTree, { ...restProps, ref: ref, nodes: nodes, nodeRenderer: NodeRenderer }, void 0) }, void 0));
50
50
  });
51
51
  export default StandardTree;
52
52
  //# sourceMappingURL=StandardTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StandardTree.js","sourceRoot":"","sources":["../../../src/components/Tree/StandardTree.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpF,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAQ/B,MAAM,mBAAmB,GAAG,aAAa,CAEvC;IACA,aAAa,EAAE,SAAS;IACxB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;CACtB,CAAC,CAAC;AAE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CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, createContext, useMemo, useContext, useCallback } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, CSSProperties, MouseEvent } from 'react';\n\nimport Progress from '../Progress';\nimport { useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport Actions from '../Actions';\nimport type { Action, ForwardProps } from '../../types';\n\nimport {\n StyledStandardTreeParent,\n StyledToggleIcon,\n StyledStandardTreeItemSubTree,\n StyledStandardTreeLeaf,\n StyledStandardTree,\n StyledNodeInteraction,\n StyledStandardTreeNode,\n StyledNodeActions,\n StyledLabelContent,\n StyledNodeIcon,\n StyledNodeText\n} from './StandardTree.styles';\nimport type { TreeProps } from './Tree';\nimport type {\n StandardTreeNode,\n StandardTreeProps,\n StandardTreePropsWithDefaults\n} from './StandardTree.types';\n\nconst StandardTreeContext = createContext<\n Pick<StandardTreePropsWithDefaults, 'currentNodeId' | 'onNodeClick' | 'lined'>\n>({\n currentNodeId: undefined,\n lined: false,\n onNodeClick: () => {}\n});\n\nconst NodeRenderer: TreeProps<StandardTreeNode>['nodeRenderer'] = ({\n id,\n label,\n icon,\n depth,\n hasParentSibling,\n nodes,\n expanded = false,\n loading = false,\n subTree,\n actions,\n onClick\n}) => {\n const { currentNodeId, onNodeClick, lined } = useContext(StandardTreeContext);\n const current = currentNodeId === id;\n const t = useI18n();\n\n const actionsJSX = useMemo(() => {\n return actions ? (\n // Wrapping in a div since Actions may render a frag of buttons and we need a wrapper for flex space-between.\n <StyledNodeActions>\n <Actions\n items={actions.map(action => {\n return {\n ...action,\n onClick: (\n actionId: Action['id'],\n e: MouseEvent<HTMLButtonElement | HTMLAnchorElement | HTMLInputElement>\n ) => {\n e.stopPropagation();\n action?.onClick?.(actionId, e);\n }\n };\n })}\n menuAt={3}\n />\n </StyledNodeActions>\n ) : null;\n }, [actions]);\n\n const labelContent = useMemo(() => {\n const internal = (\n // Wrapping in a div for handling of flex space-between when there are node actions.\n <Flex container={{ alignItems: 'center', gap: 0.5 }} as={StyledLabelContent}>\n {icon && <StyledNodeIcon name={icon} />}\n <StyledNodeText>{label}</StyledNodeText>\n </Flex>\n );\n\n return !nodes && (onClick ?? onNodeClick) ? (\n <Flex\n container={{ alignItems: 'center', justify: 'between', gap: 2 }}\n as={StyledNodeInteraction}\n role='treeitem'\n aria-current={current ? 'true' : undefined}\n onClick={(e: MouseEvent<HTMLElement>) => {\n onClick?.(id, e);\n onNodeClick?.(id, e);\n }}\n >\n {internal}\n {actionsJSX}\n </Flex>\n ) : (\n internal\n );\n }, [id, label, icon, nodes, actions, onClick, onNodeClick, current]);\n\n const handleToggleClick = useCallback(\n (e: MouseEvent<HTMLElement>) => {\n onNodeClick?.(id, e);\n },\n [id, onNodeClick]\n );\n\n return (\n <StyledStandardTreeNode\n id={id}\n style={\n { '--depth': depth, '--has-parent-sibling': Number(hasParentSibling) } as CSSProperties\n }\n aria-busy={loading}\n >\n {nodes ? (\n <>\n <Flex\n container={{ alignItems: 'center', justify: 'between', gap: 2 }}\n as={StyledStandardTreeParent}\n role='treeitem'\n aria-current={current ? 'true' : undefined}\n variant='text'\n onClick={handleToggleClick}\n aria-expanded={expanded ? 'true' : 'false'}\n aria-label={t(expanded ? 'collapse_noun' : 'expand_noun', [label])}\n >\n <Flex container={{ alignItems: 'center', gap: 1 }} as='span'>\n <StyledToggleIcon name='caret-right' />\n {labelContent}\n </Flex>\n {actionsJSX}\n </Flex>\n <StyledStandardTreeItemSubTree lined={lined}>\n {subTree}\n {loading && <Progress variant='ring' placement='inline' />}\n </StyledStandardTreeItemSubTree>\n </>\n ) : (\n <StyledStandardTreeLeaf>{labelContent}</StyledStandardTreeLeaf>\n )}\n </StyledStandardTreeNode>\n );\n};\n\nconst StandardTree: FunctionComponent<StandardTreeProps & ForwardProps> = forwardRef(\n (\n {\n nodes,\n currentNodeId,\n onNodeClick,\n lined = false,\n ...restProps\n }: PropsWithoutRef<StandardTreeProps>,\n ref: StandardTreeProps['ref']\n ) => {\n return (\n <StandardTreeContext.Provider\n value={useMemo(\n () => ({\n currentNodeId,\n onNodeClick,\n lined\n }),\n [currentNodeId, onNodeClick, lined]\n )}\n >\n {/* FIXME: Types are having issues when styled(Tree) is typeof Tree. */}\n <StyledStandardTree {...restProps} ref={ref} nodes={nodes} nodeRenderer={NodeRenderer} />\n </StandardTreeContext.Provider>\n );\n }\n);\n\nexport default StandardTree;\n"]}
1
+ {"version":3,"file":"StandardTree.js","sourceRoot":"","sources":["../../../src/components/Tree/StandardTree.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpF,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAQ/B,MAAM,mBAAmB,GAAG,aAAa,CAEvC;IACA,aAAa,EAAE,SAAS;IACxB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAgD,CAAC,EACjE,EAAE,EACF,KAAK,EACL,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK,EACf,OAAO,EACP,OAAO,EACP,OAAO,EACR,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,mBAAmB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,CAAC,CAAC,aAElE,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAC,MAAM,aAC1D,KAAC,gBAAgB,IAAC,IAAI,EAAC,aAAa,WAAG,EACtC,YAAY,YACR,EACN,UAAU,YACN,EACP,MAAC,6BAA6B,IAAC,KAAK,EAAE,KAAK,aACxC,OAAO,EACP,OAAO,IAAI,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ,WAAG,YAC5B,YAC/B,CACJ,CAAC,CAAC,CAAC,CACF,KAAC,sBAAsB,cAAE,YAAY,WAA0B,CAChE,WACsB,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAwD,UAAU,CAClF,CACE,EACE,KAAK,EACL,aAAa,EACb,WAAW,EACX,KAAK,GAAG,KAAK,EACb,GAAG,SAAS,EACuB,EACrC,GAA6B,EAC7B,EAAE;IACF,OAAO,CACL,KAAC,mBAAmB,CAAC,QAAQ,IAC3B,KAAK,EAAE,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;YACL,aAAa;YACb,WAAW;YACX,KAAK;SACN,CAAC,EACF,CAAC,aAAa,EAAE,WAAW,EAAE,KAAK,CAAC,CACpC,YAGD,KAAC,kBAAkB,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,WAAI,WAC5D,CAChC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, createContext, useMemo, useContext, useCallback } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, CSSProperties, MouseEvent } from 'react';\n\nimport Progress from '../Progress';\nimport { useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport Actions from '../Actions';\nimport type { Action, ForwardProps } from '../../types';\n\nimport {\n StyledStandardTreeParent,\n StyledToggleIcon,\n StyledStandardTreeItemSubTree,\n StyledStandardTreeLeaf,\n StyledStandardTree,\n StyledNodeInteraction,\n StyledStandardTreeNode,\n StyledNodeActions,\n StyledLabelContent,\n StyledNodeIcon,\n StyledNodeText\n} from './StandardTree.styles';\nimport type { TreeProps } from './Tree';\nimport type {\n StandardTreeNode,\n StandardTreeProps,\n StandardTreePropsWithDefaults\n} from './StandardTree.types';\n\nconst StandardTreeContext = createContext<\n Pick<StandardTreePropsWithDefaults, 'currentNodeId' | 'onNodeClick' | 'lined'>\n>({\n currentNodeId: undefined,\n lined: false,\n onNodeClick: () => {}\n});\n\nconst NodeRenderer: TreeProps<StandardTreeNode>['nodeRenderer'] = ({\n id,\n label,\n icon,\n depth,\n hasParentSibling,\n nodes,\n expanded = false,\n loading = false,\n subTree,\n actions,\n onClick\n}) => {\n const { currentNodeId, onNodeClick, lined } = useContext(StandardTreeContext);\n const current = currentNodeId === id;\n const t = useI18n();\n\n const actionsJSX = useMemo(() => {\n return actions ? (\n // Wrapping in a div since Actions may render a frag of buttons and we need a wrapper for flex space-between.\n <StyledNodeActions>\n <Actions\n items={actions.map(action => {\n return {\n ...action,\n onClick: (\n actionId: Action['id'],\n e: MouseEvent<HTMLButtonElement | HTMLAnchorElement | HTMLInputElement>\n ) => {\n e.stopPropagation();\n action?.onClick?.(actionId, e);\n }\n };\n })}\n menuAt={3}\n />\n </StyledNodeActions>\n ) : null;\n }, [actions]);\n\n const labelContent = useMemo(() => {\n const internal = (\n // Wrapping in a div for handling of flex space-between when there are node actions.\n <Flex container={{ alignItems: 'center', gap: 0.5 }} as={StyledLabelContent}>\n {icon && <StyledNodeIcon name={icon} />}\n <StyledNodeText>{label}</StyledNodeText>\n </Flex>\n );\n\n return !nodes && (onClick ?? onNodeClick) ? (\n <Flex\n container={{ alignItems: 'center', justify: 'between', gap: 2 }}\n as={StyledNodeInteraction}\n role='treeitem'\n aria-current={current ? 'true' : undefined}\n onClick={(e: MouseEvent<HTMLElement>) => {\n onClick?.(id, e);\n onNodeClick?.(id, e);\n }}\n >\n {internal}\n {actionsJSX}\n </Flex>\n ) : (\n internal\n );\n }, [id, label, icon, nodes, actions, onClick, onNodeClick, current]);\n\n const handleToggleClick = useCallback(\n (e: MouseEvent<HTMLElement>) => {\n onNodeClick?.(id, e);\n },\n [id, onNodeClick]\n );\n\n return (\n <StyledStandardTreeNode\n id={id}\n style={\n { '--depth': depth, '--has-parent-sibling': Number(hasParentSibling) } as CSSProperties\n }\n aria-busy={loading}\n >\n {nodes ? (\n <>\n <Flex\n container={{ alignItems: 'center', justify: 'between', gap: 2 }}\n as={StyledStandardTreeParent}\n role='treeitem'\n aria-current={current ? 'true' : undefined}\n variant='text'\n onClick={handleToggleClick}\n aria-expanded={expanded ? 'true' : 'false'}\n aria-label={t(expanded ? 'collapse_noun' : 'expand_noun', [label])}\n >\n <Flex container={{ alignItems: 'center', gap: 1 }} as='span'>\n <StyledToggleIcon name='caret-right' />\n {labelContent}\n </Flex>\n {actionsJSX}\n </Flex>\n <StyledStandardTreeItemSubTree lined={lined}>\n {subTree}\n {loading && <Progress variant='ring' placement='inline' />}\n </StyledStandardTreeItemSubTree>\n </>\n ) : (\n <StyledStandardTreeLeaf>{labelContent}</StyledStandardTreeLeaf>\n )}\n </StyledStandardTreeNode>\n );\n};\n\nconst StandardTree: FunctionComponent<StandardTreeProps & ForwardProps> = forwardRef(\n (\n {\n nodes,\n currentNodeId,\n onNodeClick,\n lined = false,\n ...restProps\n }: PropsWithoutRef<StandardTreeProps>,\n ref: StandardTreeProps['ref']\n ) => {\n return (\n <StandardTreeContext.Provider\n value={useMemo(\n () => ({\n currentNodeId,\n onNodeClick,\n lined\n }),\n [currentNodeId, onNodeClick, lined]\n )}\n >\n {/* FIXME: Types are having issues when styled(Tree) is typeof Tree. */}\n <StyledStandardTree {...restProps} ref={ref} nodes={nodes} nodeRenderer={NodeRenderer} />\n </StandardTreeContext.Provider>\n );\n }\n);\n\nexport default StandardTree;\n"]}
@@ -19,14 +19,14 @@ const DefaultNodeRenderer = ({ data, subTree }) => {
19
19
  };
20
20
  let TreeList;
21
21
  const TreeItem = ({ listItemProps, depth, nodes, nodeRenderer: NodeRenderer, ...restProps }) => {
22
- return (_jsx(StyledTreeListItem, Object.assign({}, listItemProps, { children: _jsx(NodeRenderer, Object.assign({}, restProps, { depth: depth, nodes: nodes, subTree: nodes && _jsx(TreeList, { depth: depth + 1, nodes: nodes, nodeRenderer: NodeRenderer }, void 0) }), void 0) }), void 0));
22
+ return (_jsx(StyledTreeListItem, { ...listItemProps, children: _jsx(NodeRenderer, { ...restProps, depth: depth, nodes: nodes, subTree: nodes && _jsx(TreeList, { depth: depth + 1, nodes: nodes, nodeRenderer: NodeRenderer }, void 0) }, void 0) }, void 0));
23
23
  };
24
24
  TreeList = forwardRef(({ nodes, depth, nodeRenderer, ...restProps }, ref) => {
25
25
  const hasParentSibling = nodes.some(node => !!node.nodes);
26
- return nodes.length > 0 ? (_jsx(StyledTreeList, Object.assign({}, restProps, { ref: ref, role: depth === 0 ? 'tree' : 'group' }, { children: nodes.map(node => (_createElement(TreeItem, { ...node, key: node.id, depth: depth, nodeRenderer: nodeRenderer, hasParentSibling: hasParentSibling }))) }), void 0)) : null;
26
+ return nodes.length > 0 ? (_jsx(StyledTreeList, { ...restProps, ref: ref, role: depth === 0 ? 'tree' : 'group', children: nodes.map(node => (_createElement(TreeItem, { ...node, key: node.id, depth: depth, nodeRenderer: nodeRenderer, hasParentSibling: hasParentSibling }))) }, void 0)) : null;
27
27
  });
28
28
  const Tree = forwardRef(({ nodeRenderer = DefaultNodeRenderer, ...restProps }, ref) => {
29
- return _jsx(TreeList, Object.assign({}, restProps, { ref: ref, depth: 0, nodeRenderer: nodeRenderer }), void 0);
29
+ return _jsx(TreeList, { ...restProps, ref: ref, depth: 0, nodeRenderer: nodeRenderer }, void 0);
30
30
  });
31
31
  export default Tree;
32
32
  //# sourceMappingURL=Tree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.js","sourceRo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,oBAAK,SAAS,IAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,gBAC1E,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACjB,eAAC,QAAQ,OACH,IAAI,EACR,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC,YACa,CAClB,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC;AAEF,MAAM,IAAI,GAAG,UAAU,CACrB,CACE,EAAE,YAAY,GAAG,mBAAmB,EAAE,GAAG,SAAS,EAA8B,EAChF,GAAqB,EACrB,EAAE;IACF,OAAO,KAAC,QAAQ,oBAAK,SAAS,IAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,YAAY,YAAI,CAAC;AACrF,CAAC,CAC2F,CAAC;AAE/F,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, Ref, ComponentType, ReactNode } from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, NoChildrenProp, ForwardProps } from '../../types';\n\nexport type OldTreeNode<T extends object = Record<string, unknown>> = {\n /** The id of the Node. Used as the key for the li element wrapping the Node. */\n id: string;\n /** Child nodes. */\n nodes?: OldTreeNode<T>[];\n /** Props to apply to the li. */\n listItemProps?: ForwardProps;\n\n [key: string]: unknown;\n} & T;\n\nexport type TreeNode = {\n /** The id of the Node. Used as the key for the li element wrapping the Node. */\n id: string;\n /** Child nodes. */\n nodes?: TreeNode[];\n /** Props to apply to the li. */\n listItemProps?: ForwardProps;\n\n [key: string]: unknown;\n};\n\nexport interface TreeProps<T extends TreeNode = TreeNode> extends BaseProps, NoChildrenProp {\n /** An array of ParentNodes and Nodes that compose the layout of the Tree. */\n nodes: T[];\n /** A function that allows custom styling and behavior for all Nodes. */\n nodeRenderer?: ComponentType<\n {\n depth: number;\n subTree?: ReactNode;\n hasParentSibling: TreeItemProps['hasParentSibling'];\n } & Exclude<T, 'listItemProps'>\n >;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLUListElement>;\n}\n\nexport const StyledTreeListItem = styled.li``;\n\nexport const StyledTreeList = styled.ul`\n &,\n & & {\n list-style: none;\n position: relative;\n }\n\n ${StyledTreeListItem} {\n position: relative;\n }\n`;\n\nconst DefaultNodeRenderer: TreeProps['nodeRenderer'] = ({ data, subTree }) => {\n return (\n <>\n {data}\n {subTree}\n </>\n );\n};\n\ninterface TreeItemProps extends TreeNode {\n nodeRenderer: NonNullable<TreeProps['nodeRenderer']>;\n depth: number;\n hasParentSibling: boolean;\n}\n\ninterface TreeListProps extends Pick<TreeProps, 'nodes' | 'ref'> {\n nodeRenderer: NonNullable<TreeProps['nodeRenderer']>;\n depth: number;\n}\n\nlet TreeList: ComponentType<TreeListProps>;\n\nconst TreeItem = ({\n listItemProps,\n depth,\n nodes,\n nodeRenderer: NodeRenderer,\n ...restProps\n}: TreeItemProps) => {\n return (\n <StyledTreeListItem {...listItemProps}>\n <NodeRenderer\n {...restProps}\n depth={depth}\n nodes={nodes}\n subTree={nodes && <TreeList depth={depth + 1} nodes={nodes} nodeRenderer={NodeRenderer} />}\n />\n </StyledTreeListItem>\n );\n};\n\nTreeList = forwardRef(\n (\n { nodes, depth, nodeRenderer, ...restProps }: PropsWithoutRef<TreeListProps>,\n ref?: TreeProps['ref']\n ) => {\n const hasParentSibling = nodes.some(node => !!node.nodes);\n return nodes.length > 0 ? (\n <StyledTreeList {...restProps} ref={ref} role={depth === 0 ? 'tree' : 'group'}>\n {nodes.map(node => (\n <TreeItem\n {...node}\n key={node.id}\n depth={depth}\n nodeRenderer={nodeRenderer}\n hasParentSibling={hasParentSibling}\n />\n ))}\n </StyledTreeList>\n ) : null;\n }\n);\n\nconst Tree = forwardRef(\n (\n { nodeRenderer = DefaultNodeRenderer, ...restProps }: PropsWithoutRef<TreeProps>,\n ref: TreeProps['ref']\n ) => {\n return <TreeList {...restProps} ref={ref} depth={0} nodeRenderer={nodeRenderer} />;\n }\n) as <T extends TreeNode = TreeNode>(props: TreeProps<T> & ForwardProps) => JSX.Element | null;\n\nexport default Tree;\n"]}
1
+ {"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../src/components/Tree/Tree.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAkD,MAAM,OAAO,CAAC;AACnF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAyCvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;;;IAOnC,kBAAkB;;;CAGrB,CAAC;AAEF,MAAM,mBAAmB,GAA8B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IAC3E,OAAO,CACL,8BACG,IAAI,EACJ,OAAO,YACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAaF,IAAI,QAAsC,CAAC;AAE3C,MAAM,QAAQ,GAAG,CAAC,EAChB,aAAa,EACb,KAAK,EACL,KAAK,EACL,YAAY,EAAE,YAAY,EAC1B,GAAG,SAAS,EACE,EAAE,EAAE;IAClB,OAAO,CACL,KAAC,kBAAkB,OAAK,aAAa,YACnC,KAAC,YAAY,OACP,SAAS,EACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,KAAK,IAAI,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,WAAI,WAC1F,WACiB,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,GAAG,UAAU,CACnB,CACE,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,SAAS,EAAkC,EAC5E,GAAsB,EACtB,EAAE;IACF,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CACxB,KAAC,cAAc,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,YAC1E,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACjB,eAAC,QAAQ,OACH,IAAI,EACR,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC,WACa,CAClB,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC;AAEF,MAAM,IAAI,GAAG,UAAU,CACrB,CACE,EAAE,YAAY,GAAG,mBAAmB,EAAE,GAAG,SAAS,EAA8B,EAChF,GAAqB,EACrB,EAAE;IACF,OAAO,KAAC,QAAQ,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,YAAY,WAAI,CAAC;AACrF,CAAC,CAC2F,CAAC;AAE/F,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, Ref, ComponentType, ReactNode } from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, NoChildrenProp, ForwardProps } from '../../types';\n\nexport type OldTreeNode<T extends object = Record<string, unknown>> = {\n /** The id of the Node. Used as the key for the li element wrapping the Node. */\n id: string;\n /** Child nodes. */\n nodes?: OldTreeNode<T>[];\n /** Props to apply to the li. */\n listItemProps?: ForwardProps;\n\n [key: string]: unknown;\n} & T;\n\nexport type TreeNode = {\n /** The id of the Node. Used as the key for the li element wrapping the Node. */\n id: string;\n /** Child nodes. */\n nodes?: TreeNode[];\n /** Props to apply to the li. */\n listItemProps?: ForwardProps;\n\n [key: string]: unknown;\n};\n\nexport interface TreeProps<T extends TreeNode = TreeNode> extends BaseProps, NoChildrenProp {\n /** An array of ParentNodes and Nodes that compose the layout of the Tree. */\n nodes: T[];\n /** A function that allows custom styling and behavior for all Nodes. */\n nodeRenderer?: ComponentType<\n {\n depth: number;\n subTree?: ReactNode;\n hasParentSibling: TreeItemProps['hasParentSibling'];\n } & Exclude<T, 'listItemProps'>\n >;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLUListElement>;\n}\n\nexport const StyledTreeListItem = styled.li``;\n\nexport const StyledTreeList = styled.ul`\n &,\n & & {\n list-style: none;\n position: relative;\n }\n\n ${StyledTreeListItem} {\n position: relative;\n }\n`;\n\nconst DefaultNodeRenderer: TreeProps['nodeRenderer'] = ({ data, subTree }) => {\n return (\n <>\n {data}\n {subTree}\n </>\n );\n};\n\ninterface TreeItemProps extends TreeNode {\n nodeRenderer: NonNullable<TreeProps['nodeRenderer']>;\n depth: number;\n hasParentSibling: boolean;\n}\n\ninterface TreeListProps extends Pick<TreeProps, 'nodes' | 'ref'> {\n nodeRenderer: NonNullable<TreeProps['nodeRenderer']>;\n depth: number;\n}\n\nlet TreeList: ComponentType<TreeListProps>;\n\nconst TreeItem = ({\n listItemProps,\n depth,\n nodes,\n nodeRenderer: NodeRenderer,\n ...restProps\n}: TreeItemProps) => {\n return (\n <StyledTreeListItem {...listItemProps}>\n <NodeRenderer\n {...restProps}\n depth={depth}\n nodes={nodes}\n subTree={nodes && <TreeList depth={depth + 1} nodes={nodes} nodeRenderer={NodeRenderer} />}\n />\n </StyledTreeListItem>\n );\n};\n\nTreeList = forwardRef(\n (\n { nodes, depth, nodeRenderer, ...restProps }: PropsWithoutRef<TreeListProps>,\n ref?: TreeProps['ref']\n ) => {\n const hasParentSibling = nodes.some(node => !!node.nodes);\n return nodes.length > 0 ? (\n <StyledTreeList {...restProps} ref={ref} role={depth === 0 ? 'tree' : 'group'}>\n {nodes.map(node => (\n <TreeItem\n {...node}\n key={node.id}\n depth={depth}\n nodeRenderer={nodeRenderer}\n hasParentSibling={hasParentSibling}\n />\n ))}\n </StyledTreeList>\n ) : null;\n }\n);\n\nconst Tree = forwardRef(\n (\n { nodeRenderer = DefaultNodeRenderer, ...restProps }: PropsWithoutRef<TreeProps>,\n ref: TreeProps['ref']\n ) => {\n return <TreeList {...restProps} ref={ref} depth={0} nodeRenderer={nodeRenderer} />;\n }\n) as <T extends TreeNode = TreeNode>(props: TreeProps<T> & ForwardProps) => JSX.Element | null;\n\nexport default Tree;\n"]}
@@ -26,8 +26,8 @@ const generateUrlMarkup = (url) => {
26
26
  }, []);
27
27
  };
28
28
  const URLDisplay = forwardRef(({ value, displayText, variant = 'link', ...restProps }, ref) => {
29
- const displayValue = value ? (displayText || generateUrlMarkup(value)) : (_jsx("span", Object.assign({ "aria-hidden": 'true' }, { children: "\u2013\u2013" }), void 0));
30
- return variant === 'text' || !value ? (_jsx("span", Object.assign({ ref: ref }, restProps, { children: displayValue }), void 0)) : (_jsx(Link, Object.assign({ ref: ref }, restProps, { href: value }, { children: displayValue }), void 0));
29
+ const displayValue = value ? (displayText || generateUrlMarkup(value)) : (_jsx("span", { "aria-hidden": 'true', children: "\u2013\u2013" }, void 0));
30
+ return variant === 'text' || !value ? (_jsx("span", { ref: ref, ...restProps, children: displayValue }, void 0)) : (_jsx(Link, { ref: ref, ...restProps, href: value, children: displayValue }, void 0));
31
31
  });
32
32
  export default URLDisplay;
33
33
  //# sourceMappingURL=URLDisplay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"URLDisplay.js","sourceRoot":"","sources":["../../../src/components/URL/URLDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AAEvF,OAAO,IAAI,MAAM,SAAS,CAAC;AAiB3B;;;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F,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, ReactNode, Ref } from 'react';\n\nimport Link from '../Link';\nimport { BaseProps, ForwardProps } from '../../types';\n\nexport interface URLDisplayProps extends BaseProps {\n /** URL address, includes scheme, 'http://', 'https://' */\n value?: string;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default \"link\"\n */\n variant?: 'link' | 'text';\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\n/**\n * Function gets the url as a string and converts it to a HTML markup with whitespace opportunity elements.\n * It helps breaking a long url correctly to avoid parent container overflow issues\n * according to \"The Chicago Manual of Style\" copywriting standard.\n * @param url input url to construct markup for\n * @returns array of nodes\n */\nconst generateUrlMarkup = (url: string): ReactNode => {\n const markedUrl = url\n .split('//')\n /* Insert \\x1f (unit separator) char as a placeholder at correct position. */\n .map(str => {\n return str\n .replace(/:/giu, '$&\\x1f')\n .replace(/[/~.,\\\\-_?#%]/giu, '\\x1f$&')\n .replace(/[=&]/giu, '\\x1f$&\\x1f');\n })\n .join('//\\x1f');\n\n /* Replace unit separator character with <wbr /> element. Create an array of nodes in place of string to pass tags escaping. */\n return markedUrl.split('\\x1f').reduce<ReactNode[]>((urlFragments, part) => {\n urlFragments.push(part, <wbr key={urlFragments.length} />);\n return urlFragments;\n }, []);\n};\n\nconst URLDisplay: FunctionComponent<URLDisplayProps & ForwardProps> = forwardRef(\n (\n { value, displayText, variant = 'link', ...restProps }: PropsWithoutRef<URLDisplayProps>,\n ref: URLDisplayProps['ref']\n ) => {\n const displayValue = value ? (\n displayText || generateUrlMarkup(value)\n ) : (\n <span aria-hidden='true'>&ndash;&ndash;</span>\n );\n return variant === 'text' || !value ? (\n <span ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayValue}\n </span>\n ) : (\n <Link ref={ref as Ref<HTMLAnchorElement>} {...restProps} href={value}>\n {displayValue}\n </Link>\n );\n }\n);\n\nexport default URLDisplay;\n"]}
1
+ {"version":3,"file":"URLDisplay.js","sourceRoot":"","sources":["../../../src/components/URL/URLDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AAEvF,OAAO,IAAI,MAAM,SAAS,CAAC;AAiB3B;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAa,EAAE;IACnD,MAAM,SAAS,GAAG,GAAG;SAClB,KAAK,CAAC,IAAI,CAAC;QACZ,6EAA6E;SAC5E,GAAG,CAAC,GAAG,CAAC,EAAE;QACT,OAAO,GAAG;aACP,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC;aACzB,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC;aACrC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACtC,CAAC,CAAC;SACD,IAAI,CAAC,QAAQ,CAAC,CAAC;IAElB,+HAA+H;IAC/H,OAAO,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAc,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE;QACxE,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAU,YAAY,CAAC,MAAM,CAAI,CAAC,CAAC;QAC3D,OAAO,YAAY,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,UAAU,GAAsD,UAAU,CAC9E,CACE,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,EAAoC,EACxF,GAA2B,EAC3B,EAAE;IACF,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAC3B,WAAW,IAAI,iBAAiB,CAAC,KAAK,CAAC,CACxC,CAAC,CAAC,CAAC,CACF,8BAAkB,MAAM,qCAAsB,CAC/C,CAAC;IACF,OAAO,OAAO,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACpC,eAAM,GAAG,EAAE,GAA2B,KAAM,SAAS,YAClD,YAAY,WACR,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,GAAG,EAAE,GAA6B,KAAM,SAAS,EAAE,IAAI,EAAE,KAAK,YACjE,YAAY,WACR,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, ReactNode, Ref } from 'react';\n\nimport Link from '../Link';\nimport { BaseProps, ForwardProps } from '../../types';\n\nexport interface URLDisplayProps extends BaseProps {\n /** URL address, includes scheme, 'http://', 'https://' */\n value?: string;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default \"link\"\n */\n variant?: 'link' | 'text';\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\n/**\n * Function gets the url as a string and converts it to a HTML markup with whitespace opportunity elements.\n * It helps breaking a long url correctly to avoid parent container overflow issues\n * according to \"The Chicago Manual of Style\" copywriting standard.\n * @param url input url to construct markup for\n * @returns array of nodes\n */\nconst generateUrlMarkup = (url: string): ReactNode => {\n const markedUrl = url\n .split('//')\n /* Insert \\x1f (unit separator) char as a placeholder at correct position. */\n .map(str => {\n return str\n .replace(/:/giu, '$&\\x1f')\n .replace(/[/~.,\\\\-_?#%]/giu, '\\x1f$&')\n .replace(/[=&]/giu, '\\x1f$&\\x1f');\n })\n .join('//\\x1f');\n\n /* Replace unit separator character with <wbr /> element. Create an array of nodes in place of string to pass tags escaping. */\n return markedUrl.split('\\x1f').reduce<ReactNode[]>((urlFragments, part) => {\n urlFragments.push(part, <wbr key={urlFragments.length} />);\n return urlFragments;\n }, []);\n};\n\nconst URLDisplay: FunctionComponent<URLDisplayProps & ForwardProps> = forwardRef(\n (\n { value, displayText, variant = 'link', ...restProps }: PropsWithoutRef<URLDisplayProps>,\n ref: URLDisplayProps['ref']\n ) => {\n const displayValue = value ? (\n displayText || generateUrlMarkup(value)\n ) : (\n <span aria-hidden='true'>&ndash;&ndash;</span>\n );\n return variant === 'text' || !value ? (\n <span ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayValue}\n </span>\n ) : (\n <Link ref={ref as Ref<HTMLAnchorElement>} {...restProps} href={value}>\n {displayValue}\n </Link>\n );\n }\n);\n\nexport default URLDisplay;\n"]}
@@ -4,6 +4,6 @@ import { RefObject } from 'react';
4
4
  * @param onFocusChange Callback function that is invoked with the current focus state and the current element when any child elements takes focus or all of them lose focus.
5
5
  * @returns * hasFocus:: A boolean indicating if the ref element has focus or not.
6
6
  */
7
- declare const useFocusWithin: <T extends Element = Element>(els: (T | RefObject<T | null> | null)[], onFocusChange?: ((isFocused: boolean, element: T | null) => void) | undefined) => boolean;
7
+ declare const useFocusWithin: <T extends HTMLElement = HTMLElement>(els: (T | RefObject<T | null> | null)[], onFocusChange?: ((isFocused: boolean, element: T | null) => void) | undefined) => boolean;
8
8
  export default useFocusWithin;
9
9
  //# sourceMappingURL=useFocusWithin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusWithin.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusWithin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAuB,MAAM,OAAO,CAAC;AAM5E;;;;GAIG;AACH,QAAA,MAAM,cAAc,sGAEU,OAAO,wBAAwB,IAAI,kBAC9D,OA8EF,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"useFocusWithin.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusWithin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAuB,MAAM,OAAO,CAAC;AAM5E;;;;GAIG;AACH,QAAA,MAAM,cAAc,8GAEU,OAAO,wBAAwB,IAAI,kBAC9D,OA0FF,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -9,20 +9,24 @@ import useOuterEvent from './useOuterEvent';
9
9
  const useFocusWithin = (els, onFocusChange) => {
10
10
  const [hasFocus, setFocus] = useState(false);
11
11
  const focusedElRef = useRef(null);
12
+ const blurTimerRef = useRef();
12
13
  const elsRef = useRef(els);
13
14
  elsRef.current = els;
14
- const onBlur = useCallback((e) => {
15
+ const onBlur = useCallback(({ relatedTarget }) => {
15
16
  if (!hasFocus)
16
17
  return;
17
18
  const elements = normalizeElements(elsRef.current);
18
- // changing focus to another relevant child doesn't count
19
- const focusedEl = elements.find(el => el?.contains(e.relatedTarget));
20
- if (focusedEl) {
21
- // ... just update the currently focused item
22
- focusedElRef.current = focusedEl;
23
- return;
19
+ if (relatedTarget instanceof Node) {
20
+ // changing focus to another relevant child doesn't count
21
+ const focusedEl = elements.find(el => el?.contains(relatedTarget));
22
+ if (focusedEl) {
23
+ // ... just update the currently focused item
24
+ focusedElRef.current = focusedEl;
25
+ return;
26
+ }
24
27
  }
25
- const timerId = setTimeout(() => {
28
+ clearTimeout(blurTimerRef.current);
29
+ blurTimerRef.current = setTimeout(() => {
26
30
  if (!elements.some(el => {
27
31
  return el?.contains(document.activeElement);
28
32
  })) {
@@ -31,15 +35,12 @@ const useFocusWithin = (els, onFocusChange) => {
31
35
  focusedElRef.current = null;
32
36
  }
33
37
  });
34
- return () => {
35
- if (timerId)
36
- clearTimeout(timerId);
37
- };
38
38
  }, [hasFocus, onFocusChange]);
39
- const onFocus = useCallback((e) => {
39
+ const onFocus = useCallback(({ currentTarget }) => {
40
+ clearTimeout(blurTimerRef.current);
40
41
  if (!hasFocus) {
41
42
  setFocus(true);
42
- const targetEl = e.currentTarget;
43
+ const targetEl = currentTarget;
43
44
  onFocusChange?.(true, targetEl);
44
45
  focusedElRef.current = targetEl;
45
46
  }
@@ -53,17 +54,21 @@ const useFocusWithin = (els, onFocusChange) => {
53
54
  }, [onFocusChange, hasFocus]));
54
55
  useEffect(() => {
55
56
  const elements = normalizeElements(els);
56
- elements.forEach((el) => {
57
+ elements.forEach(el => {
57
58
  el?.addEventListener('focusin', onFocus);
58
59
  el?.addEventListener('focusout', onBlur);
59
60
  });
60
61
  return () => {
61
- elements.forEach((el) => {
62
+ elements.forEach(el => {
62
63
  el?.removeEventListener('focusin', onFocus);
63
64
  el?.removeEventListener('focusout', onBlur);
64
65
  });
65
66
  };
66
67
  }, [els, onFocus, onBlur]);
68
+ // Clear timeout when component un-mounts.
69
+ useEffect(() => () => {
70
+ clearTimeout(blurTimerRef.current);
71
+ }, []);
67
72
  return hasFocus;
68
73
  };
69
74
  export default useFocusWithin;
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusWithin.js","sourceRoot":"","sources":["../../src/hooks/useFocusWithin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAa,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,cAAc,GAAG,CACrB,GAAuC,EACvC,aAA+D,EACtD,EAAE;IACX,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAW,IAAI,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC;IAErB,MAAM,MAAM,GAAG,WAAW,CACxB,CAAC,CAAQ,EAAE,EAAE;QACX,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnD,yDAAyD;QACzD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAE,CAAgB,CAAC,aAAqB,CAAC,CAAC,CAAC;QAC7F,IA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C,aAAa,EAAE,QAAQ,CAAC,CAAC,CAC9B,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAExC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAY,EAAE,EAAE;YAChC,EAAE,EAAE,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACzC,EAAE,EAAE,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAY,EAAE,EAAE;gBAChC,EAAE,EAAE,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAC5C,EAAE,EAAE,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useState, useEffect, RefObject, useCallback, useRef } from 'react';\n\nimport { normalizeElements } from '../utils';\n\nimport useOuterEvent from './useOuterEvent';\n\n/** Hook for properly handling focus state of children components.\n * @example const hasFocus = useFocusWithin([containerRef, ...], (isFocused, element) => { doSomething; });\n * @param onFocusChange Callback function that is invoked with the current focus state and the current element when any child elements takes focus or all of them lose focus.\n * @returns * hasFocus:: A boolean indicating if the ref element has focus or not.\n */\nconst useFocusWithin = <T extends Element = Element>(\n els: (T | null | RefObject<T | null>)[],\n onFocusChange?: (isFocused: boolean, element: T | null) => void\n): boolean => {\n const [hasFocus, setFocus] = useState(false);\n const focusedElRef = useRef<T | null>(null);\n\n const elsRef = useRef(els);\n elsRef.current = els;\n\n const onBlur = useCallback(\n (e: Event) => {\n if (!hasFocus) return;\n\n const elements = normalizeElements(elsRef.current);\n // changing focus to another relevant child doesn't count\n const focusedEl = elements.find(el => el?.contains((e as FocusEvent).relatedTarget as Node));\n if (focusedEl) {\n // ... just update the currently focused item\n focusedElRef.current = focusedEl;\n return;\n }\n const timerId = setTimeout(() => {\n if (\n !elements.some(el => {\n return el?.contains(document.activeElement);\n })\n ) {\n setFocus(false);\n onFocusChange?.(false, focusedElRef.current);\n focusedElRef.current = null;\n }\n });\n\n return () => {\n if (timerId) clearTimeout(timerId);\n };\n },\n [hasFocus, onFocusChange]\n );\n\n const onFocus = useCallback(\n (e: Event) => {\n if (!hasFocus) {\n setFocus(true);\n const targetEl = (e as FocusEvent).currentTarget as T;\n onFocusChange?.(true, targetEl);\n focusedElRef.current = targetEl;\n }\n },\n [hasFocus, onFocusChange]\n );\n\n useOuterEvent(\n 'mouseup',\n els,\n useCallback(() => {\n if (hasFocus) {\n setFocus(false);\n onFocusChange?.(false, focusedElRef.current);\n focusedElRef.current = null;\n }\n }, [onFocusChange, hasFocus])\n );\n\n useEffect(() => {\n const elements = normalizeElements(els);\n\n elements.forEach((el: T | null) => {\n el?.addEventListener('focusin', onFocus);\n el?.addEventListener('focusout', onBlur);\n });\n return () => {\n elements.forEach((el: T | null) => {\n el?.removeEventListener('focusin', onFocus);\n el?.removeEventListener('focusout', onBlur);\n });\n };\n }, [els, onFocus, onBlur]);\n\n return hasFocus;\n};\n\nexport default useFocusWithin;\n"]}
1
+ {"version":3,"file":"useFocusWithin.js","sourceRoot":"","sources":["../../src/hooks/useFocusWithin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAa,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,cAAc,GAAG,CACrB,GAAuC,EACvC,aAA+D,EACtD,EAAE;IACX,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AC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAE3B,0CAA0C;IAC1C,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useState, useEffect, RefObject, useCallback, useRef } from 'react';\n\nimport { normalizeElements } from '../utils';\n\nimport useOuterEvent from './useOuterEvent';\n\n/** Hook for properly handling focus state of children components.\n * @example const hasFocus = useFocusWithin([containerRef, ...], (isFocused, element) => { doSomething; });\n * @param onFocusChange Callback function that is invoked with the current focus state and the current element when any child elements takes focus or all of them lose focus.\n * @returns * hasFocus:: A boolean indicating if the ref element has focus or not.\n */\nconst useFocusWithin = <T extends HTMLElement = HTMLElement>(\n els: (T | null | RefObject<T | null>)[],\n onFocusChange?: (isFocused: boolean, element: T | null) => void\n): boolean => {\n const [hasFocus, setFocus] = useState(false);\n const focusedElRef = useRef<T | null>(null);\n const blurTimerRef = useRef<number>();\n\n const elsRef = useRef(els);\n elsRef.current = els;\n\n const onBlur = useCallback(\n ({ relatedTarget }: FocusEvent) => {\n if (!hasFocus) return;\n\n const elements = normalizeElements(elsRef.current);\n\n if (relatedTarget instanceof Node) {\n // changing focus to another relevant child doesn't count\n const focusedEl = elements.find(el => el?.contains(relatedTarget));\n if (focusedEl) {\n // ... just update the currently focused item\n focusedElRef.current = focusedEl;\n return;\n }\n }\n\n clearTimeout(blurTimerRef.current);\n blurTimerRef.current = setTimeout(() => {\n if (\n !elements.some(el => {\n return el?.contains(document.activeElement);\n })\n ) {\n setFocus(false);\n onFocusChange?.(false, focusedElRef.current);\n focusedElRef.current = null;\n }\n });\n },\n [hasFocus, onFocusChange]\n );\n\n const onFocus = useCallback(\n ({ currentTarget }: FocusEvent) => {\n clearTimeout(blurTimerRef.current);\n\n if (!hasFocus) {\n setFocus(true);\n const targetEl = currentTarget as T;\n onFocusChange?.(true, targetEl);\n focusedElRef.current = targetEl;\n }\n },\n [hasFocus, onFocusChange]\n );\n\n useOuterEvent(\n 'mouseup',\n els,\n useCallback(() => {\n if (hasFocus) {\n setFocus(false);\n onFocusChange?.(false, focusedElRef.current);\n focusedElRef.current = null;\n }\n }, [onFocusChange, hasFocus])\n );\n\n useEffect(() => {\n const elements = normalizeElements(els);\n\n elements.forEach(el => {\n el?.addEventListener('focusin', onFocus);\n el?.addEventListener('focusout', onBlur);\n });\n return () => {\n elements.forEach(el => {\n el?.removeEventListener('focusin', onFocus);\n el?.removeEventListener('focusout', onBlur);\n });\n };\n }, [els, onFocus, onBlur]);\n\n // Clear timeout when component un-mounts.\n useEffect(\n () => () => {\n clearTimeout(blurTimerRef.current);\n },\n []\n );\n\n return hasFocus;\n};\n\nexport default useFocusWithin;\n"]}
@@ -334,6 +334,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
334
334
  edit: string;
335
335
  edit_noun: string;
336
336
  edited: string;
337
+ edit_details: string;
337
338
  preview: string;
338
339
  delete: string;
339
340
  delete_noun: string;
@@ -379,6 +380,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
379
380
  many: string;
380
381
  other: string;
381
382
  };
383
+ more_count: string;
382
384
  empty_search: string;
383
385
  new_messages: string;
384
386
  earlier_transcripts: string;
@@ -488,7 +490,6 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
488
490
  feed_private_post: string;
489
491
  feed_public_post: string;
490
492
  feed_recipients: string;
491
- feed_more_count: string;
492
493
  sentiment_positive: string;
493
494
  sentiment_negative: string;
494
495
  sentiment_neutral: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -330,6 +330,7 @@
330
330
  "edit": "Edit",
331
331
  "edit_noun": "Edit {0}",
332
332
  "edited": "Edited",
333
+ "edit_details": "Edit details",
333
334
  "preview": "Preview",
334
335
  "delete": "Delete",
335
336
  "delete_noun": "Delete {0}",
@@ -375,6 +376,7 @@
375
376
  "many": "{0} results",
376
377
  "other": "{0} results"
377
378
  },
379
+ "more_count": "{0} more…",
378
380
  "empty_search": "Enter a search term",
379
381
  "new_messages": "New messages",
380
382
  "earlier_transcripts": "Earlier transcripts",
@@ -484,7 +486,6 @@
484
486
  "feed_private_post": "Private post",
485
487
  "feed_public_post": "Public post",
486
488
  "feed_recipients": "Recipients",
487
- "feed_more_count": "{0} more…",
488
489
  "sentiment_positive": "Positive",
489
490
  "sentiment_negative": "Negative",
490
491
  "sentiment_neutral": "Neutral",