@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.
Files changed (253) hide show
  1. package/README.md +13 -21
  2. package/dist/alert/alert.d.ts +25 -0
  3. package/dist/alert/alert.js +262 -0
  4. package/dist/alert/alertLink.d.ts +32 -0
  5. package/dist/alert/alertLink.js +94 -0
  6. package/dist/alert/index.d.ts +2 -0
  7. package/dist/alert/index.js +2 -0
  8. package/dist/backdrop/backdrop.d.ts +9 -0
  9. package/dist/backdrop/backdrop.js +28 -0
  10. package/dist/backdrop/index.d.ts +1 -0
  11. package/dist/backdrop/index.js +1 -0
  12. package/dist/badge/badge.d.ts +12 -0
  13. package/dist/badge/badge.js +80 -0
  14. package/dist/badge/featureBadge.d.ts +6 -0
  15. package/dist/badge/featureBadge.js +86 -0
  16. package/dist/badge/index.d.ts +3 -0
  17. package/dist/badge/index.js +3 -0
  18. package/dist/badge/tag.d.ts +15 -0
  19. package/dist/badge/tag.js +119 -0
  20. package/dist/boundaryContext.d.ts +2 -0
  21. package/dist/boundaryContext.js +5 -0
  22. package/dist/button/button.d.ts +3 -0
  23. package/dist/button/button.js +83 -0
  24. package/dist/button/buttonBar.d.ts +10 -0
  25. package/dist/button/buttonBar.js +141 -0
  26. package/dist/button/index.d.ts +5 -0
  27. package/dist/button/index.js +4 -0
  28. package/dist/button/linkButton.d.ts +3 -0
  29. package/dist/button/linkButton.js +110 -0
  30. package/dist/button/styles.d.ts +10 -0
  31. package/dist/button/styles.js +247 -0
  32. package/dist/button/types.d.ts +77 -0
  33. package/dist/button/types.js +0 -0
  34. package/dist/button/useButtonFunctionality.d.ts +5 -0
  35. package/dist/button/useButtonFunctionality.js +9 -0
  36. package/dist/checkbox/checkbox.d.ts +20 -0
  37. package/dist/checkbox/checkbox.js +193 -0
  38. package/dist/checkbox/index.d.ts +1 -0
  39. package/dist/checkbox/index.js +1 -0
  40. package/dist/chip/chip.d.ts +128 -0
  41. package/dist/chip/chip.js +364 -0
  42. package/dist/chip/index.d.ts +1 -0
  43. package/dist/chip/index.js +1 -0
  44. package/dist/code/inlineCode.d.ts +1 -0
  45. package/dist/datetime.d.ts +39 -0
  46. package/dist/datetime.js +20 -0
  47. package/dist/descriptionList/descriptionList.d.ts +69 -0
  48. package/dist/descriptionList/descriptionList.js +76 -0
  49. package/dist/descriptionList/index.d.ts +1 -0
  50. package/dist/descriptionList/index.js +1 -0
  51. package/dist/disclosure/disclosure.d.ts +37 -0
  52. package/dist/disclosure/disclosure.js +155 -0
  53. package/dist/disclosure/index.d.ts +1 -0
  54. package/dist/disclosure/index.js +1 -0
  55. package/dist/dragHandle/dragHandle.d.ts +34 -0
  56. package/dist/dragHandle/dragHandle.js +115 -0
  57. package/dist/dragHandle/index.d.ts +4 -0
  58. package/dist/dragHandle/index.js +4 -0
  59. package/dist/dragHandle/setDocumentDragging.d.ts +9 -0
  60. package/dist/dragHandle/setDocumentDragging.js +6 -0
  61. package/dist/dragHandle/useDragMove.d.ts +244 -0
  62. package/dist/dragHandle/useDragMove.js +66 -0
  63. package/dist/dragHandle/useDragSeparator.d.ts +256 -0
  64. package/dist/dragHandle/useDragSeparator.js +36 -0
  65. package/dist/emptyState/emptyState.d.ts +10 -0
  66. package/dist/emptyState/emptyState.js +81 -0
  67. package/dist/emptyState/index.d.ts +1 -0
  68. package/dist/emptyState/index.js +1 -0
  69. package/dist/formPresentation/autoSaveContext.d.ts +23 -0
  70. package/dist/formPresentation/autoSaveContext.js +13 -0
  71. package/dist/formPresentation/base.d.ts +11 -0
  72. package/dist/formPresentation/base.js +37 -0
  73. package/dist/formPresentation/displayField.d.ts +17 -0
  74. package/dist/formPresentation/displayField.js +69 -0
  75. package/dist/formPresentation/fieldIds.d.ts +3 -0
  76. package/dist/formPresentation/fieldIds.js +14 -0
  77. package/dist/formPresentation/fieldLayout.d.ts +23 -0
  78. package/dist/formPresentation/fieldLayout.js +76 -0
  79. package/dist/formPresentation/formContext.d.ts +4 -0
  80. package/dist/formPresentation/formContext.js +6 -0
  81. package/dist/formPresentation/groupContext.d.ts +24 -0
  82. package/dist/formPresentation/groupContext.js +22 -0
  83. package/dist/formPresentation/icons.d.ts +11 -0
  84. package/dist/formPresentation/icons.js +61 -0
  85. package/dist/formPresentation/index.d.ts +8 -0
  86. package/dist/formPresentation/index.js +8 -0
  87. package/dist/formPresentation/meta.d.ts +18 -0
  88. package/dist/formPresentation/meta.js +88 -0
  89. package/dist/formPresentation/useStackedLayout.d.ts +1 -0
  90. package/dist/formPresentation/useStackedLayout.js +9 -0
  91. package/dist/hotkey/hotkey.d.ts +22 -0
  92. package/dist/hotkey/hotkey.js +41 -0
  93. package/dist/hotkey/index.d.ts +4 -0
  94. package/dist/hotkey/index.js +3 -0
  95. package/dist/hotkey/kbd.d.ts +1 -0
  96. package/dist/hotkey/keyMappings.d.ts +23 -0
  97. package/dist/hotkey/keyMappings.js +223 -0
  98. package/dist/hotkey/useHotkeys.d.ts +47 -0
  99. package/dist/hotkey/useHotkeys.js +44 -0
  100. package/dist/image/image.d.ts +21 -0
  101. package/dist/image/image.js +20 -0
  102. package/dist/image/index.d.ts +1 -0
  103. package/dist/image/index.js +1 -0
  104. package/dist/info/index.d.ts +2 -0
  105. package/dist/info/index.js +2 -0
  106. package/dist/info/infoText.d.ts +15 -0
  107. package/dist/info/infoText.js +43 -0
  108. package/dist/info/infoTip.d.ts +10 -0
  109. package/dist/info/infoTip.js +54 -0
  110. package/dist/input/index.d.ts +8 -0
  111. package/dist/input/index.js +6 -0
  112. package/dist/input/input.d.ts +19 -0
  113. package/dist/input/input.js +14 -0
  114. package/dist/input/inputGroup.d.ts +29 -0
  115. package/dist/input/inputGroup.js +167 -0
  116. package/dist/input/inputStyles.d.ts +13 -0
  117. package/dist/input/inputStyles.js +52 -0
  118. package/dist/input/numberDragInput.d.ts +20 -0
  119. package/dist/input/numberDragInput.js +97 -0
  120. package/dist/input/numberInput.d.ts +10 -0
  121. package/dist/input/numberInput.js +94 -0
  122. package/dist/input/otpInput.d.ts +28 -0
  123. package/dist/input/otpInput.js +81 -0
  124. package/dist/input/useAutosizeInput.d.ts +17 -0
  125. package/dist/input/useAutosizeInput.js +56 -0
  126. package/dist/interactionStateLayer/index.d.ts +1 -0
  127. package/dist/interactionStateLayer/index.js +1 -0
  128. package/dist/interactionStateLayer/interactionStateLayer.d.ts +23 -0
  129. package/dist/interactionStateLayer/interactionStateLayer.js +67 -0
  130. package/dist/layout/flex.d.ts +1 -0
  131. package/dist/layout/grid.d.ts +1 -0
  132. package/dist/layout/index.d.ts +1 -1
  133. package/dist/layout/index.js +1 -1
  134. package/dist/layout/stack.d.ts +1 -0
  135. package/dist/layout/styles.d.ts +1 -1
  136. package/dist/layout/surface.d.ts +1 -0
  137. package/dist/link/index.d.ts +2 -0
  138. package/dist/link/index.js +2 -0
  139. package/dist/link/link.d.ts +43 -0
  140. package/dist/link/link.js +71 -0
  141. package/dist/link/linkBehaviorContext.d.ts +14 -0
  142. package/dist/link/linkBehaviorContext.js +31 -0
  143. package/dist/loader/indeterminateLoader.d.ts +1 -0
  144. package/dist/overlay.d.ts +59 -0
  145. package/dist/overlay.js +113 -0
  146. package/dist/overlayArrow.d.ts +9 -0
  147. package/dist/overlayArrow.js +55 -0
  148. package/dist/overlayPositioning.d.ts +70 -0
  149. package/dist/overlayPositioning.js +139 -0
  150. package/dist/panelProvider.d.ts +8 -0
  151. package/dist/panelProvider.js +20 -0
  152. package/dist/quote/quote.js +1 -1
  153. package/dist/radio/index.d.ts +1 -0
  154. package/dist/radio/index.js +1 -0
  155. package/dist/radio/radio.d.ts +9 -0
  156. package/dist/radio/radio.js +77 -0
  157. package/dist/renderToString.d.ts +2 -0
  158. package/dist/renderToString.js +25 -0
  159. package/dist/revealOnHover/index.d.ts +1 -0
  160. package/dist/revealOnHover/index.js +1 -0
  161. package/dist/revealOnHover/revealOnHover.d.ts +20 -0
  162. package/dist/revealOnHover/revealOnHover.js +62 -0
  163. package/dist/segmentedControl/index.d.ts +1 -0
  164. package/dist/segmentedControl/index.js +1 -0
  165. package/dist/segmentedControl/segmentedControl.d.ts +41 -0
  166. package/dist/segmentedControl/segmentedControl.js +217 -0
  167. package/dist/separator/separator.d.ts +4 -3
  168. package/dist/separator/separator.js +1 -1
  169. package/dist/sizeContext.d.ts +9 -0
  170. package/dist/sizeContext.js +13 -0
  171. package/dist/slider/index.d.ts +1 -0
  172. package/dist/slider/index.js +1 -0
  173. package/dist/slider/slider.d.ts +41 -0
  174. package/dist/slider/slider.js +386 -0
  175. package/dist/slot/index.d.ts +1 -0
  176. package/dist/slot/index.js +1 -0
  177. package/dist/slot/knownContexts.d.ts +1 -0
  178. package/dist/slot/knownContexts.js +7 -0
  179. package/dist/slot/slot.d.ts +26 -0
  180. package/dist/slot/slot.js +274 -0
  181. package/dist/statusIndicator/index.d.ts +1 -0
  182. package/dist/statusIndicator/index.js +1 -0
  183. package/dist/statusIndicator/statusIndicator.d.ts +24 -0
  184. package/dist/statusIndicator/statusIndicator.js +130 -0
  185. package/dist/switch/index.d.ts +1 -0
  186. package/dist/switch/index.js +1 -0
  187. package/dist/switch/switch.d.ts +6 -0
  188. package/dist/switch/switch.js +172 -0
  189. package/dist/table/index.d.ts +3 -0
  190. package/dist/table/index.js +3 -0
  191. package/dist/table/sortableHeaderCell.d.ts +36 -0
  192. package/dist/table/sortableHeaderCell.js +99 -0
  193. package/dist/table/styles.d.ts +46 -0
  194. package/dist/table/styles.js +93 -0
  195. package/dist/table/table.d.ts +64 -0
  196. package/dist/table/table.js +228 -0
  197. package/dist/table/useColumnResize.d.ts +27 -0
  198. package/dist/table/useColumnResize.js +62 -0
  199. package/dist/table/useObservedColumnSize.d.ts +12 -0
  200. package/dist/table/useObservedColumnSize.js +74 -0
  201. package/dist/text/heading.d.ts +2 -1
  202. package/dist/text/index.d.ts +1 -0
  203. package/dist/text/index.js +1 -0
  204. package/dist/text/prose.d.ts +8 -0
  205. package/dist/text/prose.js +45 -0
  206. package/dist/text/text.d.ts +8 -0
  207. package/dist/text/text.js +1 -1
  208. package/dist/textarea/index.d.ts +1 -0
  209. package/dist/textarea/index.js +1 -0
  210. package/dist/textarea/textarea.d.ts +22 -0
  211. package/dist/textarea/textarea.js +77 -0
  212. package/dist/theme/dark.d.ts +129 -10
  213. package/dist/theme/dark.js +41 -13
  214. package/dist/theme/index.d.ts +3 -12
  215. package/dist/theme/index.js +2 -2
  216. package/dist/theme/light.d.ts +129 -10
  217. package/dist/theme/light.js +42 -14
  218. package/dist/theme/swatch.d.ts +27 -0
  219. package/dist/theme/swatch.js +37 -0
  220. package/dist/theme/theme.d.ts +648 -0
  221. package/dist/theme/theme.js +780 -0
  222. package/dist/theme/types.d.ts +1 -0
  223. package/dist/theme/useInvertedTheme.d.ts +1 -0
  224. package/dist/theme/useInvertedTheme.js +7 -0
  225. package/dist/tooltip/index.d.ts +2 -0
  226. package/dist/tooltip/index.js +2 -0
  227. package/dist/tooltip/tooltip.d.ts +166 -0
  228. package/dist/tooltip/tooltip.js +181 -0
  229. package/dist/tooltip/useDisabledTooltip.d.ts +22 -0
  230. package/dist/tooltip/useDisabledTooltip.js +24 -0
  231. package/dist/trackingContext.d.ts +34 -0
  232. package/dist/trackingContext.js +29 -0
  233. package/dist/translation/index.d.ts +4 -0
  234. package/dist/translation/index.js +4 -0
  235. package/dist/translation/translationContext.d.ts +6 -0
  236. package/dist/translation/translationContext.js +6 -0
  237. package/dist/translation/useTranslation.d.ts +1 -0
  238. package/dist/translation/useTranslation.js +6 -0
  239. package/dist/unreachable.d.ts +1 -0
  240. package/dist/unreachable.js +4 -0
  241. package/dist/useHoverOverlay.d.ts +113 -0
  242. package/dist/useHoverOverlay.js +370 -0
  243. package/dist/useIsInsideInteractiveElement.d.ts +6 -0
  244. package/dist/useIsInsideInteractiveElement.js +31 -0
  245. package/dist/useOverlay.d.ts +82 -0
  246. package/dist/useOverlay.js +217 -0
  247. package/dist/useScrollLock.d.ts +5 -0
  248. package/dist/useScrollLock.js +100 -0
  249. package/dist/useStableMergeRef.d.ts +9 -0
  250. package/dist/useStableMergeRef.js +18 -0
  251. package/package.json +219 -11
  252. package/dist/index.d.ts +0 -9
  253. package/dist/index.js +0 -9
@@ -0,0 +1,167 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useLayoutEffect, useMemo, useState } from "react";
3
+ import { css } from "@emotion/react";
4
+ import styled from "@emotion/styled";
5
+ import { TextArea } from "../textarea/index.js";
6
+ import { Input } from "./input.js";
7
+ const InputItemsWrap = styled('div')`
8
+ display: grid;
9
+ grid-auto-flow: column;
10
+ align-items: center;
11
+ gap: ${(p)=>p.theme.space.md};
12
+
13
+ /* Do not use transform here to do alignment as it will create a new stacking
14
+ * context, breaking things like dropdown menus */
15
+ position: absolute;
16
+ top: 0;
17
+ bottom: 0;
18
+ `;
19
+ const itemsPadding = {
20
+ md: 8,
21
+ sm: 6,
22
+ xs: 4
23
+ };
24
+ const inputStyles = ({ leadingWidth, trailingWidth, size = 'md', theme })=>({
25
+ ...leadingWidth && {
26
+ paddingLeft: `calc(${theme.form[size].paddingLeft}px + ${itemsPadding[size]}px + ${leadingWidth}px)`
27
+ },
28
+ ...trailingWidth && {
29
+ paddingRight: `calc(${theme.form[size].paddingRight}px + ${itemsPadding[size]}px + ${trailingWidth}px)`
30
+ }
31
+ });
32
+ const StyledInput = styled(Input)`
33
+ ${inputStyles}
34
+ `;
35
+ const StyledTextArea = styled(TextArea)`
36
+ ${inputStyles}
37
+ `;
38
+ const StyledLeadingItemsWrap = styled(InputItemsWrap)`
39
+ left: ${(p)=>p.theme.form[p.size].paddingLeft + 1}px;
40
+ ${(p)=>p.disablePointerEvents && 'pointer-events: none;'}
41
+ `;
42
+ const StyledTrailingItemsWrap = styled(InputItemsWrap)`
43
+ right: ${(p)=>p.theme.form[p.size].paddingRight + 1}px;
44
+ ${(p)=>p.disablePointerEvents && 'pointer-events: none;'}
45
+ `;
46
+ const InputGroupContext = /*#__PURE__*/ createContext({
47
+ inputProps: {}
48
+ });
49
+ function InputGroup({ children, ...props }) {
50
+ const [leadingWidth, setLeadingWidth] = useState();
51
+ const [trailingWidth, setTrailingWidth] = useState();
52
+ const [inputProps, setInputProps] = useState({});
53
+ const contextValue = useMemo(()=>({
54
+ inputProps,
55
+ setInputProps,
56
+ leadingWidth,
57
+ setLeadingWidth,
58
+ trailingWidth,
59
+ setTrailingWidth
60
+ }), [
61
+ inputProps,
62
+ leadingWidth,
63
+ trailingWidth
64
+ ]);
65
+ return /*#__PURE__*/ jsx(InputGroupContext, {
66
+ value: contextValue,
67
+ children: /*#__PURE__*/ jsx(InputGroupWrap, {
68
+ disabled: inputProps.disabled,
69
+ ...props,
70
+ children: children
71
+ })
72
+ });
73
+ }
74
+ function inputGroup_Input({ ref, size, disabled, ...props }) {
75
+ const { leadingWidth, trailingWidth, setInputProps } = useContext(InputGroupContext);
76
+ useLayoutEffect(()=>{
77
+ setInputProps?.({
78
+ size,
79
+ disabled
80
+ });
81
+ }, [
82
+ size,
83
+ disabled,
84
+ setInputProps
85
+ ]);
86
+ return /*#__PURE__*/ jsx(StyledInput, {
87
+ ref: ref,
88
+ leadingWidth: leadingWidth,
89
+ trailingWidth: trailingWidth,
90
+ size: size,
91
+ disabled: disabled,
92
+ ...props
93
+ });
94
+ }
95
+ function inputGroup_TextArea({ ref, size, disabled, ...props }) {
96
+ const { leadingWidth, trailingWidth, setInputProps } = useContext(InputGroupContext);
97
+ useLayoutEffect(()=>{
98
+ setInputProps?.({
99
+ size,
100
+ disabled
101
+ });
102
+ }, [
103
+ size,
104
+ disabled,
105
+ setInputProps
106
+ ]);
107
+ return /*#__PURE__*/ jsx(StyledTextArea, {
108
+ ref: ref,
109
+ leadingWidth: leadingWidth,
110
+ trailingWidth: trailingWidth,
111
+ size: size,
112
+ disabled: disabled,
113
+ ...props
114
+ });
115
+ }
116
+ function useInputItemsWidthRef(setWidth) {
117
+ return useCallback((node)=>{
118
+ if (!node || !setWidth) return;
119
+ const updateWidth = ()=>{
120
+ setWidth(node.offsetWidth);
121
+ };
122
+ updateWidth();
123
+ const observer = new ResizeObserver(updateWidth);
124
+ observer.observe(node);
125
+ return ()=>{
126
+ observer.disconnect();
127
+ setWidth(void 0);
128
+ };
129
+ }, [
130
+ setWidth
131
+ ]);
132
+ }
133
+ function LeadingItems({ children, disablePointerEvents, ...props }) {
134
+ const { inputProps: { size = 'md', disabled }, setLeadingWidth } = useContext(InputGroupContext);
135
+ const ref = useInputItemsWidthRef(setLeadingWidth);
136
+ return /*#__PURE__*/ jsx(StyledLeadingItemsWrap, {
137
+ ref: ref,
138
+ size: size,
139
+ disablePointerEvents: disabled || disablePointerEvents,
140
+ "data-test-id": "input-leading-items",
141
+ ...props,
142
+ children: children
143
+ });
144
+ }
145
+ function TrailingItems({ children, disablePointerEvents, ...props }) {
146
+ const { inputProps: { size = 'md', disabled }, setTrailingWidth } = useContext(InputGroupContext);
147
+ const ref = useInputItemsWidthRef(setTrailingWidth);
148
+ return /*#__PURE__*/ jsx(StyledTrailingItemsWrap, {
149
+ ref: ref,
150
+ size: size,
151
+ disablePointerEvents: disabled || disablePointerEvents,
152
+ "data-test-id": "input-trailing-items",
153
+ ...props,
154
+ children: children
155
+ });
156
+ }
157
+ InputGroup.Input = inputGroup_Input;
158
+ InputGroup.TextArea = inputGroup_TextArea;
159
+ InputGroup.LeadingItems = LeadingItems;
160
+ InputGroup.TrailingItems = TrailingItems;
161
+ const InputGroupWrap = styled('div')`
162
+ position: relative;
163
+ ${(p)=>p.disabled && css`
164
+ color: ${p.theme.tokens.content.disabled};
165
+ `}
166
+ `;
167
+ export { InputGroup };
@@ -0,0 +1,13 @@
1
+ import type * as React from 'react';
2
+ import { type Theme } from '@emotion/react';
3
+ import { type FormSize, type StrictCSSObject } from '../theme/index.js';
4
+ export interface InputStylesProps {
5
+ monospace?: boolean;
6
+ nativeSize?: React.InputHTMLAttributes<HTMLInputElement>['size'];
7
+ readOnly?: React.InputHTMLAttributes<HTMLInputElement>['readOnly'];
8
+ size?: FormSize;
9
+ type?: React.HTMLInputTypeAttribute;
10
+ }
11
+ export declare const inputStyles: ({ theme, monospace, readOnly, size, }: InputStylesProps & {
12
+ theme: Theme;
13
+ }) => StrictCSSObject;
@@ -0,0 +1,52 @@
1
+ const inputStyles = ({ theme, monospace, readOnly, size = 'md' })=>{
2
+ const boxShadow = `0px 1px 0px 0px ${theme.tokens.interactive.chonky.debossed.neutral.chonk} inset`;
3
+ return {
4
+ display: 'block',
5
+ width: '100%',
6
+ color: theme.tokens.content.primary,
7
+ backgroundColor: theme.tokens.interactive.chonky.debossed.neutral.background,
8
+ boxShadow,
9
+ border: `1px solid ${theme.tokens.border.primary}`,
10
+ fontFamily: theme.font.family[monospace ? 'mono' : 'sans'],
11
+ fontWeight: theme.font.weight[monospace ? 'mono' : 'sans'].regular,
12
+ resize: 'vertical',
13
+ transition: `border ${theme.motion.smooth.fast}, box-shadow ${theme.motion.smooth.fast}`,
14
+ ...readOnly ? {
15
+ cursor: 'default'
16
+ } : {},
17
+ fontSize: theme.form[size].fontSize,
18
+ height: theme.form[size].height,
19
+ lineHeight: theme.form[size].lineHeight,
20
+ minHeight: theme.form[size].minHeight,
21
+ paddingBottom: theme.form[size].paddingBottom,
22
+ paddingLeft: theme.form[size].paddingLeft,
23
+ paddingRight: theme.form[size].paddingRight,
24
+ paddingTop: theme.form[size].paddingTop,
25
+ borderRadius: theme.form[size].borderRadius,
26
+ '&::placeholder': {
27
+ color: theme.tokens.content.secondary,
28
+ opacity: 1
29
+ },
30
+ "&[disabled], &[aria-disabled='true']": {
31
+ color: theme.tokens.content.disabled,
32
+ cursor: 'not-allowed',
33
+ opacity: '60%',
34
+ '&::placeholder': {
35
+ color: theme.tokens.content.disabled
36
+ }
37
+ },
38
+ '&:focus, &:focus-visible, :focus-within': {
39
+ ...theme.focusRing(boxShadow)
40
+ },
41
+ "&[type='number']": {
42
+ appearance: 'textfield',
43
+ MozAppearance: 'textfield',
44
+ fontVariantNumeric: 'tabular-nums'
45
+ },
46
+ '&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
47
+ WebkitAppearance: 'none',
48
+ margin: 0
49
+ }
50
+ };
51
+ };
52
+ export { inputStyles };
@@ -0,0 +1,20 @@
1
+ import type { InputProps } from './input.js';
2
+ export interface NumberDragInput extends Omit<InputProps, 'type' | 'onPointerMove'> {
3
+ /**
4
+ * Determines the axis of the drag input. Defaults to `x`
5
+ */
6
+ axis?: 'x' | 'y';
7
+ /**
8
+ * The maximum value of the input (inclusive)
9
+ */
10
+ max?: number;
11
+ /**
12
+ * The minimum value of the input (inclusive)
13
+ */
14
+ min?: number;
15
+ /**
16
+ * The multiplier for the value when the shift key is held down
17
+ */
18
+ shiftKeyMultiplier?: number;
19
+ }
20
+ export declare function NumberDragInput({ axis, shiftKeyMultiplier, ...props }: NumberDragInput): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,97 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { useCallback, useRef } from "react";
3
+ import styled from "@emotion/styled";
4
+ import { IconArrow } from "@sentry/icons/arrow";
5
+ import { Flex } from "../layout/index.js";
6
+ import { Tooltip } from "../tooltip/index.js";
7
+ import { useTranslation } from "../translation/useTranslation.js";
8
+ import { InputGroup } from "./inputGroup.js";
9
+ function NumberDragInput({ axis = 'x', shiftKeyMultiplier = 10, ...props }) {
10
+ const { tct } = useTranslation();
11
+ const inputRef = useRef(null);
12
+ const onPointerMove = useCallback((event)=>{
13
+ if (0 === event.movementX && 0 === event.movementY || !inputRef.current) return;
14
+ const step = parseFloat(props.step?.toString() ?? '1');
15
+ if (isNaN(step)) throw new TypeError('Step must be of type number, got ' + props.step);
16
+ const pointerDelta = 'x' === axis ? event.movementX : -1 * event.movementY;
17
+ const pointerDeltaOne = pointerDelta > 0 ? Math.ceil(pointerDelta / 100) : Math.floor(pointerDelta / 100);
18
+ const deltaStep = pointerDeltaOne * ((event.shiftKey ? shiftKeyMultiplier : step) ?? 1);
19
+ const min = props.min ?? -1 / 0;
20
+ const max = props.max ?? 1 / 0;
21
+ const value = Math.min(Math.max(Number(inputRef.current.value) + deltaStep, min), max);
22
+ setInputValueAndDispatchChange(inputRef.current, value.toString());
23
+ }, [
24
+ axis,
25
+ props.min,
26
+ props.max,
27
+ props.step,
28
+ shiftKeyMultiplier
29
+ ]);
30
+ const onPointerUp = useCallback(()=>{
31
+ document.exitPointerLock();
32
+ document.removeEventListener('pointermove', onPointerMove);
33
+ document.removeEventListener('pointerup', onPointerUp);
34
+ }, [
35
+ onPointerMove
36
+ ]);
37
+ const onPointerDown = (event)=>{
38
+ if (0 !== event.button) return;
39
+ event.currentTarget.requestPointerLock();
40
+ document.addEventListener('pointermove', onPointerMove);
41
+ document.addEventListener('pointerup', onPointerUp);
42
+ };
43
+ const onKeyDownProp = props.onKeyDown;
44
+ const onKeyDown = (event)=>{
45
+ onKeyDownProp?.(event);
46
+ if (!inputRef.current || 'ArrowUp' !== event.key && 'ArrowDown' !== event.key) return;
47
+ event.preventDefault();
48
+ const value = parseFloat(inputRef.current.value);
49
+ const step = parseFloat(props.step?.toString() ?? '1');
50
+ const min = props.min ?? -1 / 0;
51
+ const max = props.max ?? 1 / 0;
52
+ const newValue = Math.min(Math.max(value + ('ArrowUp' === event.key ? step : -step), min), max);
53
+ setInputValueAndDispatchChange(inputRef.current, newValue.toString());
54
+ };
55
+ return /*#__PURE__*/ jsxs(InputGroup, {
56
+ children: [
57
+ /*#__PURE__*/ jsx(InputGroup.Input, {
58
+ ref: inputRef,
59
+ type: "text",
60
+ ...props,
61
+ onKeyDown: onKeyDown
62
+ }),
63
+ /*#__PURE__*/ jsx(InputGroup.TrailingItems, {
64
+ children: /*#__PURE__*/ jsx(Tooltip, {
65
+ title: tct('Drag to adjust threshold[break]You can hold shift to fine tune', {
66
+ break: /*#__PURE__*/ jsx("br", {})
67
+ }),
68
+ skipWrapper: true,
69
+ children: /*#__PURE__*/ jsxs(Flex, {
70
+ direction: 'x' === axis ? 'row' : 'column',
71
+ gap: "2xs",
72
+ onPointerDown: onPointerDown,
73
+ children: [
74
+ /*#__PURE__*/ jsx(VerySmallIconArrow, {
75
+ direction: 'x' === axis ? 'left' : 'up'
76
+ }),
77
+ /*#__PURE__*/ jsx(VerySmallIconArrow, {
78
+ direction: 'x' === axis ? 'right' : 'down'
79
+ })
80
+ ]
81
+ })
82
+ })
83
+ })
84
+ ]
85
+ });
86
+ }
87
+ function setInputValueAndDispatchChange(input, value) {
88
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, value);
89
+ input.dispatchEvent(new Event('input', {
90
+ bubbles: true
91
+ }));
92
+ }
93
+ const VerySmallIconArrow = styled(IconArrow)`
94
+ width: 8px;
95
+ height: 8px;
96
+ `;
97
+ export { NumberDragInput };
@@ -0,0 +1,10 @@
1
+ import type * as React from 'react';
2
+ import type { AriaNumberFieldProps } from '@react-aria/numberfield';
3
+ import type { InputStylesProps } from './input.js';
4
+ interface NumberInputProps extends InputStylesProps, AriaNumberFieldProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'disabled' | 'readOnly' | 'required' | 'className'> {
5
+ max?: number;
6
+ min?: number;
7
+ ref?: React.Ref<HTMLInputElement>;
8
+ }
9
+ export declare function NumberInput({ ref, disabled, readOnly, monospace, min, max, size, placeholder, nativeSize, className, ...props }: NumberInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,94 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import styled from "@emotion/styled";
4
+ import { useButton } from "@react-aria/button";
5
+ import { useLocale } from "@react-aria/i18n";
6
+ import { useNumberField } from "@react-aria/numberfield";
7
+ import { mergeRefs } from "@react-aria/utils";
8
+ import { useNumberFieldState } from "@react-stately/numberfield";
9
+ import { IconChevron } from "@sentry/icons/chevron";
10
+ import { Button } from "../button/index.js";
11
+ import { useTranslation } from "../translation/useTranslation.js";
12
+ import { InputGroup } from "./inputGroup.js";
13
+ function NumberInput({ ref, disabled, readOnly, monospace, min, max, size, placeholder, nativeSize, className, ...props }) {
14
+ const { t } = useTranslation();
15
+ const localRef = useRef(null);
16
+ const ariaProps = {
17
+ isDisabled: disabled,
18
+ isReadOnly: readOnly,
19
+ minValue: min,
20
+ maxValue: max,
21
+ placeholder,
22
+ ...props
23
+ };
24
+ const { locale } = useLocale();
25
+ const state = useNumberFieldState({
26
+ locale,
27
+ ...ariaProps
28
+ });
29
+ const { groupProps, inputProps, incrementButtonProps, decrementButtonProps } = useNumberField(ariaProps, state, localRef);
30
+ const incrementButtonRef = useRef(null);
31
+ const { buttonProps: incrementProps } = useButton(incrementButtonProps, incrementButtonRef);
32
+ const decrementButtonRef = useRef(null);
33
+ const { buttonProps: decrementProps } = useButton(decrementButtonProps, decrementButtonRef);
34
+ return /*#__PURE__*/ jsxs(InputGroup, {
35
+ ...groupProps,
36
+ children: [
37
+ /*#__PURE__*/ jsx(InputGroup.Input, {
38
+ ...inputProps,
39
+ ref: mergeRefs(localRef, ref),
40
+ placeholder: placeholder,
41
+ size: size,
42
+ nativeSize: nativeSize,
43
+ monospace: monospace,
44
+ className: className
45
+ }),
46
+ /*#__PURE__*/ jsx(InputGroup.TrailingItems, {
47
+ children: /*#__PURE__*/ jsxs(StepWrap, {
48
+ size: size,
49
+ children: [
50
+ /*#__PURE__*/ jsx(StepButton, {
51
+ ref: incrementButtonRef,
52
+ size: "zero",
53
+ variant: "transparent",
54
+ ...incrementProps,
55
+ "aria-label": incrementProps['aria-label'] ?? t('Increment'),
56
+ icon: /*#__PURE__*/ jsx(StyledIconChevron, {
57
+ direction: "up"
58
+ })
59
+ }),
60
+ /*#__PURE__*/ jsx(StepButton, {
61
+ ref: decrementButtonRef,
62
+ size: "zero",
63
+ variant: "transparent",
64
+ ...decrementProps,
65
+ "aria-label": decrementProps['aria-label'] ?? t('Decrement'),
66
+ icon: /*#__PURE__*/ jsx(StyledIconChevron, {
67
+ direction: "down"
68
+ })
69
+ })
70
+ ]
71
+ })
72
+ })
73
+ ]
74
+ });
75
+ }
76
+ const StepWrap = styled('div')`
77
+ display: flex;
78
+ flex-direction: column;
79
+ align-items: center;
80
+ width: ${(p)=>p.theme.space.lg};
81
+ height: ${(p)=>'xs' === p.size ? '1rem' : '1.25rem'};
82
+ `;
83
+ const StepButton = styled(Button)`
84
+ display: flex;
85
+ height: 50%;
86
+ padding: 0 ${(p)=>p.theme.space['2xs']};
87
+ min-height: 0;
88
+ color: ${(p)=>p.theme.tokens.content.secondary};
89
+ `;
90
+ const StyledIconChevron = styled(IconChevron)`
91
+ width: 0.5rem;
92
+ height: 0.5rem;
93
+ `;
94
+ export { NumberInput };
@@ -0,0 +1,28 @@
1
+ type FormatToken = '0' | 'A';
2
+ type FormatParserState = 'start' | 'token' | 'separator';
3
+ /**
4
+ * Type-level parsing machinery for OTP formats. It walks the format one character at
5
+ * a time, remembers whether the first input token was `0` or `A`, and rejects formats
6
+ * that mix the two token types. The parser state also prevents leading, trailing, or
7
+ * consecutive separators. This type has no runtime behavior; it exists solely to
8
+ * provide useful TypeScript errors at OTPInput call sites.
9
+ */
10
+ type IsValidOTPFormat<Format extends string, SelectedToken extends FormatToken | null = null, State extends FormatParserState = 'start'> = Format extends '' ? State extends 'token' ? true : false : Format extends `${infer Character}${infer Rest}` ? Character extends FormatToken ? SelectedToken extends null ? IsValidOTPFormat<Rest, Character, 'token'> : Character extends SelectedToken ? IsValidOTPFormat<Rest, SelectedToken, 'token'> : false : Character extends '-' ? State extends 'token' ? IsValidOTPFormat<Rest, SelectedToken, 'separator'> : false : false : false;
11
+ type OTPFormat<Format extends string> = IsValidOTPFormat<Format> extends true ? Format : never;
12
+ export interface OTPInputProps<Format extends string> {
13
+ /**
14
+ * Describes the accepted characters and visual grouping. Use `0` for numeric
15
+ * inputs, `A` for alphanumeric inputs, and `-` for visual separators. A format
16
+ * must use either `0` or `A` throughout. Separators are not included in the value.
17
+ */
18
+ format: OTPFormat<Format>;
19
+ onComplete: (value: string) => void;
20
+ 'aria-label'?: string;
21
+ defaultValue?: string;
22
+ disabled?: boolean;
23
+ /** Converts alphanumeric input to uppercase as it is entered. */
24
+ uppercase?: boolean;
25
+ }
26
+ /** @public */
27
+ export declare function OTPInput<const Format extends string>({ 'aria-label': ariaLabel, format, onComplete, disabled, defaultValue, uppercase, }: OTPInputProps<Format>): import("@emotion/react/jsx-runtime").JSX.Element;
28
+ export {};
@@ -0,0 +1,81 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { Fragment, useState } from "react";
3
+ import styled from "@emotion/styled";
4
+ import { OTPInput, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS } from "input-otp";
5
+ import { Flex } from "../layout/index.js";
6
+ import { Text } from "../text/index.js";
7
+ import { useTranslation } from "../translation/useTranslation.js";
8
+ import { inputStyles } from "./inputStyles.js";
9
+ function otpInput_OTPInput({ 'aria-label': ariaLabel, format, onComplete, disabled = false, defaultValue = '', uppercase = false }) {
10
+ const { t } = useTranslation();
11
+ const [value, setValue] = useState(defaultValue);
12
+ const normalizeValue = (newValue)=>uppercase ? newValue.toUpperCase() : newValue;
13
+ const formatCharacters = [
14
+ ...format
15
+ ];
16
+ const isAlphanumeric = format.includes('A');
17
+ const length = formatCharacters.filter((character)=>'-' !== character).length;
18
+ return /*#__PURE__*/ jsx(OTPInput, {
19
+ "aria-label": ariaLabel ?? t('One-time password'),
20
+ autoComplete: "one-time-code",
21
+ disabled: disabled,
22
+ inputMode: isAlphanumeric ? 'text' : 'numeric',
23
+ maxLength: length,
24
+ onChange: (newValue)=>setValue(normalizeValue(newValue)),
25
+ onComplete: (newValue)=>onComplete(normalizeValue(newValue)),
26
+ onPasteCapture: (event)=>{
27
+ if (!event.clipboardData) {
28
+ event.preventDefault();
29
+ event.stopPropagation();
30
+ }
31
+ },
32
+ pasteTransformer: (pastedValue)=>pastedValue.replaceAll('-', ''),
33
+ pattern: isAlphanumeric ? REGEXP_ONLY_DIGITS_AND_CHARS : REGEXP_ONLY_DIGITS,
34
+ render: ({ slots })=>/*#__PURE__*/ jsx(Flex, {
35
+ align: "center",
36
+ "aria-hidden": true,
37
+ gap: "xs",
38
+ paddingRight: "md",
39
+ children: formatCharacters.map((character, formatIndex)=>{
40
+ if ('-' === character) return /*#__PURE__*/ jsx(Fragment, {
41
+ children: /*#__PURE__*/ jsx(Flex, {
42
+ align: "center",
43
+ paddingLeft: "xs",
44
+ paddingRight: "xs",
45
+ children: (flexProps)=>/*#__PURE__*/ jsx(Text, {
46
+ ...flexProps,
47
+ as: "span",
48
+ size: "lg",
49
+ children: "-"
50
+ })
51
+ })
52
+ }, formatIndex);
53
+ const slotIndex = formatCharacters.slice(0, formatIndex).filter((formatCharacter)=>'-' !== formatCharacter).length;
54
+ const slot = slots[slotIndex];
55
+ if (!slot) return null;
56
+ return /*#__PURE__*/ jsx(OTPInputSlot, {
57
+ align: "center",
58
+ "aria-hidden": true,
59
+ "aria-disabled": disabled,
60
+ "data-input-otp-slot": true,
61
+ justify: "center",
62
+ $isActive: slot.isActive,
63
+ children: slot.char ?? slot.placeholderChar
64
+ }, formatIndex);
65
+ })
66
+ }),
67
+ value: value
68
+ });
69
+ }
70
+ const OTPInputSlot = styled(Flex)`
71
+ ${(p)=>inputStyles({
72
+ theme: p.theme
73
+ })};
74
+ display: flex;
75
+ min-width: ${(p)=>p.theme.form.md.height};
76
+ padding: 0;
77
+ width: ${(p)=>p.theme.form.md.height};
78
+
79
+ ${(p)=>p.$isActive && p.theme.focusRing(`0 1px 0 0 ${p.theme.tokens.interactive.chonky.debossed.neutral.chonk} inset`)};
80
+ `;
81
+ export { otpInput_OTPInput as OTPInput };
@@ -0,0 +1,17 @@
1
+ import type React from 'react';
2
+ /**
3
+ * This hook is used to automatically resize an input element based on its content.
4
+ * It is useful for creating "growing" inputs that can resize to fit their content.
5
+ *
6
+ * @param options - Options for the autosize input functionality.
7
+ * @param options.value - The value of the input, use when the input is controlled.
8
+ * @param options.placeholder - The placeholder of the input. An empty input is sized
9
+ * to its placeholder, so pass it when the placeholder can change.
10
+ * @returns A ref callback for the input element.
11
+ */
12
+ interface UseAutosizeInputOptions {
13
+ placeholder?: string | undefined;
14
+ value?: React.InputHTMLAttributes<HTMLInputElement>['value'] | undefined;
15
+ }
16
+ export declare function useAutosizeInput(options?: UseAutosizeInputOptions): React.RefCallback<HTMLInputElement>;
17
+ export {};
@@ -0,0 +1,56 @@
1
+ import { useCallback, useLayoutEffect, useRef } from "react";
2
+ function createSizingDiv(computedStyles) {
3
+ const sizingDiv = document.createElement('div');
4
+ sizingDiv.style.whiteSpace = 'pre';
5
+ sizingDiv.style.width = 'auto';
6
+ sizingDiv.style.height = '0';
7
+ sizingDiv.style.position = 'fixed';
8
+ sizingDiv.style.pointerEvents = 'none';
9
+ sizingDiv.style.opacity = '0';
10
+ sizingDiv.style.zIndex = '-1';
11
+ sizingDiv.style.fontSize = computedStyles.fontSize;
12
+ sizingDiv.style.fontWeight = computedStyles.fontWeight;
13
+ sizingDiv.style.fontFamily = computedStyles.fontFamily;
14
+ return sizingDiv;
15
+ }
16
+ function useAutosizeInput(options) {
17
+ const sourceRef = useRef(null);
18
+ const sizingDivRef = useRef(null);
19
+ useLayoutEffect(()=>()=>{
20
+ if (sizingDivRef.current?.parentNode) {
21
+ sizingDivRef.current.parentNode.removeChild(sizingDivRef.current);
22
+ sizingDivRef.current = null;
23
+ }
24
+ }, []);
25
+ useLayoutEffect(()=>{
26
+ if (sourceRef.current) resize(sourceRef.current, sizingDivRef);
27
+ }, [
28
+ options?.value,
29
+ options?.placeholder
30
+ ]);
31
+ const onInputChange = useCallback((_event)=>{
32
+ if (sourceRef.current) resize(sourceRef.current, sizingDivRef);
33
+ }, []);
34
+ const autosizingCallbackRef = useCallback((element)=>{
35
+ if (element) {
36
+ resize(element, sizingDivRef);
37
+ element.addEventListener('input', onInputChange);
38
+ } else sourceRef.current?.removeEventListener('input', onInputChange);
39
+ sourceRef.current = element;
40
+ }, [
41
+ onInputChange
42
+ ]);
43
+ return autosizingCallbackRef;
44
+ }
45
+ function resize(input, sizingDivRef) {
46
+ const computedStyles = getComputedStyle(input);
47
+ if (!sizingDivRef.current) {
48
+ sizingDivRef.current = createSizingDiv(computedStyles);
49
+ document.body.appendChild(sizingDivRef.current);
50
+ }
51
+ const sizingDiv = sizingDivRef.current;
52
+ sizingDiv.innerText = input.value || input.placeholder;
53
+ const newTotalInputSize = sizingDiv.offsetWidth + parseInt(computedStyles.paddingLeft ?? 0, 10) + parseInt(computedStyles.paddingRight ?? 0, 10) + 2 * parseInt(computedStyles.borderWidth ?? 0, 10) + 1;
54
+ input.style.width = `${newTotalInputSize}px`;
55
+ }
56
+ export { useAutosizeInput };
@@ -0,0 +1 @@
1
+ export { InteractionStateLayer as default } from './interactionStateLayer.js';
@@ -0,0 +1 @@
1
+ export { InteractionStateLayer as default } from "./interactionStateLayer.js";
@@ -0,0 +1,23 @@
1
+ import type * as React from 'react';
2
+ interface StateLayerProps extends React.HTMLAttributes<HTMLSpanElement> {
3
+ as?: React.ElementType;
4
+ color?: string;
5
+ /**
6
+ * Controls if the opacity is increased when the element is in a
7
+ * selected or expanded state (aria-selected='true' or aria-expanded='true')
8
+ *
9
+ * @default true
10
+ */
11
+ hasSelectedBackground?: boolean;
12
+ higherOpacity?: boolean;
13
+ isHovered?: boolean;
14
+ isPressed?: boolean;
15
+ }
16
+ /**
17
+ * use core components with built-in interaction states
18
+ * @deprecated
19
+ */
20
+ export declare const InteractionStateLayer: import("@emotion/styled").StyledComponent<StateLayerProps & {
21
+ theme?: import("@emotion/react").Theme;
22
+ }, {}, {}>;
23
+ export {};