@sentry/scraps 0.4.0 → 0.6.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 (352) hide show
  1. package/README.md +74 -8
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +4 -4
  5. package/dist/button/button.js +1 -0
  6. package/dist/button/index.d.ts +0 -1
  7. package/dist/button/index.js +0 -1
  8. package/dist/button/linkButton.js +1 -0
  9. package/dist/button/styles.js +157 -152
  10. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  11. package/dist/clipboard/copyToClipboardButton.js +32 -0
  12. package/dist/clipboard/index.d.ts +1 -0
  13. package/dist/clipboard/index.js +1 -0
  14. package/dist/code/index.d.ts +1 -0
  15. package/dist/code/index.js +1 -0
  16. package/dist/codeBlock/codeBlock.d.ts +68 -0
  17. package/dist/codeBlock/codeBlock.js +243 -0
  18. package/dist/codeBlock/index.d.ts +2 -0
  19. package/dist/codeBlock/index.js +2 -0
  20. package/dist/codeBlock/prism.d.ts +11 -0
  21. package/dist/codeBlock/prism.js +101 -0
  22. package/dist/codeBlock/styles.d.ts +2 -0
  23. package/dist/codeBlock/styles.js +133 -0
  24. package/dist/compactSelect/compactSelect.d.ts +21 -0
  25. package/dist/compactSelect/compactSelect.js +150 -0
  26. package/dist/compactSelect/composite.d.ts +54 -0
  27. package/dist/compactSelect/composite.js +101 -0
  28. package/dist/compactSelect/control.d.ts +112 -0
  29. package/dist/compactSelect/control.js +355 -0
  30. package/dist/compactSelect/gridList/index.d.ts +46 -0
  31. package/dist/compactSelect/gridList/index.js +102 -0
  32. package/dist/compactSelect/gridList/option.d.ts +15 -0
  33. package/dist/compactSelect/gridList/option.js +111 -0
  34. package/dist/compactSelect/gridList/section.d.ts +15 -0
  35. package/dist/compactSelect/gridList/section.js +58 -0
  36. package/dist/compactSelect/highlightText.d.ts +6 -0
  37. package/dist/compactSelect/highlightText.js +33 -0
  38. package/dist/compactSelect/index.d.ts +9 -0
  39. package/dist/compactSelect/index.js +8 -0
  40. package/dist/compactSelect/list.d.ts +94 -0
  41. package/dist/compactSelect/list.js +167 -0
  42. package/dist/compactSelect/listBox/index.d.ts +84 -0
  43. package/dist/compactSelect/listBox/index.js +175 -0
  44. package/dist/compactSelect/listBox/option.d.ts +19 -0
  45. package/dist/compactSelect/listBox/option.js +101 -0
  46. package/dist/compactSelect/listBox/section.d.ts +21 -0
  47. package/dist/compactSelect/listBox/section.js +58 -0
  48. package/dist/compactSelect/menuComponents.d.ts +89 -0
  49. package/dist/compactSelect/menuComponents.js +117 -0
  50. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  51. package/dist/compactSelect/selectFilterContext.js +3 -0
  52. package/dist/compactSelect/styles.d.ts +39 -0
  53. package/dist/compactSelect/styles.js +155 -0
  54. package/dist/compactSelect/types.d.ts +1 -0
  55. package/dist/compactSelect/types.js +0 -0
  56. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  57. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  58. package/dist/compactSelect/utils.d.ts +80 -0
  59. package/dist/compactSelect/utils.js +264 -0
  60. package/dist/confirm/index.d.ts +153 -0
  61. package/dist/confirm/index.js +132 -0
  62. package/dist/dateTime/config.d.ts +23 -0
  63. package/dist/dateTime/config.js +50 -0
  64. package/dist/dateTime/context.d.ts +18 -0
  65. package/dist/dateTime/context.js +46 -0
  66. package/dist/dateTime/dateTime.d.ts +6 -0
  67. package/dist/dateTime/dateTime.js +30 -0
  68. package/dist/dateTime/format.d.ts +24 -0
  69. package/dist/dateTime/format.js +45 -0
  70. package/dist/dateTime/index.d.ts +6 -0
  71. package/dist/dateTime/index.js +6 -0
  72. package/dist/dateTime/intlFormatter.d.ts +9 -0
  73. package/dist/dateTime/intlFormatter.js +16 -0
  74. package/dist/dateTime/parseDate.d.ts +3 -0
  75. package/dist/dateTime/parseDate.js +12 -0
  76. package/dist/descriptionList/descriptionList.js +4 -3
  77. package/dist/disclosure/disclosure.js +2 -2
  78. package/dist/dragHandle/dragHandle.d.ts +3 -1
  79. package/dist/dragHandle/dragHandle.js +8 -5
  80. package/dist/drawer/components.d.ts +46 -0
  81. package/dist/drawer/components.js +265 -0
  82. package/dist/drawer/globalDrawer.d.ts +106 -0
  83. package/dist/drawer/globalDrawer.js +173 -0
  84. package/dist/drawer/index.d.ts +3 -0
  85. package/dist/drawer/index.js +2 -0
  86. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  87. package/dist/drawer/useDrawerResizing.js +111 -0
  88. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  89. package/dist/drawer/useDrawerWidth.js +42 -0
  90. package/dist/dropdownMenu/content.d.ts +1 -0
  91. package/dist/dropdownMenu/content.js +1 -0
  92. package/dist/dropdownMenu/context.d.ts +39 -0
  93. package/dist/dropdownMenu/context.js +3 -0
  94. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  95. package/dist/dropdownMenu/dropdownMenu.js +109 -0
  96. package/dist/dropdownMenu/index.d.ts +2 -0
  97. package/dist/dropdownMenu/index.js +1 -0
  98. package/dist/dropdownMenu/item.d.ts +140 -0
  99. package/dist/dropdownMenu/item.js +142 -0
  100. package/dist/dropdownMenu/list.d.ts +85 -0
  101. package/dist/dropdownMenu/list.js +429 -0
  102. package/dist/dropdownMenu/search.d.ts +16 -0
  103. package/dist/dropdownMenu/search.js +16 -0
  104. package/dist/dropdownMenu/section.d.ts +21 -0
  105. package/dist/dropdownMenu/section.js +40 -0
  106. package/dist/dropdownMenu/separator.d.ts +7 -0
  107. package/dist/dropdownMenu/separator.js +15 -0
  108. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
  109. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
  110. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  111. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  112. package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
  113. package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
  114. package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
  115. package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
  116. package/dist/dropdownMenu/utils.d.ts +21 -0
  117. package/dist/dropdownMenu/utils.js +55 -0
  118. package/dist/duration/formatElapsedDuration.d.ts +4 -0
  119. package/dist/duration/formatElapsedDuration.js +10 -0
  120. package/dist/duration/getDuration.d.ts +68 -0
  121. package/dist/duration/getDuration.js +80 -0
  122. package/dist/duration/index.d.ts +2 -0
  123. package/dist/duration/index.js +2 -0
  124. package/dist/form/FormSearch.d.ts +19 -0
  125. package/dist/form/FormSearch.js +4 -0
  126. package/dist/form/autoSaveForm.d.ts +110 -0
  127. package/dist/form/autoSaveForm.js +100 -0
  128. package/dist/{formPresentation → form}/displayField.js +2 -2
  129. package/dist/form/field/baseField.d.ts +23 -0
  130. package/dist/form/field/baseField.js +116 -0
  131. package/dist/form/field/checkboxField.d.ts +11 -0
  132. package/dist/form/field/checkboxField.js +42 -0
  133. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  134. package/dist/form/field/checkboxGroupField.js +80 -0
  135. package/dist/form/field/compactSelectField.d.ts +19 -0
  136. package/dist/form/field/compactSelectField.js +77 -0
  137. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  138. package/dist/form/field/inputField.d.ts +19 -0
  139. package/dist/form/field/inputField.js +31 -0
  140. package/dist/{formPresentation → form/field}/meta.js +6 -6
  141. package/dist/form/field/numberField.d.ts +5 -0
  142. package/dist/form/field/numberField.js +11 -0
  143. package/dist/form/field/passwordField.d.ts +3 -0
  144. package/dist/form/field/passwordField.js +27 -0
  145. package/dist/form/field/radioGroupField.d.ts +16 -0
  146. package/dist/form/field/radioGroupField.js +92 -0
  147. package/dist/form/field/rangeField.d.ts +8 -0
  148. package/dist/form/field/rangeField.js +34 -0
  149. package/dist/form/field/selectAsyncField.d.ts +31 -0
  150. package/dist/form/field/selectAsyncField.js +22 -0
  151. package/dist/form/field/selectField.d.ts +9 -0
  152. package/dist/form/field/selectField.js +72 -0
  153. package/dist/form/field/switchField.d.ts +7 -0
  154. package/dist/form/field/switchField.js +37 -0
  155. package/dist/form/field/textAreaField.d.ts +7 -0
  156. package/dist/form/field/textAreaField.js +25 -0
  157. package/dist/{formPresentation → form}/formContext.js +1 -1
  158. package/dist/form/formErrorContext/index.d.ts +9 -0
  159. package/dist/form/formErrorContext/index.js +7 -0
  160. package/dist/form/index.d.ts +9 -0
  161. package/dist/form/index.js +8 -0
  162. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  163. package/dist/{formPresentation → form/layout}/base.js +1 -1
  164. package/dist/form/layout/fieldGroup.d.ts +6 -0
  165. package/dist/form/layout/fieldGroup.js +60 -0
  166. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  167. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  168. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  169. package/dist/form/scrapsForm.d.ts +220 -0
  170. package/dist/form/scrapsForm.js +126 -0
  171. package/dist/fzf.d.ts +9 -0
  172. package/dist/fzf.js +155 -0
  173. package/dist/hotkey/hotkey.d.ts +9 -8
  174. package/dist/hotkey/hotkey.js +13 -6
  175. package/dist/hotkey/index.d.ts +2 -1
  176. package/dist/hotkey/index.js +2 -1
  177. package/dist/hotkey/keyMappings.d.ts +1 -15
  178. package/dist/hotkey/keyMappings.js +29 -174
  179. package/dist/hotkey/useHotkeys.d.ts +3 -47
  180. package/dist/hotkey/useHotkeys.js +8 -42
  181. package/dist/image/image.js +2 -1
  182. package/dist/info/infoTip.d.ts +1 -1
  183. package/dist/info/infoTip.js +4 -3
  184. package/dist/input/index.d.ts +0 -3
  185. package/dist/input/index.js +0 -2
  186. package/dist/input/input.d.ts +2 -0
  187. package/dist/input/input.js +2 -0
  188. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  189. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  190. package/dist/layout/container.d.ts +8 -2
  191. package/dist/layout/container.js +2 -2
  192. package/dist/layout/index.d.ts +2 -2
  193. package/dist/layout/index.js +1 -1
  194. package/dist/layout/styles.d.ts +2 -1
  195. package/dist/layout/styles.js +11 -5
  196. package/dist/legacyDatetime.d.ts +21 -0
  197. package/dist/legacyDatetime.js +13 -0
  198. package/dist/link/index.d.ts +1 -1
  199. package/dist/link/index.js +1 -1
  200. package/dist/link/link.js +4 -3
  201. package/dist/link/linkBehaviorContext.d.ts +11 -0
  202. package/dist/link/linkBehaviorContext.js +48 -11
  203. package/dist/menu/index.d.ts +1 -1
  204. package/dist/menu/index.js +1 -1
  205. package/dist/menu/menu.d.ts +14 -8
  206. package/dist/menu/menu.js +163 -60
  207. package/dist/modal/components.d.ts +19 -0
  208. package/dist/modal/components.js +99 -0
  209. package/dist/modal/errorBoundary.d.ts +2 -0
  210. package/dist/modal/errorBoundary.js +35 -0
  211. package/dist/modal/index.d.ts +33 -0
  212. package/dist/modal/index.js +260 -0
  213. package/dist/modal/portal.d.ts +1 -0
  214. package/dist/modal/portal.js +10 -0
  215. package/dist/modal/state.d.ts +17 -0
  216. package/dist/modal/state.js +41 -0
  217. package/dist/modal/types.d.ts +75 -0
  218. package/dist/modal/types.js +0 -0
  219. package/dist/numberInput/index.d.ts +3 -0
  220. package/dist/numberInput/index.js +2 -0
  221. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  222. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  223. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  224. package/dist/{input → numberInput}/numberInput.js +1 -1
  225. package/dist/overlayContext.d.ts +29 -0
  226. package/dist/overlayContext.js +7 -0
  227. package/dist/pagination/index.d.ts +1 -0
  228. package/dist/pagination/index.js +1 -0
  229. package/dist/pagination/pagination.d.ts +24 -0
  230. package/dist/pagination/pagination.js +63 -0
  231. package/dist/pictureInPicture/index.d.ts +2 -0
  232. package/dist/pictureInPicture/index.js +2 -0
  233. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  234. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  235. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  236. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  237. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  238. package/dist/pictureInPicture/portalContext.js +3 -0
  239. package/dist/relativeTime/getRelativeDate.d.ts +14 -0
  240. package/dist/relativeTime/getRelativeDate.js +107 -0
  241. package/dist/relativeTime/index.d.ts +3 -0
  242. package/dist/relativeTime/index.js +3 -0
  243. package/dist/relativeTime/relativeTime.d.ts +55 -0
  244. package/dist/relativeTime/relativeTime.js +102 -0
  245. package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
  246. package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
  247. package/dist/revealOnHover/revealOnHover.js +1 -1
  248. package/dist/segmentedControl/segmentedControl.js +1 -1
  249. package/dist/select/filter.d.ts +4 -0
  250. package/dist/select/filter.js +12 -0
  251. package/dist/select/index.d.ts +3 -0
  252. package/dist/select/index.js +2 -0
  253. package/dist/select/option.d.ts +16 -0
  254. package/dist/select/option.js +81 -0
  255. package/dist/select/reactSelectWrapper.d.ts +8 -0
  256. package/dist/select/reactSelectWrapper.js +25 -0
  257. package/dist/select/select.d.ts +79 -0
  258. package/dist/select/select.js +454 -0
  259. package/dist/select/styles.d.ts +9 -0
  260. package/dist/select/styles.js +27 -0
  261. package/dist/select/types.d.ts +60 -0
  262. package/dist/select/types.js +0 -0
  263. package/dist/select/virtualizedMenuList.d.ts +24 -0
  264. package/dist/select/virtualizedMenuList.js +123 -0
  265. package/dist/slideOverPanel.d.ts +20 -0
  266. package/dist/slideOverPanel.js +141 -0
  267. package/dist/splitPanel/splitPanel.d.ts +3 -1
  268. package/dist/splitPanel/splitPanel.js +2 -1
  269. package/dist/table/table.d.ts +1 -1
  270. package/dist/table/table.js +39 -20
  271. package/dist/table/useColumnResize.d.ts +6 -5
  272. package/dist/table/useColumnResize.js +5 -4
  273. package/dist/tabs/context.d.ts +9 -0
  274. package/dist/tabs/context.js +9 -0
  275. package/dist/tabs/index.d.ts +2 -0
  276. package/dist/tabs/index.js +1 -0
  277. package/dist/tabs/item.d.ts +24 -0
  278. package/dist/tabs/item.js +4 -0
  279. package/dist/tabs/tab.d.ts +22 -0
  280. package/dist/tabs/tab.js +208 -0
  281. package/dist/tabs/tabList.d.ts +18 -0
  282. package/dist/tabs/tabList.js +258 -0
  283. package/dist/tabs/tabPanels.d.ts +13 -0
  284. package/dist/tabs/tabPanels.js +62 -0
  285. package/dist/tabs/tabs.d.ts +53 -0
  286. package/dist/tabs/tabs.js +59 -0
  287. package/dist/tabs/utils.d.ts +3 -0
  288. package/dist/tabs/utils.js +6 -0
  289. package/dist/text/heading.d.ts +1 -1
  290. package/dist/text/heading.js +1 -1
  291. package/dist/text/prose.d.ts +2 -2
  292. package/dist/text/styles.js +1 -1
  293. package/dist/text/text.d.ts +1 -1
  294. package/dist/text/text.js +1 -1
  295. package/dist/theme/dark.js +9 -9
  296. package/dist/theme/light.js +9 -9
  297. package/dist/theme/theme.d.ts +34 -34
  298. package/dist/theme/theme.js +9 -0
  299. package/dist/theme/types.d.ts +20 -2
  300. package/dist/tooltip/tooltip.js +2 -5
  301. package/dist/translation/index.d.ts +1 -0
  302. package/dist/translation/index.js +1 -0
  303. package/dist/translation/translate.d.ts +9 -0
  304. package/dist/translation/translate.js +5 -0
  305. package/dist/translation/translationContext.d.ts +2 -1
  306. package/dist/translation/translationContext.js +2 -1
  307. package/dist/useMedia.d.ts +15 -0
  308. package/dist/useMedia.js +24 -0
  309. package/dist/useOnClickOutside.d.ts +2 -0
  310. package/dist/useOnClickOutside.js +22 -0
  311. package/dist/useOverlay.d.ts +1 -0
  312. package/dist/useOverlay.js +1 -0
  313. package/dist/useVirtualCollection.d.ts +154 -0
  314. package/dist/useVirtualCollection.js +143 -0
  315. package/dist/useVirtualRows.d.ts +26 -0
  316. package/dist/useVirtualRows.js +26 -0
  317. package/dist/virtualCollectionLayout.d.ts +51 -0
  318. package/dist/virtualCollectionLayout.js +49 -0
  319. package/fonts/OFL.txt +94 -0
  320. package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
  321. package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
  322. package/fonts/roboto-mono-variable-greek.woff2 +0 -0
  323. package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
  324. package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
  325. package/fonts/roboto-mono-variable.woff2 +0 -0
  326. package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
  327. package/fonts/rubik-variable-cyrillic.woff2 +0 -0
  328. package/fonts/rubik-variable-latin-ext.woff2 +0 -0
  329. package/fonts/rubik-variable.woff2 +0 -0
  330. package/fonts.css +211 -0
  331. package/package.json +140 -23
  332. package/dist/datetime.d.ts +0 -39
  333. package/dist/datetime.js +0 -20
  334. package/dist/formPresentation/index.d.ts +0 -8
  335. package/dist/formPresentation/index.js +0 -8
  336. package/dist/interactionStateLayer/index.d.ts +0 -1
  337. package/dist/interactionStateLayer/index.js +0 -1
  338. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  339. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  340. package/dist/unreachable.d.ts +0 -1
  341. package/dist/unreachable.js +0 -4
  342. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  343. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  344. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  345. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  346. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  347. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  348. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  349. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  350. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  351. /package/dist/{formPresentation → form}/icons.js +0 -0
  352. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
package/README.md CHANGED
@@ -6,9 +6,9 @@ The source code is open, but the system is designed for Sentry and is not intend
6
6
 
7
7
  ## Development in Sentry
8
8
 
9
- The package source lives in [src](./src). Component stories remain in the app.
9
+ The package source lives in [src](./src). Component docs (`.mdx`) sit next to their components and render in the app's Scraps viewer; `.npmignore` and the build config keep them out of the published package.
10
10
 
11
- Move components and their tests into `src` as they become isolated. The [Scraps contribution guide](../../app/components/core/overview/contributing.mdx) covers component contributions and the Figma process for changing design tokens.
11
+ Move components, their tests, and their docs into `src` as they become isolated. The [Scraps contribution guide](../../app/components/core/overview/contributing.mdx) covers component contributions and the Figma process for changing design tokens.
12
12
 
13
13
  Run package checks from the repository root:
14
14
 
@@ -35,20 +35,86 @@ pnpm --dir static/packages/scraps pack --pack-destination .artifacts
35
35
  ```
36
36
 
37
37
  The `prepack` hook builds JavaScript and declarations with
38
- [Rslib](./rslib.config.mjs), including from a clean checkout. Only `dist`, the
39
- package manifest, README, and license ship.
38
+ [Rslib](./rslib.config.mjs), including from a clean checkout. The package ships `dist`, the font stylesheet and WOFF2 assets, the manifest, README, and licenses.
40
39
 
41
40
  The `exports` field in [package.json](./package.json) defines the published API.
42
41
  Import from its explicit subpaths, including `@sentry/scraps/code/inlineCode`
43
42
  and `@sentry/scraps/hotkey/kbd`. The package has no root export; unlisted module
44
43
  paths remain private.
45
44
  Add an entry only when its runtime and type dependencies belong to the package
46
- or are declared dependencies. App stories cover more components than this API;
47
- for example, the hotkey story uses both `Hotkey` and `Kbd`, but only `Kbd` is
48
- isolated. Published consumers have no fallback to app components.
45
+ or are declared dependencies. Both `Hotkey` and `Kbd` are isolated and exported
46
+ from `@sentry/scraps/hotkey`; `Kbd` also has its own `@sentry/scraps/hotkey/kbd`
47
+ entry point. App stories cover more components than this API. Published consumers
48
+ have no fallback to app components.
49
49
 
50
50
  Consumers provide Emotion's `ThemeProvider` with `lightTheme` or `darkTheme`.
51
- The package does not include application providers, global CSS, or fonts.
51
+ Load Rubik, Roboto Mono, and their metric-adjusted fallbacks in your app stylesheet.
52
+
53
+ ```css
54
+ @import '@sentry/scraps/fonts.css';
55
+ ```
56
+
57
+ The stylesheet uses relative URLs to separate WOFF2 files. For direct asset imports, use paths such as `@sentry/scraps/fonts/rubik-variable.woff2`.
58
+
59
+ To self-host without a bundler, copy `fonts.css` and the `fonts/` directory from the installed package into the same public directory, then link to `fonts.css` in your page. Keep `fonts/OFL.txt` with the font files.
60
+
61
+ ## Date and duration formatting
62
+
63
+ Components and plain formatters share the same presentation options:
64
+
65
+ ```tsx
66
+ import {DateTime, formatDateTime} from '@sentry/scraps/dateTime';
67
+ import {getDuration} from '@sentry/scraps/duration';
68
+
69
+ const date = '2025-01-01T12:00:00Z';
70
+ formatDateTime(date, {timezone: 'America/New_York', mode: 'time'});
71
+ <DateTime date={date} mode="time" precision="second" />;
72
+ getDuration(65, {precision: 1, style: 'short'}); // "1.1min"
73
+ getDuration(55, {minimumUnit: 'minute'}); // "1 minute"
74
+ ```
75
+
76
+ Dates accept a `Date`, epoch milliseconds, or an ISO timestamp with an explicit
77
+ `Z` or UTC offset. Offset-free strings, calendar-only dates, invalid dates, and
78
+ unknown timezone identifiers return `Invalid date`.
79
+
80
+ Use `mode` to choose `dateTime`, `date`, or `time`. Time precision is
81
+ `minute`, `second`, or `millisecond`; year display is `auto`, `always`, or
82
+ `never`. Set `timezone: 'UTC'` for UTC output and `clock` to `'12'` or
83
+ `'24'`. UTC output includes its timezone label by default; `showTimezone`
84
+ controls the label explicitly. Formatting-engine types and patterns are private.
85
+
86
+ Parsing and timezone conversion use a private Temporal ponyfill, without changing
87
+ browser globals. Rendering preserves Intl's locale-specific date order, literal
88
+ characters, and time punctuation while honoring the configured clock. French
89
+ output includes `1 janv. 2025` and `1:05:06,123 PM`; Japanese output includes
90
+ `2025年1月1日` and `午後1:05`. These locale conventions replace Moment's fixed
91
+ month-first layout. Timezone labels use Intl by default. An application can supply
92
+ `getTimezoneAbbreviation(epochMilliseconds, timezone, locale)` in its formatting snapshot
93
+ to retain its existing labels. Returning `undefined` uses the Intl fallback.
94
+ Sentry supplies its already-loaded timezone lookup, preserving labels such as
95
+ `AEDT`, `AEST`, and `+0545` without adding Moment or a timezone dataset to Scraps.
96
+
97
+ Without configuration, dates use UTC and a 12-hour clock. Applications call
98
+ `configureFormatting` before rendering with one source. Its `getSnapshot`
99
+ returns the same object until preferences change, and `subscribe` notifies
100
+ consumers after a new snapshot is ready. Each snapshot contains `timezone`,
101
+ `clock`, `locale`, and matching `messages` with `t`, `tn`, and `pgettext`.
102
+ The source feeds a Zustand store shared by plain formatters and React consumers.
103
+ Plain formatters read its current snapshot; React consumers subscribe to changes.
104
+ The cleanup returned by `configureFormatting` disconnects the source and restores
105
+ the previous snapshot.
106
+
107
+ `DateTimeProvider` accepts partial timezone and clock overrides and inherits
108
+ unspecified values from its parent. Explicit component or function options win
109
+ over defaults. Use `useDateTimeFormatter()` to bind a formatter to the nearest
110
+ provider for callbacks and copied text. A free `formatDateTime` call reads
111
+ application preferences, without a React subtree's overrides.
112
+
113
+ `getDuration` accepts seconds and uses the same configured messages. Its
114
+ `minimumUnit` is a unit name such as `'millisecond'` or `'minute'`, and its
115
+ `style` is `'long'`, `'short'`, or `'narrow'`. The default style is long,
116
+ the minimum is one millisecond, and `precision` controls decimal places.
117
+ Month and year conversions remain approximate elapsed durations.
52
118
 
53
119
  ## Prepare a release
54
120
 
@@ -13,7 +13,6 @@ import { Container, Flex, Grid } from "../layout/index.js";
13
13
  import { PanelProvider } from "../panelProvider.js";
14
14
  import { Text } from "../text/index.js";
15
15
  import { useTranslation } from "../translation/useTranslation.js";
16
- import { unreachable } from "../unreachable.js";
17
16
  const AlertPanel = styled('div')`
18
17
  position: relative;
19
18
  display: grid;
@@ -83,7 +82,6 @@ function getAlertTokens(variant, theme) {
83
82
  border: theme.tokens.border.primary
84
83
  };
85
84
  default:
86
- unreachable(variant);
87
85
  }
88
86
  throw new TypeError(`Invalid alert variant, got ${variant}`);
89
87
  }
@@ -240,7 +238,6 @@ function AlertIcon({ variant }) {
240
238
  case 'muted':
241
239
  return /*#__PURE__*/ jsx(IconInfo, {});
242
240
  default:
243
- unreachable(variant);
244
241
  }
245
242
  return null;
246
243
  }
@@ -1,5 +1,4 @@
1
1
  import styled from "@emotion/styled";
2
- import { unreachable } from "../unreachable.js";
3
2
  const Badge = styled('span')`
4
3
  ${(p)=>({
5
4
  ...makeBadgeTheme(p, p.theme)
@@ -73,7 +72,7 @@ function makeBadgeTheme(p, theme) {
73
72
  background: theme.tokens.background.transparent.success.muted
74
73
  };
75
74
  default:
76
- unreachable(p.variant);
75
+ p.variant;
77
76
  throw new TypeError(`Unsupported badge variant: ${p.variant}`);
78
77
  }
79
78
  }
package/dist/badge/tag.js CHANGED
@@ -4,7 +4,6 @@ import { IconClose } from "@sentry/icons/close";
4
4
  import { IconDefaultsProvider } from "@sentry/icons/useIconDefaults";
5
5
  import { Button } from "../button/index.js";
6
6
  import { useTranslation } from "../translation/useTranslation.js";
7
- import { unreachable } from "../unreachable.js";
8
7
  function Tag({ ref, variant, icon, onDismiss, children, ...props }) {
9
8
  const { t } = useTranslation();
10
9
  return /*#__PURE__*/ jsxs(TagPill, {
@@ -47,8 +46,9 @@ const TagPill = styled('div')`
47
46
  display: inline-flex;
48
47
  gap: ${(p)=>p.theme.space.xs};
49
48
  align-items: center;
49
+ justify-content: center;
50
50
  border-radius: ${(p)=>p.theme.radius.xs};
51
- padding: 0 ${(p)=>p.theme.space.md};
51
+ padding: 0 ${(p)=>p.theme.space.xs};
52
52
  max-width: 100%;
53
53
 
54
54
  /* @TODO(jonasbadalic): We need to override button colors because they wrongly default to a blue color... */
@@ -91,7 +91,6 @@ function makeTagPillTheme(type, theme) {
91
91
  background: theme.tokens.background.transparent.success.muted
92
92
  };
93
93
  default:
94
- unreachable(type);
95
94
  throw new TypeError(`Unsupported badge type: ${type}`);
96
95
  }
97
96
  }
@@ -100,6 +99,8 @@ const TagText = styled('div')`
100
99
  white-space: nowrap;
101
100
  text-overflow: ellipsis;
102
101
  min-width: 0;
102
+ text-box-edge: text text;
103
+ text-box-trim: trim-both;
103
104
 
104
105
  &:has(> *) {
105
106
  display: flex;
@@ -113,7 +114,6 @@ const IconWrapper = styled('span')`
113
114
  gap: inherit;
114
115
  `;
115
116
  const DismissButton = styled(Button)`
116
- margin-right: -${(p)=>p.theme.space.xs};
117
117
  border: none;
118
118
  `;
119
119
  export { Tag };
@@ -42,6 +42,7 @@ function Button({ disabled, type = 'button', tooltipProps, onKeyDown, 'aria-disa
42
42
  role: "button",
43
43
  children: /*#__PURE__*/ jsxs(Flex, {
44
44
  as: "span",
45
+ "data-button-label": true,
45
46
  align: "center",
46
47
  justify: "center",
47
48
  minWidth: "0",
@@ -1,5 +1,4 @@
1
1
  export { Button, type ButtonProps } from './button.js';
2
2
  export { ButtonBar, type ButtonBarProps } from './buttonBar.js';
3
3
  export { LinkButton, type LinkButtonProps } from './linkButton.js';
4
- export { DO_NOT_USE_getButtonStyles } from './styles.js';
5
4
  export type { ButtonSize } from './types.js';
@@ -1,4 +1,3 @@
1
1
  export { Button } from "./button.js";
2
2
  export { ButtonBar } from "./buttonBar.js";
3
3
  export { LinkButton } from "./linkButton.js";
4
- export { DO_NOT_USE_getButtonStyles } from "./styles.js";
@@ -32,6 +32,7 @@ function LinkButton({ disabled, tooltipProps, size: explicitSize, ...props }) {
32
32
  to: disabled ? void 0 : 'to' in props ? props.to : void 0,
33
33
  children: /*#__PURE__*/ jsxs(Flex, {
34
34
  as: "span",
35
+ "data-button-label": true,
35
36
  align: "center",
36
37
  justify: "center",
37
38
  minWidth: "0",
@@ -4,61 +4,102 @@ const DO_NOT_USE_BUTTON_ICON_SIZES = {
4
4
  sm: 'sm',
5
5
  md: 'sm'
6
6
  };
7
- const elevation = {
8
- md: '2px',
9
- sm: '2px',
10
- xs: '1px',
11
- zero: '0px'
12
- };
13
- const hoverElevation = '1px';
14
7
  function DO_NOT_USE_getButtonStyles(p) {
15
- const variant = p.variant ?? 'secondary';
16
8
  const ariaDisabled = p['aria-disabled'];
17
- const disabled = p.disabled || true === ariaDisabled || 'true' === ariaDisabled;
18
- const buttonSizes = {
19
- ...p.theme.form,
20
- zero: {
21
- height: '24px',
22
- minHeight: '24px',
23
- fontSize: '0.75rem',
24
- lineHeight: '1rem'
25
- }
9
+ const disabled = Boolean(p.disabled || true === ariaDisabled || 'true' === ariaDisabled);
10
+ const props = {
11
+ busy: Boolean(p.busy),
12
+ disabled,
13
+ shapeVariant: p.shapeVariant,
14
+ size: getSizeTokens(p.size, p.theme),
15
+ theme: p.theme
26
16
  };
27
- const buttonTheme = getButtonTheme(variant, p.theme);
28
- const buttonElevation = elevation[p.size];
17
+ const variant = p.variant ?? 'secondary';
18
+ switch(variant){
19
+ case 'transparent':
20
+ return getTransparentStyles(props);
21
+ case 'link':
22
+ return getLinkStyles(props);
23
+ default:
24
+ return getChonkyStyles(props, chonkyTokens[variant](p.theme.tokens.interactive.chonky.embossed, p.theme));
25
+ }
26
+ }
27
+ function getBaseStyles(p) {
29
28
  return {
30
- '--button-lift': buttonElevation,
31
29
  position: 'relative',
32
30
  display: 'inline-flex',
33
31
  alignItems: 'center',
34
32
  justifyContent: 'center',
35
33
  whiteSpace: 'nowrap',
36
34
  fontWeight: p.theme.font.weight.sans.medium,
37
- opacity: disabled ? 0.6 : void 0,
35
+ fontSize: p.size.fontSize,
36
+ lineHeight: p.size.lineHeight,
37
+ opacity: p.disabled ? 0.6 : void 0,
38
+ borderRadius: p.size.borderRadius,
39
+ border: 'none',
40
+ background: 'none',
38
41
  cursor: 'pointer',
39
42
  '&[disabled], &[aria-disabled="true"]': {
40
43
  cursor: 'not-allowed'
41
44
  },
42
- padding: 'square' === p.shapeVariant ? '0' : getButtonSizeTheme(p.size, p.theme).padding,
43
- borderRadius: getButtonSizeTheme(p.size, p.theme).borderRadius,
44
- border: 'none',
45
- color: buttonTheme.color,
46
- background: 'none',
47
- height: buttonSizes[p.size].height,
48
- minWidth: 'square' === p.shapeVariant ? buttonSizes[p.size].height : void 0,
49
- minHeight: buttonSizes[p.size].minHeight,
50
- fontSize: buttonSizes[p.size].fontSize,
51
- lineHeight: buttonSizes[p.size].lineHeight,
45
+ '&[aria-busy="true"]': {
46
+ cursor: 'progress'
47
+ }
48
+ };
49
+ }
50
+ const chonkyTokens = {
51
+ primary: (embossed, theme)=>({
52
+ surface: embossed.accent.background,
53
+ chonk: embossed.accent.chonk,
54
+ content: embossed.accent.content,
55
+ focus: {
56
+ border: `2px dotted ${theme.tokens.focus.onVibrant.light}`
57
+ }
58
+ }),
59
+ secondary: (embossed, theme)=>({
60
+ surface: embossed.neutral.background,
61
+ chonk: embossed.neutral.chonk,
62
+ content: embossed.neutral.content.primary,
63
+ focus: {
64
+ boxShadow: `0 var(--button-lift) 0 0 ${embossed.neutral.chonk}, 0 var(--button-lift) 0 2px ${theme.tokens.focus.default}, 0 0 0 2px ${theme.tokens.focus.default}`
65
+ }
66
+ }),
67
+ warning: (embossed, theme)=>({
68
+ surface: embossed.warning.background,
69
+ chonk: embossed.warning.chonk,
70
+ content: embossed.warning.content,
71
+ focus: {
72
+ border: `2px dotted ${theme.tokens.focus.onVibrant.dark}`
73
+ }
74
+ }),
75
+ danger: (embossed, theme)=>({
76
+ surface: embossed.danger.background,
77
+ chonk: embossed.danger.chonk,
78
+ content: embossed.danger.content,
79
+ focus: {
80
+ border: `2px dotted ${theme.tokens.focus.onVibrant.light}`
81
+ }
82
+ })
83
+ };
84
+ function getChonkyStyles(p, tokens) {
85
+ return {
86
+ ...getBaseStyles(p),
87
+ '--button-lift': p.size.lift,
88
+ padding: 'square' === p.shapeVariant ? '0' : p.size.padding,
89
+ height: p.size.height,
90
+ minHeight: p.size.minHeight,
91
+ minWidth: 'square' === p.shapeVariant ? p.size.height : void 0,
92
+ color: tokens.content,
52
93
  '&::before': {
53
94
  content: '""',
54
95
  display: 'block',
55
96
  position: 'absolute',
56
97
  inset: '0',
57
- height: `calc(100% - ${buttonElevation})`,
58
- top: buttonElevation,
59
- transform: `translateY(-${buttonElevation})`,
60
- boxShadow: `0 ${buttonElevation} 0 0px ${buttonTheme.background}`,
61
- background: buttonTheme.background,
98
+ height: `calc(100% - ${p.size.lift})`,
99
+ top: p.size.lift,
100
+ transform: `translateY(-${p.size.lift})`,
101
+ boxShadow: `0 ${p.size.lift} 0 0px ${tokens.chonk}`,
102
+ background: tokens.chonk,
62
103
  borderRadius: 'inherit'
63
104
  },
64
105
  '&::after': {
@@ -66,23 +107,16 @@ function DO_NOT_USE_getButtonStyles(p) {
66
107
  display: 'block',
67
108
  position: 'absolute',
68
109
  inset: '0',
69
- background: buttonTheme.surface,
110
+ background: tokens.surface,
70
111
  borderRadius: 'inherit',
71
- border: `1px solid ${buttonTheme.background}`,
112
+ border: `1px solid ${tokens.chonk}`,
72
113
  transform: 'translateY(calc(-1 * var(--button-lift)))',
73
114
  transition: `transform ${p.theme.motion.snap.fast}`
74
115
  },
75
116
  '&:focus-visible': {
76
117
  outline: 'none',
77
- color: disabled || p.busy ? void 0 : buttonTheme.color,
78
- '&::after': buttonTheme.focus ? {
79
- border: `2px dotted ${buttonTheme.focus}`
80
- } : {
81
- boxShadow: `0 var(--button-lift) 0 0 ${buttonTheme.background}, 0 var(--button-lift) 0 2px ${p.theme.tokens.focus.default}, 0 0 0 2px ${p.theme.tokens.focus.default}`
82
- }
83
- },
84
- '&[aria-busy="true"] > span:last-child': {
85
- overflow: 'visible'
118
+ color: p.disabled || p.busy ? void 0 : tokens.content,
119
+ '&::after': tokens.focus
86
120
  },
87
121
  '> span:last-child': {
88
122
  zIndex: 1,
@@ -97,9 +131,12 @@ function DO_NOT_USE_getButtonStyles(p) {
97
131
  transform: 'translateY(calc(-1 * var(--button-lift)))',
98
132
  transition: `transform ${p.theme.motion.snap.fast}`
99
133
  },
134
+ '&[aria-busy="true"] > span:last-child': {
135
+ overflow: 'visible'
136
+ },
100
137
  '&:hover': {
101
- '--button-lift': `calc(${buttonElevation} + ${hoverElevation})`,
102
- color: disabled || p.busy ? void 0 : buttonTheme.color
138
+ '--button-lift': `calc(${p.size.lift} + 1px)`,
139
+ color: p.disabled || p.busy ? void 0 : tokens.content
103
140
  },
104
141
  '&:active, &[aria-expanded="true"], &[aria-checked="true"]': {
105
142
  '--button-lift': '0px'
@@ -114,134 +151,102 @@ function DO_NOT_USE_getButtonStyles(p) {
114
151
  },
115
152
  '&:disabled, &[aria-disabled="true"], &[aria-busy="true"]': {
116
153
  '--button-lift': '0px'
154
+ }
155
+ };
156
+ }
157
+ function getTransparentStyles(p) {
158
+ return {
159
+ ...getBaseStyles(p),
160
+ padding: 'square' === p.shapeVariant ? '0' : p.size.padding,
161
+ height: p.size.height,
162
+ minHeight: p.size.minHeight,
163
+ minWidth: 'square' === p.shapeVariant ? p.size.height : void 0,
164
+ color: p.theme.tokens.interactive.transparent.neutral.content.primary,
165
+ transform: 'translateY(0px)',
166
+ '&::before': {
167
+ display: 'none'
117
168
  },
118
- '&[aria-busy="true"]': {
119
- cursor: 'progress'
169
+ '&::after': {
170
+ display: 'none'
120
171
  },
121
- ...'link' === variant && {
122
- transform: 'translateY(0px)',
123
- '&::before': {
124
- display: 'none'
125
- },
126
- '&::after': {
127
- display: 'none'
128
- }
172
+ '&:focus-visible': p.theme.focusRing(),
173
+ '> span:last-child': {
174
+ transform: 'translateY(0px)'
129
175
  },
130
- ...('transparent' === variant || 'link' === variant) && {
131
- border: 'none',
132
- transform: 'translateY(0px)',
133
- '&::before': {
134
- display: 'none'
135
- },
136
- '&::after': {
137
- display: 'none'
138
- },
139
- '&:focus-visible': {
140
- ...p.theme.focusRing()
141
- },
142
- '> span:last-child': {
143
- transform: 'translateY(0px)'
144
- },
145
- '&:hover': {
146
- '> span:last-child': {
147
- transform: 'translateY(0px)'
148
- },
149
- backgroundColor: p.busy || disabled || 'link' === variant ? 'inherit' : p.theme.colors.gray100
150
- },
151
- '&:active': {
152
- '> span:last-child': {
153
- transform: 'translateY(0px)'
154
- },
155
- backgroundColor: p.busy || disabled || 'link' === variant ? 'inherit' : p.theme.colors.gray200
156
- }
176
+ '&:hover': {
177
+ backgroundColor: p.disabled || p.busy ? 'inherit' : p.theme.colors.gray100
157
178
  },
158
- ...'link' === variant && {
159
- padding: '0',
160
- height: 'auto',
161
- minHeight: 'auto',
162
- minWidth: 'auto',
163
- border: 'none',
164
- transform: 'translateY(0px)',
165
- '> span:last-child': {
166
- color: 'inherit'
167
- },
168
- '&:hover': {
169
- '> span:last-child': {
170
- transform: 'translateY(0px)'
171
- }
172
- }
179
+ '&:active': {
180
+ backgroundColor: p.disabled || p.busy ? 'inherit' : p.theme.colors.gray200
173
181
  }
174
182
  };
175
183
  }
176
- function getButtonTheme(variant, theme) {
177
- switch(variant){
178
- case 'primary':
179
- return {
180
- surface: theme.tokens.interactive.chonky.embossed.accent.background,
181
- background: theme.tokens.interactive.chonky.embossed.accent.chonk,
182
- color: theme.tokens.interactive.chonky.embossed.accent.content,
183
- focus: theme.tokens.focus.onVibrant.light
184
- };
185
- case 'secondary':
186
- return {
187
- surface: theme.tokens.interactive.chonky.embossed.neutral.background,
188
- background: theme.tokens.interactive.chonky.embossed.neutral.chonk,
189
- color: theme.tokens.interactive.chonky.embossed.neutral.content.primary
190
- };
191
- case 'warning':
192
- return {
193
- surface: theme.tokens.interactive.chonky.embossed.warning.background,
194
- background: theme.tokens.interactive.chonky.embossed.warning.chonk,
195
- color: theme.tokens.interactive.chonky.embossed.warning.content,
196
- focus: theme.tokens.focus.onVibrant.dark
197
- };
198
- case 'danger':
199
- return {
200
- surface: theme.tokens.interactive.chonky.embossed.danger.background,
201
- background: theme.tokens.interactive.chonky.embossed.danger.chonk,
202
- color: theme.tokens.interactive.chonky.embossed.danger.content,
203
- focus: theme.tokens.focus.onVibrant.light
204
- };
205
- case 'transparent':
206
- return {
207
- surface: theme.tokens.interactive.transparent.neutral.background.rest,
208
- background: theme.tokens.interactive.transparent.neutral.background.rest,
209
- color: theme.tokens.interactive.transparent.neutral.content.primary
210
- };
211
- case 'link':
212
- return {
213
- surface: 'transparent',
214
- background: 'transparent',
215
- color: theme.tokens.interactive.link.accent.rest
216
- };
217
- default:
218
- return {};
219
- }
184
+ function getLinkStyles(p) {
185
+ return {
186
+ ...getBaseStyles(p),
187
+ padding: '0',
188
+ height: 'auto',
189
+ minHeight: 'auto',
190
+ minWidth: 'auto',
191
+ color: p.theme.tokens.interactive.link.accent.rest,
192
+ transform: 'translateY(0px)',
193
+ '&::before': {
194
+ display: 'none'
195
+ },
196
+ '&::after': {
197
+ display: 'none'
198
+ },
199
+ '&:focus-visible': p.theme.focusRing(),
200
+ '> span:last-child': {
201
+ color: 'inherit'
202
+ },
203
+ '&:active': {
204
+ backgroundColor: 'inherit'
205
+ }
206
+ };
220
207
  }
221
- function getButtonSizeTheme(size, theme) {
208
+ function getSizeTokens(size, theme) {
222
209
  switch(size){
223
210
  case 'md':
224
211
  return {
212
+ height: '36px',
213
+ minHeight: '36px',
214
+ fontSize: '0.875rem',
215
+ lineHeight: '1rem',
216
+ padding: `${theme.space.md} ${theme.space.xl}`,
225
217
  borderRadius: theme.radius.lg,
226
- padding: `${theme.space.md} ${theme.space.xl}`
218
+ lift: '2px'
227
219
  };
228
220
  case 'sm':
229
221
  return {
222
+ height: '32px',
223
+ minHeight: '32px',
224
+ fontSize: '0.875rem',
225
+ lineHeight: '1rem',
226
+ padding: `${theme.space.md} ${theme.space.lg}`,
230
227
  borderRadius: theme.radius.md,
231
- padding: `${theme.space.md} ${theme.space.lg}`
228
+ lift: '2px'
232
229
  };
233
230
  case 'xs':
234
231
  return {
232
+ height: '28px',
233
+ minHeight: '28px',
234
+ fontSize: '0.75rem',
235
+ lineHeight: '1rem',
236
+ padding: `${theme.space.sm} ${theme.space.md}`,
235
237
  borderRadius: theme.radius.sm,
236
- padding: `${theme.space.sm} ${theme.space.md}`
238
+ lift: '1px'
237
239
  };
238
240
  case 'zero':
239
241
  return {
242
+ height: '24px',
243
+ minHeight: '24px',
244
+ fontSize: '0.75rem',
245
+ lineHeight: '1rem',
246
+ padding: `${theme.space.xs} ${theme.space.sm}`,
240
247
  borderRadius: theme.radius.xs,
241
- padding: `${theme.space.xs} ${theme.space.sm}`
248
+ lift: '0px'
242
249
  };
243
- default:
244
- return {};
245
250
  }
246
251
  }
247
252
  export { DO_NOT_USE_BUTTON_ICON_SIZES, DO_NOT_USE_getButtonStyles };
@@ -0,0 +1,15 @@
1
+ import type * as React from 'react';
2
+ import { type ButtonProps } from '../button/index.js';
3
+ export interface CopyToClipboardButtonProps extends Omit<Extract<ButtonProps, {
4
+ 'aria-label': string;
5
+ }>, 'children' | 'onCopy' | 'onError'> {
6
+ text: string;
7
+ children?: never;
8
+ /** Custom failure feedback. Pass false to suppress the toast. */
9
+ errorMessage?: React.ReactNode;
10
+ onCopy?: (copiedText: string) => void;
11
+ onError?: (error: unknown) => void;
12
+ /** Custom success feedback. Pass false to suppress the toast. */
13
+ successMessage?: React.ReactNode;
14
+ }
15
+ export declare function CopyToClipboardButton({ onCopy, onError, onClick, text, icon, errorMessage, successMessage, ...props }: CopyToClipboardButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { IconCopy } from "@sentry/icons/copy";
3
+ import { Button } from "../button/index.js";
4
+ import { toast } from "../toast/index.js";
5
+ import { useTranslation } from "../translation/index.js";
6
+ function CopyToClipboardButton({ onCopy, onError, onClick, text, icon, errorMessage, successMessage, ...props }) {
7
+ const { t } = useTranslation();
8
+ async function copy() {
9
+ try {
10
+ await navigator.clipboard.writeText(text);
11
+ } catch (error) {
12
+ const message = errorMessage ?? t('Error copying to clipboard');
13
+ if (message) toast.error(message);
14
+ onError?.(error);
15
+ return;
16
+ }
17
+ const message = successMessage ?? t('Copied to clipboard');
18
+ if (message) toast.success(message);
19
+ onCopy?.(text);
20
+ }
21
+ return /*#__PURE__*/ jsx(Button, {
22
+ ...props,
23
+ onClick: (event)=>{
24
+ copy();
25
+ onClick?.(event);
26
+ },
27
+ icon: icon ?? /*#__PURE__*/ jsx(IconCopy, {
28
+ variant: "muted"
29
+ })
30
+ });
31
+ }
32
+ export { CopyToClipboardButton };
@@ -0,0 +1 @@
1
+ export { CopyToClipboardButton, type CopyToClipboardButtonProps, } from './copyToClipboardButton.js';
@@ -0,0 +1 @@
1
+ export { CopyToClipboardButton } from "./copyToClipboardButton.js";