@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,139 @@
1
+ import { arrow, autoPlacement, flip, getOverflowAncestors, limitShift, platform as react_dom_platform, shift } from "@floating-ui/react-dom";
2
+ function placementMiddleware(position, flipOptions = {}) {
3
+ if ('auto' === position || 'auto-start' === position || 'auto-end' === position) {
4
+ const { mainAxis: _mainAxis, crossAxis: _crossAxis, fallbackPlacements: _fallbackPlacements, fallbackStrategy: _fallbackStrategy, fallbackAxisSideDirection: _fallbackAxisSideDirection, flipAlignment = true, ...detectOverflowOptions } = flipOptions;
5
+ const alignment = 'auto-start' === position ? 'start' : 'auto-end' === position ? 'end' : void 0;
6
+ return {
7
+ placement: alignment ? `top-${alignment}` : 'top',
8
+ middleware: autoPlacement({
9
+ ...detectOverflowOptions,
10
+ alignment,
11
+ autoAlignment: flipAlignment
12
+ })
13
+ };
14
+ }
15
+ return {
16
+ placement: position,
17
+ middleware: flipOverlay(flipOptions)
18
+ };
19
+ }
20
+ function flipOverlay(options = {}) {
21
+ return flip({
22
+ fallbackStrategy: 'initialPlacement',
23
+ ...options
24
+ });
25
+ }
26
+ const anchorOverlay = {
27
+ name: 'anchor',
28
+ async fn ({ x, y, placement, rects, elements, platform, strategy }) {
29
+ const [side, alignment] = placement.split('-');
30
+ const isVertical = 'top' === side || 'bottom' === side;
31
+ const anchorBottom = 'top' === side || !isVertical && 'end' === alignment;
32
+ const anchorRight = 'left' === side || isVertical && 'end' === alignment;
33
+ if (!anchorBottom && !anchorRight) return {};
34
+ const { floating } = elements;
35
+ const offsetParent = await platform.getOffsetParent?.(floating);
36
+ const container = offsetParent && await platform.isElement?.(offsetParent) ? {
37
+ width: offsetParent.clientWidth,
38
+ height: offsetParent.clientHeight
39
+ } : getRootContainingBlock(floating, strategy);
40
+ const dpr = floating.ownerDocument.defaultView?.devicePixelRatio || 1;
41
+ const round = (value)=>Math.round(value * dpr) / dpr;
42
+ const anchor = {};
43
+ if (anchorBottom) anchor.bottom = round(container.height - y - rects.floating.height);
44
+ if (anchorRight) anchor.right = round(container.width - x - rects.floating.width);
45
+ return {
46
+ data: anchor
47
+ };
48
+ }
49
+ };
50
+ function getRootContainingBlock(floating, strategy) {
51
+ const root = floating.ownerDocument.documentElement;
52
+ const isDocument = 'absolute' === strategy && floating.ownerDocument.defaultView?.getComputedStyle(root).position !== 'static';
53
+ return isDocument ? {
54
+ width: root.scrollWidth,
55
+ height: root.scrollHeight
56
+ } : {
57
+ width: root.clientWidth,
58
+ height: root.clientHeight
59
+ };
60
+ }
61
+ function anchoredStyles(floatingStyles, anchor) {
62
+ return {
63
+ ...floatingStyles,
64
+ ...anchor?.bottom === void 0 ? {} : {
65
+ top: 'auto',
66
+ bottom: anchor.bottom
67
+ },
68
+ ...anchor?.right === void 0 ? {} : {
69
+ left: 'auto',
70
+ right: anchor.right
71
+ }
72
+ };
73
+ }
74
+ function getArrow(floating) {
75
+ return floating.querySelector('[data-overlay-arrow]');
76
+ }
77
+ function arrowOverlay(options = {}) {
78
+ return {
79
+ name: 'arrow',
80
+ options,
81
+ fn (state) {
82
+ const element = getArrow(state.elements.floating);
83
+ return element ? arrow({
84
+ ...options,
85
+ element
86
+ }).fn(state) : {};
87
+ }
88
+ };
89
+ }
90
+ function shiftOverlay(options = {}) {
91
+ const { tether = true, ...shiftOptions } = options;
92
+ return {
93
+ name: 'shift',
94
+ options,
95
+ fn (state) {
96
+ const limiter = tether ? tetherLimiter(state, getArrow(state.elements.floating)) : void 0;
97
+ return shift({
98
+ limiter,
99
+ ...shiftOptions
100
+ }).fn(state);
101
+ }
102
+ };
103
+ }
104
+ function tetherLimiter(origin, arrowElement) {
105
+ const crossAxisLimiter = limitShift({
106
+ mainAxis: false
107
+ });
108
+ return {
109
+ fn (state) {
110
+ const coords = crossAxisLimiter.fn(state);
111
+ const isVertical = state.placement.startsWith('top') || state.placement.startsWith('bottom');
112
+ const axis = isVertical ? 'x' : 'y';
113
+ const length = isVertical ? 'width' : 'height';
114
+ const { reference, floating } = state.rects;
115
+ const arrowLength = Math.min((isVertical ? arrowElement?.offsetWidth : arrowElement?.offsetHeight) ?? 0, reference[length]);
116
+ const min = reference[axis] - floating[length] + arrowLength;
117
+ const max = reference[axis] + reference[length] - arrowLength;
118
+ const start = origin[axis];
119
+ const shifted = state[axis];
120
+ if (shifted > start) coords[axis] = Math.max(start, Math.min(shifted, max));
121
+ else if (shifted < start) coords[axis] = Math.min(start, Math.max(shifted, min));
122
+ return coords;
123
+ }
124
+ };
125
+ }
126
+ const overlayPlatform = {
127
+ ...react_dom_platform,
128
+ getClippingRect (args) {
129
+ const { element, boundary, strategy } = args;
130
+ const offsetParent = element instanceof HTMLElement && 'absolute' === strategy ? element.offsetParent : null;
131
+ if ('clippingAncestors' !== boundary || !offsetParent) return react_dom_platform.getClippingRect.call(this, args);
132
+ const clippingAncestors = getOverflowAncestors(element, [], false).filter((ancestor)=>ancestor instanceof Element && ancestor !== element.ownerDocument.body && ancestor.contains(offsetParent));
133
+ return react_dom_platform.getClippingRect.call(this, {
134
+ ...args,
135
+ boundary: clippingAncestors
136
+ });
137
+ }
138
+ };
139
+ export { anchorOverlay, anchoredStyles, arrowOverlay, flipOverlay, overlayPlatform, placementMiddleware, shiftOverlay };
@@ -0,0 +1,8 @@
1
+ import type * as React from 'react';
2
+ /**
3
+ * Nested theme provider that automatically adjusts the styles of descendants
4
+ * of panel-like elements. See `panel.tsx` for usage example.
5
+ */
6
+ export declare function PanelProvider({ children }: {
7
+ children: React.ReactNode;
8
+ }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { ThemeProvider, useTheme } from "@emotion/react";
4
+ const smallerBorderRadii = {
5
+ borderRadius: '4px'
6
+ };
7
+ function PanelProvider({ children }) {
8
+ const theme = useTheme();
9
+ const modifiedTheme = useMemo(()=>({
10
+ ...theme,
11
+ ...smallerBorderRadii
12
+ }), [
13
+ theme
14
+ ]);
15
+ return /*#__PURE__*/ jsx(ThemeProvider, {
16
+ theme: modifiedTheme,
17
+ children: children
18
+ });
19
+ }
20
+ export { PanelProvider };
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
3
  import styled from "@emotion/styled";
4
4
  import { Stack } from "../layout/index.js";
5
- import { Text } from "../text/index.js";
5
+ import { Text } from "../text/text.js";
6
6
  function Quote(props) {
7
7
  const { children, ...spreadProps } = props;
8
8
  return /*#__PURE__*/ jsxs(Stack, {
@@ -0,0 +1 @@
1
+ export { Radio } from './radio.js';
@@ -0,0 +1 @@
1
+ export { Radio } from "./radio.js";
@@ -0,0 +1,9 @@
1
+ import type * as React from 'react';
2
+ interface RadioProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
3
+ ref?: React.Ref<HTMLInputElement>;
4
+ size?: 'xs' | 'sm' | 'md';
5
+ }
6
+ export declare const Radio: import("@emotion/styled").StyledComponent<RadioProps & {
7
+ theme?: import("@emotion/react").Theme;
8
+ }, {}, {}>;
9
+ export {};
@@ -0,0 +1,77 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import is_prop_valid from "@emotion/is-prop-valid";
3
+ import { keyframes } from "@emotion/react";
4
+ import styled from "@emotion/styled";
5
+ const growIn = keyframes`
6
+ 0% {
7
+ opacity: 0;
8
+ transform: scale(0.75);
9
+ }
10
+ 100% {
11
+ opacity: 1;
12
+ transform: scale(1);
13
+ }
14
+ `;
15
+ const radioConfig = {
16
+ xs: {
17
+ outerSize: '12px',
18
+ innerSize: '6px'
19
+ },
20
+ sm: {
21
+ outerSize: '20px',
22
+ innerSize: '10px'
23
+ },
24
+ md: {
25
+ outerSize: '24px',
26
+ innerSize: '12px'
27
+ }
28
+ };
29
+ const radioStyles = (props)=>({
30
+ width: radioConfig[props.size ?? 'md'].outerSize,
31
+ height: radioConfig[props.size ?? 'md'].outerSize,
32
+ flexShrink: 0,
33
+ borderRadius: props.theme.radius.full,
34
+ display: 'inline-flex',
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ cursor: 'pointer',
38
+ appearance: 'none',
39
+ transition: `border ${props.theme.motion.smooth.fast}, box-shadow ${props.theme.motion.smooth.fast}`,
40
+ margin: '0 !important',
41
+ border: `1px solid ${props.theme.tokens.border.primary} !important`,
42
+ '&:after': {
43
+ content: '""',
44
+ display: 'block',
45
+ width: radioConfig[props.size ?? 'md'].innerSize,
46
+ height: radioConfig[props.size ?? 'md'].innerSize,
47
+ borderRadius: props.theme.radius.full,
48
+ backgroundColor: props.theme.tokens.content.onVibrant.light,
49
+ transition: `all ${props.theme.motion.smooth.moderate}`,
50
+ opacity: 0
51
+ },
52
+ '&:focus-visible': {
53
+ ...props.theme.focusRing()
54
+ },
55
+ '&:checked': {
56
+ backgroundColor: props.theme.tokens.interactive.chonky.debossed.accent.background,
57
+ border: `1px solid ${props.theme.tokens.interactive.chonky.debossed.accent.chonk}`,
58
+ '&:after': {
59
+ animation: `${growIn} ${props.theme.motion.smooth.moderate}`,
60
+ opacity: 1
61
+ }
62
+ },
63
+ '&:disabled': {
64
+ opacity: props.theme.tokens.interactive.disabled,
65
+ cursor: 'not-allowed'
66
+ }
67
+ });
68
+ const Radio = styled(({ ref, size: _size, ...props })=>/*#__PURE__*/ jsx("input", {
69
+ type: "radio",
70
+ ...props,
71
+ ref: ref
72
+ }), {
73
+ shouldForwardProp: (prop)=>'string' == typeof prop && is_prop_valid(prop)
74
+ })`
75
+ ${(p)=>radioStyles(p)}
76
+ `;
77
+ export { Radio };
@@ -0,0 +1,2 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare const useRenderToString: () => (tree: ReactNode) => string;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { flushSync } from "react-dom";
4
+ import { createRoot } from "react-dom/client";
5
+ import { ThemeProvider, useTheme } from "@emotion/react";
6
+ const renderToString = (tree)=>{
7
+ const div = document.createElement('div');
8
+ const root = createRoot(div);
9
+ flushSync(()=>{
10
+ root.render(tree);
11
+ });
12
+ const html = div.innerHTML;
13
+ root.unmount();
14
+ return html;
15
+ };
16
+ const useRenderToString = ()=>{
17
+ const theme = useTheme();
18
+ return useCallback((tree)=>renderToString(/*#__PURE__*/ jsx(ThemeProvider, {
19
+ theme: theme,
20
+ children: tree
21
+ })), [
22
+ theme
23
+ ]);
24
+ };
25
+ export { useRenderToString };
@@ -0,0 +1 @@
1
+ export { RevealOnHover } from './revealOnHover.js';
@@ -0,0 +1 @@
1
+ export { RevealOnHover } from "./revealOnHover.js";
@@ -0,0 +1,20 @@
1
+ import type * as React from 'react';
2
+ import { type FlexProps } from '../layout/index.js';
3
+ interface RevealOnHoverRenderProps {
4
+ className: string;
5
+ }
6
+ type RevealOnHoverProps = (FlexProps & {
7
+ children: React.ReactNode;
8
+ }) | {
9
+ children: (props: RevealOnHoverRenderProps) => React.ReactNode;
10
+ };
11
+ declare function RevealOnHoverRoot(props: RevealOnHoverProps): import("@emotion/react/jsx-runtime").JSX.Element;
12
+ interface ActionProps {
13
+ children: React.ReactNode;
14
+ visible?: boolean;
15
+ }
16
+ declare function Action({ children, visible }: ActionProps): import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export declare const RevealOnHover: typeof RevealOnHoverRoot & {
18
+ Action: typeof Action;
19
+ };
20
+ export {};
@@ -0,0 +1,62 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { Flex } from "../layout/index.js";
4
+ function RevealOnHoverRoot(props) {
5
+ const { children, ...rest } = props;
6
+ if ('function' == typeof children) return /*#__PURE__*/ jsx(RevealOnHoverStyles, {
7
+ children: ({ className })=>children({
8
+ className
9
+ })
10
+ });
11
+ return /*#__PURE__*/ jsx(RevealOnHoverFlex, {
12
+ align: "center",
13
+ gap: "xs",
14
+ ...rest,
15
+ children: children
16
+ });
17
+ }
18
+ const revealStyles = (p)=>`
19
+ [data-reveal-on-hover][data-reveal-on-hover-visible] {
20
+ opacity: 1;
21
+ pointer-events: auto;
22
+ }
23
+
24
+ @media (hover: hover) {
25
+ [data-reveal-on-hover] {
26
+ opacity: 0;
27
+ pointer-events: none;
28
+ transition: opacity ${p.theme.motion.exit.fast};
29
+ }
30
+
31
+ &:hover [data-reveal-on-hover],
32
+ &:has(:focus-visible) [data-reveal-on-hover] {
33
+ opacity: 1;
34
+ pointer-events: auto;
35
+ transition: opacity ${p.theme.motion.enter.moderate};
36
+ }
37
+ }
38
+ `;
39
+ function RevealOnHoverFlex(props) {
40
+ return /*#__PURE__*/ jsx(Flex, {
41
+ css: (theme)=>revealStyles({
42
+ theme
43
+ }),
44
+ ...props
45
+ });
46
+ }
47
+ const RevealOnHoverStyles = styled((props)=>props.children({
48
+ className: props.className ?? ''
49
+ }))`
50
+ ${revealStyles}
51
+ `;
52
+ function Action({ children, visible }) {
53
+ return /*#__PURE__*/ jsx("span", {
54
+ "data-reveal-on-hover": "",
55
+ "data-reveal-on-hover-visible": visible ? '' : void 0,
56
+ children: children
57
+ });
58
+ }
59
+ const RevealOnHover = Object.assign(RevealOnHoverRoot, {
60
+ Action: Action
61
+ });
62
+ export { RevealOnHover };
@@ -0,0 +1 @@
1
+ export { SegmentedControl } from './segmentedControl.js';
@@ -0,0 +1 @@
1
+ export { SegmentedControl } from "./segmentedControl.js";
@@ -0,0 +1,41 @@
1
+ import type * as React from 'react';
2
+ import type { CollectionChildren } from '@react-types/shared';
3
+ import type { FormSize } from '../theme/index.js';
4
+ import type { TooltipProps } from '../tooltip/index.js';
5
+ type Priority = 'default' | 'primary' | 'secondary';
6
+ interface SegmentedControlItemProps<Value extends string> {
7
+ key: Value;
8
+ children?: React.ReactNode;
9
+ disabled?: boolean;
10
+ /**
11
+ * Optional icon to be rendered to the left of the segment label. Use this prop to
12
+ * ensure proper vertical alignment.
13
+ *
14
+ * NOTE: if the segment contains only an icon and no text label (i.e. `children` is
15
+ * not defined), then an `aria-label` must be provided for screen reader support.
16
+ */
17
+ icon?: React.ReactNode;
18
+ /** A string representation of the item's contents */
19
+ textValue?: string;
20
+ /**
21
+ * Optional tooltip that appears when the use hovers over the segment. Avoid using
22
+ * tooltips if there are other, more visible ways to display the same information.
23
+ */
24
+ tooltip?: React.ReactNode;
25
+ /**
26
+ * Additional props to be passed into <Tooltip />.
27
+ */
28
+ tooltipOptions?: Omit<TooltipProps, 'children' | 'title' | 'className'>;
29
+ }
30
+ interface SegmentedControlProps<Value extends string> {
31
+ children: CollectionChildren<Value>;
32
+ onChange: (value: Value) => void;
33
+ value: Value;
34
+ priority?: Priority;
35
+ size?: FormSize;
36
+ }
37
+ export declare function SegmentedControl<Value extends string>({ value, onChange, size, priority, ...props }: SegmentedControlProps<Value>): import("@emotion/react/jsx-runtime").JSX.Element;
38
+ export declare namespace SegmentedControl {
39
+ var Item: <Value extends string>(props: SegmentedControlItemProps<Value>) => React.JSX.Element;
40
+ }
41
+ export {};
@@ -0,0 +1,217 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createElement, css } from "@emotion/react";
3
+ import { useMemo, useRef } from "react";
4
+ import styled from "@emotion/styled";
5
+ import { useRadio, useRadioGroup } from "@react-aria/radio";
6
+ import { Item, useCollection } from "@react-stately/collections";
7
+ import { ListCollection } from "@react-stately/list";
8
+ import { useRadioGroupState } from "@react-stately/radio";
9
+ import { LayoutGroup } from "framer-motion";
10
+ import { DO_NOT_USE_getButtonStyles } from "../button/index.js";
11
+ import { Tooltip } from "../tooltip/index.js";
12
+ const getChildTransforms = (count)=>Array.from({
13
+ length: count
14
+ }, (_, index)=>css`
15
+ label:nth-of-type(${index + 1}) {
16
+ transform: translateX(-${index}px);
17
+ }
18
+ `);
19
+ function getTextColor({ isSelected, priority, theme }) {
20
+ if (isSelected) return 'default' === priority || 'secondary' === priority ? theme.tokens.interactive.chonky.embossed.neutral.content.accent : void 0;
21
+ return theme.tokens.content.secondary;
22
+ }
23
+ const segmentedWrapPadding = {
24
+ md: '10px 16px 10px 16px',
25
+ sm: '8px 12px 8px 12px',
26
+ xs: '6px 8px 6px 8px'
27
+ };
28
+ const collectionFactory = (nodes)=>new ListCollection(nodes);
29
+ function SegmentedControl({ value, onChange, size = 'md', priority = 'default', ...props }) {
30
+ const ref = useRef(null);
31
+ const collection = useCollection(props, collectionFactory);
32
+ const ariaProps = {
33
+ ...props,
34
+ value,
35
+ onChange: onChange,
36
+ orientation: 'horizontal'
37
+ };
38
+ const state = useRadioGroupState(ariaProps);
39
+ const { radioGroupProps } = useRadioGroup(ariaProps, state);
40
+ const collectionList = useMemo(()=>[
41
+ ...collection
42
+ ], [
43
+ collection
44
+ ]);
45
+ return /*#__PURE__*/ jsx(GroupWrap, {
46
+ ...radioGroupProps,
47
+ ...props,
48
+ size: size,
49
+ priority: priority,
50
+ ref: ref,
51
+ listSize: collectionList.length,
52
+ children: /*#__PURE__*/ jsx(LayoutGroup, {
53
+ id: radioGroupProps.id,
54
+ children: collectionList.map((option)=>/*#__PURE__*/ createElement(Segment, {
55
+ ...option.props,
56
+ key: option.key,
57
+ nextKey: option.nextKey,
58
+ prevKey: option.prevKey,
59
+ value: String(option.key),
60
+ isDisabled: option.props.disabled,
61
+ state: state,
62
+ size: size,
63
+ priority: priority,
64
+ layoutGroupId: radioGroupProps.id
65
+ }, option.rendered))
66
+ })
67
+ });
68
+ }
69
+ SegmentedControl.Item = Item;
70
+ function Segment({ state, size, priority, tooltip, tooltipOptions = {}, icon, ...props }) {
71
+ const ref = useRef(null);
72
+ const { inputProps } = useRadio(props, state, ref);
73
+ const isSelected = state.selectedValue === props.value;
74
+ const { isDisabled } = props;
75
+ const label = /*#__PURE__*/ jsx(VisibleLabel, {
76
+ children: props.children
77
+ });
78
+ const content = /*#__PURE__*/ jsxs(SegmentWrap, {
79
+ size: size,
80
+ shapeVariant: props.children ? 'rectangular' : 'square',
81
+ isSelected: isSelected,
82
+ isDisabled: isDisabled,
83
+ priority: priority,
84
+ "data-test-id": props.value,
85
+ "aria-checked": isSelected,
86
+ "aria-disabled": isDisabled,
87
+ children: [
88
+ /*#__PURE__*/ jsx(SegmentInput, {
89
+ ...inputProps,
90
+ ref: ref
91
+ }),
92
+ /*#__PURE__*/ jsxs(LabelWrap, {
93
+ size: size,
94
+ isSelected: isSelected,
95
+ priority: priority,
96
+ role: "presentation",
97
+ children: [
98
+ icon,
99
+ props.children && label
100
+ ]
101
+ })
102
+ ]
103
+ });
104
+ if (tooltip) return /*#__PURE__*/ jsx(Tooltip, {
105
+ skipWrapper: true,
106
+ title: tooltip,
107
+ delay: 500,
108
+ position: 'bottom',
109
+ ...tooltipOptions,
110
+ children: content
111
+ });
112
+ return content;
113
+ }
114
+ const GroupWrap = styled('div')`
115
+ position: relative;
116
+ display: inline-grid;
117
+ grid-auto-flow: column;
118
+ min-width: 0;
119
+
120
+ font-size: ${(p)=>p.theme.form[p.size].fontSize};
121
+ height: ${(p)=>p.theme.form[p.size].height};
122
+ line-height: ${(p)=>p.theme.form[p.size].lineHeight};
123
+ min-height: ${(p)=>p.theme.form[p.size].minHeight};
124
+
125
+ & > label:first-child {
126
+ border-top-right-radius: 0;
127
+ border-bottom-right-radius: 0;
128
+ }
129
+
130
+ & > label:not(:first-child):not(:last-child) {
131
+ border-radius: 0;
132
+ }
133
+
134
+ & > label:last-child {
135
+ border-top-left-radius: 0;
136
+ border-bottom-left-radius: 0;
137
+ }
138
+
139
+ ${(p)=>getChildTransforms(p.listSize)}
140
+ `;
141
+ const SegmentWrap = styled('label')`
142
+ position: relative;
143
+ display: flex;
144
+ align-items: center;
145
+ margin: 0;
146
+ cursor: ${(p)=>p.isDisabled ? 'default' : 'pointer'};
147
+ min-height: 0;
148
+ min-width: 0;
149
+ z-index: ${(p)=>p.isSelected ? 1 : void 0};
150
+
151
+ padding: ${(p)=>segmentedWrapPadding[p.size]};
152
+ font-weight: ${(p)=>p.theme.font.weight.sans.regular};
153
+
154
+ ${(p)=>({
155
+ ...DO_NOT_USE_getButtonStyles({
156
+ ...p,
157
+ disabled: p.isDisabled,
158
+ variant: p.isSelected && 'primary' === p.priority ? 'primary' : 'secondary',
159
+ shapeVariant: p.shapeVariant
160
+ })
161
+ })}
162
+
163
+ &:has(input:focus-visible) {
164
+ ${(p)=>p.theme.focusRing()};
165
+
166
+ /* Hide fallback ring when :has works */
167
+ span {
168
+ box-shadow: none !important;
169
+ }
170
+ }
171
+
172
+ /* Fallback ring (for Firefox, where :has doesn't work) */
173
+ input:focus-visible + span {
174
+ ${({ theme })=>theme.focusRing()};
175
+ }
176
+ `;
177
+ const SegmentInput = styled('input')`
178
+ appearance: none;
179
+ position: absolute;
180
+ top: 0;
181
+ left: 0;
182
+ bottom: 0;
183
+ right: 0;
184
+
185
+ border-radius: ${(p)=>p.theme.radius.md};
186
+ transition: box-shadow 0.125s ease-out;
187
+ z-index: -1;
188
+
189
+ /* Reset global styles */
190
+ && {
191
+ padding: 0;
192
+ margin: 0;
193
+ }
194
+
195
+ &:focus {
196
+ outline: none;
197
+ }
198
+ `;
199
+ const LabelWrap = styled('span')`
200
+ display: grid;
201
+ grid-auto-flow: column;
202
+ align-items: center;
203
+ gap: ${(p)=>'xs' === p.size ? p.theme.space.xs : p.theme.space.sm};
204
+ z-index: 1;
205
+ color: ${(p)=>getTextColor(p)};
206
+ `;
207
+ const VisibleLabel = styled('span')`
208
+ display: block;
209
+ width: 100%;
210
+ white-space: nowrap;
211
+ overflow: hidden;
212
+ text-overflow: ellipsis;
213
+ user-select: none;
214
+ font-weight: ${(p)=>p.theme.font.weight.sans.medium};
215
+ text-align: center;
216
+ `;
217
+ export { SegmentedControl };
@@ -1,4 +1,5 @@
1
- import type { ContainerProps } from '../layout/index.js';
1
+ import type * as React from 'react';
2
+ import type { ContainerProps } from '../layout/container.js';
2
3
  export type SeparatorProps = Pick<ContainerProps, 'border' | 'margin' | 'padding'> & {
3
4
  orientation: 'horizontal' | 'vertical';
4
5
  children?: never;
@@ -7,9 +8,9 @@ export type SeparatorProps = Pick<ContainerProps, 'border' | 'margin' | 'padding
7
8
  * We require a wrapper if we want to use the orientation context,
8
9
  * otherwise the styling won't work as override needs to come from the parent.
9
10
  */
10
- export declare const Separator: import("@emotion/styled").StyledComponent<Pick<ContainerProps, "border" | "padding" | "margin"> & {
11
+ export declare const Separator: import("@emotion/styled").StyledComponent<Pick<ContainerProps, "border" | "margin" | "padding"> & {
11
12
  orientation: "horizontal" | "vertical";
12
13
  children?: never;
13
- } & Omit<import("react").HTMLAttributes<HTMLHRElement>, "aria-orientation"> & {
14
+ } & Omit<React.HTMLAttributes<HTMLHRElement>, "aria-orientation"> & {
14
15
  theme?: import("@emotion/react").Theme;
15
16
  }, {}, {}>;