@tamagui/select 3.0.0 → 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.
@@ -40,7 +40,7 @@ const SelectInlineImpl = (props) => {
40
40
  const selectContext = (0, import_context.useSelectContext)(scope);
41
41
  const selectItemParentContext = (0, import_context.useSelectItemParentContext)(scope);
42
42
  const { setActiveIndex, selectedIndex, activeIndexRef } = selectContext;
43
- const { requestOpenChange, registry } = selectItemParentContext;
43
+ const { requestOpenChange, registry, lastPointerRef } = selectItemParentContext;
44
44
  const touch = (0, import_core.useIsTouchDevice)();
45
45
  const listItemsRef = selectItemParentContext.listRef;
46
46
  const overflowRef = React.useRef(null);
@@ -56,7 +56,6 @@ const SelectInlineImpl = (props) => {
56
56
  });
57
57
  const [controlledScrolling, setControlledScrolling] = React.useState(false);
58
58
  const [fallback, setFallback] = React.useState(false);
59
- const [innerOffset, setInnerOffset] = React.useState(0);
60
59
  const [blockSelection, setBlockSelection] = React.useState(false);
61
60
  React.useEffect(() => {
62
61
  if (!open) {
@@ -79,7 +78,6 @@ const SelectInlineImpl = (props) => {
79
78
  const { x, y, strategy, refs, update, placement: computedPlacement } = (0, import_floating.useFloatingRaw)({
80
79
  open,
81
80
  placement: "bottom-start",
82
- whileElementsMounted: import_floating.autoUpdate,
83
81
  middleware: [
84
82
  (0, import_floating.size)({ apply({ rects, elements }) {
85
83
  elements.floating.style.minWidth = `${rects.reference.width + 8}px`;
@@ -88,9 +86,10 @@ const SelectInlineImpl = (props) => {
88
86
  listRef: listItemsRef,
89
87
  overflowRef,
90
88
  index: selectedIndex,
91
- offset: innerOffset,
92
89
  onFallbackChange: setFallback,
93
- padding: 10,
90
+ get padding() {
91
+ return 10 + Math.max(upArrowRef.current?.offsetHeight ?? 0, downArrowRef.current?.offsetHeight ?? 0);
92
+ },
94
93
  minItemsVisible: touch ? 10 : 4,
95
94
  referenceOverflowThreshold: 20
96
95
  }),
@@ -107,9 +106,11 @@ const SelectInlineImpl = (props) => {
107
106
  }, [refs]);
108
107
  const showUpArrow = open && canScrollUp;
109
108
  const showDownArrow = open && canScrollDown;
110
- const isScrollable = showDownArrow || showUpArrow;
111
109
  (0, import_constants.useIsomorphicLayoutEffect)(() => {
112
- if (open) update();
110
+ if (!open) return;
111
+ update();
112
+ window.addEventListener("resize", update);
113
+ return () => window.removeEventListener("resize", update);
113
114
  }, [update, open]);
114
115
  const onMatch = (0, import_core.useEvent)((index) => {
115
116
  if (!open) return;
@@ -154,12 +155,6 @@ const SelectInlineImpl = (props) => {
154
155
  keyboardHandlers: false
155
156
  }),
156
157
  (0, import_floating.useRole)(interactionContext, { role: "listbox" }),
157
- (0, import_floating.useInnerOffset)(interactionContext, {
158
- enabled: !fallback && isScrollable,
159
- onChange: setInnerOffset,
160
- overflowRef,
161
- scrollRef: refs.floating
162
- }),
163
158
  (0, import_floating.useListNavigation)(interactionContext, {
164
159
  listRef: listItemsRef,
165
160
  activeIndex: null,
@@ -194,6 +189,11 @@ const SelectInlineImpl = (props) => {
194
189
  getReferenceProps(props2 = {}) {
195
190
  return interactions.getReferenceProps({
196
191
  ...props2,
192
+ onMouseDown: (0, import_helpers.composeEventHandlers)(props2.onMouseDown, (event) => {
193
+ const last = lastPointerRef.current;
194
+ last.x = event.clientX;
195
+ last.y = event.clientY;
196
+ }),
197
197
  onKeyDown: (0, import_helpers.composeEventHandlers)(props2.onKeyDown, (event) => {
198
198
  latestKeyboardEventRef.current = event.nativeEvent || event;
199
199
  if (event.key === "Enter" || event.code === "Space" || event.key === " " && !state.current.isTyping) {
@@ -257,7 +257,6 @@ const SelectInlineImpl = (props) => {
257
257
  }
258
258
  allowSelectRef.current = false;
259
259
  allowMouseUpRef.current = true;
260
- setInnerOffset(0);
261
260
  setFallback(false);
262
261
  setBlockSelection(false);
263
262
  }, [open]);
@@ -298,7 +297,6 @@ const SelectInlineImpl = (props) => {
298
297
  scope,
299
298
  ...selectContext,
300
299
  updateScrollArrows,
301
- setInnerOffset,
302
300
  fallback,
303
301
  floatingContext,
304
302
  interactions: interactionsContext,
@@ -36,7 +36,6 @@ var import_floating = require("@tamagui/floating");
36
36
  var import_compose_refs = require("@tamagui/compose-refs");
37
37
  var import_helpers = require("@tamagui/helpers");
38
38
  var React = __toESM(require("react"), 1);
39
- var import_react_dom = require("react-dom");
40
39
  var import_context = require("./context.cjs");
41
40
  var import_jsx_runtime = require("react/jsx-runtime");
42
41
  const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
@@ -63,53 +62,39 @@ SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
63
62
  const SelectScrollButtonImpl = React.memo((0, import_core.createStyledHOC)(SelectScrollButtonFrame, (props, forwardedRef) => {
64
63
  const { scope, dir, partClassName, ...scrollIndicatorProps } = props;
65
64
  const { className, onPointerEnter, onPointerLeave, ...frameProps } = scrollIndicatorProps;
66
- const { open, fallback, updateScrollArrows, setInnerOffset, ...context } = (0, import_context.useSelectContext)(scope);
65
+ const { open, ...context } = (0, import_context.useSelectContext)(scope);
67
66
  const floatingRef = context.floatingContext?.refs.floating;
68
- const statusRef = React.useRef("idle");
69
67
  const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
70
68
  const frameRef = React.useRef(null);
69
+ const arrowRef = dir === "up" ? context.upArrowRef : context.downArrowRef;
71
70
  const { x, y, refs, strategy } = (0, import_floating.useFloatingRaw)({
72
71
  open: open && isVisible,
73
72
  strategy: "fixed",
74
73
  elements: { reference: floatingRef?.current },
75
74
  placement: dir === "up" ? "top" : "bottom",
76
- middleware: [(0, import_floating.offset)(({ rects }) => -rects.floating.height)],
77
- whileElementsMounted: (...args) => (0, import_floating.autoUpdate)(...args, { animationFrame: true })
75
+ whileElementsMounted: import_floating.autoUpdate
78
76
  });
79
77
  const setFloatingRef = React.useCallback((node) => {
80
78
  refs.setFloating(node);
81
- }, [refs.setFloating]);
79
+ if (arrowRef) arrowRef.current = node;
80
+ }, [refs.setFloating, arrowRef]);
82
81
  const composedRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, setFloatingRef);
83
82
  React.useEffect(() => {
84
83
  return () => cancelAnimationFrame(frameRef.current);
85
- }, []);
86
- if (!isVisible) {
87
- return null;
88
- }
89
- const onScroll = (amount) => {
90
- const floating = floatingRef;
91
- if (!floating) return;
92
- if (fallback) {
93
- if (floating.current) {
94
- floating.current.scrollTop -= amount;
95
- updateScrollArrows();
96
- }
97
- } else {
98
- (0, import_react_dom.flushSync)(() => setInnerOffset((value) => value - amount));
99
- }
100
- };
84
+ }, [isVisible]);
101
85
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectScrollButtonFrame, {
102
86
  ref: composedRef,
103
87
  className: `${partClassName} ${className || ""}`.trim(),
104
88
  "aria-hidden": true,
105
89
  ...frameProps,
90
+ visibility: isVisible ? "visible" : "hidden",
91
+ pointerEvents: isVisible ? "auto" : "none",
106
92
  zIndex: 1e3,
107
93
  position: strategy,
108
94
  left: x || 0,
109
95
  top: y || 0,
110
96
  width: `calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`,
111
97
  onPointerEnter: (0, import_helpers.composeEventHandlers)(onPointerEnter, () => {
112
- statusRef.current = "active";
113
98
  let prevNow = Date.now();
114
99
  function frame() {
115
100
  const element = floatingRef?.current;
@@ -120,7 +105,7 @@ const SelectScrollButtonImpl = React.memo((0, import_core.createStyledHOC)(Selec
120
105
  const pixelsToScroll = msElapsed / 2;
121
106
  const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
122
107
  const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
123
- onScroll(dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels));
108
+ element.scrollTop += dir === "up" ? -Math.min(pixelsToScroll, remainingPixels) : Math.min(pixelsToScroll, remainingPixels);
124
109
  if (scrollRemaining) {
125
110
  frameRef.current = requestAnimationFrame(frame);
126
111
  }
@@ -130,7 +115,6 @@ const SelectScrollButtonImpl = React.memo((0, import_core.createStyledHOC)(Selec
130
115
  frameRef.current = requestAnimationFrame(frame);
131
116
  }),
132
117
  onPointerLeave: (0, import_helpers.composeEventHandlers)(onPointerLeave, () => {
133
- statusRef.current = "idle";
134
118
  cancelAnimationFrame(frameRef.current);
135
119
  })
136
120
  });
@@ -47,6 +47,10 @@ const SelectViewportFrame = (0, import_core.styled)(import_core.View, {
47
47
  position: "relative"
48
48
  });
49
49
  const needsRepropagation = (0, import_portal.needsPortalRepropagation)();
50
+ const getSheetFrameProps = (props) => {
51
+ const { className, style, "data-tamagui-hoc-class": _hocClassNames, ...rest } = props;
52
+ return (0, import_core.splitStyleProps)(rest)[1];
53
+ };
50
54
  const SelectViewport = (0, import_core.createStyledHOC)(SelectViewportFrame, function SelectViewport2(props, forwardedRef) {
51
55
  const { scope, children, disableScroll, ...viewportProps } = props;
52
56
  const context = (0, import_context.useSelectContext)(scope);
@@ -89,8 +93,9 @@ const SelectViewport = (0, import_core.createStyledHOC)(SelectViewportFrame, fun
89
93
  });
90
94
  }
91
95
  if (isAdapted || !import_constants.isWeb) {
96
+ const frameProps = isAdapted ? getSheetFrameProps(viewportProps) : viewportProps;
92
97
  let content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectViewportFrame, {
93
- ...viewportProps,
98
+ ...frameProps,
94
99
  ...import_constants.isWeb ? (0, import_selectionController.getSelectListboxProps)(itemContext.mode) : {},
95
100
  "data-select-viewport": "",
96
101
  ref: composedRefs,
@@ -139,7 +144,7 @@ const selectViewportCSS = `
139
144
  [data-select-viewport] {
140
145
  scrollbar-width: none;
141
146
  -webkit-overflow-scrolling: touch;
142
- overscroll-behavior: contain;
147
+ overscroll-behavior: none;
143
148
  }
144
149
 
145
150
  [data-select-viewport]::-webkit-scrollbar{
@@ -1,4 +1,4 @@
1
- import { autoUpdate, inner, offset, size, useClick, useFloatingRaw, useInnerOffset, useInteractions, useListNavigation, useRole, useTypeahead } from "@tamagui/floating";
1
+ import { inner, offset, size, useClick, useFloatingRaw, useInteractions, useListNavigation, useRole, useTypeahead } from "@tamagui/floating";
2
2
  import { useIsomorphicLayoutEffect } from "@tamagui/constants";
3
3
  import { createChangeEventDetails, useEvent, useIsTouchDevice } from "@tamagui/core";
4
4
  import { composeEventHandlers } from "@tamagui/helpers";
@@ -12,7 +12,7 @@ const SelectInlineImpl = (props) => {
12
12
  const selectContext = useSelectContext(scope);
13
13
  const selectItemParentContext = useSelectItemParentContext(scope);
14
14
  const { setActiveIndex, selectedIndex, activeIndexRef } = selectContext;
15
- const { requestOpenChange, registry } = selectItemParentContext;
15
+ const { requestOpenChange, registry, lastPointerRef } = selectItemParentContext;
16
16
  const touch = useIsTouchDevice();
17
17
  const listItemsRef = selectItemParentContext.listRef;
18
18
  const overflowRef = React.useRef(null);
@@ -28,7 +28,6 @@ const SelectInlineImpl = (props) => {
28
28
  });
29
29
  const [controlledScrolling, setControlledScrolling] = React.useState(false);
30
30
  const [fallback, setFallback] = React.useState(false);
31
- const [innerOffset, setInnerOffset] = React.useState(0);
32
31
  const [blockSelection, setBlockSelection] = React.useState(false);
33
32
  React.useEffect(() => {
34
33
  if (!open) {
@@ -51,7 +50,6 @@ const SelectInlineImpl = (props) => {
51
50
  const { x, y, strategy, refs, update, placement: computedPlacement } = useFloatingRaw({
52
51
  open,
53
52
  placement: "bottom-start",
54
- whileElementsMounted: autoUpdate,
55
53
  middleware: [
56
54
  size({ apply({ rects, elements }) {
57
55
  elements.floating.style.minWidth = `${rects.reference.width + 8}px`;
@@ -60,9 +58,10 @@ const SelectInlineImpl = (props) => {
60
58
  listRef: listItemsRef,
61
59
  overflowRef,
62
60
  index: selectedIndex,
63
- offset: innerOffset,
64
61
  onFallbackChange: setFallback,
65
- padding: 10,
62
+ get padding() {
63
+ return 10 + Math.max(upArrowRef.current?.offsetHeight ?? 0, downArrowRef.current?.offsetHeight ?? 0);
64
+ },
66
65
  minItemsVisible: touch ? 10 : 4,
67
66
  referenceOverflowThreshold: 20
68
67
  }),
@@ -79,9 +78,11 @@ const SelectInlineImpl = (props) => {
79
78
  }, [refs]);
80
79
  const showUpArrow = open && canScrollUp;
81
80
  const showDownArrow = open && canScrollDown;
82
- const isScrollable = showDownArrow || showUpArrow;
83
81
  useIsomorphicLayoutEffect(() => {
84
- if (open) update();
82
+ if (!open) return;
83
+ update();
84
+ window.addEventListener("resize", update);
85
+ return () => window.removeEventListener("resize", update);
85
86
  }, [update, open]);
86
87
  const onMatch = useEvent((index) => {
87
88
  if (!open) return;
@@ -126,12 +127,6 @@ const SelectInlineImpl = (props) => {
126
127
  keyboardHandlers: false
127
128
  }),
128
129
  useRole(interactionContext, { role: "listbox" }),
129
- useInnerOffset(interactionContext, {
130
- enabled: !fallback && isScrollable,
131
- onChange: setInnerOffset,
132
- overflowRef,
133
- scrollRef: refs.floating
134
- }),
135
130
  useListNavigation(interactionContext, {
136
131
  listRef: listItemsRef,
137
132
  activeIndex: null,
@@ -166,6 +161,11 @@ const SelectInlineImpl = (props) => {
166
161
  getReferenceProps(props2 = {}) {
167
162
  return interactions.getReferenceProps({
168
163
  ...props2,
164
+ onMouseDown: composeEventHandlers(props2.onMouseDown, (event) => {
165
+ const last = lastPointerRef.current;
166
+ last.x = event.clientX;
167
+ last.y = event.clientY;
168
+ }),
169
169
  onKeyDown: composeEventHandlers(props2.onKeyDown, (event) => {
170
170
  latestKeyboardEventRef.current = event.nativeEvent || event;
171
171
  if (event.key === "Enter" || event.code === "Space" || event.key === " " && !state.current.isTyping) {
@@ -229,7 +229,6 @@ const SelectInlineImpl = (props) => {
229
229
  }
230
230
  allowSelectRef.current = false;
231
231
  allowMouseUpRef.current = true;
232
- setInnerOffset(0);
233
232
  setFallback(false);
234
233
  setBlockSelection(false);
235
234
  }, [open]);
@@ -270,7 +269,6 @@ const SelectInlineImpl = (props) => {
270
269
  scope,
271
270
  ...selectContext,
272
271
  updateScrollArrows,
273
- setInnerOffset,
274
272
  fallback,
275
273
  floatingContext,
276
274
  interactions: interactionsContext,
@@ -1 +1 @@
1
- {"version":3,"file":"SelectImpl.js","names":[],"sources":["esm/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 { 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 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\tReact.useEffect(() => {\n\t\tif (!open) {\n\t\t\tsetCanScrollUp(false);\n\t\t\tsetCanScrollDown(false);\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, elements }) {\n\t\t\t\telements.floating.style.minWidth = `${rects.reference.width + 8}px`;\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: -4 })\n\t\t]\n\t});\n\tconst [canScrollUp, setCanScrollUp] = React.useState(false);\n\tconst [canScrollDown, setCanScrollDown] = React.useState(false);\n\tconst updateScrollArrows = React.useCallback(() => {\n\t\tconst el = refs.floating.current;\n\t\tif (!el) return;\n\t\tsetCanScrollUp(el.scrollTop > SCROLL_ARROW_THRESHOLD);\n\t\tsetCanScrollDown(el.scrollTop < el.scrollHeight - el.clientHeight - SCROLL_ARROW_THRESHOLD);\n\t}, [refs]);\n\tconst showUpArrow = open && canScrollUp;\n\tconst showDownArrow = open && canScrollDown;\n\tconst isScrollable = showDownArrow || showUpArrow;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (open) 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 onOpenChange = useEvent((nextOpen, event, reason) => {\n\t\trequestOpenChange(nextOpen, createChangeEventDetails(reason === \"list-navigation\" ? \"keyboard\" : \"trigger-press\", event, refs.reference.current));\n\t});\n\tconst referenceElement = refs.reference.current || null;\n\tconst floatingElement = refs.floating.current || null;\n\tconst interactionContext = React.useMemo(() => ({\n\t\topen,\n\t\tonOpenChange,\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: referenceElement,\n\t\t\tfloating: floatingElement,\n\t\t\tdomReference: referenceElement\n\t\t},\n\t\tdataRef\n\t}), [\n\t\topen,\n\t\tonOpenChange,\n\t\trefs,\n\t\treferenceElement,\n\t\tfloatingElement\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: null,\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\tfocusItemOnHover: 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: null,\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\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\t...props2,\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: updateScrollArrows\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t}, [\n\t\trefs,\n\t\tinteractions,\n\t\trequestOpenChange,\n\t\tupdateScrollArrows\n\t]);\n\tconst floatingPosition = React.useMemo(() => ({\n\t\tposition: strategy,\n\t\ttop: y ?? \"\",\n\t\tleft: x ?? \"\"\n\t}), [\n\t\tstrategy,\n\t\tx,\n\t\ty\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\tupdateScrollArrows();\n\t\t};\n\t\tscrollActiveIntoView(activeIndexRef.current);\n\t\treturn selectItemParentContext.activeIndexSubscribe(scrollActiveIntoView);\n\t}, [\n\t\topen,\n\t\tcontrolledScrolling,\n\t\tselectItemParentContext.activeIndexSubscribe,\n\t\tupdateScrollArrows\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\tupdateScrollArrows,\n\t\tsetInnerOffset,\n\t\tfallback,\n\t\tfloatingContext,\n\t\tinteractions: interactionsContext,\n\t\tfloatingPosition,\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\tgetItemProps: interactions.getItemProps,\n\t\t\tlistRef: listItemsRef,\n\t\t\tselectTimeoutRef,\n\t\t\tchildren\n\t\t})\n\t});\n};\n\nexport { SelectInlineImpl };"],"mappings":";;;;;;;;;;AASA,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,QAAQ,iBAAiB;CAC/B,MAAM,eAAe,wBAAwB;CAC7C,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,aAAa,MAAM,OAAO,IAAI;CACpC,MAAM,eAAe,MAAM,OAAO,IAAI;CACtC,MAAM,iBAAiB,MAAM,OAAO,KAAK;CACzC,MAAM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AM,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,cAAc;EACd;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,aAAa;GAC3B,SAAS;GACT;GACA;EACD,CAAC;CACF,CAAC;AACF"}
1
+ {"version":3,"file":"SelectImpl.js","names":[],"sources":["esm/SelectImpl.js"],"sourcesContent":["import { inner, offset, size, useClick, useFloatingRaw, 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 { 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, lastPointerRef } = selectItemParentContext;\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 [blockSelection, setBlockSelection] = React.useState(false);\n\tReact.useEffect(() => {\n\t\tif (!open) {\n\t\t\tsetCanScrollUp(false);\n\t\t\tsetCanScrollDown(false);\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\tmiddleware: [\n\t\t\tsize({ apply({ rects, elements }) {\n\t\t\t\telements.floating.style.minWidth = `${rects.reference.width + 8}px`;\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\tonFallbackChange: setFallback,\n\t\t\t\tget padding() {\n\t\t\t\t\treturn 10 + Math.max(upArrowRef.current?.offsetHeight ?? 0, downArrowRef.current?.offsetHeight ?? 0);\n\t\t\t\t},\n\t\t\t\tminItemsVisible: touch ? 10 : 4,\n\t\t\t\treferenceOverflowThreshold: 20\n\t\t\t}),\n\t\t\toffset({ crossAxis: -4 })\n\t\t]\n\t});\n\tconst [canScrollUp, setCanScrollUp] = React.useState(false);\n\tconst [canScrollDown, setCanScrollDown] = React.useState(false);\n\tconst updateScrollArrows = React.useCallback(() => {\n\t\tconst el = refs.floating.current;\n\t\tif (!el) return;\n\t\tsetCanScrollUp(el.scrollTop > SCROLL_ARROW_THRESHOLD);\n\t\tsetCanScrollDown(el.scrollTop < el.scrollHeight - el.clientHeight - SCROLL_ARROW_THRESHOLD);\n\t}, [refs]);\n\tconst showUpArrow = open && canScrollUp;\n\tconst showDownArrow = open && canScrollDown;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!open) return;\n\t\tupdate();\n\t\twindow.addEventListener(\"resize\", 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 onOpenChange = useEvent((nextOpen, event, reason) => {\n\t\trequestOpenChange(nextOpen, createChangeEventDetails(reason === \"list-navigation\" ? \"keyboard\" : \"trigger-press\", event, refs.reference.current));\n\t});\n\tconst referenceElement = refs.reference.current || null;\n\tconst floatingElement = refs.floating.current || null;\n\tconst interactionContext = React.useMemo(() => ({\n\t\topen,\n\t\tonOpenChange,\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: referenceElement,\n\t\t\tfloating: floatingElement,\n\t\t\tdomReference: referenceElement\n\t\t},\n\t\tdataRef\n\t}), [\n\t\topen,\n\t\tonOpenChange,\n\t\trefs,\n\t\treferenceElement,\n\t\tfloatingElement\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\tuseListNavigation(interactionContext, {\n\t\t\tlistRef: listItemsRef,\n\t\t\tactiveIndex: null,\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\tfocusItemOnHover: 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: null,\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\tgetReferenceProps(props2 = {}) {\n\t\t\t\treturn interactions.getReferenceProps({\n\t\t\t\t\t...props2,\n\t\t\t\t\tonMouseDown: composeEventHandlers(props2.onMouseDown, (event) => {\n\t\t\t\t\t\tconst last = lastPointerRef.current;\n\t\t\t\t\t\tlast.x = event.clientX;\n\t\t\t\t\t\tlast.y = event.clientY;\n\t\t\t\t\t}),\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\t...props2,\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: updateScrollArrows\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t}, [\n\t\trefs,\n\t\tinteractions,\n\t\trequestOpenChange,\n\t\tupdateScrollArrows\n\t]);\n\tconst floatingPosition = React.useMemo(() => ({\n\t\tposition: strategy,\n\t\ttop: y ?? \"\",\n\t\tleft: x ?? \"\"\n\t}), [\n\t\tstrategy,\n\t\tx,\n\t\ty\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\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\tupdateScrollArrows();\n\t\t};\n\t\tscrollActiveIntoView(activeIndexRef.current);\n\t\treturn selectItemParentContext.activeIndexSubscribe(scrollActiveIntoView);\n\t}, [\n\t\topen,\n\t\tcontrolledScrolling,\n\t\tselectItemParentContext.activeIndexSubscribe,\n\t\tupdateScrollArrows\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\tupdateScrollArrows,\n\t\tfallback,\n\t\tfloatingContext,\n\t\tinteractions: interactionsContext,\n\t\tfloatingPosition,\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\tgetItemProps: interactions.getItemProps,\n\t\t\tlistRef: listItemsRef,\n\t\t\tselectTimeoutRef,\n\t\t\tchildren\n\t\t})\n\t});\n};\n\nexport { SelectInlineImpl };"],"mappings":";;;;;;;;;;AASA,MAAM,oBAAoB,UAAU;CACnC,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,mBAAmB;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,uBAAuB,SAAS,MAAM,aAAa,QAAQ,MAAM,EAAE,eAAe,EAAE,OAAO,UAAU,CAAC;GAC1G,mBAAmB;EACpB;EACA,qBAAqB,eAAe,OAAO;EAC3C,OAAO,wBAAwB,qBAAqB,oBAAoB;CACzE,GAAG;EACF;EACA;EACA,wBAAwB;EACxB;CACD,CAAC;CACD,MAAM,gBAAgB;EACrB,IAAI,QAAQ,UAAU;GACrB,IAAI,iBAAiB,MAAM,aAAa,QAAQ,cAAc,EAAE,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,cAAc;EACd;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,aAAa;GAC3B,SAAS;GACT;GACA;EACD,CAAC;CACF,CAAC;AACF"}
@@ -1,9 +1,8 @@
1
1
  import { View, createStyledHOC, styled } from "@tamagui/core";
2
- import { autoUpdate, offset, useFloatingRaw } from "@tamagui/floating";
2
+ import { autoUpdate, useFloatingRaw } from "@tamagui/floating";
3
3
  import { useComposedRefs } from "@tamagui/compose-refs";
4
4
  import { composeEventHandlers } from "@tamagui/helpers";
5
5
  import * as React from "react";
6
- import { flushSync } from "react-dom";
7
6
  import { useSelectContext } from "./context.mjs";
8
7
  import { jsx } from "react/jsx-runtime";
9
8
 
@@ -31,53 +30,39 @@ SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
31
30
  const SelectScrollButtonImpl = React.memo(createStyledHOC(SelectScrollButtonFrame, (props, forwardedRef) => {
32
31
  const { scope, dir, partClassName, ...scrollIndicatorProps } = props;
33
32
  const { className, onPointerEnter, onPointerLeave, ...frameProps } = scrollIndicatorProps;
34
- const { open, fallback, updateScrollArrows, setInnerOffset, ...context } = useSelectContext(scope);
33
+ const { open, ...context } = useSelectContext(scope);
35
34
  const floatingRef = context.floatingContext?.refs.floating;
36
- const statusRef = React.useRef("idle");
37
35
  const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
38
36
  const frameRef = React.useRef(null);
37
+ const arrowRef = dir === "up" ? context.upArrowRef : context.downArrowRef;
39
38
  const { x, y, refs, strategy } = useFloatingRaw({
40
39
  open: open && isVisible,
41
40
  strategy: "fixed",
42
41
  elements: { reference: floatingRef?.current },
43
42
  placement: dir === "up" ? "top" : "bottom",
44
- middleware: [offset(({ rects }) => -rects.floating.height)],
45
- whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true })
43
+ whileElementsMounted: autoUpdate
46
44
  });
47
45
  const setFloatingRef = React.useCallback((node) => {
48
46
  refs.setFloating(node);
49
- }, [refs.setFloating]);
47
+ if (arrowRef) arrowRef.current = node;
48
+ }, [refs.setFloating, arrowRef]);
50
49
  const composedRef = useComposedRefs(forwardedRef, setFloatingRef);
51
50
  React.useEffect(() => {
52
51
  return () => cancelAnimationFrame(frameRef.current);
53
- }, []);
54
- if (!isVisible) {
55
- return null;
56
- }
57
- const onScroll = (amount) => {
58
- const floating = floatingRef;
59
- if (!floating) return;
60
- if (fallback) {
61
- if (floating.current) {
62
- floating.current.scrollTop -= amount;
63
- updateScrollArrows();
64
- }
65
- } else {
66
- flushSync(() => setInnerOffset((value) => value - amount));
67
- }
68
- };
52
+ }, [isVisible]);
69
53
  return /* @__PURE__ */ jsx(SelectScrollButtonFrame, {
70
54
  ref: composedRef,
71
55
  className: `${partClassName} ${className || ""}`.trim(),
72
56
  "aria-hidden": true,
73
57
  ...frameProps,
58
+ visibility: isVisible ? "visible" : "hidden",
59
+ pointerEvents: isVisible ? "auto" : "none",
74
60
  zIndex: 1e3,
75
61
  position: strategy,
76
62
  left: x || 0,
77
63
  top: y || 0,
78
64
  width: `calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`,
79
65
  onPointerEnter: composeEventHandlers(onPointerEnter, () => {
80
- statusRef.current = "active";
81
66
  let prevNow = Date.now();
82
67
  function frame() {
83
68
  const element = floatingRef?.current;
@@ -88,7 +73,7 @@ const SelectScrollButtonImpl = React.memo(createStyledHOC(SelectScrollButtonFram
88
73
  const pixelsToScroll = msElapsed / 2;
89
74
  const remainingPixels = dir === "up" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;
90
75
  const scrollRemaining = dir === "up" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;
91
- onScroll(dir === "up" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels));
76
+ element.scrollTop += dir === "up" ? -Math.min(pixelsToScroll, remainingPixels) : Math.min(pixelsToScroll, remainingPixels);
92
77
  if (scrollRemaining) {
93
78
  frameRef.current = requestAnimationFrame(frame);
94
79
  }
@@ -98,7 +83,6 @@ const SelectScrollButtonImpl = React.memo(createStyledHOC(SelectScrollButtonFram
98
83
  frameRef.current = requestAnimationFrame(frame);
99
84
  }),
100
85
  onPointerLeave: composeEventHandlers(onPointerLeave, () => {
101
- statusRef.current = "idle";
102
86
  cancelAnimationFrame(frameRef.current);
103
87
  })
104
88
  });
@@ -1 +1 @@
1
- {"version":3,"file":"SelectScrollButton.js","names":["useFloating"],"sources":["esm/SelectScrollButton.js"],"sourcesContent":["import { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { autoUpdate, offset, useFloatingRaw as useFloating } from \"@tamagui/floating\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useSelectContext } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\nconst SCROLL_UP_BUTTON_NAME = \"SelectScrollUpButton\";\nconst SelectScrollButtonFrame = styled(View, {\n displayName: \"SelectScrollButton\"\n});\nconst SelectScrollUpButton = createStyledHOC(\n SelectScrollButtonFrame,\n (props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n SelectScrollButtonImpl,\n {\n partClassName: `is_${SCROLL_UP_BUTTON_NAME}`,\n ...props,\n dir: \"up\",\n ref: forwardedRef\n }\n );\n }\n);\nSelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;\nconst SCROLL_DOWN_BUTTON_NAME = \"SelectScrollDownButton\";\nconst SelectScrollDownButton = createStyledHOC(\n SelectScrollButtonFrame,\n (props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n SelectScrollButtonImpl,\n {\n partClassName: `is_${SCROLL_DOWN_BUTTON_NAME}`,\n ...props,\n dir: \"down\",\n ref: forwardedRef\n }\n );\n }\n);\nSelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;\nconst SelectScrollButtonImpl = React.memo(\n createStyledHOC(\n SelectScrollButtonFrame,\n (props, forwardedRef) => {\n const { scope, dir, partClassName, ...scrollIndicatorProps } = props;\n const { className, onPointerEnter, onPointerLeave, ...frameProps } = scrollIndicatorProps;\n const { open, fallback, updateScrollArrows, setInnerOffset, ...context } = useSelectContext(scope);\n const floatingRef = context.floatingContext?.refs.floating;\n const statusRef = React.useRef(\"idle\");\n const isVisible = context[dir === \"down\" ? \"canScrollDown\" : \"canScrollUp\"];\n const frameRef = React.useRef(null);\n const { x, y, refs, strategy } = useFloating({\n open: open && isVisible,\n strategy: \"fixed\",\n elements: {\n reference: floatingRef?.current\n },\n placement: dir === \"up\" ? \"top\" : \"bottom\",\n middleware: [offset(({ rects }) => -rects.floating.height)],\n whileElementsMounted: (...args) => autoUpdate(...args, { animationFrame: true })\n });\n const setFloatingRef = React.useCallback(\n (node) => {\n refs.setFloating(node);\n },\n [refs.setFloating]\n );\n const composedRef = useComposedRefs(forwardedRef, setFloatingRef);\n React.useEffect(() => {\n return () => cancelAnimationFrame(frameRef.current);\n }, []);\n if (!isVisible) {\n return null;\n }\n const onScroll = (amount) => {\n const floating = floatingRef;\n if (!floating) return;\n if (fallback) {\n if (floating.current) {\n floating.current.scrollTop -= amount;\n updateScrollArrows();\n }\n } else {\n flushSync(() => setInnerOffset((value) => value - amount));\n }\n };\n return /* @__PURE__ */ jsx(\n SelectScrollButtonFrame,\n {\n ref: composedRef,\n className: `${partClassName} ${className || \"\"}`.trim(),\n \"aria-hidden\": true,\n ...frameProps,\n zIndex: 1e3,\n position: strategy,\n left: x || 0,\n top: y || 0,\n width: `calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`,\n onPointerEnter: composeEventHandlers(onPointerEnter, () => {\n statusRef.current = \"active\";\n let prevNow = Date.now();\n function frame() {\n const element = floatingRef?.current;\n if (element) {\n const currentNow = Date.now();\n const msElapsed = currentNow - prevNow;\n prevNow = currentNow;\n const pixelsToScroll = msElapsed / 2;\n const remainingPixels = dir === \"up\" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;\n const scrollRemaining = dir === \"up\" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;\n onScroll(\n dir === \"up\" ? Math.min(pixelsToScroll, remainingPixels) : Math.max(-pixelsToScroll, -remainingPixels)\n );\n if (scrollRemaining) {\n frameRef.current = requestAnimationFrame(frame);\n }\n }\n }\n cancelAnimationFrame(frameRef.current);\n frameRef.current = requestAnimationFrame(frame);\n }),\n onPointerLeave: composeEventHandlers(onPointerLeave, () => {\n statusRef.current = \"idle\";\n cancelAnimationFrame(frameRef.current);\n })\n }\n );\n }\n )\n);\nexport {\n SelectScrollButtonFrame,\n SelectScrollDownButton,\n SelectScrollUpButton\n};\n//# sourceMappingURL=SelectScrollButton.js.map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AsB,KAAK;EAChD,CAAC;EACD,gBAAgB,qBAAqB,sBAAsB;GACzD,UAAU,UAAU;GACpB,qBAAqB,SAAS,OAAO;EACvC,CAAC;CACH,CACF;AACF,CACF,CACF"}
1
+ {"version":3,"file":"SelectScrollButton.js","names":["useFloating"],"sources":["esm/SelectScrollButton.js"],"sourcesContent":["import { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { autoUpdate, useFloatingRaw as useFloating } from \"@tamagui/floating\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { useSelectContext } from \"./context\";\nimport { jsx } from \"react/jsx-runtime\";\nconst SCROLL_UP_BUTTON_NAME = \"SelectScrollUpButton\";\nconst SelectScrollButtonFrame = styled(View, {\n displayName: \"SelectScrollButton\"\n});\nconst SelectScrollUpButton = createStyledHOC(\n SelectScrollButtonFrame,\n (props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n SelectScrollButtonImpl,\n {\n partClassName: `is_${SCROLL_UP_BUTTON_NAME}`,\n ...props,\n dir: \"up\",\n ref: forwardedRef\n }\n );\n }\n);\nSelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;\nconst SCROLL_DOWN_BUTTON_NAME = \"SelectScrollDownButton\";\nconst SelectScrollDownButton = createStyledHOC(\n SelectScrollButtonFrame,\n (props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n SelectScrollButtonImpl,\n {\n partClassName: `is_${SCROLL_DOWN_BUTTON_NAME}`,\n ...props,\n dir: \"down\",\n ref: forwardedRef\n }\n );\n }\n);\nSelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;\nconst SelectScrollButtonImpl = React.memo(\n createStyledHOC(\n SelectScrollButtonFrame,\n (props, forwardedRef) => {\n const { scope, dir, partClassName, ...scrollIndicatorProps } = props;\n const { className, onPointerEnter, onPointerLeave, ...frameProps } = scrollIndicatorProps;\n const { open, ...context } = useSelectContext(scope);\n const floatingRef = context.floatingContext?.refs.floating;\n const isVisible = context[dir === \"down\" ? \"canScrollDown\" : \"canScrollUp\"];\n const frameRef = React.useRef(null);\n const arrowRef = dir === \"up\" ? context.upArrowRef : context.downArrowRef;\n const { x, y, refs, strategy } = useFloating({\n open: open && isVisible,\n strategy: \"fixed\",\n elements: {\n reference: floatingRef?.current\n },\n placement: dir === \"up\" ? \"top\" : \"bottom\",\n whileElementsMounted: autoUpdate\n });\n const setFloatingRef = React.useCallback(\n (node) => {\n refs.setFloating(node);\n if (arrowRef) arrowRef.current = node;\n },\n [refs.setFloating, arrowRef]\n );\n const composedRef = useComposedRefs(forwardedRef, setFloatingRef);\n React.useEffect(() => {\n return () => cancelAnimationFrame(frameRef.current);\n }, [isVisible]);\n return /* @__PURE__ */ jsx(\n SelectScrollButtonFrame,\n {\n ref: composedRef,\n className: `${partClassName} ${className || \"\"}`.trim(),\n \"aria-hidden\": true,\n ...frameProps,\n visibility: isVisible ? \"visible\" : \"hidden\",\n pointerEvents: isVisible ? \"auto\" : \"none\",\n zIndex: 1e3,\n position: strategy,\n left: x || 0,\n top: y || 0,\n width: `calc(${(floatingRef?.current?.offsetWidth ?? 0) - 2}px)`,\n onPointerEnter: composeEventHandlers(onPointerEnter, () => {\n let prevNow = Date.now();\n function frame() {\n const element = floatingRef?.current;\n if (element) {\n const currentNow = Date.now();\n const msElapsed = currentNow - prevNow;\n prevNow = currentNow;\n const pixelsToScroll = msElapsed / 2;\n const remainingPixels = dir === \"up\" ? element.scrollTop : element.scrollHeight - element.clientHeight - element.scrollTop;\n const scrollRemaining = dir === \"up\" ? element.scrollTop - pixelsToScroll > 0 : element.scrollTop + pixelsToScroll < element.scrollHeight - element.clientHeight;\n element.scrollTop += dir === \"up\" ? -Math.min(pixelsToScroll, remainingPixels) : Math.min(pixelsToScroll, remainingPixels);\n if (scrollRemaining) {\n frameRef.current = requestAnimationFrame(frame);\n }\n }\n }\n cancelAnimationFrame(frameRef.current);\n frameRef.current = requestAnimationFrame(frame);\n }),\n onPointerLeave: composeEventHandlers(onPointerLeave, () => {\n cancelAnimationFrame(frameRef.current);\n })\n }\n );\n }\n )\n);\nexport {\n SelectScrollButtonFrame,\n SelectScrollDownButton,\n SelectScrollUpButton\n};\n//# sourceMappingURL=SelectScrollButton.js.map\n"],"mappings":";;;;;;;;;AAOA,MAAM,wBAAwB;AAC9B,MAAM,0BAA0B,OAAO,MAAM,EAC3C,aAAa,qBACf,CAAC;AACD,MAAM,uBAAuB,gBAC3B,0BACC,OAAO,iBAAiB;CACvB,OAAuB,oBACrB,wBACA;EACE,eAAe,MAAM;EACrB,GAAG;EACH,KAAK;EACL,KAAK;CACP,CACF;AACF,CACF;AACA,qBAAqB,cAAc;AACnC,MAAM,0BAA0B;AAChC,MAAM,yBAAyB,gBAC7B,0BACC,OAAO,iBAAiB;CACvB,OAAuB,oBACrB,wBACA;EACE,eAAe,MAAM;EACrB,GAAG;EACH,KAAK;EACL,KAAK;CACP,CACF;AACF,CACF;AACA,uBAAuB,cAAc;AACrC,MAAM,yBAAyB,MAAM,KACnC,gBACE,0BACC,OAAO,iBAAiB;CACvB,MAAM,EAAE,OAAO,KAAK,eAAe,GAAG,yBAAyB;CAC/D,MAAM,EAAE,WAAW,gBAAgB,gBAAgB,GAAG,eAAe;CACrE,MAAM,EAAE,MAAM,GAAG,YAAY,iBAAiB,KAAK;CACnD,MAAM,cAAc,QAAQ,iBAAiB,KAAK;CAClD,MAAM,YAAY,QAAQ,QAAQ,SAAS,kBAAkB;CAC7D,MAAM,WAAW,MAAM,OAAO,IAAI;CAClC,MAAM,WAAW,QAAQ,OAAO,QAAQ,aAAa,QAAQ;CAC7D,MAAM,EAAE,GAAG,GAAG,MAAM,aAAaA,eAAY;EAC3C,MAAM,QAAQ;EACd,UAAU;EACV,UAAU,EACR,WAAW,aAAa,QAC1B;EACA,WAAW,QAAQ,OAAO,QAAQ;EAClC,sBAAsB;CACxB,CAAC;CACD,MAAM,iBAAiB,MAAM,aAC1B,SAA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daptPortalContents, useAdaptIsActive } from "@tamagui/adapt";
2
2
  import { AnimatePresence } from "@tamagui/animate-presence";
3
3
  import { useComposedRefs } from "@tamagui/compose-refs";
4
4
  import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
5
- import { View, createStyledHOC, styled } from "@tamagui/core";
5
+ import { View, createStyledHOC, splitStyleProps, styled } from "@tamagui/core";
6
6
  import { needsPortalRepropagation } from "@tamagui/portal";
7
7
  import { YStack } from "@tamagui/stacks";
8
8
  import * as React from "react";
@@ -16,6 +16,10 @@ const SelectViewportFrame = styled(View, {
16
16
  position: "relative"
17
17
  });
18
18
  const needsRepropagation = needsPortalRepropagation();
19
+ const getSheetFrameProps = (props) => {
20
+ const { className, style, "data-tamagui-hoc-class": _hocClassNames, ...rest } = props;
21
+ return splitStyleProps(rest)[1];
22
+ };
19
23
  const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewport2(props, forwardedRef) {
20
24
  const { scope, children, disableScroll, ...viewportProps } = props;
21
25
  const context = useSelectContext(scope);
@@ -58,8 +62,9 @@ const SelectViewport = createStyledHOC(SelectViewportFrame, function SelectViewp
58
62
  });
59
63
  }
60
64
  if (isAdapted || !isWeb) {
65
+ const frameProps = isAdapted ? getSheetFrameProps(viewportProps) : viewportProps;
61
66
  let content = /* @__PURE__ */ jsx(SelectViewportFrame, {
62
- ...viewportProps,
67
+ ...frameProps,
63
68
  ...isWeb ? getSelectListboxProps(itemContext.mode) : {},
64
69
  "data-select-viewport": "",
65
70
  ref: composedRefs,
@@ -108,7 +113,7 @@ const selectViewportCSS = `
108
113
  [data-select-viewport] {
109
114
  scrollbar-width: none;
110
115
  -webkit-overflow-scrolling: touch;
111
- overscroll-behavior: contain;
116
+ overscroll-behavior: none;
112
117
  }
113
118
 
114
119
  [data-select-viewport]::-webkit-scrollbar{
@@ -1 +1 @@
1
- {"version":3,"file":"SelectViewport.js","names":[],"sources":["esm/SelectViewport.js"],"sourcesContent":["import { AdaptPortalContents, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { AnimatePresence } from \"@tamagui/animate-presence\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createStyledHOC, styled, View } from \"@tamagui/core\";\nimport { needsPortalRepropagation } from \"@tamagui/portal\";\nimport { YStack } from \"@tamagui/stacks\";\nimport * as React from \"react\";\nimport { VIEWPORT_NAME } from \"./constants\";\nimport {\n ForwardSelectContext,\n useSelectContext,\n useSelectItemParentContext\n} from \"./context\";\nimport { getSelectListboxProps } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst SelectViewportFrame = styled(View, {\n displayName: VIEWPORT_NAME,\n position: \"relative\"\n});\nconst needsRepropagation = needsPortalRepropagation();\nconst SelectViewport = createStyledHOC(\n SelectViewportFrame,\n function SelectViewport2(props, forwardedRef) {\n const { scope, children, disableScroll, ...viewportProps } = props;\n const context = useSelectContext(scope);\n const itemContext = useSelectItemParentContext(scope);\n const isAdapted = useAdaptIsActive(context.adaptScope);\n const viewportRef = React.useRef(null);\n const registeredItemCount = itemContext.registry.getItems().length;\n const hasOpenedRef = React.useRef(!context.lazyMount);\n if (context.open) hasOpenedRef.current = true;\n const lazyMounted = hasOpenedRef.current;\n React.useEffect(() => {\n if (!isWeb || !isAdapted || !context.open) return;\n const frame = requestAnimationFrame(() => {\n const index = context.activeIndexRef.current ?? itemContext.registry.firstEnabledIndex();\n const activeItem = viewportRef.current?.querySelector(\n '[role=\"option\"][tabindex=\"0\"]'\n ) ?? (index >= 0 ? itemContext.listRef?.current[index] : null);\n activeItem?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, isAdapted, registeredItemCount]);\n const composedRefs = useComposedRefs(\n // @ts-ignore react 19 ref type mismatch\n forwardedRef,\n viewportRef,\n context.floatingContext?.refs.setFloating\n );\n useIsomorphicLayoutEffect(() => {\n if (context.update) {\n context.update();\n }\n }, [isAdapted]);\n React.useEffect(() => {\n if (context.lazyMount && context.open && context.update) {\n const frame = requestAnimationFrame(context.update);\n return () => cancelAnimationFrame(frame);\n }\n }, [context.open, registeredItemCount]);\n if (itemContext.shouldRenderWebNative) {\n return /* @__PURE__ */ jsx(YStack, { position: \"relative\", children });\n }\n if (isAdapted || !isWeb) {\n let content = /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n ...viewportProps,\n ...isWeb ? getSelectListboxProps(itemContext.mode) : {},\n \"data-select-viewport\": \"\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n }\n );\n if (needsRepropagation) {\n content = /* @__PURE__ */ jsx(ForwardSelectContext, { itemContext, context, children: content });\n }\n return /* @__PURE__ */ jsx(AdaptPortalContents, { scope: context.adaptScope, children: content });\n }\n if (!context.interactions) {\n return null;\n }\n const floatingProps = context.interactions.getFloatingProps();\n return /* @__PURE__ */ jsxs(Fragment, { children: [\n !disableScroll && /* @__PURE__ */ jsx(\n \"style\",\n {\n dangerouslySetInnerHTML: {\n __html: selectViewportCSS\n }\n }\n ),\n /* @__PURE__ */ jsx(AnimatePresence, { presenceAffectsLayout: false, children: context.open ? /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n \"data-select-viewport\": \"\",\n ...isWeb && {\n \"data-state\": context.open ? \"open\" : \"closed\"\n },\n ...viewportProps,\n ...context.floatingPosition,\n outlineWidth: 0,\n ...floatingProps,\n ...getSelectListboxProps(itemContext.mode),\n overflowY: disableScroll ? void 0 : \"auto\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n },\n \"select-viewport\"\n ) : null }),\n !context.open && !(context.lazyMount && context.renderValue) && lazyMounted && /* @__PURE__ */ jsx(\"div\", { style: { display: \"none\" }, children })\n ] });\n }\n);\nconst selectViewportCSS = `\n[data-select-viewport] {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: contain;\n}\n\n[data-select-viewport]::-webkit-scrollbar{\n display:none\n}\n`;\nexport {\n SelectViewport,\n SelectViewportFrame\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ources":["esm/SelectViewport.js"],"sourcesContent":["import { AdaptPortalContents, useAdaptIsActive } from \"@tamagui/adapt\";\nimport { AnimatePresence } from \"@tamagui/animate-presence\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb, useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createStyledHOC, splitStyleProps, styled, View } from \"@tamagui/core\";\nimport { needsPortalRepropagation } from \"@tamagui/portal\";\nimport { YStack } from \"@tamagui/stacks\";\nimport * as React from \"react\";\nimport { VIEWPORT_NAME } from \"./constants\";\nimport {\n ForwardSelectContext,\n useSelectContext,\n useSelectItemParentContext\n} from \"./context\";\nimport { getSelectListboxProps } from \"./selectionController\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst SelectViewportFrame = styled(View, {\n displayName: VIEWPORT_NAME,\n position: \"relative\"\n});\nconst needsRepropagation = needsPortalRepropagation();\nconst getSheetFrameProps = (props) => {\n const { className, style, \"data-tamagui-hoc-class\": _hocClassNames, ...rest } = props;\n return splitStyleProps(rest)[1];\n};\nconst SelectViewport = createStyledHOC(\n SelectViewportFrame,\n function SelectViewport2(props, forwardedRef) {\n const { scope, children, disableScroll, ...viewportProps } = props;\n const context = useSelectContext(scope);\n const itemContext = useSelectItemParentContext(scope);\n const isAdapted = useAdaptIsActive(context.adaptScope);\n const viewportRef = React.useRef(null);\n const registeredItemCount = itemContext.registry.getItems().length;\n const hasOpenedRef = React.useRef(!context.lazyMount);\n if (context.open) hasOpenedRef.current = true;\n const lazyMounted = hasOpenedRef.current;\n React.useEffect(() => {\n if (!isWeb || !isAdapted || !context.open) return;\n const frame = requestAnimationFrame(() => {\n const index = context.activeIndexRef.current ?? itemContext.registry.firstEnabledIndex();\n const activeItem = viewportRef.current?.querySelector(\n '[role=\"option\"][tabindex=\"0\"]'\n ) ?? (index >= 0 ? itemContext.listRef?.current[index] : null);\n activeItem?.focus();\n });\n return () => cancelAnimationFrame(frame);\n }, [context.open, isAdapted, registeredItemCount]);\n const composedRefs = useComposedRefs(\n // @ts-ignore react 19 ref type mismatch\n forwardedRef,\n viewportRef,\n context.floatingContext?.refs.setFloating\n );\n useIsomorphicLayoutEffect(() => {\n if (context.update) {\n context.update();\n }\n }, [isAdapted]);\n React.useEffect(() => {\n if (context.lazyMount && context.open && context.update) {\n const frame = requestAnimationFrame(context.update);\n return () => cancelAnimationFrame(frame);\n }\n }, [context.open, registeredItemCount]);\n if (itemContext.shouldRenderWebNative) {\n return /* @__PURE__ */ jsx(YStack, { position: \"relative\", children });\n }\n if (isAdapted || !isWeb) {\n const frameProps = isAdapted ? getSheetFrameProps(viewportProps) : viewportProps;\n let content = /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n ...frameProps,\n ...isWeb ? getSelectListboxProps(itemContext.mode) : {},\n \"data-select-viewport\": \"\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n }\n );\n if (needsRepropagation) {\n content = /* @__PURE__ */ jsx(ForwardSelectContext, { itemContext, context, children: content });\n }\n return /* @__PURE__ */ jsx(AdaptPortalContents, { scope: context.adaptScope, children: content });\n }\n if (!context.interactions) {\n return null;\n }\n const floatingProps = context.interactions.getFloatingProps();\n return /* @__PURE__ */ jsxs(Fragment, { children: [\n !disableScroll && /* @__PURE__ */ jsx(\n \"style\",\n {\n dangerouslySetInnerHTML: {\n __html: selectViewportCSS\n }\n }\n ),\n /* @__PURE__ */ jsx(AnimatePresence, { presenceAffectsLayout: false, children: context.open ? /* @__PURE__ */ jsx(\n SelectViewportFrame,\n {\n \"data-select-viewport\": \"\",\n ...isWeb && {\n \"data-state\": context.open ? \"open\" : \"closed\"\n },\n ...viewportProps,\n ...context.floatingPosition,\n outlineWidth: 0,\n ...floatingProps,\n ...getSelectListboxProps(itemContext.mode),\n overflowY: disableScroll ? void 0 : \"auto\",\n ref: composedRefs,\n children: lazyMounted ? children : null\n },\n \"select-viewport\"\n ) : null }),\n !context.open && !(context.lazyMount && context.renderValue) && lazyMounted && /* @__PURE__ */ jsx(\"div\", { style: { display: \"none\" }, children })\n ] });\n }\n);\nconst selectViewportCSS = `\n[data-select-viewport] {\n scrollbar-width: none;\n -webkit-overflow-scrolling: touch;\n overscroll-behavior: none;\n}\n\n[data-select-viewport]::-webkit-scrollbar{\n display:none\n}\n`;\nexport {\n SelectViewport,\n SelectViewportFrame\n};\n//# sourceMappingURL=SelectViewport.js.map\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,sBAAsB,OAAO,MAAM;CACvC,aAAa;CACb,UAAU;AACZ,CAAC;AACD,MAAM,qBAAqB,yBAAyB;AACpD,MAAM,sBAAsB,UAAU;CACpC,MAAM,EAAE,WAAW,OAAO,0BAA0B,gBAAgB,GAAG,SAAS;CAChF,OAAO,gBAAgB,IAAI,CAAC,CAAC;AAC/B;AACA,MAAM,iBAAiB,gBACrB,qBACA,SAAS,gBAAgB,OAAO,cAAc;CAC5C,MAAM,EAAE,OAAO,UAAU,eAAe,GAAG,kBAAkB;CAC7D,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,cAAc,2BAA2B,KAAK;CACpD,MAAM,YAAY,iBAAiB,QAAQ,UAAU;CACrD,MAAM,cAAc,MAAM,OAAO,IAAI;CACrC,MAAM,sBAAsB,YAAY,SAAS,SAAS,CAAC,CAAC;CAC5D,MAAM,eAAe,MAAM,OAAO,CAAC,QAAQ,SAAS;CACpD,IAAI,QAAQ,MAAM,aAAa,UAAU;CACzC,MAAM,cAAc,aAAa;CACjC,MAAM,gBAAgB;EACpB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,MAAM;EAC3C,MAAM,QAAQ,4BAA4B;GACxC,MAAM,QAAQ,QAAQ,eAAe,WAAW,YAAY,SAAS,kBAAkB;GACvF,MAAM,aAAa,YAAY,SAAS,cACtC,mCACF,MAAM,SAAS,IAAI,YAAY,SAAS,QAAQ,SAAS;GACzD,YAAY,MAAM;EACpB,CAAC;EACD,aAAa,qBAAqB,KAAK;CACzC,GAAG;EAAC,QAAQ;E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