@pega/cosmos-react-core 4.0.0-dev.13.0 → 4.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 (321) hide show
  1. package/README.md +2 -2
  2. package/lib/components/AppShell/AppShell.js.map +1 -1
  3. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  4. package/lib/components/AppShell/AppShell.styles.js +10 -12
  5. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  6. package/lib/components/AppShell/AppShell.types.d.ts +6 -6
  7. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
  8. package/lib/components/AppShell/AppShell.types.js.map +1 -1
  9. package/lib/components/AppShell/AppShellContext.d.ts +1 -1
  10. package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
  11. package/lib/components/AppShell/AppShellContext.js.map +1 -1
  12. package/lib/components/AppShell/AppShellList.styles.js +1 -1
  13. package/lib/components/AppShell/AppShellList.styles.js.map +1 -1
  14. package/lib/components/AppShell/NavigationList.js.map +1 -1
  15. package/lib/components/Banner/Banner.d.ts.map +1 -1
  16. package/lib/components/Banner/Banner.js +3 -3
  17. package/lib/components/Banner/Banner.js.map +1 -1
  18. package/lib/components/Boolean/BooleanDisplay.js +2 -2
  19. package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
  20. package/lib/components/Button/Button.d.ts +3 -1
  21. package/lib/components/Button/Button.d.ts.map +1 -1
  22. package/lib/components/Button/Button.js +168 -142
  23. package/lib/components/Button/Button.js.map +1 -1
  24. package/lib/components/ColorPicker/ColorPicker.js +1 -1
  25. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  26. package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts +1 -1
  27. package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts.map +1 -1
  28. package/lib/components/ColorPicker/ColorPicker.test-ids.js +5 -1
  29. package/lib/components/ColorPicker/ColorPicker.test-ids.js.map +1 -1
  30. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  31. package/lib/components/ComboBox/ComboBox.js +2 -10
  32. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  33. package/lib/components/ComboBox/ComboxBox.test-ids.d.ts +1 -1
  34. package/lib/components/ComboBox/ComboxBox.test-ids.d.ts.map +1 -1
  35. package/lib/components/ComboBox/ComboxBox.test-ids.js +2 -1
  36. package/lib/components/ComboBox/ComboxBox.test-ids.js.map +1 -1
  37. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  38. package/lib/components/CompositeInput/CompositeInput.js +8 -10
  39. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  40. package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts +1 -1
  41. package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts.map +1 -1
  42. package/lib/components/CompositeInput/CompositeInput.test-ids.js +5 -1
  43. package/lib/components/CompositeInput/CompositeInput.test-ids.js.map +1 -1
  44. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  45. package/lib/components/Configuration/Configuration.js +5 -1
  46. package/lib/components/Configuration/Configuration.js.map +1 -1
  47. package/lib/components/Currency/Currency.test-ids.d.ts +1 -1
  48. package/lib/components/Currency/Currency.test-ids.d.ts.map +1 -1
  49. package/lib/components/Currency/Currency.test-ids.js +5 -1
  50. package/lib/components/Currency/Currency.test-ids.js.map +1 -1
  51. package/lib/components/Currency/CurrencyInput.js +1 -1
  52. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  53. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  54. package/lib/components/DateTime/Input/DateInput.js +25 -32
  55. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  56. package/lib/components/DateTime/Input/DateTime.styles.d.ts +1 -0
  57. package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
  58. package/lib/components/DateTime/Input/DateTime.styles.js +3 -0
  59. package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
  60. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  61. package/lib/components/DateTime/Input/DateTimeInput.js +20 -27
  62. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  63. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  64. package/lib/components/DateTime/Input/TimeInput.js +1 -9
  65. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  66. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  67. package/lib/components/DateTime/Input/WeekInput.js +11 -17
  68. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  69. package/lib/components/DateTime/Picker/Calendar.js +1 -1
  70. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  71. package/lib/components/DateTime/Picker/Weeks.js +1 -1
  72. package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
  73. package/lib/components/DateTime/utils.d.ts.map +1 -1
  74. package/lib/components/DateTime/utils.js +8 -6
  75. package/lib/components/DateTime/utils.js.map +1 -1
  76. package/lib/components/Dialog/Dialog.d.ts.map +1 -1
  77. package/lib/components/Dialog/Dialog.js +2 -2
  78. package/lib/components/Dialog/Dialog.js.map +1 -1
  79. package/lib/components/Dialog/Dialog.styles.d.ts +3 -0
  80. package/lib/components/Dialog/Dialog.styles.d.ts.map +1 -1
  81. package/lib/components/Dialog/Dialog.styles.js +29 -2
  82. package/lib/components/Dialog/Dialog.styles.js.map +1 -1
  83. package/lib/components/Dialog/Dialog.types.d.ts +36 -14
  84. package/lib/components/Dialog/Dialog.types.d.ts.map +1 -1
  85. package/lib/components/Dialog/Dialog.types.js +0 -1
  86. package/lib/components/Dialog/Dialog.types.js.map +1 -1
  87. package/lib/components/Dialog/FormDialog.d.ts +4 -1
  88. package/lib/components/Dialog/FormDialog.d.ts.map +1 -1
  89. package/lib/components/Dialog/FormDialog.js +4 -5
  90. package/lib/components/Dialog/FormDialog.js.map +1 -1
  91. package/lib/components/Dialog/InfoDialog.d.ts +0 -1
  92. package/lib/components/Dialog/InfoDialog.d.ts.map +1 -1
  93. package/lib/components/Dialog/InfoDialog.js +15 -13
  94. package/lib/components/Dialog/InfoDialog.js.map +1 -1
  95. package/lib/components/Dialog/InfoDialog.styles.d.ts +6 -0
  96. package/lib/components/Dialog/InfoDialog.styles.d.ts.map +1 -0
  97. package/lib/components/Dialog/InfoDialog.styles.js +18 -0
  98. package/lib/components/Dialog/InfoDialog.styles.js.map +1 -0
  99. package/lib/components/EmojiPicker/EmojiPicker.styles.js +1 -1
  100. package/lib/components/EmojiPicker/EmojiPicker.styles.js.map +1 -1
  101. package/lib/components/FieldValueList/FieldValueList.d.ts +4 -2
  102. package/lib/components/FieldValueList/FieldValueList.d.ts.map +1 -1
  103. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  104. package/lib/components/FieldValueList/FieldValueList.test-ids.d.ts +2 -2
  105. package/lib/components/FieldValueList/FieldValueList.test-ids.d.ts.map +1 -1
  106. package/lib/components/FieldValueList/index.d.ts +1 -1
  107. package/lib/components/FieldValueList/index.d.ts.map +1 -1
  108. package/lib/components/FieldValueList/index.js.map +1 -1
  109. package/lib/components/File/File.test-ids.d.ts +1 -1
  110. package/lib/components/File/File.test-ids.d.ts.map +1 -1
  111. package/lib/components/File/File.test-ids.js +6 -1
  112. package/lib/components/File/File.test-ids.js.map +1 -1
  113. package/lib/components/File/FileInput.js +1 -1
  114. package/lib/components/File/FileInput.js.map +1 -1
  115. package/lib/components/Flex/Flex.d.ts +7 -1
  116. package/lib/components/Flex/Flex.d.ts.map +1 -1
  117. package/lib/components/Flex/Flex.js +37 -10
  118. package/lib/components/Flex/Flex.js.map +1 -1
  119. package/lib/components/FormField/FormField.d.ts +2 -1
  120. package/lib/components/FormField/FormField.d.ts.map +1 -1
  121. package/lib/components/FormField/FormField.js.map +1 -1
  122. package/lib/components/FormField/FormField.test-ids.d.ts +2 -1
  123. package/lib/components/FormField/FormField.test-ids.d.ts.map +1 -1
  124. package/lib/components/FormField/FormField.test-ids.js +3 -2
  125. package/lib/components/FormField/FormField.test-ids.js.map +1 -1
  126. package/lib/components/Icon/iconNames.d.ts +2 -2
  127. package/lib/components/Icon/iconNames.d.ts.map +1 -1
  128. package/lib/components/Icon/iconNames.js +2 -0
  129. package/lib/components/Icon/iconNames.js.map +1 -1
  130. package/lib/components/Icon/icons/phone-merge-solid.icon.d.ts +4 -0
  131. package/lib/components/Icon/icons/phone-merge-solid.icon.d.ts.map +1 -0
  132. package/lib/components/Icon/icons/phone-merge-solid.icon.js +6 -0
  133. package/lib/components/Icon/icons/phone-merge-solid.icon.js.map +1 -0
  134. package/lib/components/Icon/icons/phone-merge.icon.d.ts +4 -0
  135. package/lib/components/Icon/icons/phone-merge.icon.d.ts.map +1 -0
  136. package/lib/components/Icon/icons/phone-merge.icon.js +6 -0
  137. package/lib/components/Icon/icons/phone-merge.icon.js.map +1 -0
  138. package/lib/components/IconPicker/IconPicker.js +2 -2
  139. package/lib/components/IconPicker/IconPicker.js.map +1 -1
  140. package/lib/components/Input/Input.js +1 -1
  141. package/lib/components/Input/Input.js.map +1 -1
  142. package/lib/components/Input/Input.test-ids.d.ts +1 -1
  143. package/lib/components/Input/Input.test-ids.d.ts.map +1 -1
  144. package/lib/components/Input/Input.test-ids.js +2 -1
  145. package/lib/components/Input/Input.test-ids.js.map +1 -1
  146. package/lib/components/List/List.d.ts.map +1 -1
  147. package/lib/components/List/List.js.map +1 -1
  148. package/lib/components/ListToolbar/ListToolbar.d.ts +1 -1
  149. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  150. package/lib/components/ListToolbar/ListToolbar.js +49 -17
  151. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  152. package/lib/components/ListToolbar/ListToolbar.styles.d.ts +3 -1
  153. package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
  154. package/lib/components/ListToolbar/ListToolbar.styles.js +2 -3
  155. package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
  156. package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts +2 -0
  157. package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts.map +1 -0
  158. package/lib/components/ListToolbar/ListToolbar.test-ids.js +7 -0
  159. package/lib/components/ListToolbar/ListToolbar.test-ids.js.map +1 -0
  160. package/lib/components/ListToolbar/ListToolbar.types.d.ts +31 -8
  161. package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
  162. package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
  163. package/lib/components/ListToolbar/helpers.d.ts +10 -0
  164. package/lib/components/ListToolbar/helpers.d.ts.map +1 -0
  165. package/lib/components/ListToolbar/helpers.js +46 -0
  166. package/lib/components/ListToolbar/helpers.js.map +1 -0
  167. package/lib/components/ListToolbar/index.d.ts +1 -0
  168. package/lib/components/ListToolbar/index.d.ts.map +1 -1
  169. package/lib/components/ListToolbar/index.js +1 -0
  170. package/lib/components/ListToolbar/index.js.map +1 -1
  171. package/lib/components/LiveLog/LiveLog.d.ts.map +1 -1
  172. package/lib/components/LiveLog/LiveLog.js +17 -16
  173. package/lib/components/LiveLog/LiveLog.js.map +1 -1
  174. package/lib/components/Location/Location.test-ids.d.ts +1 -1
  175. package/lib/components/Location/Location.test-ids.d.ts.map +1 -1
  176. package/lib/components/Location/Location.test-ids.js +5 -1
  177. package/lib/components/Location/Location.test-ids.js.map +1 -1
  178. package/lib/components/Location/LocationInput.js +1 -1
  179. package/lib/components/Location/LocationInput.js.map +1 -1
  180. package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
  181. package/lib/components/Menu/Menu.styles.js +1 -4
  182. package/lib/components/Menu/Menu.styles.js.map +1 -1
  183. package/lib/components/Menu/Menu.test-ids.d.ts +2 -2
  184. package/lib/components/Menu/Menu.test-ids.d.ts.map +1 -1
  185. package/lib/components/Menu/NavItemsList.d.ts.map +1 -1
  186. package/lib/components/Menu/NavItemsList.js +2 -0
  187. package/lib/components/Menu/NavItemsList.js.map +1 -1
  188. package/lib/components/MenuButton/MenuButton.d.ts +2 -2
  189. package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
  190. package/lib/components/MenuButton/MenuButton.js +6 -4
  191. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  192. package/lib/components/MenuButton/MenuButton.test-ids.d.ts +2 -0
  193. package/lib/components/MenuButton/MenuButton.test-ids.d.ts.map +1 -0
  194. package/lib/components/MenuButton/MenuButton.test-ids.js +3 -0
  195. package/lib/components/MenuButton/MenuButton.test-ids.js.map +1 -0
  196. package/lib/components/MetaList/MetaList.test-ids.d.ts +1 -1
  197. package/lib/components/MetaList/MetaList.test-ids.d.ts.map +1 -1
  198. package/lib/components/Modal/Modal.styles.js +1 -1
  199. package/lib/components/Modal/Modal.styles.js.map +1 -1
  200. package/lib/components/Modal/ModalManager.d.ts.map +1 -1
  201. package/lib/components/Modal/ModalManager.js +5 -2
  202. package/lib/components/Modal/ModalManager.js.map +1 -1
  203. package/lib/components/Number/Number.test-ids.d.ts +2 -2
  204. package/lib/components/Number/Number.test-ids.d.ts.map +1 -1
  205. package/lib/components/Number/Number.test-ids.js +8 -2
  206. package/lib/components/Number/Number.test-ids.js.map +1 -1
  207. package/lib/components/Number/NumberInput.js +1 -1
  208. package/lib/components/Number/NumberInput.js.map +1 -1
  209. package/lib/components/Number/NumberRangeInput.js +1 -1
  210. package/lib/components/Number/NumberRangeInput.js.map +1 -1
  211. package/lib/components/PageTemplates/PageTemplates.js +2 -2
  212. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  213. package/lib/components/Phone/Phone.test-ids.d.ts +1 -1
  214. package/lib/components/Phone/Phone.test-ids.d.ts.map +1 -1
  215. package/lib/components/Phone/Phone.test-ids.js +3 -1
  216. package/lib/components/Phone/Phone.test-ids.js.map +1 -1
  217. package/lib/components/Phone/PhoneInput.js +2 -2
  218. package/lib/components/Phone/PhoneInput.js.map +1 -1
  219. package/lib/components/Popover/Popover.d.ts +1 -0
  220. package/lib/components/Popover/Popover.d.ts.map +1 -1
  221. package/lib/components/Popover/Popover.js +37 -40
  222. package/lib/components/Popover/Popover.js.map +1 -1
  223. package/lib/components/Popover/PopoverManager.d.ts.map +1 -1
  224. package/lib/components/Popover/PopoverManager.js +11 -10
  225. package/lib/components/Popover/PopoverManager.js.map +1 -1
  226. package/lib/components/Popover/modifiers.d.ts +1 -0
  227. package/lib/components/Popover/modifiers.d.ts.map +1 -1
  228. package/lib/components/Popover/modifiers.js +97 -1
  229. package/lib/components/Popover/modifiers.js.map +1 -1
  230. package/lib/components/Progress/Progress.styles.d.ts.map +1 -1
  231. package/lib/components/Progress/Progress.styles.js +25 -20
  232. package/lib/components/Progress/Progress.styles.js.map +1 -1
  233. package/lib/components/RadioCheck/RadioCheck.js +2 -2
  234. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  235. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  236. package/lib/components/SearchInput/SearchInput.js +1 -9
  237. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  238. package/lib/components/Select/Select.js +2 -2
  239. package/lib/components/Select/Select.js.map +1 -1
  240. package/lib/components/Select/Select.test-ids.d.ts +1 -1
  241. package/lib/components/Select/Select.test-ids.d.ts.map +1 -1
  242. package/lib/components/Select/Select.test-ids.js +2 -1
  243. package/lib/components/Select/Select.test-ids.js.map +1 -1
  244. package/lib/components/Slider/Slider.js +1 -1
  245. package/lib/components/Slider/Slider.js.map +1 -1
  246. package/lib/components/Slider/Slider.styles.d.ts.map +1 -1
  247. package/lib/components/Slider/Slider.styles.js +114 -128
  248. package/lib/components/Slider/Slider.styles.js.map +1 -1
  249. package/lib/components/Slider/Slider.test-ids.d.ts +1 -1
  250. package/lib/components/Slider/Slider.test-ids.d.ts.map +1 -1
  251. package/lib/components/Slider/Slider.test-ids.js +2 -1
  252. package/lib/components/Slider/Slider.test-ids.js.map +1 -1
  253. package/lib/components/Slider/utils.d.ts.map +1 -1
  254. package/lib/components/Slider/utils.js +0 -1
  255. package/lib/components/Slider/utils.js.map +1 -1
  256. package/lib/components/SummaryItem/SummaryItem.test-ids.d.ts +1 -1
  257. package/lib/components/SummaryItem/SummaryItem.test-ids.d.ts.map +1 -1
  258. package/lib/components/Tabs/Tab.d.ts.map +1 -1
  259. package/lib/components/Tabs/Tab.js +21 -18
  260. package/lib/components/Tabs/Tab.js.map +1 -1
  261. package/lib/components/TextArea/TextArea.js +1 -1
  262. package/lib/components/TextArea/TextArea.js.map +1 -1
  263. package/lib/components/TextArea/TextArea.test-ids.d.ts +1 -1
  264. package/lib/components/TextArea/TextArea.test-ids.d.ts.map +1 -1
  265. package/lib/components/TextArea/TextArea.test-ids.js +2 -1
  266. package/lib/components/TextArea/TextArea.test-ids.js.map +1 -1
  267. package/lib/hooks/index.d.ts +1 -0
  268. package/lib/hooks/index.d.ts.map +1 -1
  269. package/lib/hooks/index.js +1 -0
  270. package/lib/hooks/index.js.map +1 -1
  271. package/lib/hooks/useBreakpoint.d.ts.map +1 -1
  272. package/lib/hooks/useBreakpoint.js +4 -1
  273. package/lib/hooks/useBreakpoint.js.map +1 -1
  274. package/lib/hooks/useChToPxConversionFactor.d.ts +3 -0
  275. package/lib/hooks/useChToPxConversionFactor.d.ts.map +1 -0
  276. package/lib/hooks/useChToPxConversionFactor.js +13 -0
  277. package/lib/hooks/useChToPxConversionFactor.js.map +1 -0
  278. package/lib/hooks/useElement.d.ts +1 -1
  279. package/lib/hooks/useElement.d.ts.map +1 -1
  280. package/lib/hooks/useI18n.d.ts +13 -0
  281. package/lib/hooks/useI18n.d.ts.map +1 -1
  282. package/lib/hooks/useScrollToggle.d.ts.map +1 -1
  283. package/lib/hooks/useScrollToggle.js +0 -1
  284. package/lib/hooks/useScrollToggle.js.map +1 -1
  285. package/lib/hooks/useTestIds.d.ts +1 -1
  286. package/lib/hooks/useTestIds.d.ts.map +1 -1
  287. package/lib/hooks/useTestIds.js +3 -0
  288. package/lib/hooks/useTestIds.js.map +1 -1
  289. package/lib/i18n/default.d.ts +13 -0
  290. package/lib/i18n/default.d.ts.map +1 -1
  291. package/lib/i18n/default.js +14 -0
  292. package/lib/i18n/default.js.map +1 -1
  293. package/lib/i18n/i18n.d.ts +13 -0
  294. package/lib/i18n/i18n.d.ts.map +1 -1
  295. package/lib/styles/gradients.d.ts.map +1 -1
  296. package/lib/styles/gradients.js.map +1 -1
  297. package/lib/theme/ThemeMachine.js.map +1 -1
  298. package/lib/types/types.d.ts +7 -2
  299. package/lib/types/types.d.ts.map +1 -1
  300. package/lib/types/types.js.map +1 -1
  301. package/lib/utils/createTestIds.d.ts +1 -6
  302. package/lib/utils/createTestIds.d.ts.map +1 -1
  303. package/lib/utils/createTestIds.js +2 -4
  304. package/lib/utils/createTestIds.js.map +1 -1
  305. package/lib/utils/debounce.d.ts +2 -2
  306. package/lib/utils/debounce.d.ts.map +1 -1
  307. package/lib/utils/debounce.js +9 -10
  308. package/lib/utils/debounce.js.map +1 -1
  309. package/lib/utils/getEdge.d.ts +7 -0
  310. package/lib/utils/getEdge.d.ts.map +1 -0
  311. package/lib/utils/getEdge.js +9 -0
  312. package/lib/utils/getEdge.js.map +1 -0
  313. package/lib/utils/index.d.ts +2 -1
  314. package/lib/utils/index.d.ts.map +1 -1
  315. package/lib/utils/index.js +2 -0
  316. package/lib/utils/index.js.map +1 -1
  317. package/lib/utils/throttle.d.ts +4 -0
  318. package/lib/utils/throttle.d.ts.map +1 -0
  319. package/lib/utils/throttle.js +15 -0
  320. package/lib/utils/throttle.js.map +1 -0
  321. package/package.json +2 -2
@@ -11,94 +11,136 @@ import Progress, { StyledProgressRing } from '../Progress';
11
11
  import { StyledBackdrop } from '../Backdrop';
12
12
  import { StyledIcon } from '../Icon';
13
13
  import { StyledPopover } from '../Popover';
14
- export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ variant, icon, loading, compact, theme: { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'primary-background': backgroundColor, 'foreground-color': textColor }, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger, 'compact-min': hitAreaCompact }, animation: { speed, timing: { ease } }, 'disabled-opacity': disabledOpacity }, components: { button: { color, 'secondary-color': secondaryColor, padding, 'border-radius': borderRadius, 'border-width': borderWidth, 'focus-shadow': focusShadow, touch: { padding: touchPadding } }, link: { color: linkColor } } } }) => {
15
- const borderColor = variant === 'secondary' ? color : 'transparent';
16
- const contrastColor = tryCatch(() => readableColor(color));
17
- const hoverColors = getHoverColors(color);
18
- const hoverPrimaryColor = hoverColors.background;
19
- const hoverContrastColor = hoverColors.foreground;
20
- const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, color));
21
- const secondaryHoverForegroundColor = readableHue(color, secondaryHoverBackgroundColor ?? 'transparent');
22
- let buttonColor = contrastColor;
23
- let buttonBackgroundColor = color;
24
- if (variant === 'secondary') {
25
- buttonColor = color;
26
- buttonBackgroundColor = secondaryColor;
14
+ const baseStyles = (theme) => {
15
+ const { base: { spacing, animation: { speed, timing: { ease } }, 'disabled-opacity': disabledOpacity }, components: { button: { 'focus-shadow': focusShadow } } } = theme;
16
+ return css `
17
+ outline: none;
18
+ text-decoration: none;
19
+ transition-property: background-color, color, box-shadow;
20
+ transition-duration: calc(0.5 * ${speed});
21
+ transition-timing-function: ${ease};
22
+ cursor: pointer;
23
+
24
+ & + & {
25
+ margin-inline-start: ${spacing};
27
26
  }
28
- else if (variant === 'simple') {
29
- if (icon) {
30
- buttonColor = 'currentColor';
31
- buttonBackgroundColor = 'transparent';
32
- }
33
- else {
34
- buttonColor = color;
35
- buttonBackgroundColor = backgroundColor;
36
- }
27
+
28
+ /* Not able to combine with selector above. Stylis bug? */
29
+ & + ${StyledPopover} + & {
30
+ margin-inline-start: ${spacing};
37
31
  }
38
- else if (variant === 'link') {
39
- buttonColor = linkColor;
40
- buttonBackgroundColor = 'transparent';
32
+
33
+ &:disabled,
34
+ &[disabled] {
35
+ opacity: ${disabledOpacity};
36
+ cursor: not-allowed;
37
+ pointer-events: none;
41
38
  }
42
- else if (variant === 'text') {
43
- buttonColor = textColor;
44
- buttonBackgroundColor = 'transparent';
39
+
40
+ &:enabled:focus,
41
+ &:not([disabled]):focus {
42
+ box-shadow: ${focusShadow};
45
43
  }
46
- return css `
47
- color: ${buttonColor};
48
- background-color: ${buttonBackgroundColor};
49
- display: ${variant === 'link' || variant === 'text' ? 'inline' : 'inline-flex'};
44
+ `;
45
+ };
46
+ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ variant, icon, loading, compact, theme }) => {
47
+ const { base: { 'border-radius': baseBorderRadius, palette: { 'primary-background': backgroundColor }, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger, 'compact-min': hitAreaCompact }, animation: { speed } }, components: { button: { color, 'secondary-color': secondaryColor, padding, 'border-radius': borderRadius, 'border-width': borderWidth, touch: { padding: touchPadding } } } } = theme;
48
+ const contrastColor = tryCatch(() => readableColor(color));
49
+ // Base
50
+ const base = baseStyles(theme);
51
+ // Non-text base
52
+ const nonTextual = css `
53
+ position: relative;
54
+ display: inline-flex;
50
55
  align-items: center;
51
- outline: none;
52
- text-decoration: none;
53
- transition-property: background-color, color, box-shadow;
54
- transition-duration: calc(0.5 * ${speed});
55
- transition-timing-function: ${ease};
56
- cursor: pointer;
57
-
58
- ${variant !== 'link' && variant !== 'text'
59
- ? css `
60
- justify-content: center;
61
- line-height: 1;
62
- border: ${borderWidth} solid ${borderColor};
63
- position: relative;
64
- `
65
- : css `
66
- text-align: start;
67
- border: none;
68
-
69
- > ${StyledIcon} {
70
- vertical-align: bottom;
71
- }
72
- `}
56
+ justify-content: center;
57
+ min-height: ${hitAreaMouse};
58
+ min-width: ${hitAreaMouse};
59
+ line-height: 1;
60
+ border: ${borderWidth} solid transparent;
61
+ border-radius: calc(${baseBorderRadius} * ${borderRadius});
62
+ -webkit-user-select: none;
63
+ user-select: none;
73
64
 
74
- & + & {
75
- margin-inline-start: ${spacing};
76
- }
65
+ ${!icon &&
66
+ css `
67
+ padding: ${padding};
68
+ `}
77
69
 
78
- /* Not able to combine with selector above. Stylis bug? */
79
- & + ${StyledPopover} + & {
80
- margin-inline-start: ${spacing};
70
+ ${icon &&
71
+ css `
72
+ border-radius: calc(${baseBorderRadius} * ${borderRadius});
73
+
74
+ > svg {
75
+ display: block;
76
+ }
77
+ `}
78
+
79
+ ${compact &&
80
+ css `
81
+ min-height: ${hitAreaCompact};
82
+ min-width: ${hitAreaCompact};
83
+ `}
84
+
85
+ @media (pointer: coarse) {
86
+ border-radius: calc(${baseBorderRadius} * ${borderRadius});
87
+
88
+ ${!compact &&
89
+ css `
90
+ min-height: ${hitAreaFinger};
91
+ min-width: ${hitAreaFinger};
92
+ `}
93
+
94
+ ${!icon &&
95
+ css `
96
+ padding: ${touchPadding};
97
+ `}
81
98
  }
99
+ `;
100
+ // Primary
101
+ const hoverColors = getHoverColors(color);
102
+ const hoverPrimaryColor = hoverColors.background;
103
+ const hoverContrastColor = hoverColors.foreground;
104
+ const primary = css `
105
+ --button-background-color: ${color};
106
+ color: ${contrastColor};
107
+ background-color: ${color};
82
108
 
83
109
  @media (hover: hover) {
84
110
  &:hover {
85
- ${variant === 'primary' &&
86
- css `
87
- background-color: ${hoverPrimaryColor};
88
- color: ${hoverContrastColor};
89
- text-decoration: none;
90
- `}
111
+ background-color: ${hoverPrimaryColor};
112
+ color: ${hoverContrastColor};
113
+ text-decoration: none;
114
+ }
115
+ }
116
+ `;
117
+ // Secondary
118
+ const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, color));
119
+ const secondaryHoverForegroundColor = readableHue(color, secondaryHoverBackgroundColor ?? 'transparent');
120
+ const secondary = css `
121
+ --button-background-color: ${secondaryColor};
122
+ color: ${color};
123
+ background-color: ${secondaryColor};
124
+ border-color: ${color};
91
125
 
92
- ${(variant === 'secondary' || (variant === 'simple' && !icon)) &&
93
- css `
94
- background-color: ${secondaryHoverBackgroundColor};
95
- color: ${secondaryHoverForegroundColor};
96
- border-color: ${secondaryHoverForegroundColor};
97
- text-decoration: none;
98
- `}
126
+ @media (hover: hover) {
127
+ &:hover {
128
+ color: ${secondaryHoverForegroundColor};
129
+ background-color: ${secondaryHoverBackgroundColor};
130
+ text-decoration: none;
131
+ border-color: ${secondaryHoverForegroundColor};
132
+ }
133
+ }
134
+ `;
135
+ // Simple
136
+ const simple = css `
137
+ --button-background-color: ${icon ? 'transparent' : backgroundColor};
138
+ color: ${icon ? 'currentColor' : color};
139
+ background-color: ${icon ? 'transparent' : backgroundColor};
99
140
 
100
- ${variant === 'simple' &&
101
- icon &&
141
+ @media (hover: hover) {
142
+ &:hover {
143
+ ${icon &&
102
144
  css `
103
145
  ::before {
104
146
  content: '';
@@ -113,81 +155,30 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
113
155
  }
114
156
  `}
115
157
 
116
- ${(variant === 'link' || variant === 'text') &&
117
- css `
118
- text-decoration: underline;
119
- `}
120
- }
121
- }
122
-
123
- ${variant !== 'link' &&
124
- variant !== 'text' &&
125
- css `
126
- min-height: ${hitAreaMouse};
127
- min-width: ${hitAreaMouse};
128
- border-radius: calc(${baseBorderRadius} * ${borderRadius});
129
- -webkit-user-select: none;
130
- user-select: none;
131
- `}
132
-
133
- ${compact &&
134
- css `
135
- min-height: ${hitAreaCompact};
136
- min-width: ${hitAreaCompact};
137
- `}
138
-
139
- ${!icon &&
140
- variant !== 'link' &&
141
- variant !== 'text' &&
142
- css `
143
- padding: ${padding};
144
- `}
145
-
146
- ${variant !== 'link' &&
147
- variant !== 'text' &&
148
- css `
149
- @media (pointer: coarse) {
150
- ${!compact &&
151
- css `
152
- min-height: ${hitAreaFinger};
153
- min-width: ${hitAreaFinger};
154
- `}
155
- border-radius: calc(${baseBorderRadius} * ${borderRadius});
156
158
  ${!icon &&
157
- css `
158
- padding: ${touchPadding};
159
+ css `
160
+ background-color: ${secondaryHoverBackgroundColor};
161
+ color: ${secondaryHoverForegroundColor};
162
+ border-color: ${secondaryHoverForegroundColor};
163
+ text-decoration: none;
159
164
  `}
160
165
  }
161
- `}
162
-
163
- &:disabled,
164
- &[disabled] {
165
- opacity: ${disabledOpacity};
166
- cursor: not-allowed;
167
- pointer-events: none;
168
166
  }
169
-
170
- &:enabled:focus,
171
- &:not([disabled]):focus {
172
- box-shadow: ${focusShadow};
173
- }
174
-
175
- ${icon &&
176
- variant !== 'link' &&
177
- variant !== 'text' &&
178
- css `
179
- border-radius: calc(${baseBorderRadius} * ${borderRadius});
180
- > svg {
181
- display: block;
182
- }
183
- `}
167
+ `;
168
+ return css `
169
+ ${base}
170
+ ${nonTextual}
171
+ ${variant === 'primary' && primary}
172
+ ${variant === 'secondary' && secondary}
173
+ ${variant === 'simple' && simple}
184
174
 
185
175
  ${loading &&
186
176
  css `
187
177
  ${StyledBackdrop} {
188
- background-color: ${buttonBackgroundColor};
178
+ background-color: var(--button-background-color);
189
179
  border-radius: inherit;
190
180
  }
181
+
191
182
  ${StyledProgressRing} {
192
183
  width: 1em;
193
184
  height: 1em;
@@ -199,17 +190,52 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
199
190
  `;
200
191
  });
201
192
  StyledButton.defaultProps = defaultThemeProp;
193
+ export const StyledButtonLink = styled.a.withConfig(omitProps('loading'))(({ theme, variant }) => {
194
+ const { base: { palette: { 'foreground-color': textColor } }, components: { link: { color: linkColor } } } = theme;
195
+ const base = baseStyles(theme);
196
+ const textual = css `
197
+ background-color: transparent;
198
+ display: inline;
199
+ text-align: start;
200
+ border: none;
201
+
202
+ @media (hover: hover) {
203
+ &:hover {
204
+ text-decoration: underline;
205
+ }
206
+ }
207
+
208
+ > ${StyledIcon} {
209
+ vertical-align: bottom;
210
+ }
211
+ `;
212
+ const link = css `
213
+ color: ${linkColor};
214
+ `;
215
+ const text = css `
216
+ color: ${textColor};
217
+ `;
218
+ return css `
219
+ ${base}
220
+ ${textual}
221
+ ${variant === 'link' && link}
222
+ ${variant === 'text' && text}
223
+ `;
224
+ });
225
+ StyledButtonLink.defaultProps = defaultThemeProp;
202
226
  const Button = forwardRef(({ variant = 'secondary', type = 'button', disabled = false, icon = false, compact = false, href, as, forwardedAs, label, 'aria-label': ariaLabel, loading = false, children, ...restProps }, ref) => {
203
227
  const [buttonEl, setButtonEl] = useElement();
204
228
  const mouseDownEvent = useRef();
205
229
  const buttonRef = useConsolidatedRef(ref, setButtonEl);
206
- const showProgress = loading && variant !== 'link' && variant !== 'text';
230
+ const isTextual = ['link', 'text'].includes(variant);
231
+ const showProgress = loading && !isTextual;
232
+ const StyledComp = isTextual ? StyledButtonLink : StyledButton;
207
233
  useEffect(() => {
208
234
  return () => {
209
235
  mouseDownEvent.current = undefined;
210
236
  };
211
237
  }, []);
212
- return (_jsxs(_Fragment, { children: [_jsxs(StyledButton, { ...restProps, ref: buttonRef, as: as || (href ? 'a' : 'button'), forwardedAs: forwardedAs || (href ? 'a' : 'button'), variant: variant, icon: icon, compact: compact, type: href ? undefined : type, href: href, disabled: disabled && !href, loading: showProgress, "aria-label": ariaLabel || label, onMouseDown: (e) => {
238
+ return (_jsxs(_Fragment, { children: [_jsxs(StyledComp, { ...restProps, ref: buttonRef, as: as || (href ? 'a' : 'button'), forwardedAs: forwardedAs || (href ? 'a' : 'button'), variant: variant, icon: icon, compact: compact, type: href ? undefined : type, href: href, disabled: disabled && !href, loading: showProgress, "aria-label": ariaLabel || label, onMouseDown: (e) => {
213
239
  restProps.onMouseDown?.(e);
214
240
  e.persist();
215
241
  mouseDownEvent.current = e;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EAOX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO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C;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import {\n useRef,\n useEffect,\n forwardRef,\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { getHoverColors, omitProps, readableHue } from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default \"secondary\"\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default \"button\"\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /**\n * The label text will be used inside a Tooltip.\n */\n label?: string;\n /**\n * The aria label text will be inserted as the aria-label on the Button.\n */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({\n variant,\n icon,\n loading,\n compact,\n theme: {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor, 'foreground-color': textColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n 'focus-shadow': focusShadow,\n touch: { padding: touchPadding }\n },\n link: { color: linkColor }\n }\n }\n }) => {\n const borderColor = variant === 'secondary' ? color : 'transparent';\n const contrastColor = tryCatch(() => readableColor(color));\n\n const hoverColors = getHoverColors(color);\n const hoverPrimaryColor = hoverColors.background;\n const hoverContrastColor = hoverColors.foreground;\n\n const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, color));\n const secondaryHoverForegroundColor = readableHue(\n color,\n secondaryHoverBackgroundColor ?? 'transparent'\n );\n\n let buttonColor = contrastColor;\n let buttonBackgroundColor = color;\n if (variant === 'secondary') {\n buttonColor = color;\n buttonBackgroundColor = secondaryColor;\n } else if (variant === 'simple') {\n if (icon) {\n buttonColor = 'currentColor';\n buttonBackgroundColor = 'transparent';\n } else {\n buttonColor = color;\n buttonBackgroundColor = backgroundColor;\n }\n } else if (variant === 'link') {\n buttonColor = linkColor;\n buttonBackgroundColor = 'transparent';\n } else if (variant === 'text') {\n buttonColor = textColor;\n buttonBackgroundColor = 'transparent';\n }\n\n return css`\n color: ${buttonColor};\n background-color: ${buttonBackgroundColor};\n display: ${variant === 'link' || variant === 'text' ? 'inline' : 'inline-flex'};\n align-items: center;\n outline: none;\n text-decoration: none;\n transition-property: background-color, color, box-shadow;\n transition-duration: calc(0.5 * ${speed});\n transition-timing-function: ${ease};\n cursor: pointer;\n\n ${variant !== 'link' && variant !== 'text'\n ? css`\n justify-content: center;\n line-height: 1;\n border: ${borderWidth} solid ${borderColor};\n position: relative;\n `\n : css`\n text-align: start;\n border: none;\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `}\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n @media (hover: hover) {\n &:hover {\n ${variant === 'primary' &&\n css`\n background-color: ${hoverPrimaryColor};\n color: ${hoverContrastColor};\n text-decoration: none;\n `}\n\n ${(variant === 'secondary' || (variant === 'simple' && !icon)) &&\n css`\n background-color: ${secondaryHoverBackgroundColor};\n color: ${secondaryHoverForegroundColor};\n border-color: ${secondaryHoverForegroundColor};\n text-decoration: none;\n `}\n\n ${variant === 'simple' &&\n icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n `}\n\n ${(variant === 'link' || variant === 'text') &&\n css`\n text-decoration: underline;\n `}\n }\n }\n\n ${variant !== 'link' &&\n variant !== 'text' &&\n css`\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n ${!icon &&\n variant !== 'link' &&\n variant !== 'text' &&\n css`\n padding: ${padding};\n `}\n\n ${variant !== 'link' &&\n variant !== 'text' &&\n css`\n @media (pointer: coarse) {\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n `}\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n\n ${icon &&\n variant !== 'link' &&\n variant !== 'text' &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n > svg {\n display: block;\n }\n `}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: ${buttonBackgroundColor};\n border-radius: inherit;\n }\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n ) => {\n const [buttonEl, setButtonEl] = useElement();\n const mouseDownEvent = useRef<MouseEvent>();\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const showProgress = loading && variant !== 'link' && variant !== 'text';\n\n useEffect(() => {\n return () => {\n mouseDownEvent.current = undefined;\n };\n }, []);\n\n return (\n <>\n <StyledButton\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n (restProps.onMouseDown as MouseEventHandler | undefined)?.(e);\n e.persist();\n mouseDownEvent.current = e;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;\n mouseDownEvent.current = undefined;\n\n if (shouldFocus && buttonRef.current !== document.activeElement) {\n buttonRef.current?.focus();\n }\n\n return (restProps.onMouseUp as MouseEventHandler | undefined)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='local' />}\n {children}\n </StyledButton>\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n }\n);\n\nexport default Button;\n"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EAOX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAsD3C,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAE,EAAE;IACzC,MAAM,EACJ,IAAI,EAAE,EACJ,OAAO,EACP,SAAS,EAAE,EACT,KAAK,EACL,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB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Ref,\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport { mix, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { getHoverColors, omitProps, readableHue } from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default \"secondary\"\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default \"button\"\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /**\n * The label text will be used inside a Tooltip.\n */\n label?: string;\n /**\n * The aria label text will be inserted as the aria-label on the Button.\n */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nconst baseStyles = (theme: DefaultTheme) => {\n const {\n base: {\n spacing,\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: { 'focus-shadow': focusShadow }\n }\n } = theme;\n\n return css`\n outline: none;\n text-decoration: none;\n transition-property: background-color, color, box-shadow;\n transition-duration: calc(0.5 * ${speed});\n transition-timing-function: ${ease};\n cursor: pointer;\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n `;\n};\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ variant, icon, loading, compact, theme }) => {\n const {\n base: {\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: { speed }\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n touch: { padding: touchPadding }\n }\n }\n } = theme;\n const contrastColor = tryCatch(() => readableColor(color));\n\n // Base\n const base = baseStyles(theme);\n\n // Non-text base\n const nonTextual = css`\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n line-height: 1;\n border: ${borderWidth} solid transparent;\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n\n ${!icon &&\n css`\n padding: ${padding};\n `}\n\n ${icon &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n > svg {\n display: block;\n }\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n @media (pointer: coarse) {\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n `;\n\n // Primary\n const hoverColors = getHoverColors(color);\n const hoverPrimaryColor = hoverColors.background;\n const hoverContrastColor = hoverColors.foreground;\n const primary = css`\n --button-background-color: ${color};\n color: ${contrastColor};\n background-color: ${color};\n\n @media (hover: hover) {\n &:hover {\n background-color: ${hoverPrimaryColor};\n color: ${hoverContrastColor};\n text-decoration: none;\n }\n }\n `;\n\n // Secondary\n const secondaryHoverBackgroundColor = tryCatch(() => mix(0.85, secondaryColor, color));\n const secondaryHoverForegroundColor = readableHue(\n color,\n secondaryHoverBackgroundColor ?? 'transparent'\n );\n const secondary = css`\n --button-background-color: ${secondaryColor};\n color: ${color};\n background-color: ${secondaryColor};\n border-color: ${color};\n\n @media (hover: hover) {\n &:hover {\n color: ${secondaryHoverForegroundColor};\n background-color: ${secondaryHoverBackgroundColor};\n text-decoration: none;\n border-color: ${secondaryHoverForegroundColor};\n }\n }\n `;\n\n // Simple\n const simple = css`\n --button-background-color: ${icon ? 'transparent' : backgroundColor};\n color: ${icon ? 'currentColor' : color};\n background-color: ${icon ? 'transparent' : backgroundColor};\n\n @media (hover: hover) {\n &:hover {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${secondaryHoverBackgroundColor};\n color: ${secondaryHoverForegroundColor};\n border-color: ${secondaryHoverForegroundColor};\n text-decoration: none;\n `}\n }\n }\n `;\n\n return css`\n ${base}\n ${nonTextual}\n ${variant === 'primary' && primary}\n ${variant === 'secondary' && secondary}\n ${variant === 'simple' && simple}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: var(--button-background-color);\n border-radius: inherit;\n }\n\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport const StyledButtonLink = styled.a.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ theme, variant }) => {\n const {\n base: {\n palette: { 'foreground-color': textColor }\n },\n components: {\n link: { color: linkColor }\n }\n } = theme;\n\n const base = baseStyles(theme);\n\n const textual = css`\n background-color: transparent;\n display: inline;\n text-align: start;\n border: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `;\n\n const link = css`\n color: ${linkColor};\n `;\n\n const text = css`\n color: ${textColor};\n `;\n\n return css`\n ${base}\n ${textual}\n ${variant === 'link' && link}\n ${variant === 'text' && text}\n `;\n }\n);\n\nStyledButtonLink.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n ) => {\n const [buttonEl, setButtonEl] = useElement();\n const mouseDownEvent = useRef<MouseEvent>();\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const isTextual = ['link', 'text'].includes(variant);\n const showProgress = loading && !isTextual;\n const StyledComp: React.ElementType = isTextual ? StyledButtonLink : StyledButton;\n\n useEffect(() => {\n return () => {\n mouseDownEvent.current = undefined;\n };\n }, []);\n\n return (\n <>\n <StyledComp\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n (restProps.onMouseDown as MouseEventHandler | undefined)?.(e);\n e.persist();\n mouseDownEvent.current = e;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;\n mouseDownEvent.current = undefined;\n\n if (shouldFocus && buttonRef.current !== document.activeElement) {\n buttonRef.current?.focus();\n }\n\n return (restProps.onMouseUp as MouseEventHandler | undefined)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='local' />}\n {children}\n </StyledComp>\n\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n }\n);\n\nexport default Button;\n"]}
@@ -109,7 +109,7 @@ const ColorPicker = forwardRef((props, ref) => {
109
109
  popoverEl?.focus();
110
110
  }
111
111
  }, [showPopOver]);
112
- return (_jsx(FormField, { testId: testIds.root, inline: inline, container: inline ? { justify: 'between' } : undefined, as: StyledColorPicker, id: id, label: label, labelHidden: labelHidden, swatchOnly: swatchOnly, info: info, disabled: disabled, status: status, required: required, additionalInfo: additionalInfo, children: _jsxs(Flex, { container: { alignItems: 'center' }, item: swatchOnly ? { alignSelf: 'start' } : undefined, as: StyledFormControl, disabled: disabled, status: status, required: required, readOnly: readOnly, onClick: readOnly || disabled ? undefined : () => setShowPopOver(true), children: [_jsx("input", { "data-testid": testIds.control, ...restProps, id: id, type: readOnly ? undefined : 'color', ref: inputRef, defaultValue: value, disabled: disabled, required: required, readOnly: readOnly, onClick: e => {
112
+ return (_jsx(FormField, { testId: testIds, inline: inline, container: inline ? { justify: 'between' } : undefined, as: StyledColorPicker, id: id, label: label, labelHidden: labelHidden, swatchOnly: swatchOnly, info: info, disabled: disabled, status: status, required: required, additionalInfo: additionalInfo, children: _jsxs(Flex, { container: { alignItems: 'center' }, item: swatchOnly ? { alignSelf: 'start' } : undefined, as: StyledFormControl, disabled: disabled, status: status, required: required, readOnly: readOnly, onClick: readOnly || disabled ? undefined : () => setShowPopOver(true), children: [_jsx("input", { "data-testid": testIds.control, ...restProps, id: id, type: readOnly ? undefined : 'color', ref: inputRef, defaultValue: value, disabled: disabled, required: required, readOnly: readOnly, onClick: e => {
113
113
  e.preventDefault();
114
114
  } }), _jsx("div", { style: { backgroundColor: value }, ref: maskedSwatchRef }), !swatchOnly && value, _jsx(Popover, { placement: 'bottom-start', style: { zIndex: '3000' }, show: showPopOver, ref: setPopoverEl, groupId: 'popover', target: maskedSwatchRef.current, children: _jsx(ChromePicker, { disableAlpha: !alpha, color: value, onChange: (color, e) => {
115
115
  onChange?.(color, e);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAEV,QAAQ,EAGR,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAS/D,OAAO,SAA6B,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAu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EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAC,EAAE;wBACX,CAAC,CAAC,cAAc,EAAE,CAAC;oBACrB,CAAC,GACD,EACF,cAAK,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,eAAe,GAAI,EAC/D,CAAC,UAAU,IAAI,KAAK,EACrB,KAAC,OAAO,IACN,SAAS,EAAC,cAAc,EACxB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EACzB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,YAAY,EACjB,OAAO,EAAC,SAAS,EACjB,MAAM,EAAE,eAAe,CAAC,OAAO,YAE/B,KAAC,YAAY,IACX,YAAY,EAAE,CAAC,KAAK,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;4BACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;wBACvB,CAAC,GACD,GACM,IACL,GACG,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n forwardRef,\n Ref,\n useState,\n PropsWithoutRef,\n MouseEventHandler,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\nimport { ChromePicker, ColorChangeHandler } from 'react-color';\n\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport FormField, { FormFieldProps } from '../FormField';\nimport { defaultThemeProp } from '../../theme';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport Flex from '../Flex';\nimport { useConsolidatedRef, useUID, useElement, useOuterEvent, useTestIds } from '../../hooks';\nimport Popover from '../Popover';\n\nimport { getColorPickerTestIds } from './ColorPicker.test-ids';\n\nexport interface ColorPickerProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** label for the color picker control */\n label: FormControlProps['label'];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not passed, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Color picker value in hex\n * @default \"#000000\"\n */\n value?: FormControlProps['value'];\n /**\n * Show color swatch without hex value display.\n * @default false\n */\n swatchOnly?: boolean;\n /**\n * Enables alpha slider.\n * @default false\n */\n alpha?: boolean;\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. */\n disabled?: FormControlProps['disabled'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Layout field elements inline in a row. */\n inline?: FormFieldProps['inline'];\n /** Button when clicked will show additional information on the color picker */\n additionalInfo?: FormFieldProps['additionalInfo'];\n /** onChange event handler that gets called on change of value. */\n onChange?: ColorChangeHandler;\n /** onBeforeClose of the color picker */\n onBeforeClose?: () => void;\n /** Called when the underlying input element is clicked. This should be rarely if ever used. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Ref placed on the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n\ntype ColorPickerPropsWithDefaults = PropsWithDefaults<ColorPickerProps, 'value' | 'swatchOnly'>;\n\nconst StyledColorPicker = styled.div<Pick<ColorPickerPropsWithDefaults, 'swatchOnly'>>(\n ({ theme, swatchOnly }) => {\n const size = theme.components.input.height;\n const borderWidth = theme.components['form-control']['border-width'];\n\n return css`\n ${StyledFormControl} {\n overflow: hidden;\n text-transform: uppercase;\n ${!swatchOnly &&\n css`\n min-width: 8rem;\n `}\n\n ${!swatchOnly &&\n css`\n padding-inline-end: ${theme.base.spacing};\n `}\n\n &:focus-within {\n box-shadow: ${theme.base.shadow.focus};\n border: none;\n }\n\n & > input {\n ${hideVisually}\n\n & + div {\n height: calc(${size} - (2 * ${borderWidth}));\n\n ${swatchOnly\n ? css`\n width: calc(${size} - (2 * ${borderWidth}));\n `\n : css`\n min-width: calc(${size} - ${borderWidth});\n margin-inline-end: ${theme.base.spacing};\n border-inline-end: ${borderWidth} solid\n ${theme.components['form-control']['border-color']};\n `}\n }\n\n &:focus + div {\n width: ${size};\n height: ${size};\n }\n }\n\n & input {\n height: 2rem !important;\n min-height: 2rem;\n color: #000000 !important;\n background-color: #ffffff !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n\n & + label {\n font-weight: 600;\n color: rgba(0, 0, 0, 0.6) !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n }\n }\n }\n `;\n }\n);\n\nStyledColorPicker.defaultProps = defaultThemeProp;\n\nconst ColorPicker: FC<ColorPickerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ColorPickerProps>, ref: ColorPickerProps['ref']) => {\n const uid = useUID();\n const {\n testId,\n id = uid,\n value = '#000000',\n label,\n info,\n disabled,\n status,\n required,\n readOnly,\n labelHidden,\n swatchOnly = false,\n alpha = false,\n inline,\n onClick,\n onChange,\n onBeforeClose,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getColorPickerTestIds);\n\n const inputRef = useConsolidatedRef(ref);\n const maskedSwatchRef = useConsolidatedRef<HTMLDivElement>();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>(null);\n const [showPopOver, setShowPopOver] = useState(false);\n\n const hidePopover = () => {\n if (showPopOver) {\n onBeforeClose?.();\n }\n\n setShowPopOver(false);\n };\n\n const closePopover = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n hidePopover();\n }\n };\n\n useOuterEvent('mousedown', [popoverEl], hidePopover);\n\n useEffect(() => {\n document.addEventListener('keydown', closePopover);\n popoverEl?.addEventListener('keydown', closePopover);\n return () => {\n document.removeEventListener('keydown', closePopover);\n popoverEl?.removeEventListener('keydown', closePopover);\n };\n }, [popoverEl]);\n\n useEffect(() => {\n if (showPopOver) {\n popoverEl?.focus();\n }\n }, [showPopOver]);\n\n return (\n <FormField\n testId={testIds.root}\n inline={inline}\n container={inline ? { justify: 'between' } : undefined}\n as={StyledColorPicker}\n id={id}\n label={label}\n labelHidden={labelHidden}\n swatchOnly={swatchOnly}\n info={info}\n disabled={disabled}\n status={status}\n required={required}\n additionalInfo={additionalInfo}\n >\n <Flex\n container={{ alignItems: 'center' }}\n item={swatchOnly ? { alignSelf: 'start' } : undefined}\n as={StyledFormControl}\n disabled={disabled}\n status={status}\n required={required}\n readOnly={readOnly}\n onClick={readOnly || disabled ? undefined : () => setShowPopOver(true)}\n >\n <input\n data-testid={testIds.control}\n {...restProps}\n id={id}\n type={readOnly ? undefined : 'color'}\n ref={inputRef}\n defaultValue={value}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onClick={e => {\n e.preventDefault();\n }}\n />\n <div style={{ backgroundColor: value }} ref={maskedSwatchRef} />\n {!swatchOnly && value}\n <Popover\n placement='bottom-start'\n style={{ zIndex: '3000' }}\n show={showPopOver}\n ref={setPopoverEl}\n groupId='popover'\n target={maskedSwatchRef.current}\n >\n <ChromePicker\n disableAlpha={!alpha}\n color={value}\n onChange={(color, e) => {\n onChange?.(color, e);\n }}\n />\n </Popover>\n </Flex>\n </FormField>\n );\n }\n);\n\nexport default ColorPicker;\n"]}
1
+ {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAEV,QAAQ,EAGR,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC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from 'styled-components';\nimport { hideVisually } from 'polished';\nimport { ChromePicker, ColorChangeHandler } from 'react-color';\n\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport FormField, { FormFieldProps } from '../FormField';\nimport { defaultThemeProp } from '../../theme';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport Flex from '../Flex';\nimport { useConsolidatedRef, useUID, useElement, useOuterEvent, useTestIds } from '../../hooks';\nimport Popover from '../Popover';\n\nimport { getColorPickerTestIds } from './ColorPicker.test-ids';\n\nexport interface ColorPickerProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** label for the color picker control */\n label: FormControlProps['label'];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not passed, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Color picker value in hex\n * @default \"#000000\"\n */\n value?: FormControlProps['value'];\n /**\n * Show color swatch without hex value display.\n * @default false\n */\n swatchOnly?: boolean;\n /**\n * Enables alpha slider.\n * @default false\n */\n alpha?: boolean;\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. */\n disabled?: FormControlProps['disabled'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Layout field elements inline in a row. */\n inline?: FormFieldProps['inline'];\n /** Button when clicked will show additional information on the color picker */\n additionalInfo?: FormFieldProps['additionalInfo'];\n /** onChange event handler that gets called on change of value. */\n onChange?: ColorChangeHandler;\n /** onBeforeClose of the color picker */\n onBeforeClose?: () => void;\n /** Called when the underlying input element is clicked. This should be rarely if ever used. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Ref placed on the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n\ntype ColorPickerPropsWithDefaults = PropsWithDefaults<ColorPickerProps, 'value' | 'swatchOnly'>;\n\nconst StyledColorPicker = styled.div<Pick<ColorPickerPropsWithDefaults, 'swatchOnly'>>(\n ({ theme, swatchOnly }) => {\n const size = theme.components.input.height;\n const borderWidth = theme.components['form-control']['border-width'];\n\n return css`\n ${StyledFormControl} {\n overflow: hidden;\n text-transform: uppercase;\n ${!swatchOnly &&\n css`\n min-width: 8rem;\n `}\n\n ${!swatchOnly &&\n css`\n padding-inline-end: ${theme.base.spacing};\n `}\n\n &:focus-within {\n box-shadow: ${theme.base.shadow.focus};\n border: none;\n }\n\n & > input {\n ${hideVisually}\n\n & + div {\n height: calc(${size} - (2 * ${borderWidth}));\n\n ${swatchOnly\n ? css`\n width: calc(${size} - (2 * ${borderWidth}));\n `\n : css`\n min-width: calc(${size} - ${borderWidth});\n margin-inline-end: ${theme.base.spacing};\n border-inline-end: ${borderWidth} solid\n ${theme.components['form-control']['border-color']};\n `}\n }\n\n &:focus + div {\n width: ${size};\n height: ${size};\n }\n }\n\n & input {\n height: 2rem !important;\n min-height: 2rem;\n color: #000000 !important;\n background-color: #ffffff !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n\n & + label {\n font-weight: 600;\n color: rgba(0, 0, 0, 0.6) !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n }\n }\n }\n `;\n }\n);\n\nStyledColorPicker.defaultProps = defaultThemeProp;\n\nconst ColorPicker: FC<ColorPickerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ColorPickerProps>, ref: ColorPickerProps['ref']) => {\n const uid = useUID();\n const {\n testId,\n id = uid,\n value = '#000000',\n label,\n info,\n disabled,\n status,\n required,\n readOnly,\n labelHidden,\n swatchOnly = false,\n alpha = false,\n inline,\n onClick,\n onChange,\n onBeforeClose,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getColorPickerTestIds);\n\n const inputRef = useConsolidatedRef(ref);\n const maskedSwatchRef = useConsolidatedRef<HTMLDivElement>();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>(null);\n const [showPopOver, setShowPopOver] = useState(false);\n\n const hidePopover = () => {\n if (showPopOver) {\n onBeforeClose?.();\n }\n\n setShowPopOver(false);\n };\n\n const closePopover = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n hidePopover();\n }\n };\n\n useOuterEvent('mousedown', [popoverEl], hidePopover);\n\n useEffect(() => {\n document.addEventListener('keydown', closePopover);\n popoverEl?.addEventListener('keydown', closePopover);\n return () => {\n document.removeEventListener('keydown', closePopover);\n popoverEl?.removeEventListener('keydown', closePopover);\n };\n }, [popoverEl]);\n\n useEffect(() => {\n if (showPopOver) {\n popoverEl?.focus();\n }\n }, [showPopOver]);\n\n return (\n <FormField\n testId={testIds}\n inline={inline}\n container={inline ? { justify: 'between' } : undefined}\n as={StyledColorPicker}\n id={id}\n label={label}\n labelHidden={labelHidden}\n swatchOnly={swatchOnly}\n info={info}\n disabled={disabled}\n status={status}\n required={required}\n additionalInfo={additionalInfo}\n >\n <Flex\n container={{ alignItems: 'center' }}\n item={swatchOnly ? { alignSelf: 'start' } : undefined}\n as={StyledFormControl}\n disabled={disabled}\n status={status}\n required={required}\n readOnly={readOnly}\n onClick={readOnly || disabled ? undefined : () => setShowPopOver(true)}\n >\n <input\n data-testid={testIds.control}\n {...restProps}\n id={id}\n type={readOnly ? undefined : 'color'}\n ref={inputRef}\n defaultValue={value}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onClick={e => {\n e.preventDefault();\n }}\n />\n <div style={{ backgroundColor: value }} ref={maskedSwatchRef} />\n {!swatchOnly && value}\n <Popover\n placement='bottom-start'\n style={{ zIndex: '3000' }}\n show={showPopOver}\n ref={setPopoverEl}\n groupId='popover'\n target={maskedSwatchRef.current}\n >\n <ChromePicker\n disableAlpha={!alpha}\n color={value}\n onChange={(color, e) => {\n onChange?.(color, e);\n }}\n />\n </Popover>\n </Flex>\n </FormField>\n );\n }\n);\n\nexport default ColorPicker;\n"]}
@@ -1,2 +1,2 @@
1
- export declare const getColorPickerTestIds: (testIdProp?: string | undefined) => import("../../utils").TestIdsRecord<readonly ["control"]>;
1
+ export declare const getColorPickerTestIds: (testIdProp?: string | undefined) => import("../..").TestIdsRecord<readonly ["control", "label", "info", "additional-info", "suggestion-accept", "suggestion-reject"]>;
2
2
  //# sourceMappingURL=ColorPicker.test-ids.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,gGAAsD,CAAC"}
1
+ {"version":3,"file":"ColorPicker.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.test-ids.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,wKAGvB,CAAC"}
@@ -1,3 +1,7 @@
1
1
  import { createTestIds } from '../../utils';
2
- export const getColorPickerTestIds = createTestIds('color-picker', ['control']);
2
+ import { elements } from '../FormField/FormField.test-ids';
3
+ export const getColorPickerTestIds = createTestIds('color-picker', [
4
+ 'control',
5
+ ...elements
6
+ ]);
3
7
  //# sourceMappingURL=ColorPicker.test-ids.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.test-ids.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE,CAAC,SAAS,CAAU,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getColorPickerTestIds = createTestIds('color-picker', ['control'] as const);\n"]}
1
+ {"version":3,"file":"ColorPicker.test-ids.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE;IACjE,SAAS;IACT,GAAG,QAAQ;CACH,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\nimport { elements } from '../FormField/FormField.test-ids';\n\nexport const getColorPickerTestIds = createTestIds('color-picker', [\n 'control',\n ...elements\n] as const);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqB3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAQ7C,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAoT7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"ComboBox.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqB3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAQ7C,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CA4S7D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -144,15 +144,7 @@ const ComboBox = forwardRef((props, ref) => {
144
144
  toggleSelectedDescendantsActive(true);
145
145
  }, onSelectedBlur: () => {
146
146
  toggleSelectedDescendantsActive(false);
147
- }, ...restProps }), _jsx(Popover, { show: open && menu !== undefined, target: containerRef.current, placement: 'bottom-start', modifiers: [
148
- {
149
- name: 'flip',
150
- options: {
151
- fallbackPlacements: ['top-start']
152
- }
153
- },
154
- sameWidth
155
- ],
147
+ }, ...restProps }), _jsx(Popover, { show: open && menu !== undefined, target: containerRef.current, placement: 'bottom-start', modifiers: [sameWidth],
156
148
  // FIXME: Removed absolute strategy for mobile to avoid overflow issues.
157
149
  strategy: 'fixed', onMouseDown: (e) => e.preventDefault(), children: menu && (_jsx(Menu, { ref: menuRef, listId: listId, id: menuComponentId, role: 'listbox', mode: mode, ...menu, items: menu.items, focusControlEl: inputRef.current || undefined, onItemClick: (itemId, e) => {
158
150
  if (mode === 'single-select') {
@@ -166,7 +158,7 @@ const ComboBox = forwardRef((props, ref) => {
166
158
  }
167
159
  }, "aria-label": t('menu_option_list'), pauseDescendantEvaluation: pauseMenuDescendantEvaluation, arrowNavigationUnsupported: true })) })] }));
168
160
  return (_jsxs(_Fragment, { children: [label ? (_jsx(FormField, { ...{
169
- testId: testIds.root,
161
+ testId: testIds,
170
162
  label,
171
163
  labelHidden,
172
164
  id,