@sentry/scraps 0.1.0 → 0.3.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 (253) hide show
  1. package/README.md +13 -21
  2. package/dist/alert/alert.d.ts +25 -0
  3. package/dist/alert/alert.js +262 -0
  4. package/dist/alert/alertLink.d.ts +32 -0
  5. package/dist/alert/alertLink.js +94 -0
  6. package/dist/alert/index.d.ts +2 -0
  7. package/dist/alert/index.js +2 -0
  8. package/dist/backdrop/backdrop.d.ts +9 -0
  9. package/dist/backdrop/backdrop.js +28 -0
  10. package/dist/backdrop/index.d.ts +1 -0
  11. package/dist/backdrop/index.js +1 -0
  12. package/dist/badge/badge.d.ts +12 -0
  13. package/dist/badge/badge.js +80 -0
  14. package/dist/badge/featureBadge.d.ts +6 -0
  15. package/dist/badge/featureBadge.js +86 -0
  16. package/dist/badge/index.d.ts +3 -0
  17. package/dist/badge/index.js +3 -0
  18. package/dist/badge/tag.d.ts +15 -0
  19. package/dist/badge/tag.js +119 -0
  20. package/dist/boundaryContext.d.ts +2 -0
  21. package/dist/boundaryContext.js +5 -0
  22. package/dist/button/button.d.ts +3 -0
  23. package/dist/button/button.js +83 -0
  24. package/dist/button/buttonBar.d.ts +10 -0
  25. package/dist/button/buttonBar.js +141 -0
  26. package/dist/button/index.d.ts +5 -0
  27. package/dist/button/index.js +4 -0
  28. package/dist/button/linkButton.d.ts +3 -0
  29. package/dist/button/linkButton.js +110 -0
  30. package/dist/button/styles.d.ts +10 -0
  31. package/dist/button/styles.js +247 -0
  32. package/dist/button/types.d.ts +77 -0
  33. package/dist/button/types.js +0 -0
  34. package/dist/button/useButtonFunctionality.d.ts +5 -0
  35. package/dist/button/useButtonFunctionality.js +9 -0
  36. package/dist/checkbox/checkbox.d.ts +20 -0
  37. package/dist/checkbox/checkbox.js +193 -0
  38. package/dist/checkbox/index.d.ts +1 -0
  39. package/dist/checkbox/index.js +1 -0
  40. package/dist/chip/chip.d.ts +128 -0
  41. package/dist/chip/chip.js +364 -0
  42. package/dist/chip/index.d.ts +1 -0
  43. package/dist/chip/index.js +1 -0
  44. package/dist/code/inlineCode.d.ts +1 -0
  45. package/dist/datetime.d.ts +39 -0
  46. package/dist/datetime.js +20 -0
  47. package/dist/descriptionList/descriptionList.d.ts +69 -0
  48. package/dist/descriptionList/descriptionList.js +76 -0
  49. package/dist/descriptionList/index.d.ts +1 -0
  50. package/dist/descriptionList/index.js +1 -0
  51. package/dist/disclosure/disclosure.d.ts +37 -0
  52. package/dist/disclosure/disclosure.js +155 -0
  53. package/dist/disclosure/index.d.ts +1 -0
  54. package/dist/disclosure/index.js +1 -0
  55. package/dist/dragHandle/dragHandle.d.ts +34 -0
  56. package/dist/dragHandle/dragHandle.js +115 -0
  57. package/dist/dragHandle/index.d.ts +4 -0
  58. package/dist/dragHandle/index.js +4 -0
  59. package/dist/dragHandle/setDocumentDragging.d.ts +9 -0
  60. package/dist/dragHandle/setDocumentDragging.js +6 -0
  61. package/dist/dragHandle/useDragMove.d.ts +244 -0
  62. package/dist/dragHandle/useDragMove.js +66 -0
  63. package/dist/dragHandle/useDragSeparator.d.ts +256 -0
  64. package/dist/dragHandle/useDragSeparator.js +36 -0
  65. package/dist/emptyState/emptyState.d.ts +10 -0
  66. package/dist/emptyState/emptyState.js +81 -0
  67. package/dist/emptyState/index.d.ts +1 -0
  68. package/dist/emptyState/index.js +1 -0
  69. package/dist/formPresentation/autoSaveContext.d.ts +23 -0
  70. package/dist/formPresentation/autoSaveContext.js +13 -0
  71. package/dist/formPresentation/base.d.ts +11 -0
  72. package/dist/formPresentation/base.js +37 -0
  73. package/dist/formPresentation/displayField.d.ts +17 -0
  74. package/dist/formPresentation/displayField.js +69 -0
  75. package/dist/formPresentation/fieldIds.d.ts +3 -0
  76. package/dist/formPresentation/fieldIds.js +14 -0
  77. package/dist/formPresentation/fieldLayout.d.ts +23 -0
  78. package/dist/formPresentation/fieldLayout.js +76 -0
  79. package/dist/formPresentation/formContext.d.ts +4 -0
  80. package/dist/formPresentation/formContext.js +6 -0
  81. package/dist/formPresentation/groupContext.d.ts +24 -0
  82. package/dist/formPresentation/groupContext.js +22 -0
  83. package/dist/formPresentation/icons.d.ts +11 -0
  84. package/dist/formPresentation/icons.js +61 -0
  85. package/dist/formPresentation/index.d.ts +8 -0
  86. package/dist/formPresentation/index.js +8 -0
  87. package/dist/formPresentation/meta.d.ts +18 -0
  88. package/dist/formPresentation/meta.js +88 -0
  89. package/dist/formPresentation/useStackedLayout.d.ts +1 -0
  90. package/dist/formPresentation/useStackedLayout.js +9 -0
  91. package/dist/hotkey/hotkey.d.ts +22 -0
  92. package/dist/hotkey/hotkey.js +41 -0
  93. package/dist/hotkey/index.d.ts +4 -0
  94. package/dist/hotkey/index.js +3 -0
  95. package/dist/hotkey/kbd.d.ts +1 -0
  96. package/dist/hotkey/keyMappings.d.ts +23 -0
  97. package/dist/hotkey/keyMappings.js +223 -0
  98. package/dist/hotkey/useHotkeys.d.ts +47 -0
  99. package/dist/hotkey/useHotkeys.js +44 -0
  100. package/dist/image/image.d.ts +21 -0
  101. package/dist/image/image.js +20 -0
  102. package/dist/image/index.d.ts +1 -0
  103. package/dist/image/index.js +1 -0
  104. package/dist/info/index.d.ts +2 -0
  105. package/dist/info/index.js +2 -0
  106. package/dist/info/infoText.d.ts +15 -0
  107. package/dist/info/infoText.js +43 -0
  108. package/dist/info/infoTip.d.ts +10 -0
  109. package/dist/info/infoTip.js +54 -0
  110. package/dist/input/index.d.ts +8 -0
  111. package/dist/input/index.js +6 -0
  112. package/dist/input/input.d.ts +19 -0
  113. package/dist/input/input.js +14 -0
  114. package/dist/input/inputGroup.d.ts +29 -0
  115. package/dist/input/inputGroup.js +167 -0
  116. package/dist/input/inputStyles.d.ts +13 -0
  117. package/dist/input/inputStyles.js +52 -0
  118. package/dist/input/numberDragInput.d.ts +20 -0
  119. package/dist/input/numberDragInput.js +97 -0
  120. package/dist/input/numberInput.d.ts +10 -0
  121. package/dist/input/numberInput.js +94 -0
  122. package/dist/input/otpInput.d.ts +28 -0
  123. package/dist/input/otpInput.js +81 -0
  124. package/dist/input/useAutosizeInput.d.ts +17 -0
  125. package/dist/input/useAutosizeInput.js +56 -0
  126. package/dist/interactionStateLayer/index.d.ts +1 -0
  127. package/dist/interactionStateLayer/index.js +1 -0
  128. package/dist/interactionStateLayer/interactionStateLayer.d.ts +23 -0
  129. package/dist/interactionStateLayer/interactionStateLayer.js +67 -0
  130. package/dist/layout/flex.d.ts +1 -0
  131. package/dist/layout/grid.d.ts +1 -0
  132. package/dist/layout/index.d.ts +1 -1
  133. package/dist/layout/index.js +1 -1
  134. package/dist/layout/stack.d.ts +1 -0
  135. package/dist/layout/styles.d.ts +1 -1
  136. package/dist/layout/surface.d.ts +1 -0
  137. package/dist/link/index.d.ts +2 -0
  138. package/dist/link/index.js +2 -0
  139. package/dist/link/link.d.ts +43 -0
  140. package/dist/link/link.js +71 -0
  141. package/dist/link/linkBehaviorContext.d.ts +14 -0
  142. package/dist/link/linkBehaviorContext.js +31 -0
  143. package/dist/loader/indeterminateLoader.d.ts +1 -0
  144. package/dist/overlay.d.ts +59 -0
  145. package/dist/overlay.js +113 -0
  146. package/dist/overlayArrow.d.ts +9 -0
  147. package/dist/overlayArrow.js +55 -0
  148. package/dist/overlayPositioning.d.ts +70 -0
  149. package/dist/overlayPositioning.js +139 -0
  150. package/dist/panelProvider.d.ts +8 -0
  151. package/dist/panelProvider.js +20 -0
  152. package/dist/quote/quote.js +1 -1
  153. package/dist/radio/index.d.ts +1 -0
  154. package/dist/radio/index.js +1 -0
  155. package/dist/radio/radio.d.ts +9 -0
  156. package/dist/radio/radio.js +77 -0
  157. package/dist/renderToString.d.ts +2 -0
  158. package/dist/renderToString.js +25 -0
  159. package/dist/revealOnHover/index.d.ts +1 -0
  160. package/dist/revealOnHover/index.js +1 -0
  161. package/dist/revealOnHover/revealOnHover.d.ts +20 -0
  162. package/dist/revealOnHover/revealOnHover.js +62 -0
  163. package/dist/segmentedControl/index.d.ts +1 -0
  164. package/dist/segmentedControl/index.js +1 -0
  165. package/dist/segmentedControl/segmentedControl.d.ts +41 -0
  166. package/dist/segmentedControl/segmentedControl.js +217 -0
  167. package/dist/separator/separator.d.ts +4 -3
  168. package/dist/separator/separator.js +1 -1
  169. package/dist/sizeContext.d.ts +9 -0
  170. package/dist/sizeContext.js +13 -0
  171. package/dist/slider/index.d.ts +1 -0
  172. package/dist/slider/index.js +1 -0
  173. package/dist/slider/slider.d.ts +41 -0
  174. package/dist/slider/slider.js +386 -0
  175. package/dist/slot/index.d.ts +1 -0
  176. package/dist/slot/index.js +1 -0
  177. package/dist/slot/knownContexts.d.ts +1 -0
  178. package/dist/slot/knownContexts.js +7 -0
  179. package/dist/slot/slot.d.ts +26 -0
  180. package/dist/slot/slot.js +274 -0
  181. package/dist/statusIndicator/index.d.ts +1 -0
  182. package/dist/statusIndicator/index.js +1 -0
  183. package/dist/statusIndicator/statusIndicator.d.ts +24 -0
  184. package/dist/statusIndicator/statusIndicator.js +130 -0
  185. package/dist/switch/index.d.ts +1 -0
  186. package/dist/switch/index.js +1 -0
  187. package/dist/switch/switch.d.ts +6 -0
  188. package/dist/switch/switch.js +172 -0
  189. package/dist/table/index.d.ts +3 -0
  190. package/dist/table/index.js +3 -0
  191. package/dist/table/sortableHeaderCell.d.ts +36 -0
  192. package/dist/table/sortableHeaderCell.js +99 -0
  193. package/dist/table/styles.d.ts +46 -0
  194. package/dist/table/styles.js +93 -0
  195. package/dist/table/table.d.ts +64 -0
  196. package/dist/table/table.js +228 -0
  197. package/dist/table/useColumnResize.d.ts +27 -0
  198. package/dist/table/useColumnResize.js +62 -0
  199. package/dist/table/useObservedColumnSize.d.ts +12 -0
  200. package/dist/table/useObservedColumnSize.js +74 -0
  201. package/dist/text/heading.d.ts +2 -1
  202. package/dist/text/index.d.ts +1 -0
  203. package/dist/text/index.js +1 -0
  204. package/dist/text/prose.d.ts +8 -0
  205. package/dist/text/prose.js +45 -0
  206. package/dist/text/text.d.ts +8 -0
  207. package/dist/text/text.js +1 -1
  208. package/dist/textarea/index.d.ts +1 -0
  209. package/dist/textarea/index.js +1 -0
  210. package/dist/textarea/textarea.d.ts +22 -0
  211. package/dist/textarea/textarea.js +77 -0
  212. package/dist/theme/dark.d.ts +129 -10
  213. package/dist/theme/dark.js +41 -13
  214. package/dist/theme/index.d.ts +3 -12
  215. package/dist/theme/index.js +2 -2
  216. package/dist/theme/light.d.ts +129 -10
  217. package/dist/theme/light.js +42 -14
  218. package/dist/theme/swatch.d.ts +27 -0
  219. package/dist/theme/swatch.js +37 -0
  220. package/dist/theme/theme.d.ts +648 -0
  221. package/dist/theme/theme.js +780 -0
  222. package/dist/theme/types.d.ts +1 -0
  223. package/dist/theme/useInvertedTheme.d.ts +1 -0
  224. package/dist/theme/useInvertedTheme.js +7 -0
  225. package/dist/tooltip/index.d.ts +2 -0
  226. package/dist/tooltip/index.js +2 -0
  227. package/dist/tooltip/tooltip.d.ts +166 -0
  228. package/dist/tooltip/tooltip.js +181 -0
  229. package/dist/tooltip/useDisabledTooltip.d.ts +22 -0
  230. package/dist/tooltip/useDisabledTooltip.js +24 -0
  231. package/dist/trackingContext.d.ts +34 -0
  232. package/dist/trackingContext.js +29 -0
  233. package/dist/translation/index.d.ts +4 -0
  234. package/dist/translation/index.js +4 -0
  235. package/dist/translation/translationContext.d.ts +6 -0
  236. package/dist/translation/translationContext.js +6 -0
  237. package/dist/translation/useTranslation.d.ts +1 -0
  238. package/dist/translation/useTranslation.js +6 -0
  239. package/dist/unreachable.d.ts +1 -0
  240. package/dist/unreachable.js +4 -0
  241. package/dist/useHoverOverlay.d.ts +113 -0
  242. package/dist/useHoverOverlay.js +370 -0
  243. package/dist/useIsInsideInteractiveElement.d.ts +6 -0
  244. package/dist/useIsInsideInteractiveElement.js +31 -0
  245. package/dist/useOverlay.d.ts +82 -0
  246. package/dist/useOverlay.js +217 -0
  247. package/dist/useScrollLock.d.ts +5 -0
  248. package/dist/useScrollLock.js +100 -0
  249. package/dist/useStableMergeRef.d.ts +9 -0
  250. package/dist/useStableMergeRef.js +18 -0
  251. package/package.json +219 -11
  252. package/dist/index.d.ts +0 -9
  253. package/dist/index.js +0 -9
@@ -0,0 +1,86 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { IconBroadcast } from "@sentry/icons/broadcast";
4
+ import { IconBug } from "@sentry/icons/bug";
5
+ import { IconLab } from "@sentry/icons/lab";
6
+ import { Tooltip } from "../tooltip/index.js";
7
+ import { useTranslation } from "../translation/useTranslation.js";
8
+ import { useIsInsideInteractiveElement } from "../useIsInsideInteractiveElement.js";
9
+ import { Tag } from "./tag.js";
10
+ function useDefaultTitle(type) {
11
+ const { t } = useTranslation();
12
+ switch(type){
13
+ case 'alpha':
14
+ return t('This feature is internal and available for QA purposes');
15
+ case 'beta':
16
+ return t('This feature is in beta and may change');
17
+ case 'new':
18
+ return t('This feature is new! Try it out and let us know what you think');
19
+ case 'experimental':
20
+ return t('This feature is experimental! Try it out and let us know what you think. No promises!');
21
+ case 'debug':
22
+ return t('This UI is for debugging purposes only');
23
+ }
24
+ }
25
+ const variantMap = {
26
+ alpha: 'promotion',
27
+ beta: 'warning',
28
+ new: 'success',
29
+ experimental: 'muted',
30
+ debug: 'danger'
31
+ };
32
+ const iconMap = {
33
+ alpha: /*#__PURE__*/ jsx(IconLab, {
34
+ isSolid: true,
35
+ size: "xs",
36
+ "aria-hidden": true
37
+ }),
38
+ beta: /*#__PURE__*/ jsx(IconLab, {
39
+ isSolid: true,
40
+ size: "xs",
41
+ "aria-hidden": true
42
+ }),
43
+ new: /*#__PURE__*/ jsx(IconBroadcast, {
44
+ size: "xs",
45
+ "aria-hidden": true
46
+ }),
47
+ experimental: /*#__PURE__*/ jsx(IconLab, {
48
+ isSolid: true,
49
+ size: "xs",
50
+ "aria-hidden": true
51
+ }),
52
+ debug: /*#__PURE__*/ jsx(IconBug, {
53
+ size: "xs",
54
+ "aria-hidden": true
55
+ })
56
+ };
57
+ function FeatureBadge({ type, tooltipProps }) {
58
+ const defaultTitle = useDefaultTitle(type);
59
+ const title = tooltipProps?.title ?? defaultTitle;
60
+ const { ref, isInsideInteractiveElement, isInteractiveElementFocusVisible } = useIsInsideInteractiveElement(void 0);
61
+ return /*#__PURE__*/ jsx(Tooltip, {
62
+ title: title,
63
+ position: "right",
64
+ ...tooltipProps,
65
+ skipWrapper: true,
66
+ forceVisible: isInteractiveElementFocusVisible ? 'delayed' : tooltipProps?.forceVisible,
67
+ children: /*#__PURE__*/ jsx(SquareTag, {
68
+ tabIndex: isInsideInteractiveElement ? void 0 : 0,
69
+ variant: variantMap[type],
70
+ "aria-label": type,
71
+ ref: ref,
72
+ children: iconMap[type]
73
+ })
74
+ });
75
+ }
76
+ const SquareTag = styled(Tag)`
77
+ width: 20px;
78
+ flex-shrink: 0;
79
+ padding: 0;
80
+ justify-content: center;
81
+
82
+ &:focus-visible {
83
+ ${(p)=>p.theme.focusRing()}
84
+ }
85
+ `;
86
+ export { FeatureBadge };
@@ -0,0 +1,3 @@
1
+ export { Badge, type BadgeProps } from './badge.js';
2
+ export { FeatureBadge, type FeatureBadgeProps } from './featureBadge.js';
3
+ export { Tag, type TagProps } from './tag.js';
@@ -0,0 +1,3 @@
1
+ export { Badge } from "./badge.js";
2
+ export { FeatureBadge } from "./featureBadge.js";
3
+ export { Tag } from "./tag.js";
@@ -0,0 +1,15 @@
1
+ import type * as React from 'react';
2
+ import type { TagVariant } from '../theme/index.js';
3
+ export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> {
4
+ variant: TagVariant;
5
+ /**
6
+ * Icon on the left side.
7
+ */
8
+ icon?: React.ReactNode;
9
+ /**
10
+ * Shows clickable IconClose on the right side.
11
+ */
12
+ onDismiss?: () => void;
13
+ ref?: React.Ref<HTMLDivElement>;
14
+ }
15
+ export declare function Tag({ ref, variant, icon, onDismiss, children, ...props }: TagProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,119 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { IconClose } from "@sentry/icons/close";
4
+ import { IconDefaultsProvider } from "@sentry/icons/useIconDefaults";
5
+ import { Button } from "../button/index.js";
6
+ import { useTranslation } from "../translation/useTranslation.js";
7
+ import { unreachable } from "../unreachable.js";
8
+ function Tag({ ref, variant, icon, onDismiss, children, ...props }) {
9
+ const { t } = useTranslation();
10
+ return /*#__PURE__*/ jsxs(TagPill, {
11
+ variant: variant,
12
+ "data-test-id": "tag-background",
13
+ ref: ref,
14
+ ...props,
15
+ children: [
16
+ icon && /*#__PURE__*/ jsx(IconWrapper, {
17
+ children: /*#__PURE__*/ jsx(IconDefaultsProvider, {
18
+ size: "xs",
19
+ children: icon
20
+ })
21
+ }),
22
+ children && /*#__PURE__*/ jsx(TagText, {
23
+ children: children
24
+ }),
25
+ onDismiss && /*#__PURE__*/ jsx(DismissButton, {
26
+ onClick: (event)=>{
27
+ event.preventDefault();
28
+ onDismiss?.();
29
+ },
30
+ size: "zero",
31
+ variant: "link",
32
+ "aria-label": t('Dismiss'),
33
+ icon: /*#__PURE__*/ jsx(IconClose, {
34
+ size: "xs"
35
+ })
36
+ })
37
+ ]
38
+ });
39
+ }
40
+ const TagPill = styled('div')`
41
+ ${(p)=>({
42
+ ...makeTagPillTheme(p.variant, p.theme)
43
+ })};
44
+
45
+ height: 20px;
46
+ font-size: ${(p)=>p.theme.font.size.sm};
47
+ display: inline-flex;
48
+ gap: ${(p)=>p.theme.space.xs};
49
+ align-items: center;
50
+ border-radius: ${(p)=>p.theme.radius.xs};
51
+ padding: 0 ${(p)=>p.theme.space.md};
52
+ max-width: 100%;
53
+
54
+ /* @TODO(jonasbadalic): We need to override button colors because they wrongly default to a blue color... */
55
+ button,
56
+ button:hover {
57
+ color: currentColor;
58
+ }
59
+ `;
60
+ function makeTagPillTheme(type, theme) {
61
+ switch(type){
62
+ case void 0:
63
+ case 'muted':
64
+ return {
65
+ color: theme.tokens.content.secondary,
66
+ background: theme.colors.gray100
67
+ };
68
+ case 'info':
69
+ return {
70
+ color: theme.tokens.content.accent,
71
+ background: theme.tokens.background.transparent.accent.muted
72
+ };
73
+ case 'promotion':
74
+ return {
75
+ color: theme.tokens.content.promotion,
76
+ background: theme.tokens.background.transparent.promotion.muted
77
+ };
78
+ case 'danger':
79
+ return {
80
+ color: theme.tokens.content.danger,
81
+ background: theme.tokens.background.transparent.danger.muted
82
+ };
83
+ case 'warning':
84
+ return {
85
+ color: theme.tokens.content.warning,
86
+ background: theme.colors.yellow100
87
+ };
88
+ case 'success':
89
+ return {
90
+ color: theme.tokens.content.success,
91
+ background: theme.tokens.background.transparent.success.muted
92
+ };
93
+ default:
94
+ unreachable(type);
95
+ throw new TypeError(`Unsupported badge type: ${type}`);
96
+ }
97
+ }
98
+ const TagText = styled('div')`
99
+ overflow: hidden;
100
+ white-space: nowrap;
101
+ text-overflow: ellipsis;
102
+ min-width: 0;
103
+
104
+ &:has(> *) {
105
+ display: flex;
106
+ align-items: center;
107
+ gap: ${(p)=>p.theme.space.xs};
108
+ }
109
+ `;
110
+ const IconWrapper = styled('span')`
111
+ display: inline-flex;
112
+ align-items: center;
113
+ gap: inherit;
114
+ `;
115
+ const DismissButton = styled(Button)`
116
+ margin-right: -${(p)=>p.theme.space.xs};
117
+ border: none;
118
+ `;
119
+ export { Tag };
@@ -0,0 +1,2 @@
1
+ export declare const BoundaryContextProvider: import("react").Provider<string | null>;
2
+ export declare const useBoundaryContext: () => string | null;
@@ -0,0 +1,5 @@
1
+ import { createContext, useContext } from "react";
2
+ const BoundaryContext = /*#__PURE__*/ createContext(null);
3
+ const BoundaryContextProvider = BoundaryContext.Provider;
4
+ const useBoundaryContext = ()=>useContext(BoundaryContext);
5
+ export { BoundaryContextProvider, useBoundaryContext };
@@ -0,0 +1,3 @@
1
+ import type { DO_NOT_USE_ButtonProps as ButtonProps } from './types.js';
2
+ export type { ButtonProps };
3
+ export declare function Button({ disabled, type, tooltipProps, onKeyDown, 'aria-disabled': ariaDisabled, busy, size: explicitSize, ...props }: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,83 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { IconDefaultsProvider } from "@sentry/icons/useIconDefaults";
4
+ import { Flex, useResponsivePropValue } from "../layout/index.js";
5
+ import { IndeterminateLoader } from "../loader/index.js";
6
+ import { useSizeContext } from "../sizeContext.js";
7
+ import { Tooltip, useDisabledTooltip } from "../tooltip/index.js";
8
+ import { useClickTracking } from "../trackingContext.js";
9
+ import { DO_NOT_USE_BUTTON_ICON_SIZES, DO_NOT_USE_getButtonStyles } from "./styles.js";
10
+ import { useButtonFunctionality } from "./useButtonFunctionality.js";
11
+ function Button({ disabled, type = 'button', tooltipProps, onKeyDown, 'aria-disabled': ariaDisabled, busy, size: explicitSize, ...props }) {
12
+ const contextSize = useSizeContext();
13
+ const size = useResponsivePropValue(explicitSize ?? contextSize ?? 'md');
14
+ const buttonProps = {
15
+ ...props,
16
+ type,
17
+ disabled,
18
+ busy
19
+ };
20
+ const { hasChildren, accessibleLabel } = useButtonFunctionality(buttonProps);
21
+ const { handleClick } = useClickTracking(buttonProps, 'button');
22
+ const { disabledProps } = useDisabledTooltip({
23
+ disabled,
24
+ tooltipProps,
25
+ onKeyDown,
26
+ 'aria-disabled': disabled ?? ariaDisabled
27
+ });
28
+ return /*#__PURE__*/ jsx(Tooltip, {
29
+ skipWrapper: true,
30
+ ...tooltipProps,
31
+ title: tooltipProps?.title,
32
+ children: /*#__PURE__*/ jsx(StyledButton, {
33
+ "aria-label": accessibleLabel,
34
+ "aria-busy": busy,
35
+ size: size,
36
+ type: type,
37
+ busy: busy,
38
+ ...props,
39
+ ...disabledProps,
40
+ shapeVariant: hasChildren ? 'rectangular' : 'square',
41
+ onClick: handleClick,
42
+ role: "button",
43
+ children: /*#__PURE__*/ jsxs(Flex, {
44
+ as: "span",
45
+ align: "center",
46
+ justify: "center",
47
+ minWidth: "0",
48
+ height: "100%",
49
+ whiteSpace: "nowrap",
50
+ visibility: busy ? 'hidden' : void 0,
51
+ children: [
52
+ props.icon && /*#__PURE__*/ jsx(Flex, {
53
+ as: "span",
54
+ align: "center",
55
+ flexShrink: 0,
56
+ marginRight: hasChildren ? 'xs' === size || 'zero' === size ? 'sm' : 'md' : void 0,
57
+ "aria-hidden": "true",
58
+ children: /*#__PURE__*/ jsx(IconDefaultsProvider, {
59
+ size: DO_NOT_USE_BUTTON_ICON_SIZES[size],
60
+ children: props.icon
61
+ })
62
+ }),
63
+ props.children,
64
+ busy && /*#__PURE__*/ jsx(Flex, {
65
+ align: "center",
66
+ justify: "center",
67
+ position: "absolute",
68
+ visibility: "visible",
69
+ inset: 0,
70
+ children: /*#__PURE__*/ jsx(IndeterminateLoader, {
71
+ variant: "monochrome",
72
+ "aria-hidden": true
73
+ })
74
+ })
75
+ ]
76
+ })
77
+ })
78
+ });
79
+ }
80
+ const StyledButton = styled('button')`
81
+ ${(p)=>DO_NOT_USE_getButtonStyles(p)}
82
+ `;
83
+ export { Button };
@@ -0,0 +1,10 @@
1
+ import type * as React from 'react';
2
+ import { type GridProps } from '../layout/index.js';
3
+ export interface ButtonBarProps extends Omit<GridProps, 'gap'> {
4
+ children: NonNullable<React.ReactNode>;
5
+ orientation?: 'horizontal' | 'vertical';
6
+ size?: 'xs' | 'sm' | 'md';
7
+ }
8
+ export declare const ButtonBar: import("@emotion/styled").StyledComponent<ButtonBarProps & {
9
+ theme?: import("@emotion/react").Theme;
10
+ }, {}, {}>;
@@ -0,0 +1,141 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { css } from "@emotion/react";
3
+ import styled from "@emotion/styled";
4
+ import { Grid } from "../layout/index.js";
5
+ import { SizeProvider } from "../sizeContext.js";
6
+ const ButtonBar = styled(({ children, orientation = 'horizontal', size, ...props })=>{
7
+ const content = /*#__PURE__*/ jsx(Grid, {
8
+ flow: 'horizontal' === orientation ? 'column' : 'row',
9
+ align: "center",
10
+ gap: "0",
11
+ ...props,
12
+ children: children
13
+ });
14
+ if (size) return /*#__PURE__*/ jsx(SizeProvider, {
15
+ size: size,
16
+ children: content
17
+ });
18
+ return content;
19
+ })`
20
+ /* Raised buttons show borders on both sides. Useful to create pill bars */
21
+ & > .active {
22
+ z-index: 2;
23
+ }
24
+
25
+ & > [role='presentation'],
26
+ & > .dropdown,
27
+ & > button,
28
+ & > input,
29
+ & > a {
30
+ /* Dropdown menu wrappers use display: contents, so they never form a
31
+ containing block. Positioning them anyway makes Floating UI clamp the
32
+ menu's max-height to clipping ancestors it can actually escape, such as
33
+ table header cells. */
34
+ &:not([role='presentation']) {
35
+ position: relative;
36
+ }
37
+
38
+ ${(p)=>'vertical' === p.orientation ? css`
39
+ /* First button is square on the bottom side */
40
+ &:first-child:not(:last-child) {
41
+ border-bottom-left-radius: 0;
42
+ border-bottom-right-radius: 0;
43
+
44
+ & > .dropdown-actor > button,
45
+ & > .dropdown-actor > a {
46
+ border-bottom-left-radius: 0;
47
+ border-bottom-right-radius: 0;
48
+ }
49
+ }
50
+
51
+ /* Middle buttons are square */
52
+ &:not(:last-child):not(:first-child),
53
+ &:not(:last-child):not(:first-child)[role='presentation'] > button,
54
+ &:not(:last-child):not(:first-child)[role='presentation'] > a {
55
+ border-radius: 0;
56
+
57
+ & > .dropdown-actor > button,
58
+ & > .dropdown-actor > a {
59
+ border-radius: 0;
60
+ }
61
+ }
62
+
63
+ /* Middle buttons only need one border so we don't get a double line */
64
+ & + [role='presentation'] > button,
65
+ & + [role='presentation'] > a,
66
+ & + .dropdown:not(:last-child),
67
+ & + a:not(:last-child),
68
+ & + input:not(:last-child),
69
+ & + button:not(:last-child) {
70
+ margin-top: -1px;
71
+ }
72
+
73
+ /* Last button is square on the top side */
74
+ &:last-child:not(:first-child) {
75
+ border-top-left-radius: 0;
76
+ border-top-right-radius: 0;
77
+ margin-top: -1px;
78
+
79
+ &[role='presentation'] > button,
80
+ &[role='presentation'] > a,
81
+ & > .dropdown-actor > button,
82
+ & > .dropdown-actor > a {
83
+ border-top-left-radius: 0;
84
+ border-top-right-radius: 0;
85
+ margin-top: -1px;
86
+ }
87
+ }
88
+ ` : css`
89
+ /* First button is square on the right side */
90
+ &:first-child:not(:last-child) {
91
+ border-top-right-radius: 0;
92
+ border-bottom-right-radius: 0;
93
+
94
+ & > .dropdown-actor > button,
95
+ & > .dropdown-actor > a {
96
+ border-top-right-radius: 0;
97
+ border-bottom-right-radius: 0;
98
+ }
99
+ }
100
+
101
+ /* Middle buttons are square */
102
+ &:not(:last-child):not(:first-child),
103
+ &:not(:last-child):not(:first-child)[role='presentation'] > button,
104
+ &:not(:last-child):not(:first-child)[role='presentation'] > a {
105
+ border-radius: 0;
106
+
107
+ & > .dropdown-actor > button,
108
+ & > .dropdown-actor > a {
109
+ border-radius: 0;
110
+ }
111
+ }
112
+
113
+ /* Middle buttons only need one border so we don't get a double line */
114
+ & + [role='presentation'] > button,
115
+ & + [role='presentation'] > a,
116
+ & + .dropdown:not(:last-child),
117
+ & + a:not(:last-child),
118
+ & + input:not(:last-child),
119
+ & + button:not(:last-child) {
120
+ margin-left: -1px;
121
+ }
122
+
123
+ /* Last button is square on the left side */
124
+ &:last-child:not(:first-child) {
125
+ border-top-left-radius: 0;
126
+ border-bottom-left-radius: 0;
127
+ margin-left: -1px;
128
+
129
+ &[role='presentation'] > button,
130
+ &[role='presentation'] > a,
131
+ & > .dropdown-actor > button,
132
+ & > .dropdown-actor > a {
133
+ border-top-left-radius: 0;
134
+ border-bottom-left-radius: 0;
135
+ margin-left: -1px;
136
+ }
137
+ }
138
+ `}
139
+ }
140
+ `;
141
+ export { ButtonBar };
@@ -0,0 +1,5 @@
1
+ export { Button, type ButtonProps } from './button.js';
2
+ export { ButtonBar, type ButtonBarProps } from './buttonBar.js';
3
+ export { LinkButton, type LinkButtonProps } from './linkButton.js';
4
+ export { DO_NOT_USE_getButtonStyles } from './styles.js';
5
+ export type { ButtonSize } from './types.js';
@@ -0,0 +1,4 @@
1
+ export { Button } from "./button.js";
2
+ export { ButtonBar } from "./buttonBar.js";
3
+ export { LinkButton } from "./linkButton.js";
4
+ export { DO_NOT_USE_getButtonStyles } from "./styles.js";
@@ -0,0 +1,3 @@
1
+ import type { DO_NOT_USE_LinkButtonProps as LinkButtonProps } from './types.js';
2
+ export type { LinkButtonProps };
3
+ export declare function LinkButton({ disabled, tooltipProps, size: explicitSize, ...props }: LinkButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,110 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import is_prop_valid from "@emotion/is-prop-valid";
3
+ import styled from "@emotion/styled";
4
+ import { IconDefaultsProvider } from "@sentry/icons/useIconDefaults";
5
+ import { Flex, useResponsivePropValue } from "../layout/index.js";
6
+ import { Link } from "../link/index.js";
7
+ import { useSizeContext } from "../sizeContext.js";
8
+ import { Tooltip } from "../tooltip/index.js";
9
+ import { useClickTracking } from "../trackingContext.js";
10
+ import { DO_NOT_USE_BUTTON_ICON_SIZES, DO_NOT_USE_getButtonStyles } from "./styles.js";
11
+ import { useButtonFunctionality } from "./useButtonFunctionality.js";
12
+ function LinkButton({ disabled, tooltipProps, size: explicitSize, ...props }) {
13
+ const contextSize = useSizeContext();
14
+ const size = useResponsivePropValue(explicitSize ?? contextSize ?? 'md');
15
+ const { hasChildren, accessibleLabel } = useButtonFunctionality({
16
+ ...props,
17
+ disabled
18
+ });
19
+ return /*#__PURE__*/ jsx(Tooltip, {
20
+ skipWrapper: true,
21
+ ...tooltipProps,
22
+ title: tooltipProps?.title,
23
+ disabled: !tooltipProps?.title,
24
+ children: /*#__PURE__*/ jsx(StyledLinkButton, {
25
+ "aria-label": accessibleLabel,
26
+ "aria-disabled": disabled,
27
+ disabled: disabled,
28
+ size: size,
29
+ ...props,
30
+ shapeVariant: hasChildren ? 'rectangular' : 'square',
31
+ href: disabled ? void 0 : 'href' in props ? props.href : void 0,
32
+ to: disabled ? void 0 : 'to' in props ? props.to : void 0,
33
+ children: /*#__PURE__*/ jsxs(Flex, {
34
+ as: "span",
35
+ align: "center",
36
+ justify: "center",
37
+ minWidth: "0",
38
+ height: "100%",
39
+ whiteSpace: "nowrap",
40
+ children: [
41
+ props.icon && /*#__PURE__*/ jsx(Flex, {
42
+ as: "span",
43
+ align: "center",
44
+ flexShrink: 0,
45
+ marginRight: hasChildren ? 'xs' === size || 'zero' === size ? 'sm' : 'md' : void 0,
46
+ children: /*#__PURE__*/ jsx(IconDefaultsProvider, {
47
+ size: DO_NOT_USE_BUTTON_ICON_SIZES[size],
48
+ children: props.icon
49
+ })
50
+ }),
51
+ props.children
52
+ ]
53
+ })
54
+ })
55
+ });
56
+ }
57
+ const StyledLinkButton = styled(({ size: _size, shapeVariant: _shapeVariant, ...props })=>{
58
+ const { handleClick } = useClickTracking(props, 'link');
59
+ if ('to' in props && props.to) {
60
+ const { openInNewTab, ...linkProps } = props;
61
+ return /*#__PURE__*/ jsx(Link, {
62
+ ...linkProps,
63
+ to: props.to,
64
+ role: "button",
65
+ ...openInNewTab ? {
66
+ target: '_blank',
67
+ rel: 'noreferrer noopener'
68
+ } : {}
69
+ });
70
+ }
71
+ if ('href' in props && props.href) {
72
+ const { external, analyticsEventKey: _analyticsEventKey, analyticsEventName: _analyticsEventName, analyticsParams: _analyticsParams, busy: _busy, variant: _variant, ...rest } = props;
73
+ return /*#__PURE__*/ jsx("a", {
74
+ ...rest,
75
+ onClick: handleClick,
76
+ ...external ? {
77
+ target: '_blank',
78
+ rel: 'noreferrer noopener'
79
+ } : {},
80
+ role: "button"
81
+ });
82
+ }
83
+ const { external: _e, replace: _r, preventScrollReset: _p, openInNewTab: _o, analyticsEventKey: _analyticsEventKey, analyticsEventName: _analyticsEventName, analyticsParams: _analyticsParams, busy: _busy, variant: _variant, ...rest } = props;
84
+ return /*#__PURE__*/ jsx("a", {
85
+ ...rest,
86
+ onClick: handleClick,
87
+ role: "button"
88
+ });
89
+ }, {
90
+ shouldForwardProp: (prop)=>'analyticsEventKey' === prop || 'analyticsEventName' === prop || 'analyticsParams' === prop || 'busy' === prop || 'external' === prop || 'replace' === prop || 'preventScrollReset' === prop || 'openInNewTab' === prop || 'variant' === prop || 'string' == typeof prop && is_prop_valid(prop)
91
+ })`
92
+ ${(p)=>getLinkButtonStyles(p, p.theme)}
93
+ `;
94
+ const getLinkButtonStyles = (p, theme)=>{
95
+ const buttonStyles = DO_NOT_USE_getButtonStyles({
96
+ ...p,
97
+ theme,
98
+ shapeVariant: p.shapeVariant
99
+ });
100
+ return {
101
+ ...p.disabled || p.busy ? {
102
+ color: buttonStyles.color,
103
+ ':hover': {
104
+ color: buttonStyles.color
105
+ }
106
+ } : void 0,
107
+ ...buttonStyles
108
+ };
109
+ };
110
+ export { LinkButton };
@@ -0,0 +1,10 @@
1
+ import { type SVGIconProps } from '@sentry/icons/svgIcon';
2
+ import type { ButtonProps } from './index.js';
3
+ import type { StrictCSSObject, Theme } from '../theme/index.js';
4
+ import { type ButtonSize, type DO_NOT_USE_CommonButtonProps as CommonButtonProps } from './types.js';
5
+ export declare const DO_NOT_USE_BUTTON_ICON_SIZES: Record<ButtonSize, SVGIconProps['size']>;
6
+ export declare function DO_NOT_USE_getButtonStyles(p: Pick<CommonButtonProps, 'variant' | 'busy'> & Pick<ButtonProps, 'disabled' | 'aria-disabled'> & {
7
+ shapeVariant: 'rectangular' | 'square';
8
+ size: ButtonSize;
9
+ theme: Theme;
10
+ }): StrictCSSObject;