@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.
- package/README.md +13 -21
- package/dist/alert/alert.d.ts +25 -0
- package/dist/alert/alert.js +262 -0
- package/dist/alert/alertLink.d.ts +32 -0
- package/dist/alert/alertLink.js +94 -0
- package/dist/alert/index.d.ts +2 -0
- package/dist/alert/index.js +2 -0
- package/dist/backdrop/backdrop.d.ts +9 -0
- package/dist/backdrop/backdrop.js +28 -0
- package/dist/backdrop/index.d.ts +1 -0
- package/dist/backdrop/index.js +1 -0
- package/dist/badge/badge.d.ts +12 -0
- package/dist/badge/badge.js +80 -0
- package/dist/badge/featureBadge.d.ts +6 -0
- package/dist/badge/featureBadge.js +86 -0
- package/dist/badge/index.d.ts +3 -0
- package/dist/badge/index.js +3 -0
- package/dist/badge/tag.d.ts +15 -0
- package/dist/badge/tag.js +119 -0
- package/dist/boundaryContext.d.ts +2 -0
- package/dist/boundaryContext.js +5 -0
- package/dist/button/button.d.ts +3 -0
- package/dist/button/button.js +83 -0
- package/dist/button/buttonBar.d.ts +10 -0
- package/dist/button/buttonBar.js +135 -0
- package/dist/button/index.d.ts +5 -0
- package/dist/button/index.js +4 -0
- package/dist/button/linkButton.d.ts +3 -0
- package/dist/button/linkButton.js +110 -0
- package/dist/button/styles.d.ts +10 -0
- package/dist/button/styles.js +247 -0
- package/dist/button/types.d.ts +77 -0
- package/dist/button/types.js +0 -0
- package/dist/button/useButtonFunctionality.d.ts +5 -0
- package/dist/button/useButtonFunctionality.js +9 -0
- package/dist/checkbox/checkbox.d.ts +20 -0
- package/dist/checkbox/checkbox.js +193 -0
- package/dist/checkbox/index.d.ts +1 -0
- package/dist/checkbox/index.js +1 -0
- package/dist/chip/chip.d.ts +128 -0
- package/dist/chip/chip.js +364 -0
- package/dist/chip/index.d.ts +1 -0
- package/dist/chip/index.js +1 -0
- package/dist/code/inlineCode.d.ts +1 -0
- package/dist/datetime.d.ts +39 -0
- package/dist/datetime.js +20 -0
- package/dist/descriptionList/descriptionList.d.ts +69 -0
- package/dist/descriptionList/descriptionList.js +76 -0
- package/dist/descriptionList/index.d.ts +1 -0
- package/dist/descriptionList/index.js +1 -0
- package/dist/disclosure/disclosure.d.ts +37 -0
- package/dist/disclosure/disclosure.js +155 -0
- package/dist/disclosure/index.d.ts +1 -0
- package/dist/disclosure/index.js +1 -0
- package/dist/emptyState/emptyState.d.ts +10 -0
- package/dist/emptyState/emptyState.js +81 -0
- package/dist/emptyState/index.d.ts +1 -0
- package/dist/emptyState/index.js +1 -0
- package/dist/hotkey/hotkey.d.ts +22 -0
- package/dist/hotkey/hotkey.js +41 -0
- package/dist/hotkey/index.d.ts +4 -0
- package/dist/hotkey/index.js +3 -0
- package/dist/hotkey/kbd.d.ts +1 -0
- package/dist/hotkey/keyMappings.d.ts +23 -0
- package/dist/hotkey/keyMappings.js +223 -0
- package/dist/hotkey/useHotkeys.d.ts +47 -0
- package/dist/hotkey/useHotkeys.js +44 -0
- package/dist/image/image.d.ts +21 -0
- package/dist/image/image.js +20 -0
- package/dist/image/index.d.ts +1 -0
- package/dist/image/index.js +1 -0
- package/dist/info/index.d.ts +2 -0
- package/dist/info/index.js +2 -0
- package/dist/info/infoText.d.ts +15 -0
- package/dist/info/infoText.js +43 -0
- package/dist/info/infoTip.d.ts +10 -0
- package/dist/info/infoTip.js +54 -0
- package/dist/interactionStateLayer/index.d.ts +1 -0
- package/dist/interactionStateLayer/index.js +1 -0
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +23 -0
- package/dist/interactionStateLayer/interactionStateLayer.js +67 -0
- package/dist/layout/flex.d.ts +1 -0
- package/dist/layout/grid.d.ts +1 -0
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/stack.d.ts +1 -0
- package/dist/layout/styles.d.ts +1 -1
- package/dist/layout/surface.d.ts +1 -0
- package/dist/link/index.d.ts +2 -0
- package/dist/link/index.js +2 -0
- package/dist/link/link.d.ts +43 -0
- package/dist/link/link.js +71 -0
- package/dist/link/linkBehaviorContext.d.ts +14 -0
- package/dist/link/linkBehaviorContext.js +31 -0
- package/dist/loader/indeterminateLoader.d.ts +1 -0
- package/dist/overlay.d.ts +59 -0
- package/dist/overlay.js +113 -0
- package/dist/overlayArrow.d.ts +9 -0
- package/dist/overlayArrow.js +55 -0
- package/dist/overlayPositioning.d.ts +61 -0
- package/dist/overlayPositioning.js +126 -0
- package/dist/panelProvider.d.ts +8 -0
- package/dist/panelProvider.js +20 -0
- package/dist/quote/quote.js +1 -1
- package/dist/radio/index.d.ts +1 -0
- package/dist/radio/index.js +1 -0
- package/dist/radio/radio.d.ts +9 -0
- package/dist/radio/radio.js +77 -0
- package/dist/renderToString.d.ts +2 -0
- package/dist/renderToString.js +25 -0
- package/dist/revealOnHover/index.d.ts +1 -0
- package/dist/revealOnHover/index.js +1 -0
- package/dist/revealOnHover/revealOnHover.d.ts +20 -0
- package/dist/revealOnHover/revealOnHover.js +62 -0
- package/dist/segmentedControl/index.d.ts +1 -0
- package/dist/segmentedControl/index.js +1 -0
- package/dist/segmentedControl/segmentedControl.d.ts +41 -0
- package/dist/segmentedControl/segmentedControl.js +217 -0
- package/dist/separator/separator.d.ts +4 -3
- package/dist/separator/separator.js +1 -1
- package/dist/sizeContext.d.ts +9 -0
- package/dist/sizeContext.js +13 -0
- package/dist/slider/index.d.ts +1 -0
- package/dist/slider/index.js +1 -0
- package/dist/slider/slider.d.ts +41 -0
- package/dist/slider/slider.js +386 -0
- package/dist/slot/index.d.ts +1 -0
- package/dist/slot/index.js +1 -0
- package/dist/slot/knownContexts.d.ts +1 -0
- package/dist/slot/knownContexts.js +7 -0
- package/dist/slot/slot.d.ts +26 -0
- package/dist/slot/slot.js +274 -0
- package/dist/statusIndicator/index.d.ts +1 -0
- package/dist/statusIndicator/index.js +1 -0
- package/dist/statusIndicator/statusIndicator.d.ts +24 -0
- package/dist/statusIndicator/statusIndicator.js +130 -0
- package/dist/switch/index.d.ts +1 -0
- package/dist/switch/index.js +1 -0
- package/dist/switch/switch.d.ts +6 -0
- package/dist/switch/switch.js +172 -0
- package/dist/text/heading.d.ts +1 -0
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.js +1 -0
- package/dist/text/prose.d.ts +8 -0
- package/dist/text/prose.js +45 -0
- package/dist/text/text.d.ts +1 -0
- package/dist/theme/dark.d.ts +129 -10
- package/dist/theme/dark.js +41 -13
- package/dist/theme/index.d.ts +3 -12
- package/dist/theme/index.js +2 -2
- package/dist/theme/light.d.ts +129 -10
- package/dist/theme/light.js +42 -14
- package/dist/theme/swatch.d.ts +27 -0
- package/dist/theme/swatch.js +37 -0
- package/dist/theme/theme.d.ts +648 -0
- package/dist/theme/theme.js +780 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/theme/useInvertedTheme.d.ts +1 -0
- package/dist/theme/useInvertedTheme.js +7 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/tooltip.d.ts +166 -0
- package/dist/tooltip/tooltip.js +181 -0
- package/dist/tooltip/useDisabledTooltip.d.ts +22 -0
- package/dist/tooltip/useDisabledTooltip.js +24 -0
- package/dist/trackingContext.d.ts +34 -0
- package/dist/trackingContext.js +29 -0
- package/dist/translation/index.d.ts +4 -0
- package/dist/translation/index.js +4 -0
- package/dist/translation/translationContext.d.ts +6 -0
- package/dist/translation/translationContext.js +6 -0
- package/dist/translation/useTranslation.d.ts +1 -0
- package/dist/translation/useTranslation.js +6 -0
- package/dist/unreachable.d.ts +1 -0
- package/dist/unreachable.js +4 -0
- package/dist/useHoverOverlay.d.ts +113 -0
- package/dist/useHoverOverlay.js +370 -0
- package/dist/useIsInsideInteractiveElement.d.ts +6 -0
- package/dist/useIsInsideInteractiveElement.js +31 -0
- package/dist/useOverlay.d.ts +82 -0
- package/dist/useOverlay.js +216 -0
- package/dist/useScrollLock.d.ts +5 -0
- package/dist/useScrollLock.js +100 -0
- package/dist/useStableMergeRef.d.ts +9 -0
- package/dist/useStableMergeRef.js +18 -0
- package/package.json +193 -11
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -9
package/README.md
CHANGED
|
@@ -17,6 +17,11 @@ pnpm --dir static/packages/scraps test
|
|
|
17
17
|
pnpm --dir static/packages/scraps typecheck
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
Typechecking checks source and tests together and emits declarations into the
|
|
21
|
+
ignored `.types` directory. The app uses these declarations through a TypeScript
|
|
22
|
+
project reference. Run `pnpm run typecheck` to check the full project in
|
|
23
|
+
dependency order. The release build continues to use `dist`.
|
|
24
|
+
|
|
20
25
|
To check package imports through the Sentry app's aliases, run the app integration test:
|
|
21
26
|
|
|
22
27
|
```sh
|
|
@@ -34,34 +39,21 @@ The `prepack` hook builds JavaScript and declarations with
|
|
|
34
39
|
package manifest, README, and license ship.
|
|
35
40
|
|
|
36
41
|
The `exports` field in [package.json](./package.json) defines the published API.
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
Import from its explicit subpaths, including `@sentry/scraps/code/inlineCode`
|
|
43
|
+
and `@sentry/scraps/hotkey/kbd`. The package has no root export; unlisted module
|
|
44
|
+
paths remain private.
|
|
39
45
|
Add an entry only when its runtime and type dependencies belong to the package
|
|
40
46
|
or are declared dependencies. App stories cover more components than this API;
|
|
41
47
|
for example, the hotkey story uses both `Hotkey` and `Kbd`, but only `Kbd` is
|
|
42
48
|
isolated. Published consumers have no fallback to app components.
|
|
43
49
|
|
|
44
|
-
## Verify the package
|
|
45
|
-
|
|
46
|
-
```sh
|
|
47
|
-
pnpm --dir static/packages/scraps verify
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Verification deletes `dist` before packing to exercise `prepack`, checks the
|
|
51
|
-
tarball contents and dependencies, typechecks and imports each public export,
|
|
52
|
-
and server renders representative components in both themes.
|
|
53
|
-
|
|
54
50
|
Consumers provide Emotion's `ThemeProvider` with `lightTheme` or `darkTheme`.
|
|
55
51
|
The package does not include application providers, global CSS, or fonts.
|
|
56
52
|
|
|
57
53
|
## Prepare a release
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Craft creates a `scraps/release/<version>` branch and opens a request in
|
|
65
|
-
`getsentry/publish`. The package workflow verifies that branch and uploads its
|
|
66
|
-
npm tarball. A release manager must approve the request before Craft publishes.
|
|
67
|
-
The Sentry Docker release uses the root `.craft.yml`.
|
|
55
|
+
Run the `Release` GitHub workflow and select the `static/packages/scraps` workspace.
|
|
56
|
+
Leave the version blank to use the workspace's automatic versioning policy.
|
|
57
|
+
Craft uses conventional commits to choose the next version and update
|
|
58
|
+
[CHANGELOG.md](./CHANGELOG.md). To override the version, enter an exact version
|
|
59
|
+
or `major`, `minor`, `patch`, or `auto`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type Theme } from '@emotion/react';
|
|
3
|
+
import type { DistributedOmit } from 'type-fest';
|
|
4
|
+
import { type ButtonProps } from '../button/index.js';
|
|
5
|
+
import type { AlertVariant } from '../theme/index.js';
|
|
6
|
+
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
variant: AlertVariant;
|
|
8
|
+
defaultExpanded?: boolean;
|
|
9
|
+
expand?: React.ReactNode;
|
|
10
|
+
handleExpandChange?: (isExpanded: boolean) => void;
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
showIcon?: boolean;
|
|
13
|
+
system?: boolean;
|
|
14
|
+
trailingItems?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function Alert({ icon, system, expand, trailingItems, className, children, variant, ...props }: AlertProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare namespace Alert {
|
|
18
|
+
var Container: import("@emotion/styled").StyledComponent<{
|
|
19
|
+
theme?: Theme;
|
|
20
|
+
as?: React.ElementType;
|
|
21
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
22
|
+
var Button: typeof AlertButton;
|
|
23
|
+
}
|
|
24
|
+
declare function AlertButton(props: DistributedOmit<ButtonProps, 'size'>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { css } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
6
|
+
import { IconChevron } from "@sentry/icons/chevron";
|
|
7
|
+
import { IconInfo } from "@sentry/icons/info";
|
|
8
|
+
import { IconNot } from "@sentry/icons/not";
|
|
9
|
+
import { IconWarning } from "@sentry/icons/warning";
|
|
10
|
+
import classnames from "classnames";
|
|
11
|
+
import { Button } from "../button/index.js";
|
|
12
|
+
import { Container, Flex, Grid } from "../layout/index.js";
|
|
13
|
+
import { PanelProvider } from "../panelProvider.js";
|
|
14
|
+
import { Text } from "../text/index.js";
|
|
15
|
+
import { useTranslation } from "../translation/useTranslation.js";
|
|
16
|
+
import { unreachable } from "../unreachable.js";
|
|
17
|
+
const AlertPanel = styled('div')`
|
|
18
|
+
position: relative;
|
|
19
|
+
display: grid;
|
|
20
|
+
width: 100%;
|
|
21
|
+
container-type: inline-size;
|
|
22
|
+
grid-template-columns: ${(p)=>getAlertGridLayout(p)};
|
|
23
|
+
padding: ${(p)=>p.theme.space.md} ${(p)=>p.theme.space.lg};
|
|
24
|
+
border-width: ${(p)=>p.system ? '0px 0px 1px 0px' : '1px'};
|
|
25
|
+
border-style: solid;
|
|
26
|
+
border-radius: ${(p)=>p.system ? '0px' : p.theme.radius.md};
|
|
27
|
+
cursor: ${(p)=>p.expand ? 'pointer' : 'inherit'};
|
|
28
|
+
gap: ${(p)=>p.theme.space.lg};
|
|
29
|
+
row-gap: 0;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
min-height: 44px;
|
|
32
|
+
${(props)=>makeAlertTheme(props, props.theme)};
|
|
33
|
+
|
|
34
|
+
a:not([role='button']) {
|
|
35
|
+
text-decoration: underline;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
function getAlertGridLayout(p) {
|
|
39
|
+
return `1fr ${p.trailingItems ? 'auto' : ''} ${p.expand ? 'min-content' : ''}`;
|
|
40
|
+
}
|
|
41
|
+
function makeAlertTheme(props, theme) {
|
|
42
|
+
const tokens = getAlertTokens(props.variant, theme);
|
|
43
|
+
return css`
|
|
44
|
+
${generateAlertBackground(props, tokens, theme)};
|
|
45
|
+
border-color: ${tokens.border};
|
|
46
|
+
|
|
47
|
+
/* We dont want to override the color of any elements inside buttons */
|
|
48
|
+
:not(button *) {
|
|
49
|
+
color: ${theme.tokens.content.primary};
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
function getAlertTokens(variant, theme) {
|
|
54
|
+
switch(variant){
|
|
55
|
+
case 'info':
|
|
56
|
+
return {
|
|
57
|
+
background: theme.tokens.background.transparent.accent.muted,
|
|
58
|
+
iconBackground: theme.tokens.background.accent.vibrant,
|
|
59
|
+
border: theme.tokens.border.accent.moderate
|
|
60
|
+
};
|
|
61
|
+
case 'danger':
|
|
62
|
+
return {
|
|
63
|
+
background: theme.tokens.background.transparent.danger.muted,
|
|
64
|
+
iconBackground: theme.tokens.background.danger.vibrant,
|
|
65
|
+
border: theme.tokens.border.danger.moderate
|
|
66
|
+
};
|
|
67
|
+
case 'warning':
|
|
68
|
+
return {
|
|
69
|
+
background: theme.tokens.background.transparent.warning.muted,
|
|
70
|
+
iconBackground: theme.tokens.background.warning.vibrant,
|
|
71
|
+
border: theme.tokens.border.warning.moderate
|
|
72
|
+
};
|
|
73
|
+
case 'success':
|
|
74
|
+
return {
|
|
75
|
+
background: theme.tokens.background.transparent.success.muted,
|
|
76
|
+
iconBackground: theme.tokens.background.success.vibrant,
|
|
77
|
+
border: theme.tokens.border.success.moderate
|
|
78
|
+
};
|
|
79
|
+
case 'muted':
|
|
80
|
+
return {
|
|
81
|
+
background: theme.tokens.background.primary,
|
|
82
|
+
iconBackground: theme.tokens.background.primary,
|
|
83
|
+
border: theme.tokens.border.primary
|
|
84
|
+
};
|
|
85
|
+
default:
|
|
86
|
+
unreachable(variant);
|
|
87
|
+
}
|
|
88
|
+
throw new TypeError(`Invalid alert variant, got ${variant}`);
|
|
89
|
+
}
|
|
90
|
+
function generateAlertBackground(props, tokens, theme) {
|
|
91
|
+
const width = 44;
|
|
92
|
+
if (props.showIcon) return css`
|
|
93
|
+
background-image:
|
|
94
|
+
linear-gradient(
|
|
95
|
+
to right,
|
|
96
|
+
${tokens.iconBackground},
|
|
97
|
+
${tokens.iconBackground} ${width - 1}px,
|
|
98
|
+
${tokens.iconBackground} ${width - 1}px,
|
|
99
|
+
${tokens.border} ${width - 1}px,
|
|
100
|
+
${tokens.border} ${width}px,
|
|
101
|
+
${tokens.background} ${width}px,
|
|
102
|
+
${tokens.background} ${width + 1}px
|
|
103
|
+
),
|
|
104
|
+
linear-gradient(${theme.tokens.background.primary});
|
|
105
|
+
padding-left: calc(${width}px + ${theme.space.lg});
|
|
106
|
+
`;
|
|
107
|
+
return css`
|
|
108
|
+
background-image:
|
|
109
|
+
linear-gradient(${tokens.background}),
|
|
110
|
+
linear-gradient(${theme.tokens.background.primary});
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
const StyledTrailingItems = styled(Grid)`
|
|
114
|
+
font-size: ${(p)=>p.theme.font.size.md};
|
|
115
|
+
|
|
116
|
+
> svg {
|
|
117
|
+
width: 16px;
|
|
118
|
+
height: 16px;
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
align-self: center;
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
const StyledMessage = styled('div')`
|
|
125
|
+
line-height: ${(p)=>p.theme.font.lineHeight.comfortable};
|
|
126
|
+
place-content: center;
|
|
127
|
+
padding-block: ${(p)=>p.theme.space.xs};
|
|
128
|
+
`;
|
|
129
|
+
const StyledIconWrapper = styled('div')`
|
|
130
|
+
position: absolute;
|
|
131
|
+
top: ${(p)=>p.theme.space.lg};
|
|
132
|
+
left: ${(p)=>p.theme.space.lg};
|
|
133
|
+
width: 20px;
|
|
134
|
+
height: 20px;
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
color: ${(p)=>[
|
|
139
|
+
'info',
|
|
140
|
+
'danger'
|
|
141
|
+
].includes(p.variant) ? p.theme.colors.white : 'muted' === p.variant ? p.theme.tokens.content.primary : p.theme.colors.black};
|
|
142
|
+
`;
|
|
143
|
+
function Alert({ icon, system, expand, trailingItems, className, children, variant, ...props }) {
|
|
144
|
+
const { t } = useTranslation();
|
|
145
|
+
const showExpand = null != expand;
|
|
146
|
+
const [isExpanded, setIsExpanded] = useState(!!props.defaultExpanded);
|
|
147
|
+
const expandRef = useRef(null);
|
|
148
|
+
function handleClick(e) {
|
|
149
|
+
if (e.target === expandRef.current || expandRef.current?.contains(e.target)) return;
|
|
150
|
+
if (showExpand) {
|
|
151
|
+
setIsExpanded(!isExpanded);
|
|
152
|
+
props.handleExpandChange?.(!isExpanded);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const showIcon = props.showIcon ?? true;
|
|
156
|
+
return /*#__PURE__*/ jsx(AlertPanel, {
|
|
157
|
+
system: system,
|
|
158
|
+
expand: expand,
|
|
159
|
+
trailingItems: trailingItems,
|
|
160
|
+
onClick: handleClick,
|
|
161
|
+
className: classnames(`ref-${variant}`, className),
|
|
162
|
+
variant: variant,
|
|
163
|
+
...props,
|
|
164
|
+
showIcon: showIcon,
|
|
165
|
+
children: /*#__PURE__*/ jsxs(PanelProvider, {
|
|
166
|
+
children: [
|
|
167
|
+
showIcon && /*#__PURE__*/ jsx(StyledIconWrapper, {
|
|
168
|
+
variant: variant,
|
|
169
|
+
onClick: handleClick,
|
|
170
|
+
children: icon ?? /*#__PURE__*/ jsx(AlertIcon, {
|
|
171
|
+
variant: variant
|
|
172
|
+
})
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ jsx(StyledMessage, {
|
|
175
|
+
children: children
|
|
176
|
+
}),
|
|
177
|
+
!!trailingItems && /*#__PURE__*/ jsx(StyledTrailingItems, {
|
|
178
|
+
flow: "column",
|
|
179
|
+
autoColumns: "max-content",
|
|
180
|
+
rows: "100%",
|
|
181
|
+
gap: "md",
|
|
182
|
+
area: {
|
|
183
|
+
zero: '2 / 1 / auto / -1',
|
|
184
|
+
sm: 'auto'
|
|
185
|
+
},
|
|
186
|
+
align: {
|
|
187
|
+
zero: 'stretch',
|
|
188
|
+
sm: 'start'
|
|
189
|
+
},
|
|
190
|
+
justifyItems: "start",
|
|
191
|
+
minHeight: "28px",
|
|
192
|
+
padding: "2xs 0",
|
|
193
|
+
onClick: (e)=>e.stopPropagation(),
|
|
194
|
+
children: trailingItems
|
|
195
|
+
}),
|
|
196
|
+
showExpand && /*#__PURE__*/ jsx(Flex, {
|
|
197
|
+
align: "center",
|
|
198
|
+
alignSelf: "flex-start",
|
|
199
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
200
|
+
size: "zero",
|
|
201
|
+
variant: "transparent",
|
|
202
|
+
icon: /*#__PURE__*/ jsx(IconChevron, {
|
|
203
|
+
direction: isExpanded ? 'up' : 'down'
|
|
204
|
+
}),
|
|
205
|
+
"aria-label": isExpanded ? t('Collapse') : t('Expand'),
|
|
206
|
+
onClick: ()=>{
|
|
207
|
+
setIsExpanded(!isExpanded);
|
|
208
|
+
props.handleExpandChange?.(!isExpanded);
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
}),
|
|
212
|
+
isExpanded && /*#__PURE__*/ jsx(Container, {
|
|
213
|
+
ref: expandRef,
|
|
214
|
+
row: {
|
|
215
|
+
zero: trailingItems ? '3' : '2',
|
|
216
|
+
xl: '2'
|
|
217
|
+
},
|
|
218
|
+
column: "1 / -1",
|
|
219
|
+
alignSelf: "flex-start",
|
|
220
|
+
cursor: "auto",
|
|
221
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
222
|
+
as: "div",
|
|
223
|
+
variant: "muted",
|
|
224
|
+
children: expand
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function AlertIcon({ variant }) {
|
|
232
|
+
switch(variant){
|
|
233
|
+
case 'warning':
|
|
234
|
+
return /*#__PURE__*/ jsx(IconWarning, {});
|
|
235
|
+
case 'success':
|
|
236
|
+
return /*#__PURE__*/ jsx(IconCheckmark, {});
|
|
237
|
+
case 'danger':
|
|
238
|
+
return /*#__PURE__*/ jsx(IconNot, {});
|
|
239
|
+
case 'info':
|
|
240
|
+
case 'muted':
|
|
241
|
+
return /*#__PURE__*/ jsx(IconInfo, {});
|
|
242
|
+
default:
|
|
243
|
+
unreachable(variant);
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const AlertContainer = styled('div')`
|
|
248
|
+
width: 100%;
|
|
249
|
+
|
|
250
|
+
> div {
|
|
251
|
+
margin-bottom: ${(p)=>p.theme.space.xl};
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
Alert.Container = AlertContainer;
|
|
255
|
+
function AlertButton(props) {
|
|
256
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
257
|
+
...props,
|
|
258
|
+
size: "zero"
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
Alert.Button = AlertButton;
|
|
262
|
+
export { Alert };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type Theme } from '@emotion/react';
|
|
3
|
+
import { type AlertProps } from './alert.js';
|
|
4
|
+
interface BaseAlertLinkProps extends Pick<AlertProps, 'system' | 'children' | 'trailingItems' | 'variant'> {
|
|
5
|
+
}
|
|
6
|
+
interface ExternalAlertLinkProps extends BaseAlertLinkProps {
|
|
7
|
+
href: string;
|
|
8
|
+
openInNewTab: boolean;
|
|
9
|
+
onClick?: never;
|
|
10
|
+
to?: never;
|
|
11
|
+
}
|
|
12
|
+
interface InternalAlertLinkProps extends BaseAlertLinkProps {
|
|
13
|
+
to: string;
|
|
14
|
+
href?: never;
|
|
15
|
+
onClick?: never;
|
|
16
|
+
openInNewTab?: never;
|
|
17
|
+
}
|
|
18
|
+
interface ManualAlertLinkProps extends BaseAlertLinkProps {
|
|
19
|
+
onClick: React.MouseEventHandler<HTMLAnchorElement>;
|
|
20
|
+
href?: never;
|
|
21
|
+
openInNewTab?: never;
|
|
22
|
+
to?: never;
|
|
23
|
+
}
|
|
24
|
+
type AlertLinkProps = ExternalAlertLinkProps | InternalAlertLinkProps | ManualAlertLinkProps;
|
|
25
|
+
export declare function AlertLink(props: AlertLinkProps): React.ReactNode;
|
|
26
|
+
export declare namespace AlertLink {
|
|
27
|
+
var Container: import("@emotion/styled").StyledComponent<{
|
|
28
|
+
theme?: Theme;
|
|
29
|
+
as?: React.ElementType;
|
|
30
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { IconChevron } from "@sentry/icons/chevron";
|
|
5
|
+
import { ExternalLink, Link } from "../link/index.js";
|
|
6
|
+
import { Alert } from "./alert.js";
|
|
7
|
+
function AlertLink(props) {
|
|
8
|
+
const alertProps = {
|
|
9
|
+
variant: props.variant,
|
|
10
|
+
system: props.system,
|
|
11
|
+
trailingItems: props.trailingItems ?? /*#__PURE__*/ jsx(IconChevron, {
|
|
12
|
+
direction: "right"
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
if ('href' in props) return /*#__PURE__*/ jsx(ExternalLinkWithTextDecoration, {
|
|
16
|
+
variant: alertProps.variant,
|
|
17
|
+
href: props.href,
|
|
18
|
+
openInNewTab: props.openInNewTab,
|
|
19
|
+
children: /*#__PURE__*/ jsx(Alert, {
|
|
20
|
+
...alertProps,
|
|
21
|
+
children: props.children
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
if ('onClick' in props) return /*#__PURE__*/ jsx(LinkWithTextDecoration, {
|
|
25
|
+
variant: alertProps.variant,
|
|
26
|
+
to: "",
|
|
27
|
+
onClick: props.onClick,
|
|
28
|
+
children: /*#__PURE__*/ jsx(Alert, {
|
|
29
|
+
...alertProps,
|
|
30
|
+
children: props.children
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/ jsx(LinkWithTextDecoration, {
|
|
34
|
+
variant: alertProps.variant,
|
|
35
|
+
to: props.to,
|
|
36
|
+
children: /*#__PURE__*/ jsx(Alert, {
|
|
37
|
+
...alertProps,
|
|
38
|
+
children: props.children
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const ExternalLinkWithTextDecoration = styled(ExternalLink)`
|
|
43
|
+
display: block;
|
|
44
|
+
width: 100%;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
${(p)=>textDecorationStyles({
|
|
47
|
+
type: p.variant,
|
|
48
|
+
theme: p.theme
|
|
49
|
+
})}
|
|
50
|
+
`;
|
|
51
|
+
const LinkWithTextDecoration = styled(Link)`
|
|
52
|
+
display: block;
|
|
53
|
+
width: 100%;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
${(p)=>textDecorationStyles({
|
|
56
|
+
type: p.variant,
|
|
57
|
+
theme: p.theme
|
|
58
|
+
})}
|
|
59
|
+
`;
|
|
60
|
+
function textDecorationStyles({ type, theme }) {
|
|
61
|
+
const borderColors = {
|
|
62
|
+
info: theme.colors.blue200,
|
|
63
|
+
success: theme.colors.green200,
|
|
64
|
+
muted: theme.tokens.border.primary,
|
|
65
|
+
warning: theme.colors.yellow200,
|
|
66
|
+
danger: theme.colors.red200
|
|
67
|
+
};
|
|
68
|
+
const hoverColors = {
|
|
69
|
+
info: theme.colors.blue500,
|
|
70
|
+
success: theme.colors.green500,
|
|
71
|
+
muted: 'inherit',
|
|
72
|
+
warning: theme.colors.yellow500,
|
|
73
|
+
danger: theme.colors.red500
|
|
74
|
+
};
|
|
75
|
+
return css`
|
|
76
|
+
text-decoration-color: ${borderColors[type]};
|
|
77
|
+
text-decoration-style: solid;
|
|
78
|
+
text-decoration-line: underline;
|
|
79
|
+
transition: border-color ${theme.motion.smooth.moderate};
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
text-decoration-color: ${hoverColors[type]};
|
|
83
|
+
text-decoration-style: solid;
|
|
84
|
+
text-decoration-line: underline;
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
const Container = styled('div')`
|
|
89
|
+
> a {
|
|
90
|
+
margin-bottom: ${(p)=>p.theme.space.xl};
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
AlertLink.Container = Container;
|
|
94
|
+
export { AlertLink };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
interface BackdropProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'style' | 'className' | `on${string}`> {
|
|
3
|
+
zIndex: 'widgetBuilderDrawer' | 'drawer' | 'modal';
|
|
4
|
+
'data-drawer-backdrop'?: string;
|
|
5
|
+
'data-test-id'?: string;
|
|
6
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function Backdrop({ onClick, zIndex, ...props }: BackdropProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
function Backdrop({ onClick, zIndex, ...props }) {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
const background = 'light' === theme.type ? '#10082845' : '#10082080';
|
|
7
|
+
return /*#__PURE__*/ jsx(motion.div, {
|
|
8
|
+
id: "backdrop",
|
|
9
|
+
onClick: onClick,
|
|
10
|
+
"data-overlay": true,
|
|
11
|
+
...props,
|
|
12
|
+
transition: theme.motion.framer.smooth.slow,
|
|
13
|
+
initial: {
|
|
14
|
+
opacity: 0,
|
|
15
|
+
background,
|
|
16
|
+
position: 'fixed',
|
|
17
|
+
inset: '0',
|
|
18
|
+
zIndex: theme.zIndex[zIndex]
|
|
19
|
+
},
|
|
20
|
+
animate: {
|
|
21
|
+
opacity: 1
|
|
22
|
+
},
|
|
23
|
+
exit: {
|
|
24
|
+
opacity: 0
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { Backdrop };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Backdrop } from './backdrop.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Backdrop } from "./backdrop.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { Theme } from '@emotion/react';
|
|
3
|
+
type FeatureBadgeType = 'alpha' | 'beta' | 'new' | 'experimental' | 'internal';
|
|
4
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
variant: 'muted' | 'internal' | 'info' | 'success' | 'warning' | 'danger' | 'highlight' | 'promotion' | FeatureBadgeType;
|
|
7
|
+
}
|
|
8
|
+
export declare const Badge: import("@emotion/styled").StyledComponent<{
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
as?: React.ElementType;
|
|
11
|
+
} & BadgeProps, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { unreachable } from "../unreachable.js";
|
|
3
|
+
const Badge = styled('span')`
|
|
4
|
+
${(p)=>({
|
|
5
|
+
...makeBadgeTheme(p, p.theme)
|
|
6
|
+
})};
|
|
7
|
+
border-radius: ${(p)=>p.theme.radius.sm};
|
|
8
|
+
font-size: ${(p)=>p.theme.font.size.sm};
|
|
9
|
+
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
line-height: initial;
|
|
13
|
+
height: 20px;
|
|
14
|
+
font-weight: ${(p)=>p.theme.font.weight.sans.medium};
|
|
15
|
+
padding: ${(p)=>p.theme.space.xs} ${(p)=>p.theme.space.xs};
|
|
16
|
+
`;
|
|
17
|
+
function makeBadgeTheme(p, theme) {
|
|
18
|
+
switch(p.variant){
|
|
19
|
+
case 'alpha':
|
|
20
|
+
return {
|
|
21
|
+
color: theme.tokens.content.onVibrant.dark,
|
|
22
|
+
background: theme.tokens.background.promotion.vibrant
|
|
23
|
+
};
|
|
24
|
+
case 'beta':
|
|
25
|
+
return {
|
|
26
|
+
color: theme.tokens.content.onVibrant.dark,
|
|
27
|
+
background: theme.tokens.background.warning.vibrant
|
|
28
|
+
};
|
|
29
|
+
case 'new':
|
|
30
|
+
return {
|
|
31
|
+
color: theme.tokens.content.onVibrant.dark,
|
|
32
|
+
background: theme.tokens.background.success.vibrant
|
|
33
|
+
};
|
|
34
|
+
case 'experimental':
|
|
35
|
+
return {
|
|
36
|
+
color: theme.tokens.content.secondary,
|
|
37
|
+
background: theme.tokens.background.transparent.neutral.muted
|
|
38
|
+
};
|
|
39
|
+
case 'muted':
|
|
40
|
+
return {
|
|
41
|
+
color: theme.tokens.content.secondary,
|
|
42
|
+
background: theme.tokens.background.transparent.neutral.muted
|
|
43
|
+
};
|
|
44
|
+
case 'internal':
|
|
45
|
+
return {
|
|
46
|
+
color: theme.tokens.content.secondary,
|
|
47
|
+
background: theme.tokens.background.transparent.neutral.muted
|
|
48
|
+
};
|
|
49
|
+
case 'highlight':
|
|
50
|
+
case 'info':
|
|
51
|
+
return {
|
|
52
|
+
color: theme.tokens.content.accent,
|
|
53
|
+
background: theme.tokens.background.transparent.accent.muted
|
|
54
|
+
};
|
|
55
|
+
case 'promotion':
|
|
56
|
+
return {
|
|
57
|
+
color: theme.tokens.content.promotion,
|
|
58
|
+
background: theme.tokens.background.transparent.promotion.muted
|
|
59
|
+
};
|
|
60
|
+
case 'danger':
|
|
61
|
+
return {
|
|
62
|
+
color: theme.tokens.content.danger,
|
|
63
|
+
background: theme.tokens.background.transparent.danger.muted
|
|
64
|
+
};
|
|
65
|
+
case 'warning':
|
|
66
|
+
return {
|
|
67
|
+
color: theme.tokens.content.warning,
|
|
68
|
+
background: theme.tokens.background.transparent.warning.muted
|
|
69
|
+
};
|
|
70
|
+
case 'success':
|
|
71
|
+
return {
|
|
72
|
+
color: theme.tokens.content.success,
|
|
73
|
+
background: theme.tokens.background.transparent.success.muted
|
|
74
|
+
};
|
|
75
|
+
default:
|
|
76
|
+
unreachable(p.variant);
|
|
77
|
+
throw new TypeError(`Unsupported badge variant: ${p.variant}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export { Badge };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type TooltipProps } from '../tooltip/index.js';
|
|
2
|
+
export interface FeatureBadgeProps {
|
|
3
|
+
type: 'alpha' | 'beta' | 'new' | 'experimental' | 'debug';
|
|
4
|
+
tooltipProps?: Omit<Partial<TooltipProps>, 'skipWrapper'>;
|
|
5
|
+
}
|
|
6
|
+
export declare function FeatureBadge({ type, tooltipProps }: FeatureBadgeProps): import("@emotion/react/jsx-runtime").JSX.Element;
|