@sentry/scraps 0.3.0 → 0.4.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 (43) hide show
  1. package/dist/layout/styles.d.ts +1 -1
  2. package/dist/menu/controlContext.d.ts +32 -0
  3. package/dist/menu/controlContext.js +7 -0
  4. package/dist/menu/dropdownButton.d.ts +18 -0
  5. package/dist/menu/dropdownButton.js +66 -0
  6. package/dist/menu/index.d.ts +7 -0
  7. package/dist/menu/index.js +3 -0
  8. package/dist/menu/menu.d.ts +159 -0
  9. package/dist/menu/menu.js +464 -0
  10. package/dist/menu/selectTypes.d.ts +96 -0
  11. package/dist/menu/selectTypes.js +0 -0
  12. package/dist/menu/selectValue.d.ts +13 -0
  13. package/dist/menu/selectValue.js +0 -0
  14. package/dist/overlayTrigger.d.ts +22 -0
  15. package/dist/overlayTrigger.js +30 -0
  16. package/dist/slot/knownContexts.d.ts +1 -1
  17. package/dist/spinner/index.d.ts +1 -0
  18. package/dist/spinner/index.js +1 -0
  19. package/dist/spinner/spinner.d.ts +14 -0
  20. package/dist/spinner/spinner.js +126 -0
  21. package/dist/splitPanel/index.d.ts +1 -0
  22. package/dist/splitPanel/index.js +1 -0
  23. package/dist/splitPanel/splitPanel.d.ts +36 -0
  24. package/dist/splitPanel/splitPanel.js +144 -0
  25. package/dist/toast/index.d.ts +5 -0
  26. package/dist/toast/index.js +4 -0
  27. package/dist/toast/toast.d.ts +10 -0
  28. package/dist/toast/toast.js +182 -0
  29. package/dist/toast/toastApi.d.ts +10 -0
  30. package/dist/toast/toastApi.js +53 -0
  31. package/dist/toast/toaster.d.ts +4 -0
  32. package/dist/toast/toaster.js +42 -0
  33. package/dist/toast/types.d.ts +17 -0
  34. package/dist/toast/types.js +2 -0
  35. package/dist/toggleCard/index.d.ts +1 -0
  36. package/dist/toggleCard/index.js +1 -0
  37. package/dist/toggleCard/toggleCard.d.ts +32 -0
  38. package/dist/toggleCard/toggleCard.js +301 -0
  39. package/dist/useDimensions.d.ts +12 -0
  40. package/dist/useDimensions.js +31 -0
  41. package/dist/useResizableDrawer.d.ts +72 -0
  42. package/dist/useResizableDrawer.js +136 -0
  43. package/package.json +34 -1
@@ -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<"xs" | "sm" | "md" | "2xs" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "zero" | "3xs" | "5xl" | null>;
80
+ export declare const ContainerQueryContext: import("react").Context<"2xs" | "xs" | "sm" | "md" | "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`),
@@ -0,0 +1,32 @@
1
+ import type { OverlayTriggerState } from '@react-stately/overlays';
2
+ import type { FormSize } from '../theme/index.js';
3
+ import type { SearchMatchResult, SelectKey, SelectOptionWithKey } from './selectTypes.js';
4
+ interface ControlContextValue {
5
+ overlayIsOpen: boolean;
6
+ /**
7
+ * Search string to determine whether an option should be rendered in the select list.
8
+ */
9
+ search: string;
10
+ /**
11
+ * Whether the select has a search input field.
12
+ */
13
+ searchable: boolean;
14
+ disabled?: boolean;
15
+ /**
16
+ * Whether the matched substring of each option's label should be highlighted
17
+ * as the user types.
18
+ */
19
+ highlightSearch?: boolean;
20
+ /**
21
+ * The control's overlay state. Useful for opening/closing the menu from inside the
22
+ * selector.
23
+ */
24
+ overlayState?: OverlayTriggerState;
25
+ /**
26
+ * Custom function to determine whether an option matches the search query.
27
+ */
28
+ searchMatcher?: (option: SelectOptionWithKey<SelectKey>, search: string) => SearchMatchResult;
29
+ size?: FormSize;
30
+ }
31
+ export declare const ControlContext: import("react").Context<ControlContextValue>;
32
+ export {};
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react";
2
+ const ControlContext = /*#__PURE__*/ createContext({
3
+ overlayIsOpen: false,
4
+ search: '',
5
+ searchable: false
6
+ });
7
+ export { ControlContext };
@@ -0,0 +1,18 @@
1
+ import type * as React from 'react';
2
+ import type { DistributedOmit } from 'type-fest';
3
+ import type { ButtonProps } from '../button/index.js';
4
+ export type DropdownButtonProps = DistributedOmit<ButtonProps, 'type' | 'prefix'> & {
5
+ /**
6
+ * Whether or not the button should render as open
7
+ */
8
+ isOpen?: boolean;
9
+ /**
10
+ * The fixed prefix text to show in the button eg: 'Sort By'
11
+ */
12
+ prefix?: React.ReactNode;
13
+ /**
14
+ * Should a chevron icon be shown?
15
+ */
16
+ showChevron?: boolean;
17
+ };
18
+ export declare function DropdownButton({ children, prefix, size: explicitSize, isOpen, showChevron, disabled, ref, onClick, ...props }: DropdownButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,66 @@
1
+ import { jsx, jsxs } 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 { Button } from "../button/index.js";
6
+ import { useResponsivePropValue } from "../layout/index.js";
7
+ import { useSizeContext } from "../sizeContext.js";
8
+ function DropdownButton({ children, prefix, size: explicitSize, isOpen = false, showChevron = true, disabled = false, ref, onClick, ...props }) {
9
+ const contextSize = useSizeContext();
10
+ const size = useResponsivePropValue(explicitSize ?? contextSize ?? 'md');
11
+ return /*#__PURE__*/ jsxs(StyledButton, {
12
+ "aria-haspopup": "true",
13
+ "aria-expanded": isOpen,
14
+ hasPrefix: !!prefix,
15
+ disabled: disabled,
16
+ isOpen: isOpen,
17
+ size: size,
18
+ ref: ref,
19
+ ...props,
20
+ onClick: (event)=>{
21
+ event.preventDefault();
22
+ event.stopPropagation();
23
+ onClick?.(event);
24
+ },
25
+ children: [
26
+ prefix && /*#__PURE__*/ jsx(LabelText, {
27
+ children: prefix
28
+ }),
29
+ children,
30
+ showChevron && /*#__PURE__*/ jsx(ChevronWrap, {
31
+ children: /*#__PURE__*/ jsx(IconChevron, {
32
+ variant: (props.variant ?? 'secondary') === 'secondary' ? 'muted' : void 0,
33
+ direction: isOpen ? 'up' : 'down',
34
+ size: 'zero' === size || 'xs' === size ? 'xs' : 'sm'
35
+ })
36
+ })
37
+ ]
38
+ });
39
+ }
40
+ const ChevronWrap = styled('div')`
41
+ display: flex;
42
+ align-items: center;
43
+ margin-left: auto;
44
+ padding-left: ${(p)=>p.theme.space.xs};
45
+ flex-shrink: 0;
46
+ `;
47
+ const StyledButton = styled(Button)`
48
+ position: relative;
49
+ max-width: 100%;
50
+
51
+ ${(p)=>(p.isOpen || p.disabled) && css`
52
+ box-shadow: none;
53
+ `}
54
+ ${(p)=>p.hasPrefix && css`
55
+ font-weight: ${p.theme.font.weight.sans.regular};
56
+ `}
57
+ `;
58
+ const LabelText = styled('span')`
59
+ &:after {
60
+ content: ':';
61
+ }
62
+
63
+ font-weight: ${(p)=>p.theme.font.weight.sans.medium};
64
+ padding-right: ${(p)=>p.theme.space.sm};
65
+ `;
66
+ export { DropdownButton };
@@ -0,0 +1,7 @@
1
+ /** Shared presentation; consumers own state, keyboard behavior, and ARIA roles. */
2
+ export { calculateMenuMinHeight, MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuSectionLabel as SectionLabel, MenuSectionHeader as SectionHeader, MenuSectionGroup as SectionGroup, MenuSectionList as SectionList, MenuListItem as ListItem, ReserveLeadingSlot, MenuSectionSeparator as SectionSeparator, SearchInput as Search, useReserveLeadingSlot, } from './menu.js';
3
+ export type { ListItemProps, MenuItemTrailingAction } from './menu.js';
4
+ export { ControlContext } from './controlContext.js';
5
+ export { DropdownButton, type DropdownButtonProps } from './dropdownButton.js';
6
+ export type { SelectValue } from './selectValue.js';
7
+ export type * from './selectTypes.js';
@@ -0,0 +1,3 @@
1
+ export { MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuListItem as ListItem, MenuSectionGroup as SectionGroup, MenuSectionHeader as SectionHeader, MenuSectionLabel as SectionLabel, MenuSectionList as SectionList, MenuSectionSeparator as SectionSeparator, ReserveLeadingSlot, SearchInput as Search, calculateMenuMinHeight, useReserveLeadingSlot } from "./menu.js";
2
+ export { ControlContext } from "./controlContext.js";
3
+ export { DropdownButton } from "./dropdownButton.js";
@@ -0,0 +1,159 @@
1
+ import type * as React from 'react';
2
+ import { InputGroup } from '../input/index.js';
3
+ import { type FlexProps } from '../layout/index.js';
4
+ import type { ContainerProps } from '../layout/container.js';
5
+ import type { FormSize } from '../theme/index.js';
6
+ import type { TooltipProps } from '../tooltip/index.js';
7
+ /** Caps a requested menu height by the space available to its overlay. */
8
+ export declare function calculateMenuMinHeight(first: string | number | undefined, second: string | number | undefined): string | undefined;
9
+ /** Container for a menu header, with a divider below it. */
10
+ export declare function MenuHeaderLayout(props: FlexProps): import("@emotion/react/jsx-runtime").JSX.Element;
11
+ /** Text style for the menu's main heading. */
12
+ export declare function MenuHeading({ children, padding, }: {
13
+ children: React.ReactNode;
14
+ padding?: ContainerProps['padding'];
15
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
16
+ /** Text style for a heading within a menu section. */
17
+ export declare function MenuSectionLabel({ children, padding, ...props }: Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'style'> & {
18
+ children: React.ReactNode;
19
+ padding?: ContainerProps['padding'];
20
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
21
+ /** Layout for a menu section heading and an optional action beside it. */
22
+ export declare function MenuSectionHeader({ children, trailingAction, ...props }: FlexProps & {
23
+ trailingAction?: React.ReactNode;
24
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
25
+ /** Divider between menu sections. */
26
+ export declare function MenuSectionSeparator(): import("@emotion/react/jsx-runtime").JSX.Element;
27
+ /** List item wrapper for a menu section. */
28
+ export declare function MenuSectionGroup(props: ContainerProps<'li'>): import("@emotion/react/jsx-runtime").JSX.Element;
29
+ /** List wrapper for the items within a menu section. */
30
+ export declare function MenuSectionList(props: ContainerProps<'ul'>): import("@emotion/react/jsx-runtime").JSX.Element;
31
+ /** Container for menu footer actions, with a divider above it. */
32
+ export declare function MenuFooterLayout(props: FlexProps): import("@emotion/react/jsx-runtime").JSX.Element;
33
+ type SearchInputProps = React.ComponentPropsWithRef<typeof InputGroup.Input> & {
34
+ padding?: ContainerProps['padding'];
35
+ };
36
+ /** Shared search field with a leading icon for menu controls. */
37
+ export declare function SearchInput({ padding, ...props }: SearchInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
38
+ /**
39
+ * When `reserve` is true, items without leading items render an empty leading
40
+ * slot, so their labels line up with items that have an icon. Menus should set
41
+ * it whenever any of their items renders leading items.
42
+ */
43
+ export declare function ReserveLeadingSlot({ reserve, children, }: {
44
+ children: React.ReactNode;
45
+ reserve: boolean;
46
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
47
+ /** Whether the surrounding menu reserves a leading slot for every item. */
48
+ export declare function useReserveLeadingSlot(): boolean;
49
+ /**
50
+ * Menu item priority. Determines the text and background color.
51
+ */
52
+ type Priority = 'primary' | 'danger' | 'default';
53
+ declare const StyledInnerWrap: import("@emotion/styled").StyledComponent<((FlexProps<import("../layout/container.js").ContainerElement> | import("../layout/flex.js").FlexPropsWithRenderFunction<import("../layout/container.js").ContainerElement>) & {
54
+ theme?: import("@emotion/react").Theme;
55
+ }) & {
56
+ disabled: boolean;
57
+ hasTrailingAction: boolean;
58
+ isFocused: boolean;
59
+ priority: Priority;
60
+ size?: FormSize;
61
+ }, {}, {}>;
62
+ declare const StyledDetails: import("@emotion/styled").StyledComponent<{
63
+ theme?: import("@emotion/react").Theme;
64
+ as?: React.ElementType;
65
+ } & {
66
+ disabled: boolean;
67
+ priority: Priority;
68
+ }, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
69
+ /**
70
+ * A renderable item. Either a React node, or a function that accepts properties
71
+ * of the item, and returns a React node. The function version is useful for
72
+ * lazily rendering supplementary content like training items and tooltips.
73
+ */
74
+ type ExtraContent = React.ReactNode | ((state: {
75
+ disabled: boolean;
76
+ isFocused: boolean;
77
+ isSelected: boolean;
78
+ }) => React.ReactNode);
79
+ /**
80
+ * An icon-only button rendered beside, rather than inside, the focusable menu
81
+ * item. The item reserves space for exactly one button, so the shape is limited
82
+ * to what that button needs.
83
+ */
84
+ export interface MenuItemTrailingAction {
85
+ icon: React.ReactNode;
86
+ /** Accessible name for the button, also shown as its tooltip. */
87
+ label: string;
88
+ onAction: () => void;
89
+ }
90
+ export type ListItemProps = {
91
+ /**
92
+ * Optional descriptive text. Like 'label', should preferably be a string or
93
+ * have appropriate aria-labels.
94
+ */
95
+ details?: ExtraContent;
96
+ /**
97
+ * Whether the item is disabled (if true, the item will be grayed out and
98
+ * non-interactive).
99
+ */
100
+ disabled?: boolean;
101
+ /**
102
+ * Item label. Should preferably be a string. If not, make sure that
103
+ * there are appropriate aria-labels.
104
+ */
105
+ label?: React.ReactNode;
106
+ /**
107
+ * Items to be added to the left of the label
108
+ */
109
+ leadingItems?: ExtraContent;
110
+ /**
111
+ * Accented text and background (on hover) colors.
112
+ */
113
+ priority?: Priority;
114
+ /**
115
+ * Whether to show the details in an overlay when the item is hovered / focused.
116
+ */
117
+ showDetailsInOverlay?: boolean;
118
+ /**
119
+ * Determines the item's font sizes and internal paddings.
120
+ */
121
+ size?: FormSize;
122
+ /**
123
+ * Optional tooltip that appears when the use hovers over the item. This is
124
+ * not very visible - if possible, add additional text via the `details`
125
+ * prop instead.
126
+ */
127
+ tooltip?: ExtraContent;
128
+ /**
129
+ * Additional props to be passed into <Tooltip />.
130
+ */
131
+ tooltipOptions?: Omit<TooltipProps, 'children' | 'title' | 'className'>;
132
+ /**
133
+ * Items to be added to the right of the label.
134
+ */
135
+ trailingItems?: ExtraContent;
136
+ };
137
+ interface OtherProps<T extends React.ElementType> {
138
+ as?: T;
139
+ detailsProps?: Partial<React.ComponentProps<typeof StyledDetails>>;
140
+ innerWrapProps?: Partial<React.ComponentProps<typeof StyledInnerWrap>>;
141
+ isFocused?: boolean;
142
+ isPressed?: boolean;
143
+ isSelected?: boolean;
144
+ labelProps?: {
145
+ as?: 'div' | 'p';
146
+ id?: string;
147
+ };
148
+ trailingAction?: MenuItemTrailingAction;
149
+ /** Ref to the trailing action's button. */
150
+ trailingActionRef?: React.Ref<HTMLButtonElement>;
151
+ /** Props for the wrapper around the trailing action. */
152
+ trailingActionWrapperProps?: React.ComponentPropsWithRef<'div'>;
153
+ }
154
+ interface MenuListItemProps<T extends React.ElementType = 'li'> extends ListItemProps, OtherProps<T> {
155
+ ref?: React.ComponentPropsWithRef<NoInfer<T>>['ref'];
156
+ }
157
+ /** Renders the shared visual shell for menu and select items. */
158
+ export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, tooltip, tooltipOptions, ref, trailingActionRef, trailingActionWrapperProps, ...props }: MenuListItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
159
+ export {};