@sentry/scraps 0.1.0 → 0.2.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 (188) 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 +135 -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/emptyState/emptyState.d.ts +10 -0
  56. package/dist/emptyState/emptyState.js +81 -0
  57. package/dist/emptyState/index.d.ts +1 -0
  58. package/dist/emptyState/index.js +1 -0
  59. package/dist/hotkey/hotkey.d.ts +22 -0
  60. package/dist/hotkey/hotkey.js +41 -0
  61. package/dist/hotkey/index.d.ts +4 -0
  62. package/dist/hotkey/index.js +3 -0
  63. package/dist/hotkey/kbd.d.ts +1 -0
  64. package/dist/hotkey/keyMappings.d.ts +23 -0
  65. package/dist/hotkey/keyMappings.js +223 -0
  66. package/dist/hotkey/useHotkeys.d.ts +47 -0
  67. package/dist/hotkey/useHotkeys.js +44 -0
  68. package/dist/image/image.d.ts +21 -0
  69. package/dist/image/image.js +20 -0
  70. package/dist/image/index.d.ts +1 -0
  71. package/dist/image/index.js +1 -0
  72. package/dist/info/index.d.ts +2 -0
  73. package/dist/info/index.js +2 -0
  74. package/dist/info/infoText.d.ts +15 -0
  75. package/dist/info/infoText.js +43 -0
  76. package/dist/info/infoTip.d.ts +10 -0
  77. package/dist/info/infoTip.js +54 -0
  78. package/dist/interactionStateLayer/index.d.ts +1 -0
  79. package/dist/interactionStateLayer/index.js +1 -0
  80. package/dist/interactionStateLayer/interactionStateLayer.d.ts +23 -0
  81. package/dist/interactionStateLayer/interactionStateLayer.js +67 -0
  82. package/dist/layout/flex.d.ts +1 -0
  83. package/dist/layout/grid.d.ts +1 -0
  84. package/dist/layout/index.d.ts +1 -1
  85. package/dist/layout/index.js +1 -1
  86. package/dist/layout/stack.d.ts +1 -0
  87. package/dist/layout/styles.d.ts +1 -1
  88. package/dist/layout/surface.d.ts +1 -0
  89. package/dist/link/index.d.ts +2 -0
  90. package/dist/link/index.js +2 -0
  91. package/dist/link/link.d.ts +43 -0
  92. package/dist/link/link.js +71 -0
  93. package/dist/link/linkBehaviorContext.d.ts +14 -0
  94. package/dist/link/linkBehaviorContext.js +31 -0
  95. package/dist/loader/indeterminateLoader.d.ts +1 -0
  96. package/dist/overlay.d.ts +59 -0
  97. package/dist/overlay.js +113 -0
  98. package/dist/overlayArrow.d.ts +9 -0
  99. package/dist/overlayArrow.js +55 -0
  100. package/dist/overlayPositioning.d.ts +61 -0
  101. package/dist/overlayPositioning.js +126 -0
  102. package/dist/panelProvider.d.ts +8 -0
  103. package/dist/panelProvider.js +20 -0
  104. package/dist/quote/quote.js +1 -1
  105. package/dist/radio/index.d.ts +1 -0
  106. package/dist/radio/index.js +1 -0
  107. package/dist/radio/radio.d.ts +9 -0
  108. package/dist/radio/radio.js +77 -0
  109. package/dist/renderToString.d.ts +2 -0
  110. package/dist/renderToString.js +25 -0
  111. package/dist/revealOnHover/index.d.ts +1 -0
  112. package/dist/revealOnHover/index.js +1 -0
  113. package/dist/revealOnHover/revealOnHover.d.ts +20 -0
  114. package/dist/revealOnHover/revealOnHover.js +62 -0
  115. package/dist/segmentedControl/index.d.ts +1 -0
  116. package/dist/segmentedControl/index.js +1 -0
  117. package/dist/segmentedControl/segmentedControl.d.ts +41 -0
  118. package/dist/segmentedControl/segmentedControl.js +217 -0
  119. package/dist/separator/separator.d.ts +4 -3
  120. package/dist/separator/separator.js +1 -1
  121. package/dist/sizeContext.d.ts +9 -0
  122. package/dist/sizeContext.js +13 -0
  123. package/dist/slider/index.d.ts +1 -0
  124. package/dist/slider/index.js +1 -0
  125. package/dist/slider/slider.d.ts +41 -0
  126. package/dist/slider/slider.js +386 -0
  127. package/dist/slot/index.d.ts +1 -0
  128. package/dist/slot/index.js +1 -0
  129. package/dist/slot/knownContexts.d.ts +1 -0
  130. package/dist/slot/knownContexts.js +7 -0
  131. package/dist/slot/slot.d.ts +26 -0
  132. package/dist/slot/slot.js +274 -0
  133. package/dist/statusIndicator/index.d.ts +1 -0
  134. package/dist/statusIndicator/index.js +1 -0
  135. package/dist/statusIndicator/statusIndicator.d.ts +24 -0
  136. package/dist/statusIndicator/statusIndicator.js +130 -0
  137. package/dist/switch/index.d.ts +1 -0
  138. package/dist/switch/index.js +1 -0
  139. package/dist/switch/switch.d.ts +6 -0
  140. package/dist/switch/switch.js +172 -0
  141. package/dist/text/heading.d.ts +1 -0
  142. package/dist/text/index.d.ts +1 -0
  143. package/dist/text/index.js +1 -0
  144. package/dist/text/prose.d.ts +8 -0
  145. package/dist/text/prose.js +45 -0
  146. package/dist/text/text.d.ts +1 -0
  147. package/dist/theme/dark.d.ts +129 -10
  148. package/dist/theme/dark.js +41 -13
  149. package/dist/theme/index.d.ts +3 -12
  150. package/dist/theme/index.js +2 -2
  151. package/dist/theme/light.d.ts +129 -10
  152. package/dist/theme/light.js +42 -14
  153. package/dist/theme/swatch.d.ts +27 -0
  154. package/dist/theme/swatch.js +37 -0
  155. package/dist/theme/theme.d.ts +648 -0
  156. package/dist/theme/theme.js +780 -0
  157. package/dist/theme/types.d.ts +1 -0
  158. package/dist/theme/useInvertedTheme.d.ts +1 -0
  159. package/dist/theme/useInvertedTheme.js +7 -0
  160. package/dist/tooltip/index.d.ts +2 -0
  161. package/dist/tooltip/index.js +2 -0
  162. package/dist/tooltip/tooltip.d.ts +166 -0
  163. package/dist/tooltip/tooltip.js +181 -0
  164. package/dist/tooltip/useDisabledTooltip.d.ts +22 -0
  165. package/dist/tooltip/useDisabledTooltip.js +24 -0
  166. package/dist/trackingContext.d.ts +34 -0
  167. package/dist/trackingContext.js +29 -0
  168. package/dist/translation/index.d.ts +4 -0
  169. package/dist/translation/index.js +4 -0
  170. package/dist/translation/translationContext.d.ts +6 -0
  171. package/dist/translation/translationContext.js +6 -0
  172. package/dist/translation/useTranslation.d.ts +1 -0
  173. package/dist/translation/useTranslation.js +6 -0
  174. package/dist/unreachable.d.ts +1 -0
  175. package/dist/unreachable.js +4 -0
  176. package/dist/useHoverOverlay.d.ts +113 -0
  177. package/dist/useHoverOverlay.js +370 -0
  178. package/dist/useIsInsideInteractiveElement.d.ts +6 -0
  179. package/dist/useIsInsideInteractiveElement.js +31 -0
  180. package/dist/useOverlay.d.ts +82 -0
  181. package/dist/useOverlay.js +216 -0
  182. package/dist/useScrollLock.d.ts +5 -0
  183. package/dist/useScrollLock.js +100 -0
  184. package/dist/useStableMergeRef.d.ts +9 -0
  185. package/dist/useStableMergeRef.js +18 -0
  186. package/package.json +193 -11
  187. package/dist/index.d.ts +0 -9
  188. 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,135 @@
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
+ position: relative;
31
+
32
+ ${(p)=>'vertical' === p.orientation ? css`
33
+ /* First button is square on the bottom side */
34
+ &:first-child:not(:last-child) {
35
+ border-bottom-left-radius: 0;
36
+ border-bottom-right-radius: 0;
37
+
38
+ & > .dropdown-actor > button,
39
+ & > .dropdown-actor > a {
40
+ border-bottom-left-radius: 0;
41
+ border-bottom-right-radius: 0;
42
+ }
43
+ }
44
+
45
+ /* Middle buttons are square */
46
+ &:not(:last-child):not(:first-child),
47
+ &:not(:last-child):not(:first-child)[role='presentation'] > button,
48
+ &:not(:last-child):not(:first-child)[role='presentation'] > a {
49
+ border-radius: 0;
50
+
51
+ & > .dropdown-actor > button,
52
+ & > .dropdown-actor > a {
53
+ border-radius: 0;
54
+ }
55
+ }
56
+
57
+ /* Middle buttons only need one border so we don't get a double line */
58
+ & + [role='presentation'] > button,
59
+ & + [role='presentation'] > a,
60
+ & + .dropdown:not(:last-child),
61
+ & + a:not(:last-child),
62
+ & + input:not(:last-child),
63
+ & + button:not(:last-child) {
64
+ margin-top: -1px;
65
+ }
66
+
67
+ /* Last button is square on the top side */
68
+ &:last-child:not(:first-child) {
69
+ border-top-left-radius: 0;
70
+ border-top-right-radius: 0;
71
+ margin-top: -1px;
72
+
73
+ &[role='presentation'] > button,
74
+ &[role='presentation'] > a,
75
+ & > .dropdown-actor > button,
76
+ & > .dropdown-actor > a {
77
+ border-top-left-radius: 0;
78
+ border-top-right-radius: 0;
79
+ margin-top: -1px;
80
+ }
81
+ }
82
+ ` : css`
83
+ /* First button is square on the right side */
84
+ &:first-child:not(:last-child) {
85
+ border-top-right-radius: 0;
86
+ border-bottom-right-radius: 0;
87
+
88
+ & > .dropdown-actor > button,
89
+ & > .dropdown-actor > a {
90
+ border-top-right-radius: 0;
91
+ border-bottom-right-radius: 0;
92
+ }
93
+ }
94
+
95
+ /* Middle buttons are square */
96
+ &:not(:last-child):not(:first-child),
97
+ &:not(:last-child):not(:first-child)[role='presentation'] > button,
98
+ &:not(:last-child):not(:first-child)[role='presentation'] > a {
99
+ border-radius: 0;
100
+
101
+ & > .dropdown-actor > button,
102
+ & > .dropdown-actor > a {
103
+ border-radius: 0;
104
+ }
105
+ }
106
+
107
+ /* Middle buttons only need one border so we don't get a double line */
108
+ & + [role='presentation'] > button,
109
+ & + [role='presentation'] > a,
110
+ & + .dropdown:not(:last-child),
111
+ & + a:not(:last-child),
112
+ & + input:not(:last-child),
113
+ & + button:not(:last-child) {
114
+ margin-left: -1px;
115
+ }
116
+
117
+ /* Last button is square on the left side */
118
+ &:last-child:not(:first-child) {
119
+ border-top-left-radius: 0;
120
+ border-bottom-left-radius: 0;
121
+ margin-left: -1px;
122
+
123
+ &[role='presentation'] > button,
124
+ &[role='presentation'] > a,
125
+ & > .dropdown-actor > button,
126
+ & > .dropdown-actor > a {
127
+ border-top-left-radius: 0;
128
+ border-bottom-left-radius: 0;
129
+ margin-left: -1px;
130
+ }
131
+ }
132
+ `}
133
+ }
134
+ `;
135
+ 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;