@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
@@ -0,0 +1 @@
1
+ export { InlineCode, inlineCodeStyles } from './inlineCode.js';
@@ -0,0 +1 @@
1
+ export { InlineCode, inlineCodeStyles } from "./inlineCode.js";
@@ -0,0 +1,68 @@
1
+ import type * as React from 'react';
2
+ export interface CodeBlockProps {
3
+ children: string;
4
+ /**
5
+ * Keeps the copy button visible when it floats over the code snippet.
6
+ */
7
+ alwaysShowCopyButton?: boolean;
8
+ className?: string;
9
+ dark?: boolean;
10
+ ['data-render-inline']?: boolean;
11
+ /**
12
+ * Makes the text of the element and its sub-elements not selectable.
13
+ * Useful when loading parts of a code snippet, and
14
+ * we wish to avoid users copying them manually.
15
+ */
16
+ disableUserSelection?: boolean;
17
+ /**
18
+ * Name of the file to be displayed at the top of the code snippet.
19
+ */
20
+ filename?: string;
21
+ /**
22
+ * Hides the copy button in the top right.
23
+ */
24
+ hideCopyButton?: boolean;
25
+ /**
26
+ * Adds an icon to the top right, next to the copy button.
27
+ */
28
+ icon?: React.ReactNode;
29
+ /**
30
+ * Controls whether the snippet wrapper has rounded corners.
31
+ */
32
+ isRounded?: boolean;
33
+ language?: string;
34
+ /**
35
+ * Line numbers of the code that will be visually highlighted.
36
+ */
37
+ linesToHighlight?: number[];
38
+ /**
39
+ * Fires after the code snippet is highlighted and all DOM nodes are available
40
+ * @param element The root element of the code snippet
41
+ */
42
+ onAfterHighlight?: (element: HTMLElement) => void;
43
+ /**
44
+ * Fires with the user presses the copy button.
45
+ */
46
+ onCopy?: (copiedCode: string) => void;
47
+ /**
48
+ * Fires when the user selects and copies code snippet manually
49
+ */
50
+ onSelectAndCopy?: () => void;
51
+ /**
52
+ * Fires when the user switches tabs.
53
+ */
54
+ onTabClick?: (tab: string) => void;
55
+ ref?: React.Ref<HTMLDivElement>;
56
+ selectedTab?: string;
57
+ tabs?: Array<{
58
+ label: string;
59
+ value: string;
60
+ }>;
61
+ /**
62
+ * Controls whether long lines scroll horizontally or wrap within the snippet.
63
+ *
64
+ * @default 'scroll'
65
+ */
66
+ wrapMode?: 'scroll' | 'wrap';
67
+ }
68
+ export declare function CodeBlock({ alwaysShowCopyButton, children, className, dark, 'data-render-inline': dataRenderInline, disableUserSelection, filename, hideCopyButton, language, linesToHighlight, icon, isRounded, onAfterHighlight, onCopy, onSelectAndCopy, onTabClick, ref: forwardedRef, selectedTab, tabs, wrapMode, }: CodeBlockProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,243 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { Fragment, useEffect, useRef, useState } from "react";
3
+ import { ThemeProvider, css, useTheme } from "@emotion/react";
4
+ import styled from "@emotion/styled";
5
+ import { IconCopy } from "@sentry/icons/copy";
6
+ import prismjs from "prismjs";
7
+ import { Button } from "../button/index.js";
8
+ import { Container } from "../layout/index.js";
9
+ import { darkTheme } from "../theme/index.js";
10
+ import { useTranslation } from "../translation/index.js";
11
+ import { getPrismLanguage, loadPrismLanguage } from "./prism.js";
12
+ import { codeBlockStyles } from "./styles.js";
13
+ function CodeBlock({ alwaysShowCopyButton, children, className, dark, 'data-render-inline': dataRenderInline, disableUserSelection, filename, hideCopyButton, language, linesToHighlight, icon, isRounded = true, onAfterHighlight, onCopy, onSelectAndCopy, onTabClick, ref: forwardedRef, selectedTab, tabs, wrapMode = 'scroll' }) {
14
+ const { t } = useTranslation();
15
+ const ref = useRef(null);
16
+ const theme = useTheme();
17
+ const [lineHighlightLoaded, setLineHighlightLoaded] = useState(false);
18
+ useEffect(()=>{
19
+ async function loadLineHighlight() {
20
+ await import("prismjs/plugins/line-highlight/prism-line-highlight.js");
21
+ setLineHighlightLoaded(true);
22
+ }
23
+ if (linesToHighlight) loadLineHighlight();
24
+ }, [
25
+ linesToHighlight
26
+ ]);
27
+ useEffect(()=>{
28
+ const element = ref.current;
29
+ if (!element) return;
30
+ if (!language || !getPrismLanguage(language)) return;
31
+ if (language in prismjs.languages) return void prismjs.highlightElement(element, false, ()=>onAfterHighlight?.(element));
32
+ loadPrismLanguage(language, {
33
+ onLoad: ()=>prismjs.highlightElement(element, false, ()=>onAfterHighlight?.(element))
34
+ });
35
+ }, [
36
+ children,
37
+ language,
38
+ onAfterHighlight,
39
+ lineHighlightLoaded
40
+ ]);
41
+ const [tooltipState, setTooltipState] = useState('copy');
42
+ const handleCopy = ()=>{
43
+ navigator.clipboard.writeText(ref.current?.textContent ?? '').then(()=>{
44
+ setTooltipState('copied');
45
+ }).catch(()=>{
46
+ setTooltipState('error');
47
+ });
48
+ onCopy?.(children);
49
+ };
50
+ const hasTabs = tabs && tabs.length > 0;
51
+ const hasFloatingHeader = !(filename || hasTabs);
52
+ const tooltipTitle = 'copy' === tooltipState ? t('Copy') : 'copied' === tooltipState ? t('Copied') : t('Unable to copy');
53
+ const snippet = /*#__PURE__*/ jsxs(Wrapper, {
54
+ ref: forwardedRef,
55
+ reserveCopyButtonSpace: alwaysShowCopyButton && hasFloatingHeader,
56
+ isRounded: isRounded,
57
+ wrapMode: wrapMode,
58
+ className: `${dark ? 'prism-dark ' : ''}${className ?? ''}`,
59
+ "data-render-inline": dataRenderInline,
60
+ children: [
61
+ /*#__PURE__*/ jsxs(Header, {
62
+ isFloating: hasFloatingHeader,
63
+ children: [
64
+ hasTabs && /*#__PURE__*/ jsxs(Fragment, {
65
+ children: [
66
+ /*#__PURE__*/ jsx(TabsWrapper, {
67
+ children: tabs.map(({ label, value })=>/*#__PURE__*/ jsx(Tab, {
68
+ type: "button",
69
+ isSelected: selectedTab === value,
70
+ onClick: ()=>onTabClick?.(value),
71
+ children: label
72
+ }, value))
73
+ }),
74
+ /*#__PURE__*/ jsx(Container, {
75
+ flexGrow: 1
76
+ })
77
+ ]
78
+ }),
79
+ icon,
80
+ filename && /*#__PURE__*/ jsx(FileName, {
81
+ children: filename
82
+ }),
83
+ !hasTabs && /*#__PURE__*/ jsx(Container, {
84
+ flexGrow: 1
85
+ }),
86
+ !hideCopyButton && /*#__PURE__*/ jsx(CopyButton, {
87
+ type: "button",
88
+ size: "xs",
89
+ variant: "transparent",
90
+ onClick: handleCopy,
91
+ tooltipProps: {
92
+ position: 'left',
93
+ title: tooltipTitle
94
+ },
95
+ onMouseLeave: ()=>setTooltipState('copy'),
96
+ isAlwaysVisible: alwaysShowCopyButton || !hasFloatingHeader || !!icon && hasFloatingHeader,
97
+ "aria-label": t('Copy snippet'),
98
+ icon: /*#__PURE__*/ jsx(IconCopy, {})
99
+ })
100
+ ]
101
+ }),
102
+ /*#__PURE__*/ jsx(ScrollWrapper, {
103
+ reserveCopyButtonSpace: alwaysShowCopyButton && hasFloatingHeader,
104
+ wrapMode: wrapMode,
105
+ children: /*#__PURE__*/ jsx("pre", {
106
+ className: `language-${String(language)}`,
107
+ "data-line": linesToHighlight?.join(','),
108
+ children: /*#__PURE__*/ jsx(Code, {
109
+ ref: ref,
110
+ className: `language-${String(language)}`,
111
+ onCopy: onSelectAndCopy,
112
+ disableUserSelection: disableUserSelection,
113
+ wrapMode: wrapMode,
114
+ children: children
115
+ })
116
+ })
117
+ })
118
+ ]
119
+ });
120
+ return /*#__PURE__*/ jsx(ThemeProvider, {
121
+ theme: dark ? darkTheme : theme,
122
+ children: snippet
123
+ });
124
+ }
125
+ const Wrapper = styled('div')`
126
+ ${(p)=>codeBlockStyles(p.theme)};
127
+
128
+ position: relative;
129
+ isolation: isolate;
130
+ height: 100%;
131
+ min-width: 0;
132
+ background: var(--prism-block-background);
133
+ border-radius: ${(p)=>p.isRounded ? p.theme.radius.md : '0px'};
134
+
135
+ && code[class*='language-'] {
136
+ white-space: ${(p)=>'wrap' === p.wrapMode ? 'pre-wrap' : 'pre'};
137
+ overflow-wrap: ${(p)=>'wrap' === p.wrapMode ? 'anywhere' : 'normal'};
138
+ }
139
+
140
+ && pre[class*='language-'] {
141
+ margin: 0;
142
+ height: 100%;
143
+ width: ${(p)=>'wrap' === p.wrapMode ? '100%' : 'max-content'};
144
+ min-width: 100%;
145
+ white-space: ${(p)=>'wrap' === p.wrapMode ? 'pre-wrap' : 'pre'};
146
+ overflow-wrap: ${(p)=>'wrap' === p.wrapMode ? 'anywhere' : 'normal'};
147
+
148
+ ${(p)=>'wrap' === p.wrapMode && p.reserveCopyButtonSpace && css`
149
+ &::before {
150
+ content: '';
151
+ float: right;
152
+ width: ${p.theme.space.lg};
153
+ height: ${p.theme.space.xl};
154
+ }
155
+ `}
156
+ }
157
+
158
+ &[data-render-inline='true'] pre {
159
+ padding: 0;
160
+ }
161
+ `;
162
+ const Header = styled('div')`
163
+ display: flex;
164
+ align-items: center;
165
+
166
+ font-family: ${(p)=>p.theme.font.family.mono};
167
+ font-size: ${(p)=>p.theme.font.size.sm};
168
+ color: var(--prism-base);
169
+ font-weight: ${(p)=>p.theme.font.weight.mono.medium};
170
+ z-index: 2;
171
+
172
+ ${(p)=>p.isFloating ? css`
173
+ gap: ${p.theme.space['2xs']};
174
+ justify-content: flex-end;
175
+ position: absolute;
176
+ top: 0;
177
+ right: 0;
178
+ width: max-content;
179
+ height: max-content;
180
+ max-height: 100%;
181
+ padding: ${p.theme.space.xs};
182
+ ` : css`
183
+ gap: ${p.theme.space.sm};
184
+ padding: ${p.theme.space.xs} ${p.theme.space.xs} 0 ${p.theme.space.md};
185
+ border-bottom: solid 1px ${p.theme.tokens.border.primary};
186
+ `}
187
+ `;
188
+ const FileName = styled('span')`
189
+ display: block;
190
+ white-space: nowrap;
191
+ overflow: hidden;
192
+ text-overflow: ellipsis;
193
+ width: auto;
194
+ `;
195
+ const TabsWrapper = styled('div')`
196
+ padding: 0;
197
+ display: flex;
198
+ overflow-x: auto;
199
+ `;
200
+ const Tab = styled('button')`
201
+ box-sizing: border-box;
202
+ display: block;
203
+ margin: 0;
204
+ border: none;
205
+ background: none;
206
+ padding: ${(p)=>p.theme.space.md} ${(p)=>p.theme.space.md};
207
+ color: var(--prism-comment);
208
+ ${(p)=>p.isSelected ? css`
209
+ border-bottom: 3px solid ${p.theme.tokens.graphics.accent.vibrant};
210
+ padding-bottom: 5px;
211
+ color: var(--prism-base);
212
+ ` : ''}
213
+ `;
214
+ const CopyButton = styled(Button)`
215
+ color: var(--prism-comment);
216
+ transition: opacity 0.1s ease-out;
217
+ opacity: 0;
218
+
219
+ div:hover > div > &, /* if Wrapper is hovered */
220
+ &:focus-visible {
221
+ opacity: 1;
222
+ }
223
+ &:hover {
224
+ color: var(--prism-base);
225
+ }
226
+ ${(p)=>p.isAlwaysVisible ? 'opacity: 1;' : ''}
227
+ `;
228
+ const ScrollWrapper = styled('div')`
229
+ overflow-x: ${(p)=>'wrap' === p.wrapMode ? 'hidden' : 'auto'};
230
+ height: 100%;
231
+ margin-right: ${(p)=>'scroll' === p.wrapMode && p.reserveCopyButtonSpace ? p.theme.space['3xl'] : '0'};
232
+ `;
233
+ const Code = styled('code')`
234
+ user-select: ${(p)=>p.disableUserSelection ? 'none' : 'auto'};
235
+
236
+ ${(p)=>'wrap' === p.wrapMode && css`
237
+ && {
238
+ white-space: pre-wrap;
239
+ overflow-wrap: anywhere;
240
+ }
241
+ `}
242
+ `;
243
+ export { CodeBlock };
@@ -0,0 +1,2 @@
1
+ export { CodeBlock, type CodeBlockProps } from './codeBlock.js';
2
+ export { getPrismLanguage, loadPrismLanguage } from './prism.js';
@@ -0,0 +1,2 @@
1
+ export { CodeBlock } from "./codeBlock.js";
2
+ export { getPrismLanguage, loadPrismLanguage } from "./prism.js";
@@ -0,0 +1,11 @@
1
+ export declare const getPrismLanguage: (lang: string) => string | undefined;
2
+ /**
3
+ * Loads the specified Prism language (aliases like `js` for `javascript` also work).
4
+ * Will log a warning if a) the language doesn't exist (unless `suppressExistenceWarning`
5
+ * is true) or b) there was a problem downloading the grammar file.
6
+ */
7
+ export declare function loadPrismLanguage(lang: string, { onError, onLoad, suppressExistenceWarning, }: {
8
+ onError?: (error: unknown) => void;
9
+ onLoad?: () => void;
10
+ suppressExistenceWarning?: boolean;
11
+ }): Promise<void>;
@@ -0,0 +1,101 @@
1
+ import prismjs from "prismjs";
2
+ import components from "prismjs/components.js";
3
+ const prismLanguages = components.languages;
4
+ prismjs.manual = true;
5
+ const PRISM_LANGUAGE_MAP = Object.fromEntries(Object.entries(prismLanguages).flatMap(([lang, value])=>{
6
+ if (!value.alias) return [
7
+ [
8
+ lang,
9
+ lang
10
+ ]
11
+ ];
12
+ return [
13
+ [
14
+ lang,
15
+ lang
16
+ ],
17
+ ...Array.isArray(value.alias) ? value.alias.map((alias)=>[
18
+ alias,
19
+ lang
20
+ ]) : [
21
+ [
22
+ value.alias,
23
+ lang
24
+ ]
25
+ ]
26
+ ];
27
+ }));
28
+ const EXTRA_LANGUAGE_ALIASES = {
29
+ cc: 'cpp',
30
+ erl: 'erlang',
31
+ ex: 'elixir',
32
+ h: 'c',
33
+ m: 'objectivec',
34
+ pl: 'perl',
35
+ pm: 'perl',
36
+ pyx: 'python',
37
+ rs: 'rust',
38
+ jbuilder: 'ruby',
39
+ ru: 'ruby',
40
+ rake: 'ruby',
41
+ rabl: 'ruby',
42
+ cjs: "javascript",
43
+ mjs: "javascript",
44
+ jsbundle: "javascript",
45
+ bundle: "javascript",
46
+ astro: "javascript",
47
+ vue: "javascript",
48
+ svelte: "javascript",
49
+ 'js?': "javascript",
50
+ 'ts?': "typescript",
51
+ 'tsx?': 'tsx',
52
+ mts: "typescript",
53
+ clj: 'clojure',
54
+ cljc: 'clojure',
55
+ cljs: 'clojure',
56
+ php5: 'php',
57
+ phtml: 'php',
58
+ arb: 'json',
59
+ ps1: 'powershell',
60
+ jinja: 'jinja2',
61
+ gd: "gdscript"
62
+ };
63
+ const getPrismLanguage = (lang)=>{
64
+ const language = lang.toLowerCase();
65
+ const aliased = EXTRA_LANGUAGE_ALIASES[language];
66
+ return PRISM_LANGUAGE_MAP[aliased ?? language];
67
+ };
68
+ const pendingGrammars = new Map();
69
+ function loadGrammar(language) {
70
+ if (prismjs.languages[language]) return Promise.resolve();
71
+ const pending = pendingGrammars.get(language);
72
+ if (pending) return pending;
73
+ const load = async ()=>{
74
+ const required = prismLanguages[language]?.require;
75
+ const dependencies = Array.isArray(required) ? required : required ? [
76
+ required
77
+ ] : [];
78
+ for (const dependency of dependencies)await loadGrammar(dependency);
79
+ await import(`prismjs/components/prism-${language}.min.js`);
80
+ };
81
+ const promise = load().finally(()=>pendingGrammars.delete(language));
82
+ pendingGrammars.set(language, promise);
83
+ return promise;
84
+ }
85
+ async function loadPrismLanguage(lang, { onError, onLoad, suppressExistenceWarning }) {
86
+ try {
87
+ const language = getPrismLanguage(lang);
88
+ if (language && prismjs.languages[language]) return void onLoad?.();
89
+ if (!language) {
90
+ if (!suppressExistenceWarning) console.warn(`No Prism grammar file for \`${lang}\` exists. Check the \`lang\` argument passed to \`loadPrismLanguage()\`.`);
91
+ onError?.(new Error(`No Prism grammar file for \`${lang}\` exists.`));
92
+ return;
93
+ }
94
+ await loadGrammar(language);
95
+ onLoad?.();
96
+ } catch (error) {
97
+ console.warn(`Cannot download Prism grammar file for \`${lang}\`. Check the internet connection, and the \`lang\` argument passed to \`loadPrismLanguage()\`.`);
98
+ onError?.(error);
99
+ }
100
+ }
101
+ export { getPrismLanguage, loadPrismLanguage };
@@ -0,0 +1,2 @@
1
+ import type { Theme } from '@emotion/react';
2
+ export declare const codeBlockStyles: (theme: Theme) => import("@emotion/react").SerializedStyles;
@@ -0,0 +1,133 @@
1
+ import { css } from "@emotion/react";
2
+ const generateThemePrismVariables = (theme, blockBackground)=>({
3
+ '--prism-base': theme.tokens.syntax.base,
4
+ '--prism-inline-code': theme.tokens.syntax.inlineCode,
5
+ '--prism-inline-code-background': theme.tokens.syntax.codeBackground,
6
+ '--prism-highlight-background': theme.tokens.syntax.hightlightBackground,
7
+ '--prism-highlight-accent': theme.tokens.syntax.hightlightAccent,
8
+ '--prism-comment': theme.tokens.syntax.comment,
9
+ '--prism-punctuation': theme.tokens.syntax.punctuation,
10
+ '--prism-property': theme.tokens.syntax.property,
11
+ '--prism-selector': theme.tokens.syntax.selector,
12
+ '--prism-operator': theme.tokens.syntax.operator,
13
+ '--prism-variable': theme.tokens.syntax.variable,
14
+ '--prism-function': theme.tokens.syntax.function,
15
+ '--prism-keyword': theme.tokens.syntax.keyWord,
16
+ '--prism-block-background': blockBackground
17
+ });
18
+ const codeBlockStyles = (theme)=>css`
19
+ ${generateThemePrismVariables(theme, theme.tokens.background.secondary)};
20
+ pre[class*='language-'] {
21
+ overflow-x: auto;
22
+ padding: ${theme.space.md} ${theme.space.xl};
23
+ border-radius: ${theme.radius.md};
24
+ box-shadow: none;
25
+
26
+ code {
27
+ background: unset;
28
+ }
29
+ }
30
+
31
+ pre[class*='language-'],
32
+ code[class*='language-'] {
33
+ color: var(--prism-base);
34
+ background: var(--prism-block-background);
35
+ font-size: ${theme.font.size.sm};
36
+ text-shadow: none;
37
+ font-family: ${theme.font.family.mono};
38
+ direction: ltr;
39
+ text-align: left;
40
+ white-space: pre;
41
+ word-spacing: normal;
42
+ word-break: normal;
43
+ -moz-tab-size: 4;
44
+ -o-tab-size: 4;
45
+ tab-size: 4;
46
+ -webkit-hyphens: none;
47
+ -moz-hyphens: none;
48
+ -ms-hyphens: none;
49
+ hyphens: none;
50
+
51
+ .namespace {
52
+ opacity: 0.7;
53
+ }
54
+ .token.comment,
55
+ .token.prolog,
56
+ .token.doctype,
57
+ .token.cdata {
58
+ color: var(--prism-comment);
59
+ }
60
+ .token.punctuation {
61
+ color: var(--prism-punctuation);
62
+ }
63
+ .token.property,
64
+ .token.tag,
65
+ .token.boolean,
66
+ .token.number,
67
+ .token.constant,
68
+ .token.symbol,
69
+ .token.deleted {
70
+ color: var(--prism-property);
71
+ }
72
+ .token.selector,
73
+ .token.attr-name,
74
+ .token.string,
75
+ .token.char,
76
+ .token.builtin,
77
+ .token.inserted {
78
+ color: var(--prism-selector);
79
+ }
80
+ .token.operator,
81
+ .token.entity,
82
+ .token.url,
83
+ .language-css .token.string,
84
+ .style .token.string {
85
+ color: var(--prism-operator);
86
+ background: none;
87
+ }
88
+ .token.atrule,
89
+ .token.attr-value,
90
+ .token.keyword {
91
+ color: var(--prism-keyword);
92
+ }
93
+ .token.function {
94
+ color: var(--prism-function);
95
+ }
96
+ .token.regex,
97
+ .token.important,
98
+ .token.variable {
99
+ color: var(--prism-variable);
100
+ }
101
+ .token.important,
102
+ .token.bold {
103
+ font-weight: ${theme.font.weight.sans.medium};
104
+ }
105
+ .token.italic {
106
+ font-style: italic;
107
+ }
108
+ .token.entity {
109
+ cursor: help;
110
+ }
111
+ .line-highlight {
112
+ position: absolute;
113
+ left: -${theme.space.xl};
114
+ right: 0;
115
+ background: var(--prism-highlight-background);
116
+ box-shadow: inset 5px 0 0 var(--prism-highlight-accent);
117
+ z-index: 0;
118
+ pointer-events: none;
119
+ line-height: inherit;
120
+ white-space: pre;
121
+ }
122
+ }
123
+
124
+ pre[data-line] {
125
+ position: relative;
126
+ }
127
+
128
+ pre[class*='language-'] > code[class*='language-'] {
129
+ position: relative;
130
+ z-index: 1;
131
+ }
132
+ `;
133
+ export { codeBlockStyles };
@@ -0,0 +1,21 @@
1
+ import type * as React from 'react';
2
+ import type { DistributedOmit } from 'type-fest';
3
+ import { type ControlProps } from './control.js';
4
+ import type { MultipleListProps, SingleListProps } from './list.js';
5
+ import type { SelectKey, SelectOption, SelectOptionOrSection, SelectSection } from './types.js';
6
+ export type { SelectOption, SelectOptionOrSection, SelectSection, SelectKey };
7
+ interface BaseSelectProps<Value extends SelectKey> extends Omit<ControlProps, 'onClear' | 'clearable'> {
8
+ options: Array<SelectOptionOrSection<Value>>;
9
+ /**
10
+ * Number of options above which virtualization will be enabled.
11
+ * Note that virtualization is always disabled if there are sections in the options.
12
+ * @default 150
13
+ */
14
+ virtualizeThreshold?: number;
15
+ }
16
+ export type SingleSelectProps<Value extends SelectKey> = BaseSelectProps<Value> & DistributedOmit<SingleListProps<Value>, 'children' | 'items' | 'mode' | 'label'>;
17
+ export type MultipleSelectProps<Value extends SelectKey> = BaseSelectProps<Value> & DistributedOmit<MultipleListProps<Value>, 'children' | 'items' | 'mode' | 'label'>;
18
+ export type SelectProps<Value extends SelectKey> = SingleSelectProps<Value> | MultipleSelectProps<Value>;
19
+ export declare function CompactSelect<Value extends number>(props: SelectProps<Value>): React.JSX.Element;
20
+ export declare function CompactSelect<Value extends string>(props: SelectProps<Value>): React.JSX.Element;
21
+ export declare function CompactSelect<Value extends SelectKey>(props: SelectProps<Value>): React.JSX.Element;