@tamagui/select 3.0.0 → 3.0.2

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.
@@ -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":["jsx/SelectImpl.js"],"sourcesContent":["import { autoUpdate, inner, offset, size, useClick, useFloatingRaw, useInnerOffset, useInteractions, useListNavigation, useRole, useTypeahead } from \"@tamagui/floating\";\nimport { useIsomorphicLayoutEffect } from \"@tamagui/constants\";\nimport { createChangeEventDetails, useEvent, useIsTouchDevice } from \"@tamagui/core\";\nimport { composeEventHandlers } from \"@tamagui/helpers\";\nimport * as React from \"react\";\nimport { 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,e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M,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;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":["jsx/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: listItems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IAAI,CAAC,QAAQ,MAAM,QAAQ,gBAAgB,MAAM,QAAQ,iBAAiB;CAC3E,GAAG,CAAC,IAAI,CAAC;CACT,MAAM,gBAAgB;EACrB,IAAI,CAAC,MAAM;EACX,MAAM,wBAAwB,UAAU;GACvC,IAAI,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":["jsx/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\n"],"mappings":";;;;;;;;;;AAQA,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,UAAU,oBAAoB,gBAAgB,GAAG,YAAY,iBAAiB,KAAK;CACjG,MAAM,cAAc,QAAQ,iBAAiB,KAAK;CAClD,MAAM,YAAY,MAAM,OAAO,MAAM;CACrC,MAAM,YAAY,QAAQ,QAAQ,SAAS,kBAAkB;CAC7D,MAAM,WAAW,MAAM,OAAO,IAAI;CAClC,MAAM,EAAE,GAAG,GAAG,MAAM,aAAaA,eAAY;EAC3C,MAAM,QAAQ;EACd,UAAU;EACV,UAAU,EACR,WAAW,aAAa,QAC1B;EACA,WAAW,QAAQ,OAAO,QAAQ;EAClC,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,SAAS,MAAM,C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gB,eAAe,IAAI,KAAK,IAAI,CAAC,gBAAgB,CAAC,eAAe,CACvG;KACA,IAAI,iBAAiB;MACnB,SAAS,UAAU,sBAAsB,KAAK;KAChD;IACF;GACF;GACA,qBAAqB,SAAS,OAAO;GACrC,SAAS,UAAU,sBAAsB,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":["jsx/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,MAA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,SAAS,OAAO;GACrC,SAAS,UAAU,sBAAsB,KAAK;EAChD,CAAC;EACD,gBAAgB,qBAAqB,sBAAsB;GACzD,qBAAqB,SAAS,OAAO;EACvC,CAAC;CACH,CACF;AACF,CACF,CACF"}
@@ -2,7 +2,7 @@ import { AdaptPortalContents, 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":["jsx/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\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,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;EAAM;EAAW;CAAmB,CAAC;CACjD,MAAM,eAAe,gBAEnB,cACA,aACA,QAAQ,iBAAiB,KAAK,WAChC;CACA,gCAAgC;EAC9B,IAAI,QAAQ,QAAQ;GAClB,QAAQ,OAAO;EACjB;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,aAAa,QAAQ,gBAAgB,eAA+B,oBAAI,OAAO;GAAE,OAAO,EAAE,SAAS,OAAO;GAAG;EAAS,CAAC;CACpJ,EAAE,CAAC;AACL,CACF;AACA,MAAM,oBAAoB"}
1
+ {"version":3,"file":"SelectViewport.js","names":[],"sources":["jsx/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,SAA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,EACF,CACF;EACgB,oBAAI,iBAAiB;GAAE,uBAAuB;GAAO,UAAU,QAAQ,OAAuB,oBAC5G,qBACA;IACE,wBAAwB;IACxB,GAAG,SAAS,EACV,cAAc,QAAQ,OAAO,SAAS,SACxC;IACA,GAAG;IACH,GAAG,QAAQ;IACX,cAAc;IACd,GAAG;IACH,GAAG,sBAAsB,YAAY,IAAI;IACzC,WAAW,gBAAgB,KAAK,IAAI;IACpC,KAAK;IACL,UAAU,cAAc,WAAW;GACrC,GACA,iBACF,IAAI;EAAK,CAAC;EACV,CAAC,QAAQ,QAAQ,EAAE,QAAQ,aAAa,QAAQ,gBAAgB,eAA+B,oBAAI,OAAO;GAAE,OAAO,EAAE,SAAS,OAAO;GAAG;EAAS,CAAC;CACpJ,EAAE,CAAC;AACL,CACF;AACA,MAAM,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/select",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "license": "MIT",
5
5
  "source": "src/index.tsx",
6
6
  "files": [
@@ -35,33 +35,33 @@
35
35
  "clean:build": "tamagui-build clean:build"
36
36
  },
37
37
  "dependencies": {
38
- "@tamagui/adapt": "3.0.0",
39
- "@tamagui/animate-presence": "3.0.0",
40
- "@tamagui/compose-refs": "3.0.0",
41
- "@tamagui/constants": "3.0.0",
42
- "@tamagui/core": "3.0.0",
43
- "@tamagui/create-context": "3.0.0",
44
- "@tamagui/dismissable": "3.0.0",
45
- "@tamagui/floating": "3.0.0",
46
- "@tamagui/focus-scope": "3.0.0",
47
- "@tamagui/focusable": "3.0.0",
48
- "@tamagui/get-token": "3.0.0",
49
- "@tamagui/helpers": "3.0.0",
50
- "@tamagui/list-item": "3.0.0",
51
- "@tamagui/native": "3.0.0",
52
- "@tamagui/portal": "3.0.0",
53
- "@tamagui/remove-scroll": "3.0.0",
54
- "@tamagui/separator": "3.0.0",
55
- "@tamagui/sheet": "3.0.0",
56
- "@tamagui/stacks": "3.0.0",
57
- "@tamagui/text": "3.0.0",
58
- "@tamagui/use-controllable-state": "3.0.0",
59
- "@tamagui/use-debounce": "3.0.0",
60
- "@tamagui/use-event": "3.0.0",
61
- "@tamagui/z-index-stack": "3.0.0"
38
+ "@tamagui/adapt": "3.0.2",
39
+ "@tamagui/animate-presence": "3.0.2",
40
+ "@tamagui/compose-refs": "3.0.2",
41
+ "@tamagui/constants": "3.0.2",
42
+ "@tamagui/core": "3.0.2",
43
+ "@tamagui/create-context": "3.0.2",
44
+ "@tamagui/dismissable": "3.0.2",
45
+ "@tamagui/floating": "3.0.2",
46
+ "@tamagui/focus-scope": "3.0.2",
47
+ "@tamagui/focusable": "3.0.2",
48
+ "@tamagui/get-token": "3.0.2",
49
+ "@tamagui/helpers": "3.0.2",
50
+ "@tamagui/list-item": "3.0.2",
51
+ "@tamagui/native": "3.0.2",
52
+ "@tamagui/portal": "3.0.2",
53
+ "@tamagui/remove-scroll": "3.0.2",
54
+ "@tamagui/separator": "3.0.2",
55
+ "@tamagui/sheet": "3.0.2",
56
+ "@tamagui/stacks": "3.0.2",
57
+ "@tamagui/text": "3.0.2",
58
+ "@tamagui/use-controllable-state": "3.0.2",
59
+ "@tamagui/use-debounce": "3.0.2",
60
+ "@tamagui/use-event": "3.0.2",
61
+ "@tamagui/z-index-stack": "3.0.2"
62
62
  },
63
63
  "devDependencies": {
64
- "@tamagui/build": "3.0.0",
64
+ "@tamagui/build": "3.0.2",
65
65
  "react": "19.2.3",
66
66
  "react-dom": "19.2.3",
67
67
  "react-native": "0.87.1"
@@ -77,5 +77,5 @@
77
77
  "url": "git+https://github.com/tamagui/tamagui.git",
78
78
  "directory": "code/ui/select"
79
79
  },
80
- "releaseSourceCommit": "15fbca480b143f876f6975601e23a17d3f90d2ee"
80
+ "releaseSourceCommit": "8d875db3d642488c86973478d85e1f66db49e5bd"
81
81
  }
@@ -1,12 +1,10 @@
1
1
  import {
2
- autoUpdate,
3
2
  inner,
4
3
  offset,
5
4
  size,
6
5
  useClick,
7
6
  useFloatingRaw as useFloatingDom,
8
7
  useInteractions,
9
- useInnerOffset,
10
8
  useListNavigation,
11
9
  useRole,
12
10
  useTypeahead,
@@ -37,7 +35,7 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
37
35
  const selectItemParentContext = useSelectItemParentContext(scope)
38
36
  const { setActiveIndex, selectedIndex, activeIndexRef } = selectContext
39
37
 
40
- const { requestOpenChange, registry } = selectItemParentContext
38
+ const { requestOpenChange, registry, lastPointerRef } = selectItemParentContext
41
39
 
42
40
  const touch = useIsTouchDevice()
43
41
 
@@ -56,7 +54,6 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
56
54
 
57
55
  const [controlledScrolling, setControlledScrolling] = React.useState(false)
58
56
  const [fallback, setFallback] = React.useState(false)
59
- const [innerOffset, setInnerOffset] = React.useState(0)
60
57
  const [blockSelection, setBlockSelection] = React.useState(false)
61
58
 
62
59
  React.useEffect(() => {
@@ -97,7 +94,6 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
97
94
  } = useFloatingDom({
98
95
  open,
99
96
  placement: 'bottom-start',
100
- whileElementsMounted: autoUpdate,
101
97
  // The removed alternate stack was the logic from floating-ui,
102
98
  // but it causes issues (open, drag select, close, then re-open its not positioned "over")
103
99
  // https://github.com/floating-ui/floating-ui/blob/master/packages/react/test/visual/components/MacSelect.tsx
@@ -112,9 +108,17 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
112
108
  listRef: listItemsRef,
113
109
  overflowRef,
114
110
  index: selectedIndex,
115
- offset: innerOffset,
116
111
  onFallbackChange: setFallback,
117
- padding: 10,
112
+ // arrows sit outside the scrollport, with room reserved at both screen edges
113
+ get padding() {
114
+ return (
115
+ 10 +
116
+ Math.max(
117
+ upArrowRef.current?.offsetHeight ?? 0,
118
+ downArrowRef.current?.offsetHeight ?? 0
119
+ )
120
+ )
121
+ },
118
122
  minItemsVisible: touch ? 10 : 4,
119
123
  referenceOverflowThreshold: 20,
120
124
  }),
@@ -137,11 +141,16 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
137
141
 
138
142
  const showUpArrow = open && canScrollUp
139
143
  const showDownArrow = open && canScrollDown
140
- const isScrollable = showDownArrow || showUpArrow
141
144
 
142
- // autoUpdate handles resize and scroll while mounted; this covers the open
145
+ // the list is placed once per open, not kept in sync: the inner middleware
146
+ // scrolls the list to align the selected item, so recomputing on a page
147
+ // scroll would yank the list out from under the user's own scroll. the list
148
+ // is absolutely positioned, so it rides along with page scroll on its own.
143
149
  useIsomorphicLayoutEffect(() => {
144
- if (open) update()
150
+ if (!open) return
151
+ update()
152
+ window.addEventListener('resize', update)
153
+ return () => window.removeEventListener('resize', update)
145
154
  }, [update, open])
146
155
 
147
156
  const onMatch = useEvent((index: number) => {
@@ -194,12 +203,6 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
194
203
  useClick(interactionContext, { event: 'mousedown', keyboardHandlers: false }),
195
204
  // useDismiss removed - already handled by Dismissable in SelectContent
196
205
  useRole(interactionContext, { role: 'listbox' }),
197
- useInnerOffset(interactionContext, {
198
- enabled: !fallback && isScrollable,
199
- onChange: setInnerOffset,
200
- overflowRef,
201
- scrollRef: refs.floating,
202
- }),
203
206
  useListNavigation(interactionContext, {
204
207
  listRef: listItemsRef,
205
208
  // items focus themselves from the active-index emitter, and the hook's
@@ -247,6 +250,15 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
247
250
  getReferenceProps(props: Record<string, any> = {}) {
248
251
  return interactions.getReferenceProps({
249
252
  ...props,
253
+ // the press that opens is the pointer's last real position: WebKit
254
+ // replays a mousemove there whenever the list scrolls under it (say a
255
+ // keyboard move scrolling the next item into view), and that replay
256
+ // must not read as a hover
257
+ onMouseDown: composeEventHandlers(props.onMouseDown, (event: any) => {
258
+ const last = lastPointerRef.current
259
+ last.x = event.clientX
260
+ last.y = event.clientY
261
+ }),
250
262
  onKeyDown: composeEventHandlers(props.onKeyDown, (event: any) => {
251
263
  latestKeyboardEventRef.current = event.nativeEvent || event
252
264
  if (
@@ -317,7 +329,6 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
317
329
  }
318
330
  allowSelectRef.current = false
319
331
  allowMouseUpRef.current = true
320
- setInnerOffset(0)
321
332
  setFallback(false)
322
333
  setBlockSelection(false)
323
334
  }, [open])
@@ -377,7 +388,6 @@ export const SelectInlineImpl = (props: SelectImplProps) => {
377
388
  scope={scope}
378
389
  {...(selectContext as Required<typeof selectContext>)}
379
390
  updateScrollArrows={updateScrollArrows}
380
- setInnerOffset={setInnerOffset}
381
391
  fallback={fallback}
382
392
  floatingContext={floatingContext as any}
383
393
  interactions={interactionsContext}