@seed-design/lynx-react 0.7.1 → 0.9.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 (265) hide show
  1. package/lib/components/Accordion/Accordion.jsx +2 -2
  2. package/lib/components/ActionButton/ActionButton.jsx +1 -1
  3. package/lib/components/AlertDialog/AlertDialog.d.ts +64 -0
  4. package/lib/components/AlertDialog/AlertDialog.d.ts.map +1 -0
  5. package/lib/components/AlertDialog/AlertDialog.jsx +138 -0
  6. package/lib/components/AlertDialog/AlertDialog.namespace.d.ts +2 -0
  7. package/lib/components/AlertDialog/AlertDialog.namespace.d.ts.map +1 -0
  8. package/lib/components/AlertDialog/AlertDialog.namespace.js +17 -0
  9. package/lib/components/AlertDialog/index.d.ts +3 -0
  10. package/lib/components/AlertDialog/index.d.ts.map +1 -0
  11. package/lib/components/AppBar/AppBar.d.ts +14 -1
  12. package/lib/components/AppBar/AppBar.d.ts.map +1 -1
  13. package/lib/components/AppBar/AppBar.jsx +42 -16
  14. package/lib/components/AppBar/AppBar.namespace.d.ts +1 -1
  15. package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -1
  16. package/lib/components/AppBar/context.d.ts +2 -1
  17. package/lib/components/AppBar/context.d.ts.map +1 -1
  18. package/lib/components/AppBar/index.d.ts +1 -1
  19. package/lib/components/AppBar/index.d.ts.map +1 -1
  20. package/lib/components/AppBar/useAppBar.d.ts +2 -1
  21. package/lib/components/AppBar/useAppBar.d.ts.map +1 -1
  22. package/lib/components/AppBar/useAppBar.js +17 -15
  23. package/lib/components/AttachmentDisplay/AttachmentDisplay.d.ts +182 -0
  24. package/lib/components/AttachmentDisplay/AttachmentDisplay.d.ts.map +1 -0
  25. package/lib/components/AttachmentDisplay/AttachmentDisplay.jsx +444 -0
  26. package/lib/components/AttachmentDisplay/index.d.ts +2 -0
  27. package/lib/components/AttachmentDisplay/index.d.ts.map +1 -0
  28. package/lib/components/AttachmentInput/AttachmentInput.d.ts +179 -0
  29. package/lib/components/AttachmentInput/AttachmentInput.d.ts.map +1 -0
  30. package/lib/components/AttachmentInput/AttachmentInput.jsx +520 -0
  31. package/lib/components/AttachmentInput/index.d.ts +2 -0
  32. package/lib/components/AttachmentInput/index.d.ts.map +1 -0
  33. package/lib/components/BottomSheet/BottomSheet.d.ts +1 -1
  34. package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
  35. package/lib/components/BottomSheet/BottomSheet.jsx +1 -7
  36. package/lib/components/Box/Box.d.ts +3 -3
  37. package/lib/components/Box/Box.d.ts.map +1 -1
  38. package/lib/components/Callout/Callout.jsx +2 -2
  39. package/lib/components/Checkbox/Checkbox.jsx +2 -2
  40. package/lib/components/Chip/Chip.jsx +2 -2
  41. package/lib/components/ChipTabs/ChipTabs.d.ts +41 -0
  42. package/lib/components/ChipTabs/ChipTabs.d.ts.map +1 -0
  43. package/lib/components/ChipTabs/ChipTabs.jsx +39 -0
  44. package/lib/components/ChipTabs/ChipTabs.namespace.d.ts +2 -0
  45. package/lib/components/ChipTabs/ChipTabs.namespace.d.ts.map +1 -0
  46. package/lib/components/ChipTabs/ChipTabs.namespace.js +13 -0
  47. package/lib/components/ChipTabs/index.d.ts +3 -0
  48. package/lib/components/ChipTabs/index.d.ts.map +1 -0
  49. package/lib/components/ContextualFloatingButton/ContextualFloatingButton.d.ts +18 -0
  50. package/lib/components/ContextualFloatingButton/ContextualFloatingButton.d.ts.map +1 -0
  51. package/lib/components/ContextualFloatingButton/ContextualFloatingButton.jsx +113 -0
  52. package/lib/components/ContextualFloatingButton/index.d.ts +2 -0
  53. package/lib/components/ContextualFloatingButton/index.d.ts.map +1 -0
  54. package/lib/components/Dialog/Dialog.d.ts +87 -0
  55. package/lib/components/Dialog/Dialog.d.ts.map +1 -0
  56. package/lib/components/Dialog/Dialog.jsx +147 -0
  57. package/lib/components/Dialog/Dialog.namespace.d.ts +2 -0
  58. package/lib/components/Dialog/Dialog.namespace.d.ts.map +1 -0
  59. package/lib/components/Dialog/Dialog.namespace.js +18 -0
  60. package/lib/components/Dialog/index.d.ts +3 -0
  61. package/lib/components/Dialog/index.d.ts.map +1 -0
  62. package/lib/components/FloatingActionButton/FloatingActionButton.d.ts +23 -0
  63. package/lib/components/FloatingActionButton/FloatingActionButton.d.ts.map +1 -0
  64. package/lib/components/FloatingActionButton/FloatingActionButton.jsx +76 -0
  65. package/lib/components/FloatingActionButton/FloatingActionButton.namespace.d.ts +2 -0
  66. package/lib/components/FloatingActionButton/FloatingActionButton.namespace.d.ts.map +1 -0
  67. package/lib/components/FloatingActionButton/FloatingActionButton.namespace.js +10 -0
  68. package/lib/components/FloatingActionButton/index.d.ts +3 -0
  69. package/lib/components/FloatingActionButton/index.d.ts.map +1 -0
  70. package/lib/components/HelpBubble/HelpBubble.d.ts +67 -0
  71. package/lib/components/HelpBubble/HelpBubble.d.ts.map +1 -0
  72. package/lib/components/HelpBubble/HelpBubble.jsx +600 -0
  73. package/lib/components/HelpBubble/HelpBubble.namespace.d.ts +2 -0
  74. package/lib/components/HelpBubble/HelpBubble.namespace.d.ts.map +1 -0
  75. package/lib/components/HelpBubble/HelpBubble.namespace.js +18 -0
  76. package/lib/components/HelpBubble/index.d.ts +3 -0
  77. package/lib/components/HelpBubble/index.d.ts.map +1 -0
  78. package/lib/components/Icon/Icon.d.ts +1 -0
  79. package/lib/components/Icon/Icon.d.ts.map +1 -1
  80. package/lib/components/Icon/Icon.jsx +2 -1
  81. package/lib/components/IdentityPlaceholder/IdentityPlaceholder.d.ts +28 -0
  82. package/lib/components/IdentityPlaceholder/IdentityPlaceholder.d.ts.map +1 -0
  83. package/lib/components/IdentityPlaceholder/IdentityPlaceholder.jsx +37 -0
  84. package/lib/components/IdentityPlaceholder/IdentityPlaceholder.namespace.d.ts +2 -0
  85. package/lib/components/IdentityPlaceholder/IdentityPlaceholder.namespace.d.ts.map +1 -0
  86. package/lib/components/IdentityPlaceholder/IdentityPlaceholder.namespace.js +9 -0
  87. package/lib/components/IdentityPlaceholder/identity-placeholder-business.js +4 -0
  88. package/lib/components/IdentityPlaceholder/identity-placeholder-person.js +4 -0
  89. package/lib/components/IdentityPlaceholder/index.d.ts +3 -0
  90. package/lib/components/IdentityPlaceholder/index.d.ts.map +1 -0
  91. package/lib/components/InputButton/InputButton.d.ts +2 -0
  92. package/lib/components/InputButton/InputButton.d.ts.map +1 -1
  93. package/lib/components/InputButton/InputButton.jsx +40 -8
  94. package/lib/components/List/List.d.ts +1 -1
  95. package/lib/components/List/List.d.ts.map +1 -1
  96. package/lib/components/List/List.jsx +26 -12
  97. package/lib/components/Menu/Menu.d.ts.map +1 -1
  98. package/lib/components/Menu/Menu.jsx +15 -5
  99. package/lib/components/PageBanner/PageBanner.d.ts +3 -0
  100. package/lib/components/PageBanner/PageBanner.d.ts.map +1 -1
  101. package/lib/components/PageBanner/PageBanner.jsx +49 -11
  102. package/lib/components/QuantityPicker/QuantityPicker.d.ts +53 -0
  103. package/lib/components/QuantityPicker/QuantityPicker.d.ts.map +1 -0
  104. package/lib/components/QuantityPicker/QuantityPicker.jsx +282 -0
  105. package/lib/components/QuantityPicker/QuantityPicker.namespace.d.ts +2 -0
  106. package/lib/components/QuantityPicker/QuantityPicker.namespace.d.ts.map +1 -0
  107. package/lib/components/QuantityPicker/QuantityPicker.namespace.js +11 -0
  108. package/lib/components/QuantityPicker/index.d.ts +3 -0
  109. package/lib/components/QuantityPicker/index.d.ts.map +1 -0
  110. package/lib/components/RadioGroup/RadioGroup.jsx +2 -2
  111. package/lib/components/ReactionButton/ReactionButton.d.ts +1 -1
  112. package/lib/components/ReactionButton/ReactionButton.d.ts.map +1 -1
  113. package/lib/components/ReactionButton/ReactionButton.jsx +22 -13
  114. package/lib/components/ScrollFog/ScrollFog.d.ts +41 -0
  115. package/lib/components/ScrollFog/ScrollFog.d.ts.map +1 -0
  116. package/lib/components/ScrollFog/ScrollFog.jsx +65 -0
  117. package/lib/components/ScrollFog/index.d.ts +2 -0
  118. package/lib/components/ScrollFog/index.d.ts.map +1 -0
  119. package/lib/components/SegmentedControl/SegmentedControl.jsx +2 -2
  120. package/lib/components/Select/Select.d.ts +112 -0
  121. package/lib/components/Select/Select.d.ts.map +1 -0
  122. package/lib/components/Select/Select.jsx +885 -0
  123. package/lib/components/Select/Select.namespace.d.ts +2 -0
  124. package/lib/components/Select/Select.namespace.d.ts.map +1 -0
  125. package/lib/components/Select/Select.namespace.js +23 -0
  126. package/lib/components/Select/index.d.ts +3 -0
  127. package/lib/components/Select/index.d.ts.map +1 -0
  128. package/lib/components/Skeleton/Skeleton.d.ts +15 -0
  129. package/lib/components/Skeleton/Skeleton.d.ts.map +1 -0
  130. package/lib/components/Skeleton/Skeleton.jsx +18 -0
  131. package/lib/components/Skeleton/index.d.ts +2 -0
  132. package/lib/components/Skeleton/index.d.ts.map +1 -0
  133. package/lib/components/Slider/Slider.d.ts +101 -0
  134. package/lib/components/Slider/Slider.d.ts.map +1 -0
  135. package/lib/components/Slider/Slider.jsx +573 -0
  136. package/lib/components/Slider/Slider.namespace.d.ts +2 -0
  137. package/lib/components/Slider/Slider.namespace.d.ts.map +1 -0
  138. package/lib/components/Slider/Slider.namespace.js +19 -0
  139. package/lib/components/Slider/Slider.utils.d.ts +19 -0
  140. package/lib/components/Slider/Slider.utils.d.ts.map +1 -0
  141. package/lib/components/Slider/Slider.utils.js +106 -0
  142. package/lib/components/Slider/index.d.ts +3 -0
  143. package/lib/components/Slider/index.d.ts.map +1 -0
  144. package/lib/components/Stack/Stack.d.ts +7 -9
  145. package/lib/components/Stack/Stack.d.ts.map +1 -1
  146. package/lib/components/SwipeableMenuSheet/SwipeableMenuSheet.d.ts.map +1 -1
  147. package/lib/components/SwipeableMenuSheet/SwipeableMenuSheet.jsx +22 -8
  148. package/lib/components/Switch/Switch.d.ts.map +1 -1
  149. package/lib/components/Switch/Switch.jsx +5 -3
  150. package/lib/components/Tabs/Tabs.d.ts +34 -2
  151. package/lib/components/Tabs/Tabs.d.ts.map +1 -1
  152. package/lib/components/Tabs/Tabs.jsx +186 -56
  153. package/lib/components/Tabs/Tabs.utils.d.ts +14 -1
  154. package/lib/components/Tabs/Tabs.utils.d.ts.map +1 -1
  155. package/lib/components/Tabs/Tabs.utils.js +24 -3
  156. package/lib/components/Tabs/index.d.ts +1 -1
  157. package/lib/components/Tabs/index.d.ts.map +1 -1
  158. package/lib/components/index.d.ts +14 -0
  159. package/lib/components/index.d.ts.map +1 -1
  160. package/lib/hooks/useControllableState.d.ts +1 -14
  161. package/lib/hooks/useControllableState.d.ts.map +1 -1
  162. package/lib/hooks/usePressTap.d.ts +1 -27
  163. package/lib/hooks/usePressTap.d.ts.map +1 -1
  164. package/lib/hooks/useSafeArea.d.ts +8 -4
  165. package/lib/hooks/useSafeArea.d.ts.map +1 -1
  166. package/lib/hooks/useSafeArea.js +22 -20
  167. package/lib/index.js +29 -6
  168. package/lib/{hooks/useControllableState.js → packages/lynx-react-headless/use-controllable-state/lib/index.js} +2 -3
  169. package/lib/{hooks/usePressTap.js → packages/lynx-react-headless/use-press-tap/lib/index.js} +13 -10
  170. package/lib/types.d.ts +1 -0
  171. package/lib/types.d.ts.map +1 -1
  172. package/lib/utils/styled.d.ts +46 -6
  173. package/lib/utils/styled.d.ts.map +1 -1
  174. package/lib/utils/styled.js +19 -4
  175. package/package.json +9 -5
  176. package/src/components/AlertDialog/AlertDialog.namespace.ts +22 -0
  177. package/src/components/AlertDialog/AlertDialog.test.tsx +226 -0
  178. package/src/components/AlertDialog/AlertDialog.tsx +374 -0
  179. package/src/components/AlertDialog/index.ts +24 -0
  180. package/src/components/AppBar/AppBar.namespace.ts +1 -0
  181. package/src/components/AppBar/AppBar.test.tsx +252 -3
  182. package/src/components/AppBar/AppBar.tsx +108 -25
  183. package/src/components/AppBar/context.ts +3 -1
  184. package/src/components/AppBar/index.ts +1 -0
  185. package/src/components/AppBar/useAppBar.ts +21 -15
  186. package/src/components/AttachmentDisplay/AttachmentDisplay.tsx +886 -0
  187. package/src/components/AttachmentDisplay/index.ts +48 -0
  188. package/src/components/AttachmentInput/AttachmentInput.tsx +1001 -0
  189. package/src/components/AttachmentInput/index.ts +49 -0
  190. package/src/components/BottomSheet/BottomSheet.test.tsx +22 -7
  191. package/src/components/BottomSheet/BottomSheet.tsx +1 -19
  192. package/src/components/Box/Box.test.tsx +104 -0
  193. package/src/components/Box/Box.tsx +9 -6
  194. package/src/components/ChipTabs/ChipTabs.namespace.ts +14 -0
  195. package/src/components/ChipTabs/ChipTabs.tsx +119 -0
  196. package/src/components/ChipTabs/index.ts +16 -0
  197. package/src/components/ContextualFloatingButton/ContextualFloatingButton.test.tsx +63 -0
  198. package/src/components/ContextualFloatingButton/ContextualFloatingButton.tsx +232 -0
  199. package/src/components/ContextualFloatingButton/index.ts +4 -0
  200. package/src/components/Dialog/Dialog.namespace.ts +24 -0
  201. package/src/components/Dialog/Dialog.test.tsx +172 -0
  202. package/src/components/Dialog/Dialog.tsx +373 -0
  203. package/src/components/Dialog/index.ts +26 -0
  204. package/src/components/FloatingActionButton/FloatingActionButton.namespace.ts +8 -0
  205. package/src/components/FloatingActionButton/FloatingActionButton.test.tsx +59 -0
  206. package/src/components/FloatingActionButton/FloatingActionButton.tsx +207 -0
  207. package/src/components/FloatingActionButton/index.ts +10 -0
  208. package/src/components/HelpBubble/HelpBubble.namespace.ts +24 -0
  209. package/src/components/HelpBubble/HelpBubble.tsx +998 -0
  210. package/src/components/HelpBubble/index.ts +26 -0
  211. package/src/components/Icon/Icon.test.tsx +0 -3
  212. package/src/components/Icon/Icon.tsx +11 -1
  213. package/src/components/IdentityPlaceholder/IdentityPlaceholder.namespace.ts +6 -0
  214. package/src/components/IdentityPlaceholder/IdentityPlaceholder.tsx +103 -0
  215. package/src/components/IdentityPlaceholder/assets.d.ts +4 -0
  216. package/src/components/IdentityPlaceholder/identity-placeholder-business.webp +0 -0
  217. package/src/components/IdentityPlaceholder/identity-placeholder-person.webp +0 -0
  218. package/src/components/IdentityPlaceholder/index.ts +8 -0
  219. package/src/components/InputButton/InputButton.test.tsx +128 -1
  220. package/src/components/InputButton/InputButton.tsx +60 -9
  221. package/src/components/List/List.test.tsx +54 -2
  222. package/src/components/List/List.tsx +43 -10
  223. package/src/components/Menu/Menu.tsx +14 -4
  224. package/src/components/Menu/__tests__/Menu.test.tsx +34 -0
  225. package/src/components/PageBanner/PageBanner.test.tsx +110 -3
  226. package/src/components/PageBanner/PageBanner.tsx +83 -19
  227. package/src/components/QuantityPicker/QuantityPicker.namespace.ts +10 -0
  228. package/src/components/QuantityPicker/QuantityPicker.test.tsx +235 -0
  229. package/src/components/QuantityPicker/QuantityPicker.tsx +605 -0
  230. package/src/components/QuantityPicker/index.ts +14 -0
  231. package/src/components/ReactionButton/ReactionButton.feedback.test.tsx +50 -0
  232. package/src/components/ReactionButton/ReactionButton.test.tsx +5 -3
  233. package/src/components/ReactionButton/ReactionButton.tsx +20 -12
  234. package/src/components/ScrollFog/ScrollFog.test.tsx +222 -0
  235. package/src/components/ScrollFog/ScrollFog.tsx +172 -0
  236. package/src/components/ScrollFog/index.ts +1 -0
  237. package/src/components/Select/Select.namespace.ts +34 -0
  238. package/src/components/Select/Select.test.tsx +297 -0
  239. package/src/components/Select/Select.tsx +1483 -0
  240. package/src/components/Select/index.ts +39 -0
  241. package/src/components/Skeleton/Skeleton.test.tsx +64 -0
  242. package/src/components/Skeleton/Skeleton.tsx +45 -0
  243. package/src/components/Skeleton/index.ts +1 -0
  244. package/src/components/Slider/Slider.namespace.ts +26 -0
  245. package/src/components/Slider/Slider.test.tsx +260 -0
  246. package/src/components/Slider/Slider.tsx +897 -0
  247. package/src/components/Slider/Slider.utils.ts +167 -0
  248. package/src/components/Slider/index.ts +30 -0
  249. package/src/components/Stack/Stack.test.tsx +7 -0
  250. package/src/components/Stack/Stack.tsx +11 -10
  251. package/src/components/SwipeableMenuSheet/SwipeableMenuSheet.test.tsx +21 -1
  252. package/src/components/SwipeableMenuSheet/SwipeableMenuSheet.tsx +30 -7
  253. package/src/components/Switch/Switch.tsx +14 -13
  254. package/src/components/Tabs/Tabs.test.tsx +218 -1
  255. package/src/components/Tabs/Tabs.tsx +346 -75
  256. package/src/components/Tabs/Tabs.utils.ts +51 -1
  257. package/src/components/Tabs/index.ts +17 -1
  258. package/src/components/index.ts +14 -0
  259. package/src/hooks/useControllableState.ts +1 -43
  260. package/src/hooks/usePressTap.test.ts +23 -11
  261. package/src/hooks/usePressTap.ts +1 -60
  262. package/src/hooks/useSafeArea.test.ts +13 -1
  263. package/src/hooks/useSafeArea.ts +25 -23
  264. package/src/types.ts +1 -0
  265. package/src/utils/styled.ts +127 -9
@@ -0,0 +1,885 @@
1
+ import { useControllableState } from "../../packages/lynx-react-headless/use-controllable-state/lib/index.js";
2
+ import { usePressTap } from "../../packages/lynx-react-headless/use-press-tap/lib/index.js";
3
+ import { toArray } from "../../utils/children.js";
4
+ import { InternalIcon } from "../Icon/Icon.jsx";
5
+ import { useFieldContext } from "../Field/context.js";
6
+ import { computePosition } from "../private/Positioning.js";
7
+ import * as React from "@lynx-js/react";
8
+ import { isValidElement } from "@lynx-js/react";
9
+ import clsx from "clsx";
10
+ import { getRectByRef } from "@lynx-js/lynx-ui-common";
11
+ import { select } from "@seed-design/lynx-css/vars/component";
12
+ import { select as select$1 } from "@seed-design/lynx-css/recipes/select";
13
+ import { selectTrigger } from "@seed-design/lynx-css/recipes/select-trigger";
14
+ import { selectItem } from "@seed-design/lynx-css/recipes/select-item";
15
+ //#region src/components/Select/Select.tsx
16
+ var EMPTY_VALUE = [];
17
+ var selectGutter = 8;
18
+ var selectOverflowPadding = 8;
19
+ var selectMaxHeight = Number.parseFloat(select.base.enabled.root.maxHeight);
20
+ var selectMinimumAvailableHeight = 200;
21
+ var nextSelectScrollAreaId = 0;
22
+ var SelectContext = React.createContext(null);
23
+ var SelectItemContext = React.createContext(null);
24
+ var SelectGroupPositionContext = React.createContext({ isFirst: true });
25
+ function useSelectContext(consumer) {
26
+ const context = React.useContext(SelectContext);
27
+ if (!context) throw new Error(`<${consumer}/> must be rendered inside <SelectRoot/>.`);
28
+ return context;
29
+ }
30
+ function useSelectItemContext(consumer) {
31
+ const context = React.useContext(SelectItemContext);
32
+ if (!context) throw new Error(`<${consumer}/> must be rendered inside <SelectItem/>.`);
33
+ return context;
34
+ }
35
+ function mergeNodeRef(forwardedRef, node) {
36
+ if (typeof forwardedRef === "function") forwardedRef(node);
37
+ else if (forwardedRef) forwardedRef.current = node;
38
+ }
39
+ function getScreenRect() {
40
+ const systemInfo = typeof SystemInfo === "undefined" ? void 0 : SystemInfo;
41
+ const pixelWidth = systemInfo?.pixelWidth;
42
+ const pixelHeight = systemInfo?.pixelHeight;
43
+ const pixelRatio = systemInfo?.pixelRatio;
44
+ if (typeof pixelWidth !== "number" || typeof pixelHeight !== "number" || typeof pixelRatio !== "number" || pixelWidth <= 0 || pixelHeight <= 0 || pixelRatio <= 0) return null;
45
+ const width = pixelWidth / pixelRatio;
46
+ const height = pixelHeight / pixelRatio;
47
+ return {
48
+ left: 0,
49
+ top: 0,
50
+ right: width,
51
+ bottom: height,
52
+ width,
53
+ height
54
+ };
55
+ }
56
+ function getRootRect() {
57
+ "background only";
58
+ return getRectByRef({ current: lynx.createSelectorQuery().selectRoot() }, true);
59
+ }
60
+ function toPixel(value) {
61
+ return `${value}px`;
62
+ }
63
+ function areStylesEqual(left, right) {
64
+ if (left === right) return true;
65
+ if (!left || !right) return false;
66
+ const leftEntries = Object.entries(left);
67
+ if (leftEntries.length !== Object.keys(right).length) return false;
68
+ return leftEntries.every(([key, value]) => Object.is(value, right[key]));
69
+ }
70
+ function hasExitTransition(event) {
71
+ if (event.target.uid !== event.currentTarget.uid) return false;
72
+ return event.params.animation_type === "transition-opacity" || event.params.animation_name === "opacity";
73
+ }
74
+ function isSameValue(a, b) {
75
+ return a.length === b.length && a.every((entry, index) => entry === b[index]);
76
+ }
77
+ function renderTextContent(className, value, ref, nativeProps) {
78
+ if (typeof value === "string" || typeof value === "number") return <text {...ref ? { ref } : {}} className={className} {...nativeProps}>
79
+ {value}
80
+ </text>;
81
+ return <view {...ref ? { ref } : {}} className={className} {...nativeProps}>
82
+ {value}
83
+ </view>;
84
+ }
85
+ var SelectRoot = React.forwardRef((props, ref) => {
86
+ const screenRect = getScreenRect();
87
+ const [variantProps, otherProps] = select$1.splitVariantProps({
88
+ ...props,
89
+ size: props.size === "responsive" ? screenRect?.width != null && screenRect.width >= 1280 ? "medium" : "large" : props.size
90
+ });
91
+ const { size = "large", open: openProp } = variantProps;
92
+ const { children, className, value: valueProp, defaultValue = EMPTY_VALUE, onValueChange, multiple = false, defaultOpen = false, onOpenChange, disabled: disabledProp, readOnly: readOnlyProp, invalid: invalidProp, required: requiredProp, placement = "bottom", gutter = selectGutter, overflowPadding = selectOverflowPadding, formatValue, ...nativeProps } = otherProps;
93
+ const fieldContext = useFieldContext({ strict: false });
94
+ const disabled = disabledProp ?? fieldContext?.disabled ?? false;
95
+ const readOnly = readOnlyProp ?? fieldContext?.readOnly ?? false;
96
+ const invalid = invalidProp ?? fieldContext?.invalid ?? false;
97
+ const required = requiredProp ?? fieldContext?.required ?? false;
98
+ const [value, setValueState] = useControllableState({
99
+ value: valueProp,
100
+ defaultValue,
101
+ onChange: onValueChange
102
+ });
103
+ const [open, setOpenState] = useControllableState({
104
+ value: openProp,
105
+ defaultValue: defaultOpen
106
+ });
107
+ const [optionRegistry, setOptionRegistry] = React.useState(() => /* @__PURE__ */ new Map());
108
+ const [mounted, setMounted] = React.useState(open);
109
+ const [positionedEpoch, setPositionedEpoch] = React.useState(null);
110
+ const isOpenRef = React.useRef(open);
111
+ const openEpochRef = React.useRef(0);
112
+ if (open && !isOpenRef.current) openEpochRef.current++;
113
+ isOpenRef.current = open;
114
+ const openEpoch = openEpochRef.current;
115
+ const positioned = positionedEpoch === openEpoch;
116
+ const [triggerHandlers, setTriggerHandlers] = React.useState({});
117
+ const triggerRef = React.useRef(null);
118
+ const classes = select$1({
119
+ ...variantProps,
120
+ open,
121
+ positioned
122
+ });
123
+ const selectedItems = React.useMemo(() => value.map((optionValue) => {
124
+ const entry = optionRegistry.get(optionValue);
125
+ return entry ? {
126
+ ...entry,
127
+ value: optionValue,
128
+ resolved: true
129
+ } : {
130
+ value: optionValue,
131
+ label: null,
132
+ textValue: "",
133
+ resolved: false
134
+ };
135
+ }), [optionRegistry, value]);
136
+ const selectedOption = value.length === 1 ? optionRegistry.get(value[0] ?? "") : void 0;
137
+ const selectedItem = selectedOption ? {
138
+ ...selectedOption,
139
+ value: value[0] ?? "",
140
+ resolved: true
141
+ } : void 0;
142
+ const showPlaceholder = value.length === 0 || optionRegistry.size > 0 && selectedItems.every((item) => !item.resolved);
143
+ const displayValue = showPlaceholder ? void 0 : formatValue ? formatValue(selectedItems) : selectedItems.filter((item) => item.resolved).map((item) => item.textValue).join(", ");
144
+ React.useEffect(() => {
145
+ "background only";
146
+ if (open) {
147
+ setMounted(true);
148
+ return;
149
+ }
150
+ if (!positioned) setMounted(false);
151
+ }, [open, positioned]);
152
+ const setPositioned = React.useCallback((nextPositioned) => setPositionedEpoch(nextPositioned ? openEpochRef.current : null), []);
153
+ const requestOpen = React.useCallback((nextOpen, details) => {
154
+ "background only";
155
+ if (nextOpen && (disabled || readOnly)) return;
156
+ if (nextOpen === open) return;
157
+ setOpenState(nextOpen);
158
+ onOpenChange?.(nextOpen, details);
159
+ }, [
160
+ disabled,
161
+ onOpenChange,
162
+ open,
163
+ readOnly,
164
+ setOpenState
165
+ ]);
166
+ const finishClose = React.useCallback((immediate = false) => {
167
+ "background only";
168
+ if (immediate || !isOpenRef.current) {
169
+ setMounted(false);
170
+ setPositionedEpoch(null);
171
+ }
172
+ }, []);
173
+ const selectValue = React.useCallback((nextValue, event) => {
174
+ "background only";
175
+ if (disabled || readOnly) return;
176
+ const next = multiple ? value.includes(nextValue) ? value.filter((entry) => entry !== nextValue) : [...value, nextValue] : [nextValue];
177
+ if (!isSameValue(value, next)) setValueState(next);
178
+ if (!multiple) requestOpen(false, {
179
+ reason: "itemSelect",
180
+ event
181
+ });
182
+ }, [
183
+ disabled,
184
+ multiple,
185
+ readOnly,
186
+ requestOpen,
187
+ setValueState,
188
+ value
189
+ ]);
190
+ const registerOption = React.useCallback((optionValue, entry) => {
191
+ setOptionRegistry((current) => {
192
+ const previous = current.get(optionValue);
193
+ if (previous && previous.label === entry.label && previous.textValue === entry.textValue && previous.prefixIcon === entry.prefixIcon && previous.node === entry.node) return current;
194
+ return new Map(current).set(optionValue, entry);
195
+ });
196
+ }, []);
197
+ const unregisterOption = React.useCallback((optionValue) => {
198
+ setOptionRegistry((current) => {
199
+ if (!current.has(optionValue)) return current;
200
+ const next = new Map(current);
201
+ next.delete(optionValue);
202
+ return next;
203
+ });
204
+ }, []);
205
+ const contextValue = React.useMemo(() => ({
206
+ value,
207
+ selectedItems,
208
+ selectedItem,
209
+ displayValue,
210
+ showPlaceholder,
211
+ multiple,
212
+ open,
213
+ mounted,
214
+ openEpoch,
215
+ disabled,
216
+ readOnly,
217
+ invalid,
218
+ required,
219
+ size,
220
+ placement,
221
+ gutter,
222
+ overflowPadding,
223
+ isOpenRef,
224
+ openEpochRef,
225
+ triggerRef,
226
+ triggerHandlers,
227
+ setTriggerHandlers,
228
+ classes,
229
+ positioned,
230
+ setPositioned,
231
+ requestOpen,
232
+ finishClose,
233
+ selectValue,
234
+ registerOption,
235
+ unregisterOption
236
+ }), [
237
+ classes,
238
+ disabled,
239
+ displayValue,
240
+ finishClose,
241
+ gutter,
242
+ invalid,
243
+ mounted,
244
+ multiple,
245
+ open,
246
+ openEpoch,
247
+ overflowPadding,
248
+ placement,
249
+ positioned,
250
+ readOnly,
251
+ registerOption,
252
+ requestOpen,
253
+ required,
254
+ selectValue,
255
+ selectedItem,
256
+ selectedItems,
257
+ setPositioned,
258
+ showPlaceholder,
259
+ size,
260
+ triggerHandlers,
261
+ unregisterOption,
262
+ value
263
+ ]);
264
+ return <SelectContext.Provider value={contextValue}>
265
+ <view {...ref ? { ref } : {}} className={className} {...nativeProps}>
266
+ {children}
267
+ </view>
268
+ </SelectContext.Provider>;
269
+ });
270
+ SelectRoot.displayName = "SelectRoot";
271
+ var SelectTrigger = React.forwardRef((props, ref) => {
272
+ const { children, className, placeholder, prefixIcon, suffixIcon, bindtap, "main-thread:bindtap": mainThreadBindtap, "accessibility-element": accessibilityElement = true, "accessibility-label": accessibilityLabel, "accessibility-traits": accessibilityTraits, ...nativeProps } = props;
273
+ const context = useSelectContext("SelectTrigger");
274
+ const nonInteractive = context.disabled || context.readOnly;
275
+ const { pressed, bindtap: proxyBindtap, ...pressHandlers } = usePressTap({
276
+ disabled: nonInteractive,
277
+ onTap: React.useCallback((event, instance) => {
278
+ "background only";
279
+ context.requestOpen(!context.open, {
280
+ reason: "trigger",
281
+ event
282
+ });
283
+ bindtap?.(event, instance);
284
+ }, [
285
+ bindtap,
286
+ context.open,
287
+ context.requestOpen
288
+ ]),
289
+ mainThreadOnTap: mainThreadBindtap
290
+ });
291
+ const mainThreadProxyBindtap = pressHandlers["main-thread:bindtap"];
292
+ React.useEffect(() => {
293
+ "background only";
294
+ context.setTriggerHandlers({
295
+ bindtap: proxyBindtap,
296
+ "main-thread:bindtap": mainThreadProxyBindtap
297
+ });
298
+ return () => {
299
+ context.setTriggerHandlers({});
300
+ };
301
+ }, [
302
+ context.setTriggerHandlers,
303
+ mainThreadProxyBindtap,
304
+ proxyBindtap
305
+ ]);
306
+ const handleRef = React.useCallback((node) => {
307
+ context.triggerRef.current = node;
308
+ mergeNodeRef(ref, node);
309
+ }, [context.triggerRef, ref]);
310
+ const classes = selectTrigger({
311
+ size: context.size,
312
+ open: context.open,
313
+ pressed,
314
+ disabled: context.disabled,
315
+ readOnly: context.readOnly,
316
+ invalid: context.invalid
317
+ });
318
+ return <view ref={handleRef} className={clsx(classes.root, className)} accessibility-element={accessibilityElement} accessibility-label={accessibilityLabel} accessibility-role-description="button" accessibility-value={context.open ? "expanded" : "collapsed"} accessibility-traits={nonInteractive ? "disabled" : accessibilityTraits ?? "button"} {...nativeProps} {...pressHandlers} bindtap={proxyBindtap}>
319
+ <view className={classes.pressedOverlay} accessibility-elements-hidden={true} />
320
+ {children ?? <>
321
+ <SelectPrefixIcon fallback={prefixIcon} />
322
+ <SelectValue />
323
+ <SelectPlaceholder>{placeholder}</SelectPlaceholder>
324
+ <SelectSuffixIcon icon={suffixIcon} />
325
+ </>}
326
+ </view>;
327
+ });
328
+ SelectTrigger.displayName = "SelectTrigger";
329
+ var SelectValue = React.forwardRef((props, ref) => {
330
+ const { children, className, ...nativeProps } = props;
331
+ const context = useSelectContext("SelectValue");
332
+ if (context.showPlaceholder) return null;
333
+ return renderTextContent(clsx(selectTrigger({
334
+ size: context.size,
335
+ open: context.open,
336
+ disabled: context.disabled,
337
+ readOnly: context.readOnly,
338
+ invalid: context.invalid
339
+ }).value, className), children ?? context.displayValue, ref, nativeProps);
340
+ });
341
+ SelectValue.displayName = "SelectValue";
342
+ var SelectPlaceholder = React.forwardRef((props, ref) => {
343
+ const { children, className, ...nativeProps } = props;
344
+ const context = useSelectContext("SelectPlaceholder");
345
+ if (!context.showPlaceholder) return null;
346
+ return renderTextContent(clsx(selectTrigger({
347
+ size: context.size,
348
+ open: context.open,
349
+ disabled: context.disabled,
350
+ readOnly: context.readOnly,
351
+ invalid: context.invalid
352
+ }).placeholder, className), children, ref, nativeProps);
353
+ });
354
+ SelectPlaceholder.displayName = "SelectPlaceholder";
355
+ var SelectPrefixIcon = React.forwardRef((props, ref) => {
356
+ const { fallback, className, ...nativeProps } = props;
357
+ const context = useSelectContext("SelectPrefixIcon");
358
+ const icon = context.selectedItem?.prefixIcon ?? fallback;
359
+ if (!isValidElement(icon)) return null;
360
+ const classes = selectTrigger({
361
+ size: context.size,
362
+ open: context.open,
363
+ disabled: context.disabled,
364
+ readOnly: context.readOnly,
365
+ invalid: context.invalid
366
+ });
367
+ return <InternalIcon ref={ref} icon={icon} className={clsx(classes.prefixIcon, className)} accessibility-elements-hidden={true} deps={[context.selectedItem?.prefixIcon, context.value]} {...nativeProps} />;
368
+ });
369
+ SelectPrefixIcon.displayName = "SelectPrefixIcon";
370
+ var SelectSuffixIcon = React.forwardRef((props, ref) => {
371
+ const { icon, className, ...nativeProps } = props;
372
+ const context = useSelectContext("SelectSuffixIcon");
373
+ const classes = selectTrigger({
374
+ size: context.size,
375
+ open: context.open,
376
+ disabled: context.disabled,
377
+ readOnly: context.readOnly,
378
+ invalid: context.invalid
379
+ });
380
+ if (!isValidElement(icon)) return <text {...ref ? { ref } : {}} className={clsx(classes.suffixIcon, className)} accessibility-elements-hidden={true} {...nativeProps}>
381
+ ⌄
382
+ </text>;
383
+ return <InternalIcon ref={ref} icon={icon} className={clsx(classes.suffixIcon, className)} accessibility-elements-hidden={true} deps={[context.open]} {...nativeProps} />;
384
+ });
385
+ SelectSuffixIcon.displayName = "SelectSuffixIcon";
386
+ var SelectContent = React.forwardRef((props, ref) => {
387
+ const { children, className, style, ...nativeProps } = props;
388
+ const context = useSelectContext("SelectContent");
389
+ const measurementVersionRef = React.useRef(0);
390
+ const intrinsicMeasurementVersionRef = React.useRef(0);
391
+ const scrollRequestVersionRef = React.useRef(0);
392
+ const scrolledEpochRef = React.useRef(null);
393
+ const overlayNodeRef = React.useRef(null);
394
+ const scrollNodeRef = React.useRef(null);
395
+ const scrollContentNodeRef = React.useRef(null);
396
+ const overlayAttachedRef = React.useRef(false);
397
+ const scrollAttachedRef = React.useRef(false);
398
+ const scrollContentAttachedRef = React.useRef(false);
399
+ const [overlayAttached, setOverlayAttached] = React.useState(false);
400
+ const [scrollAttached, setScrollAttached] = React.useState(false);
401
+ const [scrollContentAttached, setScrollContentAttached] = React.useState(false);
402
+ const [scrollAreaId, setScrollAreaId] = React.useState(void 0);
403
+ React.useEffect(() => {
404
+ "background only";
405
+ setScrollAreaId(`seed-select-scroll-area-${nextSelectScrollAreaId++}`);
406
+ }, []);
407
+ const measurementConfigRef = React.useRef(0);
408
+ const configuredClassNameRef = React.useRef(className);
409
+ const configuredSizeRef = React.useRef(context.size);
410
+ const configuredStyleRef = React.useRef(style);
411
+ const [intrinsicSize, setIntrinsicSize] = React.useState(null);
412
+ const [position, setPosition] = React.useState(null);
413
+ const [widthConstraint, setWidthConstraint] = React.useState(null);
414
+ const [overlayRect, setOverlayRect] = React.useState(null);
415
+ const [triggerRect, setTriggerRect] = React.useState(null);
416
+ const selectedNode = context.selectedItem?.node;
417
+ const measurePosition = React.useCallback(async () => {
418
+ "background only";
419
+ const referenceNode = context.triggerRef.current;
420
+ const openEpoch = context.openEpoch;
421
+ const overlayNode = overlayNodeRef.current;
422
+ if (!context.open || !referenceNode || !overlayNode || !intrinsicSize || intrinsicSize.epoch !== openEpoch || intrinsicSize.config !== measurementConfigRef.current) return;
423
+ const version = ++measurementVersionRef.current;
424
+ try {
425
+ const [reference, boundary, overlay] = await Promise.all([
426
+ getRectByRef({ current: referenceNode }, true),
427
+ getRootRect(),
428
+ getRectByRef({ current: overlayNode }, true)
429
+ ]);
430
+ if (version !== measurementVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current) return;
431
+ const width = widthConstraint ?? reference.width;
432
+ const nextPosition = await computePosition({
433
+ reference,
434
+ boundary,
435
+ width,
436
+ height: Math.min(intrinsicSize.height, selectMaxHeight),
437
+ placement: context.placement,
438
+ gutter: context.gutter,
439
+ overflowPadding: context.overflowPadding,
440
+ flip: { fallbackStrategy: "bestFit" },
441
+ shift: { crossAxis: true },
442
+ size: {
443
+ order: "beforeFlip",
444
+ minimumHeight: selectMinimumAvailableHeight
445
+ }
446
+ });
447
+ if (version !== measurementVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current) return;
448
+ if (nextPosition.availableWidth < width) {
449
+ const constrainedWidth = nextPosition.availableWidth;
450
+ if (widthConstraint !== constrainedWidth) {
451
+ measurementVersionRef.current++;
452
+ measurementConfigRef.current++;
453
+ intrinsicMeasurementVersionRef.current++;
454
+ scrollRequestVersionRef.current++;
455
+ setWidthConstraint(constrainedWidth);
456
+ setIntrinsicSize(null);
457
+ setPosition(null);
458
+ setOverlayRect(null);
459
+ setTriggerRect(null);
460
+ context.setPositioned(false);
461
+ }
462
+ return;
463
+ }
464
+ setPosition((previous) => {
465
+ if (previous?.left === nextPosition.left && previous.top === nextPosition.top && previous.width === nextPosition.width && previous.height === nextPosition.height && previous.placement === nextPosition.placement) return previous;
466
+ return nextPosition;
467
+ });
468
+ setOverlayRect(overlay);
469
+ setTriggerRect(reference);
470
+ context.setPositioned(true);
471
+ } catch {}
472
+ }, [
473
+ context.gutter,
474
+ context.isOpenRef,
475
+ context.open,
476
+ context.openEpoch,
477
+ context.openEpochRef,
478
+ context.overflowPadding,
479
+ context.placement,
480
+ context.setPositioned,
481
+ context.triggerRef,
482
+ intrinsicSize,
483
+ overlayAttached,
484
+ widthConstraint
485
+ ]);
486
+ const measureIntrinsicSize = React.useCallback(async () => {
487
+ "background only";
488
+ const scrollNode = scrollNodeRef.current;
489
+ const scrollContentNode = scrollContentNodeRef.current;
490
+ const openEpoch = context.openEpochRef.current;
491
+ const config = measurementConfigRef.current;
492
+ if (!context.isOpenRef.current || !scrollAreaId || !scrollNode || !scrollContentNode) return;
493
+ const version = ++intrinsicMeasurementVersionRef.current;
494
+ try {
495
+ const rect = await getRectByRef({ current: scrollContentNode }, false, scrollAreaId);
496
+ if (version !== intrinsicMeasurementVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current || config !== measurementConfigRef.current) return;
497
+ setIntrinsicSize((current) => {
498
+ if (current?.width === rect.width && current.height === rect.height && current.epoch === openEpoch && current.config === config) return current;
499
+ return {
500
+ width: rect.width,
501
+ height: rect.height,
502
+ epoch: openEpoch,
503
+ config
504
+ };
505
+ });
506
+ } catch {}
507
+ }, [
508
+ context.isOpenRef,
509
+ context.openEpochRef,
510
+ scrollAreaId
511
+ ]);
512
+ React.useEffect(() => {
513
+ "background only";
514
+ measurementVersionRef.current++;
515
+ intrinsicMeasurementVersionRef.current++;
516
+ scrollRequestVersionRef.current++;
517
+ setWidthConstraint(null);
518
+ setPosition(null);
519
+ setOverlayRect(null);
520
+ setTriggerRect(null);
521
+ setIntrinsicSize((current) => current ? {
522
+ ...current,
523
+ epoch: context.openEpoch
524
+ } : current);
525
+ scrolledEpochRef.current = null;
526
+ if (scrollNodeRef.current && scrollContentNodeRef.current) measureIntrinsicSize();
527
+ }, [context.openEpoch, measureIntrinsicSize]);
528
+ React.useEffect(() => {
529
+ "background only";
530
+ if (context.open) return;
531
+ measurementVersionRef.current++;
532
+ intrinsicMeasurementVersionRef.current++;
533
+ scrollRequestVersionRef.current++;
534
+ }, [context.open]);
535
+ React.useEffect(() => {
536
+ "background only";
537
+ return () => {
538
+ measurementVersionRef.current++;
539
+ intrinsicMeasurementVersionRef.current++;
540
+ scrollRequestVersionRef.current++;
541
+ };
542
+ }, []);
543
+ React.useEffect(() => {
544
+ "background only";
545
+ if (configuredClassNameRef.current === className && configuredSizeRef.current === context.size && areStylesEqual(configuredStyleRef.current, style)) return;
546
+ measurementVersionRef.current++;
547
+ intrinsicMeasurementVersionRef.current++;
548
+ scrollRequestVersionRef.current++;
549
+ measurementConfigRef.current++;
550
+ configuredClassNameRef.current = className;
551
+ configuredSizeRef.current = context.size;
552
+ configuredStyleRef.current = style;
553
+ setWidthConstraint(null);
554
+ setIntrinsicSize(null);
555
+ setPosition(null);
556
+ setOverlayRect(null);
557
+ setTriggerRect(null);
558
+ context.setPositioned(false);
559
+ if (scrollNodeRef.current && scrollContentNodeRef.current) measureIntrinsicSize();
560
+ }, [
561
+ className,
562
+ context.setPositioned,
563
+ context.size,
564
+ measureIntrinsicSize,
565
+ style
566
+ ]);
567
+ React.useEffect(() => {
568
+ "background only";
569
+ if (scrollAttached && scrollContentAttached) measureIntrinsicSize();
570
+ }, [
571
+ measureIntrinsicSize,
572
+ scrollAttached,
573
+ scrollContentAttached
574
+ ]);
575
+ React.useEffect(() => {
576
+ "background only";
577
+ if (context.open) measurePosition();
578
+ }, [context.open, measurePosition]);
579
+ React.useEffect(() => {
580
+ "background only";
581
+ if (context.open && widthConstraint != null) measureIntrinsicSize();
582
+ }, [
583
+ context.open,
584
+ measureIntrinsicSize,
585
+ widthConstraint
586
+ ]);
587
+ React.useEffect(() => {
588
+ "background only";
589
+ const requestVersion = ++scrollRequestVersionRef.current;
590
+ const openEpoch = context.openEpoch;
591
+ const selected = context.selectedItem;
592
+ const scrollNode = scrollNodeRef.current;
593
+ if (!context.open || !context.positioned || !position || !intrinsicSize || intrinsicSize.epoch !== openEpoch || intrinsicSize.config !== measurementConfigRef.current || !selected?.node || !scrollNode || !scrollAreaId || scrolledEpochRef.current === openEpoch) return;
594
+ if (intrinsicSize.height <= position.height) {
595
+ scrolledEpochRef.current = openEpoch;
596
+ return;
597
+ }
598
+ const entry = selected.node;
599
+ getRectByRef({ current: entry }, false, scrollAreaId).then((item) => {
600
+ if (requestVersion !== scrollRequestVersionRef.current || !context.isOpenRef.current || openEpoch !== context.openEpochRef.current || scrolledEpochRef.current === openEpoch) return;
601
+ const offset = item.top < 0 ? item.top : item.bottom > position.height ? item.bottom - position.height : 0;
602
+ if (offset === 0) {
603
+ scrolledEpochRef.current = openEpoch;
604
+ return;
605
+ }
606
+ try {
607
+ scrollNode.invoke({
608
+ method: "scrollBy",
609
+ params: { offset }
610
+ }).exec();
611
+ scrolledEpochRef.current = openEpoch;
612
+ } catch {}
613
+ }).catch(() => {});
614
+ }, [
615
+ context.isOpenRef,
616
+ context.open,
617
+ context.openEpoch,
618
+ context.openEpochRef,
619
+ context.positioned,
620
+ context.selectedItem,
621
+ intrinsicSize,
622
+ position,
623
+ scrollAreaId,
624
+ scrollAttached,
625
+ selectedNode
626
+ ]);
627
+ const handleShowOverlay = React.useCallback(() => {
628
+ "background only";
629
+ measureIntrinsicSize();
630
+ measurePosition();
631
+ }, [measureIntrinsicSize, measurePosition]);
632
+ const handleRef = React.useCallback((node) => {
633
+ mergeNodeRef(ref, node);
634
+ }, [ref]);
635
+ const handlePositionerRef = React.useCallback((node) => {
636
+ overlayNodeRef.current = node;
637
+ if (node && !overlayAttachedRef.current) {
638
+ overlayAttachedRef.current = true;
639
+ setOverlayAttached(true);
640
+ }
641
+ }, []);
642
+ const handleScrollRef = React.useCallback((node) => {
643
+ "background only";
644
+ scrollNodeRef.current = node;
645
+ if (node && !scrollAttachedRef.current) {
646
+ scrollAttachedRef.current = true;
647
+ setScrollAttached(true);
648
+ }
649
+ }, []);
650
+ const handleScrollContentRef = React.useCallback((node) => {
651
+ "background only";
652
+ scrollContentNodeRef.current = node;
653
+ if (node && !scrollContentAttachedRef.current) {
654
+ scrollContentAttachedRef.current = true;
655
+ setScrollContentAttached(true);
656
+ }
657
+ }, []);
658
+ const handleIntrinsicLayoutChange = React.useCallback(() => {
659
+ "background only";
660
+ measureIntrinsicSize();
661
+ }, [measureIntrinsicSize]);
662
+ const handleTransitionEnd = React.useCallback((event) => {
663
+ "background only";
664
+ if (!context.open && hasExitTransition(event)) context.finishClose();
665
+ }, [context]);
666
+ const handleBackdropTap = React.useCallback((event) => {
667
+ "background only";
668
+ context.requestOpen(false, {
669
+ reason: "interactOutside",
670
+ event
671
+ });
672
+ }, [context]);
673
+ const handleNativeDismiss = React.useCallback((event) => {
674
+ "background only";
675
+ context.requestOpen(false, {
676
+ reason: "dismiss",
677
+ event
678
+ });
679
+ context.finishClose(true);
680
+ }, [context]);
681
+ const handleRequestClose = React.useCallback((event) => {
682
+ "background only";
683
+ context.requestOpen(false, {
684
+ reason: "dismiss",
685
+ event
686
+ });
687
+ }, [context]);
688
+ const geometryStyle = position && overlayRect ? {
689
+ left: toPixel(position.left - overlayRect.left),
690
+ top: toPixel(position.top - overlayRect.top),
691
+ width: toPixel(position.width),
692
+ transformOrigin: position.transformOrigin
693
+ } : void 0;
694
+ const scrollStyle = position ? { height: toPixel(position.height) } : void 0;
695
+ const triggerProxyStyle = triggerRect && overlayRect ? {
696
+ left: toPixel(triggerRect.left - overlayRect.left),
697
+ top: toPixel(triggerRect.top - overlayRect.top),
698
+ width: toPixel(triggerRect.width),
699
+ height: toPixel(triggerRect.height)
700
+ } : void 0;
701
+ const groups = toArray(children);
702
+ return <overlay visible={context.mounted} style={{ position: "fixed" }} binddismissoverlay={handleNativeDismiss} bindshowoverlay={handleShowOverlay} bindrequestclose={handleRequestClose}>
703
+ <view ref={handlePositionerRef} className={context.classes.positioner}>
704
+ <view className={context.classes.backdrop} bindtap={handleBackdropTap} />
705
+ {triggerProxyStyle && <view style={{
706
+ position: "absolute",
707
+ ...triggerProxyStyle
708
+ }} bindtap={context.triggerHandlers.bindtap} main-thread:bindtap={context.triggerHandlers["main-thread:bindtap"]} />}
709
+ <view ref={handleRef} className={clsx(context.classes.content, className)} style={{
710
+ ...geometryStyle,
711
+ ...style,
712
+ ...widthConstraint != null ? { width: toPixel(widthConstraint) } : {}
713
+ }} bindtransitionend={handleTransitionEnd} {...nativeProps}>
714
+ <scroll-view ref={handleScrollRef} id={scrollAreaId} className={context.classes.scrollArea} scroll-orientation="vertical" enable-scroll={Boolean(position && intrinsicSize && intrinsicSize.epoch === context.openEpoch && intrinsicSize.config === measurementConfigRef.current && intrinsicSize.height > position.height)} style={scrollStyle}>
715
+ <view ref={handleScrollContentRef} className={context.classes.scrollContent} bindlayoutchange={handleIntrinsicLayoutChange}>
716
+ {groups.map((group, index) => <SelectGroupPositionContext.Provider key={React.isValidElement(group) ? group.key ?? index : index} value={{ isFirst: index === 0 }}>
717
+ {group}
718
+ </SelectGroupPositionContext.Provider>)}
719
+ </view>
720
+ </scroll-view>
721
+ </view>
722
+ </view>
723
+ </overlay>;
724
+ });
725
+ SelectContent.displayName = "SelectContent";
726
+ var SelectScrollArea = React.forwardRef((props, ref) => {
727
+ const { children, className, ...nativeProps } = props;
728
+ const context = useSelectContext("SelectScrollArea");
729
+ return <scroll-view {...ref ? { ref } : {}} className={clsx(context.classes.scrollArea, className)} scroll-orientation="vertical" {...nativeProps}>
730
+ <view className={context.classes.scrollContent}>{children}</view>
731
+ </scroll-view>;
732
+ });
733
+ SelectScrollArea.displayName = "SelectScrollArea";
734
+ var SelectGroup = React.forwardRef((props, ref) => {
735
+ const { children, className, ...nativeProps } = props;
736
+ const context = useSelectContext("SelectGroup");
737
+ const position = React.useContext(SelectGroupPositionContext);
738
+ return <view {...ref ? { ref } : {}} className={clsx(context.classes.group, className)} {...nativeProps}>
739
+ {!position.isFirst ? <view className={context.classes.separator} accessibility-elements-hidden={true} /> : null}
740
+ {children}
741
+ </view>;
742
+ });
743
+ SelectGroup.displayName = "SelectGroup";
744
+ var SelectGroupLabel = React.forwardRef((props, ref) => {
745
+ const { children, className, "accessibility-heading": accessibilityHeading = true, ...nativeProps } = props;
746
+ const context = useSelectContext("SelectGroupLabel");
747
+ return <text {...ref ? { ref } : {}} className={clsx(context.classes.groupLabel, className)} accessibility-heading={accessibilityHeading} {...nativeProps}>
748
+ {children}
749
+ </text>;
750
+ });
751
+ SelectGroupLabel.displayName = "SelectGroupLabel";
752
+ var SelectItem = React.forwardRef((props, ref) => {
753
+ const [variantProps, otherProps] = selectItem.splitVariantProps(props);
754
+ const { disabled: disabledProp = false } = variantProps;
755
+ const { value, label, textValue, prefixIcon, readOnly = false, children, className, bindtap, "main-thread:bindtap": mainThreadBindtap, "accessibility-element": accessibilityElement = true, "accessibility-label": accessibilityLabel, "accessibility-traits": accessibilityTraits, "accessibility-value": accessibilityValue, ...nativeProps } = otherProps;
756
+ const context = useSelectContext("SelectItem");
757
+ const nodeRef = React.useRef(null);
758
+ const nodeAttachedRef = React.useRef(false);
759
+ const [nodeAttached, setNodeAttached] = React.useState(false);
760
+ const disabled = context.disabled || context.readOnly || disabledProp || readOnly;
761
+ const selected = context.value.includes(value);
762
+ const resolvedTextValue = textValue ?? (typeof label === "string" ? label : value);
763
+ const { pressed, ...pressHandlers } = usePressTap({
764
+ disabled,
765
+ onTap: React.useCallback((event, instance) => {
766
+ "background only";
767
+ context.selectValue(value, event);
768
+ bindtap?.(event, instance);
769
+ }, [
770
+ bindtap,
771
+ context,
772
+ value
773
+ ]),
774
+ mainThreadOnTap: mainThreadBindtap
775
+ });
776
+ const handleRef = React.useCallback((nextNode) => {
777
+ nodeRef.current = nextNode;
778
+ if (nextNode && !nodeAttachedRef.current) {
779
+ nodeAttachedRef.current = true;
780
+ setNodeAttached(true);
781
+ }
782
+ mergeNodeRef(ref, nextNode);
783
+ }, [ref]);
784
+ React.useEffect(() => {
785
+ "background only";
786
+ context.registerOption(value, {
787
+ label,
788
+ textValue: resolvedTextValue,
789
+ prefixIcon,
790
+ node: nodeRef.current
791
+ });
792
+ return () => {
793
+ context.unregisterOption(value);
794
+ };
795
+ }, [
796
+ context.registerOption,
797
+ context.unregisterOption,
798
+ label,
799
+ nodeAttached,
800
+ prefixIcon,
801
+ resolvedTextValue,
802
+ value
803
+ ]);
804
+ const classes = selectItem({
805
+ ...variantProps,
806
+ size: context.size,
807
+ disabled,
808
+ selected,
809
+ pressed
810
+ });
811
+ const itemContextValue = React.useMemo(() => ({
812
+ label,
813
+ prefixIcon,
814
+ selected,
815
+ disabled,
816
+ pressed,
817
+ classes
818
+ }), [
819
+ classes,
820
+ disabled,
821
+ label,
822
+ prefixIcon,
823
+ pressed,
824
+ selected
825
+ ]);
826
+ return <SelectItemContext.Provider value={itemContextValue}>
827
+ <view ref={handleRef} className={clsx(classes.root, className)} accessibility-element={accessibilityElement} accessibility-label={accessibilityLabel ?? resolvedTextValue} accessibility-role-description="option" accessibility-value={accessibilityValue ?? (selected ? "selected" : "not selected")} accessibility-traits={disabled ? "disabled" : accessibilityTraits} {...nativeProps} {...pressHandlers}>
828
+ <view className={classes.pressedOverlay} accessibility-elements-hidden={true} />
829
+ {children}
830
+ </view>
831
+ </SelectItemContext.Provider>;
832
+ });
833
+ SelectItem.displayName = "SelectItem";
834
+ var SelectItemPrefixIcon = React.forwardRef((props, ref) => {
835
+ const { icon: iconOverride, className, ...nativeProps } = props;
836
+ const context = useSelectItemContext("SelectItemPrefixIcon");
837
+ const icon = iconOverride ?? context.prefixIcon;
838
+ if (!isValidElement(icon)) return null;
839
+ return <InternalIcon ref={ref} icon={icon} className={clsx(context.classes.prefixIcon, className)} accessibility-elements-hidden={true} deps={[
840
+ context.selected,
841
+ context.disabled,
842
+ context.pressed,
843
+ icon
844
+ ]} {...nativeProps} />;
845
+ });
846
+ SelectItemPrefixIcon.displayName = "SelectItemPrefixIcon";
847
+ var SelectItemBody = React.forwardRef((props, ref) => {
848
+ const { children, className, ...nativeProps } = props;
849
+ const context = useSelectItemContext("SelectItemBody");
850
+ return <view {...ref ? { ref } : {}} className={clsx(context.classes.body, className)} {...nativeProps}>
851
+ {children}
852
+ </view>;
853
+ });
854
+ SelectItemBody.displayName = "SelectItemBody";
855
+ var SelectItemLabel = React.forwardRef((props, ref) => {
856
+ const { children, className, ...nativeProps } = props;
857
+ const context = useSelectItemContext("SelectItemLabel");
858
+ return renderTextContent(clsx(context.classes.label, className), children ?? context.label, ref, nativeProps);
859
+ });
860
+ SelectItemLabel.displayName = "SelectItemLabel";
861
+ var SelectItemDescription = React.forwardRef((props, ref) => {
862
+ const { children, className, ...nativeProps } = props;
863
+ return renderTextContent(clsx(useSelectItemContext("SelectItemDescription").classes.description, className), children, ref, nativeProps);
864
+ });
865
+ SelectItemDescription.displayName = "SelectItemDescription";
866
+ var SelectItemIndicator = React.forwardRef((props, ref) => {
867
+ const { selected: selectedIcon, unselected, className, ...nativeProps } = props;
868
+ const context = useSelectItemContext("SelectItemIndicator");
869
+ const icon = context.selected ? selectedIcon : unselected;
870
+ if (!isValidElement(icon)) {
871
+ if (!context.selected) return null;
872
+ return <text {...ref ? { ref } : {}} className={clsx(context.classes.indicator, className)} accessibility-elements-hidden={true} {...nativeProps}>
873
+ ✓
874
+ </text>;
875
+ }
876
+ return <InternalIcon ref={ref} icon={icon} className={clsx(context.classes.indicator, className)} accessibility-elements-hidden={true} deps={[
877
+ context.selected,
878
+ context.disabled,
879
+ context.pressed,
880
+ icon
881
+ ]} {...nativeProps} />;
882
+ });
883
+ SelectItemIndicator.displayName = "SelectItemIndicator";
884
+ //#endregion
885
+ export { SelectContent, SelectGroup, SelectGroupLabel, SelectItem, SelectItemBody, SelectItemDescription, SelectItemIndicator, SelectItemLabel, SelectItemPrefixIcon, SelectPlaceholder, SelectPrefixIcon, SelectRoot, SelectScrollArea, SelectSuffixIcon, SelectTrigger, SelectValue };