@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,217 @@
1
+ import { useMemo, useRef, useState } from "react";
2
+ import { autoUpdate, detectOverflow, offset as react_dom_offset, useFloating } from "@floating-ui/react-dom";
3
+ import { useButton } from "@react-aria/button";
4
+ import { useOverlay, useOverlayTrigger } from "@react-aria/overlays";
5
+ import { mergeProps } from "@react-aria/utils";
6
+ import { useOverlayTriggerState } from "@react-stately/overlays";
7
+ import { anchorOverlay, anchoredStyles, arrowOverlay, overlayPlatform, placementMiddleware, shiftOverlay } from "./overlayPositioning.js";
8
+ function maxSize(options) {
9
+ return {
10
+ name: 'maxSize',
11
+ options,
12
+ async fn (state) {
13
+ const { x, y } = state.middlewareData.shift ?? {
14
+ x: 0,
15
+ y: 0
16
+ };
17
+ const overflow = await detectOverflow({
18
+ ...state,
19
+ x: state.x - x,
20
+ y: state.y - y
21
+ }, options);
22
+ const { width, height } = state.rects.floating;
23
+ const [basePlacement] = state.placement.split('-');
24
+ const widthSide = 'left' === basePlacement ? 'left' : 'right';
25
+ const heightSide = 'top' === basePlacement ? 'top' : 'bottom';
26
+ const flippedWidthSide = 'left' === basePlacement ? 'right' : 'left';
27
+ const flippedHeightSide = 'top' === basePlacement ? 'bottom' : 'top';
28
+ const maxHeight = 'left' === basePlacement || 'right' === basePlacement ? height - overflow.top - overflow.bottom : Math.max(height - overflow[heightSide] - y, -overflow[flippedHeightSide]);
29
+ const maxWidth = 'top' === basePlacement || 'bottom' === basePlacement ? width - overflow.left - overflow.right : Math.max(width - overflow[widthSide] - x, -overflow[flippedWidthSide]);
30
+ return {
31
+ data: {
32
+ width: maxWidth,
33
+ height: maxHeight
34
+ }
35
+ };
36
+ }
37
+ };
38
+ }
39
+ const referenceWidth = {
40
+ name: 'referenceWidth',
41
+ fn: ({ rects })=>({
42
+ data: {
43
+ width: rects.reference.width
44
+ }
45
+ })
46
+ };
47
+ function useOverlay_useOverlay({ isOpen, onClose, defaultOpen, onOpenChange, type = 'dialog', offset = 8, position = 'top', arrowOptions = {}, flipOptions = {}, preventOverflowOptions = {}, getOverflowBoundary, shouldApplyMinWidth = true, isDismissable = true, shouldCloseOnBlur = false, isKeyboardDismissDisabled, shouldCloseOnInteractOutside, onInteractOutside, disableTrigger, strategy = 'absolute' } = {}) {
48
+ const [triggerElement, setTriggerElement] = useState(null);
49
+ const [overlayElement, setOverlayElement] = useState(null);
50
+ const openState = useOverlayTriggerState({
51
+ isOpen,
52
+ defaultOpen,
53
+ onOpenChange
54
+ });
55
+ const triggerRef = useMemo(()=>({
56
+ current: triggerElement
57
+ }), [
58
+ triggerElement
59
+ ]);
60
+ const overlayRef = useMemo(()=>({
61
+ current: overlayElement
62
+ }), [
63
+ overlayElement
64
+ ]);
65
+ const hasBoundary = !!preventOverflowOptions.boundary;
66
+ const fallbackBoundary = useMemo(()=>openState.isOpen && !hasBoundary ? getOverflowBoundary?.() : void 0, [
67
+ openState.isOpen,
68
+ hasBoundary,
69
+ getOverflowBoundary
70
+ ]);
71
+ const { placement: initialPlacement, middleware } = useMemo(()=>{
72
+ const placement = placementMiddleware(position, {
73
+ flipAlignment: false,
74
+ ...flipOptions
75
+ });
76
+ const overflowOptions = {
77
+ padding: 16,
78
+ ...preventOverflowOptions,
79
+ ...fallbackBoundary && {
80
+ boundary: fallbackBoundary
81
+ }
82
+ };
83
+ return {
84
+ placement: placement.placement,
85
+ middleware: [
86
+ react_dom_offset(Array.isArray(offset) ? {
87
+ crossAxis: offset[0],
88
+ mainAxis: offset[1]
89
+ } : offset),
90
+ placement.middleware,
91
+ shiftOverlay(overflowOptions),
92
+ arrowOverlay({
93
+ padding: 4,
94
+ ...arrowOptions
95
+ }),
96
+ maxSize(overflowOptions),
97
+ ...shouldApplyMinWidth ? [
98
+ referenceWidth
99
+ ] : [],
100
+ anchorOverlay
101
+ ]
102
+ };
103
+ }, [
104
+ arrowOptions,
105
+ flipOptions,
106
+ offset,
107
+ position,
108
+ preventOverflowOptions,
109
+ fallbackBoundary,
110
+ shouldApplyMinWidth
111
+ ]);
112
+ const { floatingStyles, middlewareData, placement, update } = useFloating({
113
+ elements: {
114
+ reference: triggerElement,
115
+ floating: overlayElement
116
+ },
117
+ middleware,
118
+ placement: initialPlacement,
119
+ platform: overlayPlatform,
120
+ strategy,
121
+ transform: false,
122
+ whileElementsMounted: openState.isOpen ? autoUpdate : void 0
123
+ });
124
+ const overlayStyle = useMemo(()=>{
125
+ const anchor = middlewareData.anchor;
126
+ const maxSizeData = middlewareData.maxSize;
127
+ const referenceWidthData = middlewareData.referenceWidth;
128
+ return {
129
+ ...anchoredStyles(floatingStyles, anchor),
130
+ ...referenceWidthData && {
131
+ minWidth: `${referenceWidthData.width}px`
132
+ },
133
+ ...maxSizeData && {
134
+ maxHeight: maxSizeData.height,
135
+ maxWidth: maxSizeData.width
136
+ }
137
+ };
138
+ }, [
139
+ floatingStyles,
140
+ middlewareData
141
+ ]);
142
+ const arrowStyle = useMemo(()=>{
143
+ const { x, y } = middlewareData.arrow ?? {};
144
+ return {
145
+ position: 'absolute',
146
+ ...void 0 !== x && {
147
+ left: `${x}px`
148
+ },
149
+ ...void 0 !== y && {
150
+ top: `${y}px`
151
+ }
152
+ };
153
+ }, [
154
+ middlewareData.arrow
155
+ ]);
156
+ const { triggerProps, overlayProps: overlayTriggerAriaProps } = useOverlayTrigger({
157
+ type
158
+ }, openState, triggerRef);
159
+ const { buttonProps: triggerAriaProps } = useButton({
160
+ ...triggerProps,
161
+ isDisabled: disableTrigger
162
+ }, triggerRef);
163
+ const interactedOutside = useRef(false);
164
+ const interactOutsideTrigger = useRef(null);
165
+ const isClosing = useRef(false);
166
+ const { overlayProps: overlayAriaProps } = useOverlay({
167
+ onClose: ()=>{
168
+ isClosing.current = true;
169
+ onClose?.();
170
+ if (interactedOutside.current) {
171
+ onInteractOutside?.();
172
+ interactedOutside.current = false;
173
+ const trigger = interactOutsideTrigger.current;
174
+ interactOutsideTrigger.current = null;
175
+ trigger?.focus();
176
+ trigger?.click();
177
+ }
178
+ openState.close();
179
+ isClosing.current = false;
180
+ },
181
+ isOpen: openState.isOpen,
182
+ isDismissable,
183
+ shouldCloseOnBlur,
184
+ isKeyboardDismissDisabled,
185
+ shouldCloseOnInteractOutside: (target)=>{
186
+ if (target && triggerRef.current !== target && !triggerRef.current?.contains(target) && (shouldCloseOnInteractOutside?.(target) ?? true) && !isClosing.current) {
187
+ const closestOverlayTrigger = target.closest?.('[aria-expanded="false"]');
188
+ if (closestOverlayTrigger && closestOverlayTrigger !== triggerRef.current) interactOutsideTrigger.current = closestOverlayTrigger;
189
+ else interactOutsideTrigger.current = null;
190
+ interactedOutside.current = true;
191
+ return true;
192
+ }
193
+ return false;
194
+ }
195
+ }, overlayRef);
196
+ return {
197
+ isOpen: openState.isOpen,
198
+ state: openState,
199
+ update,
200
+ triggerRef,
201
+ triggerProps: {
202
+ ref: setTriggerElement,
203
+ ...triggerAriaProps
204
+ },
205
+ overlayRef,
206
+ overlayProps: {
207
+ ref: setOverlayElement,
208
+ style: overlayStyle,
209
+ ...mergeProps(overlayTriggerAriaProps, overlayAriaProps)
210
+ },
211
+ arrowProps: {
212
+ style: arrowStyle,
213
+ placement
214
+ }
215
+ };
216
+ }
217
+ export { useOverlay_useOverlay as useOverlay };
@@ -0,0 +1,5 @@
1
+ export declare function useScrollLock(container: HTMLElement): {
2
+ acquire: () => void;
3
+ release: () => void;
4
+ held: () => boolean;
5
+ };
@@ -0,0 +1,100 @@
1
+ import { useEffect, useId, useMemo } from "react";
2
+ class Lock {
3
+ acquiredBy = new Set();
4
+ initialOverflow = null;
5
+ initialBodyStyles = null;
6
+ scroll = {
7
+ x: 0,
8
+ y: 0
9
+ };
10
+ container;
11
+ constructor(container){
12
+ this.container = container;
13
+ }
14
+ acquire(id) {
15
+ if (0 === this.acquiredBy.size) if (this.container === document.body) {
16
+ this.scroll = {
17
+ x: window.scrollX,
18
+ y: window.scrollY
19
+ };
20
+ this.initialBodyStyles = {
21
+ position: document.body.style.position,
22
+ top: document.body.style.top,
23
+ left: document.body.style.left,
24
+ right: document.body.style.right,
25
+ width: document.body.style.width,
26
+ paddingRight: document.body.style.paddingRight
27
+ };
28
+ const scrollbarWidth = window.innerWidth - document.body.clientWidth;
29
+ const existingPaddingRight = Number.parseFloat(getComputedStyle(document.body).paddingRight) || 0;
30
+ document.body.style.position = 'fixed';
31
+ document.body.style.top = `-${this.scroll.y}px`;
32
+ document.body.style.left = '0';
33
+ document.body.style.right = '0';
34
+ document.body.style.width = '100%';
35
+ document.documentElement.style.setProperty('--scrollbar-size', `${scrollbarWidth}px`);
36
+ document.body.style.paddingRight = `${existingPaddingRight + scrollbarWidth}px`;
37
+ } else {
38
+ this.initialOverflow = this.container.style.overflow;
39
+ this.container.style.overflow = 'hidden';
40
+ }
41
+ this.acquiredBy.add(id);
42
+ }
43
+ release(id) {
44
+ this.acquiredBy.delete(id);
45
+ if (0 === this.acquiredBy.size) {
46
+ if (null !== this.initialBodyStyles) {
47
+ document.body.style.position = this.initialBodyStyles.position;
48
+ document.body.style.top = this.initialBodyStyles.top;
49
+ document.body.style.left = this.initialBodyStyles.left;
50
+ document.body.style.right = this.initialBodyStyles.right;
51
+ document.body.style.width = this.initialBodyStyles.width;
52
+ document.body.style.paddingRight = this.initialBodyStyles.paddingRight;
53
+ document.documentElement.style.removeProperty('--scrollbar-size');
54
+ const { x, y } = this.scroll;
55
+ requestAnimationFrame(()=>{
56
+ if (0 === this.acquiredBy.size) window.scrollTo(x, y);
57
+ });
58
+ this.initialBodyStyles = null;
59
+ }
60
+ if (null !== this.initialOverflow) {
61
+ this.container.style.overflow = this.initialOverflow;
62
+ this.initialOverflow = null;
63
+ }
64
+ }
65
+ }
66
+ held() {
67
+ return this.acquiredBy.size > 0;
68
+ }
69
+ }
70
+ const LockMap = new Map();
71
+ function useScrollLock(container) {
72
+ const id = useId();
73
+ const lock = useMemo(()=>{
74
+ let globalLock = LockMap.get(container);
75
+ if (!globalLock) {
76
+ globalLock = new Lock(container);
77
+ LockMap.set(container, globalLock);
78
+ }
79
+ return globalLock;
80
+ }, [
81
+ container
82
+ ]);
83
+ useEffect(()=>()=>{
84
+ lock.release(id);
85
+ if (!lock.held()) LockMap.delete(container);
86
+ }, [
87
+ container,
88
+ lock,
89
+ id
90
+ ]);
91
+ return useMemo(()=>({
92
+ acquire: ()=>lock.acquire(id),
93
+ release: ()=>lock.release(id),
94
+ held: ()=>lock.held()
95
+ }), [
96
+ lock,
97
+ id
98
+ ]);
99
+ }
100
+ export { useScrollLock };
@@ -0,0 +1,9 @@
1
+ import type * as React from 'react';
2
+ /**
3
+ * Returns a stable function for merging a dynamic child ref with a stable ref.
4
+ *
5
+ * Merged refs are cached by child ref identity so React does not detach and
6
+ * reattach callback refs on every render. Cleanup functions returned by either
7
+ * ref are preserved by `mergeRefs`.
8
+ */
9
+ export declare function useStableMergeRef<T>(stableRef: React.Ref<T> | undefined): (ref: React.Ref<T> | null | undefined) => React.Ref<T> | undefined;
@@ -0,0 +1,18 @@
1
+ import { useMemo } from "react";
2
+ import { mergeRefs } from "@react-aria/utils";
3
+ function useStableMergeRef(stableRef) {
4
+ return useMemo(()=>{
5
+ const cache = new WeakMap();
6
+ return (ref)=>{
7
+ if (null == ref) return stableRef;
8
+ const cachedRef = cache.get(ref);
9
+ if (void 0 !== cachedRef) return cachedRef;
10
+ const mergedRef = mergeRefs(ref, stableRef);
11
+ cache.set(ref, mergedRef);
12
+ return mergedRef;
13
+ };
14
+ }, [
15
+ stableRef
16
+ ]);
17
+ }
18
+ export { useStableMergeRef };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/scraps",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/getsentry/sentry.git",
@@ -11,14 +11,22 @@
11
11
  ],
12
12
  "type": "module",
13
13
  "exports": {
14
- ".": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.js"
14
+ "./code/inlineCode": {
15
+ "types": "./dist/code/inlineCode.d.ts",
16
+ "import": "./dist/code/inlineCode.js"
17
+ },
18
+ "./hotkey/kbd": {
19
+ "types": "./dist/hotkey/kbd.d.ts",
20
+ "import": "./dist/hotkey/kbd.js"
17
21
  },
18
22
  "./theme": {
19
23
  "types": "./dist/theme/index.d.ts",
20
24
  "import": "./dist/theme/index.js"
21
25
  },
26
+ "./formPresentation": {
27
+ "types": "./dist/formPresentation/index.d.ts",
28
+ "import": "./dist/formPresentation/index.js"
29
+ },
22
30
  "./tokens": {
23
31
  "types": "./dist/tokens/index.d.ts",
24
32
  "import": "./dist/tokens/index.js"
@@ -42,42 +50,242 @@
42
50
  "./loader": {
43
51
  "types": "./dist/loader/index.d.ts",
44
52
  "import": "./dist/loader/index.js"
53
+ },
54
+ "./backdrop": {
55
+ "types": "./dist/backdrop/index.d.ts",
56
+ "import": "./dist/backdrop/index.js"
57
+ },
58
+ "./emptyState": {
59
+ "types": "./dist/emptyState/index.d.ts",
60
+ "import": "./dist/emptyState/index.js"
61
+ },
62
+ "./revealOnHover": {
63
+ "types": "./dist/revealOnHover/index.d.ts",
64
+ "import": "./dist/revealOnHover/index.js"
65
+ },
66
+ "./slider": {
67
+ "types": "./dist/slider/index.d.ts",
68
+ "import": "./dist/slider/index.js"
69
+ },
70
+ "./input": {
71
+ "types": "./dist/input/index.d.ts",
72
+ "import": "./dist/input/index.js"
73
+ },
74
+ "./textarea": {
75
+ "types": "./dist/textarea/index.d.ts",
76
+ "import": "./dist/textarea/index.js"
77
+ },
78
+ "./slot": {
79
+ "types": "./dist/slot/index.d.ts",
80
+ "import": "./dist/slot/index.js"
81
+ },
82
+ "./switch": {
83
+ "types": "./dist/switch/index.d.ts",
84
+ "import": "./dist/switch/index.js"
85
+ },
86
+ "./translation": {
87
+ "types": "./dist/translation/index.d.ts",
88
+ "import": "./dist/translation/index.js"
89
+ },
90
+ "./boundaryContext": {
91
+ "types": "./dist/boundaryContext.d.ts",
92
+ "import": "./dist/boundaryContext.js"
93
+ },
94
+ "./datetime": {
95
+ "types": "./dist/datetime.d.ts",
96
+ "import": "./dist/datetime.js"
97
+ },
98
+ "./sizeContext": {
99
+ "types": "./dist/sizeContext.d.ts",
100
+ "import": "./dist/sizeContext.js"
101
+ },
102
+ "./renderToString": {
103
+ "types": "./dist/renderToString.d.ts",
104
+ "import": "./dist/renderToString.js"
105
+ },
106
+ "./useScrollLock": {
107
+ "types": "./dist/useScrollLock.d.ts",
108
+ "import": "./dist/useScrollLock.js"
109
+ },
110
+ "./link": {
111
+ "types": "./dist/link/index.d.ts",
112
+ "import": "./dist/link/index.js"
113
+ },
114
+ "./trackingContext": {
115
+ "types": "./dist/trackingContext.d.ts",
116
+ "import": "./dist/trackingContext.js"
117
+ },
118
+ "./image": {
119
+ "types": "./dist/image/index.d.ts",
120
+ "import": "./dist/image/index.js"
121
+ },
122
+ "./descriptionList": {
123
+ "types": "./dist/descriptionList/index.d.ts",
124
+ "import": "./dist/descriptionList/index.js"
125
+ },
126
+ "./interactionStateLayer": {
127
+ "types": "./dist/interactionStateLayer/index.d.ts",
128
+ "import": "./dist/interactionStateLayer/index.js"
129
+ },
130
+ "./radio": {
131
+ "types": "./dist/radio/index.d.ts",
132
+ "import": "./dist/radio/index.js"
133
+ },
134
+ "./statusIndicator": {
135
+ "types": "./dist/statusIndicator/index.d.ts",
136
+ "import": "./dist/statusIndicator/index.js"
137
+ },
138
+ "./hotkey": {
139
+ "types": "./dist/hotkey/index.d.ts",
140
+ "import": "./dist/hotkey/index.js"
141
+ },
142
+ "./overlay": {
143
+ "types": "./dist/overlay.d.ts",
144
+ "import": "./dist/overlay.js"
145
+ },
146
+ "./overlayArrow": {
147
+ "types": "./dist/overlayArrow.d.ts",
148
+ "import": "./dist/overlayArrow.js"
149
+ },
150
+ "./panelProvider": {
151
+ "types": "./dist/panelProvider.d.ts",
152
+ "import": "./dist/panelProvider.js"
153
+ },
154
+ "./useStableMergeRef": {
155
+ "types": "./dist/useStableMergeRef.d.ts",
156
+ "import": "./dist/useStableMergeRef.js"
157
+ },
158
+ "./useOverlay": {
159
+ "types": "./dist/useOverlay.d.ts",
160
+ "import": "./dist/useOverlay.js"
161
+ },
162
+ "./useHoverOverlay": {
163
+ "types": "./dist/useHoverOverlay.d.ts",
164
+ "import": "./dist/useHoverOverlay.js"
165
+ },
166
+ "./tooltip": {
167
+ "types": "./dist/tooltip/index.d.ts",
168
+ "import": "./dist/tooltip/index.js"
169
+ },
170
+ "./overlayPositioning": {
171
+ "types": "./dist/overlayPositioning.d.ts",
172
+ "import": "./dist/overlayPositioning.js"
173
+ },
174
+ "./button": {
175
+ "types": "./dist/button/index.d.ts",
176
+ "import": "./dist/button/index.js"
177
+ },
178
+ "./info": {
179
+ "types": "./dist/info/index.d.ts",
180
+ "import": "./dist/info/index.js"
181
+ },
182
+ "./checkbox": {
183
+ "types": "./dist/checkbox/index.d.ts",
184
+ "import": "./dist/checkbox/index.js"
185
+ },
186
+ "./chip": {
187
+ "types": "./dist/chip/index.d.ts",
188
+ "import": "./dist/chip/index.js"
189
+ },
190
+ "./disclosure": {
191
+ "types": "./dist/disclosure/index.d.ts",
192
+ "import": "./dist/disclosure/index.js"
193
+ },
194
+ "./segmentedControl": {
195
+ "types": "./dist/segmentedControl/index.d.ts",
196
+ "import": "./dist/segmentedControl/index.js"
197
+ },
198
+ "./alert": {
199
+ "types": "./dist/alert/index.d.ts",
200
+ "import": "./dist/alert/index.js"
201
+ },
202
+ "./badge": {
203
+ "types": "./dist/badge/index.d.ts",
204
+ "import": "./dist/badge/index.js"
205
+ },
206
+ "./useIsInsideInteractiveElement": {
207
+ "types": "./dist/useIsInsideInteractiveElement.d.ts",
208
+ "import": "./dist/useIsInsideInteractiveElement.js"
209
+ },
210
+ "./table": {
211
+ "types": "./dist/table/index.d.ts",
212
+ "import": "./dist/table/index.js"
213
+ },
214
+ "./dragHandle": {
215
+ "types": "./dist/dragHandle/index.d.ts",
216
+ "import": "./dist/dragHandle/index.js"
45
217
  }
46
218
  },
47
219
  "publishConfig": {
48
220
  "access": "public"
49
221
  },
50
222
  "dependencies": {
51
- "@emotion/is-prop-valid": "1.4.0",
52
- "@emotion/styled": "11.14.0",
223
+ "@emotion/is-prop-valid": "^1.4.0",
224
+ "@emotion/styled": "^11.14.0",
225
+ "@floating-ui/react-dom": "^2.1.9",
226
+ "@react-aria/button": "3.15.1",
227
+ "@react-aria/disclosure": "3.2.1",
228
+ "@react-aria/i18n": "3.13.1",
229
+ "@react-aria/interactions": "3.28.1",
230
+ "@react-aria/numberfield": "3.13.1",
231
+ "@react-aria/overlays": "3.32.1",
232
+ "@react-aria/radio": "3.13.1",
233
+ "@react-aria/slider": "3.9.1",
53
234
  "@react-aria/utils": "3.34.1",
54
- "@types/react": "^19.0.0"
235
+ "@react-aria/visually-hidden": "3.9.1",
236
+ "@react-stately/collections": "3.13.1",
237
+ "@react-stately/disclosure": "3.1.1",
238
+ "@react-stately/list": "3.14.1",
239
+ "@react-stately/numberfield": "3.12.1",
240
+ "@react-stately/overlays": "3.7.1",
241
+ "@react-stately/radio": "3.12.1",
242
+ "@react-stately/slider": "3.8.1",
243
+ "@react-types/shared": "3.36.0",
244
+ "@sentry/icons": "0.1.0",
245
+ "@sentry/react": "11.7.0",
246
+ "@types/react": "19.3.0",
247
+ "classnames": "2.3.1",
248
+ "framer-motion": "12.38.0",
249
+ "input-otp": "^1.5.0",
250
+ "query-string": "7.0.1",
251
+ "react-textarea-autosize": "8.5.7",
252
+ "type-fest": "^5.10.0"
55
253
  },
56
254
  "devDependencies": {
255
+ "@jest/environment": "30.5.1",
57
256
  "@jest/environment-jsdom-abstract": "30.5.1",
58
257
  "@rsbuild/plugin-react": "2.1.1",
59
258
  "@rslib/core": "1.0.3",
60
259
  "@swc/core": "1.16.13",
61
260
  "@swc/jest": "0.2.39",
261
+ "@tanstack/react-form": "1.28.6",
62
262
  "@testing-library/dom": "10.4.1",
63
263
  "@testing-library/jest-dom": "7.0.1",
64
264
  "@testing-library/react": "16.3.2",
265
+ "@testing-library/user-event": "14.6.7",
65
266
  "@types/jest": "30.0.0",
66
- "@types/node": "24.13.2",
267
+ "@types/node": "26.6.4",
268
+ "@types/react-dom": "19.3.0",
67
269
  "expect-type": "1.4.0",
68
270
  "jest": "30.5.1",
69
271
  "jsdom": "30.1.1",
272
+ "oxlint": "1.88.0",
273
+ "oxlint-tsgolint": "7.0.2004",
274
+ "stylelint": "16.26.1",
70
275
  "typescript": "npm:@typescript/typescript6@6.0.2"
71
276
  },
72
277
  "peerDependencies": {
73
278
  "@emotion/react": "^11.14.0",
279
+ "@tanstack/react-form": "^1.28.6",
74
280
  "react": "^19.0.0",
75
281
  "react-dom": "^19.0.0"
76
282
  },
77
283
  "scripts": {
78
284
  "build": "rslib build",
79
- "verify": "node scripts/verify.mjs",
80
- "test": "jest --config jest.config.mjs",
81
- "typecheck": "tsc --project tsconfig.test.json"
285
+ "test": "NODE_ENV=test jest --config jest.config.mjs",
286
+ "typecheck": "tsc --build tsconfig.test.json",
287
+ "lint": "pnpm run lint:js && pnpm run lint:css",
288
+ "lint:js": "oxlint --type-aware --report-unused-disable-directives",
289
+ "lint:css": "stylelint '**/*.[jt]sx' --allow-empty-input"
82
290
  }
83
291
  }
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from './layout/index.js';
2
- export * from './text/index.js';
3
- export * from './separator/index.js';
4
- export * from './quote/index.js';
5
- export * from './loader/index.js';
6
- export { InlineCode } from './code/inlineCode.js';
7
- export { Kbd } from './hotkey/kbd.js';
8
- export * from './theme/index.js';
9
- export * from './tokens/index.js';
package/dist/index.js DELETED
@@ -1,9 +0,0 @@
1
- export * from "./layout/index.js";
2
- export * from "./text/index.js";
3
- export * from "./separator/index.js";
4
- export * from "./quote/index.js";
5
- export * from "./loader/index.js";
6
- export * from "./theme/index.js";
7
- export * from "./tokens/index.js";
8
- export { InlineCode } from "./code/inlineCode.js";
9
- export { Kbd } from "./hotkey/kbd.js";