@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,69 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { DescriptionList } from "../descriptionList/index.js";
|
|
3
|
+
import { InfoText } from "../info/index.js";
|
|
4
|
+
import { Container, Stack } from "../layout/index.js";
|
|
5
|
+
import { Text } from "../text/index.js";
|
|
6
|
+
import { BaseLayout, LayoutLabel } from "./base.js";
|
|
7
|
+
import { useStackedLayout } from "./useStackedLayout.js";
|
|
8
|
+
function RowDisplay(props) {
|
|
9
|
+
const stacked = useStackedLayout();
|
|
10
|
+
return /*#__PURE__*/ jsx(DisplayLayout, {
|
|
11
|
+
...props,
|
|
12
|
+
stacked: stacked
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function StackDisplay(props) {
|
|
16
|
+
return /*#__PURE__*/ jsx(DisplayLayout, {
|
|
17
|
+
...props,
|
|
18
|
+
stacked: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function DisplayLayout({ children, label, hintText, padding, variant, stacked }) {
|
|
22
|
+
const compact = 'compact' === variant;
|
|
23
|
+
const hint = hintText && !compact ? /*#__PURE__*/ jsx(Text, {
|
|
24
|
+
size: "sm",
|
|
25
|
+
variant: "muted",
|
|
26
|
+
children: hintText
|
|
27
|
+
}) : null;
|
|
28
|
+
return /*#__PURE__*/ jsxs(BaseLayout, {
|
|
29
|
+
as: "dl",
|
|
30
|
+
stacked: stacked,
|
|
31
|
+
padding: padding,
|
|
32
|
+
margin: "0",
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx(LayoutLabel, {
|
|
35
|
+
stacked: stacked,
|
|
36
|
+
children: (labelProps)=>/*#__PURE__*/ jsxs(DescriptionList.Term, {
|
|
37
|
+
...labelProps,
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ jsx(Text, {
|
|
40
|
+
children: compact && hintText ? /*#__PURE__*/ jsx(InfoText, {
|
|
41
|
+
title: hintText,
|
|
42
|
+
children: label
|
|
43
|
+
}) : label
|
|
44
|
+
}),
|
|
45
|
+
!stacked && hint
|
|
46
|
+
]
|
|
47
|
+
})
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ jsx(Container, {
|
|
50
|
+
flexGrow: 1,
|
|
51
|
+
children: (valueProps)=>/*#__PURE__*/ jsx(DescriptionList.Details, {
|
|
52
|
+
...valueProps,
|
|
53
|
+
children: /*#__PURE__*/ jsxs(Stack, {
|
|
54
|
+
gap: "md",
|
|
55
|
+
children: [
|
|
56
|
+
children,
|
|
57
|
+
stacked && hint
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const DisplayField = {
|
|
66
|
+
Row: RowDisplay,
|
|
67
|
+
Stack: StackDisplay
|
|
68
|
+
};
|
|
69
|
+
export { DisplayField };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useFieldContext } from "./formContext.js";
|
|
2
|
+
const useFieldId = ()=>{
|
|
3
|
+
const field = useFieldContext();
|
|
4
|
+
return field.form.formId + field.name;
|
|
5
|
+
};
|
|
6
|
+
const useHintTextId = ()=>{
|
|
7
|
+
const fieldId = useFieldId();
|
|
8
|
+
return `${fieldId}-hint`;
|
|
9
|
+
};
|
|
10
|
+
const useLabelId = ()=>{
|
|
11
|
+
const fieldId = useFieldId();
|
|
12
|
+
return `${fieldId}-label`;
|
|
13
|
+
};
|
|
14
|
+
export { useFieldId, useHintTextId, useLabelId };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type FlexProps } from '../layout/index.js';
|
|
3
|
+
interface LayoutProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
hintText?: React.ReactNode;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
variant?: 'compact';
|
|
9
|
+
}
|
|
10
|
+
interface RowLayoutProps extends LayoutProps {
|
|
11
|
+
padding?: FlexProps['padding'];
|
|
12
|
+
}
|
|
13
|
+
interface StackLayoutProps extends LayoutProps {
|
|
14
|
+
align?: FlexProps['align'];
|
|
15
|
+
}
|
|
16
|
+
declare function RowLayout(props: RowLayoutProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare function StackLayout(props: StackLayoutProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function FieldLayout(): null;
|
|
19
|
+
export declare namespace FieldLayout {
|
|
20
|
+
var Row: typeof RowLayout;
|
|
21
|
+
var Stack: typeof StackLayout;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Container, Flex } from "../layout/index.js";
|
|
3
|
+
import { BaseLayout, LayoutLabel } from "./base.js";
|
|
4
|
+
import { useFieldContext } from "./formContext.js";
|
|
5
|
+
import { FieldMeta } from "./meta.js";
|
|
6
|
+
import { useStackedLayout } from "./useStackedLayout.js";
|
|
7
|
+
function RowLayout(props) {
|
|
8
|
+
const isStackLayout = useStackedLayout();
|
|
9
|
+
return isStackLayout ? /*#__PURE__*/ jsx(StackLayout, {
|
|
10
|
+
...props
|
|
11
|
+
}) : /*#__PURE__*/ jsx(RowLayoutContent, {
|
|
12
|
+
...props
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function RowLayoutContent(props) {
|
|
16
|
+
const isCompact = 'compact' === props.variant;
|
|
17
|
+
const field = useFieldContext();
|
|
18
|
+
return /*#__PURE__*/ jsxs(BaseLayout, {
|
|
19
|
+
id: field.name,
|
|
20
|
+
stacked: false,
|
|
21
|
+
padding: props.padding,
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsxs(LayoutLabel, {
|
|
24
|
+
stacked: false,
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ jsx(Flex, {
|
|
27
|
+
gap: "xs",
|
|
28
|
+
align: "center",
|
|
29
|
+
children: /*#__PURE__*/ jsx(FieldMeta.Label, {
|
|
30
|
+
required: props.required,
|
|
31
|
+
description: isCompact ? props.hintText : void 0,
|
|
32
|
+
children: props.label
|
|
33
|
+
})
|
|
34
|
+
}),
|
|
35
|
+
props.hintText && !isCompact ? /*#__PURE__*/ jsx(FieldMeta.HintText, {
|
|
36
|
+
children: props.hintText
|
|
37
|
+
}) : null
|
|
38
|
+
]
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ jsx(Container, {
|
|
41
|
+
flexGrow: 1,
|
|
42
|
+
children: props.children
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function StackLayout(props) {
|
|
48
|
+
const isCompact = 'compact' === props.variant;
|
|
49
|
+
const field = useFieldContext();
|
|
50
|
+
return /*#__PURE__*/ jsxs(BaseLayout, {
|
|
51
|
+
id: field.name,
|
|
52
|
+
stacked: true,
|
|
53
|
+
align: props.align,
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ jsx(Flex, {
|
|
56
|
+
gap: "xs",
|
|
57
|
+
align: "center",
|
|
58
|
+
children: /*#__PURE__*/ jsx(FieldMeta.Label, {
|
|
59
|
+
required: props.required,
|
|
60
|
+
description: isCompact ? props.hintText : void 0,
|
|
61
|
+
children: props.label
|
|
62
|
+
})
|
|
63
|
+
}),
|
|
64
|
+
props.children,
|
|
65
|
+
props.hintText && !isCompact ? /*#__PURE__*/ jsx(FieldMeta.HintText, {
|
|
66
|
+
children: props.hintText
|
|
67
|
+
}) : null
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function FieldLayout() {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
FieldLayout.Row = RowLayout;
|
|
75
|
+
FieldLayout.Stack = StackLayout;
|
|
76
|
+
export { FieldLayout };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const fieldContext: import("react").Context<import("@tanstack/react-form").AnyFieldApi>, formContext: import("react").Context<import("@tanstack/react-form").AnyFormApi>, useFormContext: () => import("@tanstack/react-form").ReactFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>, useFieldContext: <TData>() => import("@tanstack/react-form").FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
2
|
+
declare const FormElementContext: import("react").Context<boolean>;
|
|
3
|
+
declare const useIsInsideFormElement: () => boolean;
|
|
4
|
+
export { fieldContext, formContext, useFormContext, useFieldContext, FormElementContext, useIsInsideFormElement, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import { createFormHookContexts } from "@tanstack/react-form";
|
|
3
|
+
const { fieldContext: fieldContext, formContext: formContext, useFormContext: useFormContext, useFieldContext: useFieldContext } = createFormHookContexts();
|
|
4
|
+
const FormElementContext = createContext(false);
|
|
5
|
+
const useIsInsideFormElement = ()=>useContext(FormElementContext);
|
|
6
|
+
export { FormElementContext, fieldContext, formContext, useFieldContext, useFormContext, useIsInsideFormElement };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface GroupContextValue {
|
|
3
|
+
'aria-invalid': boolean;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
isChecked: (value: string) => boolean;
|
|
6
|
+
name: string;
|
|
7
|
+
onChange: (value: string, checked: boolean) => void;
|
|
8
|
+
'aria-describedby'?: string;
|
|
9
|
+
onBlur?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function GroupProvider({ children, value, }: {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
value: GroupContextValue;
|
|
14
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function useGroupContext(): GroupContextValue | null;
|
|
16
|
+
export declare function useGroupItemContext(value: string): {
|
|
17
|
+
checked: boolean;
|
|
18
|
+
'aria-invalid': boolean;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
name: string;
|
|
21
|
+
onChange: (value: string, checked: boolean) => void;
|
|
22
|
+
'aria-describedby'?: string;
|
|
23
|
+
onBlur?: () => void;
|
|
24
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const GroupContext = /*#__PURE__*/ createContext(null);
|
|
4
|
+
function GroupProvider({ children, value }) {
|
|
5
|
+
return /*#__PURE__*/ jsx(GroupContext, {
|
|
6
|
+
value: value,
|
|
7
|
+
children: children
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function useGroupContext() {
|
|
11
|
+
return useContext(GroupContext);
|
|
12
|
+
}
|
|
13
|
+
function useGroupItemContext(value) {
|
|
14
|
+
const context = useGroupContext();
|
|
15
|
+
if (!context) throw new Error('Group items must be used within a form field group');
|
|
16
|
+
const { isChecked, ...fieldProps } = context;
|
|
17
|
+
return {
|
|
18
|
+
...fieldProps,
|
|
19
|
+
checked: isChecked(value)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { GroupProvider, useGroupContext, useGroupItemContext };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const Spinner: import("@emotion/styled").StyledComponent<{
|
|
2
|
+
theme?: import("@emotion/react").Theme;
|
|
3
|
+
as?: React.ElementType;
|
|
4
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
5
|
+
export declare const Checkmark: import("@emotion/styled").StyledComponent<import("@sentry/icons/svgIcon").SVGIconProps & {
|
|
6
|
+
theme?: import("@emotion/react").Theme;
|
|
7
|
+
}, {}, {}>;
|
|
8
|
+
export declare const Warning: import("@emotion/styled").StyledComponent<import("@sentry/icons/svgIcon").SVGIconProps & {
|
|
9
|
+
theme?: import("@emotion/react").Theme;
|
|
10
|
+
}, {}, {}>;
|
|
11
|
+
export declare function RequiredIndicator(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { keyframes } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
6
|
+
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
7
|
+
import { IconWarning } from "@sentry/icons/warning";
|
|
8
|
+
const fadeOut = keyframes`
|
|
9
|
+
0% { opacity: 1; }
|
|
10
|
+
100% { opacity: 0; }
|
|
11
|
+
`;
|
|
12
|
+
const pulse = keyframes`
|
|
13
|
+
0%, 100% { transform: scale(1, 1); }
|
|
14
|
+
50% { transform: scale(1.15, 1.15); }
|
|
15
|
+
`;
|
|
16
|
+
const spin = keyframes`
|
|
17
|
+
0% {
|
|
18
|
+
transform: rotate(0deg);
|
|
19
|
+
}
|
|
20
|
+
100% {
|
|
21
|
+
transform: rotate(360deg);
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const Spinner = styled('div')`
|
|
25
|
+
animation: ${spin} 0.4s linear infinite;
|
|
26
|
+
width: 14px;
|
|
27
|
+
height: 14px;
|
|
28
|
+
border-radius: 50%;
|
|
29
|
+
border: 2px solid ${(p)=>p.theme.tokens.border.transparent.neutral.muted};
|
|
30
|
+
border-left-color: ${(p)=>p.theme.tokens.border.accent.vibrant};
|
|
31
|
+
margin-left: 0;
|
|
32
|
+
`;
|
|
33
|
+
const Checkmark = styled(IconCheckmark)`
|
|
34
|
+
animation: ${fadeOut} 0.3s ease 2s 1 forwards;
|
|
35
|
+
`;
|
|
36
|
+
const Warning = styled(IconWarning)`
|
|
37
|
+
animation: ${pulse} 1s ease infinite;
|
|
38
|
+
`;
|
|
39
|
+
const RequiredIndicatorBase = styled('div')`
|
|
40
|
+
display: inline-block;
|
|
41
|
+
background: ${(p)=>p.theme.colors.red400};
|
|
42
|
+
opacity: 0.6;
|
|
43
|
+
width: 5px;
|
|
44
|
+
height: 5px;
|
|
45
|
+
border-radius: 5px;
|
|
46
|
+
text-indent: -9999em;
|
|
47
|
+
vertical-align: super;
|
|
48
|
+
`;
|
|
49
|
+
function RequiredIndicator() {
|
|
50
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ jsx(RequiredIndicatorBase, {
|
|
53
|
+
"aria-hidden": true
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx(VisuallyHidden, {
|
|
56
|
+
children: "(required)"
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export { Checkmark, RequiredIndicator, Spinner, Warning };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AutoSaveContextProvider, useAutoSaveContext } from './autoSaveContext.js';
|
|
2
|
+
export { DisplayField } from './displayField.js';
|
|
3
|
+
export { useFieldId, useHintTextId, useLabelId } from './fieldIds.js';
|
|
4
|
+
export { GroupProvider, useGroupItemContext, type GroupContextValue } from './groupContext.js';
|
|
5
|
+
export { FieldMeta } from './meta.js';
|
|
6
|
+
export { fieldContext, formContext, useFormContext, useFieldContext, FormElementContext, useIsInsideFormElement, } from './formContext.js';
|
|
7
|
+
export { Checkmark, Spinner } from './icons.js';
|
|
8
|
+
export { FieldLayout } from './fieldLayout.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AutoSaveContextProvider, useAutoSaveContext } from "./autoSaveContext.js";
|
|
2
|
+
export { DisplayField } from "./displayField.js";
|
|
3
|
+
export { useFieldId, useHintTextId, useLabelId } from "./fieldIds.js";
|
|
4
|
+
export { GroupProvider, useGroupItemContext } from "./groupContext.js";
|
|
5
|
+
export { FieldMeta } from "./meta.js";
|
|
6
|
+
export { FormElementContext, fieldContext, formContext, useFieldContext, useFormContext, useIsInsideFormElement } from "./formContext.js";
|
|
7
|
+
export { Checkmark, Spinner } from "./icons.js";
|
|
8
|
+
export { FieldLayout } from "./fieldLayout.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
declare function FieldStatus({ disabled, error }: {
|
|
3
|
+
disabled?: boolean | string;
|
|
4
|
+
error?: string;
|
|
5
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare function FieldMeta(): null;
|
|
7
|
+
export declare namespace FieldMeta {
|
|
8
|
+
var Label: (props: {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
|
+
var HintText: (props: {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
16
|
+
var Status: typeof FieldStatus;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
3
|
+
import { DisabledTip, InfoText } from "../info/index.js";
|
|
4
|
+
import { Container, Flex } from "../layout/index.js";
|
|
5
|
+
import { Text } from "../text/index.js";
|
|
6
|
+
import { Tooltip } from "../tooltip/index.js";
|
|
7
|
+
import { useFieldId, useHintTextId, useLabelId } from "./fieldIds.js";
|
|
8
|
+
import { useFieldContext } from "./formContext.js";
|
|
9
|
+
import { useGroupContext } from "./groupContext.js";
|
|
10
|
+
import { RequiredIndicator, Warning } from "./icons.js";
|
|
11
|
+
function HintText(props) {
|
|
12
|
+
const id = useHintTextId();
|
|
13
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
14
|
+
width: "fit-content",
|
|
15
|
+
children: (containerProps)=>/*#__PURE__*/ jsx(Text, {
|
|
16
|
+
...containerProps,
|
|
17
|
+
size: "sm",
|
|
18
|
+
variant: "muted",
|
|
19
|
+
id: id,
|
|
20
|
+
children: props.children
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function Label(props) {
|
|
25
|
+
const fieldId = useFieldId();
|
|
26
|
+
const hintTextId = useHintTextId();
|
|
27
|
+
const labelId = useLabelId();
|
|
28
|
+
const isGroup = useGroupContext();
|
|
29
|
+
const labelContent = props.description ? /*#__PURE__*/ jsx(InfoText, {
|
|
30
|
+
title: props.description,
|
|
31
|
+
children: props.children
|
|
32
|
+
}) : props.children;
|
|
33
|
+
const labelProps = isGroup ? {
|
|
34
|
+
as: 'span',
|
|
35
|
+
cursor: 'default',
|
|
36
|
+
id: labelId
|
|
37
|
+
} : {
|
|
38
|
+
as: 'label',
|
|
39
|
+
htmlFor: fieldId,
|
|
40
|
+
id: labelId
|
|
41
|
+
};
|
|
42
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
43
|
+
width: "fit-content",
|
|
44
|
+
children: (containerProps)=>/*#__PURE__*/ jsxs(Flex, {
|
|
45
|
+
gap: "xs",
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ jsx(Text, {
|
|
48
|
+
...containerProps,
|
|
49
|
+
...labelProps,
|
|
50
|
+
bold: false,
|
|
51
|
+
children: labelContent
|
|
52
|
+
}),
|
|
53
|
+
props.required ? /*#__PURE__*/ jsx(RequiredIndicator, {}) : null,
|
|
54
|
+
props.description ? /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
55
|
+
id: hintTextId,
|
|
56
|
+
children: props.description
|
|
57
|
+
}) : null
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function FieldStatus({ disabled, error }) {
|
|
63
|
+
const field = useFieldContext();
|
|
64
|
+
const errorMessage = error ?? (field.state.meta.isValid ? void 0 : field.state.meta.errors.map((e)=>e?.message).join(','));
|
|
65
|
+
if (errorMessage) return /*#__PURE__*/ jsx(Tooltip, {
|
|
66
|
+
position: "bottom",
|
|
67
|
+
title: errorMessage,
|
|
68
|
+
forceVisible: true,
|
|
69
|
+
skipWrapper: true,
|
|
70
|
+
children: /*#__PURE__*/ jsx(Warning, {
|
|
71
|
+
variant: "danger",
|
|
72
|
+
size: "sm"
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
const disabledReason = 'string' == typeof disabled ? disabled : void 0;
|
|
76
|
+
if (disabledReason) return /*#__PURE__*/ jsx(DisabledTip, {
|
|
77
|
+
title: disabledReason,
|
|
78
|
+
size: "sm"
|
|
79
|
+
});
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function FieldMeta() {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
FieldMeta.Label = Label;
|
|
86
|
+
FieldMeta.HintText = HintText;
|
|
87
|
+
FieldMeta.Status = FieldStatus;
|
|
88
|
+
export { FieldMeta };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useStackedLayout(): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useHasContainerQuery, useResponsivePropValue } from "../layout/index.js";
|
|
2
|
+
function useStackedLayout() {
|
|
3
|
+
const isStackAtBreakpoint = useResponsivePropValue({
|
|
4
|
+
zero: true,
|
|
5
|
+
md: false
|
|
6
|
+
});
|
|
7
|
+
return useHasContainerQuery() && isStackAtBreakpoint;
|
|
8
|
+
}
|
|
9
|
+
export { useStackedLayout };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface HotkeyProps {
|
|
2
|
+
/**
|
|
3
|
+
* Key combination string(s) in the same format as `useHotkeys` match strings.
|
|
4
|
+
* Keys are separated by `+`. For example: `"command+k"`, `"shift+enter"`.
|
|
5
|
+
*
|
|
6
|
+
* Platform modifiers are mapped automatically:
|
|
7
|
+
* - `command` renders as `⌘` on Mac, `CTRL` on other platforms
|
|
8
|
+
* - `ctrl` renders as `⌃` on Mac, `CTRL` on other platforms
|
|
9
|
+
* - `alt`/`option` renders as `⌥` on Mac, `ALT` on other platforms
|
|
10
|
+
*
|
|
11
|
+
* Pass an array only when the actual keys differ across platforms
|
|
12
|
+
* (not just modifier names). The first compatible combo is used:
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Hotkey value={['command+backspace', 'delete']} />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
value: string | string[];
|
|
19
|
+
variant?: 'embossed' | 'debossed';
|
|
20
|
+
}
|
|
21
|
+
export declare function Hotkey({ value, variant }: HotkeyProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Kbd } from "./kbd.js";
|
|
4
|
+
import { resolveKeyGlyph } from "./keyMappings.js";
|
|
5
|
+
function Hotkey({ value, variant }) {
|
|
6
|
+
const keySets = (Array.isArray(value) ? value : [
|
|
7
|
+
value
|
|
8
|
+
]).map((v)=>v.trim().split('+'));
|
|
9
|
+
const resolved = keySets.map((keys)=>keys.map((key)=>resolveKeyGlyph(key)));
|
|
10
|
+
const finalKeys = resolved[0];
|
|
11
|
+
if (!finalKeys || 0 === finalKeys.length) return null;
|
|
12
|
+
return /*#__PURE__*/ jsx(WrapperKbd, {
|
|
13
|
+
variant: variant,
|
|
14
|
+
children: finalKeys.map((glyph, i)=>'icon' in glyph ? /*#__PURE__*/ jsx(StyledKbd, {
|
|
15
|
+
"aria-label": glyph.label,
|
|
16
|
+
children: glyph.icon
|
|
17
|
+
}, i) : /*#__PURE__*/ jsx(StyledKbd, {
|
|
18
|
+
children: glyph.label
|
|
19
|
+
}, i))
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const WrapperKbd = styled(Kbd)`
|
|
23
|
+
padding: 0 ${(p)=>p.theme.space.xs};
|
|
24
|
+
gap: ${(p)=>p.theme.space['2xs']};
|
|
25
|
+
`;
|
|
26
|
+
const StyledKbd = styled('kbd')`
|
|
27
|
+
scale: 0.9;
|
|
28
|
+
color: inherit;
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
font-family: inherit;
|
|
35
|
+
font-size: inherit;
|
|
36
|
+
background: none;
|
|
37
|
+
border: 0;
|
|
38
|
+
border-radius: 0;
|
|
39
|
+
box-shadow: none;
|
|
40
|
+
`;
|
|
41
|
+
export { Hotkey };
|
package/dist/hotkey/kbd.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
1
2
|
import type { Theme } from '../theme/index.js';
|
|
2
3
|
export declare const kbdStyles: (theme: Theme, variant?: KbdProps["variant"]) => import("@emotion/react").SerializedStyles;
|
|
3
4
|
interface KbdProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export declare function canonicalize(keyName: string): string;
|
|
3
|
+
export declare const MODIFIER_KEYS: readonly ["command", "shift", "control", "alt"];
|
|
4
|
+
/**
|
|
5
|
+
* Tests whether a single key name from a hotkey match string is currently
|
|
6
|
+
* pressed in the given keyboard event. Layout-aware: matches against
|
|
7
|
+
* `event.key` (so an AZERTY user pressing the K-labeled key fires `'k'`
|
|
8
|
+
* shortcuts) with `event.code` as a physical-position fallback (so
|
|
9
|
+
* `shift+1` works even though `event.key === '!'` on US QWERTY).
|
|
10
|
+
*/
|
|
11
|
+
export declare function matchesKey(name: string, event: KeyboardEvent): boolean;
|
|
12
|
+
type KeyGlyph = {
|
|
13
|
+
icon: React.ReactNode;
|
|
14
|
+
label: string;
|
|
15
|
+
} | {
|
|
16
|
+
label: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a key name to its display glyph for the given platform.
|
|
20
|
+
* Non-special keys fall through to title-cased text (e.g. `'k'` → `'K'`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveKeyGlyph(keyName: string): KeyGlyph;
|
|
23
|
+
export {};
|