@tamagui/select 2.7.7 → 3.0.0-beta.643.1

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 (248) hide show
  1. package/dist/cjs/Select.cjs +409 -467
  2. package/dist/cjs/Select.native.cjs +495 -0
  3. package/dist/cjs/Select.native.js +445 -492
  4. package/dist/cjs/Select.native.js.map +1 -1
  5. package/dist/cjs/SelectContent.cjs +80 -79
  6. package/dist/cjs/SelectContent.native.cjs +30 -0
  7. package/dist/cjs/SelectContent.native.js +18 -22
  8. package/dist/cjs/SelectContent.native.js.map +1 -1
  9. package/dist/cjs/SelectImpl.cjs +299 -319
  10. package/dist/cjs/SelectImpl.native.cjs +30 -0
  11. package/dist/cjs/SelectImpl.native.js +17 -24
  12. package/dist/cjs/SelectImpl.native.js.map +1 -1
  13. package/dist/cjs/SelectItem.cjs +268 -205
  14. package/dist/cjs/SelectItem.native.cjs +317 -0
  15. package/dist/cjs/SelectItem.native.js +291 -211
  16. package/dist/cjs/SelectItem.native.js.map +1 -1
  17. package/dist/cjs/SelectItemText.cjs +49 -79
  18. package/dist/cjs/SelectItemText.native.cjs +74 -0
  19. package/dist/cjs/SelectItemText.native.js +50 -79
  20. package/dist/cjs/SelectItemText.native.js.map +1 -1
  21. package/dist/cjs/SelectScrollButton.cjs +111 -130
  22. package/dist/cjs/SelectScrollButton.native.cjs +38 -0
  23. package/dist/cjs/SelectScrollButton.native.js +25 -22
  24. package/dist/cjs/SelectScrollButton.native.js.map +1 -1
  25. package/dist/cjs/SelectTrigger.cjs +69 -84
  26. package/dist/cjs/SelectTrigger.native.cjs +91 -0
  27. package/dist/cjs/SelectTrigger.native.js +71 -66
  28. package/dist/cjs/SelectTrigger.native.js.map +1 -1
  29. package/dist/cjs/SelectViewport.cjs +119 -142
  30. package/dist/cjs/SelectViewport.native.cjs +73 -0
  31. package/dist/cjs/SelectViewport.native.js +54 -50
  32. package/dist/cjs/SelectViewport.native.js.map +1 -1
  33. package/dist/cjs/constants.cjs +21 -22
  34. package/dist/cjs/constants.native.cjs +41 -0
  35. package/dist/cjs/constants.native.js +21 -21
  36. package/dist/cjs/constants.native.js.map +1 -1
  37. package/dist/cjs/context.cjs +38 -48
  38. package/dist/cjs/context.native.cjs +58 -0
  39. package/dist/cjs/context.native.js +40 -49
  40. package/dist/cjs/context.native.js.map +1 -1
  41. package/dist/cjs/index.cjs +15 -11
  42. package/dist/cjs/index.native.cjs +27 -0
  43. package/dist/cjs/index.native.js +15 -10
  44. package/dist/cjs/index.native.js.map +1 -1
  45. package/dist/cjs/selectionController.cjs +334 -0
  46. package/dist/cjs/selectionController.native.cjs +403 -0
  47. package/dist/cjs/selectionController.native.js +405 -0
  48. package/dist/cjs/selectionController.native.js.map +1 -0
  49. package/dist/cjs/types.cjs +10 -11
  50. package/dist/cjs/types.native.cjs +19 -0
  51. package/dist/cjs/types.native.js +10 -10
  52. package/dist/cjs/types.native.js.map +1 -1
  53. package/dist/esm/Select.mjs +382 -443
  54. package/dist/esm/Select.mjs.map +1 -1
  55. package/dist/esm/Select.native.js +418 -469
  56. package/dist/esm/Select.native.js.map +1 -1
  57. package/dist/esm/SelectContent.mjs +67 -61
  58. package/dist/esm/SelectContent.mjs.map +1 -1
  59. package/dist/esm/SelectContent.native.js +4 -5
  60. package/dist/esm/SelectContent.native.js.map +1 -1
  61. package/dist/esm/SelectImpl.mjs +284 -294
  62. package/dist/esm/SelectImpl.mjs.map +1 -1
  63. package/dist/esm/SelectImpl.native.js +5 -8
  64. package/dist/esm/SelectImpl.native.js.map +1 -1
  65. package/dist/esm/SelectItem.mjs +252 -182
  66. package/dist/esm/SelectItem.mjs.map +1 -1
  67. package/dist/esm/SelectItem.native.js +276 -190
  68. package/dist/esm/SelectItem.native.js.map +1 -1
  69. package/dist/esm/SelectItemText.mjs +33 -55
  70. package/dist/esm/SelectItemText.mjs.map +1 -1
  71. package/dist/esm/SelectItemText.native.js +34 -56
  72. package/dist/esm/SelectItemText.native.js.map +1 -1
  73. package/dist/esm/SelectScrollButton.mjs +95 -107
  74. package/dist/esm/SelectScrollButton.mjs.map +1 -1
  75. package/dist/esm/SelectScrollButton.native.js +11 -7
  76. package/dist/esm/SelectScrollButton.native.js.map +1 -1
  77. package/dist/esm/SelectTrigger.mjs +56 -58
  78. package/dist/esm/SelectTrigger.mjs.map +1 -1
  79. package/dist/esm/SelectTrigger.native.js +54 -44
  80. package/dist/esm/SelectTrigger.native.js.map +1 -1
  81. package/dist/esm/SelectViewport.mjs +104 -119
  82. package/dist/esm/SelectViewport.mjs.map +1 -1
  83. package/dist/esm/SelectViewport.native.js +44 -39
  84. package/dist/esm/SelectViewport.native.js.map +1 -1
  85. package/dist/esm/constants.mjs +1 -0
  86. package/dist/esm/constants.mjs.map +1 -1
  87. package/dist/esm/constants.native.js +1 -0
  88. package/dist/esm/constants.native.js.map +1 -1
  89. package/dist/esm/context.mjs +20 -28
  90. package/dist/esm/context.mjs.map +1 -1
  91. package/dist/esm/context.native.js +23 -31
  92. package/dist/esm/context.native.js.map +1 -1
  93. package/dist/esm/index.js +13 -3
  94. package/dist/esm/index.mjs +13 -3
  95. package/dist/esm/index.native.js +13 -3
  96. package/dist/esm/selectionController.mjs +305 -0
  97. package/dist/esm/selectionController.mjs.map +1 -0
  98. package/dist/esm/selectionController.native.js +372 -0
  99. package/dist/esm/selectionController.native.js.map +1 -0
  100. package/dist/esm/types.mjs +0 -2
  101. package/dist/esm/types.native.js +0 -2
  102. package/dist/jsx/Select.mjs +382 -443
  103. package/dist/jsx/Select.mjs.map +1 -1
  104. package/dist/jsx/Select.native.cjs +495 -0
  105. package/dist/jsx/Select.native.js +445 -492
  106. package/dist/jsx/Select.native.js.map +1 -1
  107. package/dist/jsx/SelectContent.mjs +67 -61
  108. package/dist/jsx/SelectContent.mjs.map +1 -1
  109. package/dist/jsx/SelectContent.native.cjs +30 -0
  110. package/dist/jsx/SelectContent.native.js +18 -22
  111. package/dist/jsx/SelectContent.native.js.map +1 -1
  112. package/dist/jsx/SelectImpl.mjs +284 -294
  113. package/dist/jsx/SelectImpl.mjs.map +1 -1
  114. package/dist/jsx/SelectImpl.native.cjs +30 -0
  115. package/dist/jsx/SelectImpl.native.js +17 -24
  116. package/dist/jsx/SelectImpl.native.js.map +1 -1
  117. package/dist/jsx/SelectItem.mjs +252 -182
  118. package/dist/jsx/SelectItem.mjs.map +1 -1
  119. package/dist/jsx/SelectItem.native.cjs +317 -0
  120. package/dist/jsx/SelectItem.native.js +291 -211
  121. package/dist/jsx/SelectItem.native.js.map +1 -1
  122. package/dist/jsx/SelectItemText.mjs +33 -55
  123. package/dist/jsx/SelectItemText.mjs.map +1 -1
  124. package/dist/jsx/SelectItemText.native.cjs +74 -0
  125. package/dist/jsx/SelectItemText.native.js +50 -79
  126. package/dist/jsx/SelectItemText.native.js.map +1 -1
  127. package/dist/jsx/SelectScrollButton.mjs +95 -107
  128. package/dist/jsx/SelectScrollButton.mjs.map +1 -1
  129. package/dist/jsx/SelectScrollButton.native.cjs +38 -0
  130. package/dist/jsx/SelectScrollButton.native.js +25 -22
  131. package/dist/jsx/SelectScrollButton.native.js.map +1 -1
  132. package/dist/jsx/SelectTrigger.mjs +56 -58
  133. package/dist/jsx/SelectTrigger.mjs.map +1 -1
  134. package/dist/jsx/SelectTrigger.native.cjs +91 -0
  135. package/dist/jsx/SelectTrigger.native.js +71 -66
  136. package/dist/jsx/SelectTrigger.native.js.map +1 -1
  137. package/dist/jsx/SelectViewport.mjs +104 -119
  138. package/dist/jsx/SelectViewport.mjs.map +1 -1
  139. package/dist/jsx/SelectViewport.native.cjs +73 -0
  140. package/dist/jsx/SelectViewport.native.js +54 -50
  141. package/dist/jsx/SelectViewport.native.js.map +1 -1
  142. package/dist/jsx/constants.mjs +1 -0
  143. package/dist/jsx/constants.mjs.map +1 -1
  144. package/dist/jsx/constants.native.cjs +41 -0
  145. package/dist/jsx/constants.native.js +21 -21
  146. package/dist/jsx/constants.native.js.map +1 -1
  147. package/dist/jsx/context.mjs +20 -28
  148. package/dist/jsx/context.mjs.map +1 -1
  149. package/dist/jsx/context.native.cjs +58 -0
  150. package/dist/jsx/context.native.js +40 -49
  151. package/dist/jsx/context.native.js.map +1 -1
  152. package/dist/jsx/index.js +13 -3
  153. package/dist/jsx/index.mjs +13 -3
  154. package/dist/jsx/index.native.cjs +27 -0
  155. package/dist/jsx/index.native.js +15 -10
  156. package/dist/jsx/index.native.js.map +1 -1
  157. package/dist/jsx/selectionController.mjs +305 -0
  158. package/dist/jsx/selectionController.mjs.map +1 -0
  159. package/dist/jsx/selectionController.native.cjs +403 -0
  160. package/dist/jsx/selectionController.native.js +405 -0
  161. package/dist/jsx/selectionController.native.js.map +1 -0
  162. package/dist/jsx/types.mjs +0 -2
  163. package/dist/jsx/types.native.cjs +19 -0
  164. package/dist/jsx/types.native.js +10 -10
  165. package/dist/jsx/types.native.js.map +1 -1
  166. package/package.json +28 -28
  167. package/src/Select.tsx +457 -357
  168. package/src/SelectContent.tsx +46 -16
  169. package/src/SelectImpl.native.tsx +0 -8
  170. package/src/SelectImpl.tsx +87 -100
  171. package/src/SelectItem.tsx +282 -136
  172. package/src/SelectItemText.tsx +16 -33
  173. package/src/SelectScrollButton.native.tsx +13 -4
  174. package/src/SelectScrollButton.tsx +56 -41
  175. package/src/SelectTrigger.tsx +77 -53
  176. package/src/SelectViewport.native.tsx +42 -25
  177. package/src/SelectViewport.tsx +52 -51
  178. package/src/context.tsx +6 -2
  179. package/src/index.tsx +5 -2
  180. package/src/selectionController.ts +389 -0
  181. package/src/types.tsx +88 -45
  182. package/types/Select.d.ts +139 -201
  183. package/types/Select.d.ts.map +1 -1
  184. package/types/SelectContent.d.ts +1 -1
  185. package/types/SelectContent.d.ts.map +1 -1
  186. package/types/SelectContent.native.d.ts.map +1 -1
  187. package/types/SelectImpl.d.ts +2 -1
  188. package/types/SelectImpl.d.ts.map +1 -1
  189. package/types/SelectImpl.native.d.ts +1 -5
  190. package/types/SelectImpl.native.d.ts.map +1 -1
  191. package/types/SelectItem.d.ts +13 -16
  192. package/types/SelectItem.d.ts.map +1 -1
  193. package/types/SelectItemText.d.ts +9 -13
  194. package/types/SelectItemText.d.ts.map +1 -1
  195. package/types/SelectScrollButton.d.ts +15 -2
  196. package/types/SelectScrollButton.d.ts.map +1 -1
  197. package/types/SelectScrollButton.native.d.ts +16 -3
  198. package/types/SelectScrollButton.native.d.ts.map +1 -1
  199. package/types/SelectTrigger.d.ts +11 -23
  200. package/types/SelectTrigger.d.ts.map +1 -1
  201. package/types/SelectViewport.d.ts +11 -38
  202. package/types/SelectViewport.d.ts.map +1 -1
  203. package/types/SelectViewport.native.d.ts +15 -4
  204. package/types/SelectViewport.native.d.ts.map +1 -1
  205. package/types/context.d.ts +2 -0
  206. package/types/context.d.ts.map +1 -1
  207. package/types/index.d.ts +5 -2
  208. package/types/index.d.ts.map +1 -1
  209. package/types/selectionController.d.ts +88 -0
  210. package/types/selectionController.d.ts.map +1 -0
  211. package/types/types.d.ts +47 -37
  212. package/types/types.d.ts.map +1 -1
  213. package/dist/cjs/BubbleSelect.cjs +0 -50
  214. package/dist/cjs/BubbleSelect.native.js +0 -30
  215. package/dist/cjs/BubbleSelect.native.js.map +0 -1
  216. package/dist/cjs/useSelectBreakpointActive.cjs +0 -32
  217. package/dist/cjs/useSelectBreakpointActive.native.js +0 -35
  218. package/dist/cjs/useSelectBreakpointActive.native.js.map +0 -1
  219. package/dist/esm/BubbleSelect.mjs +0 -27
  220. package/dist/esm/BubbleSelect.mjs.map +0 -1
  221. package/dist/esm/BubbleSelect.native.js +0 -4
  222. package/dist/esm/BubbleSelect.native.js.map +0 -1
  223. package/dist/esm/index.js.map +0 -1
  224. package/dist/esm/index.mjs.map +0 -1
  225. package/dist/esm/index.native.js.map +0 -1
  226. package/dist/esm/types.mjs.map +0 -1
  227. package/dist/esm/types.native.js.map +0 -1
  228. package/dist/esm/useSelectBreakpointActive.mjs +0 -7
  229. package/dist/esm/useSelectBreakpointActive.mjs.map +0 -1
  230. package/dist/esm/useSelectBreakpointActive.native.js +0 -7
  231. package/dist/esm/useSelectBreakpointActive.native.js.map +0 -1
  232. package/dist/jsx/BubbleSelect.mjs +0 -27
  233. package/dist/jsx/BubbleSelect.mjs.map +0 -1
  234. package/dist/jsx/BubbleSelect.native.js +0 -30
  235. package/dist/jsx/BubbleSelect.native.js.map +0 -1
  236. package/dist/jsx/index.js.map +0 -1
  237. package/dist/jsx/index.mjs.map +0 -1
  238. package/dist/jsx/types.mjs.map +0 -1
  239. package/dist/jsx/useSelectBreakpointActive.mjs +0 -7
  240. package/dist/jsx/useSelectBreakpointActive.mjs.map +0 -1
  241. package/dist/jsx/useSelectBreakpointActive.native.js +0 -35
  242. package/dist/jsx/useSelectBreakpointActive.native.js.map +0 -1
  243. package/src/BubbleSelect.tsx +0 -50
  244. package/src/useSelectBreakpointActive.tsx +0 -7
  245. package/types/BubbleSelect.d.ts +0 -2
  246. package/types/BubbleSelect.d.ts.map +0 -1
  247. package/types/useSelectBreakpointActive.d.ts +0 -3
  248. package/types/useSelectBreakpointActive.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["autoUpdate","inner","offset","size","useClick","useFloatingRaw","useInnerOffset","useInteractions","useListNavigation","useRole","useTypeahead","useIsomorphicLayoutEffect","useEvent","useIsTouchDevice","React","flushSync","SCROLL_ARROW_THRESHOLD","SelectItemParentProvider","SelectProvider","useSelectContext","useSelectItemParentContext","jsx","SelectInlineImpl","props","scope","children","open","listContentRef","setActiveIndexFast","selectContext","selectItemParentContext","setActiveIndex","selectedIndex","activeIndexRef","setOpen","setSelectedIndex","scrollTop","setScrollTop","useState","touch","listItemsRef","useRef","overflowRef","upArrowRef","downArrowRef","allowSelectRef","allowMouseUpRef","selectTimeoutRef","state","isMouseOutside","isTyping","controlledScrolling","setControlledScrolling","fallback","setFallback","innerOffset","setInnerOffset","blockSelection","setBlockSelection","floatingStyle","useEffect","mouseUp","e","current","document","addEventListener","removeEventListener","x","y","strategy","refs","update","placement","computedPlacement","whileElementsMounted","middleware","apply","rects","reference","width","Object","assign","minWidth","floating","style","listRef","index","onFallbackChange","padding","minItemsVisible","referenceOverflowThreshold","crossAxis","floatingRef","showUpArrow","showDownArrow","scrollHeight","clientHeight","isScrollable","window","onMatch","dataRef","interactionContext","onOpenChange","val","domReference","elements","interactionsProps","event","keyboardHandlers","role","enabled","onChange","scrollRef","activeIndex","onNavigate","scrollItemIntoView","onTypingChange","interactions","useMemo","interactionsContext","getReferenceProps","ref","className","onKeyDown","key","code","preventDefault","getFloatingProps","props2","position","top","left","outline","scrollbarWidth","onPointerEnter","onPointerLeave","onPointerMove","onContextMenu","onScroll","currentTarget","setTimeout","clearTimeout","onPointerDown","target","contains","scrollActiveIntoView","scrollIntoView","block","activeIndexSubscribe","maxHeight","floatingContext","canScrollDown","canScrollUp"],"sources":["SelectImpl.mjs"],"sourcesContent":["import { autoUpdate, inner, offset, size, useClick, useFloatingRaw, useInnerOffset, useInteractions, useListNavigation, useRole, useTypeahead } from \"@tamagui/floating\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { useEvent, useIsTouchDevice } from \"@tamagui/core\";\nimport * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { SCROLL_ARROW_THRESHOLD } from \"./constants\";\nimport { SelectItemParentProvider, SelectProvider, useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst SelectInlineImpl = (props) => {\n\tconst { scope, children, open = false, listContentRef, setActiveIndexFast } = props;\n\tconst selectContext = useSelectContext(scope);\n\tconst selectItemParentContext = useSelectItemParentContext(scope);\n\tconst { setActiveIndex, selectedIndex, activeIndexRef } = selectContext;\n\tconst { setOpen, setSelectedIndex } = selectItemParentContext;\n\tconst [scrollTop, setScrollTop] = React.useState(0);\n\tconst touch = useIsTouchDevice();\n\tconst listItemsRef = React.useRef([]);\n\tconst overflowRef = React.useRef(null);\n\tconst upArrowRef = React.useRef(null);\n\tconst downArrowRef = React.useRef(null);\n\tconst allowSelectRef = React.useRef(false);\n\tconst allowMouseUpRef = React.useRef(true);\n\tconst selectTimeoutRef = React.useRef(null);\n\tconst state = React.useRef({\n\t\tisMouseOutside: false,\n\t\tisTyping: false\n\t});\n\tconst [controlledScrolling, setControlledScrolling] = React.useState(false);\n\tconst [fallback, setFallback] = React.useState(false);\n\tconst [innerOffset, setInnerOffset] = React.useState(0);\n\tconst [blockSelection, setBlockSelection] = React.useState(false);\n\tconst floatingStyle = React.useRef({});\n\tReact.useEffect(() => {\n\t\tif (open) setActiveIndexFast(selectedIndex ?? 0);\n\t\telse {\n\t\t\tsetScrollTop(0);\n\t\t\tsetFallback(false);\n\t\t\tsetActiveIndexFast(null);\n\t\t\tsetControlledScrolling(false);\n\t\t}\n\t}, [\n\t\topen,\n\t\tselectedIndex,\n\t\tsetActiveIndexFast\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open) return;\n\t\tconst mouseUp = (e) => {\n\t\t\tif (state.current.isMouseOutside) setOpen(false);\n\t\t};\n\t\tdocument.addEventListener(\"mouseup\", mouseUp);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"mouseup\", mouseUp);\n\t\t};\n\t}, [open]);\n\tconst { x, y, strategy, refs, update, placement: computedPlacement } = useFloatingRaw({\n\t\topen,\n\t\tplacement: \"bottom-start\",\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tsize({ apply({ rects: { reference: { width } } }) {\n\t\t\t\tObject.assign(floatingStyle.current, { minWidth: width + 8 });\n\t\t\t\tif (refs.floating.current) Object.assign(refs.floating.current.style, floatingStyle.current);\n\t\t\t} }),\n\t\t\tinner({\n\t\t\t\tlistRef: listItemsRef,\n\t\t\t\toverflowRef,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\toffset: innerOffset,\n\t\t\t\tonFallbackChange: setFallback,\n\t\t\t\tpadding: 10,\n\t\t\t\tminItemsVisible: touch ? 10 : 4,\n\t\t\t\treferenceOverflowThreshold: 20\n\t\t\t}),\n\t\t\toffset({ crossAxis: -5 })\n\t\t]\n\t});\n\tconst floatingRef = refs.floating;\n\tconst showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;\n\tconst showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;\n\tconst isScrollable = showDownArrow || showUpArrow;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\t\twindow.addEventListener(\"resize\", update);\n\t\tif (open) update();\n\t\treturn () => window.removeEventListener(\"resize\", update);\n\t}, [update, open]);\n\tconst onMatch = useEvent((index) => {\n\t\treturn (open ? setActiveIndex : setSelectedIndex)(index);\n\t});\n\tconst dataRef = React.useRef({});\n\tdataRef.current.placement = computedPlacement;\n\tconst interactionContext = {\n\t\topen,\n\t\tonOpenChange: (val) => setOpen(val),\n\t\trefs: {\n\t\t\treference: refs.reference,\n\t\t\tfloating: refs.floating,\n\t\t\tdomReference: refs.reference\n\t\t},\n\t\telements: {\n\t\t\treference: refs.reference?.current || null,\n\t\t\tfloating: refs.floating?.current || null,\n\t\t\tdomReference: refs.reference?.current || null\n\t\t},\n\t\tdataRef\n\t};\n\tconst interactionsProps = [\n\t\tuseClick(interactionContext, {\n\t\t\tevent: \"mousedown\",\n\t\t\tkeyboardHandlers: false\n\t\t}),\n\t\tuseRole(interactionContext, { role: \"listbox\" }),\n\t\tuseInnerOffset(interactionContext, {\n\t\t\tenabled: !fallback && isScrollable,\n\t\t\tonChange: setInnerOffset,\n\t\t\toverflowRef,\n\t\t\tscrollRef: refs.floating\n\t\t}),\n\t\tuseListNavigation(interactionContext, {\n\t\t\tlistRef: listItemsRef,\n\t\t\tactiveIndex: selectContext.activeIndex ?? 0,\n\t\t\tselectedIndex,\n\t\t\tonNavigate: (index) => {\n\t\t\t\tif (index !== null) setActiveIndex(index);\n\t\t\t},\n\t\t\tscrollItemIntoView: false\n\t\t}),\n\t\tuseTypeahead(interactionContext, {\n\t\t\tlistRef: listContentRef,\n\t\t\tonMatch,\n\t\t\tselectedIndex,\n\t\t\tactiveIndex: selectContext.activeIndex,\n\t\t\tonTypingChange: (e) => {\n\t\t\t\tstate.current.isTyping = e;\n\t\t\t}\n\t\t})\n\t];\n\tconst interactions = useInteractions(React.useMemo(() => {\n\t\treturn interactionsProps;\n\t}, interactionsProps));\n\tconst interactionsContext = React.useMemo(() => {\n\t\treturn {\n\t\t\t...interactions,\n\t\t\tgetReferenceProps() {\n\t\t\t\treturn interactions.getReferenceProps({\n\t\t\t\t\tref: refs.reference,\n\t\t\t\t\tclassName: \"SelectTrigger\",\n\t\t\t\t\tonKeyDown(event) {\n\t\t\t\t\t\tif (event.key === \"Enter\" || event.code === \"Space\" || event.key === \" \" && !state.current.isTyping) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tsetOpen(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetFloatingProps(props2) {\n\t\t\t\treturn interactions.getFloatingProps({\n\t\t\t\t\tref: refs.floating,\n\t\t\t\t\tclassName: \"Select\",\n\t\t\t\t\t...props2,\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\ttop: y ?? \"\",\n\t\t\t\t\t\tleft: x ?? \"\",\n\t\t\t\t\t\toutline: 0,\n\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t...floatingStyle.current,\n\t\t\t\t\t\t...props2?.style\n\t\t\t\t\t},\n\t\t\t\t\tonPointerEnter() {\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerLeave() {\n\t\t\t\t\t\tstate.current.isMouseOutside = true;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerMove() {\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t},\n\t\t\t\t\tonKeyDown() {\n\t\t\t\t\t\tsetControlledScrolling(true);\n\t\t\t\t\t},\n\t\t\t\t\tonContextMenu(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t},\n\t\t\t\t\tonScroll(event) {\n\t\t\t\t\t\tflushSync(() => {\n\t\t\t\t\t\t\tsetScrollTop(event.currentTarget.scrollTop);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t}, [\n\t\trefs.reference.current,\n\t\tx,\n\t\ty,\n\t\trefs.floating.current,\n\t\tinteractions\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (open) {\n\t\t\tallowMouseUpRef.current = false;\n\t\t\tselectTimeoutRef.current = setTimeout(() => {\n\t\t\t\tallowSelectRef.current = true;\n\t\t\t\tallowMouseUpRef.current = true;\n\t\t\t}, 300);\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(selectTimeoutRef.current);\n\t\t\t};\n\t\t}\n\t\tallowSelectRef.current = false;\n\t\tallowMouseUpRef.current = true;\n\t\tsetInnerOffset(0);\n\t\tsetFallback(false);\n\t\tsetBlockSelection(false);\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open && state.current.isMouseOutside) state.current.isMouseOutside = false;\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tfunction onPointerDown(e) {\n\t\t\tconst target = e.target;\n\t\t\tif (!(refs.floating.current?.contains(target) || upArrowRef.current?.contains(target) || downArrowRef.current?.contains(target))) {\n\t\t\t\tsetOpen(false);\n\t\t\t\tsetControlledScrolling(false);\n\t\t\t}\n\t\t}\n\t\tif (open) {\n\t\t\tdocument.addEventListener(\"pointerdown\", onPointerDown);\n\t\t\treturn () => {\n\t\t\t\tdocument.removeEventListener(\"pointerdown\", onPointerDown);\n\t\t\t};\n\t\t}\n\t}, [\n\t\topen,\n\t\trefs,\n\t\tsetOpen\n\t]);\n\tReact.useEffect(() => {\n\t\tif (!open) return;\n\t\tconst scrollActiveIntoView = (index) => {\n\t\t\tif (controlledScrolling && index != null) listItemsRef.current[index]?.scrollIntoView({ block: \"nearest\" });\n\t\t\tsetScrollTop(refs.floating.current?.scrollTop ?? 0);\n\t\t};\n\t\tscrollActiveIntoView(activeIndexRef.current);\n\t\treturn selectItemParentContext.activeIndexSubscribe(scrollActiveIntoView);\n\t}, [\n\t\topen,\n\t\trefs,\n\t\tcontrolledScrolling,\n\t\tselectItemParentContext.activeIndexSubscribe\n\t]);\n\tReact.useEffect(() => {\n\t\tif (open && fallback) {\n\t\t\tif (selectedIndex != null) listItemsRef.current[selectedIndex]?.scrollIntoView({ block: \"nearest\" });\n\t\t}\n\t}, [\n\t\topen,\n\t\tfallback,\n\t\tselectedIndex\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (refs.floating.current && fallback) refs.floating.current.style.maxHeight = \"\";\n\t}, [refs, fallback]);\n\tconst floatingContext = React.useMemo(() => ({\n\t\trefs,\n\t\tdataRef\n\t}), [refs]);\n\treturn /* @__PURE__ */ jsx(SelectProvider, {\n\t\tscope,\n\t\t...selectContext,\n\t\tsetScrollTop,\n\t\tsetInnerOffset,\n\t\tfallback,\n\t\tfloatingContext,\n\t\tcanScrollDown: !!showDownArrow,\n\t\tcanScrollUp: !!showUpArrow,\n\t\tcontrolledScrolling,\n\t\tblockSelection,\n\t\tupArrowRef,\n\t\tdownArrowRef,\n\t\tupdate,\n\t\tchildren: /* @__PURE__ */ jsx(SelectItemParentProvider, {\n\t\t\tscope,\n\t\t\t...selectItemParentContext,\n\t\t\tallowMouseUpRef,\n\t\t\tallowSelectRef,\n\t\t\tdataRef,\n\t\t\tinteractions: interactionsContext,\n\t\t\tlistRef: listItemsRef,\n\t\t\tselectTimeoutRef,\n\t\t\tchildren\n\t\t})\n\t});\n};\n\nexport { SelectInlineImpl };"],"mappings":"AAAA,SAASA,UAAU,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C,YAAY;MACrBO,gBAAgB;MAChBtB;IACD,CAAC;EACF,CAAC,CAAC;AACH,CAAC;AAED,SAASH,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"SelectImpl.js","names":[],"sources":["jsx/SelectImpl.js"],"sourcesContent":["import { autoUpdate, inner, offset, size, useClick, useFloatingRaw, useInnerOffset, useInteractions, useListNavigation, useRole, useTypeahead } from \"@tamagui/floating\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, useEvent, useIsTouchDevice } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { SCROLL_ARROW_THRESHOLD } from \"./constants\";\nimport { SelectItemParentProvider, SelectProvider, useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\n\nconst SelectInlineImpl = (props) => {\n\tconst { scope, children, open = false, listContentRef } = props;\n\tconst selectContext = useSelectContext(scope);\n\tconst selectItemParentContext = useSelectItemParentContext(scope);\n\tconst { setActiveIndex, selectedIndex, activeIndexRef } = selectContext;\n\tconst { requestOpenChange, registry } = selectItemParentContext;\n\tconst [scrollTop, setScrollTop] = React.useState(0);\n\tconst touch = useIsTouchDevice();\n\tconst listItemsRef = selectItemParentContext.listRef;\n\tconst overflowRef = React.useRef(null);\n\tconst upArrowRef = React.useRef(null);\n\tconst downArrowRef = React.useRef(null);\n\tconst allowSelectRef = React.useRef(false);\n\tconst allowMouseUpRef = React.useRef(true);\n\tconst selectTimeoutRef = React.useRef(null);\n\tconst latestKeyboardEventRef = React.useRef(void 0);\n\tconst state = React.useRef({\n\t\tisMouseOutside: false,\n\t\tisTyping: false\n\t});\n\tconst [controlledScrolling, setControlledScrolling] = React.useState(false);\n\tconst [fallback, setFallback] = React.useState(false);\n\tconst [innerOffset, setInnerOffset] = React.useState(0);\n\tconst [blockSelection, setBlockSelection] = React.useState(false);\n\tconst floatingStyle = React.useRef({});\n\tReact.useEffect(() => {\n\t\tif (!open) {\n\t\t\tsetScrollTop(0);\n\t\t\tsetFallback(false);\n\t\t\tsetControlledScrolling(false);\n\t\t}\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open) return;\n\t\tconst mouseUp = (e) => {\n\t\t\tif (state.current.isMouseOutside) requestOpenChange(false, createChangeEventDetails(\"outside-press\", e));\n\t\t};\n\t\tdocument.addEventListener(\"mouseup\", mouseUp);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"mouseup\", mouseUp);\n\t\t};\n\t}, [open]);\n\tconst { x, y, strategy, refs, update, placement: computedPlacement } = useFloatingRaw({\n\t\topen,\n\t\tplacement: \"bottom-start\",\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tsize({ apply({ rects: { reference: { width } } }) {\n\t\t\t\tObject.assign(floatingStyle.current, { minWidth: width + 8 });\n\t\t\t\tif (refs.floating.current) Object.assign(refs.floating.current.style, floatingStyle.current);\n\t\t\t} }),\n\t\t\tinner({\n\t\t\t\tlistRef: listItemsRef,\n\t\t\t\toverflowRef,\n\t\t\t\tindex: selectedIndex,\n\t\t\t\toffset: innerOffset,\n\t\t\t\tonFallbackChange: setFallback,\n\t\t\t\tpadding: 10,\n\t\t\t\tminItemsVisible: touch ? 10 : 4,\n\t\t\t\treferenceOverflowThreshold: 20\n\t\t\t}),\n\t\t\toffset({ crossAxis: -5 })\n\t\t]\n\t});\n\tconst floatingRef = refs.floating;\n\tconst showUpArrow = open && scrollTop > SCROLL_ARROW_THRESHOLD;\n\tconst showDownArrow = open && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;\n\tconst isScrollable = showDownArrow || showUpArrow;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\t\twindow.addEventListener(\"resize\", update);\n\t\tif (open) update();\n\t\treturn () => window.removeEventListener(\"resize\", update);\n\t}, [update, open]);\n\tconst onMatch = useEvent((index) => {\n\t\tif (!open) return;\n\t\tsetActiveIndex(index, {\n\t\t\treason: \"keyboard\",\n\t\t\tevent: latestKeyboardEventRef.current,\n\t\t\ttrigger: void 0,\n\t\t\tindex\n\t\t});\n\t});\n\tconst dataRef = React.useRef({});\n\tdataRef.current.placement = computedPlacement;\n\tconst interactionContext = {\n\t\topen,\n\t\tonOpenChange: (nextOpen, event, reason) => {\n\t\t\trequestOpenChange(nextOpen, createChangeEventDetails(reason === \"list-navigation\" ? \"keyboard\" : \"trigger-press\", event, refs.reference.current));\n\t\t},\n\t\trefs: {\n\t\t\treference: refs.reference,\n\t\t\tfloating: refs.floating,\n\t\t\tdomReference: refs.reference\n\t\t},\n\t\telements: {\n\t\t\treference: refs.reference?.current || null,\n\t\t\tfloating: refs.floating?.current || null,\n\t\t\tdomReference: refs.reference?.current || null\n\t\t},\n\t\tdataRef\n\t};\n\tconst interactionsProps = [\n\t\tuseClick(interactionContext, {\n\t\t\tevent: \"mousedown\",\n\t\t\tkeyboardHandlers: false\n\t\t}),\n\t\tuseRole(interactionContext, { role: \"listbox\" }),\n\t\tuseInnerOffset(interactionContext, {\n\t\t\tenabled: !fallback && isScrollable,\n\t\t\tonChange: setInnerOffset,\n\t\t\toverflowRef,\n\t\t\tscrollRef: refs.floating\n\t\t}),\n\t\tuseListNavigation(interactionContext, {\n\t\t\tlistRef: listItemsRef,\n\t\t\tactiveIndex: selectContext.activeIndex ?? 0,\n\t\t\tselectedIndex,\n\t\t\tonNavigate: (index) => {\n\t\t\t\tif (index !== null) setActiveIndex(index, {\n\t\t\t\t\treason: \"list-navigation\",\n\t\t\t\t\tevent: latestKeyboardEventRef.current,\n\t\t\t\t\ttrigger: void 0,\n\t\t\t\t\tindex\n\t\t\t\t});\n\t\t\t},\n\t\t\tdisabledIndices: registry.getDisabledIndices(),\n\t\t\tscrollItemIntoView: false\n\t\t}),\n\t\tuseTypeahead(interactionContext, {\n\t\t\tlistRef: listContentRef,\n\t\t\tonMatch,\n\t\t\tselectedIndex,\n\t\t\tactiveIndex: selectContext.activeIndex,\n\t\t\tonTypingChange: (e) => {\n\t\t\t\tstate.current.isTyping = e;\n\t\t\t}\n\t\t})\n\t];\n\tconst interactions = useInteractions(React.useMemo(() => {\n\t\treturn interactionsProps;\n\t}, interactionsProps));\n\tconst interactionsContext = React.useMemo(() => {\n\t\treturn {\n\t\t\t...interactions,\n\t\t\tgetReferenceProps(props2 = {}) {\n\t\t\t\treturn interactions.getReferenceProps({\n\t\t\t\t\t...props2,\n\t\t\t\t\tonKeyDown: composeEventHandlers(props2.onKeyDown, (event) => {\n\t\t\t\t\t\tlatestKeyboardEventRef.current = event.nativeEvent || event;\n\t\t\t\t\t\tif (event.key === \"Enter\" || event.code === \"Space\" || event.key === \" \" && !state.current.isTyping) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\trequestOpenChange(true, createChangeEventDetails(\"keyboard\", event.nativeEvent || event, refs.reference.current));\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetFloatingProps(props2) {\n\t\t\t\treturn interactions.getFloatingProps({\n\t\t\t\t\tref: refs.floating,\n\t\t\t\t\tclassName: \"Select\",\n\t\t\t\t\t...props2,\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\ttop: y ?? \"\",\n\t\t\t\t\t\tleft: x ?? \"\",\n\t\t\t\t\t\toutline: 0,\n\t\t\t\t\t\tscrollbarWidth: \"none\",\n\t\t\t\t\t\t...floatingStyle.current,\n\t\t\t\t\t\t...props2?.style\n\t\t\t\t\t},\n\t\t\t\t\tonPointerEnter() {\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerLeave() {\n\t\t\t\t\t\tstate.current.isMouseOutside = true;\n\t\t\t\t\t},\n\t\t\t\t\tonPointerMove() {\n\t\t\t\t\t\tstate.current.isMouseOutside = false;\n\t\t\t\t\t\tsetControlledScrolling(false);\n\t\t\t\t\t},\n\t\t\t\t\tonKeyDown(event) {\n\t\t\t\t\t\tlatestKeyboardEventRef.current = event.nativeEvent || event;\n\t\t\t\t\t\tsetControlledScrolling(true);\n\t\t\t\t\t},\n\t\t\t\t\tonContextMenu(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t},\n\t\t\t\t\tonScroll(event) {\n\t\t\t\t\t\tflushSync(() => {\n\t\t\t\t\t\t\tsetScrollTop(event.currentTarget.scrollTop);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t}, [\n\t\trefs.reference.current,\n\t\tx,\n\t\ty,\n\t\trefs.floating.current,\n\t\tinteractions\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (open) {\n\t\t\tallowMouseUpRef.current = false;\n\t\t\tselectTimeoutRef.current = setTimeout(() => {\n\t\t\t\tallowSelectRef.current = true;\n\t\t\t\tallowMouseUpRef.current = true;\n\t\t\t}, 300);\n\t\t\treturn () => {\n\t\t\t\tclearTimeout(selectTimeoutRef.current);\n\t\t\t};\n\t\t}\n\t\tallowSelectRef.current = false;\n\t\tallowMouseUpRef.current = true;\n\t\tsetInnerOffset(0);\n\t\tsetFallback(false);\n\t\tsetBlockSelection(false);\n\t}, [open]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open && state.current.isMouseOutside) state.current.isMouseOutside = false;\n\t}, [open]);\n\tReact.useEffect(() => {\n\t\tif (!open) return;\n\t\tconst scrollActiveIntoView = (index) => {\n\t\t\tif (controlledScrolling && index != null) listItemsRef.current[index]?.scrollIntoView({ block: \"nearest\" });\n\t\t\tsetScrollTop(refs.floating.current?.scrollTop ?? 0);\n\t\t};\n\t\tscrollActiveIntoView(activeIndexRef.current);\n\t\treturn selectItemParentContext.activeIndexSubscribe(scrollActiveIntoView);\n\t}, [\n\t\topen,\n\t\trefs,\n\t\tcontrolledScrolling,\n\t\tselectItemParentContext.activeIndexSubscribe\n\t]);\n\tReact.useEffect(() => {\n\t\tif (open && fallback) {\n\t\t\tif (selectedIndex != null) listItemsRef.current[selectedIndex]?.scrollIntoView({ block: \"nearest\" });\n\t\t}\n\t}, [\n\t\topen,\n\t\tfallback,\n\t\tselectedIndex\n\t]);\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (refs.floating.current && fallback) refs.floating.current.style.maxHeight = \"\";\n\t}, [refs, fallback]);\n\tconst floatingContext = React.useMemo(() => ({\n\t\trefs,\n\t\tdataRef\n\t}), [refs]);\n\treturn /* @__PURE__ */ jsx(SelectProvider, {\n\t\tscope,\n\t\t...selectContext,\n\t\tsetScrollTop,\n\t\tsetInnerOffset,\n\t\tfallback,\n\t\tfloatingContext,\n\t\tcanScrollDown: !!showDownArrow,\n\t\tcanScrollUp: !!showUpArrow,\n\t\tcontrolledScrolling,\n\t\tblockSelection,\n\t\tupArrowRef,\n\t\tdownArrowRef,\n\t\tupdate,\n\t\tchildren: /* @__PURE__ */ jsx(SelectItemParentProvider, {\n\t\t\tscope,\n\t\t\t...selectItemParentContext,\n\t\t\tallowMouseUpRef,\n\t\t\tallowSelectRef,\n\t\t\tdataRef,\n\t\t\tinteractions: interactionsContext,\n\t\t\tlistRef: listItemsRef,\n\t\t\tselectTimeoutRef,\n\t\t\tchildren\n\t\t})\n\t});\n};\n\nexport { SelectInlineImpl };"],"mappings":";;;;;;;;;;;AAUA,MAAM,oBAAoB,UAAU;CACnC,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,mBAAmB;CAC1D,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,0BAA0B,2BAA2B,KAAK;CAChE,MAAM,EAAE,gBAAgB,eAAe,mBAAmB;CAC1D,MAAM,EAAE,mBAAmB,aAAa;CACxC,MAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,CAAC;CAClD,MAAM,QAAQ,iB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B,CAAC;CACD,MAAM,gBAAgB;EACrB,IAAI,QAAQ,UAAU;GACrB,IAAI,iBAAiB,MAAM,aAAa,QAAQ,gBAAgB,eAAe,EAAE,OAAO,UAAU,CAAC;EACpG;CACD,GAAG;EACF;EACA;EACA;CACD,CAAC;CACD,gCAAgC;EAC/B,IAAI,KAAK,SAAS,WAAW,UAAU,KAAK,SAAS,QAAQ,MAAM,YAAY;CAChF,GAAG,CAAC,MAAM,QAAQ,CAAC;CACnB,MAAM,kBAAkB,MAAM,eAAe;EAC5C;EACA;CACD,IAAI,CAAC,IAAI,CAAC;CACV,OAAuB,oBAAI,gBAAgB;EAC1C;EACA,GAAG;EACH;EACA;EACA;EACA;EACA,eAAe,CAAC,CAAC;EACjB,aAAa,CAAC,CAAC;EACf;EACA;EACA;EACA;EACA;EACA,UAA0B,oBAAI,0BAA0B;GACvD;GACA,GAAG;GACH;GACA;GACA;GACA,cAAc;GACd,SAAS;GACT;GACA;EACD,CAAC;CACF,CAAC;AACF"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var SelectImpl_native_exports = {};
25
+ __export(SelectImpl_native_exports, { SelectInlineImpl: () => SelectInlineImpl });
26
+ module.exports = __toCommonJS(SelectImpl_native_exports);
27
+ var import_jsx_runtime = require("react/jsx-runtime");
28
+ var SelectInlineImpl = function(props) {
29
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children });
30
+ };
@@ -1,39 +1,32 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
24
  var SelectImpl_native_exports = {};
26
- __export(SelectImpl_native_exports, {
27
- SelectInlineImpl: () => SelectInlineImpl
28
- });
25
+ __export(SelectImpl_native_exports, { SelectInlineImpl: () => SelectInlineImpl });
29
26
  module.exports = __toCommonJS(SelectImpl_native_exports);
30
27
  var import_jsx_runtime = require("react/jsx-runtime");
31
- var SelectInlineImpl = function (props) {
32
- if (process.env.NODE_ENV === "development") {
33
- console.warn("Sheet not implemented inline on native");
34
- }
35
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
36
- children: props.children
37
- });
28
+ var SelectInlineImpl = function(props) {
29
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children });
38
30
  };
31
+
39
32
  //# sourceMappingURL=SelectImpl.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SelectImpl_native_exports","__export","SelectInlineImpl","module","exports","__toCommonJS","import_jsx_runtime","require","props","process","env","NODE_ENV","console","warn","jsx","Fragment","children"],"sources":["../../src/SelectImpl.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,yBAAA;AAAA,IAAAM,kBAAA,GAAmDC,OAAA;AAIxC,IAAIL,gBAAA,GAAmB,SAAAA,CAASM,KAAA,EAAO;EAC9C,IAAIC,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,eAAe;IACxCC,OAAA,CAAQC,IAAA,CAAK,wCAAwC;EACzD;EACA,OAAqB,mBAAAP,kBAAA,CAAAQ,GAAA,EAAKR,kBAAA,CAAAS,QAAA,EAAW;IACjCC,QAAA,EAAUR,KAAA,CAAMQ;EACpB,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"file":"SelectImpl.native.js","names":[],"sources":["jsx/SelectImpl.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar SelectImpl_native_exports = {};\n__export(SelectImpl_native_exports, {\n SelectInlineImpl: () => SelectInlineImpl\n});\nmodule.exports = __toCommonJS(SelectImpl_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar SelectInlineImpl = function(props) {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {\n children: props.children\n });\n};\n//# sourceMappingURL=SelectImpl.native.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,4BAA4B,CAAC;AACjC,SAAS,2BAA2B,EAClC,wBAAwB,iBAC1B,CAAC;AACD,OAAO,UAAU,aAAa,yBAAyB;AACvD,IAAI,qBAAqB,QAAQ,mBAAmB;AACpD,IAAI,mBAAmB,SAAS,OAAO;CACrC,OAAuB,iBAAC,GAAG,mBAAmB,KAAK,mBAAmB,UAAU,EAC9E,UAAU,MAAM,SAClB,CAAC;AACH"}
@@ -1,189 +1,259 @@
1
1
  import { useComposedRefs } from "@tamagui/compose-refs";
2
+ import { useAdaptIsActive } from "@tamagui/adapt";
2
3
  import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
3
- import { createStyledContext } from "@tamagui/core";
4
- import { ListItem } from "@tamagui/list-item";
4
+ import { View, createChangeEventDetails, createStyledContext, createStyledHOC, styled } from "@tamagui/core";
5
+ import { composeEventHandlers } from "@tamagui/helpers";
5
6
  import * as React from "react";
6
- import { useSelectItemParentContext } from "./context.mjs";
7
+ import { useSelectContext, useSelectItemParentContext } from "./context.mjs";
8
+ import { getSelectOptionProps } from "./selectionController.mjs";
7
9
  import { jsx } from "react/jsx-runtime";
10
+
8
11
  const ITEM_NAME = "SelectItem";
9
- const {
10
- Provider: SelectItemContextProvider,
11
- useStyledContext: useSelectItemContext
12
- } = createStyledContext(null, ITEM_NAME);
13
- const SelectItem = ListItem.Frame.styleable(function SelectItem2(props, forwardedRef) {
14
- const {
15
- scope,
16
- value,
17
- disabled = false,
18
- textValue: textValueProp,
19
- index,
20
- ...restProps
21
- } = props;
22
- const context = useSelectItemParentContext(scope);
23
- const {
24
- setSelectedIndex,
25
- listRef,
26
- setOpen,
27
- onChange,
28
- activeIndexSubscribe,
29
- activeIndexRef,
30
- valueSubscribe,
31
- allowMouseUpRef,
32
- allowSelectRef,
33
- setValueAtIndex,
34
- selectTimeoutRef,
35
- dataRef,
36
- interactions,
37
- shouldRenderWebNative,
38
- size,
39
- onActiveChange,
40
- initialValue,
41
- setActiveIndexFast
42
- } = context;
43
- const [isSelected, setSelected] = React.useState(initialValue === value);
44
- useIsomorphicLayoutEffect(() => {
45
- if (initialValue === value) {
46
- setSelectedIndex(index);
47
- }
48
- }, []);
49
- React.useEffect(() => {
50
- const handleActiveIndex = i => {
51
- if (index === i) {
52
- onActiveChange(value, index);
53
- if (isWeb) {
54
- requestAnimationFrame(() => {
55
- listRef?.current[index]?.focus();
56
- });
57
- }
58
- }
59
- };
60
- const currentActiveIndex = activeIndexRef?.current;
61
- if (currentActiveIndex !== null && currentActiveIndex !== void 0) {
62
- handleActiveIndex(currentActiveIndex);
63
- }
64
- return activeIndexSubscribe(handleActiveIndex);
65
- }, [index]);
66
- React.useEffect(() => {
67
- return valueSubscribe(val => {
68
- setSelected(val === value);
69
- });
70
- }, [value]);
71
- const textId = React.useId();
72
- const refCallback = React.useCallback(node => {
73
- if (!isWeb) return;
74
- if (node instanceof HTMLElement) {
75
- if (listRef) {
76
- listRef.current[index] = node;
77
- }
78
- }
79
- }, [index, listRef]);
80
- const composedRefs = useComposedRefs(forwardedRef, refCallback);
81
- useIsomorphicLayoutEffect(() => {
82
- setValueAtIndex(index, value);
83
- }, [index, setValueAtIndex, value]);
84
- function handleSelect() {
85
- setSelectedIndex(index);
86
- onChange(value);
87
- setOpen(false);
88
- }
89
- const selectItemProps = React.useMemo(() => {
90
- return interactions ? interactions.getItemProps({
91
- onTouchMove() {
92
- allowSelectRef.current = true;
93
- allowMouseUpRef.current = false;
94
- },
95
- onTouchEnd() {
96
- allowSelectRef.current = false;
97
- allowMouseUpRef.current = true;
98
- },
99
- onKeyDown(event) {
100
- if (event.key === "Enter" || event.key === " " && !dataRef?.current.typing) {
101
- event.preventDefault();
102
- handleSelect();
103
- } else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
104
- event.preventDefault();
105
- event.stopPropagation();
106
- const itemCount = listRef?.current.length ?? 0;
107
- if (itemCount === 0) return;
108
- let nextIndex;
109
- if (event.key === "ArrowDown") {
110
- nextIndex = index + 1 >= itemCount ? 0 : index + 1;
111
- } else {
112
- nextIndex = index - 1 < 0 ? itemCount - 1 : index - 1;
113
- }
114
- setActiveIndexFast?.(nextIndex);
115
- } else {
116
- allowSelectRef.current = true;
117
- }
118
- },
119
- onClick() {
120
- if (allowSelectRef.current) {
121
- handleSelect();
122
- }
123
- },
124
- onMouseUp() {
125
- if (!allowMouseUpRef.current) {
126
- allowMouseUpRef.current = true;
127
- allowSelectRef.current = true;
128
- return;
129
- }
130
- if (allowSelectRef.current) {
131
- handleSelect();
132
- }
133
- clearTimeout(selectTimeoutRef.current);
134
- selectTimeoutRef.current = setTimeout(() => {
135
- allowSelectRef.current = true;
136
- });
137
- }
138
- }) : {
139
- onPress: handleSelect
140
- };
141
- }, [handleSelect, index, listRef, setActiveIndexFast]);
142
- return /* @__PURE__ */jsx(SelectItemContextProvider, {
143
- scope,
144
- value,
145
- textId: textId || "",
146
- isSelected,
147
- children: shouldRenderWebNative ? /* @__PURE__ */jsx("option", {
148
- value,
149
- children: props.children
150
- }) : /* @__PURE__ */jsx(ListItem.Frame, {
151
- render: "div",
152
- componentName: ITEM_NAME,
153
- ref: composedRefs,
154
- role: "option",
155
- "aria-labelledby": textId,
156
- "aria-selected": isSelected,
157
- "data-state": isSelected ? "active" : "inactive",
158
- "aria-disabled": disabled || void 0,
159
- "data-disabled": disabled ? "" : void 0,
160
- tabIndex: disabled ? void 0 : -1,
161
- ...(!props.unstyled && {
162
- cursor: "default",
163
- size,
164
- outlineOffset: -0.5,
165
- zIndex: 100,
166
- hoverStyle: {
167
- backgroundColor: "$backgroundHover"
168
- },
169
- pressStyle: {
170
- backgroundColor: "$backgroundPress"
171
- },
172
- focusStyle: {
173
- backgroundColor: "$backgroundFocus"
174
- },
175
- focusVisibleStyle: {
176
- outlineColor: "$outlineColor",
177
- outlineWidth: 1,
178
- outlineStyle: "solid"
179
- }
180
- }),
181
- ...restProps,
182
- ...selectItemProps
183
- })
184
- });
185
- }, {
186
- disableTheme: true
12
+ const { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = createStyledContext(null, ITEM_NAME);
13
+ const SelectItemFrame = styled(View, {
14
+ displayName: ITEM_NAME,
15
+ alignItems: "center",
16
+ flexDirection: "row"
187
17
  });
188
- export { SelectItem, SelectItemContextProvider, useSelectItemContext };
18
+ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, forwardedRef) {
19
+ const { scope, value, disabled: disabledProp, "aria-disabled": ariaDisabled, textValue: textValueProp, ...restProps } = props;
20
+ const disabled = disabledProp ?? ariaDisabled === true;
21
+ const context = useSelectItemParentContext(scope);
22
+ const selectContext = useSelectContext(scope);
23
+ const isAdapted = useAdaptIsActive(selectContext.adaptScope);
24
+ const { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;
25
+ const isSelected = selectedValues.includes(value);
26
+ const pendingMouseUpSelectionRef = React.useRef(false);
27
+ const itemNodeRef = React.useRef(null);
28
+ const [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);
29
+ const registrationRef = React.useRef(null);
30
+ const initialRegistration = React.useRef({
31
+ value,
32
+ disabled,
33
+ textValue: textValueProp
34
+ });
35
+ useIsomorphicLayoutEffect(() => registry.subscribe(() => rerenderRegistry()), [registry]);
36
+ useIsomorphicLayoutEffect(() => {
37
+ const registration = registry.registerItem(initialRegistration.current);
38
+ registrationRef.current = registration;
39
+ const registeredNode = itemNodeRef.current;
40
+ registration.setNode(registeredNode);
41
+ const registeredIndex = registry.getItems().findIndex((item) => item.id === registration.id);
42
+ if (isWeb && listRef && registeredIndex >= 0 && registeredNode instanceof HTMLElement) {
43
+ listRef.current[registeredIndex] = registeredNode;
44
+ }
45
+ return () => {
46
+ const currentIndex = registry.getItems().findIndex((item) => item.id === registration.id);
47
+ if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {
48
+ listRef.current[currentIndex] = null;
49
+ }
50
+ registrationRef.current = null;
51
+ registration.unregister();
52
+ };
53
+ }, [registry]);
54
+ useIsomorphicLayoutEffect(() => {
55
+ registrationRef.current?.update({
56
+ value,
57
+ disabled,
58
+ textValue: textValueProp
59
+ });
60
+ }, [
61
+ disabled,
62
+ textValueProp,
63
+ value
64
+ ]);
65
+ useIsomorphicLayoutEffect(() => {
66
+ registrationRef.current?.setNode(itemNodeRef.current);
67
+ });
68
+ const index = registry.getIndex(value);
69
+ React.useEffect(() => {
70
+ const handleActiveIndex = (i) => {
71
+ if (index === i) {
72
+ if (isWeb) {
73
+ requestAnimationFrame(() => {
74
+ listRef?.current[index]?.focus();
75
+ });
76
+ }
77
+ }
78
+ };
79
+ const currentActiveIndex = activeIndexRef?.current;
80
+ if (currentActiveIndex !== null && currentActiveIndex !== void 0) {
81
+ handleActiveIndex(currentActiveIndex);
82
+ }
83
+ return activeIndexSubscribe(handleActiveIndex);
84
+ }, [
85
+ activeIndexRef,
86
+ activeIndexSubscribe,
87
+ index,
88
+ listRef
89
+ ]);
90
+ const textId = React.useId();
91
+ const refCallback = React.useCallback((node) => {
92
+ itemNodeRef.current = node;
93
+ registrationRef.current?.setNode(node);
94
+ if (!isWeb) return;
95
+ if (listRef && index >= 0) {
96
+ listRef.current[index] = node instanceof HTMLElement ? node : null;
97
+ }
98
+ }, [index, listRef]);
99
+ const composedRefs = useComposedRefs(forwardedRef, refCallback);
100
+ const handleSelect = React.useCallback((event, reason = "item-press") => {
101
+ if (disabled) return;
102
+ const nativeEvent = event?.nativeEvent || event;
103
+ selectValue(value, createChangeEventDetails(reason, nativeEvent, event?.currentTarget));
104
+ }, [
105
+ disabled,
106
+ selectValue,
107
+ value
108
+ ]);
109
+ const handleKeyDown = React.useCallback((event) => {
110
+ if (disabled) return;
111
+ if (event.key === "Enter" || event.key === " ") {
112
+ event.preventDefault();
113
+ handleSelect(event, "keyboard");
114
+ return;
115
+ }
116
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
117
+ event.preventDefault();
118
+ event.stopPropagation();
119
+ moveActive(event.key === "ArrowDown" ? 1 : -1, event.nativeEvent || event);
120
+ return;
121
+ }
122
+ if (!interactions && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {
123
+ search(event.key, event.nativeEvent || event);
124
+ }
125
+ if (allowSelectRef) {
126
+ allowSelectRef.current = true;
127
+ }
128
+ }, [
129
+ allowSelectRef,
130
+ disabled,
131
+ handleSelect,
132
+ interactions,
133
+ moveActive,
134
+ search
135
+ ]);
136
+ const selectItemProps = React.useMemo(() => {
137
+ if (interactions) {
138
+ const { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;
139
+ const interactionProps = interactions.getItemProps({
140
+ ...itemProps,
141
+ onTouchMove() {
142
+ allowSelectRef.current = true;
143
+ allowMouseUpRef.current = false;
144
+ },
145
+ onTouchEnd() {
146
+ allowSelectRef.current = false;
147
+ allowMouseUpRef.current = true;
148
+ },
149
+ onMouseMove(event) {
150
+ if (disabled || index < 0) return;
151
+ setActiveIndexFast?.(index, {
152
+ reason: "item-hover",
153
+ event: event.nativeEvent || event,
154
+ trigger: event.currentTarget,
155
+ index
156
+ });
157
+ },
158
+ onKeyDown: handleKeyDown,
159
+ onClick(event) {
160
+ if (disabled) return;
161
+ const shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;
162
+ pendingMouseUpSelectionRef.current = false;
163
+ clearTimeout(selectTimeoutRef.current);
164
+ allowSelectRef.current = true;
165
+ if (shouldSelect) {
166
+ handleSelect(event);
167
+ }
168
+ },
169
+ onMouseUp(event) {
170
+ if (disabled) return;
171
+ if (!allowMouseUpRef.current) {
172
+ allowMouseUpRef.current = true;
173
+ allowSelectRef.current = true;
174
+ return;
175
+ }
176
+ pendingMouseUpSelectionRef.current = allowSelectRef.current;
177
+ clearTimeout(selectTimeoutRef.current);
178
+ selectTimeoutRef.current = setTimeout(() => {
179
+ allowSelectRef.current = true;
180
+ if (pendingMouseUpSelectionRef.current) {
181
+ pendingMouseUpSelectionRef.current = false;
182
+ handleSelect(event);
183
+ }
184
+ });
185
+ }
186
+ });
187
+ return {
188
+ ...interactionProps,
189
+ onTouchMove: composeEventHandlers(onTouchMove, interactionProps.onTouchMove),
190
+ onTouchEnd: composeEventHandlers(onTouchEnd, interactionProps.onTouchEnd),
191
+ onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),
192
+ onClick(event) {
193
+ onClick?.(event);
194
+ if (event.defaultPrevented) {
195
+ pendingMouseUpSelectionRef.current = false;
196
+ clearTimeout(selectTimeoutRef.current);
197
+ allowSelectRef.current = true;
198
+ return;
199
+ }
200
+ interactionProps.onClick?.(event);
201
+ },
202
+ onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),
203
+ onMouseMove: composeEventHandlers(onMouseMove, interactionProps.onMouseMove),
204
+ onPress
205
+ };
206
+ }
207
+ return {
208
+ ...restProps,
209
+ onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),
210
+ onMouseMove: composeEventHandlers(restProps.onMouseMove, (event) => {
211
+ if (disabled || index < 0) return;
212
+ setActiveIndexFast?.(index, {
213
+ reason: "item-hover",
214
+ event: event.nativeEvent || event,
215
+ trigger: event.currentTarget,
216
+ index
217
+ });
218
+ }),
219
+ onPress: composeEventHandlers(restProps.onPress, handleSelect)
220
+ };
221
+ }, [
222
+ allowMouseUpRef,
223
+ allowSelectRef,
224
+ disabled,
225
+ handleKeyDown,
226
+ handleSelect,
227
+ index,
228
+ interactions,
229
+ restProps,
230
+ selectTimeoutRef,
231
+ setActiveIndexFast
232
+ ]);
233
+ const accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? "web" : "native");
234
+ return /* @__PURE__ */ jsx(SelectItemContextProvider, {
235
+ scope,
236
+ value,
237
+ textId: textId || "",
238
+ textValue: textValueProp,
239
+ isSelected,
240
+ children: shouldRenderWebNative ? /* @__PURE__ */ jsx("option", {
241
+ value,
242
+ disabled,
243
+ children: props.children
244
+ }) : /* @__PURE__ */ jsx(SelectItemFrame, {
245
+ render: "div",
246
+ ref: composedRefs,
247
+ "aria-labelledby": textId,
248
+ "data-state": isSelected ? "active" : "inactive",
249
+ "data-disabled": disabled ? "" : void 0,
250
+ tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === (selectContext.activeIndex ?? selectContext.selectedIndex) ? 0 : -1 : -1,
251
+ zIndex: 100,
252
+ ...selectItemProps,
253
+ ...accessibilityProps
254
+ })
255
+ });
256
+ }, { disableTheme: true });
257
+
258
+ export { SelectItem, SelectItemContextProvider, SelectItemFrame, useSelectItemContext };
189
259
  //# sourceMappingURL=SelectItem.mjs.map