@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":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,YAAY,EAEZ,SAAS,EACT,QAAQ,EAER,UAAU,EAEX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,EAAc,WAAW,EAAE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AAC,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,iBAClE,WAAW,EACZ,KAAC,IAAI,kBAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,gBAAG,gBAAgB,YAAQ,aAC/C,CACR,CAAC;KACH;IAED,OAAO,CACL,MAAC,IAAI,oBACC,SAAS,IACb,SAAS,EAAE;YACT,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;YACpC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACzC,GAAG,SAAS;SACb,EACD,EAAE,EAAE,eAAe,EACnB,EAAE,EAAE,GAAG,EAAE,QAAQ,EACjB,WAAW,EAAE,EAAE,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,sBACA,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EAClE,GAAG,EAAE,GAAG,iBAEP,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,IAAI,WAAW,EAC7C,OAAO,EACP,CAAC,aAAa,IAAI,UAAU,IAAI,WAAW,EAC3C,WAAW,aACP,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n FC,\n ReactNode,\n ComponentType,\n cloneElement,\n ReactElement,\n useEffect,\n useState,\n PropsWithoutRef,\n forwardRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { Action, ForwardProps, OmitStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport { FormControlProps } from '../FormControl';\nimport { useUID } from '../../hooks';\nimport Label, { LabelProps, StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\nimport Icon from '../Icon';\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default \"label\"\n */\n labelAs?: LabelProps['as'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default \"div\"\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: Exclude<FlexProps['container'], boolean>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(\n ({ theme, status }) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${theme.components['form-field'][status]['status-color']};\n vertical-align: baseline;\n margin-inline-end: 0.5ch;\n `;\n }\n);\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n }\n }) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n max-width: max-content;\n margin-top: calc(0.25 * ${spacing});\n font-size: ${infoFontSize};\n word-break: break-word;\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `;\n }\n);\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled.div<FormFieldProps>(props => {\n const {\n disabled,\n required,\n theme: {\n base: {\n palette: { urgent },\n 'disabled-opacity': disabledOpacity,\n spacing\n }\n }\n } = props;\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n > ${StyledLabel} {\n margin-bottom: calc(0.25 * ${spacing});\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n }\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'warn', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormFieldProps>, ref: Ref<HTMLElement>) => {\n const uid = useUID();\n const {\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs = 'label',\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = false,\n actions,\n container,\n ...restProps\n } = props;\n\n const labelAsLegend: boolean = labelAs === 'legend';\n\n const styledLabel = (\n <Label\n as={labelAs}\n htmlFor={labelAs === 'label' ? id : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={inline}\n >\n {status && !labelHidden && (\n <StyledStatusIcon status={status} name={statusIconMap[status]} />\n )}\n {label}\n </Label>\n );\n\n /*\n We have to use an internal state and an effect to set the text value of info after the DOM element is rendered.\n This is to ensure screen readers will announce info on errors when role is set to alert.\n Needs testing to confirm. Currently the expected sequence would be:\n - FormField renders with no error and no info\n - user input triggers an error status\n - props passed set error status and provide info text\n - effect runs and sets live region state which renders and is announced\n */\n const [liveRegionInfo, setLiveRegionInfo] = useState<ReactNode>(null);\n\n useEffect(() => {\n setLiveRegionInfo(info);\n }, [info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'] = labelAsLegend\n ? controlElement\n : cloneElement(controlElement as ReactElement, {\n 'aria-describedby': info && `${id}-info`\n });\n\n if (actions) {\n content = (\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = info ? (\n /*\n Region for additional info, help or error message.\n Withholding aria-live=\"assertive\" to avoid iOS issue. See below.\n https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions#Preferring_specialized_live_region_roles\n */\n <StyledFormFieldInfo\n status={status}\n role={status === 'error' || status === 'warning' ? 'alert' : undefined}\n id={`${id}-info`}\n >\n {liveRegionInfo}\n </StyledFormFieldInfo>\n ) : undefined;\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n return (\n <Flex\n {...restProps}\n container={{\n direction: inline ? 'row' : 'column',\n alignItems: inline ? 'center' : undefined,\n ...container\n }}\n as={StyledFormField}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n aria-describedby={labelAsLegend && info ? `${id}-info` : undefined}\n ref={ref}\n >\n {(labelAsLegend || !labelAfter) && styledLabel}\n {content}\n {!labelAsLegend && labelAfter && styledLabel}\n {infoContent}\n </Flex>\n );\n }\n);\n\nexport default FormField;\n"]}
1
+ {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,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;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n FC,\n ReactNode,\n ComponentType,\n cloneElement,\n ReactElement,\n useEffect,\n useState,\n PropsWithoutRef,\n forwardRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { Action, ForwardProps, OmitStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport { FormControlProps } from '../FormControl';\nimport { useUID } from '../../hooks';\nimport Label, { LabelProps, StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\nimport Icon from '../Icon';\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default \"label\"\n */\n labelAs?: LabelProps['as'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default \"div\"\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: Exclude<FlexProps['container'], boolean>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(\n ({ theme, status }) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${theme.components['form-field'][status]['status-color']};\n vertical-align: baseline;\n margin-inline-end: 0.5ch;\n `;\n }\n);\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n }\n }) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n max-width: max-content;\n margin-top: calc(0.25 * ${spacing});\n font-size: ${infoFontSize};\n word-break: break-word;\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `;\n }\n);\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled.div<FormFieldProps>(props => {\n const {\n disabled,\n required,\n theme: {\n base: {\n palette: { urgent },\n 'disabled-opacity': disabledOpacity,\n spacing\n }\n }\n } = props;\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n > ${StyledLabel} {\n margin-bottom: calc(0.25 * ${spacing});\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n }\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'warn', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormFieldProps>, ref: Ref<HTMLElement>) => {\n const uid = useUID();\n const {\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs = 'label',\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = false,\n actions,\n container,\n ...restProps\n } = props;\n\n const labelAsLegend: boolean = labelAs === 'legend';\n\n const styledLabel = (\n <Label\n as={labelAs}\n htmlFor={labelAs === 'label' ? id : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={inline}\n >\n {status && !labelHidden && (\n <StyledStatusIcon status={status} name={statusIconMap[status]} />\n )}\n {label}\n </Label>\n );\n\n /*\n We have to use an internal state and an effect to set the text value of info after the DOM element is rendered.\n This is to ensure screen readers will announce info on errors when role is set to alert.\n Needs testing to confirm. Currently the expected sequence would be:\n - FormField renders with no error and no info\n - user input triggers an error status\n - props passed set error status and provide info text\n - effect runs and sets live region state which renders and is announced\n */\n const [liveRegionInfo, setLiveRegionInfo] = useState<ReactNode>(null);\n\n useEffect(() => {\n setLiveRegionInfo(info);\n }, [info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'] = labelAsLegend\n ? controlElement\n : cloneElement(controlElement as ReactElement, {\n 'aria-describedby': info && `${id}-info`\n });\n\n if (actions) {\n content = (\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = info ? (\n /*\n Region for additional info, help or error message.\n Withholding aria-live=\"assertive\" to avoid iOS issue. See below.\n https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions#Preferring_specialized_live_region_roles\n */\n <StyledFormFieldInfo\n status={status}\n role={status === 'error' || status === 'warning' ? 'alert' : undefined}\n id={`${id}-info`}\n >\n {liveRegionInfo}\n </StyledFormFieldInfo>\n ) : undefined;\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n return (\n <Flex\n {...restProps}\n container={{\n direction: inline ? 'row' : 'column',\n alignItems: inline ? 'center' : undefined,\n ...container\n }}\n as={StyledFormField}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n aria-describedby={labelAsLegend && info ? `${id}-info` : undefined}\n ref={ref}\n >\n {(labelAsLegend || !labelAfter) && styledLabel}\n {content}\n {!labelAsLegend && labelAfter && styledLabel}\n {infoContent}\n </Flex>\n );\n }\n);\n\nexport default FormField;\n"]}
@@ -174,7 +174,7 @@ export const StyledGrid = styled.div(props => {
174
174
  });
175
175
  StyledGrid.defaultProps = defaultThemeProp;
176
176
  const Grid = forwardRef((props, ref) => {
177
- return _jsx(StyledGrid, Object.assign({}, props, { ref: ref }), void 0);
177
+ return _jsx(StyledGrid, { ...props, ref: ref }, void 0);
178
178
  });
179
179
  export default Grid;
180
180
  //# sourceMappingURL=Grid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.js","sourceRoot":"","sources":["../../../src/components/Grid/Grid.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AACvE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;IAC/B,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,KAAK,EAAE,CAAC;IAC7E,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,SAAiC,EAAE,EAAE;IAC/D,IAAI,CAAC,SAAS;QAAE,OAAO;IAEvB,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,OAAO,GAAG,CAAA;;KAET,CAAC;KACH;IAED,MAAM,EACJ,MAAM,EACN,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,EAC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UAAU,GAAG,MAAM,CAAC,GAAG,CAA+B,KAAK,CAAC,EAAE;IACzE,MAAM,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,EACxC,EACD,EAAE,EACF,EAAE,EACF,EAAE,EACF,EAAE,EACF,EAAE,EACH,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG;QAClB,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;KACH,CAAC;IAEF,OAAO,GAAG,CAAA;MACN,kBAAkB,CAAC,SAAS,CAAC;MAC7B,aAAa,CAAC,IAAI,CAAC;;MAEnB,eAAe,CAAC,GAAG,CACnB,UAAU,CAAC,EAAE,CACX,WAAW,CAAC,UAAU,CAAC;QACvB,GAAG,CAAA;0CAC+B,gBAAgB,CAAC,UAAU,CAAC;cACxD,kBAAkB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC;cACtD,aAAa,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC;;SAEjD,CACJ;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,IAAI,GAAgD,UAAU,CAClE,CAAC,KAAiC,EAAE,GAAqB,EAAE,EAAE;IAC3D,OAAO,KAAC,UAAU,oBAAK,KAAK,IAAE,GAAG,EAAE,GAAG,YAAI,CAAC;AAC7C,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps, PropsWithDefaults } from '../../types';\nimport { defaultThemeProp } from '../../theme';\n\nimport GridProps from './Grid.types';\n\nconst prefix = (value: string) => {\n if (['between', 'around', 'evenly'].includes(value)) return `space-${value}`;\n return value;\n};\n\nconst getContainerStyles = (gridProps: GridProps['container']) => {\n if (!gridProps) return;\n\n if (gridProps === true) {\n return css`\n display: grid;\n `;\n }\n\n const {\n inline,\n pad,\n cols,\n autoCols,\n rows,\n autoRows,\n autoFlow,\n areas,\n template,\n colGap,\n rowGap,\n gap,\n justifyItems,\n justifyContent,\n alignItems,\n alignContent\n } = gridProps;\n\n return css`\n display: ${inline ? 'inline-grid' : 'grid'};\n\n ${typeof pad !== 'undefined' &&\n css`\n /* stylelint-disable function-name-case, function-whitespace-after */\n padding: ${({\n theme: {\n base: { spacing }\n }\n }) => (Array.isArray(pad) ? pad : [pad]).map(p => `calc(${p} * ${spacing})`).join(' ')};\n\n /* stylelint-enable function-name-case, function-whitespace-after */\n `}\n\n ${cols &&\n css`\n grid-template-columns: ${cols};\n `}\n\n ${autoCols &&\n css`\n grid-auto-columns: ${autoCols};\n `}\n\n ${rows &&\n css`\n grid-template-rows: ${rows};\n `}\n\n ${autoRows &&\n css`\n grid-auto-rows: ${autoRows};\n `}\n\n ${autoFlow &&\n css`\n grid-auto-flow: ${autoFlow};\n `}\n\n ${areas &&\n css`\n grid-template-areas: ${areas};\n `}\n\n ${template &&\n css`\n grid-template: ${template};\n `}\n\n ${typeof gap !== 'undefined' &&\n css`\n gap: calc(${gap} * ${props => props.theme.base.spacing});\n `}\n\n ${typeof colGap !== 'undefined' &&\n css`\n column-gap: calc(${colGap} * ${props => props.theme.base.spacing});\n `}\n\n ${typeof rowGap !== 'undefined' &&\n css`\n row-gap: calc(${rowGap} * ${props => props.theme.base.spacing});\n `}\n\n ${justifyItems &&\n css`\n justify-items: ${justifyItems};\n `}\n\n ${justifyContent &&\n css`\n justify-content: ${prefix(justifyContent)};\n `}\n\n ${alignItems &&\n css`\n align-items: ${alignItems};\n `}\n\n ${alignContent &&\n css`\n align-content: ${prefix(alignContent)};\n `}\n `;\n};\n\nconst getItemStyles = (props: GridProps['item']) => {\n if (!props) return;\n\n const {\n colStart,\n colEnd,\n colStartEnd,\n rowStart,\n rowEnd,\n rowStartEnd,\n area,\n justifySelf,\n alignSelf\n } = props;\n\n return css`\n ${colStart &&\n css`\n grid-column-start: ${colStart};\n `}\n\n ${colEnd &&\n css`\n grid-column-end: ${colEnd};\n `}\n\n ${colStartEnd &&\n css`\n grid-column: ${colStartEnd};\n `}\n\n ${rowStart &&\n css`\n grid-row-start: ${rowStart};\n `}\n\n ${rowEnd &&\n css`\n grid-row-end: ${rowEnd};\n `}\n\n ${rowStartEnd &&\n css`\n grid-row: ${rowStartEnd};\n `}\n\n ${area &&\n css`\n grid-area: ${area};\n `}\n\n ${justifySelf &&\n css`\n justify-self: ${justifySelf};\n `}\n\n ${alignSelf &&\n css`\n align-self: ${alignSelf};\n `}\n `;\n};\n\nconst breakpointOrder = ['xs', 'sm', 'md', 'lg', 'xl'] as const;\n\nexport const StyledGrid = styled.div<PropsWithDefaults<GridProps>>(props => {\n const {\n container,\n item,\n theme: {\n base: { breakpoints: themeBreakpoints }\n },\n xs,\n sm,\n md,\n lg,\n xl\n } = props;\n\n const breakpoints = {\n xs,\n sm,\n md,\n lg,\n xl\n };\n\n return css`\n ${getContainerStyles(container)}\n ${getItemStyles(item)}\n\n ${breakpointOrder.map(\n breakpoint =>\n breakpoints[breakpoint] &&\n css`\n @media screen and (min-width: ${themeBreakpoints[breakpoint]}) {\n ${getContainerStyles(breakpoints[breakpoint]?.container)}\n ${getItemStyles(breakpoints[breakpoint]?.item)}\n }\n `\n )}\n `;\n});\n\nStyledGrid.defaultProps = defaultThemeProp;\n\nconst Grid: FunctionComponent<GridProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<GridProps>, ref: GridProps['ref']) => {\n return <StyledGrid {...props} ref={ref} />;\n }\n);\n\nexport default Grid;\n"]}
1
+ {"version":3,"file":"Grid.js","sourceRoot":"","sources":["../../../src/components/Grid/Grid.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,OAAO,CAAC;AACvE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAG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AAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,IAAI,GAAgD,UAAU,CAClE,CAAC,KAAiC,EAAE,GAAqB,EAAE,EAAE;IAC3D,OAAO,KAAC,UAAU,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,WAAI,CAAC;AAC7C,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps, PropsWithDefaults } from '../../types';\nimport { defaultThemeProp } from '../../theme';\n\nimport GridProps from './Grid.types';\n\nconst prefix = (value: string) => {\n if (['between', 'around', 'evenly'].includes(value)) return `space-${value}`;\n return value;\n};\n\nconst getContainerStyles = (gridProps: GridProps['container']) => {\n if (!gridProps) return;\n\n if (gridProps === true) {\n return css`\n display: grid;\n `;\n }\n\n const {\n inline,\n pad,\n cols,\n autoCols,\n rows,\n autoRows,\n autoFlow,\n areas,\n template,\n colGap,\n rowGap,\n gap,\n justifyItems,\n justifyContent,\n alignItems,\n alignContent\n } = gridProps;\n\n return css`\n display: ${inline ? 'inline-grid' : 'grid'};\n\n ${typeof pad !== 'undefined' &&\n css`\n /* stylelint-disable function-name-case, function-whitespace-after */\n padding: ${({\n theme: {\n base: { spacing }\n }\n }) => (Array.isArray(pad) ? pad : [pad]).map(p => `calc(${p} * ${spacing})`).join(' ')};\n\n /* stylelint-enable function-name-case, function-whitespace-after */\n `}\n\n ${cols &&\n css`\n grid-template-columns: ${cols};\n `}\n\n ${autoCols &&\n css`\n grid-auto-columns: ${autoCols};\n `}\n\n ${rows &&\n css`\n grid-template-rows: ${rows};\n `}\n\n ${autoRows &&\n css`\n grid-auto-rows: ${autoRows};\n `}\n\n ${autoFlow &&\n css`\n grid-auto-flow: ${autoFlow};\n `}\n\n ${areas &&\n css`\n grid-template-areas: ${areas};\n `}\n\n ${template &&\n css`\n grid-template: ${template};\n `}\n\n ${typeof gap !== 'undefined' &&\n css`\n gap: calc(${gap} * ${props => props.theme.base.spacing});\n `}\n\n ${typeof colGap !== 'undefined' &&\n css`\n column-gap: calc(${colGap} * ${props => props.theme.base.spacing});\n `}\n\n ${typeof rowGap !== 'undefined' &&\n css`\n row-gap: calc(${rowGap} * ${props => props.theme.base.spacing});\n `}\n\n ${justifyItems &&\n css`\n justify-items: ${justifyItems};\n `}\n\n ${justifyContent &&\n css`\n justify-content: ${prefix(justifyContent)};\n `}\n\n ${alignItems &&\n css`\n align-items: ${alignItems};\n `}\n\n ${alignContent &&\n css`\n align-content: ${prefix(alignContent)};\n `}\n `;\n};\n\nconst getItemStyles = (props: GridProps['item']) => {\n if (!props) return;\n\n const {\n colStart,\n colEnd,\n colStartEnd,\n rowStart,\n rowEnd,\n rowStartEnd,\n area,\n justifySelf,\n alignSelf\n } = props;\n\n return css`\n ${colStart &&\n css`\n grid-column-start: ${colStart};\n `}\n\n ${colEnd &&\n css`\n grid-column-end: ${colEnd};\n `}\n\n ${colStartEnd &&\n css`\n grid-column: ${colStartEnd};\n `}\n\n ${rowStart &&\n css`\n grid-row-start: ${rowStart};\n `}\n\n ${rowEnd &&\n css`\n grid-row-end: ${rowEnd};\n `}\n\n ${rowStartEnd &&\n css`\n grid-row: ${rowStartEnd};\n `}\n\n ${area &&\n css`\n grid-area: ${area};\n `}\n\n ${justifySelf &&\n css`\n justify-self: ${justifySelf};\n `}\n\n ${alignSelf &&\n css`\n align-self: ${alignSelf};\n `}\n `;\n};\n\nconst breakpointOrder = ['xs', 'sm', 'md', 'lg', 'xl'] as const;\n\nexport const StyledGrid = styled.div<PropsWithDefaults<GridProps>>(props => {\n const {\n container,\n item,\n theme: {\n base: { breakpoints: themeBreakpoints }\n },\n xs,\n sm,\n md,\n lg,\n xl\n } = props;\n\n const breakpoints = {\n xs,\n sm,\n md,\n lg,\n xl\n };\n\n return css`\n ${getContainerStyles(container)}\n ${getItemStyles(item)}\n\n ${breakpointOrder.map(\n breakpoint =>\n breakpoints[breakpoint] &&\n css`\n @media screen and (min-width: ${themeBreakpoints[breakpoint]}) {\n ${getContainerStyles(breakpoints[breakpoint]?.container)}\n ${getItemStyles(breakpoints[breakpoint]?.item)}\n }\n `\n )}\n `;\n});\n\nStyledGrid.defaultProps = defaultThemeProp;\n\nconst Grid: FunctionComponent<GridProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<GridProps>, ref: GridProps['ref']) => {\n return <StyledGrid {...props} ref={ref} />;\n }\n);\n\nexport default Grid;\n"]}
@@ -45,7 +45,7 @@ const Icon = forwardRef(({ name, ...restProps }, ref) => {
45
45
  controller.abort();
46
46
  };
47
47
  }, [name]);
48
- return (_jsx(StyledIcon, Object.assign({}, restProps, { role: 'img', ref: ref, xmlns: 'http://www.w3.org/2000/svg', viewBox: iconDef.viewBox }, { children: _jsx(iconDef.Component, {}, void 0) }), void 0));
48
+ return (_jsx(StyledIcon, { ...restProps, role: 'img', ref: ref, xmlns: 'http://www.w3.org/2000/svg', viewBox: iconDef.viewBox, children: _jsx(iconDef.Component, {}, void 0) }, void 0));
49
49
  });
50
50
  export default Icon;
51
51
  //# sourceMappingURL=Icon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAoBvC,MAAM,YAAY,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,KAAmB,EAAE,EAAE;IACrD,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,YAAY,CAAC,GAAG,CAAC,IA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B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAC5B,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,CAAC;QACrE,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,KAAC,UAAU,oBACL,SAAS,IACb,IAAI,EAAC,KAAK,EACV,GAAG,EAAE,GAAG,EACR,KAAK,EAAC,4BAA4B,EAClC,OAAO,EAAE,OAAO,CAAC,OAAO,gBAExB,KAAC,OAAO,CAAC,SAAS,aAAG,YACV,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n useState,\n useEffect,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ComponentType\n} from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\n\nexport interface IconDefinition {\n Component: ComponentType;\n viewBox?: string;\n}\n\nexport interface IconModule extends IconDefinition {\n name: string;\n}\n\nexport interface IconProps extends BaseProps, NoChildrenProp {\n /** The name indicating the Cosmos Icon. Reference the catalog above for the available names. */\n name: string;\n /** Ref for the wrapping element. */\n ref?: Ref<SVGSVGElement>;\n}\n\nconst iconRegistry = new Map<string, IconDefinition>();\n\nexport const registerIcon = (...icons: IconModule[]) => {\n icons.forEach(({ name, ...iconDef }) => {\n if (!iconRegistry.has(name)) iconRegistry.set(name, iconDef);\n });\n};\n\nexport const forceRegisterIcon = (...icons: IconModule[]) => {\n icons.forEach(({ name, ...iconDef }) => {\n iconRegistry.set(name, iconDef);\n });\n};\n\nexport const StyledIcon = styled.svg`\n display: inline-block;\n fill: currentColor;\n height: 1.125rem;\n width: 1.125rem;\n vertical-align: middle;\n`;\n\nconst emptyIconDefinition: Readonly<IconDefinition> = Object.freeze({ Component: () => null });\n\nconst Icon: FunctionComponent<IconProps & ForwardProps> = forwardRef(\n ({ name, ...restProps }: PropsWithoutRef<IconProps>, ref: IconProps['ref']) => {\n const [iconDef, setIconDef] = useState(iconRegistry.get(name) ?? emptyIconDefinition);\n\n useEffect(() => {\n if (iconRegistry.has(name)) {\n setIconDef(iconRegistry.get(name)!);\n return;\n }\n\n const controller = new AbortController();\n import(`./icons/${encodeURIComponent(name)}.icon`)\n .then((module: IconModule) => {\n if (!module.name || !module.Component) throw new Error('Malformed icon definition');\n\n registerIcon(module);\n if (!controller.signal.aborted)\n setIconDef(iconRegistry.get(module.name) ?? emptyIconDefinition);\n })\n .catch(() => {\n if (!controller.signal.aborted) setIconDef(emptyIconDefinition);\n });\n\n return () => {\n controller.abort();\n };\n }, [name]);\n\n return (\n <StyledIcon\n {...restProps}\n role='img'\n ref={ref}\n xmlns='http://www.w3.org/2000/svg'\n viewBox={iconDef.viewBox}\n >\n <iconDef.Component />\n </StyledIcon>\n );\n }\n);\n\nexport default Icon;\n"]}
1
+ {"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAoBvC,MAAM,YAAY,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAG,KAAmB,EAAE,EAAE;IACrD,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE;QACrC,IAAI,CAAC,YAAY,CAAC,GAAG,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AC,CAAC;YAEpF,YAAY,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAC5B,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,CAAC;QACrE,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,KAAC,UAAU,OACL,SAAS,EACb,IAAI,EAAC,KAAK,EACV,GAAG,EAAE,GAAG,EACR,KAAK,EAAC,4BAA4B,EAClC,OAAO,EAAE,OAAO,CAAC,OAAO,YAExB,KAAC,OAAO,CAAC,SAAS,aAAG,WACV,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n useState,\n useEffect,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ComponentType\n} from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\n\nexport interface IconDefinition {\n Component: ComponentType;\n viewBox?: string;\n}\n\nexport interface IconModule extends IconDefinition {\n name: string;\n}\n\nexport interface IconProps extends BaseProps, NoChildrenProp {\n /** The name indicating the Cosmos Icon. Reference the catalog above for the available names. */\n name: string;\n /** Ref for the wrapping element. */\n ref?: Ref<SVGSVGElement>;\n}\n\nconst iconRegistry = new Map<string, IconDefinition>();\n\nexport const registerIcon = (...icons: IconModule[]) => {\n icons.forEach(({ name, ...iconDef }) => {\n if (!iconRegistry.has(name)) iconRegistry.set(name, iconDef);\n });\n};\n\nexport const forceRegisterIcon = (...icons: IconModule[]) => {\n icons.forEach(({ name, ...iconDef }) => {\n iconRegistry.set(name, iconDef);\n });\n};\n\nexport const StyledIcon = styled.svg`\n display: inline-block;\n fill: currentColor;\n height: 1.125rem;\n width: 1.125rem;\n vertical-align: middle;\n`;\n\nconst emptyIconDefinition: Readonly<IconDefinition> = Object.freeze({ Component: () => null });\n\nconst Icon: FunctionComponent<IconProps & ForwardProps> = forwardRef(\n ({ name, ...restProps }: PropsWithoutRef<IconProps>, ref: IconProps['ref']) => {\n const [iconDef, setIconDef] = useState(iconRegistry.get(name) ?? emptyIconDefinition);\n\n useEffect(() => {\n if (iconRegistry.has(name)) {\n setIconDef(iconRegistry.get(name)!);\n return;\n }\n\n const controller = new AbortController();\n import(`./icons/${encodeURIComponent(name)}.icon`)\n .then((module: IconModule) => {\n if (!module.name || !module.Component) throw new Error('Malformed icon definition');\n\n registerIcon(module);\n if (!controller.signal.aborted)\n setIconDef(iconRegistry.get(module.name) ?? emptyIconDefinition);\n })\n .catch(() => {\n if (!controller.signal.aborted) setIconDef(emptyIconDefinition);\n });\n\n return () => {\n controller.abort();\n };\n }, [name]);\n\n return (\n <StyledIcon\n {...restProps}\n role='img'\n ref={ref}\n xmlns='http://www.w3.org/2000/svg'\n viewBox={iconDef.viewBox}\n >\n <iconDef.Component />\n </StyledIcon>\n );\n }\n);\n\nexport default Icon;\n"]}
@@ -6,7 +6,7 @@ export const StyledImage = styled.img `
6
6
  `;
7
7
  const Image = forwardRef((props, ref) => {
8
8
  const { alt, ...restProps } = props;
9
- return _jsx(StyledImage, Object.assign({}, restProps, { alt: alt, ref: ref }), void 0);
9
+ return _jsx(StyledImage, { ...restProps, alt: alt, ref: ref }, void 0);
10
10
  });
11
11
  export default Image;
12
12
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../src/components/Image/Image.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA8D,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAWvC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEpC,CAAC;AAEF,MAAM,KAAK,GAAiD,UAAU,CACpE,CAAC,KAAkC,EAAE,GAA0B,EAAE,EAAE;IACjE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACpC,OAAO,KAAC,WAAW,oBAAK,SAAS,IAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,YAAI,CAAC;AAC5D,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, ImgHTMLAttributes, Ref, PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport { ForwardProps } from '../../types';\n\nexport interface ImageProps extends ImgHTMLAttributes<HTMLImageElement> {\n /** The HTML alt attribute for the image. */\n alt: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLImageElement>;\n}\n\nexport const StyledImage = styled.img`\n max-width: 100%;\n`;\n\nconst Image: FunctionComponent<ImageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ImageProps>, ref: Ref<HTMLImageElement>) => {\n const { alt, ...restProps } = props;\n return <StyledImage {...restProps} alt={alt} ref={ref} />;\n }\n);\n\nexport default Image;\n"]}
1
+ {"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../src/components/Image/Image.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA8D,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAWvC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEpC,CAAC;AAEF,MAAM,KAAK,GAAiD,UAAU,CACpE,CAAC,KAAkC,EAAE,GAA0B,EAAE,EAAE;IACjE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACpC,OAAO,KAAC,WAAW,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,WAAI,CAAC;AAC5D,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, ImgHTMLAttributes, Ref, PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport { ForwardProps } from '../../types';\n\nexport interface ImageProps extends ImgHTMLAttributes<HTMLImageElement> {\n /** The HTML alt attribute for the image. */\n alt: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLImageElement>;\n}\n\nexport const StyledImage = styled.img`\n max-width: 100%;\n`;\n\nconst Image: FunctionComponent<ImageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ImageProps>, ref: Ref<HTMLImageElement>) => {\n const { alt, ...restProps } = props;\n return <StyledImage {...restProps} alt={alt} ref={ref} />;\n }\n);\n\nexport default Image;\n"]}
@@ -16,17 +16,17 @@ const Input = forwardRef((props, ref) => {
16
16
  else if (hasProp(props, 'defaultValue')) {
17
17
  controlProp.defaultValue = defaultValue ?? '';
18
18
  }
19
- const Comp = (_jsx(StyledFormControl, Object.assign({}, {
20
- ref,
21
- id,
22
- required,
23
- disabled,
24
- status,
25
- ...controlProp,
26
- ...restProps,
27
- as: StyledInput
28
- }), void 0));
29
- return label ? (_jsx(FormField, Object.assign({}, { label, labelHidden, id, info, status, required, disabled, actions }, { children: Comp }), void 0)) : (Comp);
19
+ const Comp = (_jsx(StyledFormControl, { ...{
20
+ ref,
21
+ id,
22
+ required,
23
+ disabled,
24
+ status,
25
+ ...controlProp,
26
+ ...restProps,
27
+ as: StyledInput
28
+ } }, void 0));
29
+ return label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, required, disabled, actions }, children: Comp }, void 0)) : (Comp);
30
30
  });
31
31
  export default Input;
32
32
  //# sourceMappingURL=Input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sourceRoot":"","sources":["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AQ,EAAE,QAAQ,EAAE,OAAO,EAAE,cACjF,IAAI,YACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { FC, Ref, forwardRef, PropsWithoutRef } from 'react';\n\nimport { Action, BaseProps, ForwardProps } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { hasProp } from '../../utils';\nimport { useUID } from '../../hooks';\n\nimport StyledInput from './Input.styles';\n\nexport interface InputProps extends FormControlProps, BaseProps {\n /**\n * Specifies the type of input to be used.\n * @default \"text\"\n */\n type?:\n | 'text'\n | 'password'\n | 'number'\n | 'email'\n | 'url'\n | 'search'\n | 'tel'\n | 'date'\n | 'datetime-local'\n | 'time'\n | 'week'\n | 'month'\n | 'color';\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: Action[];\n}\n\nconst Input: FC<InputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<InputProps>, ref: Ref<HTMLInputElement>) => {\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 actions,\n ...restProps\n } = props;\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\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 Comp = (\n <StyledFormControl\n {...{\n ref,\n id,\n required,\n disabled,\n status,\n ...controlProp,\n ...restProps,\n as: StyledInput\n }}\n />\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, required, disabled, actions }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default Input;\n"]}
1
+ {"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":";AAAA,OA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I,WACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { FC, Ref, forwardRef, PropsWithoutRef } from 'react';\n\nimport { Action, BaseProps, ForwardProps } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { hasProp } from '../../utils';\nimport { useUID } from '../../hooks';\n\nimport StyledInput from './Input.styles';\n\nexport interface InputProps extends FormControlProps, BaseProps {\n /**\n * Specifies the type of input to be used.\n * @default \"text\"\n */\n type?:\n | 'text'\n | 'password'\n | 'number'\n | 'email'\n | 'url'\n | 'search'\n | 'tel'\n | 'date'\n | 'datetime-local'\n | 'time'\n | 'week'\n | 'month'\n | 'color';\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: Action[];\n}\n\nconst Input: FC<InputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<InputProps>, ref: Ref<HTMLInputElement>) => {\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 actions,\n ...restProps\n } = props;\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\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 Comp = (\n <StyledFormControl\n {...{\n ref,\n id,\n required,\n disabled,\n status,\n ...controlProp,\n ...restProps,\n as: StyledInput\n }}\n />\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, required, disabled, actions }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default Input;\n"]}
@@ -21,7 +21,7 @@ export const StyledLabel = styled.label(({ theme, labelHidden }) => {
21
21
  });
22
22
  StyledLabel.defaultProps = defaultThemeProp;
23
23
  const Label = forwardRef(({ children, labelHidden = false, ...restProps }, ref) => {
24
- return (_jsx(StyledLabel, Object.assign({ ref: ref, labelHidden: labelHidden }, restProps, { children: children }), void 0));
24
+ return (_jsx(StyledLabel, { ref: ref, labelHidden: labelHidden, ...restProps, children: children }, void 0));
25
25
  });
26
26
  export default Label;
27
27
  //# sourceMappingURL=Label.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../src/components/Label/Label.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAqB3D,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CACrC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE;IACzB,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC1B,OAAO,IAAI,CACT,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CACzC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,WAAW;QAChB,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,GAAG,CAAA;;uBAEY,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAa,CAAC;yBACvD,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC;mBAC5C,KAAK;SACf,CAAC;AACR,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5C,MAAM,KAAK,GAAiD,UAAU,CACpE,CACE,EAAE,QAAQ,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,SAAS,EAA+B,EAC5E,GAAsB,EACtB,EAAE;IACF,OAAO,CACL,KAAC,WAAW,kBAAC,GAAG,EAAE,GAA4B,EAAE,WAAW,EAAE,WAAW,IAAM,SAAS,cACpF,QAAQ,YACG,CACf,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, ReactNode, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually, readableColor, rgba } from 'polished';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize, FontSize } from '../../styles';\n\nexport interface LabelProps extends BaseProps {\n /**\n * HTML tag to render the label as.\n * @default \"label\"\n */\n as?: 'label' | 'legend' | 'div';\n /** Use to associate with a form-element's id. */\n htmlFor?: string;\n /**\n * Visually hides the label.\n * @default false\n */\n labelHidden?: boolean;\n /** Content/text for the label. */\n children: ReactNode;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLLabelElement | HTMLLegendElement>;\n}\n\nexport const StyledLabel = styled.label<Pick<LabelProps, 'labelHidden'>>(\n ({ theme, labelHidden }) => {\n const color = tryCatch(() => {\n return rgba(\n readableColor(theme.base.palette['primary-background']),\n theme.base.transparency['transparent-3']\n );\n });\n\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return labelHidden\n ? hideVisually\n : css`\n max-width: max-content;\n font-size: ${fontSize[theme.components.label['font-size'] as FontSize]};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n color: ${color};\n `;\n }\n);\n\nStyledLabel.defaultProps = defaultThemeProp;\n\nconst Label: FunctionComponent<LabelProps & ForwardProps> = forwardRef(\n (\n { children, labelHidden = false, ...restProps }: PropsWithoutRef<LabelProps>,\n ref: LabelProps['ref']\n ) => {\n return (\n <StyledLabel ref={ref as Ref<HTMLLabelElement>} labelHidden={labelHidden} {...restProps}>\n {children}\n </StyledLabel>\n );\n }\n);\n\nexport default Label;\n"]}
1
+ {"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../src/components/Label/Label.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAqB3D,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CACrC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE;IACzB,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE;QAC1B,OAAO,IAAI,CACT,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CACzC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,WAAW;QAChB,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,GAAG,CAAA;;uBAEY,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAa,CAAC;yBACvD,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC;mBAC5C,KAAK;SACf,CAAC;AACR,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5C,MAAM,KAAK,GAAiD,UAAU,CACpE,CACE,EAAE,QAAQ,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,SAAS,EAA+B,EAC5E,GAAsB,EACtB,EAAE;IACF,OAAO,CACL,KAAC,WAAW,IAAC,GAAG,EAAE,GAA4B,EAAE,WAAW,EAAE,WAAW,KAAM,SAAS,YACpF,QAAQ,WACG,CACf,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, ReactNode, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually, readableColor, rgba } from 'polished';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize, FontSize } from '../../styles';\n\nexport interface LabelProps extends BaseProps {\n /**\n * HTML tag to render the label as.\n * @default \"label\"\n */\n as?: 'label' | 'legend' | 'div';\n /** Use to associate with a form-element's id. */\n htmlFor?: string;\n /**\n * Visually hides the label.\n * @default false\n */\n labelHidden?: boolean;\n /** Content/text for the label. */\n children: ReactNode;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLLabelElement | HTMLLegendElement>;\n}\n\nexport const StyledLabel = styled.label<Pick<LabelProps, 'labelHidden'>>(\n ({ theme, labelHidden }) => {\n const color = tryCatch(() => {\n return rgba(\n readableColor(theme.base.palette['primary-background']),\n theme.base.transparency['transparent-3']\n );\n });\n\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return labelHidden\n ? hideVisually\n : css`\n max-width: max-content;\n font-size: ${fontSize[theme.components.label['font-size'] as FontSize]};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n color: ${color};\n `;\n }\n);\n\nStyledLabel.defaultProps = defaultThemeProp;\n\nconst Label: FunctionComponent<LabelProps & ForwardProps> = forwardRef(\n (\n { children, labelHidden = false, ...restProps }: PropsWithoutRef<LabelProps>,\n ref: LabelProps['ref']\n ) => {\n return (\n <StyledLabel ref={ref as Ref<HTMLLabelElement>} labelHidden={labelHidden} {...restProps}>\n {children}\n </StyledLabel>\n );\n }\n);\n\nexport default Label;\n"]}
@@ -100,7 +100,7 @@ const Link = forwardRef(({ href, variant = 'link', previewable, onPreview, ...re
100
100
  const onPreviewClick = () => {
101
101
  onPreview?.({ href });
102
102
  };
103
- return (_jsxs(_Fragment, { children: [_jsx(StyledLink, Object.assign({ href: href, variant: variant, ref: linkRef }, restProps, { onMouseEnter: onEnterLink, onMouseLeave: closePopover, onFocus: onEnterLink, onKeyUp: onKeyUp, onBlur: closePopover }), void 0), _jsxs(Popover, Object.assign({ show: popover, groupId: 'link_preview', showDelay: 'short', hideDelay: 'short', placement: 'bottom', target: linkRef.current, onMouseEnter: openPopover, onMouseLeave: closePopover, as: StyledLinkPopover, arrow: true }, { children: [_jsx(StyledLinkPopoverBtn, Object.assign({ preview: true, type: 'button', ref: previewBtnRef, onClick: onPreviewClick, tabIndex: 0, onFocus: openPopover, onKeyUp: onKeyUp }, { children: t('link_preview') }), void 0), _jsx(StyledLinkPopoverBtn, Object.assign({ forwardedAs: 'a', href: href, ref: openInTabBtnRef, target: '_blank', rel: 'noreferrer', onBlur: closePopover, onKeyUp: onKeyUp }, { children: t('link_open_in_tab') }), void 0)] }), void 0)] }, void 0));
103
+ return (_jsxs(_Fragment, { children: [_jsx(StyledLink, { href: href, variant: variant, ref: linkRef, ...restProps, onMouseEnter: onEnterLink, onMouseLeave: closePopover, onFocus: onEnterLink, onKeyUp: onKeyUp, onBlur: closePopover }, void 0), _jsxs(Popover, { show: popover, groupId: 'link_preview', showDelay: 'short', hideDelay: 'short', placement: 'bottom', target: linkRef.current, onMouseEnter: openPopover, onMouseLeave: closePopover, as: StyledLinkPopover, arrow: true, children: [_jsx(StyledLinkPopoverBtn, { preview: true, type: 'button', ref: previewBtnRef, onClick: onPreviewClick, tabIndex: 0, onFocus: openPopover, onKeyUp: onKeyUp, children: t('link_preview') }, void 0), _jsx(StyledLinkPopoverBtn, { forwardedAs: 'a', href: href, ref: openInTabBtnRef, target: '_blank', rel: 'noreferrer', onBlur: closePopover, onKeyUp: onKeyUp, children: t('link_open_in_tab') }, void 0)] }, void 0)] }, void 0));
104
104
  });
105
105
  export default Link;
106
106
  //# sourceMappingURL=Link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/components/Link/Link.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,MAAM,EAEP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,MAAuB,MAAM,WAAW,CAAC;AAChD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA2BjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;sBACrB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC;CAChF,CAAC;AAEF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AG,EAAE,OAAc,IACf,SAAS,IACb,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,YACpB,EAEF,MAAC,OAAO,kBACN,IAAI,EAAE,OAAO,EACb,OAAO,EAAC,cAAc,EACtB,SAAS,EAAC,OAAO,EACjB,SAAS,EAAC,OAAO,EACjB,SAAS,EAAC,QAAQ,EAClB,MAAM,EAAE,OAAO,CAAC,OAAO,EACvB,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,iBAAiB,EACrB,KAAK,uBAEL,KAAC,oBAAoB,kBACnB,OAAO,QACP,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,gBAEf,CAAC,CAAC,cAAc,CAAC,YACG,EACvB,KAAC,oBAAoB,kBACnB,WAAW,EAAC,GAAG,EACf,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,eAAe,EACpB,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,YAAY,EAChB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,gBAEf,CAAC,CAAC,kBAAkB,CAAC,YACD,aACf,YACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n ReactNode,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n useState,\n useRef,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport Button, { ButtonProps } from '../Button';\nimport Popover from '../Popover';\nimport BareButton from '../Button/BareButton';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useBreakpoint, useConsolidatedRef, useI18n } from '../../hooks';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize } from '../../styles';\n\nexport interface LinkProps extends BaseProps {\n /** Text or content for the Link. */\n children: ReactNode;\n /** URL or DOM id to navigate to. */\n href: string;\n /**\n * Controls the styling of the Link.\n * @default \"link\"\n */\n variant?: ButtonProps['variant'];\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Link. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: ButtonProps['icon'];\n /** Determines if the Link should render a popover when focused or hovered over. */\n previewable?: boolean;\n /** Callback function that is run when the preview popover is interacted with. */\n onPreview?: (e: { href: string }) => void;\n /** Specifies where to open the link href. */\n target?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement>;\n}\n\nexport const StyledLinkPopover = styled.div`\n background-color: ${props => props.theme.components.tooltip['background-color']};\n`;\n\nStyledLinkPopover.defaultProps = defaultThemeProp;\n\nexport const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {\n const contrastColor = tryCatch(() => readableColor(theme.base.palette.interactive));\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n position: relative;\n display: inline-flex;\n align-items: center;\n z-index: 1;\n padding: 0 ${theme.base.spacing};\n min-height: 1.5rem;\n line-height: 1;\n color: ${contrastColor};\n font-size: ${fontSize.xs};\n text-decoration: none;\n\n /* FIXME: Button selector specificity... */\n & + & {\n margin: 0;\n }\n\n &:nth-child(2)::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n bottom: 0;\n width: 1px; /* stylelint-disable-line unit-allowed-list */\n background-color: ${contrastColor};\n opacity: ${theme.base.transparency['transparent-3']};\n }\n\n &:nth-child(2) {\n /* stylelint-disable-next-line unit-allowed-list */\n margin-inline-start: -1px;\n }\n\n &:hover,\n &:active {\n text-decoration: underline;\n }\n\n &:focus {\n box-shadow: inset 0 0 0 0.0625rem ${theme.base.palette.light},\n 0 0 0.125rem 0.0625rem ${theme.base.palette.interactive};\n }\n `;\n});\n\nStyledLinkPopoverBtn.defaultProps = defaultThemeProp;\n\nexport const StyledLink = styled(Button)``;\n\nStyledLink.defaultProps = defaultThemeProp;\n\nconst Link: FunctionComponent<LinkProps & ForwardProps> = forwardRef(\n (\n { href, variant = 'link', previewable, onPreview, ...restProps }: PropsWithoutRef<LinkProps>,\n ref: LinkProps['ref']\n ) => {\n const linkRef = useConsolidatedRef(ref);\n const [popover, setPopover] = useState(false);\n const previewBtnRef = useRef<HTMLButtonElement>(null);\n const openInTabBtnRef = useRef<HTMLAnchorElement>(null);\n const isSmallOrAbove = useBreakpoint('sm');\n const t = useI18n();\n\n const openPopover = () => {\n if (isSmallOrAbove) setPopover(true);\n };\n\n const closePopover = () => {\n setPopover(false);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (event.keyCode === 27) {\n closePopover();\n }\n\n if (event.keyCode === 38 || event.keyCode === 40) {\n previewBtnRef?.current?.focus();\n }\n\n if (event.keyCode === 37 || event.keyCode === 39) {\n if (previewBtnRef.current === document.activeElement) {\n openInTabBtnRef?.current?.focus();\n } else {\n previewBtnRef?.current?.focus();\n }\n }\n };\n\n const onEnterLink = () => {\n if (previewable) openPopover();\n };\n\n const onPreviewClick = () => {\n onPreview?.({ href });\n };\n\n return (\n <>\n <StyledLink\n href={href}\n variant={variant}\n ref={linkRef as any}\n {...restProps}\n onMouseEnter={onEnterLink}\n onMouseLeave={closePopover}\n onFocus={onEnterLink}\n onKeyUp={onKeyUp}\n onBlur={closePopover}\n />\n\n <Popover\n show={popover}\n groupId='link_preview'\n showDelay='short'\n hideDelay='short'\n placement='bottom'\n target={linkRef.current}\n onMouseEnter={openPopover}\n onMouseLeave={closePopover}\n as={StyledLinkPopover}\n arrow\n >\n <StyledLinkPopoverBtn\n preview\n type='button'\n ref={previewBtnRef}\n onClick={onPreviewClick}\n tabIndex={0}\n onFocus={openPopover}\n onKeyUp={onKeyUp}\n >\n {t('link_preview')}\n </StyledLinkPopoverBtn>\n <StyledLinkPopoverBtn\n forwardedAs='a'\n href={href}\n ref={openInTabBtnRef}\n target='_blank'\n rel='noreferrer'\n onBlur={closePopover}\n onKeyUp={onKeyUp}\n >\n {t('link_open_in_tab')}\n </StyledLinkPopoverBtn>\n </Popover>\n </>\n );\n }\n);\n\nexport default Link;\n"]}
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/components/Link/Link.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,MAAM,EAEP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,MAAuB,MAAM,WAAW,CAAC;AAChD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA2BjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;sBACrB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC;CAChF,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACnE,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACpF,MAAM,QAAQ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B,MAAM,EAAE,OAAO,CAAC,OAAO,EACvB,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,iBAAiB,EACrB,KAAK,mBAEL,KAAC,oBAAoB,IACnB,OAAO,QACP,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,YAEf,CAAC,CAAC,cAAc,CAAC,WACG,EACvB,KAAC,oBAAoB,IACnB,WAAW,EAAC,GAAG,EACf,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,eAAe,EACpB,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,YAAY,EAChB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,YAEf,CAAC,CAAC,kBAAkB,CAAC,WACD,YACf,YACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n ReactNode,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n useState,\n useRef,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport Button, { ButtonProps } from '../Button';\nimport Popover from '../Popover';\nimport BareButton from '../Button/BareButton';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useBreakpoint, useConsolidatedRef, useI18n } from '../../hooks';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize } from '../../styles';\n\nexport interface LinkProps extends BaseProps {\n /** Text or content for the Link. */\n children: ReactNode;\n /** URL or DOM id to navigate to. */\n href: string;\n /**\n * Controls the styling of the Link.\n * @default \"link\"\n */\n variant?: ButtonProps['variant'];\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Link. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: ButtonProps['icon'];\n /** Determines if the Link should render a popover when focused or hovered over. */\n previewable?: boolean;\n /** Callback function that is run when the preview popover is interacted with. */\n onPreview?: (e: { href: string }) => void;\n /** Specifies where to open the link href. */\n target?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement>;\n}\n\nexport const StyledLinkPopover = styled.div`\n background-color: ${props => props.theme.components.tooltip['background-color']};\n`;\n\nStyledLinkPopover.defaultProps = defaultThemeProp;\n\nexport const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {\n const contrastColor = tryCatch(() => readableColor(theme.base.palette.interactive));\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n position: relative;\n display: inline-flex;\n align-items: center;\n z-index: 1;\n padding: 0 ${theme.base.spacing};\n min-height: 1.5rem;\n line-height: 1;\n color: ${contrastColor};\n font-size: ${fontSize.xs};\n text-decoration: none;\n\n /* FIXME: Button selector specificity... */\n & + & {\n margin: 0;\n }\n\n &:nth-child(2)::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n bottom: 0;\n width: 1px; /* stylelint-disable-line unit-allowed-list */\n background-color: ${contrastColor};\n opacity: ${theme.base.transparency['transparent-3']};\n }\n\n &:nth-child(2) {\n /* stylelint-disable-next-line unit-allowed-list */\n margin-inline-start: -1px;\n }\n\n &:hover,\n &:active {\n text-decoration: underline;\n }\n\n &:focus {\n box-shadow: inset 0 0 0 0.0625rem ${theme.base.palette.light},\n 0 0 0.125rem 0.0625rem ${theme.base.palette.interactive};\n }\n `;\n});\n\nStyledLinkPopoverBtn.defaultProps = defaultThemeProp;\n\nexport const StyledLink = styled(Button)``;\n\nStyledLink.defaultProps = defaultThemeProp;\n\nconst Link: FunctionComponent<LinkProps & ForwardProps> = forwardRef(\n (\n { href, variant = 'link', previewable, onPreview, ...restProps }: PropsWithoutRef<LinkProps>,\n ref: LinkProps['ref']\n ) => {\n const linkRef = useConsolidatedRef(ref);\n const [popover, setPopover] = useState(false);\n const previewBtnRef = useRef<HTMLButtonElement>(null);\n const openInTabBtnRef = useRef<HTMLAnchorElement>(null);\n const isSmallOrAbove = useBreakpoint('sm');\n const t = useI18n();\n\n const openPopover = () => {\n if (isSmallOrAbove) setPopover(true);\n };\n\n const closePopover = () => {\n setPopover(false);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (event.keyCode === 27) {\n closePopover();\n }\n\n if (event.keyCode === 38 || event.keyCode === 40) {\n previewBtnRef?.current?.focus();\n }\n\n if (event.keyCode === 37 || event.keyCode === 39) {\n if (previewBtnRef.current === document.activeElement) {\n openInTabBtnRef?.current?.focus();\n } else {\n previewBtnRef?.current?.focus();\n }\n }\n };\n\n const onEnterLink = () => {\n if (previewable) openPopover();\n };\n\n const onPreviewClick = () => {\n onPreview?.({ href });\n };\n\n return (\n <>\n <StyledLink\n href={href}\n variant={variant}\n ref={linkRef as any}\n {...restProps}\n onMouseEnter={onEnterLink}\n onMouseLeave={closePopover}\n onFocus={onEnterLink}\n onKeyUp={onKeyUp}\n onBlur={closePopover}\n />\n\n <Popover\n show={popover}\n groupId='link_preview'\n showDelay='short'\n hideDelay='short'\n placement='bottom'\n target={linkRef.current}\n onMouseEnter={openPopover}\n onMouseLeave={closePopover}\n as={StyledLinkPopover}\n arrow\n >\n <StyledLinkPopoverBtn\n preview\n type='button'\n ref={previewBtnRef}\n onClick={onPreviewClick}\n tabIndex={0}\n onFocus={openPopover}\n onKeyUp={onKeyUp}\n >\n {t('link_preview')}\n </StyledLinkPopoverBtn>\n <StyledLinkPopoverBtn\n forwardedAs='a'\n href={href}\n ref={openInTabBtnRef}\n target='_blank'\n rel='noreferrer'\n onBlur={closePopover}\n onKeyUp={onKeyUp}\n >\n {t('link_open_in_tab')}\n </StyledLinkPopoverBtn>\n </Popover>\n </>\n );\n }\n);\n\nexport default Link;\n"]}
@@ -50,12 +50,12 @@ const DynamicHeightValue = ({ children }) => {
50
50
  observer.disconnect();
51
51
  };
52
52
  }, [textRef.current, maxTextHeight]);
53
- return (_jsxs(_Fragment, { children: [_jsx(ExpandCollapse, Object.assign({ collapsed: collapsed, min: exceedsMaxHeight ? `${maxTextHeight}px` : 'max-content' }, { children: _jsx("div", Object.assign({ ref: textRef }, { children: children }), void 0) }), void 0), exceedsMaxHeight && (_jsx(Button, Object.assign({ variant: 'link', onClick: () => setCollapsed(current => !current) }, { children: collapsed ? t('show_more') : t('show_less') }), void 0))] }, void 0));
53
+ return (_jsxs(_Fragment, { children: [_jsx(ExpandCollapse, { collapsed: collapsed, min: exceedsMaxHeight ? `${maxTextHeight}px` : 'max-content', children: _jsx("div", { ref: textRef, children: children }, void 0) }, void 0), exceedsMaxHeight && (_jsx(Button, { variant: 'link', onClick: () => setCollapsed(current => !current), children: collapsed ? t('show_more') : t('show_less') }, void 0))] }, void 0));
54
54
  };
55
55
  const CommaSeparatedList = forwardRef(({ items, heading }, ref) => {
56
- return (_jsxs(StyledCommaSeparatedList, Object.assign({ ref: ref }, { children: [heading && _jsx(Text, Object.assign({ variant: 'h3' }, { children: heading }), void 0), _jsx(DynamicHeightValue, { children: _jsx("ul", Object.assign({ style: { listStyle: 'none' } }, { children: items.map((value, i) => (
56
+ return (_jsxs(StyledCommaSeparatedList, { ref: ref, children: [heading && _jsx(Text, { variant: 'h3', children: heading }, void 0), _jsx(DynamicHeightValue, { children: _jsx("ul", { style: { listStyle: 'none' }, children: items.map((value, i) => (
57
57
  // eslint-disable-next-line react/no-array-index-key
58
- _jsx(StyledCommaSeparatedListItem, { children: value }, i))) }), void 0) }, void 0)] }), void 0));
58
+ _jsx(StyledCommaSeparatedListItem, { children: value }, i))) }, void 0) }, void 0)] }, void 0));
59
59
  });
60
60
  export default CommaSeparatedList;
61
61
  //# sourceMappingURL=CommaSeparatedList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommaSeparatedList.js","sourceRoot":"","sources":["../../../src/components/List/CommaSeparatedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EACV,QAAQ,EAGR,eAAe,EACf,OAAO,EACP,MAAM,EACP,MA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AAC,CAAC,WAAW,CAAC,YACrC,CACV,YACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAA8D,UAAU,CAC9F,CACE,EAAE,KAAK,EAAE,OAAO,EAA4C,EAC5D,GAAmC,EACnC,EAAE;IACF,OAAO,CACL,MAAC,wBAAwB,kBAAC,GAAG,EAAE,GAAG,iBAC/B,OAAO,IAAI,KAAC,IAAI,kBAAC,OAAO,EAAC,IAAI,gBAAE,OAAO,YAAQ,EAC/C,KAAC,kBAAkB,cACjB,2BAAI,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,gBAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;oBACvB,oDAAoD;oBACpD,KAAC,4BAA4B,cAAU,KAAK,IAAT,CAAC,CAAwC,CAC7E,CAAC,YACC,WACc,aACI,CAC5B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import {\n FunctionComponent,\n ReactNode,\n forwardRef,\n useState,\n PropsWithoutRef,\n Ref,\n useLayoutEffect,\n useMemo,\n useRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useI18n } from '../../hooks';\nimport Button from '../Button';\nimport Text from '../Text';\nimport ExpandCollapse from '../ExpandCollapse';\nimport { windowIsAvailable } from '../../utils';\n\nexport interface CommaSeparatedListProps extends BaseProps {\n /** List content. */\n items: ReactNode[];\n /** List Heading. */\n heading?: string;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledCommaSeparatedList = styled.div(({ theme }) => {\n return css`\n padding: ${theme.base.spacing};\n h3 {\n padding-block-end: calc(2 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledCommaSeparatedList.defaultProps = defaultThemeProp;\n\nexport const StyledCommaSeparatedListItem = styled.li`\n display: inline;\n\n &:not(:last-child)::after {\n content: ', ';\n }\n`;\n\nconst DynamicHeightValue = ({ children }: { children: ReactNode }): JSX.Element => {\n const [collapsed, setCollapsed] = useState(true);\n const [exceedsMaxHeight, setExceedsMaxHeight] = useState(false);\n const textRef = useRef<HTMLDivElement>(null);\n const t = useI18n();\n\n const maxTextHeight = useMemo(() => {\n if (!windowIsAvailable) return Infinity;\n\n const computedLineHeight =\n Number.parseInt(\n window.getComputedStyle(document.documentElement).getPropertyValue('font-size'),\n 10\n ) * 1.25;\n\n return 3 * computedLineHeight;\n }, []);\n\n useLayoutEffect(() => {\n if (!textRef.current) return;\n\n const observer = new ResizeObserver(entries => {\n const exceedsHeight = entries.some(({ target, contentRect }) => {\n if (target !== textRef.current) return;\n\n return contentRect.height > maxTextHeight;\n });\n\n setExceedsMaxHeight(exceedsHeight);\n });\n\n observer.observe(textRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [textRef.current, maxTextHeight]);\n\n return (\n <>\n <ExpandCollapse\n collapsed={collapsed}\n min={exceedsMaxHeight ? `${maxTextHeight}px` : 'max-content'}\n >\n <div ref={textRef}>{children}</div>\n </ExpandCollapse>\n {exceedsMaxHeight && (\n <Button variant='link' onClick={() => setCollapsed(current => !current)}>\n {collapsed ? t('show_more') : t('show_less')}\n </Button>\n )}\n </>\n );\n};\n\nconst CommaSeparatedList: FunctionComponent<CommaSeparatedListProps & ForwardProps> = forwardRef(\n (\n { items, heading }: PropsWithoutRef<CommaSeparatedListProps>,\n ref: CommaSeparatedListProps['ref']\n ) => {\n return (\n <StyledCommaSeparatedList ref={ref}>\n {heading && <Text variant='h3'>{heading}</Text>}\n <DynamicHeightValue>\n <ul style={{ listStyle: 'none' }}>\n {items.map((value, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <StyledCommaSeparatedListItem key={i}>{value}</StyledCommaSeparatedListItem>\n ))}\n </ul>\n </DynamicHeightValue>\n </StyledCommaSeparatedList>\n );\n }\n);\n\nexport default CommaSeparatedList;\n"]}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C,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,YACpE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WACrC,CACV,YACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAA8D,UAAU,CAC9F,CACE,EAAE,KAAK,EAAE,OAAO,EAA4C,EAC5D,GAAmC,EACnC,EAAE;IACF,OAAO,CACL,MAAC,wBAAwB,IAAC,GAAG,EAAE,GAAG,aAC/B,OAAO,IAAI,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,WAAQ,EAC/C,KAAC,kBAAkB,cACjB,aAAI,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;oBACvB,oDAAoD;oBACpD,KAAC,4BAA4B,cAAU,KAAK,IAAT,CAAC,CAAwC,CAC7E,CAAC,WACC,WACc,YACI,CAC5B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import {\n FunctionComponent,\n ReactNode,\n forwardRef,\n useState,\n PropsWithoutRef,\n Ref,\n useLayoutEffect,\n useMemo,\n useRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useI18n } from '../../hooks';\nimport Button from '../Button';\nimport Text from '../Text';\nimport ExpandCollapse from '../ExpandCollapse';\nimport { windowIsAvailable } from '../../utils';\n\nexport interface CommaSeparatedListProps extends BaseProps {\n /** List content. */\n items: ReactNode[];\n /** List Heading. */\n heading?: string;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledCommaSeparatedList = styled.div(({ theme }) => {\n return css`\n padding: ${theme.base.spacing};\n h3 {\n padding-block-end: calc(2 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledCommaSeparatedList.defaultProps = defaultThemeProp;\n\nexport const StyledCommaSeparatedListItem = styled.li`\n display: inline;\n\n &:not(:last-child)::after {\n content: ', ';\n }\n`;\n\nconst DynamicHeightValue = ({ children }: { children: ReactNode }): JSX.Element => {\n const [collapsed, setCollapsed] = useState(true);\n const [exceedsMaxHeight, setExceedsMaxHeight] = useState(false);\n const textRef = useRef<HTMLDivElement>(null);\n const t = useI18n();\n\n const maxTextHeight = useMemo(() => {\n if (!windowIsAvailable) return Infinity;\n\n const computedLineHeight =\n Number.parseInt(\n window.getComputedStyle(document.documentElement).getPropertyValue('font-size'),\n 10\n ) * 1.25;\n\n return 3 * computedLineHeight;\n }, []);\n\n useLayoutEffect(() => {\n if (!textRef.current) return;\n\n const observer = new ResizeObserver(entries => {\n const exceedsHeight = entries.some(({ target, contentRect }) => {\n if (target !== textRef.current) return;\n\n return contentRect.height > maxTextHeight;\n });\n\n setExceedsMaxHeight(exceedsHeight);\n });\n\n observer.observe(textRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [textRef.current, maxTextHeight]);\n\n return (\n <>\n <ExpandCollapse\n collapsed={collapsed}\n min={exceedsMaxHeight ? `${maxTextHeight}px` : 'max-content'}\n >\n <div ref={textRef}>{children}</div>\n </ExpandCollapse>\n {exceedsMaxHeight && (\n <Button variant='link' onClick={() => setCollapsed(current => !current)}>\n {collapsed ? t('show_more') : t('show_less')}\n </Button>\n )}\n </>\n );\n};\n\nconst CommaSeparatedList: FunctionComponent<CommaSeparatedListProps & ForwardProps> = forwardRef(\n (\n { items, heading }: PropsWithoutRef<CommaSeparatedListProps>,\n ref: CommaSeparatedListProps['ref']\n ) => {\n return (\n <StyledCommaSeparatedList ref={ref}>\n {heading && <Text variant='h3'>{heading}</Text>}\n <DynamicHeightValue>\n <ul style={{ listStyle: 'none' }}>\n {items.map((value, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <StyledCommaSeparatedListItem key={i}>{value}</StyledCommaSeparatedListItem>\n ))}\n </ul>\n </DynamicHeightValue>\n </StyledCommaSeparatedList>\n );\n }\n);\n\nexport default CommaSeparatedList;\n"]}
@@ -50,7 +50,7 @@ const List = forwardRef(({ items, variant, count, onToggleShow, depth = 0, headi
50
50
  _jsx(StyledSublistItem, { children: _jsx(List, { depth: depth + 1, variant: variant, items: value }, void 0) }, idx)) : (
51
51
  // eslint-disable-next-line react/no-array-index-key
52
52
  _jsx("li", { children: value }, idx)));
53
- return (_jsxs(StyledList, Object.assign({}, restProps, { ref: ref, depth: depth, listType: (variant === 'ordered' ? olTypes : ulTypes)[depth % 3] }, { children: [heading && _jsx(Text, Object.assign({ variant: 'h3' }, { children: heading }), void 0), variant === 'ordered' ? _jsx("ol", { children: listContent }, void 0) : _jsx("ul", { children: listContent }, void 0), count && onToggleShow && (_jsx(Button, Object.assign({ variant: 'link', onClick: onToggleShow }, { children: count > items.flat().length ? t('show_more') : t('show_less') }), void 0))] }), void 0));
53
+ return (_jsxs(StyledList, { ...restProps, ref: ref, depth: depth, listType: (variant === 'ordered' ? olTypes : ulTypes)[depth % 3], children: [heading && _jsx(Text, { variant: 'h3', children: heading }, void 0), variant === 'ordered' ? _jsx("ol", { children: listContent }, void 0) : _jsx("ul", { children: listContent }, void 0), count && onToggleShow && (_jsx(Button, { variant: 'link', onClick: onToggleShow, children: count > items.flat().length ? t('show_more') : t('show_less') }, void 0))] }, void 0));
54
54
  });
55
55
  export default List;
56
56
  //# sourceMappingURL=List.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/components/List/List.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,UAAU,EAAwB,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/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css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport Button from '../Button';\nimport Text from '../Text';\nimport { useI18n } from '../../hooks';\n\nexport interface ListProps extends BaseProps {\n /** List content. */\n items: ReactNode[];\n /** List Heading. */\n heading?: string;\n /** Number of list items that need to be shown. */\n count?: number;\n /** Callback to display more/less items. */\n onToggleShow?: () => void;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ninterface VisualListProps extends ListProps {\n /** Type of list. */\n variant: 'ordered' | 'unordered';\n /** Depth of list (used for recursion). */\n depth?: number;\n}\n\nconst olTypes = ['decimal', 'lower-alpha', 'lower-roman'] as const;\nconst ulTypes = ['disc', 'circle', 'square'] as const;\n\nexport const StyledList = styled.div<{\n depth: number;\n listType: typeof olTypes[number] | typeof ulTypes[number];\n}>(({ theme, depth, listType }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n padding-inline-start: calc(2 * ${theme.base.spacing});\n list-style-position: inside;\n h3 {\n margin-block-end: calc(2 * ${theme.base.spacing});\n }\n\n & > ol,\n & > ul {\n list-style-type: ${listType};\n\n & > li {\n &:not(:last-child) {\n margin-block-end: calc(0.5 * ${theme.base.spacing});\n }\n\n ${depth > 0\n ? css`\n font-size: ${fontSize.xs};\n `\n : css`\n &::marker {\n font-weight: ${theme.base['font-weight'].bold};\n }\n `}\n }\n }\n `;\n});\n\nStyledList.defaultProps = defaultThemeProp;\n\nexport const StyledSublistItem = styled.li`\n list-style: none;\n`;\n\nconst List: FunctionComponent<VisualListProps & ForwardProps> = forwardRef(\n (\n {\n items,\n variant,\n count,\n onToggleShow,\n depth = 0,\n heading,\n ...restProps\n }: PropsWithoutRef<VisualListProps>,\n ref: VisualListProps['ref']\n ) => {\n const t = useI18n();\n const listContent = items.map((value, idx) =>\n Array.isArray(value) ? (\n // eslint-disable-next-line react/no-array-index-key\n <StyledSublistItem key={idx}>\n <List depth={depth + 1} variant={variant} items={value} />\n </StyledSublistItem>\n ) : (\n // eslint-disable-next-line react/no-array-index-key\n <li key={idx}>{value}</li>\n )\n );\n\n return (\n <StyledList\n {...restProps}\n ref={ref}\n depth={depth}\n listType={(variant === 'ordered' ? olTypes : ulTypes)[depth % 3]}\n >\n {heading && <Text variant='h3'>{heading}</Text>}\n {variant === 'ordered' ? <ol>{listContent}</ol> : <ul>{listContent}</ul>}\n {count && onToggleShow && (\n <Button variant='link' onClick={onToggleShow}>\n {count > items.flat().length ? t('show_more') : t('show_less')}\n </Button>\n )}\n </StyledList>\n );\n }\n);\n\nexport default List;\n"]}
1
+ {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/components/List/List.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgC,UAAU,EAAwB,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsBtC,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,CAAU,CAAC;AACnE,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAGjC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAChC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;I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AO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,aAE/D,OAAO,IAAI,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,WAAQ,EAC9C,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAK,WAAW,WAAM,CAAC,CAAC,CAAC,uBAAK,WAAW,WAAM,EACvE,KAAK,IAAI,YAAY,IAAI,CACxB,KAAC,MAAM,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,YAAY,YACzC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WACvD,CACV,YACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { FunctionComponent, ReactNode, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport Button from '../Button';\nimport Text from '../Text';\nimport { useI18n } from '../../hooks';\n\nexport interface ListProps extends BaseProps {\n /** List content. */\n items: ReactNode[];\n /** List Heading. */\n heading?: string;\n /** Number of list items that need to be shown. */\n count?: number;\n /** Callback to display more/less items. */\n onToggleShow?: () => void;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ninterface VisualListProps extends ListProps {\n /** Type of list. */\n variant: 'ordered' | 'unordered';\n /** Depth of list (used for recursion). */\n depth?: number;\n}\n\nconst olTypes = ['decimal', 'lower-alpha', 'lower-roman'] as const;\nconst ulTypes = ['disc', 'circle', 'square'] as const;\n\nexport const StyledList = styled.div<{\n depth: number;\n listType: typeof olTypes[number] | typeof ulTypes[number];\n}>(({ theme, depth, listType }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n padding-inline-start: calc(2 * ${theme.base.spacing});\n list-style-position: inside;\n h3 {\n margin-block-end: calc(2 * ${theme.base.spacing});\n }\n\n & > ol,\n & > ul {\n list-style-type: ${listType};\n\n & > li {\n &:not(:last-child) {\n margin-block-end: calc(0.5 * ${theme.base.spacing});\n }\n\n ${depth > 0\n ? css`\n font-size: ${fontSize.xs};\n `\n : css`\n &::marker {\n font-weight: ${theme.base['font-weight'].bold};\n }\n `}\n }\n }\n `;\n});\n\nStyledList.defaultProps = defaultThemeProp;\n\nexport const StyledSublistItem = styled.li`\n list-style: none;\n`;\n\nconst List: FunctionComponent<VisualListProps & ForwardProps> = forwardRef(\n (\n {\n items,\n variant,\n count,\n onToggleShow,\n depth = 0,\n heading,\n ...restProps\n }: PropsWithoutRef<VisualListProps>,\n ref: VisualListProps['ref']\n ) => {\n const t = useI18n();\n const listContent = items.map((value, idx) =>\n Array.isArray(value) ? (\n // eslint-disable-next-line react/no-array-index-key\n <StyledSublistItem key={idx}>\n <List depth={depth + 1} variant={variant} items={value} />\n </StyledSublistItem>\n ) : (\n // eslint-disable-next-line react/no-array-index-key\n <li key={idx}>{value}</li>\n )\n );\n\n return (\n <StyledList\n {...restProps}\n ref={ref}\n depth={depth}\n listType={(variant === 'ordered' ? olTypes : ulTypes)[depth % 3]}\n >\n {heading && <Text variant='h3'>{heading}</Text>}\n {variant === 'ordered' ? <ol>{listContent}</ol> : <ul>{listContent}</ul>}\n {count && onToggleShow && (\n <Button variant='link' onClick={onToggleShow}>\n {count > items.flat().length ? t('show_more') : t('show_less')}\n </Button>\n )}\n </StyledList>\n );\n }\n);\n\nexport default List;\n"]}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import List from './List';
4
- const OrderedList = forwardRef((props, ref) => _jsx(List, Object.assign({}, props, { variant: 'ordered', ref: ref }), void 0));
4
+ const OrderedList = forwardRef((props, ref) => _jsx(List, { ...props, variant: 'ordered', ref: ref }, void 0));
5
5
  export default OrderedList;
6
6
  //# sourceMappingURL=OrderedList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OrderedList.js","sourceRoot":"","sources":["../../../src/components/List/OrderedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,IAAmB,MAAM,QAAQ,CAAC;AAEzC,MAAM,WAAW,GAAiC,UAAU,CAC1D,CAAC,KAAgB,EAAE,GAAqB,EAAE,EAAE,CAAC,KAAC,IAAI,oBAAK,KAAK,IAAE,OAAO,EAAC,SAAS,EAAC,GAAG,EAAE,GAAG,YAAI,CAC7F,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC, forwardRef } from 'react';\n\nimport { ForwardProps } from '../../types';\n\nimport List, { ListProps } from './List';\n\nconst OrderedList: FC<ListProps & ForwardProps> = forwardRef(\n (props: ListProps, ref: ListProps['ref']) => <List {...props} variant='ordered' ref={ref} />\n);\n\nexport default OrderedList;\n"]}
1
+ {"version":3,"file":"OrderedList.js","sourceRoot":"","sources":["../../../src/components/List/OrderedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,IAAmB,MAAM,QAAQ,CAAC;AAEzC,MAAM,WAAW,GAAiC,UAAU,CAC1D,CAAC,KAAgB,EAAE,GAAqB,EAAE,EAAE,CAAC,KAAC,IAAI,OAAK,KAAK,EAAE,OAAO,EAAC,SAAS,EAAC,GAAG,EAAE,GAAG,WAAI,CAC7F,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC, forwardRef } from 'react';\n\nimport { ForwardProps } from '../../types';\n\nimport List, { ListProps } from './List';\n\nconst OrderedList: FC<ListProps & ForwardProps> = forwardRef(\n (props: ListProps, ref: ListProps['ref']) => <List {...props} variant='ordered' ref={ref} />\n);\n\nexport default OrderedList;\n"]}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import List from './List';
4
- const UnorderedList = forwardRef((props, ref) => _jsx(List, Object.assign({}, props, { variant: 'unordered', ref: ref }), void 0));
4
+ const UnorderedList = forwardRef((props, ref) => _jsx(List, { ...props, variant: 'unordered', ref: ref }, void 0));
5
5
  export default UnorderedList;
6
6
  //# sourceMappingURL=UnorderedList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnorderedList.js","sourceRoot":"","sources":["../../../src/components/List/UnorderedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,IAAmB,MAAM,QAAQ,CAAC;AAEzC,MAAM,aAAa,GAAiC,UAAU,CAC5D,CAAC,KAAgB,EAAE,GAAqB,EAAE,EAAE,CAAC,KAAC,IAAI,oBAAK,KAAK,IAAE,OAAO,EAAC,WAAW,EAAC,GAAG,EAAE,GAAG,YAAI,CAC/F,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, forwardRef } from 'react';\n\nimport { ForwardProps } from '../../types';\n\nimport List, { ListProps } from './List';\n\nconst UnorderedList: FC<ListProps & ForwardProps> = forwardRef(\n (props: ListProps, ref: ListProps['ref']) => <List {...props} variant='unordered' ref={ref} />\n);\n\nexport default UnorderedList;\n"]}
1
+ {"version":3,"file":"UnorderedList.js","sourceRoot":"","sources":["../../../src/components/List/UnorderedList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,IAAmB,MAAM,QAAQ,CAAC;AAEzC,MAAM,aAAa,GAAiC,UAAU,CAC5D,CAAC,KAAgB,EAAE,GAAqB,EAAE,EAAE,CAAC,KAAC,IAAI,OAAK,KAAK,EAAE,OAAO,EAAC,WAAW,EAAC,GAAG,EAAE,GAAG,WAAI,CAC/F,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, forwardRef } from 'react';\n\nimport { ForwardProps } from '../../types';\n\nimport List, { ListProps } from './List';\n\nconst UnorderedList: FC<ListProps & ForwardProps> = forwardRef(\n (props: ListProps, ref: ListProps['ref']) => <List {...props} variant='unordered' ref={ref} />\n);\n\nexport default UnorderedList;\n"]}
@@ -43,7 +43,7 @@ const CurrentLocationButton = ({ onChange, onError, defaultToCurrentLocation })
43
43
  loadMapsAPI(name, providerOpts).then(getCurrentLocation);
44
44
  }
45
45
  }, []);
46
- return (_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ ref: setEl, as: StyledCurrentLocationButton, variant: 'simple', icon: true, onClick: getCurrentLocation, "aria-label": t('my_current_location_button_a11y'), currentLocationDisabled: currentLocationDisabled }, { children: _jsx(Icon, { name: 'location' }, void 0) }), void 0), el && currentLocationDisabled && (_jsx(Tooltip, Object.assign({ shown: true, target: el }, { children: t('allow_location_permissions_text') }), void 0))] }, void 0));
46
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { ref: setEl, as: StyledCurrentLocationButton, variant: 'simple', icon: true, onClick: getCurrentLocation, "aria-label": t('my_current_location_button_a11y'), currentLocationDisabled: currentLocationDisabled, children: _jsx(Icon, { name: 'location' }, void 0) }, void 0), el && currentLocationDisabled && (_jsx(Tooltip, { shown: true, target: el, children: t('allow_location_permissions_text') }, void 0))] }, void 0));
47
47
  };
48
48
  export default CurrentLocationButton;
49
49
  //# sourceMappingURL=CurrentLocationButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrentLocationButton.js","sourceRoot":"","sources":["../../../src/components/Location/CurrentLocationButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC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jC,MAAM,KAAK,CAAC;QACd,CAAC,CAAC;aACD,IAAI,CAAC,UAAU,CAAC;aAChB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC;aACpC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAExB,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YAClE,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE;gBAC7B,0BAA0B,CAAC,IAAI,CAAC,CAAC;aAClC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,wBAAwB,EAAE;YAC5B,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SAC1D;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,8BACE,KAAC,MAAM,kBACL,GAAG,EAAE,KAAK,EACV,EAAE,EAAE,2BAA2B,EAC/B,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,kBAAkB,gBACf,CAAC,CAAC,iCAAiC,CAAC,EAChD,uBAAuB,EAAE,uBAAuB,gBAEhD,KAAC,IAAI,IAAC,IAAI,EAAC,UAAU,WAAG,YACjB,EACR,EAAE,IAAI,uBAAuB,IAAI,CAChC,KAAC,OAAO,kBAAC,KAAK,QAAC,MAAM,EAAE,EAAE,gBACtB,CAAC,CAAC,iCAAiC,CAAC,YAC7B,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,qBAAqB,CAAC","sourcesContent":["import { FC, useCallback, useContext, useEffect, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Tooltip from '../Tooltip';\nimport { useElement, useI18n } from '../../hooks';\nimport Icon, { registerIcon } from '../Icon';\nimport * as locationIcon from '../Icon/icons/location.icon';\nimport Button from '../Button';\nimport { defaultThemeProp } from '../../theme';\n\nimport MapsContext from './MapsContext';\nimport { getNavigatorPosition, getAddress, loadMapsAPI } from './utils';\n\nregisterIcon(locationIcon);\n\nexport type CurrentLocationButtonProps = {\n /** Callback fired after click on my current location button if location was found. */\n onChange?: (value: {\n name: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n }) => void;\n /** Callback fired when an error occurs. */\n onError?: (error: Error) => void;\n /** Get current location on component first render */\n defaultToCurrentLocation?: boolean;\n};\n\nexport const StyledCurrentLocationButton = styled(Button)<{ currentLocationDisabled: boolean }>(\n ({\n currentLocationDisabled,\n theme: {\n base: { 'disabled-opacity': disabledOpacity }\n }\n }) => css`\n ${currentLocationDisabled &&\n css`\n opacity: ${disabledOpacity};\n cursor: auto;\n `}\n `\n);\n\nStyledCurrentLocationButton.defaultProps = defaultThemeProp;\n\nconst CurrentLocationButton: FC<CurrentLocationButtonProps> = ({\n onChange,\n onError,\n defaultToCurrentLocation\n}: CurrentLocationButtonProps) => {\n const t = useI18n();\n const { name, ...providerOpts } = useContext(MapsContext);\n const [currentLocationDisabled, setCurrentLocationDisabled] = useState(false);\n const [el, setEl] = useElement();\n\n const getCurrentLocation = useCallback(() => {\n getNavigatorPosition()\n .catch(error => {\n setCurrentLocationDisabled(true);\n throw error;\n })\n .then(getAddress)\n .then(address => onChange?.(address))\n .catch(error => onError?.(error));\n }, [onChange, onError]);\n\n useEffect(() => {\n navigator.permissions?.query({ name: 'geolocation' }).then(result => {\n if (result.state === 'denied') {\n setCurrentLocationDisabled(true);\n }\n });\n if (defaultToCurrentLocation) {\n loadMapsAPI(name, providerOpts).then(getCurrentLocation);\n }\n }, []);\n\n return (\n <>\n <Button\n ref={setEl}\n as={StyledCurrentLocationButton}\n variant='simple'\n icon\n onClick={getCurrentLocation}\n aria-label={t('my_current_location_button_a11y')}\n currentLocationDisabled={currentLocationDisabled}\n >\n <Icon name='location' />\n </Button>\n {el && currentLocationDisabled && (\n <Tooltip shown target={el}>\n {t('allow_location_permissions_text')}\n </Tooltip>\n )}\n </>\n );\n};\nexport default CurrentLocationButton;\n"]}
1
+ {"version":3,"file":"CurrentLocationButton.js","sourceRoot":"","sources":["../../../src/components/Location/CurrentLocationButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAC5D,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExE,YAAY,CAAC,YAAY,CAAC,CAAC;AAgB3B,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,MAAM,CAAC,CACvD,CAAC,EACC,uBAAuB,EACvB,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,kBAAkB,EAAE,eAAe,EAAE,EAC9C,EACF,EAAE,EAAE,CAAC,GAAG,CAAA;MACL,uBAAuB;IACzB,GAAG,CAAA;iBACU,eAAe;;KAE3B;GACF,CACF,CAAC;AAEF,2BAA2B,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5D,MAAM,qBAAqB,GAAmC,CAAC,EAC7D,QAAQ,EACR,OA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AE,EAAE,2BAA2B,EAC/B,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,kBAAkB,gBACf,CAAC,CAAC,iCAAiC,CAAC,EAChD,uBAAuB,EAAE,uBAAuB,YAEhD,KAAC,IAAI,IAAC,IAAI,EAAC,UAAU,WAAG,WACjB,EACR,EAAE,IAAI,uBAAuB,IAAI,CAChC,KAAC,OAAO,IAAC,KAAK,QAAC,MAAM,EAAE,EAAE,YACtB,CAAC,CAAC,iCAAiC,CAAC,WAC7B,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,qBAAqB,CAAC","sourcesContent":["import { FC, useCallback, useContext, useEffect, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Tooltip from '../Tooltip';\nimport { useElement, useI18n } from '../../hooks';\nimport Icon, { registerIcon } from '../Icon';\nimport * as locationIcon from '../Icon/icons/location.icon';\nimport Button from '../Button';\nimport { defaultThemeProp } from '../../theme';\n\nimport MapsContext from './MapsContext';\nimport { getNavigatorPosition, getAddress, loadMapsAPI } from './utils';\n\nregisterIcon(locationIcon);\n\nexport type CurrentLocationButtonProps = {\n /** Callback fired after click on my current location button if location was found. */\n onChange?: (value: {\n name: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n }) => void;\n /** Callback fired when an error occurs. */\n onError?: (error: Error) => void;\n /** Get current location on component first render */\n defaultToCurrentLocation?: boolean;\n};\n\nexport const StyledCurrentLocationButton = styled(Button)<{ currentLocationDisabled: boolean }>(\n ({\n currentLocationDisabled,\n theme: {\n base: { 'disabled-opacity': disabledOpacity }\n }\n }) => css`\n ${currentLocationDisabled &&\n css`\n opacity: ${disabledOpacity};\n cursor: auto;\n `}\n `\n);\n\nStyledCurrentLocationButton.defaultProps = defaultThemeProp;\n\nconst CurrentLocationButton: FC<CurrentLocationButtonProps> = ({\n onChange,\n onError,\n defaultToCurrentLocation\n}: CurrentLocationButtonProps) => {\n const t = useI18n();\n const { name, ...providerOpts } = useContext(MapsContext);\n const [currentLocationDisabled, setCurrentLocationDisabled] = useState(false);\n const [el, setEl] = useElement();\n\n const getCurrentLocation = useCallback(() => {\n getNavigatorPosition()\n .catch(error => {\n setCurrentLocationDisabled(true);\n throw error;\n })\n .then(getAddress)\n .then(address => onChange?.(address))\n .catch(error => onError?.(error));\n }, [onChange, onError]);\n\n useEffect(() => {\n navigator.permissions?.query({ name: 'geolocation' }).then(result => {\n if (result.state === 'denied') {\n setCurrentLocationDisabled(true);\n }\n });\n if (defaultToCurrentLocation) {\n loadMapsAPI(name, providerOpts).then(getCurrentLocation);\n }\n }, []);\n\n return (\n <>\n <Button\n ref={setEl}\n as={StyledCurrentLocationButton}\n variant='simple'\n icon\n onClick={getCurrentLocation}\n aria-label={t('my_current_location_button_a11y')}\n currentLocationDisabled={currentLocationDisabled}\n >\n <Icon name='location' />\n </Button>\n {el && currentLocationDisabled && (\n <Tooltip shown target={el}>\n {t('allow_location_permissions_text')}\n </Tooltip>\n )}\n </>\n );\n};\nexport default CurrentLocationButton;\n"]}
@@ -7,13 +7,13 @@ import MapsContext from './MapsContext';
7
7
  const LocationDisplay = forwardRef(({ value = '', displayText, variant = 'text-map', height = '25rem', zoomLevel = 13, ...restProps }, ref) => {
8
8
  const { name } = useContext(MapsContext);
9
9
  const valueString = typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;
10
- return !value ? (_jsx(Text, Object.assign({ ref: ref }, restProps, { "aria-hidden": 'true' }, { children: _jsx("span", Object.assign({ "aria-hidden": 'true' }, { children: "\u2013\u2013" }), void 0) }), void 0)) : (_jsxs(_Fragment, { children: [(variant === 'text' || variant === 'text-map') &&
11
- (name === 'google' ? (_jsx(Link, Object.assign({ ref: ref }, restProps, { target: '_blank', rel: 'noopener noreferrer', href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`)}` }, { children: displayText || valueString }), void 0)) : (_jsx(Text, Object.assign({ ref: ref }, restProps, { children: displayText || valueString }), void 0))), (variant === 'text-map' || variant === 'map') && (_jsx(LocationView, Object.assign({}, {
12
- location: value,
13
- centerMapOnChange: true,
14
- height,
15
- zoomLevel
16
- }), void 0))] }, void 0));
10
+ return !value ? (_jsx(Text, { ref: ref, ...restProps, "aria-hidden": 'true', children: _jsx("span", { "aria-hidden": 'true', children: "\u2013\u2013" }, void 0) }, void 0)) : (_jsxs(_Fragment, { children: [(variant === 'text' || variant === 'text-map') &&
11
+ (name === 'google' ? (_jsx(Link, { ref: ref, ...restProps, target: '_blank', rel: 'noopener noreferrer', href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`)}`, children: displayText || valueString }, void 0)) : (_jsx(Text, { ref: ref, ...restProps, children: displayText || valueString }, void 0))), (variant === 'text-map' || variant === 'map') && (_jsx(LocationView, { ...{
12
+ location: value,
13
+ centerMapOnChange: true,
14
+ height,
15
+ zoomLevel
16
+ } }, void 0))] }, void 0));
17
17
  });
18
18
  export default LocationDisplay;
19
19
  //# sourceMappingURL=LocationDisplay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationDisplay.js","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,UAAU,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AA2BxC,MAAM,eAAe,GAA2D,UAAU,CACxF,CACE,EACE,KAAK,GAAG,EAAE,EACV,WAAW,EACX,OAAO,GAAG,UAAU,EACpB,MAAM,GAAG,OAAO,EAChB,SAAS,GAAG,EAAE,EACd,GAAG,SAAS,EAC0B,EACxC,GAAgC,EAChC,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAEzC,MAAM,WAAW,GACf,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,KAAK,KAAK,EAAE,SAAS,EAAE,CAAC;IAEhF,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CACd,KAAC,IAAI,kBAAC,GAAG,EAAE,GAA2B,IAAM,SAAS,mBAAc,MAAM,gBACvE,4CAAkB,MAAM,0CAAsB,YACzC,CACR,CAAC,CAAC,CAAC,CACF,8BACG,CAAC,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,UAAU,CAAC;gBAC7C,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CACnB,KAAC,IAAI,kBACH,GAAG,EAAE,GAA6B,IAC9B,SAAS,IACb,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,IAAI,EAAE,mDAAmD,kBAAkB,CACzE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,QAAQ,KAAK,KAAK,EAAE,SAAS,EAAE,CAC9E,EAAE,gBAEF,WAAW,IAAI,WAAW,YACtB,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,kBAAC,GAAG,EAAE,GAA2B,IAAM,SAAS,cAClD,WAAW,IAAI,WAAW,YACtB,CACR,CAAC,EACH,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,CAAC,IAAI,CAChD,KAAC,YAAY,oBACP;gBACF,QAAQ,EAAE,KAAK;gBACf,iBAAiB,EAAE,IAAI;gBACvB,MAAM;gBACN,SAAS;aACV,UACD,CACH,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useContext } from 'react';\n\nimport Text from '../Text';\nimport Link from '../Link';\nimport { BaseProps, ForwardProps } from '../../types';\n\nimport LocationView from './LocationView';\nimport MapsContext from './MapsContext';\nimport { LatLng } from './types';\n\nexport interface LocationDisplayProps extends BaseProps {\n /** Location address or coordinates */\n value?: string | LatLng;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default \"text-map\"\n */\n variant?: 'text-map' | 'text' | 'map';\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: string;\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: number;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst LocationDisplay: FunctionComponent<LocationDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value = '',\n displayText,\n variant = 'text-map',\n height = '25rem',\n zoomLevel = 13,\n ...restProps\n }: PropsWithoutRef<LocationDisplayProps>,\n ref: LocationDisplayProps['ref']\n ) => {\n const { name } = useContext(MapsContext);\n\n const valueString =\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;\n\n return !value ? (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps} aria-hidden='true'>\n <span aria-hidden='true'>&ndash;&ndash;</span>\n </Text>\n ) : (\n <>\n {(variant === 'text' || variant === 'text-map') &&\n (name === 'google' ? (\n <Link\n ref={ref as Ref<HTMLAnchorElement>}\n {...restProps}\n target='_blank'\n rel='noopener noreferrer'\n href={`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`\n )}`}\n >\n {displayText || valueString}\n </Link>\n ) : (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayText || valueString}\n </Text>\n ))}\n {(variant === 'text-map' || variant === 'map') && (\n <LocationView\n {...{\n location: value,\n centerMapOnChange: true,\n height,\n zoomLevel\n }}\n />\n )}\n </>\n );\n }\n);\n\nexport default LocationDisplay;\n"]}
1
+ {"version":3,"file":"LocationDisplay.js","sourceRoot":"","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E,EAAE,YAEF,WAAW,IAAI,WAAW,WACtB,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,GAAG,EAAE,GAA2B,KAAM,SAAS,YAClD,WAAW,IAAI,WAAW,WACtB,CACR,CAAC,EACH,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,CAAC,IAAI,CAChD,KAAC,YAAY,OACP;oBACF,QAAQ,EAAE,KAAK;oBACf,iBAAiB,EAAE,IAAI;oBACvB,MAAM;oBACN,SAAS;iBACV,WACD,CACH,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useContext } from 'react';\n\nimport Text from '../Text';\nimport Link from '../Link';\nimport { BaseProps, ForwardProps } from '../../types';\n\nimport LocationView from './LocationView';\nimport MapsContext from './MapsContext';\nimport { LatLng } from './types';\n\nexport interface LocationDisplayProps extends BaseProps {\n /** Location address or coordinates */\n value?: string | LatLng;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default \"text-map\"\n */\n variant?: 'text-map' | 'text' | 'map';\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: string;\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: number;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst LocationDisplay: FunctionComponent<LocationDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value = '',\n displayText,\n variant = 'text-map',\n height = '25rem',\n zoomLevel = 13,\n ...restProps\n }: PropsWithoutRef<LocationDisplayProps>,\n ref: LocationDisplayProps['ref']\n ) => {\n const { name } = useContext(MapsContext);\n\n const valueString =\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;\n\n return !value ? (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps} aria-hidden='true'>\n <span aria-hidden='true'>&ndash;&ndash;</span>\n </Text>\n ) : (\n <>\n {(variant === 'text' || variant === 'text-map') &&\n (name === 'google' ? (\n <Link\n ref={ref as Ref<HTMLAnchorElement>}\n {...restProps}\n target='_blank'\n rel='noopener noreferrer'\n href={`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`\n )}`}\n >\n {displayText || valueString}\n </Link>\n ) : (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayText || valueString}\n </Text>\n ))}\n {(variant === 'text-map' || variant === 'map') && (\n <LocationView\n {...{\n location: value,\n centerMapOnChange: true,\n height,\n zoomLevel\n }}\n />\n )}\n </>\n );\n }\n);\n\nexport default LocationDisplay;\n"]}