@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.
- 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 +141 -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/dragHandle/dragHandle.d.ts +34 -0
- package/dist/dragHandle/dragHandle.js +115 -0
- package/dist/dragHandle/index.d.ts +4 -0
- package/dist/dragHandle/index.js +4 -0
- package/dist/dragHandle/setDocumentDragging.d.ts +9 -0
- package/dist/dragHandle/setDocumentDragging.js +6 -0
- package/dist/dragHandle/useDragMove.d.ts +244 -0
- package/dist/dragHandle/useDragMove.js +66 -0
- package/dist/dragHandle/useDragSeparator.d.ts +256 -0
- package/dist/dragHandle/useDragSeparator.js +36 -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/formPresentation/autoSaveContext.d.ts +23 -0
- package/dist/formPresentation/autoSaveContext.js +13 -0
- package/dist/formPresentation/base.d.ts +11 -0
- package/dist/formPresentation/base.js +37 -0
- package/dist/formPresentation/displayField.d.ts +17 -0
- package/dist/formPresentation/displayField.js +69 -0
- package/dist/formPresentation/fieldIds.d.ts +3 -0
- package/dist/formPresentation/fieldIds.js +14 -0
- package/dist/formPresentation/fieldLayout.d.ts +23 -0
- package/dist/formPresentation/fieldLayout.js +76 -0
- package/dist/formPresentation/formContext.d.ts +4 -0
- package/dist/formPresentation/formContext.js +6 -0
- package/dist/formPresentation/groupContext.d.ts +24 -0
- package/dist/formPresentation/groupContext.js +22 -0
- package/dist/formPresentation/icons.d.ts +11 -0
- package/dist/formPresentation/icons.js +61 -0
- package/dist/formPresentation/index.d.ts +8 -0
- package/dist/formPresentation/index.js +8 -0
- package/dist/formPresentation/meta.d.ts +18 -0
- package/dist/formPresentation/meta.js +88 -0
- package/dist/formPresentation/useStackedLayout.d.ts +1 -0
- package/dist/formPresentation/useStackedLayout.js +9 -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/input/index.d.ts +8 -0
- package/dist/input/index.js +6 -0
- package/dist/input/input.d.ts +19 -0
- package/dist/input/input.js +14 -0
- package/dist/input/inputGroup.d.ts +29 -0
- package/dist/input/inputGroup.js +167 -0
- package/dist/input/inputStyles.d.ts +13 -0
- package/dist/input/inputStyles.js +52 -0
- package/dist/input/numberDragInput.d.ts +20 -0
- package/dist/input/numberDragInput.js +97 -0
- package/dist/input/numberInput.d.ts +10 -0
- package/dist/input/numberInput.js +94 -0
- package/dist/input/otpInput.d.ts +28 -0
- package/dist/input/otpInput.js +81 -0
- package/dist/input/useAutosizeInput.d.ts +17 -0
- package/dist/input/useAutosizeInput.js +56 -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 +70 -0
- package/dist/overlayPositioning.js +139 -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/table/index.d.ts +3 -0
- package/dist/table/index.js +3 -0
- package/dist/table/sortableHeaderCell.d.ts +36 -0
- package/dist/table/sortableHeaderCell.js +99 -0
- package/dist/table/styles.d.ts +46 -0
- package/dist/table/styles.js +93 -0
- package/dist/table/table.d.ts +64 -0
- package/dist/table/table.js +228 -0
- package/dist/table/useColumnResize.d.ts +27 -0
- package/dist/table/useColumnResize.js +62 -0
- package/dist/table/useObservedColumnSize.d.ts +12 -0
- package/dist/table/useObservedColumnSize.js +74 -0
- package/dist/text/heading.d.ts +2 -1
- 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 +8 -0
- package/dist/text/text.js +1 -1
- package/dist/textarea/index.d.ts +1 -0
- package/dist/textarea/index.js +1 -0
- package/dist/textarea/textarea.d.ts +22 -0
- package/dist/textarea/textarea.js +77 -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 +217 -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 +219 -11
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -9
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import is_prop_valid from "@emotion/is-prop-valid";
|
|
3
|
+
import { css } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
function defined(value) {
|
|
6
|
+
return null != value;
|
|
7
|
+
}
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
hasSelectedBackground: true
|
|
10
|
+
};
|
|
11
|
+
const InteractionStateLayer = styled((props)=>{
|
|
12
|
+
const { children, as: Element = 'span', ...rest } = props;
|
|
13
|
+
return /*#__PURE__*/ jsx(Element, {
|
|
14
|
+
...rest,
|
|
15
|
+
role: "presentation",
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
}, {
|
|
19
|
+
shouldForwardProp: (p)=>is_prop_valid(p) || 'as' === p
|
|
20
|
+
})`
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 50%;
|
|
23
|
+
left: 50%;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
transform: translate(-50%, -50%);
|
|
27
|
+
|
|
28
|
+
box-sizing: content-box;
|
|
29
|
+
border-radius: inherit;
|
|
30
|
+
border: inherit;
|
|
31
|
+
color: ${(p)=>p.color ? p.theme[p.color] ?? p.color : 'currentcolor'};
|
|
32
|
+
background-color: currentcolor;
|
|
33
|
+
border-color: currentcolor;
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
|
|
36
|
+
opacity: 0;
|
|
37
|
+
|
|
38
|
+
${(p)=>defined(p.isHovered) ? p.isHovered && css`
|
|
39
|
+
opacity: ${p.higherOpacity ? 0.085 : 0.06};
|
|
40
|
+
` : css`
|
|
41
|
+
*:hover:not(:focus-visible) > & {
|
|
42
|
+
opacity: ${p.higherOpacity ? 0.085 : 0.06};
|
|
43
|
+
}
|
|
44
|
+
`}
|
|
45
|
+
|
|
46
|
+
${(p)=>defined(p.isPressed) ? p.isPressed && css`
|
|
47
|
+
&&& {
|
|
48
|
+
opacity: ${p.higherOpacity ? 0.12 : 0.09};
|
|
49
|
+
}
|
|
50
|
+
` : css`
|
|
51
|
+
*:active > && {
|
|
52
|
+
opacity: ${p.higherOpacity ? 0.12 : 0.09};
|
|
53
|
+
}
|
|
54
|
+
${(p.hasSelectedBackground ?? defaultProps.hasSelectedBackground) && css`
|
|
55
|
+
*[aria-expanded='true'] > &&,
|
|
56
|
+
*[aria-selected='true'] > && {
|
|
57
|
+
opacity: ${p.higherOpacity ? 0.12 : 0.09};
|
|
58
|
+
}
|
|
59
|
+
`}
|
|
60
|
+
`}
|
|
61
|
+
|
|
62
|
+
*:disabled &&,
|
|
63
|
+
*[aria-disabled='true'] && {
|
|
64
|
+
opacity: 0;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
export { InteractionStateLayer };
|
package/dist/layout/flex.d.ts
CHANGED
package/dist/layout/grid.d.ts
CHANGED
package/dist/layout/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { Stack, type StackProps } from './stack.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* @TODO: these should probably be private to scraps
|
|
8
8
|
*/
|
|
9
|
-
export { ContainerQueryProvider, rc, type Responsive, type ResponsiveKey,
|
|
9
|
+
export { ContainerQueryContext, ContainerQueryProvider, rc, type Responsive, type ResponsiveKey,
|
|
10
10
|
/** @public */
|
|
11
11
|
useContainerBreakpoint, useHasContainerQuery, useResponsivePropResolver, useResponsivePropValue, } from './styles.js';
|
|
12
12
|
export { getBorder, getMargin, getRadius, getSpacing } from './styles.js';
|
package/dist/layout/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { Surface } from "./surface.js";
|
|
|
3
3
|
export { Flex } from "./flex.js";
|
|
4
4
|
export { Grid } from "./grid.js";
|
|
5
5
|
export { Stack } from "./stack.js";
|
|
6
|
-
export { ContainerQueryProvider, FLEX_JUSTIFY_CONTENT, getBorder, getMargin, getRadius, getSpacing, rc, useContainerBreakpoint, useHasContainerQuery, useResponsivePropResolver, useResponsivePropValue } from "./styles.js";
|
|
6
|
+
export { ContainerQueryContext, ContainerQueryProvider, FLEX_JUSTIFY_CONTENT, getBorder, getMargin, getRadius, getSpacing, rc, useContainerBreakpoint, useHasContainerQuery, useResponsivePropResolver, useResponsivePropValue } from "./styles.js";
|
package/dist/layout/stack.d.ts
CHANGED
package/dist/layout/styles.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare function useActiveBreakpoint(): BreakpointSize;
|
|
|
77
77
|
* CSS-only responsive props don't need this — they resolve natively via
|
|
78
78
|
* `@container` queries. This context exists purely for the JS resolution path.
|
|
79
79
|
*/
|
|
80
|
-
export declare const ContainerQueryContext: import("react").Context<"
|
|
80
|
+
export declare const ContainerQueryContext: import("react").Context<"xs" | "sm" | "md" | "2xs" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "zero" | "3xs" | "5xl" | null>;
|
|
81
81
|
/**
|
|
82
82
|
* The JS equivalent of a CSS container query: returns the active breakpoint of
|
|
83
83
|
* the nearest ancestor query container (read from `ContainerQueryContext`),
|
package/dist/layout/surface.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
1
2
|
import { type ContainerElement, type ContainerProps } from './container.js';
|
|
2
3
|
import type { SurfaceVariant } from '../theme/index.js';
|
|
3
4
|
interface FlatSurfaceProps<T extends ContainerElement = 'div'> extends Omit<ContainerProps<T>, 'background' | 'border'> {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type AnalyticsProps } from '../trackingContext.js';
|
|
3
|
+
export interface LinkProps extends React.RefAttributes<HTMLAnchorElement>, AnalyticsProps, Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, 'href' | 'target' | 'as' | 'css'> {
|
|
4
|
+
[key: `data-${string}`]: string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* The string path or destination object. A LinkBehaviorContextProvider can
|
|
7
|
+
* normalize destinations and handle client-side routing.
|
|
8
|
+
*/
|
|
9
|
+
to: string | {
|
|
10
|
+
hash?: string;
|
|
11
|
+
pathname?: string;
|
|
12
|
+
query?: Record<string, unknown>;
|
|
13
|
+
search?: string;
|
|
14
|
+
state?: unknown;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Indicator if the link should be disabled
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
preventScrollReset?: boolean;
|
|
21
|
+
reloadDocument?: boolean;
|
|
22
|
+
replace?: boolean;
|
|
23
|
+
state?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Where something leads: a route inside the product, or an external URL
|
|
27
|
+
* outside it. The two are mutually exclusive, so a component can pick `Link`
|
|
28
|
+
* or `ExternalLink` from whichever one it was handed.
|
|
29
|
+
*/
|
|
30
|
+
export type LinkDestination = {
|
|
31
|
+
to: LinkProps['to'];
|
|
32
|
+
externalHref?: never;
|
|
33
|
+
} | {
|
|
34
|
+
externalHref: string;
|
|
35
|
+
to?: never;
|
|
36
|
+
};
|
|
37
|
+
export declare function Link(props: LinkProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
38
|
+
interface ExternalLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
39
|
+
disabled?: LinkProps['disabled'];
|
|
40
|
+
openInNewTab?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function ExternalLink({ openInNewTab, ...props }: ExternalLinkProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import is_prop_valid from "@emotion/is-prop-valid";
|
|
3
|
+
import { css } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { getTextStyles } from "../text/text.js";
|
|
6
|
+
import { useClickTracking } from "../trackingContext.js";
|
|
7
|
+
import { useLinkBehavior } from "./linkBehaviorContext.js";
|
|
8
|
+
const getLinkStyles = ({ disabled, theme })=>css`
|
|
9
|
+
border-radius: 2px;
|
|
10
|
+
pointer-events: ${disabled ? 'none' : void 0};
|
|
11
|
+
color: ${disabled ? theme.tokens.content.disabled : void 0};
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
color: ${disabled ? theme.tokens.content.disabled : void 0};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:focus-visible {
|
|
18
|
+
text-decoration: none;
|
|
19
|
+
${theme.focusRing()}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
const getLinkTextStyles = ({ theme })=>css`
|
|
23
|
+
${getTextStyles({
|
|
24
|
+
theme,
|
|
25
|
+
variant: 'inherit'
|
|
26
|
+
})}
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
`;
|
|
29
|
+
const Anchor = styled('a', {
|
|
30
|
+
shouldForwardProp: (prop)=>is_prop_valid(prop) && 'disabled' !== prop
|
|
31
|
+
})`
|
|
32
|
+
${getLinkTextStyles}
|
|
33
|
+
${getLinkStyles}
|
|
34
|
+
`;
|
|
35
|
+
function LinkBase(props) {
|
|
36
|
+
const { Component, behavior } = useLinkBehavior(props);
|
|
37
|
+
const propsWithBehavior = behavior();
|
|
38
|
+
const { handleClick } = useClickTracking(propsWithBehavior, 'link');
|
|
39
|
+
const { analyticsEventKey: _analyticsEventKey, analyticsEventName: _analyticsEventName, analyticsParams: _analyticsParams, busy: _busy, variant: _variant, ...linkProps } = props.disabled ? props : propsWithBehavior;
|
|
40
|
+
if (props.disabled) {
|
|
41
|
+
const { to: _to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...restProps } = linkProps;
|
|
42
|
+
return /*#__PURE__*/ jsx(Anchor, {
|
|
43
|
+
...restProps
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return /*#__PURE__*/ jsx(Component, {
|
|
47
|
+
...linkProps,
|
|
48
|
+
onClick: handleClick
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const StyledLink = styled(LinkBase)`
|
|
52
|
+
${getLinkTextStyles}
|
|
53
|
+
${getLinkStyles}
|
|
54
|
+
`;
|
|
55
|
+
function Link(props) {
|
|
56
|
+
return /*#__PURE__*/ jsx(StyledLink, {
|
|
57
|
+
...props
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function ExternalLink({ openInNewTab = true, ...props }) {
|
|
61
|
+
if (openInNewTab) return /*#__PURE__*/ jsx(Anchor, {
|
|
62
|
+
...props,
|
|
63
|
+
target: "_blank",
|
|
64
|
+
rel: "noreferrer noopener"
|
|
65
|
+
});
|
|
66
|
+
return /*#__PURE__*/ jsx(Anchor, {
|
|
67
|
+
...props,
|
|
68
|
+
href: props.href
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export { ExternalLink, Link };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type FunctionComponent } from 'react';
|
|
3
|
+
import type { LinkProps } from './link.js';
|
|
4
|
+
type LinkBehavior<T extends LinkProps> = {
|
|
5
|
+
behavior: (props: T) => T;
|
|
6
|
+
component: FunctionComponent<T>;
|
|
7
|
+
};
|
|
8
|
+
declare function AnchorLink({ to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...props }: LinkProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const LinkBehaviorContextProvider: React.Provider<LinkBehavior<LinkProps> | null>;
|
|
10
|
+
export declare const useLinkBehavior: <T extends LinkProps>(props: T) => {
|
|
11
|
+
Component: typeof AnchorLink | React.FunctionComponent<T>;
|
|
12
|
+
behavior: () => T;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import * as __rspack_external_query_string_78b5d812 from "query-string";
|
|
4
|
+
const LinkBehaviorContext = /*#__PURE__*/ createContext(null);
|
|
5
|
+
function AnchorLink({ to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...props }) {
|
|
6
|
+
if ('string' == typeof to) return /*#__PURE__*/ jsx("a", {
|
|
7
|
+
...props,
|
|
8
|
+
href: to
|
|
9
|
+
});
|
|
10
|
+
const { pathname = '', hash = '', search = '', query } = to;
|
|
11
|
+
const querySearch = query ? __rspack_external_query_string_78b5d812.stringify(query) : search;
|
|
12
|
+
const href = `${pathname}${querySearch && !querySearch.startsWith('?') ? '?' : ''}${querySearch}${hash && !hash.startsWith('#') ? '#' : ''}${hash}`;
|
|
13
|
+
return /*#__PURE__*/ jsx("a", {
|
|
14
|
+
...props,
|
|
15
|
+
href: href
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const defaultLinkBehavior = ()=>({
|
|
19
|
+
component: AnchorLink,
|
|
20
|
+
behavior: (props)=>props
|
|
21
|
+
});
|
|
22
|
+
const LinkBehaviorContextProvider = LinkBehaviorContext.Provider;
|
|
23
|
+
const useLinkBehavior = (props)=>{
|
|
24
|
+
const linkBehavior = useContext(LinkBehaviorContext);
|
|
25
|
+
const { component, behavior } = linkBehavior ?? defaultLinkBehavior();
|
|
26
|
+
return {
|
|
27
|
+
Component: component,
|
|
28
|
+
behavior: ()=>behavior(props)
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export { LinkBehaviorContextProvider, useLinkBehavior };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { Placement } from '@floating-ui/react-dom';
|
|
3
|
+
import type { HTMLMotionProps } from 'framer-motion';
|
|
4
|
+
import type { OverlayArrowProps } from './overlayArrow.js';
|
|
5
|
+
type OriginPoint = Partial<{
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}>;
|
|
9
|
+
export interface OverlayProps extends HTMLMotionProps<'div'>, React.RefAttributes<HTMLDivElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the overlay should animate in/out. If true, we'll also need
|
|
12
|
+
* the `placement` and `originPoint` props.
|
|
13
|
+
*/
|
|
14
|
+
animated?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Props to be passed into <OverlayArrow />. If undefined, the overlay will
|
|
17
|
+
* render with no arrow.
|
|
18
|
+
*/
|
|
19
|
+
arrowProps?: OverlayArrowProps;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The CSS styles for the "origin point" over the overlay. Typically this
|
|
23
|
+
* would be the arrow (or tip).
|
|
24
|
+
*/
|
|
25
|
+
originPoint?: OriginPoint;
|
|
26
|
+
/**
|
|
27
|
+
* Indicates where the overlay is placed. This is useful for the animation to
|
|
28
|
+
* be animated 'towards' the placment origin, giving it a pleasing effect.
|
|
29
|
+
*/
|
|
30
|
+
placement?: Placement;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A overlay component that has an optional nice ease in animation along with
|
|
34
|
+
* a scale-down animation that animates towards an origin (think a tooltip
|
|
35
|
+
* pointing at something).
|
|
36
|
+
*
|
|
37
|
+
* If animated (`animated` prop is true), should be used within a
|
|
38
|
+
* `<AnimatePresence />`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function Overlay({ ref, children, arrowProps, animated, placement, originPoint, style, ...props }: OverlayProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
|
+
interface PositionWrapperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
42
|
+
/**
|
|
43
|
+
* Determines the zindex over the position wrapper
|
|
44
|
+
*/
|
|
45
|
+
zIndex: number;
|
|
46
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The PositionWrapper should be used when you're using the AnimatedOverlay as
|
|
50
|
+
* part of dynamically positioned component (useOverlayPosition). Generally
|
|
51
|
+
* this component will receive the `overlayProps`.
|
|
52
|
+
*
|
|
53
|
+
* This component ensures the wrapped AnimatedOverlay will not receive pointer
|
|
54
|
+
* events while it is being animated out. Especially useful since the
|
|
55
|
+
* `overlayProps` includes a onMouseEnter to allow the overlay to be hovered,
|
|
56
|
+
* which we would not want while its fading away.
|
|
57
|
+
*/
|
|
58
|
+
export declare function PositionWrapper({ ref, onAnimationStart: _onAnimationStart, onDragStart: _onDragStart, onDragEnd: _onDragEnd, onDrag: _onDrag, zIndex, style, ...props }: PositionWrapperProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
59
|
+
export {};
|
package/dist/overlay.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { motion, useIsPresent } from "framer-motion";
|
|
4
|
+
import { OverlayArrow } from "./overlayArrow.js";
|
|
5
|
+
import { PanelProvider } from "./panelProvider.js";
|
|
6
|
+
const overlayAnimation = {
|
|
7
|
+
transition: {
|
|
8
|
+
duration: 0.2
|
|
9
|
+
},
|
|
10
|
+
initial: {
|
|
11
|
+
opacity: 0
|
|
12
|
+
},
|
|
13
|
+
animate: {
|
|
14
|
+
opacity: 1,
|
|
15
|
+
scale: 1,
|
|
16
|
+
transition: {
|
|
17
|
+
type: 'spring',
|
|
18
|
+
duration: 0.2
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
exit: {
|
|
22
|
+
opacity: 0,
|
|
23
|
+
scale: 0.95,
|
|
24
|
+
transition: {
|
|
25
|
+
type: 'spring',
|
|
26
|
+
delay: 0.1
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function computeOriginFromArrow(placement, originPoint) {
|
|
31
|
+
const simplePlacement = placement?.split('-')[0];
|
|
32
|
+
const { y, x } = originPoint ?? {};
|
|
33
|
+
switch(simplePlacement){
|
|
34
|
+
case 'top':
|
|
35
|
+
return {
|
|
36
|
+
originX: x ? `${x}px` : '50%',
|
|
37
|
+
originY: '100%'
|
|
38
|
+
};
|
|
39
|
+
case 'bottom':
|
|
40
|
+
return {
|
|
41
|
+
originX: x ? `${x}px` : '50%',
|
|
42
|
+
originY: 0
|
|
43
|
+
};
|
|
44
|
+
case 'left':
|
|
45
|
+
return {
|
|
46
|
+
originX: '100%',
|
|
47
|
+
originY: y ? `${y}px` : '50%'
|
|
48
|
+
};
|
|
49
|
+
case 'right':
|
|
50
|
+
return {
|
|
51
|
+
originX: 0,
|
|
52
|
+
originY: y ? `${y}px` : '50%'
|
|
53
|
+
};
|
|
54
|
+
default:
|
|
55
|
+
return {
|
|
56
|
+
originX: '50%',
|
|
57
|
+
originY: '50%'
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function Overlay({ ref, children, arrowProps, animated, placement, originPoint, style, ...props }) {
|
|
62
|
+
const isTestEnv = 'test' === process.env.NODE_ENV;
|
|
63
|
+
const animationProps = !isTestEnv && animated ? {
|
|
64
|
+
...overlayAnimation,
|
|
65
|
+
style: {
|
|
66
|
+
...style,
|
|
67
|
+
...computeOriginFromArrow(placement, originPoint)
|
|
68
|
+
}
|
|
69
|
+
} : {
|
|
70
|
+
style
|
|
71
|
+
};
|
|
72
|
+
return /*#__PURE__*/ jsxs(OverlayInner, {
|
|
73
|
+
...props,
|
|
74
|
+
...animationProps,
|
|
75
|
+
"data-overlay": true,
|
|
76
|
+
ref: ref,
|
|
77
|
+
placement: placement,
|
|
78
|
+
children: [
|
|
79
|
+
null != arrowProps && /*#__PURE__*/ jsx(OverlayArrow, {
|
|
80
|
+
...arrowProps
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ jsx(PanelProvider, {
|
|
83
|
+
children: children
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const OverlayInner = styled(motion.div)`
|
|
89
|
+
position: relative;
|
|
90
|
+
background: ${(p)=>p.theme.tokens.background.overlay};
|
|
91
|
+
border-radius: ${(p)=>p.theme.radius.md};
|
|
92
|
+
border: 1px solid ${(p)=>p.theme.tokens.border.primary};
|
|
93
|
+
/* oxlint-disable-next-line @sentry/scraps/use-semantic-token */
|
|
94
|
+
box-shadow: 0 2px 0 ${(p)=>p.theme.tokens.border.primary};
|
|
95
|
+
font-size: ${(p)=>p.theme.font.size.md};
|
|
96
|
+
|
|
97
|
+
/* Override z-index from useOverlayPosition */
|
|
98
|
+
z-index: ${(p)=>p.theme.zIndex.dropdown} !important;
|
|
99
|
+
will-change: transform, opacity;
|
|
100
|
+
`;
|
|
101
|
+
function PositionWrapper({ ref, onAnimationStart: _onAnimationStart, onDragStart: _onDragStart, onDragEnd: _onDragEnd, onDrag: _onDrag, zIndex, style, ...props }) {
|
|
102
|
+
const isPresent = useIsPresent();
|
|
103
|
+
return /*#__PURE__*/ jsx(motion.div, {
|
|
104
|
+
...props,
|
|
105
|
+
ref: ref,
|
|
106
|
+
style: {
|
|
107
|
+
...style,
|
|
108
|
+
zIndex,
|
|
109
|
+
pointerEvents: isPresent ? 'auto' : 'none'
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export { Overlay, PositionWrapper };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { Placement } from '@floating-ui/react-dom';
|
|
3
|
+
export interface OverlayArrowProps extends React.ComponentPropsWithRef<'div'> {
|
|
4
|
+
placement?: Placement;
|
|
5
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
6
|
+
size?: number;
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function OverlayArrow({ placement, ref, size, ...props }: OverlayArrowProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useTheme } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
const sizeRatio = 0.5;
|
|
5
|
+
const heightRatio = 0.3;
|
|
6
|
+
function OverlayArrow({ placement, ref, size = 16, ...props }) {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const offset = placement?.startsWith('top') ? 3 : 1.5;
|
|
9
|
+
const topOffset = placement?.startsWith('top') ? 3 : 1;
|
|
10
|
+
return /*#__PURE__*/ jsx(OverlayArrowWrap, {
|
|
11
|
+
"data-overlay-arrow": true,
|
|
12
|
+
dimensions: size,
|
|
13
|
+
ref: ref,
|
|
14
|
+
placement: placement,
|
|
15
|
+
...props,
|
|
16
|
+
children: /*#__PURE__*/ jsxs("svg", {
|
|
17
|
+
viewBox: `0 0 ${size} ${size * sizeRatio}`,
|
|
18
|
+
fill: "none",
|
|
19
|
+
style: {
|
|
20
|
+
display: 'block'
|
|
21
|
+
},
|
|
22
|
+
children: [
|
|
23
|
+
placement?.startsWith('left') || placement?.startsWith('right') ? /*#__PURE__*/ jsx("polygon", {
|
|
24
|
+
transform: `translate(${placement?.startsWith('right') ? 2 : 0}, 0)`,
|
|
25
|
+
points: `
|
|
26
|
+
-2,0
|
|
27
|
+
${size},0
|
|
28
|
+
${size / 2},${size * heightRatio + topOffset}
|
|
29
|
+
${size / 2 - 2},${size * heightRatio + topOffset}`,
|
|
30
|
+
fill: theme.tokens.border.primary
|
|
31
|
+
}) : null,
|
|
32
|
+
/*#__PURE__*/ jsx("polygon", {
|
|
33
|
+
points: `0,0 ${size},0 ${size / 2},${size * heightRatio + topOffset}`,
|
|
34
|
+
fill: theme.tokens.border.primary
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ jsx("polygon", {
|
|
37
|
+
points: `${offset},0 ${size - offset}, 0 ${size / 2},${size * heightRatio}`,
|
|
38
|
+
fill: theme.tokens.background.primary
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const OverlayArrowWrap = styled('div')`
|
|
45
|
+
width: ${(p)=>p.dimensions}px;
|
|
46
|
+
height: ${(p)=>p.placement?.startsWith('left') || p.placement?.startsWith('right') ? p.dimensions : p.dimensions * sizeRatio}px;
|
|
47
|
+
position: absolute;
|
|
48
|
+
transform-origin: center;
|
|
49
|
+
|
|
50
|
+
${(p)=>p.placement?.startsWith('top') && 'top: 100%; left: 50%; transform: rotate(0deg);'}
|
|
51
|
+
${(p)=>p.placement?.startsWith('bottom') && 'bottom: 100%; left: 50%; transform: rotate(180deg);'}
|
|
52
|
+
${(p)=>p.placement?.startsWith('left') && 'left: 100%; top: 50%; transform: rotate(-90deg);'}
|
|
53
|
+
${(p)=>p.placement?.startsWith('right') && 'right: 100%; top: 50%; transform: rotate(90deg);'}
|
|
54
|
+
`;
|
|
55
|
+
export { OverlayArrow };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { FlipOptions, Middleware, Padding, Placement, Platform, ShiftOptions } from '@floating-ui/react-dom';
|
|
3
|
+
/**
|
|
4
|
+
* Where to place an overlay relative to its trigger. The `auto` positions
|
|
5
|
+
* pick whichever side has the most space.
|
|
6
|
+
*/
|
|
7
|
+
export type OverlayPlacement = Placement | 'auto' | 'auto-start' | 'auto-end';
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a requested position to the placement passed to Floating UI and
|
|
10
|
+
* the middleware that may change it: `autoPlacement()` for the `auto`
|
|
11
|
+
* positions, otherwise `flipOverlay()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function placementMiddleware(position: OverlayPlacement, flipOptions?: FlipOptions): {
|
|
14
|
+
middleware: Middleware;
|
|
15
|
+
placement: Placement;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Floating UI's `flip()`, but when no placement fits on its main axis the
|
|
19
|
+
* requested placement is kept instead of guessing the best fit.
|
|
20
|
+
*/
|
|
21
|
+
export declare function flipOverlay(options?: FlipOptions): Middleware;
|
|
22
|
+
export interface OverlayAnchor {
|
|
23
|
+
bottom?: number;
|
|
24
|
+
right?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Anchors the overlay by the edges nearest its trigger, the way Popper's
|
|
28
|
+
* adaptive styles did. An overlay whose content changes size, such as a
|
|
29
|
+
* hovercard that finishes loading, then grows away from its trigger instead of
|
|
30
|
+
* over it until it is repositioned. Apply the result with `anchoredStyles()`.
|
|
31
|
+
*
|
|
32
|
+
* Must be the last middleware, so it sees the final position.
|
|
33
|
+
*/
|
|
34
|
+
export declare const anchorOverlay: Middleware;
|
|
35
|
+
/**
|
|
36
|
+
* Floating UI's `floatingStyles`, positioned by the edges `anchorOverlay()`
|
|
37
|
+
* chose.
|
|
38
|
+
*/
|
|
39
|
+
export declare function anchoredStyles(floatingStyles: React.CSSProperties, anchor: OverlayAnchor | undefined): React.CSSProperties;
|
|
40
|
+
/**
|
|
41
|
+
* Floating UI's `arrow()`, pointing the overlay's `OverlayArrow` at its trigger.
|
|
42
|
+
*/
|
|
43
|
+
export declare function arrowOverlay(options?: {
|
|
44
|
+
padding?: Padding;
|
|
45
|
+
}): Middleware;
|
|
46
|
+
export interface ShiftOverlayOptions extends ShiftOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Stop the overlay from shifting so far that it detaches from its trigger.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
tether?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Floating UI's `shift()`, by default limited so the overlay never shifts so
|
|
55
|
+
* far that it detaches from its trigger. With an arrow, enough of the overlay
|
|
56
|
+
* stays beside the trigger for the arrow to point at it.
|
|
57
|
+
*
|
|
58
|
+
* Unlike `limitShift()`, this only limits how far the overlay is shifted. An
|
|
59
|
+
* offset that already places the overlay away from its trigger is kept.
|
|
60
|
+
*/
|
|
61
|
+
export declare function shiftOverlay(options?: ShiftOverlayOptions): Middleware;
|
|
62
|
+
/**
|
|
63
|
+
* Floating UI's platform, except that the default `clippingAncestors` boundary
|
|
64
|
+
* only includes ancestors that contain the overlay's offset parent, as Popper
|
|
65
|
+
* did. Floating UI treats a positioned `display: contents` element as the
|
|
66
|
+
* overlay's containing block, even though it has no box. Overflow ancestors
|
|
67
|
+
* between it and the real containing block then clamp the overlay's size
|
|
68
|
+
* without clipping it, e.g. a `DropdownMenu` inside a `ButtonBar`.
|
|
69
|
+
*/
|
|
70
|
+
export declare const overlayPlatform: Platform;
|