@pega/cosmos-react-core 2.0.0-dev.11.0 → 2.0.0-dev.14.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 (455) hide show
  1. package/README.md +3 -3
  2. package/lib/components/Actions/Actions.js +1 -1
  3. package/lib/components/Actions/Actions.js.map +1 -1
  4. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  5. package/lib/components/AppShell/AppHeader.js +1 -6
  6. package/lib/components/AppShell/AppHeader.js.map +1 -1
  7. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  8. package/lib/components/AppShell/AppShell.js +14 -32
  9. package/lib/components/AppShell/AppShell.js.map +1 -1
  10. package/lib/components/AppShell/AppShell.styles.d.ts +3 -2
  11. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  12. package/lib/components/AppShell/AppShell.styles.js +36 -24
  13. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  14. package/lib/components/AppShell/AppShellList.js +10 -13
  15. package/lib/components/AppShell/AppShellList.js.map +1 -1
  16. package/lib/components/AppShell/Drawer.js +3 -6
  17. package/lib/components/AppShell/Drawer.js.map +1 -1
  18. package/lib/components/AppShell/Operator.js +1 -3
  19. package/lib/components/AppShell/Operator.js.map +1 -1
  20. package/lib/components/AppShell/SkipNavigation.js +2 -2
  21. package/lib/components/AppShell/SkipNavigation.js.map +1 -1
  22. package/lib/components/Avatar/Avatar.js +3 -4
  23. package/lib/components/Avatar/Avatar.js.map +1 -1
  24. package/lib/components/Backdrop/Backdrop.d.ts +1 -1
  25. package/lib/components/Backdrop/Backdrop.d.ts.map +1 -1
  26. package/lib/components/Backdrop/Backdrop.js +6 -5
  27. package/lib/components/Backdrop/Backdrop.js.map +1 -1
  28. package/lib/components/Badges/Selection.js +7 -8
  29. package/lib/components/Badges/Selection.js.map +1 -1
  30. package/lib/components/Banner/Banner.js +2 -6
  31. package/lib/components/Banner/Banner.js.map +1 -1
  32. package/lib/components/Boolean/BooleanDisplay.js +1 -2
  33. package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
  34. package/lib/components/Breadcrumbs/Breadcrumbs.js +2 -5
  35. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  36. package/lib/components/Button/Button.d.ts +5 -0
  37. package/lib/components/Button/Button.d.ts.map +1 -1
  38. package/lib/components/Button/Button.js +16 -9
  39. package/lib/components/Button/Button.js.map +1 -1
  40. package/lib/components/Card/Card.d.ts.map +1 -1
  41. package/lib/components/Card/Card.js +2 -1
  42. package/lib/components/Card/Card.js.map +1 -1
  43. package/lib/components/Card/CardContent.d.ts.map +1 -1
  44. package/lib/components/Card/CardContent.js +4 -3
  45. package/lib/components/Card/CardContent.js.map +1 -1
  46. package/lib/components/Card/CardFooter.d.ts.map +1 -1
  47. package/lib/components/Card/CardFooter.js +3 -2
  48. package/lib/components/Card/CardFooter.js.map +1 -1
  49. package/lib/components/Card/CardHeader.d.ts.map +1 -1
  50. package/lib/components/Card/CardHeader.js +5 -5
  51. package/lib/components/Card/CardHeader.js.map +1 -1
  52. package/lib/components/Card/CollapsibleCard.js +2 -6
  53. package/lib/components/Card/CollapsibleCard.js.map +1 -1
  54. package/lib/components/ColorPicker/ColorPicker.js +6 -9
  55. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  56. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  57. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  58. package/lib/components/ComboBox/ComboBox.js +14 -20
  59. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  60. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  61. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +11 -19
  62. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  63. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  64. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +3 -3
  65. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  66. package/lib/components/Configuration/Configuration.js +8 -10
  67. package/lib/components/Configuration/Configuration.js.map +1 -1
  68. package/lib/components/Currency/CurrencyInput.js +2 -2
  69. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  70. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  71. package/lib/components/DateTime/Input/DateInput.js +18 -23
  72. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  73. package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
  74. package/lib/components/DateTime/Input/DateRangeInput.js +10 -16
  75. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  76. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  77. package/lib/components/DateTime/Input/DateTimeInput.js +27 -37
  78. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  79. package/lib/components/DateTime/Input/DayOfWeekInput.d.ts.map +1 -1
  80. package/lib/components/DateTime/Input/DayOfWeekInput.js +6 -4
  81. package/lib/components/DateTime/Input/DayOfWeekInput.js.map +1 -1
  82. package/lib/components/DateTime/Input/Duration/DurationInput.d.ts.map +1 -1
  83. package/lib/components/DateTime/Input/Duration/DurationInput.js +2 -2
  84. package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
  85. package/lib/components/DateTime/Input/Duration/NumberUnit.js +3 -4
  86. package/lib/components/DateTime/Input/Duration/NumberUnit.js.map +1 -1
  87. package/lib/components/DateTime/Input/Duration/Time.js +7 -10
  88. package/lib/components/DateTime/Input/Duration/Time.js.map +1 -1
  89. package/lib/components/DateTime/Input/MonthInput.js +9 -13
  90. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  91. package/lib/components/DateTime/Input/PartInput.js +2 -3
  92. package/lib/components/DateTime/Input/PartInput.js.map +1 -1
  93. package/lib/components/DateTime/Input/TimeInput.js +16 -23
  94. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  95. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  96. package/lib/components/DateTime/Input/WeekInput.js +16 -20
  97. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  98. package/lib/components/DateTime/Input/useAutoFocusNextInput.js +4 -7
  99. package/lib/components/DateTime/Input/useAutoFocusNextInput.js.map +1 -1
  100. package/lib/components/DateTime/Input/usePickerButton.js +4 -4
  101. package/lib/components/DateTime/Input/usePickerButton.js.map +1 -1
  102. package/lib/components/DateTime/Input/utils.d.ts +2 -0
  103. package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
  104. package/lib/components/DateTime/Input/utils.js +38 -10
  105. package/lib/components/DateTime/Input/utils.js.map +1 -1
  106. package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
  107. package/lib/components/DateTime/Picker/Calendar.js +24 -30
  108. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  109. package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -2
  110. package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
  111. package/lib/components/DateTime/Picker/Calendar.styles.js +2 -2
  112. package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
  113. package/lib/components/DateTime/Picker/DatePicker.js +5 -10
  114. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  115. package/lib/components/DateTime/Picker/DateRangePicker.js +5 -10
  116. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  117. package/lib/components/DateTime/Picker/TimePicker.js +5 -6
  118. package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
  119. package/lib/components/DateTime/Picker/Weeks.js +7 -9
  120. package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
  121. package/lib/components/Drawer/Drawer.js +5 -5
  122. package/lib/components/Drawer/Drawer.js.map +1 -1
  123. package/lib/components/EmojiPicker/EmojiDisplay.d.ts.map +1 -1
  124. package/lib/components/EmojiPicker/EmojiDisplay.js +1 -1
  125. package/lib/components/EmojiPicker/EmojiDisplay.js.map +1 -1
  126. package/lib/components/EmojiPicker/EmojiPicker.js +2 -3
  127. package/lib/components/EmojiPicker/EmojiPicker.js.map +1 -1
  128. package/lib/components/EmptyState/EmptyState.d.ts +14 -0
  129. package/lib/components/EmptyState/EmptyState.d.ts.map +1 -0
  130. package/lib/components/{NoItems/NoItems.js → EmptyState/EmptyState.js} +6 -7
  131. package/lib/components/EmptyState/EmptyState.js.map +1 -0
  132. package/lib/components/EmptyState/index.d.ts +4 -0
  133. package/lib/components/EmptyState/index.d.ts.map +1 -0
  134. package/lib/components/EmptyState/index.js +3 -0
  135. package/lib/components/EmptyState/index.js.map +1 -0
  136. package/lib/components/ErrorState/ErrorState.d.ts +2 -0
  137. package/lib/components/ErrorState/ErrorState.d.ts.map +1 -1
  138. package/lib/components/ErrorState/ErrorState.js +3 -3
  139. package/lib/components/ErrorState/ErrorState.js.map +1 -1
  140. package/lib/components/ExpandCollapse/ExpandCollapse.js +4 -4
  141. package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
  142. package/lib/components/FieldGroup/FieldGroup.js +2 -5
  143. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  144. package/lib/components/FieldGroup/FieldGroupList.js +1 -2
  145. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  146. package/lib/components/FieldValueList/FieldValueList.js +2 -4
  147. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  148. package/lib/components/File/FileDisplay.d.ts +4 -1
  149. package/lib/components/File/FileDisplay.d.ts.map +1 -1
  150. package/lib/components/File/FileDisplay.js.map +1 -1
  151. package/lib/components/File/FileInput.d.ts +1 -1
  152. package/lib/components/File/FileInput.d.ts.map +1 -1
  153. package/lib/components/File/FileInput.js +7 -12
  154. package/lib/components/File/FileInput.js.map +1 -1
  155. package/lib/components/File/FileItem.js +2 -3
  156. package/lib/components/File/FileItem.js.map +1 -1
  157. package/lib/components/File/FileUploadItem.js +3 -3
  158. package/lib/components/File/FileUploadItem.js.map +1 -1
  159. package/lib/components/File/FileVisual.js +2 -4
  160. package/lib/components/File/FileVisual.js.map +1 -1
  161. package/lib/components/File/utils.js +1 -2
  162. package/lib/components/File/utils.js.map +1 -1
  163. package/lib/components/Flex/Flex.d.ts +2 -2
  164. package/lib/components/Flex/Flex.d.ts.map +1 -1
  165. package/lib/components/Flex/Flex.js.map +1 -1
  166. package/lib/components/Form/Form.js +1 -3
  167. package/lib/components/Form/Form.js.map +1 -1
  168. package/lib/components/FormControl/FormControl.d.ts +1 -1
  169. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  170. package/lib/components/FormField/FormField.js +5 -10
  171. package/lib/components/FormField/FormField.js.map +1 -1
  172. package/lib/components/Grid/Grid.d.ts +1 -1
  173. package/lib/components/Grid/Grid.d.ts.map +1 -1
  174. package/lib/components/Grid/Grid.js +5 -8
  175. package/lib/components/Grid/Grid.js.map +1 -1
  176. package/lib/components/Icon/Icon.js +2 -4
  177. package/lib/components/Icon/Icon.js.map +1 -1
  178. package/lib/components/Icon/icons/compass-solid.icon.js +1 -2
  179. package/lib/components/Icon/icons/compass-solid.icon.js.map +1 -1
  180. package/lib/components/Icon/icons/dataviz-table-with-bars.icon.js +1 -4
  181. package/lib/components/Icon/icons/dataviz-table-with-bars.icon.js.map +1 -1
  182. package/lib/components/Icon/icons/dataviz-table-with-cross.icon.js +1 -2
  183. package/lib/components/Icon/icons/dataviz-table-with-cross.icon.js.map +1 -1
  184. package/lib/components/Icon/icons/dataviz-waterfall.icon.js +1 -5
  185. package/lib/components/Icon/icons/dataviz-waterfall.icon.js.map +1 -1
  186. package/lib/components/Icon/icons/filetype-text.icon.js +1 -4
  187. package/lib/components/Icon/icons/filetype-text.icon.js.map +1 -1
  188. package/lib/components/Icon/icons/folder-dollar.icon.js +1 -2
  189. package/lib/components/Icon/icons/folder-dollar.icon.js.map +1 -1
  190. package/lib/components/Icon/icons/freeze-column.icon.js +1 -2
  191. package/lib/components/Icon/icons/freeze-column.icon.js.map +1 -1
  192. package/lib/components/Icon/icons/galaxy.icon.js +1 -3
  193. package/lib/components/Icon/icons/galaxy.icon.js.map +1 -1
  194. package/lib/components/Icon/icons/grad-solid.icon.js +1 -2
  195. package/lib/components/Icon/icons/grad-solid.icon.js.map +1 -1
  196. package/lib/components/Icon/icons/grad.icon.js +1 -5
  197. package/lib/components/Icon/icons/grad.icon.js.map +1 -1
  198. package/lib/components/Icon/icons/list-number.icon.js +1 -6
  199. package/lib/components/Icon/icons/list-number.icon.js.map +1 -1
  200. package/lib/components/Icon/icons/list.icon.js +1 -6
  201. package/lib/components/Icon/icons/list.icon.js.map +1 -1
  202. package/lib/components/Icon/icons/pin.icon.js +1 -2
  203. package/lib/components/Icon/icons/pin.icon.js.map +1 -1
  204. package/lib/components/Icon/icons/search-solid.icon.js +1 -2
  205. package/lib/components/Icon/icons/search-solid.icon.js.map +1 -1
  206. package/lib/components/Icon/icons/tracer.icon.js +1 -2
  207. package/lib/components/Icon/icons/tracer.icon.js.map +1 -1
  208. package/lib/components/Icon/icons/tribox-solid.icon.js +1 -3
  209. package/lib/components/Icon/icons/tribox-solid.icon.js.map +1 -1
  210. package/lib/components/Icon/icons/tribox.icon.js +1 -3
  211. package/lib/components/Icon/icons/tribox.icon.js.map +1 -1
  212. package/lib/components/Input/Input.js +2 -2
  213. package/lib/components/Input/Input.js.map +1 -1
  214. package/lib/components/Input/Input.styles.js +2 -2
  215. package/lib/components/Input/Input.styles.js.map +1 -1
  216. package/lib/components/Link/Link.js +5 -8
  217. package/lib/components/Link/Link.js.map +1 -1
  218. package/lib/components/Location/CurrentLocationButton.js +4 -6
  219. package/lib/components/Location/CurrentLocationButton.js.map +1 -1
  220. package/lib/components/Location/LocationDisplay.js +2 -3
  221. package/lib/components/Location/LocationDisplay.js.map +1 -1
  222. package/lib/components/Location/LocationInput.js +8 -9
  223. package/lib/components/Location/LocationInput.js.map +1 -1
  224. package/lib/components/Location/LocationView.js +8 -13
  225. package/lib/components/Location/LocationView.js.map +1 -1
  226. package/lib/components/Location/utils.js +11 -15
  227. package/lib/components/Location/utils.js.map +1 -1
  228. package/lib/components/Menu/FlyoutMenuList.d.ts.map +1 -1
  229. package/lib/components/Menu/FlyoutMenuList.js +11 -14
  230. package/lib/components/Menu/FlyoutMenuList.js.map +1 -1
  231. package/lib/components/Menu/Menu.js +18 -20
  232. package/lib/components/Menu/Menu.js.map +1 -1
  233. package/lib/components/Menu/Menu.styles.d.ts +10 -0
  234. package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
  235. package/lib/components/Menu/Menu.styles.js +198 -3
  236. package/lib/components/Menu/Menu.styles.js.map +1 -1
  237. package/lib/components/Menu/Menu.types.d.ts +17 -8
  238. package/lib/components/Menu/Menu.types.d.ts.map +1 -1
  239. package/lib/components/Menu/Menu.types.js.map +1 -1
  240. package/lib/components/Menu/MenuGroup.d.ts +6 -0
  241. package/lib/components/Menu/MenuGroup.d.ts.map +1 -0
  242. package/lib/components/Menu/MenuGroup.js +17 -0
  243. package/lib/components/Menu/MenuGroup.js.map +1 -0
  244. package/lib/components/Menu/MenuItem.d.ts +0 -3
  245. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  246. package/lib/components/Menu/MenuItem.js +35 -151
  247. package/lib/components/Menu/MenuItem.js.map +1 -1
  248. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  249. package/lib/components/Menu/MenuList.js +19 -23
  250. package/lib/components/Menu/MenuList.js.map +1 -1
  251. package/lib/components/Menu/MenuListHeader.d.ts +0 -1
  252. package/lib/components/Menu/MenuListHeader.d.ts.map +1 -1
  253. package/lib/components/Menu/MenuListHeader.js +5 -55
  254. package/lib/components/Menu/MenuListHeader.js.map +1 -1
  255. package/lib/components/Menu/NavItemsList.d.ts.map +1 -1
  256. package/lib/components/Menu/NavItemsList.js +2 -3
  257. package/lib/components/Menu/NavItemsList.js.map +1 -1
  258. package/lib/components/Menu/helpers.d.ts +13 -12
  259. package/lib/components/Menu/helpers.d.ts.map +1 -1
  260. package/lib/components/Menu/helpers.js +40 -36
  261. package/lib/components/Menu/helpers.js.map +1 -1
  262. package/lib/components/Menu/index.d.ts +2 -3
  263. package/lib/components/Menu/index.d.ts.map +1 -1
  264. package/lib/components/Menu/index.js +1 -2
  265. package/lib/components/Menu/index.js.map +1 -1
  266. package/lib/components/MenuButton/MenuButton.js +6 -10
  267. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  268. package/lib/components/Modal/MinimizedModal.js +10 -13
  269. package/lib/components/Modal/MinimizedModal.js.map +1 -1
  270. package/lib/components/Modal/Modal.d.ts +1 -6
  271. package/lib/components/Modal/Modal.d.ts.map +1 -1
  272. package/lib/components/Modal/Modal.js +40 -137
  273. package/lib/components/Modal/Modal.js.map +1 -1
  274. package/lib/components/Modal/Modal.styles.d.ts +9 -0
  275. package/lib/components/Modal/Modal.styles.d.ts.map +1 -0
  276. package/lib/components/Modal/Modal.styles.js +133 -0
  277. package/lib/components/Modal/Modal.styles.js.map +1 -0
  278. package/lib/components/Modal/Modal.types.d.ts +19 -4
  279. package/lib/components/Modal/Modal.types.d.ts.map +1 -1
  280. package/lib/components/Modal/Modal.types.js.map +1 -1
  281. package/lib/components/Modal/ModalManager.js +12 -21
  282. package/lib/components/Modal/ModalManager.js.map +1 -1
  283. package/lib/components/MultiStep/MultiStep.js +3 -6
  284. package/lib/components/MultiStep/MultiStep.js.map +1 -1
  285. package/lib/components/MultiStep/MultiStep.styles.js +1 -1
  286. package/lib/components/MultiStep/MultiStep.styles.js.map +1 -1
  287. package/lib/components/Number/NumberInput.js +13 -19
  288. package/lib/components/Number/NumberInput.js.map +1 -1
  289. package/lib/components/Number/NumberInput.styles.d.ts +2 -2
  290. package/lib/components/Number/NumberInput.styles.d.ts.map +1 -1
  291. package/lib/components/Number/utils.js +2 -3
  292. package/lib/components/Number/utils.js.map +1 -1
  293. package/lib/components/PageTemplates/CategorySubPage.d.ts +1 -1
  294. package/lib/components/PageTemplates/CategorySubPage.d.ts.map +1 -1
  295. package/lib/components/PageTemplates/CategorySubPage.js +6 -16
  296. package/lib/components/PageTemplates/CategorySubPage.js.map +1 -1
  297. package/lib/components/PageTemplates/DashboardPage.js +3 -8
  298. package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
  299. package/lib/components/PageTemplates/PageTemplates.d.ts +2 -0
  300. package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
  301. package/lib/components/PageTemplates/PageTemplates.js +22 -32
  302. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  303. package/lib/components/Pagination/Pagination.js +2 -4
  304. package/lib/components/Pagination/Pagination.js.map +1 -1
  305. package/lib/components/Phone/PhoneDisplay.js +1 -2
  306. package/lib/components/Phone/PhoneDisplay.js.map +1 -1
  307. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  308. package/lib/components/Phone/PhoneInput.js +12 -10
  309. package/lib/components/Phone/PhoneInput.js.map +1 -1
  310. package/lib/components/Phone/utils.js +2 -3
  311. package/lib/components/Phone/utils.js.map +1 -1
  312. package/lib/components/Popover/Popover.js +4 -7
  313. package/lib/components/Popover/Popover.js.map +1 -1
  314. package/lib/components/Progress/Bar.js +1 -1
  315. package/lib/components/Progress/Bar.js.map +1 -1
  316. package/lib/components/Progress/Ellipsis.js +1 -3
  317. package/lib/components/Progress/Ellipsis.js.map +1 -1
  318. package/lib/components/Progress/Progress.js +2 -3
  319. package/lib/components/Progress/Progress.js.map +1 -1
  320. package/lib/components/Progress/Ring.js +2 -3
  321. package/lib/components/Progress/Ring.js.map +1 -1
  322. package/lib/components/RadioCheck/RadioCheck.js +6 -7
  323. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  324. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +7 -6
  325. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  326. package/lib/components/Rating/Rating.js +2 -6
  327. package/lib/components/Rating/Rating.js.map +1 -1
  328. package/lib/components/SearchInput/SearchInput.js +10 -12
  329. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  330. package/lib/components/Select/Select.js +2 -2
  331. package/lib/components/Select/Select.js.map +1 -1
  332. package/lib/components/Sentiment/Sentiment.js +1 -2
  333. package/lib/components/Sentiment/Sentiment.js.map +1 -1
  334. package/lib/components/Slider/Slider.js +7 -13
  335. package/lib/components/Slider/Slider.js.map +1 -1
  336. package/lib/components/Slider/Slider.styles.d.ts +1 -1
  337. package/lib/components/Slider/Slider.styles.js +1 -1
  338. package/lib/components/Slider/Slider.styles.js.map +1 -1
  339. package/lib/components/Slider/SliderTicks.js +1 -2
  340. package/lib/components/Slider/SliderTicks.js.map +1 -1
  341. package/lib/components/Slider/utils.d.ts +0 -10
  342. package/lib/components/Slider/utils.d.ts.map +1 -1
  343. package/lib/components/Slider/utils.js +3 -15
  344. package/lib/components/Slider/utils.js.map +1 -1
  345. package/lib/components/SummaryItem/SummaryItem.js +1 -4
  346. package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
  347. package/lib/components/SummaryList/SummaryList.d.ts +8 -2
  348. package/lib/components/SummaryList/SummaryList.d.ts.map +1 -1
  349. package/lib/components/SummaryList/SummaryList.js +9 -10
  350. package/lib/components/SummaryList/SummaryList.js.map +1 -1
  351. package/lib/components/SummaryList/ViewAll.d.ts +1 -1
  352. package/lib/components/SummaryList/ViewAll.d.ts.map +1 -1
  353. package/lib/components/SummaryList/ViewAll.js +7 -10
  354. package/lib/components/SummaryList/ViewAll.js.map +1 -1
  355. package/lib/components/Switch/Switch.d.ts.map +1 -1
  356. package/lib/components/Switch/Switch.js +39 -30
  357. package/lib/components/Switch/Switch.js.map +1 -1
  358. package/lib/components/Table/Table.js +3 -7
  359. package/lib/components/Table/Table.js.map +1 -1
  360. package/lib/components/Tabs/Tab.js +3 -6
  361. package/lib/components/Tabs/Tab.js.map +1 -1
  362. package/lib/components/Tabs/TabPanel.d.ts +10 -2
  363. package/lib/components/Tabs/TabPanel.d.ts.map +1 -1
  364. package/lib/components/Tabs/TabPanel.js +21 -8
  365. package/lib/components/Tabs/TabPanel.js.map +1 -1
  366. package/lib/components/Tabs/Tabs.js +7 -8
  367. package/lib/components/Tabs/Tabs.js.map +1 -1
  368. package/lib/components/Text/Text.d.ts +1 -1
  369. package/lib/components/Text/Text.d.ts.map +1 -1
  370. package/lib/components/Text/Text.js +1 -1
  371. package/lib/components/Text/Text.js.map +1 -1
  372. package/lib/components/TextArea/TextArea.js +3 -3
  373. package/lib/components/TextArea/TextArea.js.map +1 -1
  374. package/lib/components/Toaster/Toaster.js +6 -10
  375. package/lib/components/Toaster/Toaster.js.map +1 -1
  376. package/lib/components/Tree/StandardTree.d.ts.map +1 -1
  377. package/lib/components/Tree/StandardTree.js +10 -17
  378. package/lib/components/Tree/StandardTree.js.map +1 -1
  379. package/lib/components/Tree/StandardTree.styles.d.ts +1 -1
  380. package/lib/components/Tree/StandardTree.styles.d.ts.map +1 -1
  381. package/lib/components/Tree/StandardTree.styles.js +16 -11
  382. package/lib/components/Tree/StandardTree.styles.js.map +1 -1
  383. package/lib/components/Tree/Tree.d.ts +6 -0
  384. package/lib/components/Tree/Tree.d.ts.map +1 -1
  385. package/lib/components/Tree/Tree.js +3 -3
  386. package/lib/components/Tree/Tree.js.map +1 -1
  387. package/lib/components/Tree/helpers.js +4 -7
  388. package/lib/components/Tree/helpers.js.map +1 -1
  389. package/lib/hooks/index.d.ts +1 -0
  390. package/lib/hooks/index.d.ts.map +1 -1
  391. package/lib/hooks/index.js +1 -0
  392. package/lib/hooks/index.js.map +1 -1
  393. package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
  394. package/lib/hooks/useActiveDescendant.js +28 -32
  395. package/lib/hooks/useActiveDescendant.js.map +1 -1
  396. package/lib/hooks/useBreakpoint.js +2 -4
  397. package/lib/hooks/useBreakpoint.js.map +1 -1
  398. package/lib/hooks/useFocusWithin.js +9 -9
  399. package/lib/hooks/useFocusWithin.js.map +1 -1
  400. package/lib/hooks/useI18n.d.ts +57 -1
  401. package/lib/hooks/useI18n.d.ts.map +1 -1
  402. package/lib/hooks/useLongPress.d.ts +16 -0
  403. package/lib/hooks/useLongPress.d.ts.map +1 -0
  404. package/lib/hooks/useLongPress.js +57 -0
  405. package/lib/hooks/useLongPress.js.map +1 -0
  406. package/lib/hooks/useOuterEvent.js +1 -1
  407. package/lib/hooks/useOuterEvent.js.map +1 -1
  408. package/lib/hooks/useOverride.js +1 -1
  409. package/lib/hooks/useOverride.js.map +1 -1
  410. package/lib/hooks/useScrollStick.js +14 -3
  411. package/lib/hooks/useScrollStick.js.map +1 -1
  412. package/lib/i18n/default.json +59 -3
  413. package/lib/i18n/i18n.d.ts +114 -2
  414. package/lib/i18n/i18n.d.ts.map +1 -1
  415. package/lib/i18n/index.d.ts +1 -0
  416. package/lib/i18n/index.d.ts.map +1 -1
  417. package/lib/i18n/index.js.map +1 -1
  418. package/lib/index.d.ts +2 -2
  419. package/lib/index.d.ts.map +1 -1
  420. package/lib/index.js +2 -2
  421. package/lib/index.js.map +1 -1
  422. package/lib/styles/GlobalStyle.d.ts.map +1 -1
  423. package/lib/styles/GlobalStyle.js +2 -26
  424. package/lib/styles/GlobalStyle.js.map +1 -1
  425. package/lib/theme/ThemeMachine.js +7 -1
  426. package/lib/theme/ThemeMachine.js.map +1 -1
  427. package/lib/theme/index.d.ts +1 -0
  428. package/lib/theme/index.d.ts.map +1 -1
  429. package/lib/theme/index.js +1 -0
  430. package/lib/theme/index.js.map +1 -1
  431. package/lib/theme/theme.d.ts +75 -45
  432. package/lib/theme/theme.d.ts.map +1 -1
  433. package/lib/theme/themeDefinition.json +50 -30
  434. package/lib/theme/themeOverrides.schema.json +15 -3
  435. package/lib/theme/themes/buildTheme.json +2 -39
  436. package/lib/theme/themes/legacyBuildTheme.json +50 -0
  437. package/lib/types/types.d.ts +4 -1
  438. package/lib/types/types.d.ts.map +1 -1
  439. package/lib/types/types.js.map +1 -1
  440. package/lib/utils/utils.d.ts +24 -0
  441. package/lib/utils/utils.d.ts.map +1 -1
  442. package/lib/utils/utils.js +36 -1
  443. package/lib/utils/utils.js.map +1 -1
  444. package/package.json +10 -10
  445. package/lib/components/DateTime/Input/useButtonAriaLabel.d.ts +0 -3
  446. package/lib/components/DateTime/Input/useButtonAriaLabel.d.ts.map +0 -1
  447. package/lib/components/DateTime/Input/useButtonAriaLabel.js +0 -33
  448. package/lib/components/DateTime/Input/useButtonAriaLabel.js.map +0 -1
  449. package/lib/components/NoItems/NoItems.d.ts +0 -14
  450. package/lib/components/NoItems/NoItems.d.ts.map +0 -1
  451. package/lib/components/NoItems/NoItems.js.map +0 -1
  452. package/lib/components/NoItems/index.d.ts +0 -4
  453. package/lib/components/NoItems/index.d.ts.map +0 -1
  454. package/lib/components/NoItems/index.js +0 -3
  455. package/lib/components/NoItems/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB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,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,YAClB,aACe,CACpB,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,kBACR,EAAE,EAAC,UAAU,EACb,OAAO,EAAC,QAAQ,IACZ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAEpE,IAAI,YACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import {\n ChangeEvent,\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, PropsWithDefaults } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport StyledInput from '../Input/Input.styles';\nimport Select, { Option } from '../Select';\nimport Input from '../Input';\nimport { StyledSelect } from '../Select/Select';\nimport Flex from '../Flex';\nimport { useDirection, useFocusWithin } from '../../hooks';\n\nimport callingCodes from './callingCodes';\nimport {\n calculateCursorPosition,\n convertToCallbackParameter,\n formatPhoneNumber,\n getPhoneNumberParts\n} from './utils';\n\nexport interface PhoneInputProps extends FormControlProps, BaseProps {\n /**\n * Display select with countries calling codes\n * @default false\n */\n showCountryCode?: boolean;\n /** Changes lists of countries calling codes */\n callingCodesList?: string[];\n /** Callback fired on input value change */\n onChange?: (value: string) => void;\n /** Callback fired when the component loses focus */\n onBlur?: (value: string) => void;\n /** CCallback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype PhoneInputPropsWithDefaults = PropsWithDefaults<PhoneInputProps>;\n\nconst StyledPhoneInput = styled.div<PhoneInputPropsWithDefaults>(() => {\n const { start, end } = useDirection();\n return css`\n border: 0;\n > ${StyledSelect} {\n max-width: max-content;\n border-inline-end: none;\n border-top-${end}-radius: 0;\n border-bottom-${end}-radius: 0;\n }\n\n > ${StyledSelect} + ${StyledInput} {\n border-top-${start}-radius: 0;\n border-bottom-${start}-radius: 0;\n }\n `;\n});\n\nStyledPhoneInput.defaultProps = defaultThemeProp;\n\nconst PhoneInput: FunctionComponent<PhoneInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<PhoneInputProps>, ref: PhoneInputProps['ref']) => {\n const {\n defaultValue,\n value = defaultValue,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n readOnly,\n disabled,\n showCountryCode = false,\n callingCodesList = callingCodes,\n onChange,\n onBlur,\n onFocus,\n ...restProps\n } = props;\n\n const phoneNumberParts = useMemo(() => {\n return value ? getPhoneNumberParts(value, callingCodesList) : undefined;\n }, [callingCodesList, value]);\n\n const [countryCode, setCountryCode] = useState(phoneNumberParts?.[0]);\n\n const [phoneNumber, setPhoneNumber] = useState(\n phoneNumberParts ? formatPhoneNumber(phoneNumberParts[1], countryCode) : ''\n );\n\n const [cursor, setCursor] = useState<number | undefined>(undefined);\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (cursor !== undefined) inputRef.current?.setSelectionRange(cursor, cursor);\n }, [cursor, inputRef.current]);\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(countryCode, phoneNumber);\n if (focused) onFocus?.(callbackParam);\n else onBlur?.(callbackParam);\n };\n\n const containerRef = useRef<HTMLElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value;\n const selectionStart = e.target.selectionStart;\n const formatted = formatPhoneNumber(inputValue, countryCode);\n setPhoneNumber(formatted);\n if (countryCode) {\n setCursor(calculateCursorPosition(formatted, phoneNumber, countryCode, selectionStart));\n }\n onChange?.(convertToCallbackParameter(countryCode, formatted));\n };\n\n const onSelectChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const selectValue = e.target.value;\n setCountryCode(selectValue);\n setPhoneNumber(formatPhoneNumber(phoneNumber, selectValue));\n onChange?.(convertToCallbackParameter(selectValue, phoneNumber));\n };\n\n const codesOptions = (\n <>\n {callingCodesList.map(code => (\n <Option key={code} value={code}>\n {code}\n </Option>\n ))}\n </>\n );\n\n const Comp = (\n <StyledPhoneInput\n as={StyledFormControl}\n forwardedAs={Flex as any}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n ref={containerRef}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n {showCountryCode && (\n <Select\n value={countryCode}\n onChange={onSelectChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n {codesOptions}\n </Select>\n )}\n <Input\n {...restProps}\n inputMode='tel'\n ref={inputRef}\n value={phoneNumber}\n onChange={onInputChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n />\n </StyledPhoneInput>\n );\n\n return label ? (\n <FormField\n as='fieldset'\n labelAs='legend'\n {...{ label, labelHidden, id, info, ref, status, required, disabled }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default PhoneInput;\n"]}
1
+ {"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../src/components/Phone/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAoB,iBAAiB,EAAE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,EAAE,IAAI,EAAE,QAAQ,EAAE,EACnD,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,iBAEjB,eAAe,IAAI,CAClB,KAAC,MAAM,kBACL,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,gBAEjB,YAAY,YACN,CACV,EACD,KAAC,KAAK,oBACA,SAAS,IACb,SAAS,EAAC,KAAK,EACf,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,YAClB,aACe,CACpB,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,kBACR,EAAE,EAAC,UAAU,EACb,OAAO,EAAC,QAAQ,IACZ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAEpE,IAAI,YACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import {\n ChangeEvent,\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useAfterInitialEffect, useDirection, useFocusWithin } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, PropsWithDefaults } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport StyledInput from '../Input/Input.styles';\nimport Select, { Option } from '../Select';\nimport Input from '../Input';\nimport { StyledSelect } from '../Select/Select';\nimport Flex from '../Flex';\n\nimport callingCodes from './callingCodes';\nimport {\n calculateCursorPosition,\n convertToCallbackParameter,\n formatPhoneNumber,\n getPhoneNumberParts\n} from './utils';\n\nexport interface PhoneInputProps extends FormControlProps, BaseProps {\n /**\n * Display select with countries calling codes\n * @default false\n */\n showCountryCode?: boolean;\n /** Changes lists of countries calling codes */\n callingCodesList?: string[];\n /** Callback fired on input value change */\n onChange?: (value: string) => void;\n /** Callback fired when the component loses focus */\n onBlur?: (value: string) => void;\n /** CCallback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype PhoneInputPropsWithDefaults = PropsWithDefaults<PhoneInputProps>;\n\nconst StyledPhoneInput = styled.div<PhoneInputPropsWithDefaults>(() => {\n const { start, end } = useDirection();\n return css`\n border: 0;\n > ${StyledSelect} {\n max-width: max-content;\n border-inline-end: none;\n border-top-${end}-radius: 0;\n border-bottom-${end}-radius: 0;\n }\n\n > ${StyledSelect} + ${StyledInput} {\n border-top-${start}-radius: 0;\n border-bottom-${start}-radius: 0;\n }\n `;\n});\n\nStyledPhoneInput.defaultProps = defaultThemeProp;\n\nconst PhoneInput: FunctionComponent<PhoneInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<PhoneInputProps>, ref: PhoneInputProps['ref']) => {\n const {\n defaultValue,\n value = defaultValue,\n id,\n label,\n labelHidden,\n info,\n status,\n required,\n readOnly,\n disabled,\n showCountryCode = false,\n callingCodesList = callingCodes,\n onChange,\n onBlur,\n onFocus,\n ...restProps\n } = props;\n\n const phoneNumberParts = useMemo(() => {\n return value ? getPhoneNumberParts(value, callingCodesList) : undefined;\n }, [callingCodesList, value]);\n\n const [countryCode, setCountryCode] = useState(phoneNumberParts?.[0]);\n\n const [phoneNumber, setPhoneNumber] = useState(\n phoneNumberParts ? formatPhoneNumber(phoneNumberParts[1], countryCode) : ''\n );\n\n useAfterInitialEffect(() => {\n setCountryCode(phoneNumberParts?.[0]);\n setPhoneNumber(phoneNumberParts ? formatPhoneNumber(phoneNumberParts[1], countryCode) : '');\n }, [phoneNumberParts]);\n\n const [cursor, setCursor] = useState<number | undefined>(undefined);\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (cursor !== undefined) inputRef.current?.setSelectionRange(cursor, cursor);\n }, [cursor, inputRef.current]);\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(countryCode, phoneNumber);\n if (focused) onFocus?.(callbackParam);\n else onBlur?.(callbackParam);\n };\n\n const containerRef = useRef<HTMLElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value;\n const selectionStart = e.target.selectionStart;\n const formatted = formatPhoneNumber(inputValue, countryCode);\n setPhoneNumber(formatted);\n if (countryCode) {\n setCursor(calculateCursorPosition(formatted, phoneNumber, countryCode, selectionStart));\n }\n onChange?.(convertToCallbackParameter(countryCode, formatted));\n };\n\n const onSelectChange = (e: ChangeEvent<HTMLSelectElement>) => {\n const selectValue = e.target.value;\n setCountryCode(selectValue);\n setPhoneNumber(formatPhoneNumber(phoneNumber, selectValue));\n onChange?.(convertToCallbackParameter(selectValue, phoneNumber));\n };\n\n const codesOptions = (\n <>\n {callingCodesList.map(code => (\n <Option key={code} value={code}>\n {code}\n </Option>\n ))}\n </>\n );\n\n const Comp = (\n <StyledPhoneInput\n as={StyledFormControl}\n forwardedAs={Flex as any}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n ref={containerRef}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n {showCountryCode && (\n <Select\n value={countryCode}\n onChange={onSelectChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n >\n {codesOptions}\n </Select>\n )}\n <Input\n {...restProps}\n inputMode='tel'\n ref={inputRef}\n value={phoneNumber}\n onChange={onInputChange}\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n />\n </StyledPhoneInput>\n );\n\n return label ? (\n <FormField\n as='fieldset'\n labelAs='legend'\n {...{ label, labelHidden, id, info, ref, status, required, disabled }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default PhoneInput;\n"]}
@@ -3,17 +3,16 @@ export const getPhoneNumberParts = (phoneNumber, codesList) => {
3
3
  if (!phoneNumber.startsWith('+') || phoneNumber.startsWith('+0'))
4
4
  return [undefined, phoneNumber];
5
5
  const countryCode = codesList.find(code => phoneNumber.startsWith(code));
6
- const subscriberNumber = phoneNumber.substring((countryCode === null || countryCode === void 0 ? void 0 : countryCode.length) || 0);
6
+ const subscriberNumber = phoneNumber.substring(countryCode?.length || 0);
7
7
  return [countryCode, subscriberNumber];
8
8
  };
9
9
  export const cleanNumber = (phoneNumber) => {
10
10
  return phoneNumber.replace(/\D/g, '');
11
11
  };
12
12
  export const getCountry = (countryCode, number) => {
13
- var _a;
14
13
  const asYouTypeCode = new AsYouType();
15
14
  asYouTypeCode.input(countryCode + number);
16
- return countryCode === '+1' ? 'US' : (_a = asYouTypeCode.getNumber()) === null || _a === void 0 ? void 0 : _a.country;
15
+ return countryCode === '+1' ? 'US' : asYouTypeCode.getNumber()?.country;
17
16
  };
18
17
  export const formatPhoneNumber = (numberToFormat, countryCode = '') => {
19
18
  let formatted = cleanNumber(numberToFormat);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Phone/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,WAAmB,EACnB,SAAmB,EACW,EAAE;IAChC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;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,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { AsYouType, formatIncompletePhoneNumber } from 'libphonenumber-js';\n\nexport const getPhoneNumberParts = (\n phoneNumber: string,\n codesList: string[]\n): [string | undefined, string] => {\n if (!phoneNumber.startsWith('+') || phoneNumber.startsWith('+0')) return [undefined, phoneNumber];\n const countryCode = codesList.find(code => phoneNumber.startsWith(code));\n const subscriberNumber = phoneNumber.substring(countryCode?.length || 0);\n return [countryCode, subscriberNumber];\n};\n\nexport const cleanNumber = (phoneNumber: string) => {\n return phoneNumber.replace(/\\D/g, '');\n};\n\nexport const getCountry = (countryCode: string, number: string) => {\n const asYouTypeCode = new AsYouType();\n asYouTypeCode.input(countryCode + number);\n return countryCode === '+1' ? 'US' : asYouTypeCode.getNumber()?.country;\n};\n\nexport const formatPhoneNumber = (numberToFormat: string, countryCode: string = '') => {\n let formatted = cleanNumber(numberToFormat);\n if (countryCode) {\n const country = getCountry(countryCode, formatted);\n formatted = formatIncompletePhoneNumber(formatted, country);\n }\n return formatted;\n};\n\nexport const convertToCallbackParameter = (codePart: string | undefined, numberPart: string) => {\n return [codePart, cleanNumber(numberPart)].join('');\n};\n\nexport const calculateCursorPosition = (\n newValue: string,\n prevValue: string,\n countryCode: string,\n prevCursorPosition: number | null\n) => {\n if (prevCursorPosition !== undefined && prevCursorPosition !== null) {\n const country = getCountry(countryCode, cleanNumber(newValue));\n let numbersCount = cleanNumber(prevValue.slice(0, prevCursorPosition - 1)).length + 1;\n\n if (cleanNumber(prevValue).length > cleanNumber(newValue).length) {\n numbersCount = cleanNumber(prevValue.slice(0, prevCursorPosition)).length;\n }\n\n let newCursorPosition = 0;\n let count = 0;\n const asYouTypeNew = new AsYouType(country);\n asYouTypeNew.input(newValue);\n while (newCursorPosition < asYouTypeNew.getTemplate().length) {\n if (count === numbersCount) {\n break;\n }\n if (asYouTypeNew.getTemplate()[newCursorPosition] === 'x') {\n count += 1;\n }\n newCursorPosition += 1;\n }\n return newCursorPosition;\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AO,iBAAiB,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE;YAC5D,IAAI,KAAK,KAAK,YAAY,EAAE;gBAC1B,MAAM;aACP;YACD,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC,KAAK,GAAG,EAAE;gBACzD,KAAK,IAAI,CAAC,CAAC;aACZ;YACD,iBAAiB,IAAI,CAAC,CAAC;SACxB;QACD,OAAO,iBAAiB,CAAC;KAC1B;AACH,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { AsYouType, formatIncompletePhoneNumber } from 'libphonenumber-js';\n\nexport const getPhoneNumberParts = (\n phoneNumber: string,\n codesList: string[]\n): [string | undefined, string] => {\n if (!phoneNumber.startsWith('+') || phoneNumber.startsWith('+0')) return [undefined, phoneNumber];\n const countryCode = codesList.find(code => phoneNumber.startsWith(code));\n const subscriberNumber = phoneNumber.substring(countryCode?.length || 0);\n return [countryCode, subscriberNumber];\n};\n\nexport const cleanNumber = (phoneNumber: string) => {\n return phoneNumber.replace(/\\D/g, '');\n};\n\nexport const getCountry = (countryCode: string, number: string) => {\n const asYouTypeCode = new AsYouType();\n asYouTypeCode.input(countryCode + number);\n return countryCode === '+1' ? 'US' : asYouTypeCode.getNumber()?.country;\n};\n\nexport const formatPhoneNumber = (numberToFormat: string, countryCode: string = '') => {\n let formatted = cleanNumber(numberToFormat);\n if (countryCode) {\n const country = getCountry(countryCode, formatted);\n formatted = formatIncompletePhoneNumber(formatted, country);\n }\n return formatted;\n};\n\nexport const convertToCallbackParameter = (codePart: string | undefined, numberPart: string) => {\n return [codePart, cleanNumber(numberPart)].join('');\n};\n\nexport const calculateCursorPosition = (\n newValue: string,\n prevValue: string,\n countryCode: string,\n prevCursorPosition: number | null\n) => {\n if (prevCursorPosition !== undefined && prevCursorPosition !== null) {\n const country = getCountry(countryCode, cleanNumber(newValue));\n let numbersCount = cleanNumber(prevValue.slice(0, prevCursorPosition - 1)).length + 1;\n\n if (cleanNumber(prevValue).length > cleanNumber(newValue).length) {\n numbersCount = cleanNumber(prevValue.slice(0, prevCursorPosition)).length;\n }\n\n let newCursorPosition = 0;\n let count = 0;\n const asYouTypeNew = new AsYouType(country);\n asYouTypeNew.input(newValue);\n while (newCursorPosition < asYouTypeNew.getTemplate().length) {\n if (count === numbersCount) {\n break;\n }\n if (asYouTypeNew.getTemplate()[newCursorPosition] === 'x') {\n count += 1;\n }\n newCursorPosition += 1;\n }\n return newCursorPosition;\n }\n};\n\nexport default getPhoneNumberParts;\n"]}
@@ -147,12 +147,11 @@ const Popover = forwardRef(({ show = true, portal = false, target, placement, st
147
147
  ...modifiers
148
148
  ], [modifiers, arrow, hideOnTargetHidden]);
149
149
  const offset = useMemo(() => {
150
- var _a, _b, _c;
151
150
  const offsetModifier = [...memoedModifiers]
152
151
  .reverse()
153
152
  .find(m => m.name === 'offset' && m.enabled !== false);
154
- return Array.isArray((_a = offsetModifier === null || offsetModifier === void 0 ? void 0 : offsetModifier.options) === null || _a === void 0 ? void 0 : _a.offset)
155
- ? (_c = (_b = offsetModifier === null || offsetModifier === void 0 ? void 0 : offsetModifier.options) === null || _b === void 0 ? void 0 : _b.offset[1]) !== null && _c !== void 0 ? _c : 0
153
+ return Array.isArray(offsetModifier?.options?.offset)
154
+ ? offsetModifier?.options?.offset[1] ?? 0
156
155
  : 0;
157
156
  }, [memoedModifiers]);
158
157
  const { styles, attributes, forceUpdate } = usePopper(target, popperRef.current, {
@@ -164,8 +163,7 @@ const Popover = forwardRef(({ show = true, portal = false, target, placement, st
164
163
  forceUpdateRef.current = forceUpdate;
165
164
  useEffect(() => {
166
165
  const observer = new ResizeObserver(() => {
167
- var _a;
168
- (_a = forceUpdateRef.current) === null || _a === void 0 ? void 0 : _a.call(forceUpdateRef);
166
+ forceUpdateRef.current?.();
169
167
  });
170
168
  if (popperRef.current)
171
169
  observer.observe(popperRef.current);
@@ -192,8 +190,7 @@ const Popover = forwardRef(({ show = true, portal = false, target, placement, st
192
190
  useEffect(() => {
193
191
  return () => clearTimeout(timeout.current);
194
192
  }, []);
195
- const content = (_jsxs(StyledPopover, Object.assign({}, restProps, { offset: offset, ref: popperRef, style: { ...style, ...styles.popper } }, attributes.popper, { children: [arrow && _jsx(StyledPopoverArrow, { ref: arrowRef, style: { ...styles.arrow } }, void 0),
196
- children] }), void 0));
193
+ const content = (_jsxs(StyledPopover, Object.assign({}, restProps, { offset: offset, ref: popperRef, style: { ...style, ...styles.popper } }, attributes.popper, { children: [arrow && _jsx(StyledPopoverArrow, { ref: arrowRef, style: { ...styles.arrow } }, void 0), children] }), void 0));
197
194
  if (!target || !showPopover || (groupId && !checkActive(uid, groupId)))
198
195
  return null;
199
196
  return portal && portalTarget ? createPortal(content, portalTarget) : content;
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAGtD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AA0DzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;CAa3C,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CACrC,CAAC,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YACnD,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;gBACvC,cAAc,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;SAC1C;aAAM;YACL,cAAc,CAAC,IAAI,CAAC,CAAC;SACtB;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,CACd,MAAC,aAAa,oBACR,SAAS,IACb,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,IACjC,UAAU,CAAC,MAAM,eAEpB,KAAK,IAAI,KAAC,kBAAkB,IAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,WAAI;YAC1E,QAAQ,aACK,CACjB,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpF,OAAO,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChF,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import {\n forwardRef,\n useContext,\n PropsWithoutRef,\n Ref,\n CSSProperties,\n ReactElement,\n useRef,\n ReactNode,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useConfiguration, useConsolidatedRef, useElement, useUID } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { windowIsAvailable } from '../../utils';\n\nimport { PopoverManagerContext } from './PopoverContext';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean;\n /**\n * Delay on showing the Popover.\n * @default \"none\"\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default \"none\"\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default \"absolute\"\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledPopoverArrow = styled.div`\n background-color: inherit;\n height: 0;\n width: 0;\n\n ::after {\n content: '';\n display: block;\n background-color: inherit;\n height: 0.5rem;\n width: 0.5rem;\n transform: rotate(45deg);\n }\n`;\n\nexport const StyledPopover = styled.div<{ offset?: number }>(\n ({\n theme: {\n base: {\n 'border-radius': borderRadius,\n 'z-index': { popover: zIndex },\n shadow: { 'low-filter': low }\n },\n components: {\n card: { background, 'border-radius': cardBorderRadius }\n }\n },\n offset\n }) => {\n return css`\n /*\n Margin should never be used with Popper.\n https://popper.js.org/docs/v2/migration-guide/#4-remove-all-css-margins\n */\n margin: 0 !important;\n z-index: ${zIndex};\n background-color: ${background};\n border-radius: calc(${cardBorderRadius} / 2);\n filter: ${low};\n\n &[data-popper-reference-hidden='true'] {\n visibility: hidden;\n pointer-events: none;\n }\n\n &[data-popper-placement^='top'] {\n > ${StyledPopoverArrow} {\n top: calc(100% - 0.25rem);\n margin-inline-start: -0.25rem;\n\n ::after {\n border-bottom-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n bottom: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='bottom'] {\n > ${StyledPopoverArrow} {\n bottom: calc(100% + 0.25rem);\n margin-inline-start: -0.25rem;\n\n ::after {\n border-top-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n top: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='right'] {\n > ${StyledPopoverArrow} {\n right: calc(100% + 0.25rem);\n margin-block-start: -0.25rem;\n\n ::after {\n border-bottom-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n left: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n\n &[data-popper-placement^='left'] {\n > ${StyledPopoverArrow} {\n left: calc(100% - 0.25rem);\n margin-block-start: -0.25rem;\n\n ::after {\n border-top-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n right: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n `;\n }\n);\n\nStyledPopover.defaultProps = defaultThemeProp;\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(\n (\n {\n show = true,\n portal = false,\n target,\n placement,\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n ) => {\n const { portalTarget } = useConfiguration();\n const { checkActive, setActive } = useContext(PopoverManagerContext);\n const [, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const memoedModifiers = useMemo(\n () => [\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n ...modifiers\n ],\n [modifiers, arrow, hideOnTargetHidden]\n );\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperRef.current, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n forceUpdateRef.current?.();\n });\n\n if (popperRef.current) observer.observe(popperRef.current);\n if (target instanceof Element) observer.observe(target);\n\n return () => {\n observer.disconnect();\n };\n }, [forceUpdate, popperRef.current, target]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Popover;\n"]}
1
+ {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAKV,MAAM,EAEN,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAGtD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AA0DzD,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ReactNode,\n useEffect,\n useMemo,\n useState\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { usePopper, PopperProps } from 'react-popper';\nimport { VirtualElement } from '@popperjs/core';\nimport { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useConfiguration, useConsolidatedRef, useElement, useUID } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { windowIsAvailable } from '../../utils';\n\nimport { PopoverManagerContext } from './PopoverContext';\n\nexport type Delay = 'none' | 'short' | 'long';\nexport interface PopoverProps<Modifiers extends string = string> extends BaseProps {\n /** The DOM element or [virtual element](https://popper.js.org/docs/v2/virtual-elements) that the Popover is positioned in reference to. */\n target: Element | VirtualElement | null;\n /**\n * If true, the Popover will be visible.\n * @default true\n */\n show?: boolean;\n /**\n * If true, the Popover will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default false\n */\n portal?: boolean;\n /**\n * Delay on showing the Popover.\n * @default \"none\"\n */\n showDelay?: Delay;\n /**\n * Delay on hiding the Popover.\n * @default \"none\"\n */\n hideDelay?: Delay;\n /**\n * [React Popper Placement](https://popper.js.org/react-popper/v2/render-props/#placement)\n */\n placement?: PopperProps<Modifiers>['placement'];\n /**\n * [React Popper Strategy](https://popper.js.org/react-popper/v2/render-props/#strategy)\n * @default \"absolute\"\n */\n strategy?: PopperProps<Modifiers>['strategy'];\n /**\n * [React Popper Modifiers](https://popper.js.org/react-popper/v2/render-props/#modifiers)\n * @default []\n */\n modifiers?: PopperProps<Modifiers>['modifiers'];\n /**\n * If true, an arrow will visually identify from which element the Popover is rendered.\n * @default false\n */\n arrow?: boolean;\n /** The group that the Popover belongs to. Popovers in the same group will be closed when others open. */\n groupId?: string;\n /**\n * If true, the Popover will be visibly hidden when its target leaves the viewport.\n * @default false\n */\n hideOnTargetHidden?: boolean;\n /** The content of the Popover. */\n children: ReactNode;\n /** The ref of the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledPopoverArrow = styled.div`\n background-color: inherit;\n height: 0;\n width: 0;\n\n ::after {\n content: '';\n display: block;\n background-color: inherit;\n height: 0.5rem;\n width: 0.5rem;\n transform: rotate(45deg);\n }\n`;\n\nexport const StyledPopover = styled.div<{ offset?: number }>(\n ({\n theme: {\n base: {\n 'border-radius': borderRadius,\n 'z-index': { popover: zIndex },\n shadow: { 'low-filter': low }\n },\n components: {\n card: { background, 'border-radius': cardBorderRadius }\n }\n },\n offset\n }) => {\n return css`\n /*\n Margin should never be used with Popper.\n https://popper.js.org/docs/v2/migration-guide/#4-remove-all-css-margins\n */\n margin: 0 !important;\n z-index: ${zIndex};\n background-color: ${background};\n border-radius: calc(${cardBorderRadius} / 2);\n filter: ${low};\n\n &[data-popper-reference-hidden='true'] {\n visibility: hidden;\n pointer-events: none;\n }\n\n &[data-popper-placement^='top'] {\n > ${StyledPopoverArrow} {\n top: calc(100% - 0.25rem);\n margin-inline-start: -0.25rem;\n\n ::after {\n border-bottom-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n bottom: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='bottom'] {\n > ${StyledPopoverArrow} {\n bottom: calc(100% + 0.25rem);\n margin-inline-start: -0.25rem;\n\n ::after {\n border-top-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n height: ${offset}px;\n top: -${offset}px;\n left: 0;\n right: 0;\n }\n }\n\n &[data-popper-placement^='right'] {\n > ${StyledPopoverArrow} {\n right: calc(100% + 0.25rem);\n margin-block-start: -0.25rem;\n\n ::after {\n border-bottom-left-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n left: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n\n &[data-popper-placement^='left'] {\n > ${StyledPopoverArrow} {\n left: calc(100% - 0.25rem);\n margin-block-start: -0.25rem;\n\n ::after {\n border-top-right-radius: calc(${borderRadius} / 4);\n }\n }\n\n ::before {\n content: '';\n position: absolute;\n width: ${offset}px;\n right: -${offset}px;\n top: 0;\n bottom: 0;\n }\n }\n `;\n }\n);\n\nStyledPopover.defaultProps = defaultThemeProp;\n\nconst delays = {\n none: 0,\n short: 500,\n long: 1000\n};\n\nconst Popover: <Modifiers extends string = string>(\n props: PopoverProps<Modifiers> & ForwardProps\n) => ReactElement | null = forwardRef(\n (\n {\n show = true,\n portal = false,\n target,\n placement,\n strategy = 'fixed',\n style,\n modifiers = [],\n arrow = false,\n groupId,\n showDelay = 'none',\n hideDelay = 'none',\n hideOnTargetHidden = false,\n children,\n ...restProps\n }: PropsWithoutRef<PopoverProps> & { style?: CSSProperties },\n ref: PopoverProps['ref']\n ) => {\n const { portalTarget } = useConfiguration();\n const { checkActive, setActive } = useContext(PopoverManagerContext);\n const [, setPopperEl] = useElement<HTMLDivElement>();\n const popperRef = useConsolidatedRef<HTMLDivElement>(ref, setPopperEl);\n const arrowRef = useRef<HTMLDivElement>(null);\n const forceUpdateRef = useRef<() => void>();\n const [showPopover, setShowPopover] = useState(show);\n const timeout = useRef<number>();\n const uid = useUID();\n\n const memoedModifiers = useMemo(\n () => [\n {\n name: 'offset',\n options: {\n offset: [0, arrow ? 5.5 : 2]\n }\n },\n { name: 'hide', enabled: hideOnTargetHidden },\n { name: 'arrow', enabled: arrow, options: { element: arrowRef.current } },\n ...modifiers\n ],\n [modifiers, arrow, hideOnTargetHidden]\n );\n\n const offset = useMemo(() => {\n const offsetModifier = [...memoedModifiers]\n .reverse()\n .find(m => m.name === 'offset' && m.enabled !== false) as OffsetModifier | undefined;\n return Array.isArray(offsetModifier?.options?.offset)\n ? offsetModifier?.options?.offset[1] ?? 0\n : 0;\n }, [memoedModifiers]);\n\n const { styles, attributes, forceUpdate } = usePopper(target, popperRef.current, {\n placement,\n strategy,\n modifiers: memoedModifiers\n });\n\n if (forceUpdate) forceUpdateRef.current = forceUpdate;\n\n useEffect(() => {\n const observer = new ResizeObserver(() => {\n forceUpdateRef.current?.();\n });\n\n if (popperRef.current) observer.observe(popperRef.current);\n if (target instanceof Element) observer.observe(target);\n\n return () => {\n observer.disconnect();\n };\n }, [forceUpdate, popperRef.current, target]);\n\n useEffect(() => {\n if (groupId && show) setActive(uid, groupId);\n\n if (windowIsAvailable) {\n if (timeout.current) clearTimeout(timeout.current);\n timeout.current = window.setTimeout(() => {\n setShowPopover(show);\n }, delays[show ? showDelay : hideDelay]);\n } else {\n setShowPopover(show);\n }\n }, [show]);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n const content = (\n <StyledPopover\n {...restProps}\n offset={offset}\n ref={popperRef}\n style={{ ...style, ...styles.popper }}\n {...attributes.popper}\n >\n {arrow && <StyledPopoverArrow ref={arrowRef} style={{ ...styles.arrow }} />}\n {children}\n </StyledPopover>\n );\n\n if (!target || !showPopover || (groupId && !checkActive(uid, groupId))) return null;\n\n return portal && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Popover;\n"]}
@@ -5,7 +5,7 @@ import { defaultThemeProp } from '../../theme';
5
5
  export const StyledProgressBar = styled.div(({ theme, placement, determinate }) => {
6
6
  return css `
7
7
  height: 0.375rem;
8
- background-color: ${theme.base.colors.gray.light};
8
+ background-color: ${theme.base.colors.gray['extra-light']};
9
9
  border-radius: ${theme.base['border-radius']};
10
10
  min-width: 2rem;
11
11
  overflow: hidden;
@@ -1 +1 @@
1
- {"version":3,"file":"Bar.js","sourceRoot":"","sources":["../../../src/components/Progress/Bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAkC,MAAM,OAAO,CAAC;AACvE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,iBAAiB,GAAG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K,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;KAC3E;IAED,OAAO,CACL,KAAC,iBAAiB,kBAChB,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,aAAa,mBACH,QAAQ,mBACR,QAAQ,mBACR,KAAK,EACpB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,OAAO,KAAK,KAAK,QAAQ,EACtC,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,EAAmB,IAClF,SAAS,UACb,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,GAAG,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef, CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\n\nimport { ProgressProps } from './Progress.types';\n\nexport const StyledProgressBar = styled.div<ProgressProps & { determinate: boolean }>(\n ({ theme, placement, determinate }) => {\n return css`\n height: 0.375rem;\n background-color: ${theme.base.colors.gray.light};\n border-radius: ${theme.base['border-radius']};\n min-width: 2rem;\n overflow: hidden;\n\n @keyframes LoadingBar {\n 0% {\n transform: translateX(-100%);\n }\n\n 100% {\n transform: translateX(200%);\n }\n }\n\n ::before {\n content: '';\n display: block;\n height: 100%;\n width: 100%;\n left: 0;\n border-radius: ${theme.base['border-radius']};\n background-color: ${theme.components.progress['progress-color']};\n ${determinate &&\n css`\n transform: translateX(var(--progress, 0));\n transform-origin: 0 50%;\n transition: transform calc(0.5 * ${theme.base.animation.speed})\n ${theme.base.animation.timing.ease};\n `}\n\n ${!determinate &&\n css`\n animation: LoadingBar calc(8 * ${theme.base.animation.speed}) linear infinite;\n width: 50%;\n `}\n }\n\n ${placement === 'inline'\n ? css`\n display: inline-block;\n position: relative;\n `\n : css`\n width: 50%;\n `}\n `;\n }\n);\n\nStyledProgressBar.defaultProps = defaultThemeProp;\n\nconst Bar: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n value,\n minValue = 0,\n maxValue = 100,\n message,\n placement,\n style,\n ...restProps\n }: PropsWithoutRef<ProgressProps & { style?: CSSProperties }>,\n ref: ProgressProps['ref']\n ) => {\n let percentage = value;\n\n if (typeof value === 'number') {\n if (value > maxValue || minValue > maxValue) percentage = 0;\n else if (value < minValue) percentage = 100;\n else percentage = (1 - (value - minValue) / (maxValue - minValue)) * -100;\n }\n\n return (\n <StyledProgressBar\n ref={ref}\n role='progressbar'\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n aria-valuenow={value}\n placement={placement}\n determinate={typeof value === 'number'}\n style={{ ...style, '--progress': percentage ? `${percentage}%` : '' } as CSSProperties}\n {...restProps}\n />\n );\n }\n);\n\nexport default Bar;\n"]}
1
+ {"version":3,"file":"Bar.js","sourceRoot":"","sources":["../../../src/components/Progress/Bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAkC,MAAM,OAAO,CAAC;AACvE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CACzC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE;IACpC,OAAO,GAAG,CAAA;;0BAEY,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;uBACxC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;yBAoBzB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;4BACxB,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;UAC7D,WAAW;QACb,GAAG,CAAA;;;6CAGkC,KAAK,C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AC,EAAE,EAAmB,IAClF,SAAS,UACb,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,GAAG,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef, CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\n\nimport { ProgressProps } from './Progress.types';\n\nexport const StyledProgressBar = styled.div<ProgressProps & { determinate: boolean }>(\n ({ theme, placement, determinate }) => {\n return css`\n height: 0.375rem;\n background-color: ${theme.base.colors.gray['extra-light']};\n border-radius: ${theme.base['border-radius']};\n min-width: 2rem;\n overflow: hidden;\n\n @keyframes LoadingBar {\n 0% {\n transform: translateX(-100%);\n }\n\n 100% {\n transform: translateX(200%);\n }\n }\n\n ::before {\n content: '';\n display: block;\n height: 100%;\n width: 100%;\n left: 0;\n border-radius: ${theme.base['border-radius']};\n background-color: ${theme.components.progress['progress-color']};\n ${determinate &&\n css`\n transform: translateX(var(--progress, 0));\n transform-origin: 0 50%;\n transition: transform calc(0.5 * ${theme.base.animation.speed})\n ${theme.base.animation.timing.ease};\n `}\n\n ${!determinate &&\n css`\n animation: LoadingBar calc(8 * ${theme.base.animation.speed}) linear infinite;\n width: 50%;\n `}\n }\n\n ${placement === 'inline'\n ? css`\n display: inline-block;\n position: relative;\n `\n : css`\n width: 50%;\n `}\n `;\n }\n);\n\nStyledProgressBar.defaultProps = defaultThemeProp;\n\nconst Bar: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n value,\n minValue = 0,\n maxValue = 100,\n message,\n placement,\n style,\n ...restProps\n }: PropsWithoutRef<ProgressProps & { style?: CSSProperties }>,\n ref: ProgressProps['ref']\n ) => {\n let percentage = value;\n\n if (typeof value === 'number') {\n if (value > maxValue || minValue > maxValue) percentage = 0;\n else if (value < minValue) percentage = 100;\n else percentage = (1 - (value - minValue) / (maxValue - minValue)) * -100;\n }\n\n return (\n <StyledProgressBar\n ref={ref}\n role='progressbar'\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n aria-valuenow={value}\n placement={placement}\n determinate={typeof value === 'number'}\n style={{ ...style, '--progress': percentage ? `${percentage}%` : '' } as CSSProperties}\n {...restProps}\n />\n );\n }\n);\n\nexport default Bar;\n"]}
@@ -73,9 +73,7 @@ export const StyledProgressEllipsis = styled.div(({ theme, placement }) => {
73
73
  });
74
74
  StyledProgressEllipsis.defaultProps = defaultThemeProp;
75
75
  const Ellipsis = forwardRef(({ message, placement, ...restProps }, ref) => {
76
- return (_jsx(StyledProgressEllipsis, Object.assign({ ref: ref, role: 'progressbar', placement: placement }, restProps, { children: _jsxs("span", { children: [_jsx("span", {}, void 0),
77
- _jsx("span", {}, void 0),
78
- _jsx("span", {}, void 0)] }, void 0) }), void 0));
76
+ return (_jsx(StyledProgressEllipsis, Object.assign({ ref: ref, role: 'progressbar', placement: placement }, restProps, { children: _jsxs("span", { children: [_jsx("span", {}, void 0), _jsx("span", {}, void 0), _jsx("span", {}, void 0)] }, void 0) }), void 0));
79
77
  });
80
78
  export default Ellipsis;
81
79
  //# sourceMappingURL=Ellipsis.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Ellipsis.js","sourceRoot":"","sources":["../../../src/components/Progress/Ellipsis.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAmB,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IACvF,OAAO,GAAG,CAAA;;eAEG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;QAuBvD,SAAS,KAAK,QAAQ;QACxB,GAAG,CAAA;;;OAGF;;;;;oBAKa,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;;4CAEnB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;;QAE9D,SAAS,KAAK,QAAQ;QACxB,GAAG,CAAA;;;OAGF;;QAEC,SAAS,KAAK,OAAO;QACvB,GAAG,CAAA;;;OAGF;;QAEC,SAAS,KAAK,QAAQ;QACxB,GAAG,CAAA;;;;uCAI8B,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;OAC1D;;;;;;;2BAOoB,MAAM,GAAG,CAAC;;;GAGlC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,QAAQ,GAAqC,UAAU,CAC3D,CACE,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAkC,EACpE,GAAyB,EACzB,EAAE;IACF,OAAO,CACL,KAAC,sBAAsB,kBAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAC,aAAa,EAAC,SAAS,EAAE,SAAS,IAAM,SAAS,cACtF,2BACE,wBAAQ;gBACR,wBAAQ;gBACR,wBAAQ,YACH,YACgB,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\n\nimport { ProgressProps } from './Progress.types';\n\nexport const StyledProgressEllipsis = styled.div<ProgressProps>(({ theme, placement }) => {\n return css`\n line-height: 1;\n display: ${placement === 'inline' ? 'inline-flex' : 'block'};\n\n @keyframes LoadingEllipsis {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n\n 50% {\n transform: scale(1);\n opacity: 1;\n }\n\n 100% {\n transform: scale(0);\n opacity: 0;\n }\n }\n\n > span {\n display: flex;\n mix-blend-mode: multiply;\n\n ${placement === 'inline' &&\n css`\n display: inline-flex;\n margin-left: 0.1875rem;\n `}\n }\n\n > span span {\n margin: 0 0.3125rem;\n background: ${theme.components.progress['progress-color']};\n border-radius: 50%;\n animation: LoadingEllipsis calc(4 * ${theme.base.animation.speed}) infinite;\n\n ${placement === 'global' &&\n css`\n width: 1.25rem;\n height: 1.25rem;\n `}\n\n ${placement === 'local' &&\n css`\n width: 0.625rem;\n height: 0.625rem;\n `}\n\n ${placement === 'inline' &&\n css`\n width: 0.1875rem;\n height: 0.1875rem;\n margin: 0 0.1875rem;\n animation-duration: calc(4 * ${theme.base.animation.speed});\n `}\n\n &:nth-child(2) {\n animation-delay: 0.1667s;\n }\n\n &:nth-child(3) {\n animation-delay: ${0.1667 * 2}s;\n }\n }\n `;\n});\n\nStyledProgressEllipsis.defaultProps = defaultThemeProp;\n\nconst Ellipsis: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n { message, placement, ...restProps }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n return (\n <StyledProgressEllipsis ref={ref} role='progressbar' placement={placement} {...restProps}>\n <span>\n <span />\n <span />\n <span />\n </span>\n </StyledProgressEllipsis>\n );\n }\n);\n\nexport default Ellipsis;\n"]}
1
+ {"version":3,"file":"Ellipsis.js","sourceRoot":"","sources":["../../../src/components/Progress/Ellipsis.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAmB,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IACvF,OAAO,GAAG,CAAA;;eAEG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;QAuBvD,SAAS,KAAK,QAAQ;QACxB,GAAG,CAAA;;;OAGF;;;;;oBAKa,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;;4CAEnB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;;QAE9D,SAAS,KAAK,QAAQ;QACxB,GAAG,CAAA;;;OAGF;;QAEC,SAAS,KAAK,OAAO;QACvB,GAAG,CAAA;;;OAGF;;QAEC,SAAS,KAAK,QAAQ;QACxB,GAAG,CAAA;;;;uCAI8B,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;OAC1D;;;;;;;2BAOoB,MAAM,GAAG,CAAC;;;GAGlC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,QAAQ,GAAqC,UAAU,CAC3D,CACE,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAkC,EACpE,GAAyB,EACzB,EAAE;IACF,OAAO,CACL,KAAC,sBAAsB,kBAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAC,aAAa,EAAC,SAAS,EAAE,SAAS,IAAM,SAAS,cACtF,2BACE,wBAAQ,EACR,wBAAQ,EACR,wBAAQ,YACH,YACgB,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\n\nimport { ProgressProps } from './Progress.types';\n\nexport const StyledProgressEllipsis = styled.div<ProgressProps>(({ theme, placement }) => {\n return css`\n line-height: 1;\n display: ${placement === 'inline' ? 'inline-flex' : 'block'};\n\n @keyframes LoadingEllipsis {\n 0% {\n transform: scale(0);\n opacity: 0;\n }\n\n 50% {\n transform: scale(1);\n opacity: 1;\n }\n\n 100% {\n transform: scale(0);\n opacity: 0;\n }\n }\n\n > span {\n display: flex;\n mix-blend-mode: multiply;\n\n ${placement === 'inline' &&\n css`\n display: inline-flex;\n margin-left: 0.1875rem;\n `}\n }\n\n > span span {\n margin: 0 0.3125rem;\n background: ${theme.components.progress['progress-color']};\n border-radius: 50%;\n animation: LoadingEllipsis calc(4 * ${theme.base.animation.speed}) infinite;\n\n ${placement === 'global' &&\n css`\n width: 1.25rem;\n height: 1.25rem;\n `}\n\n ${placement === 'local' &&\n css`\n width: 0.625rem;\n height: 0.625rem;\n `}\n\n ${placement === 'inline' &&\n css`\n width: 0.1875rem;\n height: 0.1875rem;\n margin: 0 0.1875rem;\n animation-duration: calc(4 * ${theme.base.animation.speed});\n `}\n\n &:nth-child(2) {\n animation-delay: 0.1667s;\n }\n\n &:nth-child(3) {\n animation-delay: ${0.1667 * 2}s;\n }\n }\n `;\n});\n\nStyledProgressEllipsis.defaultProps = defaultThemeProp;\n\nconst Ellipsis: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n { message, placement, ...restProps }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n return (\n <StyledProgressEllipsis ref={ref} role='progressbar' placement={placement} {...restProps}>\n <span>\n <span />\n <span />\n <span />\n </span>\n </StyledProgressEllipsis>\n );\n }\n);\n\nexport default Ellipsis;\n"]}
@@ -37,7 +37,7 @@ const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible =
37
37
  Comp = Ellipsis;
38
38
  const onBackdropTransitionEnd = () => {
39
39
  setIsNull(true);
40
- onTransitionEndOut === null || onTransitionEndOut === void 0 ? void 0 : onTransitionEndOut();
40
+ onTransitionEndOut?.();
41
41
  };
42
42
  useEffect(() => {
43
43
  if (visible) {
@@ -74,8 +74,7 @@ const Progress = forwardRef(({ variant = 'ring', placement = 'global', visible =
74
74
  if (isNull)
75
75
  return null;
76
76
  const comp = (_jsx(Comp, Object.assign({}, restProps, { placement: placement, value: value, "aria-valuetext": message && typeof value === 'number' ? `${message} - ${value}` : message, ref: ref }), void 0));
77
- const content = placement === 'inline' ? (comp) : (_jsxs(Backdrop, Object.assign({ open: isVisible, container: { direction: 'column' }, position: placement === 'global' ? 'fixed' : 'absolute', variant: 'light', alpha: 0.5, onAfterTransitionIn: onTransitionEndIn, onAfterTransitionOut: onBackdropTransitionEnd }, { children: [comp,
78
- !!message && (_jsx(Text, Object.assign({ as: StyledMessage, variant: 'secondary', "aria-hidden": 'true' }, { children: message }), void 0))] }), void 0));
77
+ const content = placement === 'inline' ? (comp) : (_jsxs(Backdrop, Object.assign({ open: isVisible, container: { direction: 'column' }, position: placement === 'global' ? 'fixed' : 'absolute', variant: 'light', alpha: 0.5, onAfterTransitionIn: onTransitionEndIn, onAfterTransitionOut: onBackdropTransitionEnd }, { children: [comp, !!message && (_jsx(Text, Object.assign({ as: StyledMessage, variant: 'secondary', "aria-hidden": 'true' }, { children: message }), void 0))] }), void 0));
79
78
  return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;
80
79
  });
81
80
  export default Progress;
@@ -1 +1 @@
1
- {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuB,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,GAA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C,OAAO,CAAC;AAChG,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, useState, useEffect, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport styled, { css } from 'styled-components';\nimport { readableColor, rgba } from 'polished';\n\nimport { ForwardProps } from '../../types';\nimport Backdrop from '../Backdrop';\nimport Text from '../Text';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { tryCatch } from '../../utils';\nimport { useConfiguration } from '../../hooks';\n\nimport { ProgressProps } from './Progress.types';\nimport Bar from './Bar';\nimport Ellipsis from './Ellipsis';\nimport Ring from './Ring';\n\nconst StyledMessage = styled.span(({ theme }) => {\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 css`\n margin-top: 0.5rem;\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\nconst Progress: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'ring',\n placement = 'global',\n visible = true,\n onTransitionEndIn,\n onTransitionEndOut,\n value,\n message,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n const [isVisible, setIsVisible] = useState(visible);\n const [isNull, setIsNull] = useState(!visible);\n const { portalTarget } = useConfiguration();\n const showTime = useRef<number>();\n const showTimeout = useRef<number>();\n const hideTimeout = useRef<number>();\n\n let Comp = Ring;\n if (variant === 'bar') Comp = Bar;\n else if (variant === 'ellipsis') Comp = Ellipsis;\n\n const onBackdropTransitionEnd = () => {\n setIsNull(true);\n onTransitionEndOut?.();\n };\n\n useEffect(() => {\n if (visible) {\n clearTimeout(hideTimeout.current);\n showTime.current = Date.now();\n showTimeout.current = window.setTimeout(() => {\n setIsVisible(true);\n setIsNull(false);\n }, 100);\n } else {\n clearTimeout(showTimeout.current);\n\n if (typeof showTime.current === 'number') {\n const minimumDuration = 1000;\n const timeElapsed = Date.now() - showTime.current;\n\n if (timeElapsed > minimumDuration) setIsVisible(false);\n else {\n hideTimeout.current = window.setTimeout(() => {\n setIsVisible(false);\n }, minimumDuration - timeElapsed);\n }\n } else setIsVisible(false);\n }\n }, [visible]);\n\n useEffect(() => {\n return () => {\n clearTimeout(showTimeout.current);\n clearTimeout(hideTimeout.current);\n };\n }, []);\n\n if (isNull) return null;\n\n const comp = (\n <Comp\n {...restProps}\n placement={placement}\n value={value}\n aria-valuetext={message && typeof value === 'number' ? `${message} - ${value}` : message}\n ref={ref}\n />\n );\n\n const content =\n placement === 'inline' ? (\n comp\n ) : (\n <Backdrop\n open={isVisible}\n container={{ direction: 'column' }}\n position={placement === 'global' ? 'fixed' : 'absolute'}\n variant='light'\n alpha={0.5}\n onAfterTransitionIn={onTransitionEndIn}\n onAfterTransitionOut={onBackdropTransitionEnd}\n >\n {comp}\n {!!message && (\n <Text as={StyledMessage} variant='secondary' aria-hidden='true'>\n {message}\n </Text>\n )}\n </Backdrop>\n );\n\n return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Progress;\n"]}
1
+ {"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAuB,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC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AK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChG,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, useState, useEffect, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport styled, { css } from 'styled-components';\nimport { readableColor, rgba } from 'polished';\n\nimport { ForwardProps } from '../../types';\nimport Backdrop from '../Backdrop';\nimport Text from '../Text';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { tryCatch } from '../../utils';\nimport { useConfiguration } from '../../hooks';\n\nimport { ProgressProps } from './Progress.types';\nimport Bar from './Bar';\nimport Ellipsis from './Ellipsis';\nimport Ring from './Ring';\n\nconst StyledMessage = styled.span(({ theme }) => {\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 css`\n margin-top: 0.5rem;\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\nconst Progress: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'ring',\n placement = 'global',\n visible = true,\n onTransitionEndIn,\n onTransitionEndOut,\n value,\n message,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n const [isVisible, setIsVisible] = useState(visible);\n const [isNull, setIsNull] = useState(!visible);\n const { portalTarget } = useConfiguration();\n const showTime = useRef<number>();\n const showTimeout = useRef<number>();\n const hideTimeout = useRef<number>();\n\n let Comp = Ring;\n if (variant === 'bar') Comp = Bar;\n else if (variant === 'ellipsis') Comp = Ellipsis;\n\n const onBackdropTransitionEnd = () => {\n setIsNull(true);\n onTransitionEndOut?.();\n };\n\n useEffect(() => {\n if (visible) {\n clearTimeout(hideTimeout.current);\n showTime.current = Date.now();\n showTimeout.current = window.setTimeout(() => {\n setIsVisible(true);\n setIsNull(false);\n }, 100);\n } else {\n clearTimeout(showTimeout.current);\n\n if (typeof showTime.current === 'number') {\n const minimumDuration = 1000;\n const timeElapsed = Date.now() - showTime.current;\n\n if (timeElapsed > minimumDuration) setIsVisible(false);\n else {\n hideTimeout.current = window.setTimeout(() => {\n setIsVisible(false);\n }, minimumDuration - timeElapsed);\n }\n } else setIsVisible(false);\n }\n }, [visible]);\n\n useEffect(() => {\n return () => {\n clearTimeout(showTimeout.current);\n clearTimeout(hideTimeout.current);\n };\n }, []);\n\n if (isNull) return null;\n\n const comp = (\n <Comp\n {...restProps}\n placement={placement}\n value={value}\n aria-valuetext={message && typeof value === 'number' ? `${message} - ${value}` : message}\n ref={ref}\n />\n );\n\n const content =\n placement === 'inline' ? (\n comp\n ) : (\n <Backdrop\n open={isVisible}\n container={{ direction: 'column' }}\n position={placement === 'global' ? 'fixed' : 'absolute'}\n variant='light'\n alpha={0.5}\n onAfterTransitionIn={onTransitionEndIn}\n onAfterTransitionOut={onBackdropTransitionEnd}\n >\n {comp}\n {!!message && (\n <Text as={StyledMessage} variant='secondary' aria-hidden='true'>\n {message}\n </Text>\n )}\n </Backdrop>\n );\n\n return placement === 'global' && portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default Progress;\n"]}
@@ -25,7 +25,7 @@ export const StyledProgressRing = styled.div(({ theme, placement, determinate })
25
25
 
26
26
  circle {
27
27
  fill: transparent;
28
- stroke: ${theme.base.colors.gray.light};
28
+ stroke: ${theme.base.colors.gray['extra-light']};
29
29
  stroke-width: 2;
30
30
  r: 45%;
31
31
  cx: 50%;
@@ -69,8 +69,7 @@ const Ring = forwardRef(({ value, minValue = 0, maxValue = 100, placement, ...re
69
69
  strokeDashoffset = circumference;
70
70
  else
71
71
  strokeDashoffset = (1 - (value - minValue) / (maxValue - minValue)) * circumference;
72
- return (_jsx(StyledProgressRing, Object.assign({ ref: ref, role: 'progressbar', "aria-valuemin": minValue, "aria-valuemax": maxValue, "aria-valuenow": value, placement: placement, determinate: typeof value === 'number' }, restProps, { children: _jsxs("svg", Object.assign({ viewBox: '0 0 20 20' }, { children: [_jsx("circle", {}, void 0),
73
- _jsx("circle", { strokeDasharray: circumference, style: { strokeDashoffset } }, void 0)] }), void 0) }), void 0));
72
+ return (_jsx(StyledProgressRing, Object.assign({ ref: ref, role: 'progressbar', "aria-valuemin": minValue, "aria-valuemax": maxValue, "aria-valuenow": value, placement: placement, determinate: typeof value === 'number' }, restProps, { children: _jsxs("svg", Object.assign({ viewBox: '0 0 20 20' }, { children: [_jsx("circle", {}, void 0), _jsx("circle", { strokeDasharray: circumference, style: { strokeDashoffset } }, void 0)] }), void 0) }), void 0));
74
73
  });
75
74
  export default Ring;
76
75
  //# sourceMappingURL=Ring.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Ring.js","sourceRoot":"","sources":["../../../src/components/Progress/Ring.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAmB,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAC1C,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE;IACpC,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;oBAsBM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK;;;;;;;;;sBAS1B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;uDACV,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;gBACjE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;;cAElC,CAAC,WAAW;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AAK,KAAK,QAAQ,IAClC,SAAS,cAEb,6BAAK,OAAO,EAAC,WAAW,iBACtB,0BAAU;gBACV,iBAAQ,eAAe,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,WAAI,aACnE,YACa,CACtB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\n\nimport { ProgressProps } from './Progress.types';\n\nexport const StyledProgressRing = styled.div<ProgressProps & { determinate: boolean }>(\n ({ theme, placement, determinate }) => {\n return css`\n position: relative;\n min-width: 1em;\n min-height: 1em;\n\n @keyframes LoadingRing {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n }\n\n svg {\n display: block;\n position: absolute;\n height: 100%;\n\n circle {\n fill: transparent;\n stroke: ${theme.base.colors.gray.light};\n stroke-width: 2;\n r: 45%;\n cx: 50%;\n cy: 50%;\n transform: rotate(-90deg);\n transform-origin: 50% 50%;\n\n &:nth-child(2) {\n stroke: ${theme.components.progress['progress-color']};\n transition: stroke-dashoffset calc(0.5 * ${theme.base.animation.speed})\n ${theme.base.animation.timing.ease};\n\n ${!determinate &&\n css`\n animation: LoadingRing calc(4 * ${theme.base.animation.speed}) linear infinite;\n `}\n }\n }\n }\n\n ${placement === 'inline'\n ? css`\n display: inline-flex;\n vertical-align: top;\n `\n : css`\n width: ${placement === 'global' ? '4' : '2'}rem;\n height: ${placement === 'global' ? '4' : '2'}rem;\n `}\n `;\n }\n);\n\nStyledProgressRing.defaultProps = defaultThemeProp;\n\nconst Ring: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n value,\n minValue = 0,\n maxValue = 100,\n placement,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n let strokeDashoffset;\n const circumference = 18 * Math.PI;\n\n if (typeof value !== 'number') strokeDashoffset = (1 - 33 / 100) * circumference;\n else if (value > maxValue || minValue > maxValue) strokeDashoffset = 0;\n else if (value < minValue) strokeDashoffset = circumference;\n else strokeDashoffset = (1 - (value - minValue) / (maxValue - minValue)) * circumference;\n\n return (\n <StyledProgressRing\n ref={ref}\n role='progressbar'\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n aria-valuenow={value}\n placement={placement}\n determinate={typeof value === 'number'}\n {...restProps}\n >\n <svg viewBox='0 0 20 20'>\n <circle />\n <circle strokeDasharray={circumference} style={{ strokeDashoffset }} />\n </svg>\n </StyledProgressRing>\n );\n }\n);\n\nexport default Ring;\n"]}
1
+ {"version":3,"file":"Ring.js","sourceRoot":"","sources":["../../../src/components/Progress/Ring.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAmB,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAC1C,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE;IACpC,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;oBAsBM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;;;;;;;;;sBASnC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;uDACV,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;gBACjE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;;cAElC,CAAC,WAAW;QACd,GAAG,CAAA;gDACiC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;aAC7D;;;;;QAKL,SAAS,KAAK,QAAQ;QACtB,CAAC,CAAC,GA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,EAAE,gBAAgB,EAAE,WAAI,aACnE,YACa,CACtB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\n\nimport { ProgressProps } from './Progress.types';\n\nexport const StyledProgressRing = styled.div<ProgressProps & { determinate: boolean }>(\n ({ theme, placement, determinate }) => {\n return css`\n position: relative;\n min-width: 1em;\n min-height: 1em;\n\n @keyframes LoadingRing {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n }\n\n svg {\n display: block;\n position: absolute;\n height: 100%;\n\n circle {\n fill: transparent;\n stroke: ${theme.base.colors.gray['extra-light']};\n stroke-width: 2;\n r: 45%;\n cx: 50%;\n cy: 50%;\n transform: rotate(-90deg);\n transform-origin: 50% 50%;\n\n &:nth-child(2) {\n stroke: ${theme.components.progress['progress-color']};\n transition: stroke-dashoffset calc(0.5 * ${theme.base.animation.speed})\n ${theme.base.animation.timing.ease};\n\n ${!determinate &&\n css`\n animation: LoadingRing calc(4 * ${theme.base.animation.speed}) linear infinite;\n `}\n }\n }\n }\n\n ${placement === 'inline'\n ? css`\n display: inline-flex;\n vertical-align: top;\n `\n : css`\n width: ${placement === 'global' ? '4' : '2'}rem;\n height: ${placement === 'global' ? '4' : '2'}rem;\n `}\n `;\n }\n);\n\nStyledProgressRing.defaultProps = defaultThemeProp;\n\nconst Ring: FC<ProgressProps & ForwardProps> = forwardRef(\n (\n {\n value,\n minValue = 0,\n maxValue = 100,\n placement,\n ...restProps\n }: PropsWithoutRef<ProgressProps>,\n ref: ProgressProps['ref']\n ) => {\n let strokeDashoffset;\n const circumference = 18 * Math.PI;\n\n if (typeof value !== 'number') strokeDashoffset = (1 - 33 / 100) * circumference;\n else if (value > maxValue || minValue > maxValue) strokeDashoffset = 0;\n else if (value < minValue) strokeDashoffset = circumference;\n else strokeDashoffset = (1 - (value - minValue) / (maxValue - minValue)) * circumference;\n\n return (\n <StyledProgressRing\n ref={ref}\n role='progressbar'\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n aria-valuenow={value}\n placement={placement}\n determinate={typeof value === 'number'}\n {...restProps}\n >\n <svg viewBox='0 0 20 20'>\n <circle />\n <circle strokeDasharray={circumference} style={{ strokeDashoffset }} />\n </svg>\n </StyledProgressRing>\n );\n }\n);\n\nexport default Ring;\n"]}
@@ -127,10 +127,10 @@ export const StyledRadioCheck = styled.div(props => {
127
127
  font-size: ${fontSize.s};
128
128
  color: ${labelColor};
129
129
  margin: 0;
130
- min-height: ${base.sizes['touch-mouse']};
130
+ min-height: ${base['hit-area']['mouse-min']};
131
131
 
132
132
  @media (pointer: coarse) {
133
- min-height: ${base.sizes['touch-finger']};
133
+ min-height: ${base['hit-area']['finger-min']};
134
134
  }
135
135
  }
136
136
 
@@ -152,7 +152,7 @@ export const StyledRadioCheckCard = styled.label(({ disabled, readOnly, status,
152
152
  background-color: ${card.background};
153
153
  border-radius: ${card['border-radius']};
154
154
  border: 0.0625rem solid ${useBorderColor};
155
- padding: calc(1.5 * ${spacing});
155
+ padding: ${spacing};
156
156
 
157
157
  ${disabled &&
158
158
  css `
@@ -194,11 +194,10 @@ const RadioCheck = forwardRef((props, ref) => {
194
194
  newRef.current.indeterminate = !!indeterminate;
195
195
  }
196
196
  }, [newRef, indeterminate, isRadio]);
197
- return (_jsx(FormField, Object.assign({ as: card ? StyledRadioCheckCard : StyledRadioCheck, label: _jsxs(_Fragment, { children: [_jsx(StyledPseudoRadioCheck, { status: status, isRadio: isRadio, as: StyledFormControl, required: required, disabled: disabled, readOnly: readOnly }, void 0),
198
- label] }, void 0), labelAs: card ? 'div' : undefined, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, inline: true }, { children: _jsx(StyledRadioCheckInput, Object.assign({}, restProps, { id: id, type: type, required: required, disabled: disabled, readOnly: readOnly, "aria-readonly": readOnly, onClick: (e) => {
197
+ return (_jsx(FormField, Object.assign({ as: card ? StyledRadioCheckCard : StyledRadioCheck, label: _jsxs(_Fragment, { children: [_jsx(StyledPseudoRadioCheck, { status: status, isRadio: isRadio, as: StyledFormControl, required: required, disabled: disabled, readOnly: readOnly }, void 0), label] }, void 0), labelAs: card ? 'div' : undefined, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, inline: true }, { children: _jsx(StyledRadioCheckInput, Object.assign({}, restProps, { id: id, type: type, required: required, disabled: disabled, readOnly: readOnly, "aria-readonly": readOnly, onClick: (e) => {
199
198
  if (readOnly)
200
199
  e.preventDefault();
201
- onClick === null || onClick === void 0 ? void 0 : onClick(e);
200
+ onClick?.(e);
202
201
  }, onKeyDown: (e) => {
203
202
  if (type === 'checkbox' && readOnly && e.key === ' ') {
204
203
  e.preventDefault();
@@ -206,7 +205,7 @@ const RadioCheck = forwardRef((props, ref) => {
206
205
  if (type === 'radio' && readOnly && e.key.includes('Arrow')) {
207
206
  e.preventDefault();
208
207
  }
209
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
208
+ onKeyDown?.(e);
210
209
  }, ref: newRef }), void 0) }), void 0));
211
210
  });
212
211
  export default RadioCheck;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioCheck.js","sourceRoot":"","sources":["../../../src/components/RadioCheck/RadioCheck.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,SAAS,EAMV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,M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AC,cAAc,EAAE,CAAC;gBAEjC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,CAAC;YACf,CAAC,EACD,SAAS,EAAE,CAAC,CAAkC,EAAE,EAAE;gBAChD,IAAI,IAAI,KAAK,UAAU,IAAI,QAAQ,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE;oBACpD,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBACD,IAAI,IAAI,KAAK,OAAO,IAAI,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAC3D,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBAED,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,CAAC,CAAC,CAAC;YACjB,CAAC,EACD,GAAG,EAAE,MAAM,YACX,YACQ,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import {\n forwardRef,\n FC,\n Ref,\n useEffect,\n MouseEvent,\n KeyboardEvent,\n PropsWithoutRef,\n MouseEventHandler,\n KeyboardEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, hideVisually, mix } from 'polished';\n\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils/utils';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useConsolidatedRef, useDirection, useUID } from '../../hooks';\nimport { StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\n\nexport interface RadioCheckProps extends BaseProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Sets the type of input. */\n type: 'radio' | 'checkbox';\n /** Sets checked prop via onChange when using as controlled component. */\n checked?: boolean;\n /** Initialize checked prop when using as uncontrolled component. */\n defaultChecked?: boolean;\n /**\n * Sets control to an an indeterminate state.\n * @default false\n */\n indeterminate?: boolean;\n /**\n * Controls the styling of the RadioCheck.\n * @default 'simple'\n */\n variant?: 'simple' | 'card';\n /** Callback function for onClick events. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Callback function for onKeyDown events. */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /** Ref forwarded to the underlying input. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledPseudoRadioCheck = styled.div<Pick<RadioCheckProps, 'readOnly' | 'status'>>(\n props => {\n const {\n theme: {\n base: {\n spacing,\n palette: { 'primary-background': primaryBackground }\n },\n components: {\n 'form-field': formField,\n 'radio-check': {\n size,\n 'touch-size': touchSize,\n 'background-color': backgroundColor,\n 'border-color': borderColor,\n 'border-width': borderWidth\n }\n }\n },\n status\n } = props;\n\n const useBorderColor = status === 'error' ? formField.error['status-color'] : borderColor;\n const useBackgroundColor =\n status && formField[status]\n ? tryCatch(() => mix(0.8, primaryBackground, formField[status]['status-color']))\n : backgroundColor;\n\n return css`\n display: flex;\n flex-shrink: 0;\n position: relative;\n width: ${size};\n height: ${size};\n margin-inline-end: ${spacing};\n border: ${borderWidth} solid ${useBorderColor};\n background-color: ${useBackgroundColor};\n\n @media (pointer: coarse) {\n width: ${touchSize};\n height: ${touchSize};\n }\n\n &::after {\n content: '';\n display: none;\n }\n `;\n }\n);\n\nStyledPseudoRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckInput = styled.input(props => {\n const {\n theme: {\n base: { 'border-radius': baseBorderRadius },\n components: {\n 'form-control': {\n ':focus': { 'box-shadow': shadow, 'border-color': focusBorderColor },\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n },\n 'radio-check': {\n ':checked': {\n 'background-color': checkedBackgroundColor,\n 'border-color': checkedBorderColor\n }\n },\n checkbox: { 'border-radius': checkRadius },\n 'radio-button': { 'border-radius': radioRadius }\n }\n }\n } = props;\n\n const backgroundColor = props.readOnly ? readOnlyBackgroundColor : checkedBackgroundColor;\n const foreground = tryCatch(() => readableColor(backgroundColor));\n\n const prcSelector = `+ ${StyledLabel} ${StyledPseudoRadioCheck}`;\n const { ltr } = useDirection();\n\n return css`\n ${hideVisually}\n\n ${!(props.disabled || props.readOnly) &&\n css`\n &:focus ${prcSelector} {\n box-shadow: ${shadow};\n border-color: ${focusBorderColor};\n }\n `}\n\n &:checked\n ${prcSelector},\n &:checked:disabled\n ${prcSelector},\n &[type='checkbox']:indeterminate\n ${prcSelector},\n &[type='checkbox']:indeterminate:disabled\n ${prcSelector} {\n border-color: ${props.readOnly ? 'inherit' : checkedBorderColor};\n background-color: ${backgroundColor};\n\n &::after {\n display: block;\n }\n }\n\n &[type='radio'] ${prcSelector}, &[type='radio'] ${prcSelector}::after {\n border-radius: ${radioRadius};\n }\n\n &[type='radio'] ${prcSelector}::after {\n margin: auto;\n width: 100%;\n height: 100%;\n background-color: ${foreground};\n transform: scale(0.4);\n }\n\n &[type='checkbox'] ${prcSelector} {\n border-radius: min(calc(${baseBorderRadius} * ${checkRadius}), 0.25rem);\n }\n\n &[type='checkbox']:not(:indeterminate) ${prcSelector} {\n &::after {\n width: 40%;\n height: 75%;\n ${ltr\n ? css`\n transform: rotate(45deg) translate(50%, -30%);\n `\n : css`\n transform: rotate(45deg) translate(-50%, 30%);\n `}\n border-right: 0.15em solid ${foreground};\n border-bottom: 0.15em solid ${foreground};\n }\n }\n\n &[type='checkbox']:indeterminate ${prcSelector} {\n display: flex;\n &::after {\n width: 90%;\n height: 0.15em;\n margin: auto;\n background-color: ${foreground};\n }\n }\n `;\n});\n\nStyledRadioCheckInput.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheck = styled.div<Pick<RadioCheckProps, 'disabled' | 'readOnly'>>(\n props => {\n const {\n disabled,\n readOnly,\n theme: {\n base,\n components: {\n 'radio-check': {\n label: { color: labelColor, 'font-weight': labelFontWeight }\n },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n } = props;\n\n const fontSize = calculateFontSize(base['font-size'], base['font-scale']);\n\n return css`\n > ${StyledLabel} {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: ${labelFontWeight};\n word-break: break-word;\n font-size: ${fontSize.s};\n color: ${labelColor};\n margin: 0;\n min-height: ${base.sizes['touch-mouse']};\n\n @media (pointer: coarse) {\n min-height: ${base.sizes['touch-finger']};\n }\n }\n\n ${!(disabled || readOnly) &&\n css`\n &:not(:focus-within) > ${StyledLabel}:hover ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n `}\n `;\n }\n);\n\nStyledRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckCard = styled.label<\n Pick<RadioCheckProps, 'disabled' | 'readOnly' | 'status'>\n>(\n ({\n disabled,\n readOnly,\n status,\n theme: {\n base: { palette, shadow, spacing },\n components: {\n card,\n 'form-field': formField,\n 'radio-check': { label },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n }) => {\n const useBorderColor =\n status === 'error' ? formField.error['status-color'] : palette['border-line'];\n\n return css`\n min-width: min-content;\n align-items: start;\n cursor: pointer;\n background-color: ${card.background};\n border-radius: ${card['border-radius']};\n border: 0.0625rem solid ${useBorderColor};\n padding: calc(1.5 * ${spacing});\n\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n ${!(disabled || readOnly) &&\n css`\n :hover:not(:focus-within) {\n border-color: ${hoverBorderColor};\n ${StyledLabel} ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n }\n\n :focus-within {\n box-shadow: ${shadow.focus};\n border-color: transparent;\n }\n `}\n\n > ${StyledLabel} {\n display: grid;\n grid-template-columns: auto 1fr;\n color: ${label.color};\n font-weight: ${label['font-weight']};\n }\n `;\n }\n);\n\nStyledRadioCheckCard.defaultProps = defaultThemeProp;\n\nconst RadioCheck: FC<RadioCheckProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<RadioCheckProps>, ref: RadioCheckProps['ref']) => {\n const uid = useUID();\n const {\n type,\n id = uid,\n label,\n required = false,\n disabled = false,\n indeterminate = false,\n readOnly = false,\n variant = 'simple',\n onClick,\n onKeyDown,\n status,\n ...restProps\n } = props;\n\n const isRadio = type === 'radio';\n const card = variant === 'card';\n const newRef = useConsolidatedRef(ref);\n\n useEffect(() => {\n if (!isRadio && newRef.current) {\n newRef.current.indeterminate = !!indeterminate;\n }\n }, [newRef, indeterminate, isRadio]);\n\n return (\n <FormField\n as={card ? StyledRadioCheckCard : StyledRadioCheck}\n label={\n <>\n <StyledPseudoRadioCheck\n status={status}\n isRadio={isRadio}\n as={StyledFormControl}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n />\n {label}\n </>\n }\n labelAs={card ? 'div' : undefined}\n id={id}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n inline\n >\n <StyledRadioCheckInput\n {...restProps}\n id={id}\n type={type}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n aria-readonly={readOnly}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n if (readOnly) e.preventDefault();\n\n onClick?.(e);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (type === 'checkbox' && readOnly && e.key === ' ') {\n e.preventDefault();\n }\n if (type === 'radio' && readOnly && e.key.includes('Arrow')) {\n e.preventDefault();\n }\n\n onKeyDown?.(e);\n }}\n ref={newRef}\n />\n </FormField>\n );\n }\n);\n\nexport default RadioCheck;\n"]}
1
+ {"version":3,"file":"RadioCheck.js","sourceRoot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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EACjC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,sBAEN,KAAC,qBAAqB,oBAChB,SAAS,IACb,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,mBACH,QAAQ,EACvB,OAAO,EAAE,CAAC,CAA+B,EAAE,EAAE;gBAC3C,IAAI,QAAQ;oBAAE,CAAC,CAAC,cAAc,EAAE,CAAC;gBAEjC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,EACD,SAAS,EAAE,CAAC,CAAkC,EAAE,EAAE;gBAChD,IAAI,IAAI,KAAK,UAAU,IAAI,QAAQ,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE;oBACpD,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBACD,IAAI,IAAI,KAAK,OAAO,IAAI,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAC3D,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBAED,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,EACD,GAAG,EAAE,MAAM,YACX,YACQ,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import {\n forwardRef,\n FC,\n Ref,\n useEffect,\n MouseEvent,\n KeyboardEvent,\n PropsWithoutRef,\n MouseEventHandler,\n KeyboardEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, hideVisually, mix } from 'polished';\n\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils/utils';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useConsolidatedRef, useDirection, useUID } from '../../hooks';\nimport { StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\n\nexport interface RadioCheckProps extends BaseProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Sets the type of input. */\n type: 'radio' | 'checkbox';\n /** Sets checked prop via onChange when using as controlled component. */\n checked?: boolean;\n /** Initialize checked prop when using as uncontrolled component. */\n defaultChecked?: boolean;\n /**\n * Sets control to an an indeterminate state.\n * @default false\n */\n indeterminate?: boolean;\n /**\n * Controls the styling of the RadioCheck.\n * @default 'simple'\n */\n variant?: 'simple' | 'card';\n /** Callback function for onClick events. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Callback function for onKeyDown events. */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /** Ref forwarded to the underlying input. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledPseudoRadioCheck = styled.div<Pick<RadioCheckProps, 'readOnly' | 'status'>>(\n props => {\n const {\n theme: {\n base: {\n spacing,\n palette: { 'primary-background': primaryBackground }\n },\n components: {\n 'form-field': formField,\n 'radio-check': {\n size,\n 'touch-size': touchSize,\n 'background-color': backgroundColor,\n 'border-color': borderColor,\n 'border-width': borderWidth\n }\n }\n },\n status\n } = props;\n\n const useBorderColor = status === 'error' ? formField.error['status-color'] : borderColor;\n const useBackgroundColor =\n status && formField[status]\n ? tryCatch(() => mix(0.8, primaryBackground, formField[status]['status-color']))\n : backgroundColor;\n\n return css`\n display: flex;\n flex-shrink: 0;\n position: relative;\n width: ${size};\n height: ${size};\n margin-inline-end: ${spacing};\n border: ${borderWidth} solid ${useBorderColor};\n background-color: ${useBackgroundColor};\n\n @media (pointer: coarse) {\n width: ${touchSize};\n height: ${touchSize};\n }\n\n &::after {\n content: '';\n display: none;\n }\n `;\n }\n);\n\nStyledPseudoRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckInput = styled.input(props => {\n const {\n theme: {\n base: { 'border-radius': baseBorderRadius },\n components: {\n 'form-control': {\n ':focus': { 'box-shadow': shadow, 'border-color': focusBorderColor },\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n },\n 'radio-check': {\n ':checked': {\n 'background-color': checkedBackgroundColor,\n 'border-color': checkedBorderColor\n }\n },\n checkbox: { 'border-radius': checkRadius },\n 'radio-button': { 'border-radius': radioRadius }\n }\n }\n } = props;\n\n const backgroundColor = props.readOnly ? readOnlyBackgroundColor : checkedBackgroundColor;\n const foreground = tryCatch(() => readableColor(backgroundColor));\n\n const prcSelector = `+ ${StyledLabel} ${StyledPseudoRadioCheck}`;\n const { ltr } = useDirection();\n\n return css`\n ${hideVisually}\n\n ${!(props.disabled || props.readOnly) &&\n css`\n &:focus ${prcSelector} {\n box-shadow: ${shadow};\n border-color: ${focusBorderColor};\n }\n `}\n\n &:checked\n ${prcSelector},\n &:checked:disabled\n ${prcSelector},\n &[type='checkbox']:indeterminate\n ${prcSelector},\n &[type='checkbox']:indeterminate:disabled\n ${prcSelector} {\n border-color: ${props.readOnly ? 'inherit' : checkedBorderColor};\n background-color: ${backgroundColor};\n\n &::after {\n display: block;\n }\n }\n\n &[type='radio'] ${prcSelector}, &[type='radio'] ${prcSelector}::after {\n border-radius: ${radioRadius};\n }\n\n &[type='radio'] ${prcSelector}::after {\n margin: auto;\n width: 100%;\n height: 100%;\n background-color: ${foreground};\n transform: scale(0.4);\n }\n\n &[type='checkbox'] ${prcSelector} {\n border-radius: min(calc(${baseBorderRadius} * ${checkRadius}), 0.25rem);\n }\n\n &[type='checkbox']:not(:indeterminate) ${prcSelector} {\n &::after {\n width: 40%;\n height: 75%;\n ${ltr\n ? css`\n transform: rotate(45deg) translate(50%, -30%);\n `\n : css`\n transform: rotate(45deg) translate(-50%, 30%);\n `}\n border-right: 0.15em solid ${foreground};\n border-bottom: 0.15em solid ${foreground};\n }\n }\n\n &[type='checkbox']:indeterminate ${prcSelector} {\n display: flex;\n &::after {\n width: 90%;\n height: 0.15em;\n margin: auto;\n background-color: ${foreground};\n }\n }\n `;\n});\n\nStyledRadioCheckInput.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheck = styled.div<Pick<RadioCheckProps, 'disabled' | 'readOnly'>>(\n props => {\n const {\n disabled,\n readOnly,\n theme: {\n base,\n components: {\n 'radio-check': {\n label: { color: labelColor, 'font-weight': labelFontWeight }\n },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n } = props;\n\n const fontSize = calculateFontSize(base['font-size'], base['font-scale']);\n\n return css`\n > ${StyledLabel} {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: ${labelFontWeight};\n word-break: break-word;\n font-size: ${fontSize.s};\n color: ${labelColor};\n margin: 0;\n min-height: ${base['hit-area']['mouse-min']};\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n }\n\n ${!(disabled || readOnly) &&\n css`\n &:not(:focus-within) > ${StyledLabel}:hover ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n `}\n `;\n }\n);\n\nStyledRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckCard = styled.label<\n Pick<RadioCheckProps, 'disabled' | 'readOnly' | 'status'>\n>(\n ({\n disabled,\n readOnly,\n status,\n theme: {\n base: { palette, shadow, spacing },\n components: {\n card,\n 'form-field': formField,\n 'radio-check': { label },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n }) => {\n const useBorderColor =\n status === 'error' ? formField.error['status-color'] : palette['border-line'];\n\n return css`\n min-width: min-content;\n align-items: start;\n cursor: pointer;\n background-color: ${card.background};\n border-radius: ${card['border-radius']};\n border: 0.0625rem solid ${useBorderColor};\n padding: ${spacing};\n\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n ${!(disabled || readOnly) &&\n css`\n :hover:not(:focus-within) {\n border-color: ${hoverBorderColor};\n ${StyledLabel} ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n }\n\n :focus-within {\n box-shadow: ${shadow.focus};\n border-color: transparent;\n }\n `}\n\n > ${StyledLabel} {\n display: grid;\n grid-template-columns: auto 1fr;\n color: ${label.color};\n font-weight: ${label['font-weight']};\n }\n `;\n }\n);\n\nStyledRadioCheckCard.defaultProps = defaultThemeProp;\n\nconst RadioCheck: FC<RadioCheckProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<RadioCheckProps>, ref: RadioCheckProps['ref']) => {\n const uid = useUID();\n const {\n type,\n id = uid,\n label,\n required = false,\n disabled = false,\n indeterminate = false,\n readOnly = false,\n variant = 'simple',\n onClick,\n onKeyDown,\n status,\n ...restProps\n } = props;\n\n const isRadio = type === 'radio';\n const card = variant === 'card';\n const newRef = useConsolidatedRef(ref);\n\n useEffect(() => {\n if (!isRadio && newRef.current) {\n newRef.current.indeterminate = !!indeterminate;\n }\n }, [newRef, indeterminate, isRadio]);\n\n return (\n <FormField\n as={card ? StyledRadioCheckCard : StyledRadioCheck}\n label={\n <>\n <StyledPseudoRadioCheck\n status={status}\n isRadio={isRadio}\n as={StyledFormControl}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n />\n {label}\n </>\n }\n labelAs={card ? 'div' : undefined}\n id={id}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n inline\n >\n <StyledRadioCheckInput\n {...restProps}\n id={id}\n type={type}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n aria-readonly={readOnly}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n if (readOnly) e.preventDefault();\n\n onClick?.(e);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (type === 'checkbox' && readOnly && e.key === ' ') {\n e.preventDefault();\n }\n if (type === 'radio' && readOnly && e.key.includes('Arrow')) {\n e.preventDefault();\n }\n\n onKeyDown?.(e);\n }}\n ref={newRef}\n />\n </FormField>\n );\n }\n);\n\nexport default RadioCheck;\n"]}
@@ -4,7 +4,7 @@ import styled from 'styled-components';
4
4
  import FormField from '../FormField';
5
5
  import { StyledFormField } from '../FormField/FormField';
6
6
  import Grid from '../Grid';
7
- import { useElement } from '../../hooks';
7
+ import { useElement, useUID } from '../../hooks';
8
8
  const defaultProps = {
9
9
  required: false,
10
10
  disabled: false
@@ -16,7 +16,9 @@ const StyledRadioCheckGroup = styled.fieldset `
16
16
  }
17
17
  }
18
18
  `;
19
- const RadioCheckGroup = forwardRef(({ children, name, disabled, onChange, readOnly, inline = false, autoStack = true, variant = 'simple', ...restProps }, ref) => {
19
+ const RadioCheckGroup = forwardRef((props, ref) => {
20
+ const uid = useUID();
21
+ const { children, name = uid, disabled, onChange, readOnly, inline = false, autoStack = true, variant = 'simple', ...restProps } = props;
20
22
  const [optionsEl, setOptionsEl] = useElement();
21
23
  const [renderInline, setRenderInline] = useState(inline);
22
24
  const renderInlineRef = useRef(inline);
@@ -53,8 +55,8 @@ const RadioCheckGroup = forwardRef(({ children, name, disabled, onChange, readOn
53
55
  disabled,
54
56
  ...restProps
55
57
  }, { children: _jsx(Grid, Object.assign({ ref: setOptionsEl, container: {
56
- colGap: 2,
57
- rowGap: variant === 'card' ? 2 : 0,
58
+ colGap: 1,
59
+ rowGap: variant === 'card' ? 1 : 0,
58
60
  cols: renderInline ? 'repeat(auto-fit, minmax(1ch, max-content))' : '1fr'
59
61
  } }, { children: Children.map(children, child => cloneElement(child, {
60
62
  name,
@@ -63,9 +65,8 @@ const RadioCheckGroup = forwardRef(({ children, name, disabled, onChange, readOn
63
65
  variant,
64
66
  onChange: onChange
65
67
  ? (e) => {
66
- var _a, _b;
67
68
  if (!(readOnly || child.props.readOnly)) {
68
- (_b = (_a = child.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, e);
69
+ child.props.onChange?.(e);
69
70
  onChange(e);
70
71
  }
71
72
  }