@tamagui/select 3.0.0-beta.924.1 → 3.0.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 (106) hide show
  1. package/dist/cjs/Select.cjs +23 -25
  2. package/dist/cjs/Select.native.cjs +27 -26
  3. package/dist/cjs/Select.native.js +27 -26
  4. package/dist/cjs/Select.native.js.map +1 -1
  5. package/dist/cjs/SelectImpl.cjs +67 -63
  6. package/dist/cjs/SelectItem.cjs +49 -60
  7. package/dist/cjs/SelectItem.native.cjs +51 -79
  8. package/dist/cjs/SelectItem.native.js +51 -79
  9. package/dist/cjs/SelectItem.native.js.map +1 -1
  10. package/dist/cjs/SelectScrollButton.cjs +9 -25
  11. package/dist/cjs/SelectTrigger.cjs +22 -5
  12. package/dist/cjs/SelectTrigger.native.cjs +15 -5
  13. package/dist/cjs/SelectTrigger.native.js +15 -5
  14. package/dist/cjs/SelectTrigger.native.js.map +1 -1
  15. package/dist/cjs/SelectViewport.cjs +29 -32
  16. package/dist/cjs/SelectViewport.native.cjs +2 -2
  17. package/dist/cjs/SelectViewport.native.js +2 -2
  18. package/dist/cjs/SelectViewport.native.js.map +1 -1
  19. package/dist/cjs/selectionController.cjs +15 -5
  20. package/dist/cjs/selectionController.native.cjs +20 -15
  21. package/dist/cjs/selectionController.native.js +20 -15
  22. package/dist/cjs/selectionController.native.js.map +1 -1
  23. package/dist/esm/Select.mjs +27 -28
  24. package/dist/esm/Select.mjs.map +1 -1
  25. package/dist/esm/Select.native.js +31 -29
  26. package/dist/esm/Select.native.js.map +1 -1
  27. package/dist/esm/SelectImpl.mjs +68 -64
  28. package/dist/esm/SelectImpl.mjs.map +1 -1
  29. package/dist/esm/SelectItem.mjs +50 -61
  30. package/dist/esm/SelectItem.mjs.map +1 -1
  31. package/dist/esm/SelectItem.native.js +52 -80
  32. package/dist/esm/SelectItem.native.js.map +1 -1
  33. package/dist/esm/SelectScrollButton.mjs +10 -26
  34. package/dist/esm/SelectScrollButton.mjs.map +1 -1
  35. package/dist/esm/SelectTrigger.mjs +16 -5
  36. package/dist/esm/SelectTrigger.mjs.map +1 -1
  37. package/dist/esm/SelectTrigger.native.js +15 -4
  38. package/dist/esm/SelectTrigger.native.js.map +1 -1
  39. package/dist/esm/SelectViewport.mjs +30 -33
  40. package/dist/esm/SelectViewport.mjs.map +1 -1
  41. package/dist/esm/SelectViewport.native.js +3 -3
  42. package/dist/esm/SelectViewport.native.js.map +1 -1
  43. package/dist/esm/selectionController.mjs +15 -5
  44. package/dist/esm/selectionController.mjs.map +1 -1
  45. package/dist/esm/selectionController.native.js +20 -15
  46. package/dist/esm/selectionController.native.js.map +1 -1
  47. package/dist/jsx/Select.mjs +27 -28
  48. package/dist/jsx/Select.mjs.map +1 -1
  49. package/dist/jsx/Select.native.cjs +27 -26
  50. package/dist/jsx/Select.native.js +27 -26
  51. package/dist/jsx/Select.native.js.map +1 -1
  52. package/dist/jsx/SelectImpl.mjs +68 -64
  53. package/dist/jsx/SelectImpl.mjs.map +1 -1
  54. package/dist/jsx/SelectItem.mjs +50 -61
  55. package/dist/jsx/SelectItem.mjs.map +1 -1
  56. package/dist/jsx/SelectItem.native.cjs +51 -79
  57. package/dist/jsx/SelectItem.native.js +51 -79
  58. package/dist/jsx/SelectItem.native.js.map +1 -1
  59. package/dist/jsx/SelectScrollButton.mjs +10 -26
  60. package/dist/jsx/SelectScrollButton.mjs.map +1 -1
  61. package/dist/jsx/SelectTrigger.mjs +16 -5
  62. package/dist/jsx/SelectTrigger.mjs.map +1 -1
  63. package/dist/jsx/SelectTrigger.native.cjs +15 -5
  64. package/dist/jsx/SelectTrigger.native.js +15 -5
  65. package/dist/jsx/SelectTrigger.native.js.map +1 -1
  66. package/dist/jsx/SelectViewport.mjs +30 -33
  67. package/dist/jsx/SelectViewport.mjs.map +1 -1
  68. package/dist/jsx/SelectViewport.native.cjs +2 -2
  69. package/dist/jsx/SelectViewport.native.js +2 -2
  70. package/dist/jsx/SelectViewport.native.js.map +1 -1
  71. package/dist/jsx/selectionController.mjs +15 -5
  72. package/dist/jsx/selectionController.mjs.map +1 -1
  73. package/dist/jsx/selectionController.native.cjs +20 -15
  74. package/dist/jsx/selectionController.native.js +20 -15
  75. package/dist/jsx/selectionController.native.js.map +1 -1
  76. package/package.json +30 -29
  77. package/src/Select.tsx +41 -41
  78. package/src/SelectImpl.tsx +107 -95
  79. package/src/SelectItem.tsx +66 -91
  80. package/src/SelectScrollButton.tsx +14 -32
  81. package/src/SelectTrigger.tsx +19 -2
  82. package/src/SelectViewport.native.tsx +4 -4
  83. package/src/SelectViewport.tsx +34 -30
  84. package/src/selectionController.ts +20 -5
  85. package/src/types.tsx +26 -22
  86. package/types/Select.d.ts +42 -81
  87. package/types/Select.d.ts.map +1 -1
  88. package/types/SelectImpl.d.ts.map +1 -1
  89. package/types/SelectItem.d.ts +3 -5
  90. package/types/SelectItem.d.ts.map +1 -1
  91. package/types/SelectItemText.d.ts +3 -5
  92. package/types/SelectItemText.d.ts.map +1 -1
  93. package/types/SelectScrollButton.d.ts +5 -9
  94. package/types/SelectScrollButton.d.ts.map +1 -1
  95. package/types/SelectScrollButton.native.d.ts +5 -9
  96. package/types/SelectScrollButton.native.d.ts.map +1 -1
  97. package/types/SelectTrigger.d.ts +3 -5
  98. package/types/SelectTrigger.d.ts.map +1 -1
  99. package/types/SelectViewport.d.ts +4 -9
  100. package/types/SelectViewport.d.ts.map +1 -1
  101. package/types/SelectViewport.native.d.ts +4 -9
  102. package/types/SelectViewport.native.d.ts.map +1 -1
  103. package/types/selectionController.d.ts +2 -0
  104. package/types/selectionController.d.ts.map +1 -1
  105. package/types/types.d.ts +30 -22
  106. package/types/types.d.ts.map +1 -1
@@ -4,7 +4,7 @@ import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
4
4
  import { View, createChangeEventDetails, createStyledContext, createStyledHOC, styled } from "@tamagui/core";
5
5
  import { composeEventHandlers } from "@tamagui/helpers";
6
6
  import * as React from "react";
7
- import { useSelectContext, useSelectItemParentContext } from "./context.mjs";
7
+ import { useSelectItemParentContext } from "./context.mjs";
8
8
  import { getSelectOptionProps } from "./selectionController.mjs";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
 
@@ -19,34 +19,22 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
19
19
  const { scope, value, disabled: disabledProp, "aria-disabled": ariaDisabled, textValue: textValueProp, ...restProps } = props;
20
20
  const disabled = disabledProp ?? ariaDisabled === true;
21
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;
22
+ const isAdapted = useAdaptIsActive(context.adaptScope);
23
+ const { registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, getItemProps, shouldRenderWebNative, setActiveIndex, lastPointerRef, moveActive, search } = context;
25
24
  const isSelected = selectedValues.includes(value);
26
25
  const pendingMouseUpSelectionRef = React.useRef(false);
27
26
  const itemNodeRef = React.useRef(null);
28
- const [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);
29
27
  const registrationRef = React.useRef(null);
30
28
  const initialRegistration = React.useRef({
31
29
  value,
32
30
  disabled,
33
31
  textValue: textValueProp
34
32
  });
35
- useIsomorphicLayoutEffect(() => registry.subscribe(() => rerenderRegistry()), [registry]);
36
33
  useIsomorphicLayoutEffect(() => {
37
34
  const registration = registry.registerItem(initialRegistration.current);
38
35
  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
- }
36
+ registration.setNode(itemNodeRef.current);
45
37
  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
38
  registrationRef.current = null;
51
39
  registration.unregister();
52
40
  };
@@ -65,37 +53,34 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
65
53
  useIsomorphicLayoutEffect(() => {
66
54
  registrationRef.current?.setNode(itemNodeRef.current);
67
55
  });
68
- const index = registry.getIndex(value);
56
+ const [isActive, setIsActive] = React.useState(false);
57
+ const isActiveRef = React.useRef(false);
69
58
  React.useEffect(() => {
70
59
  const handleActiveIndex = (i) => {
71
- if (index === i) {
72
- if (isWeb) {
73
- requestAnimationFrame(() => {
74
- listRef?.current[index]?.focus();
75
- });
76
- }
60
+ const next = i != null && registry.getIndex(value) === i;
61
+ if (next !== isActiveRef.current) {
62
+ isActiveRef.current = next;
63
+ setIsActive(next);
64
+ }
65
+ if (next && isWeb) {
66
+ requestAnimationFrame(() => {
67
+ itemNodeRef.current?.focus?.();
68
+ });
77
69
  }
78
70
  };
79
- const currentActiveIndex = activeIndexRef?.current;
80
- if (currentActiveIndex !== null && currentActiveIndex !== void 0) {
81
- handleActiveIndex(currentActiveIndex);
82
- }
71
+ handleActiveIndex(activeIndexRef?.current ?? null);
83
72
  return activeIndexSubscribe(handleActiveIndex);
84
73
  }, [
85
74
  activeIndexRef,
86
75
  activeIndexSubscribe,
87
- index,
88
- listRef
76
+ registry,
77
+ value
89
78
  ]);
90
79
  const textId = React.useId();
91
80
  const refCallback = React.useCallback((node) => {
92
81
  itemNodeRef.current = node;
93
82
  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]);
83
+ }, []);
99
84
  const composedRefs = useComposedRefs(forwardedRef, refCallback);
100
85
  const handleSelect = React.useCallback((event, reason = "item-press") => {
101
86
  if (disabled) return;
@@ -106,6 +91,27 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
106
91
  selectValue,
107
92
  value
108
93
  ]);
94
+ const handleMouseMove = React.useCallback((event) => {
95
+ if (disabled) return;
96
+ const index = registry.getIndex(value);
97
+ if (index < 0) return;
98
+ const last = lastPointerRef.current;
99
+ if (event.clientX === last.x && event.clientY === last.y) return;
100
+ last.x = event.clientX;
101
+ last.y = event.clientY;
102
+ setActiveIndex(index, {
103
+ reason: "item-hover",
104
+ event: event.nativeEvent || event,
105
+ trigger: event.currentTarget,
106
+ index
107
+ });
108
+ }, [
109
+ disabled,
110
+ lastPointerRef,
111
+ registry,
112
+ setActiveIndex,
113
+ value
114
+ ]);
109
115
  const handleKeyDown = React.useCallback((event) => {
110
116
  if (disabled) return;
111
117
  if (event.key === "Enter" || event.key === " ") {
@@ -119,7 +125,7 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
119
125
  moveActive(event.key === "ArrowDown" ? 1 : -1, event.nativeEvent || event);
120
126
  return;
121
127
  }
122
- if (!interactions && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {
128
+ if (!getItemProps && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {
123
129
  search(event.key, event.nativeEvent || event);
124
130
  }
125
131
  if (allowSelectRef) {
@@ -129,14 +135,14 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
129
135
  allowSelectRef,
130
136
  disabled,
131
137
  handleSelect,
132
- interactions,
138
+ getItemProps,
133
139
  moveActive,
134
140
  search
135
141
  ]);
136
142
  const selectItemProps = React.useMemo(() => {
137
- if (interactions) {
143
+ if (getItemProps) {
138
144
  const { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;
139
- const interactionProps = interactions.getItemProps({
145
+ const interactionProps = getItemProps({
140
146
  ...itemProps,
141
147
  onTouchMove() {
142
148
  allowSelectRef.current = true;
@@ -146,15 +152,7 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
146
152
  allowSelectRef.current = false;
147
153
  allowMouseUpRef.current = true;
148
154
  },
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
- },
155
+ onMouseMove: handleMouseMove,
158
156
  onKeyDown: handleKeyDown,
159
157
  onClick(event) {
160
158
  if (disabled) return;
@@ -207,15 +205,7 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
207
205
  return {
208
206
  ...restProps,
209
207
  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
- }),
208
+ onMouseMove: composeEventHandlers(restProps.onMouseMove, handleMouseMove),
219
209
  onPress: composeEventHandlers(restProps.onPress, handleSelect)
220
210
  };
221
211
  }, [
@@ -223,12 +213,11 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
223
213
  allowSelectRef,
224
214
  disabled,
225
215
  handleKeyDown,
216
+ handleMouseMove,
226
217
  handleSelect,
227
- index,
228
- interactions,
218
+ getItemProps,
229
219
  restProps,
230
- selectTimeoutRef,
231
- setActiveIndexFast
220
+ selectTimeoutRef
232
221
  ]);
233
222
  const accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? "web" : "native");
234
223
  return /* @__PURE__ */ jsx(SelectItemContextProvider, {
@@ -247,7 +236,7 @@ const SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props,
247
236
  "aria-labelledby": textId,
248
237
  "data-state": isSelected ? "active" : "inactive",
249
238
  "data-disabled": disabled ? "" : void 0,
250
- tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === (selectContext.activeIndex ?? selectContext.selectedIndex) ? 0 : -1 : -1,
239
+ tabIndex: disabled ? void 0 : isWeb && isAdapted && (isActive || activeIndexRef?.current == null && isSelected) ? 0 : -1,
251
240
  zIndex: 100,
252
241
  ...selectItemProps,
253
242
  ...accessibilityProps
@@ -1 +1 @@
1
- {"version":3,"file":"SelectItem.js","names":[],"sources":["esm/SelectItem.js"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport {\n createChangeEventDetails,\n createStyledHOC,\n createStyledContext,\n styled,\n View\n} from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nimport { jsx } from \"react/jsx-runtime\";\nconst ITEM_NAME = \"SelectItem\";\nconst {\n Provider: SelectItemContextProvider,\n useStyledContext: useSelectItemContext\n} = createStyledContext(null, ITEM_NAME);\nconst SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nconst SelectItem = createStyledHOC(\n SelectItemFrame,\n function SelectItem2(props, forwardedRef) {\n const {\n scope,\n value,\n disabled: disabledProp,\n \"aria-disabled\": ariaDisabled,\n textValue: textValueProp,\n ...restProps\n } = props;\n const disabled = disabledProp ?? ariaDisabled === true;\n const context = useSelectItemParentContext(scope);\n const selectContext = useSelectContext(scope);\n const isAdapted = useAdaptIsActive(selectContext.adaptScope);\n const {\n listRef,\n registry,\n mode,\n selectedValues,\n selectValue,\n activeIndexSubscribe,\n activeIndexRef,\n allowMouseUpRef,\n allowSelectRef,\n selectTimeoutRef,\n interactions,\n shouldRenderWebNative,\n setActiveIndexFast,\n moveActive,\n search\n } = context;\n const isSelected = selectedValues.includes(value);\n const pendingMouseUpSelectionRef = React.useRef(false);\n const itemNodeRef = React.useRef(null);\n const [, rerenderRegistry] = React.useReducer((version) => version + 1, 0);\n const registrationRef = React.useRef(\n null\n );\n const initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(\n () => registry.subscribe(() => rerenderRegistry()),\n [registry]\n );\n useIsomorphicLayoutEffect(() => {\n const registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n const registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n const registeredIndex = registry.getItems().findIndex((item) => item.id === registration.id);\n if (isWeb && listRef && registeredIndex >= 0 && registeredNode instanceof HTMLElement) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return () => {\n const currentIndex = registry.getItems().findIndex((item) => item.id === registration.id);\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [registry]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.update({ value, disabled, textValue: textValueProp });\n }, [disabled, textValueProp, value]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.setNode(itemNodeRef.current);\n });\n const index = registry.getIndex(value);\n React.useEffect(() => {\n const handleActiveIndex = (i) => {\n if (index === i) {\n if (isWeb) {\n requestAnimationFrame(() => {\n listRef?.current[index]?.focus();\n });\n }\n }\n };\n const currentActiveIndex = activeIndexRef?.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [activeIndexRef, activeIndexSubscribe, index, listRef]);\n const textId = React.useId();\n const refCallback = React.useCallback(\n (node) => {\n itemNodeRef.current = node;\n registrationRef.current?.setNode(node);\n if (!isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = node instanceof HTMLElement ? node : null;\n }\n },\n [index, listRef]\n );\n const composedRefs = useComposedRefs(forwardedRef, refCallback);\n const handleSelect = React.useCallback(\n (event, reason = \"item-press\") => {\n if (disabled) return;\n const nativeEvent = event?.nativeEvent || event;\n selectValue(\n value,\n createChangeEventDetails(\n reason,\n nativeEvent,\n event?.currentTarget\n )\n );\n },\n [disabled, selectValue, value]\n );\n const handleKeyDown = React.useCallback(\n (event) => {\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n },\n [allowSelectRef, disabled, handleSelect, interactions, moveActive, search]\n );\n const selectItemProps = React.useMemo(() => {\n if (interactions) {\n const {\n onTouchMove,\n onTouchEnd,\n onKeyDown,\n onClick,\n onMouseUp,\n onMouseMove,\n onPress,\n ...itemProps\n } = restProps;\n const interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast?.(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n const shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(\n onTouchMove,\n interactionProps.onTouchMove\n ),\n onTouchEnd: composeEventHandlers(\n onTouchEnd,\n interactionProps.onTouchEnd\n ),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n onClick?.(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n interactionProps.onClick?.(event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(\n onMouseMove,\n interactionProps.onMouseMove\n ),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, (event) => {\n if (disabled || index < 0) return;\n setActiveIndexFast?.(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n const accessibilityProps = getSelectOptionProps(\n mode,\n isSelected,\n disabled,\n isWeb ? \"web\" : \"native\"\n );\n return /* @__PURE__ */ jsx(\n SelectItemContextProvider,\n {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ jsx(\"option\", { value, disabled, children: props.children }) : /* @__PURE__ */ jsx(\n SelectItemFrame,\n {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === (selectContext.activeIndex ?? selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n }\n )\n }\n );\n },\n {\n disableTheme: true\n }\n);\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,EACJ,UAAU,2BACV,kBAAkB,yBAChB,oBAAoB,MAAM,SAAS;AACvC,MAAM,kBAAkB,OAAO,MAAM;CACnC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,MAAM,aAAa,gBACjB,iBACA,SAAS,YAAY,OAAO,cAAc;CACxC,MAAM,EACJ,OACA,OACA,UAAU,cACV,iBAAiB,cACjB,WAAW,eACX,GAAG,cACD;CACJ,MAAM,WAAW,gBAAgB,iBAAiB;CAClD,MAAM,UAAU,2BAA2B,KAAK;CAChD,MAAM,gBAAgB,iBAAiB,KAAK;CAC5C,MAAM,YAAY,iBAAiB,cAAc,UAAU;CAC3D,MAAM,EACJ,SACA,UACA,MACA,gBACA,aACA,sBACA,gBACA,iBACA,gBACA,kBACA,cACA,uBACA,oBACA,YACA,WACE;CACJ,MAAM,aAAa,eAAe,SAAS,KAAK;CAChD,MAAM,6BAA6B,MAAM,OAAO,KAAK;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,GAAG,oBAAoB,MAAM,YAAY,YAAY,UAAU,GAAG,CAAC;CACzE,MAAM,kBAAkB,MAAM,OAC5B,IACF;CACA,MAAM,sBAAsB,MAAM,OAAO;EACvC;EACA;EACA,WAAW;CACb,CAAC;CACD,gCACQ,SAAS,gBA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,OAAO;KAC1B,QAAQ;KACR,OAAO,MAAM,eAAe;KAC5B,SAAS,MAAM;KACf;IACF,CAAC;GACH,CAAC;GACD,SAAS,qBAAqB,UAAU,SAAS,YAAY;EAC/D;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,qBAAqB,qBACzB,MACA,YACA,UACA,QAAQ,QAAQ,QAClB;CACA,OAAuB,oBACrB,2BACA;EACE;EACA;EACA,QAAQ,UAAU;EAClB,WAAW;EACX;EACA,UAAU,wBAAwC,oBAAI,UAAU;GAAE;GAAO;GAAU,UAAU,MAAM;EAAS,CAAC,IAAoB,oBAC/H,iBACA;GACE,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,SAAS,YAAY,WAAW,cAAc,eAAe,cAAc,iBAAiB,IAAI,CAAC,IAAI,CAAC;GACpI,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CACF;CACF,CACF;AACF,GACA,EACE,cAAc,KAChB,CACF"}
1
+ {"version":3,"file":"SelectItem.js","names":[],"sources":["esm/SelectItem.js"],"sourcesContent":["import { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport {\n createChangeEventDetails,\n createStyledHOC,\n createStyledContext,\n styled,\n View\n} from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nimport { jsx } from \"react/jsx-runtime\";\nconst ITEM_NAME = \"SelectItem\";\nconst {\n Provider: SelectItemContextProvider,\n useStyledContext: useSelectItemContext\n} = createStyledContext(null, ITEM_NAME);\nconst SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nconst SelectItem = createStyledHOC(\n SelectItemFrame,\n function SelectItem2(props, forwardedRef) {\n const {\n scope,\n value,\n disabled: disabledProp,\n \"aria-disabled\": ariaDisabled,\n textValue: textValueProp,\n ...restProps\n } = props;\n const disabled = disabledProp ?? ariaDisabled === true;\n const context = useSelectItemParentContext(scope);\n const isAdapted = useAdaptIsActive(context.adaptScope);\n const {\n registry,\n mode,\n selectedValues,\n selectValue,\n activeIndexSubscribe,\n activeIndexRef,\n allowMouseUpRef,\n allowSelectRef,\n selectTimeoutRef,\n getItemProps,\n shouldRenderWebNative,\n setActiveIndex,\n lastPointerRef,\n moveActive,\n search\n } = context;\n const isSelected = selectedValues.includes(value);\n const pendingMouseUpSelectionRef = React.useRef(false);\n const itemNodeRef = React.useRef(null);\n const registrationRef = React.useRef(\n null\n );\n const initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(() => {\n const registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n registration.setNode(itemNodeRef.current);\n return () => {\n registrationRef.current = null;\n registration.unregister();\n };\n }, [registry]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.update({ value, disabled, textValue: textValueProp });\n }, [disabled, textValueProp, value]);\n useIsomorphicLayoutEffect(() => {\n registrationRef.current?.setNode(itemNodeRef.current);\n });\n const [isActive, setIsActive] = React.useState(false);\n const isActiveRef = React.useRef(false);\n React.useEffect(() => {\n const handleActiveIndex = (i) => {\n const next = i != null && registry.getIndex(value) === i;\n if (next !== isActiveRef.current) {\n isActiveRef.current = next;\n setIsActive(next);\n }\n if (next && isWeb) {\n requestAnimationFrame(() => {\n itemNodeRef.current?.focus?.();\n });\n }\n };\n handleActiveIndex(activeIndexRef?.current ?? null);\n return activeIndexSubscribe(handleActiveIndex);\n }, [activeIndexRef, activeIndexSubscribe, registry, value]);\n const textId = React.useId();\n const refCallback = React.useCallback((node) => {\n itemNodeRef.current = node;\n registrationRef.current?.setNode(node);\n }, []);\n const composedRefs = useComposedRefs(forwardedRef, refCallback);\n const handleSelect = React.useCallback(\n (event, reason = \"item-press\") => {\n if (disabled) return;\n const nativeEvent = event?.nativeEvent || event;\n selectValue(\n value,\n createChangeEventDetails(\n reason,\n nativeEvent,\n event?.currentTarget\n )\n );\n },\n [disabled, selectValue, value]\n );\n const handleMouseMove = React.useCallback(\n (event) => {\n if (disabled) return;\n const index = registry.getIndex(value);\n if (index < 0) return;\n const last = lastPointerRef.current;\n if (event.clientX === last.x && event.clientY === last.y) return;\n last.x = event.clientX;\n last.y = event.clientY;\n setActiveIndex(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n [disabled, lastPointerRef, registry, setActiveIndex, value]\n );\n const handleKeyDown = React.useCallback(\n (event) => {\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!getItemProps && event.key?.length === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n },\n [allowSelectRef, disabled, handleSelect, getItemProps, moveActive, search]\n );\n const selectItemProps = React.useMemo(() => {\n if (getItemProps) {\n const {\n onTouchMove,\n onTouchEnd,\n onKeyDown,\n onClick,\n onMouseUp,\n onMouseMove,\n onPress,\n ...itemProps\n } = restProps;\n const interactionProps = getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove: handleMouseMove,\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n const shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(() => {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(\n onTouchMove,\n interactionProps.onTouchMove\n ),\n onTouchEnd: composeEventHandlers(\n onTouchEnd,\n interactionProps.onTouchEnd\n ),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n onClick?.(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n interactionProps.onClick?.(event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(\n onMouseMove,\n interactionProps.onMouseMove\n ),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, handleMouseMove),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleMouseMove,\n handleSelect,\n getItemProps,\n restProps,\n selectTimeoutRef\n ]);\n const accessibilityProps = getSelectOptionProps(\n mode,\n isSelected,\n disabled,\n isWeb ? \"web\" : \"native\"\n );\n return /* @__PURE__ */ jsx(\n SelectItemContextProvider,\n {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ jsx(\"option\", { value, disabled, children: props.children }) : /* @__PURE__ */ jsx(\n SelectItemFrame,\n {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted && (isActive || activeIndexRef?.current == null && isSelected) ? 0 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n }\n )\n }\n );\n },\n {\n disableTheme: true\n }\n);\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,EACJ,UAAU,2BACV,kBAAkB,yBAChB,oBAAoB,MAAM,SAAS;AACvC,MAAM,kBAAkB,OAAO,MAAM;CACnC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,MAAM,aAAa,gBACjB,iBACA,SAAS,YAAY,OAAO,cAAc;CACxC,MAAM,EACJ,OACA,OACA,UAAU,cACV,iBAAiB,cACjB,WAAW,eACX,GAAG,cACD;CACJ,MAAM,WAAW,gBAAgB,iBAAiB;CAClD,MAAM,UAAU,2BAA2B,KAAK;CAChD,MAAM,YAAY,iBAAiB,QAAQ,UAAU;CACrD,MAAM,EACJ,UACA,MACA,gBACA,aACA,sBACA,gBACA,iBACA,gBACA,kBACA,cACA,uBACA,gBACA,gBACA,YACA,WACE;CACJ,MAAM,aAAa,eAAe,SAAS,KAAK;CAChD,MAAM,6BAA6B,MAAM,OAAO,KAAK;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,kBAAkB,MAAM,OAC5B,IACF;CACA,MAAM,sBAAsB,MAAM,OAAO;EACvC;EACA;EACA,WAAW;CACb,CAAC;CACD,gCAAgC;EAC9B,MAAM,eAA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GAAE;GAAO;GAAU,UAAU,MAAM;EAAS,CAAC,IAAoB,oBAC/H,iBACA;GACE,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,SAAS,cAAc,YAAY,gBAAgB,WAAW,QAAQ,cAAc,IAAI,CAAC;GACvH,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CACF;CACF,CACF;AACF,GACA,EACE,cAAc,KAChB,CACF"}
@@ -5,16 +5,9 @@ import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
5
5
  import { View, createChangeEventDetails, createStyledContext, createStyledHOC, styled } from "@tamagui/core";
6
6
  import { composeEventHandlers } from "@tamagui/helpers";
7
7
  import * as React from "react";
8
- import { useSelectContext, useSelectItemParentContext } from "./context.native.js";
8
+ import { useSelectItemParentContext } from "./context.native.js";
9
9
  import { getSelectOptionProps } from "./selectionController.native.js";
10
10
 
11
- function _instanceof(left, right) {
12
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
13
- return !!right[Symbol.hasInstance](left);
14
- } else {
15
- return left instanceof right;
16
- }
17
- }
18
11
  var ITEM_NAME = "SelectItem";
19
12
  var { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = createStyledContext(null, ITEM_NAME);
20
13
  var SelectItemFrame = styled(View, {
@@ -26,44 +19,22 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
26
19
  var { scope, value, disabled: disabledProp, "aria-disabled": ariaDisabled, textValue: textValueProp, ...restProps } = props;
27
20
  var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;
28
21
  var context = useSelectItemParentContext(scope);
29
- var selectContext = useSelectContext(scope);
30
- var isAdapted = useAdaptIsActive(selectContext.adaptScope);
31
- var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;
22
+ var isAdapted = useAdaptIsActive(context.adaptScope);
23
+ var { registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, getItemProps, shouldRenderWebNative, setActiveIndex, lastPointerRef, moveActive, search } = context;
32
24
  var isSelected = selectedValues.includes(value);
33
25
  var pendingMouseUpSelectionRef = React.useRef(false);
34
26
  var itemNodeRef = React.useRef(null);
35
- var [, rerenderRegistry] = React.useReducer(function(version) {
36
- return version + 1;
37
- }, 0);
38
27
  var registrationRef = React.useRef(null);
39
28
  var initialRegistration = React.useRef({
40
29
  value,
41
30
  disabled,
42
31
  textValue: textValueProp
43
32
  });
44
- useIsomorphicLayoutEffect(function() {
45
- return registry.subscribe(function() {
46
- return rerenderRegistry();
47
- });
48
- }, [registry]);
49
33
  useIsomorphicLayoutEffect(function() {
50
34
  var registration = registry.registerItem(initialRegistration.current);
51
35
  registrationRef.current = registration;
52
- var registeredNode = itemNodeRef.current;
53
- registration.setNode(registeredNode);
54
- var registeredIndex = registry.getItems().findIndex(function(item) {
55
- return item.id === registration.id;
56
- });
57
- if (isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {
58
- listRef.current[registeredIndex] = registeredNode;
59
- }
36
+ registration.setNode(itemNodeRef.current);
60
37
  return function() {
61
- var currentIndex = registry.getItems().findIndex(function(item) {
62
- return item.id === registration.id;
63
- });
64
- if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {
65
- listRef.current[currentIndex] = null;
66
- }
67
38
  registrationRef.current = null;
68
39
  registration.unregister();
69
40
  };
@@ -84,39 +55,37 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
84
55
  var _registrationRef_current;
85
56
  (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);
86
57
  });
87
- var index = registry.getIndex(value);
58
+ var [isActive, setIsActive] = React.useState(false);
59
+ var isActiveRef = React.useRef(false);
88
60
  React.useEffect(function() {
89
61
  var handleActiveIndex = function(i) {
90
- if (index === i) {
91
- if (isWeb) {
92
- requestAnimationFrame(function() {
93
- var _listRef_current_index;
94
- listRef === null || listRef === void 0 ? void 0 : (_listRef_current_index = listRef.current[index]) === null || _listRef_current_index === void 0 ? void 0 : _listRef_current_index.focus();
95
- });
96
- }
62
+ var next = i != null && registry.getIndex(value) === i;
63
+ if (next !== isActiveRef.current) {
64
+ isActiveRef.current = next;
65
+ setIsActive(next);
66
+ }
67
+ if (next && isWeb) {
68
+ requestAnimationFrame(function() {
69
+ var _itemNodeRef_current_focus, _itemNodeRef_current;
70
+ (_itemNodeRef_current = itemNodeRef.current) === null || _itemNodeRef_current === void 0 ? void 0 : (_itemNodeRef_current_focus = _itemNodeRef_current.focus) === null || _itemNodeRef_current_focus === void 0 ? void 0 : _itemNodeRef_current_focus.call(_itemNodeRef_current);
71
+ });
97
72
  }
98
73
  };
99
- var currentActiveIndex = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current;
100
- if (currentActiveIndex !== null && currentActiveIndex !== void 0) {
101
- handleActiveIndex(currentActiveIndex);
102
- }
74
+ var _activeIndexRef_current;
75
+ handleActiveIndex((_activeIndexRef_current = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) !== null && _activeIndexRef_current !== void 0 ? _activeIndexRef_current : null);
103
76
  return activeIndexSubscribe(handleActiveIndex);
104
77
  }, [
105
78
  activeIndexRef,
106
79
  activeIndexSubscribe,
107
- index,
108
- listRef
80
+ registry,
81
+ value
109
82
  ]);
110
83
  var textId = React.useId();
111
84
  var refCallback = React.useCallback(function(node) {
112
85
  var _registrationRef_current;
113
86
  itemNodeRef.current = node;
114
87
  (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);
115
- if (!isWeb) return;
116
- if (listRef && index >= 0) {
117
- listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;
118
- }
119
- }, [index, listRef]);
88
+ }, []);
120
89
  var composedRefs = useComposedRefs(forwardedRef, refCallback);
121
90
  var handleSelect = React.useCallback(function(event) {
122
91
  var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "item-press";
@@ -128,6 +97,27 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
128
97
  selectValue,
129
98
  value
130
99
  ]);
100
+ var handleMouseMove = React.useCallback(function(event) {
101
+ if (disabled) return;
102
+ var index = registry.getIndex(value);
103
+ if (index < 0) return;
104
+ var last = lastPointerRef.current;
105
+ if (event.clientX === last.x && event.clientY === last.y) return;
106
+ last.x = event.clientX;
107
+ last.y = event.clientY;
108
+ setActiveIndex(index, {
109
+ reason: "item-hover",
110
+ event: event.nativeEvent || event,
111
+ trigger: event.currentTarget,
112
+ index
113
+ });
114
+ }, [
115
+ disabled,
116
+ lastPointerRef,
117
+ registry,
118
+ setActiveIndex,
119
+ value
120
+ ]);
131
121
  var handleKeyDown = React.useCallback(function(event) {
132
122
  var _event_key;
133
123
  if (disabled) return;
@@ -142,7 +132,7 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
142
132
  moveActive(event.key === "ArrowDown" ? 1 : -1, event.nativeEvent || event);
143
133
  return;
144
134
  }
145
- if (!interactions && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {
135
+ if (!getItemProps && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {
146
136
  search(event.key, event.nativeEvent || event);
147
137
  }
148
138
  if (allowSelectRef) {
@@ -152,14 +142,14 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
152
142
  allowSelectRef,
153
143
  disabled,
154
144
  handleSelect,
155
- interactions,
145
+ getItemProps,
156
146
  moveActive,
157
147
  search
158
148
  ]);
159
149
  var selectItemProps = React.useMemo(function() {
160
- if (interactions) {
150
+ if (getItemProps) {
161
151
  var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;
162
- var interactionProps = interactions.getItemProps({
152
+ var interactionProps = getItemProps({
163
153
  ...itemProps,
164
154
  onTouchMove() {
165
155
  allowSelectRef.current = true;
@@ -169,15 +159,7 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
169
159
  allowSelectRef.current = false;
170
160
  allowMouseUpRef.current = true;
171
161
  },
172
- onMouseMove(event) {
173
- if (disabled || index < 0) return;
174
- setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {
175
- reason: "item-hover",
176
- event: event.nativeEvent || event,
177
- trigger: event.currentTarget,
178
- index
179
- });
180
- },
162
+ onMouseMove: handleMouseMove,
181
163
  onKeyDown: handleKeyDown,
182
164
  onClick(event) {
183
165
  if (disabled) return;
@@ -231,15 +213,7 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
231
213
  return {
232
214
  ...restProps,
233
215
  onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),
234
- onMouseMove: composeEventHandlers(restProps.onMouseMove, function(event) {
235
- if (disabled || index < 0) return;
236
- setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {
237
- reason: "item-hover",
238
- event: event.nativeEvent || event,
239
- trigger: event.currentTarget,
240
- index
241
- });
242
- }),
216
+ onMouseMove: composeEventHandlers(restProps.onMouseMove, handleMouseMove),
243
217
  onPress: composeEventHandlers(restProps.onPress, handleSelect)
244
218
  };
245
219
  }, [
@@ -247,15 +221,13 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
247
221
  allowSelectRef,
248
222
  disabled,
249
223
  handleKeyDown,
224
+ handleMouseMove,
250
225
  handleSelect,
251
- index,
252
- interactions,
226
+ getItemProps,
253
227
  restProps,
254
- selectTimeoutRef,
255
- setActiveIndexFast
228
+ selectTimeoutRef
256
229
  ]);
257
230
  var accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? "web" : "native");
258
- var _selectContext_activeIndex;
259
231
  return /* @__PURE__ */ jsx(SelectItemContextProvider, {
260
232
  scope,
261
233
  value,
@@ -272,7 +244,7 @@ var SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, fo
272
244
  "aria-labelledby": textId,
273
245
  "data-state": isSelected ? "active" : "inactive",
274
246
  "data-disabled": disabled ? "" : void 0,
275
- tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === ((_selectContext_activeIndex = selectContext.activeIndex) !== null && _selectContext_activeIndex !== void 0 ? _selectContext_activeIndex : selectContext.selectedIndex) ? 0 : -1 : -1,
247
+ tabIndex: disabled ? void 0 : isWeb && isAdapted && (isActive || (activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) == null && isSelected) ? 0 : -1,
276
248
  zIndex: 100,
277
249
  ...selectItemProps,
278
250
  ...accessibilityProps
@@ -1 +1 @@
1
- {"version":3,"file":"SelectItem.native.js","names":[],"sources":["esm/SelectItem.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, createStyledHOC, createStyledContext, styled, View } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext, useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nvar ITEM_NAME = \"SelectItem\";\nvar { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = createStyledContext(null, ITEM_NAME);\nvar SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nvar SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, forwardedRef) {\n var { scope, value, disabled: disabledProp, \"aria-disabled\": ariaDisabled, textValue: textValueProp, ...restProps } = props;\n var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;\n var context = useSelectItemParentContext(scope);\n var selectContext = useSelectContext(scope);\n var isAdapted = useAdaptIsActive(selectContext.adaptScope);\n var { listRef, registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, interactions, shouldRenderWebNative, setActiveIndexFast, moveActive, search } = context;\n var isSelected = selectedValues.includes(value);\n var pendingMouseUpSelectionRef = React.useRef(false);\n var itemNodeRef = React.useRef(null);\n var [, rerenderRegistry] = React.useReducer(function(version) {\n return version + 1;\n }, 0);\n var registrationRef = React.useRef(null);\n var initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(function() {\n return registry.subscribe(function() {\n return rerenderRegistry();\n });\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n var registeredNode = itemNodeRef.current;\n registration.setNode(registeredNode);\n var registeredIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (isWeb && listRef && registeredIndex >= 0 && _instanceof(registeredNode, HTMLElement)) {\n listRef.current[registeredIndex] = registeredNode;\n }\n return function() {\n var currentIndex = registry.getItems().findIndex(function(item) {\n return item.id === registration.id;\n });\n if (listRef && currentIndex >= 0 && listRef.current[currentIndex] === registeredNode) {\n listRef.current[currentIndex] = null;\n }\n registrationRef.current = null;\n registration.unregister();\n };\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.update({\n value,\n disabled,\n textValue: textValueProp\n });\n }, [\n disabled,\n textValueProp,\n value\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);\n });\n var index = registry.getIndex(value);\n React.useEffect(function() {\n var handleActiveIndex = function(i) {\n if (index === i) {\n if (isWeb) {\n requestAnimationFrame(function() {\n var _listRef_current_index;\n listRef === null || listRef === void 0 ? void 0 : (_listRef_current_index = listRef.current[index]) === null || _listRef_current_index === void 0 ? void 0 : _listRef_current_index.focus();\n });\n }\n }\n };\n var currentActiveIndex = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current;\n if (currentActiveIndex !== null && currentActiveIndex !== void 0) {\n handleActiveIndex(currentActiveIndex);\n }\n return activeIndexSubscribe(handleActiveIndex);\n }, [\n activeIndexRef,\n activeIndexSubscribe,\n index,\n listRef\n ]);\n var textId = React.useId();\n var refCallback = React.useCallback(function(node) {\n var _registrationRef_current;\n itemNodeRef.current = node;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);\n if (!isWeb) return;\n if (listRef && index >= 0) {\n listRef.current[index] = _instanceof(node, HTMLElement) ? node : null;\n }\n }, [\n index,\n listRef\n ]);\n var composedRefs = useComposedRefs(forwardedRef, refCallback);\n var handleSelect = React.useCallback(function(event) {\n var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"item-press\";\n if (disabled) return;\n var nativeEvent = (event === null || event === void 0 ? void 0 : event.nativeEvent) || event;\n selectValue(value, createChangeEventDetails(reason, nativeEvent, event === null || event === void 0 ? void 0 : event.currentTarget));\n }, [\n disabled,\n selectValue,\n value\n ]);\n var handleKeyDown = React.useCallback(function(event) {\n var _event_key;\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!interactions && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n }, [\n allowSelectRef,\n disabled,\n handleSelect,\n interactions,\n moveActive,\n search\n ]);\n var selectItemProps = React.useMemo(function() {\n if (interactions) {\n var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;\n var interactionProps = interactions.getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n },\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n var shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(function() {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(onTouchMove, interactionProps.onTouchMove),\n onTouchEnd: composeEventHandlers(onTouchEnd, interactionProps.onTouchEnd),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n var _interactionProps_onClick;\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n (_interactionProps_onClick = interactionProps.onClick) === null || _interactionProps_onClick === void 0 ? void 0 : _interactionProps_onClick.call(interactionProps, event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(onMouseMove, interactionProps.onMouseMove),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, function(event) {\n if (disabled || index < 0) return;\n setActiveIndexFast === null || setActiveIndexFast === void 0 ? void 0 : setActiveIndexFast(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleSelect,\n index,\n interactions,\n restProps,\n selectTimeoutRef,\n setActiveIndexFast\n ]);\n var accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? \"web\" : \"native\");\n var _selectContext_activeIndex;\n return /* @__PURE__ */ _jsx(SelectItemContextProvider, {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ _jsx(\"option\", {\n value,\n disabled,\n children: props.children\n }) : /* @__PURE__ */ _jsx(SelectItemFrame, {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted ? index === ((_selectContext_activeIndex = selectContext.activeIndex) !== null && _selectContext_activeIndex !== void 0 ? _selectContext_activeIndex : selectContext.selectedIndex) ? 0 : -1 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n })\n });\n}, {\n disableTheme: true\n});\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMappingURL=SelectItem.js.map\n"],"mappings":";;;;;;;;;;;AASA,SAAS,YAAY,MAAM,OAAO;CAChC,IAAI,SAAS,QAAQ,OAAO,WAAW,eAAe,MAAM,OAAO,cAAc;EAC/E,OAAO,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,IAAI;CACzC,OAAO;EACL,OAAO,gBAAgB;CACzB;AACF;AACA,IAAI,YAAY;AAChB,IAAI,EAAE,UAAU,2BAA2B,kBAAkB,yBAAyB,oBAAoB,MAAM,SAAS;AACzH,IAAI,kBAAkB,OAAO,MAAM;CACjC,aAAa;CACb,YAAY;CACZ,eAAe;AACjB,CAAC;AACD,IAAI,aAAa,gBAAgB,iBAAiB,SAAS,YAAY,OAAO,cAAc;CAC1F,IAAI,EAAE,OAAO,OAAO,UAAU,cAAc,iBAAiB,cAAc,WAAW,eAAe,GAAG,cAAc;CACtH,IAAI,WAAW,iBAAiB,QAAQ,iBAAiB,KAAK,IAAI,eAAe,iBAAiB;CAClG,IAAI,UAAU,2BAA2B,KAAK;CAC9C,IAAI,gBAAgB,iBAAiB,KAAK;CAC1C,IAAI,YAAY,iBAAiB,cAAc,UAAU;CACzD,IAAI,EAAE,SAAS,UAAU,MAAM,gBAAgB,aAAa,sBAAsB,gBAAgB,iBAAiB,gBAAgB,kBAAkB,cAAc,uBAAuB,oBAAoB,YAAY,WAAW;CACrO,IAAI,aAAa,eAAe,SAAS,KAAK;CAC9C,IAA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QAAQ,uBAAuB,KAAK,IAAI,KAAK,IAAI,mBAAmB,OAAO;KAChG,QAAQ;KACR,OAAO,MAAM,eAAe;KAC5B,SAAS,MAAM;KACf;IACF,CAAC;GACH,CAAC;GACD,SAAS,qBAAqB,UAAU,SAAS,YAAY;EAC/D;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,IAAI,qBAAqB,qBAAqB,MAAM,YAAY,UAAU,QAAQ,QAAQ,QAAQ;CAClG,IAAI;CACJ,OAAuB,oBAAK,2BAA2B;EACrD;EACA;EACA,QAAQ,UAAU;EAClB,WAAW;EACX;EACA,UAAU,wBAAwC,oBAAK,UAAU;GAC/D;GACA;GACA,UAAU,MAAM;EAClB,CAAC,IAAoB,oBAAK,iBAAiB;GACzC,QAAQ;GACR,KAAK;GACL,mBAAmB;GACnB,cAAc,aAAa,WAAW;GACtC,iBAAiB,WAAW,KAAK,KAAK;GACtC,UAAU,WAAW,KAAK,IAAI,SAAS,YAAY,YAAY,6BAA6B,cAAc,iBAAiB,QAAQ,+BAA+B,KAAK,IAAI,6BAA6B,cAAc,iBAAiB,IAAI,CAAC,IAAI,CAAC;GACjP,QAAQ;GACR,GAAG;GACH,GAAG;EACL,CAAC;CACH,CAAC;AACH,GAAG,EACD,cAAc,KAChB,CAAC"}
1
+ {"version":3,"file":"SelectItem.native.js","names":[],"sources":["esm/SelectItem.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { useAdaptIsActive } from \"@tamagui/adapt\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, createStyledHOC, createStyledContext, styled, View } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectItemParentContext } from \"./context\";\nimport { getSelectOptionProps } from \"./selectionController\";\nvar ITEM_NAME = \"SelectItem\";\nvar { Provider: SelectItemContextProvider, useStyledContext: useSelectItemContext } = createStyledContext(null, ITEM_NAME);\nvar SelectItemFrame = styled(View, {\n displayName: ITEM_NAME,\n alignItems: \"center\",\n flexDirection: \"row\"\n});\nvar SelectItem = createStyledHOC(SelectItemFrame, function SelectItem2(props, forwardedRef) {\n var { scope, value, disabled: disabledProp, \"aria-disabled\": ariaDisabled, textValue: textValueProp, ...restProps } = props;\n var disabled = disabledProp !== null && disabledProp !== void 0 ? disabledProp : ariaDisabled === true;\n var context = useSelectItemParentContext(scope);\n var isAdapted = useAdaptIsActive(context.adaptScope);\n var { registry, mode, selectedValues, selectValue, activeIndexSubscribe, activeIndexRef, allowMouseUpRef, allowSelectRef, selectTimeoutRef, getItemProps, shouldRenderWebNative, setActiveIndex, lastPointerRef, moveActive, search } = context;\n var isSelected = selectedValues.includes(value);\n var pendingMouseUpSelectionRef = React.useRef(false);\n var itemNodeRef = React.useRef(null);\n var registrationRef = React.useRef(null);\n var initialRegistration = React.useRef({\n value,\n disabled,\n textValue: textValueProp\n });\n useIsomorphicLayoutEffect(function() {\n var registration = registry.registerItem(initialRegistration.current);\n registrationRef.current = registration;\n registration.setNode(itemNodeRef.current);\n return function() {\n registrationRef.current = null;\n registration.unregister();\n };\n }, [\n registry\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.update({\n value,\n disabled,\n textValue: textValueProp\n });\n }, [\n disabled,\n textValueProp,\n value\n ]);\n useIsomorphicLayoutEffect(function() {\n var _registrationRef_current;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(itemNodeRef.current);\n });\n var [isActive, setIsActive] = React.useState(false);\n var isActiveRef = React.useRef(false);\n React.useEffect(function() {\n var handleActiveIndex = function(i) {\n var next = i != null && registry.getIndex(value) === i;\n if (next !== isActiveRef.current) {\n isActiveRef.current = next;\n setIsActive(next);\n }\n if (next && isWeb) {\n requestAnimationFrame(function() {\n var _itemNodeRef_current_focus, _itemNodeRef_current;\n (_itemNodeRef_current = itemNodeRef.current) === null || _itemNodeRef_current === void 0 ? void 0 : (_itemNodeRef_current_focus = _itemNodeRef_current.focus) === null || _itemNodeRef_current_focus === void 0 ? void 0 : _itemNodeRef_current_focus.call(_itemNodeRef_current);\n });\n }\n };\n var _activeIndexRef_current;\n handleActiveIndex((_activeIndexRef_current = activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) !== null && _activeIndexRef_current !== void 0 ? _activeIndexRef_current : null);\n return activeIndexSubscribe(handleActiveIndex);\n }, [\n activeIndexRef,\n activeIndexSubscribe,\n registry,\n value\n ]);\n var textId = React.useId();\n var refCallback = React.useCallback(function(node) {\n var _registrationRef_current;\n itemNodeRef.current = node;\n (_registrationRef_current = registrationRef.current) === null || _registrationRef_current === void 0 ? void 0 : _registrationRef_current.setNode(node);\n }, []);\n var composedRefs = useComposedRefs(forwardedRef, refCallback);\n var handleSelect = React.useCallback(function(event) {\n var reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : \"item-press\";\n if (disabled) return;\n var nativeEvent = (event === null || event === void 0 ? void 0 : event.nativeEvent) || event;\n selectValue(value, createChangeEventDetails(reason, nativeEvent, event === null || event === void 0 ? void 0 : event.currentTarget));\n }, [\n disabled,\n selectValue,\n value\n ]);\n var handleMouseMove = React.useCallback(function(event) {\n if (disabled) return;\n var index = registry.getIndex(value);\n if (index < 0) return;\n var last = lastPointerRef.current;\n if (event.clientX === last.x && event.clientY === last.y) return;\n last.x = event.clientX;\n last.y = event.clientY;\n setActiveIndex(index, {\n reason: \"item-hover\",\n event: event.nativeEvent || event,\n trigger: event.currentTarget,\n index\n });\n }, [\n disabled,\n lastPointerRef,\n registry,\n setActiveIndex,\n value\n ]);\n var handleKeyDown = React.useCallback(function(event) {\n var _event_key;\n if (disabled) return;\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n handleSelect(event, \"keyboard\");\n return;\n }\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n event.stopPropagation();\n moveActive(event.key === \"ArrowDown\" ? 1 : -1, event.nativeEvent || event);\n return;\n }\n if (!getItemProps && ((_event_key = event.key) === null || _event_key === void 0 ? void 0 : _event_key.length) === 1 && !event.metaKey && !event.ctrlKey) {\n search(event.key, event.nativeEvent || event);\n }\n if (allowSelectRef) {\n allowSelectRef.current = true;\n }\n }, [\n allowSelectRef,\n disabled,\n handleSelect,\n getItemProps,\n moveActive,\n search\n ]);\n var selectItemProps = React.useMemo(function() {\n if (getItemProps) {\n var { onTouchMove, onTouchEnd, onKeyDown, onClick, onMouseUp, onMouseMove, onPress, ...itemProps } = restProps;\n var interactionProps = getItemProps({\n ...itemProps,\n onTouchMove() {\n allowSelectRef.current = true;\n allowMouseUpRef.current = false;\n },\n onTouchEnd() {\n allowSelectRef.current = false;\n allowMouseUpRef.current = true;\n },\n onMouseMove: handleMouseMove,\n onKeyDown: handleKeyDown,\n onClick(event) {\n if (disabled) return;\n var shouldSelect = pendingMouseUpSelectionRef.current || allowSelectRef.current;\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n if (shouldSelect) {\n handleSelect(event);\n }\n },\n onMouseUp(event) {\n if (disabled) return;\n if (!allowMouseUpRef.current) {\n allowMouseUpRef.current = true;\n allowSelectRef.current = true;\n return;\n }\n pendingMouseUpSelectionRef.current = allowSelectRef.current;\n clearTimeout(selectTimeoutRef.current);\n selectTimeoutRef.current = setTimeout(function() {\n allowSelectRef.current = true;\n if (pendingMouseUpSelectionRef.current) {\n pendingMouseUpSelectionRef.current = false;\n handleSelect(event);\n }\n });\n }\n });\n return {\n ...interactionProps,\n onTouchMove: composeEventHandlers(onTouchMove, interactionProps.onTouchMove),\n onTouchEnd: composeEventHandlers(onTouchEnd, interactionProps.onTouchEnd),\n onKeyDown: composeEventHandlers(onKeyDown, interactionProps.onKeyDown),\n onClick(event) {\n var _interactionProps_onClick;\n onClick === null || onClick === void 0 ? void 0 : onClick(event);\n if (event.defaultPrevented) {\n pendingMouseUpSelectionRef.current = false;\n clearTimeout(selectTimeoutRef.current);\n allowSelectRef.current = true;\n return;\n }\n (_interactionProps_onClick = interactionProps.onClick) === null || _interactionProps_onClick === void 0 ? void 0 : _interactionProps_onClick.call(interactionProps, event);\n },\n onMouseUp: composeEventHandlers(onMouseUp, interactionProps.onMouseUp),\n onMouseMove: composeEventHandlers(onMouseMove, interactionProps.onMouseMove),\n onPress\n };\n }\n return {\n ...restProps,\n onKeyDown: composeEventHandlers(restProps.onKeyDown, handleKeyDown),\n onMouseMove: composeEventHandlers(restProps.onMouseMove, handleMouseMove),\n onPress: composeEventHandlers(restProps.onPress, handleSelect)\n };\n }, [\n allowMouseUpRef,\n allowSelectRef,\n disabled,\n handleKeyDown,\n handleMouseMove,\n handleSelect,\n getItemProps,\n restProps,\n selectTimeoutRef\n ]);\n var accessibilityProps = getSelectOptionProps(mode, isSelected, disabled, isWeb ? \"web\" : \"native\");\n return /* @__PURE__ */ _jsx(SelectItemContextProvider, {\n scope,\n value,\n textId: textId || \"\",\n textValue: textValueProp,\n isSelected,\n children: shouldRenderWebNative ? /* @__PURE__ */ _jsx(\"option\", {\n value,\n disabled,\n children: props.children\n }) : /* @__PURE__ */ _jsx(SelectItemFrame, {\n render: \"div\",\n ref: composedRefs,\n \"aria-labelledby\": textId,\n \"data-state\": isSelected ? \"active\" : \"inactive\",\n \"data-disabled\": disabled ? \"\" : void 0,\n tabIndex: disabled ? void 0 : isWeb && isAdapted && (isActive || (activeIndexRef === null || activeIndexRef === void 0 ? void 0 : activeIndexRef.current) == null && isSelected) ? 0 : -1,\n zIndex: 100,\n ...selectItemProps,\n ...accessibilityProps\n })\n });\n}, {\n disableTheme: true\n});\nexport {\n SelectItem,\n SelectItemContextProvider,\n SelectItemFrame,\n useSelectItemContext\n};\n//# sourceMapp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