@tamagui/select 1.0.1-beta.36 → 1.0.1-beta.39

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,21 +1,54 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import {
4
+ FloatingFocusManager,
5
+ FloatingOverlay,
6
+ FloatingPortal,
7
+ autoUpdate,
8
+ detectOverflow,
9
+ flip,
4
10
  offset,
5
- useFloating
11
+ size,
12
+ useClick,
13
+ useDismiss,
14
+ useFloating,
15
+ useInteractions,
16
+ useListNavigation,
17
+ useRole,
18
+ useTypeahead
6
19
  } from "@floating-ui/react-dom-interactions";
7
20
  import { usePrevious } from "@radix-ui/react-use-previous";
21
+ import { Button } from "@tamagui/button";
8
22
  import { useComposedRefs } from "@tamagui/compose-refs";
9
- import { composeEventHandlers, useIsomorphicLayoutEffect } from "@tamagui/core";
23
+ import {
24
+ getVariableValue,
25
+ styled,
26
+ useIsomorphicLayoutEffect,
27
+ withStaticProperties
28
+ } from "@tamagui/core";
10
29
  import { useId } from "@tamagui/core";
11
30
  import { createContextScope } from "@tamagui/create-context";
12
31
  import { Separator } from "@tamagui/separator";
13
- import { XStack } from "@tamagui/stacks";
32
+ import { ThemeableStack, XStack, YStack } from "@tamagui/stacks";
33
+ import { Paragraph } from "@tamagui/text";
14
34
  import { useControllableState } from "@tamagui/use-controllable-state";
15
35
  import * as React from "react";
16
36
  import * as ReactDOM from "react-dom";
17
- const OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
18
- const SELECTION_KEYS = [" ", "Enter"];
37
+ const isFirefox = typeof navigator !== "undefined" && navigator.userAgent.toLowerCase().includes("firefox");
38
+ if (isFirefox) {
39
+ document.body.classList.add("firefox");
40
+ }
41
+ function getVisualOffsetTop() {
42
+ return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent) ? visualViewport.offsetTop : 0;
43
+ }
44
+ __name(getVisualOffsetTop, "getVisualOffsetTop");
45
+ const getSelectItemSize = /* @__PURE__ */ __name((val, { tokens }) => {
46
+ const padding = getVariableValue(tokens.size[val]);
47
+ return {
48
+ paddingHorizontal: padding / 2,
49
+ paddingVertical: padding / 4
50
+ };
51
+ }, "getSelectItemSize");
19
52
  const SELECT_NAME = "Select";
20
53
  const WINDOW_PADDING = 8;
21
54
  const SCROLL_ARROW_VELOCITY = 8;
@@ -24,61 +57,8 @@ const MIN_HEIGHT = 80;
24
57
  const FALLBACK_THRESHOLD = 16;
25
58
  const [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME);
26
59
  const [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
27
- const Select = /* @__PURE__ */ __name((props) => {
28
- const {
29
- __scopeSelect,
30
- children,
31
- open: openProp,
32
- defaultOpen,
33
- onOpenChange,
34
- value: valueProp,
35
- defaultValue,
36
- onValueChange,
37
- dir: dir2,
38
- name,
39
- autoComplete
40
- } = props;
41
- const [open, setOpen] = useControllableState({
42
- prop: openProp,
43
- defaultProp: defaultOpen || false,
44
- onChange: onOpenChange
45
- });
46
- const [value, setValue] = useControllableState({
47
- prop: valueProp,
48
- defaultProp: defaultValue || "",
49
- onChange: onValueChange
50
- });
51
- const selectedIndexRef = React.useRef(null);
52
- const activeIndexRef = React.useRef(null);
53
- const prevActiveIndex = usePrevious(activeIndex);
54
- const [showArrows, setShowArrows] = React.useState(false);
55
- const [scrollTop, setScrollTop] = React.useState(0);
56
- const [activeIndex, setActiveIndex] = React.useState(null);
57
- const [selectedIndex, setSelectedIndex] = React.useState(Math.max(0, listContentRef.current.indexOf(value)));
58
- useIsomorphicLayoutEffect(() => {
59
- selectedIndexRef.current = selectedIndex;
60
- activeIndexRef.current = activeIndex;
61
- });
62
- useEffect(() => {
63
- const frame = requestAnimationFrame(() => {
64
- setShowArrows(open);
65
- if (!open) {
66
- setScrollTop(0);
67
- setMiddlewareType("align");
68
- setActiveIndex(null);
69
- setControlledScrolling(false);
70
- }
71
- });
72
- return () => cancelAnimationFrame(frame);
73
- }, [open]);
74
- const showUpArrow = showArrows && scrollTop > SCROLL_ARROW_THRESHOLD;
75
- const showDownArrow = showArrows && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
76
- return /* @__PURE__ */ React.createElement(SelectProvider, {
77
- scope: __scopeSelect,
78
- open
79
- }, children);
80
- }, "Select");
81
- Select.displayName = SELECT_NAME;
60
+ const OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
61
+ const SELECTION_KEYS = [" ", "Enter"];
82
62
  const TRIGGER_NAME = "SelectTrigger";
83
63
  const SelectTrigger = React.forwardRef((props, forwardedRef) => {
84
64
  const {
@@ -88,137 +68,189 @@ const SelectTrigger = React.forwardRef((props, forwardedRef) => {
88
68
  ...triggerProps
89
69
  } = props;
90
70
  const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
91
- const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
92
- const getItems = useCollection(__scopeSelect);
93
- const handleOpen = /* @__PURE__ */ __name(() => {
94
- if (!disabled) {
95
- context.onOpenChange(true);
96
- resetTypeahead();
97
- }
98
- }, "handleOpen");
99
- return /* @__PURE__ */ React.createElement(Primitive.button, {
100
- type: "button",
101
- role: "combobox",
102
- "aria-controls": context.contentId,
71
+ return /* @__PURE__ */ React.createElement(Button, {
72
+ componentName: TRIGGER_NAME,
103
73
  "aria-expanded": context.open,
104
74
  "aria-autocomplete": "none",
105
- dir: context.dir,
106
75
  disabled,
107
76
  "data-disabled": disabled ? "" : void 0,
108
77
  ...triggerProps,
109
- ref: composedRefs,
110
- onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
111
- ;
112
- event.target.releasePointerCapture(event.pointerId);
113
- if (event.button === 0 && event.ctrlKey === false) {
114
- handleOpen();
115
- context.triggerPointerDownPosRef.current = {
116
- x: Math.round(event.pageX),
117
- y: Math.round(event.pageY)
118
- };
119
- event.preventDefault();
120
- }
121
- }),
122
- onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
123
- const isTypingAhead = searchRef.current !== "";
124
- const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
125
- if (!isModifierKey && event.key.length === 1)
126
- handleTypeaheadSearch(event.key);
127
- if (isTypingAhead && event.key === " ")
128
- return;
129
- if (OPEN_KEYS.includes(event.key)) {
130
- handleOpen();
131
- event.preventDefault();
132
- }
133
- })
78
+ ref: forwardedRef,
79
+ ...context.interactions.getReferenceProps()
134
80
  });
135
81
  });
136
82
  SelectTrigger.displayName = TRIGGER_NAME;
137
83
  const VALUE_NAME = "SelectValue";
138
- const SelectValue = React.forwardRef((props, forwardedRef) => {
139
- const { __scopeSelect, className, style, ...valueProps } = props;
140
- return /* @__PURE__ */ React.createElement(XStack, {
141
- ...valueProps,
142
- pointerEvents: "none"
143
- });
84
+ const SelectValueFrame = styled(Paragraph, {
85
+ name: VALUE_NAME
144
86
  });
145
- const ICON_NAME = "SelectIcon";
146
- const SelectIcon = React.forwardRef((props, forwardedRef) => {
147
- const { __scopeSelect, children, ...iconProps } = props;
148
- return /* @__PURE__ */ React.createElement(XStack, {
149
- "aria-hidden": true,
150
- ...iconProps,
151
- ref: forwardedRef
152
- }, children || "\u25BC");
87
+ const SelectValue = SelectValueFrame.extractable(React.forwardRef(({ __scopeSelect, children, placeholder }, forwardedRef) => {
88
+ const context = useSelectContext(VALUE_NAME, __scopeSelect);
89
+ const { onValueNodeHasChildrenChange } = context;
90
+ const hasChildren = children !== void 0;
91
+ const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
92
+ React.useLayoutEffect(() => {
93
+ onValueNodeHasChildrenChange(hasChildren);
94
+ }, [onValueNodeHasChildrenChange, hasChildren]);
95
+ return /* @__PURE__ */ React.createElement(SelectValueFrame, {
96
+ ref: composedRefs,
97
+ pointerEvents: "none"
98
+ }, context.value === void 0 && placeholder !== void 0 ? placeholder : children);
99
+ }));
100
+ SelectValue.displayName = VALUE_NAME;
101
+ const SelectIcon = styled(XStack, {
102
+ name: "SelectIcon",
103
+ "aria-hidden": true,
104
+ children: /* @__PURE__ */ React.createElement(Paragraph, null, "\u25BC")
153
105
  });
154
- SelectIcon.displayName = ICON_NAME;
155
106
  const CONTENT_NAME = "SelectContent";
156
- const SelectContent = React.forwardRef((props, forwardedRef) => {
157
- const context = useSelectContext(CONTENT_NAME, props.__scopeSelect);
158
- return props.children;
107
+ const SelectContent = React.forwardRef(({ children, __scopeSelect }, forwardedRef) => {
108
+ const context = useSelectContext(CONTENT_NAME, __scopeSelect);
109
+ return /* @__PURE__ */ React.createElement(FloatingPortal, null, context.open ? /* @__PURE__ */ React.createElement(FloatingOverlay, {
110
+ lockScroll: true
111
+ }, children) : /* @__PURE__ */ React.createElement("div", {
112
+ style: { display: "none" }
113
+ }, children));
159
114
  });
160
- const GROUP_NAME = "SelectGroup";
161
- const [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
162
- const SelectGroup = React.forwardRef((props, forwardedRef) => {
163
- const { __scopeSelect, ...groupProps } = props;
164
- const groupId = useId();
165
- return /* @__PURE__ */ React.createElement(SelectGroupContextProvider, {
166
- scope: __scopeSelect,
167
- id: groupId
168
- }, /* @__PURE__ */ React.createElement(Primitive.div, {
169
- role: "group",
170
- "aria-labelledby": groupId,
171
- ...groupProps,
172
- ref: forwardedRef
173
- }));
115
+ const VIEWPORT_NAME = "SelectViewport";
116
+ const SelectViewportFrame = styled(ThemeableStack, {
117
+ name: VIEWPORT_NAME,
118
+ backgroundColor: "$background",
119
+ elevate: true,
120
+ variants: {
121
+ size: {
122
+ "...size": (val, { tokens }) => {
123
+ var _a;
124
+ return {
125
+ borderRadius: (_a = tokens.size[val]) != null ? _a : val
126
+ };
127
+ }
128
+ }
129
+ },
130
+ defaultVariants: {
131
+ size: "$2"
132
+ }
174
133
  });
175
- SelectGroup.displayName = GROUP_NAME;
176
- const LABEL_NAME = "SelectLabel";
177
- const SelectLabel = React.forwardRef((props, forwardedRef) => {
178
- const { __scopeSelect, ...labelProps } = props;
179
- const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
180
- return /* @__PURE__ */ React.createElement(Primitive.div, {
181
- id: groupContext.id,
182
- ...labelProps,
183
- ref: forwardedRef
184
- });
134
+ const SelectViewport = React.forwardRef((props, forwardedRef) => {
135
+ const { __scopeSelect, children, ...viewportProps } = props;
136
+ const context = useSelectContext(VIEWPORT_NAME, __scopeSelect);
137
+ const composedRefs = useComposedRefs(forwardedRef);
138
+ const prevScrollTopRef = React.useRef(0);
139
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", {
140
+ dangerouslySetInnerHTML: {
141
+ __html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
142
+ }
143
+ }), /* @__PURE__ */ React.createElement(FloatingFocusManager, {
144
+ context: context.floatingContext,
145
+ preventTabbing: true
146
+ }, /* @__PURE__ */ React.createElement("div", {
147
+ ...context.interactions.getFloatingProps()
148
+ }, /* @__PURE__ */ React.createElement(SelectViewportFrame, {
149
+ "data-radix-select-viewport": "",
150
+ role: "presentation",
151
+ ...viewportProps,
152
+ ref: composedRefs
153
+ }, children))));
185
154
  });
186
- SelectLabel.displayName = LABEL_NAME;
155
+ SelectViewport.displayName = VIEWPORT_NAME;
187
156
  const ITEM_NAME = "SelectItem";
188
157
  const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
158
+ const SelectItemFrame = styled(YStack, {
159
+ name: ITEM_NAME,
160
+ tag: "li",
161
+ role: "option",
162
+ width: "100%",
163
+ hoverStyle: {
164
+ backgroundColor: "$backgroundHover"
165
+ },
166
+ focusStyle: {
167
+ backgroundColor: "$backgroundFocus"
168
+ },
169
+ variants: {
170
+ size: {
171
+ "...size": getSelectItemSize
172
+ }
173
+ },
174
+ defaultVariants: {
175
+ size: "$4"
176
+ }
177
+ });
189
178
  const SelectItem = React.forwardRef((props, forwardedRef) => {
190
- const { __scopeSelect, value, disabled = false, textValue: textValueProp, ...itemProps } = props;
179
+ const {
180
+ __scopeSelect,
181
+ value,
182
+ disabled = false,
183
+ textValue: textValueProp,
184
+ index,
185
+ ...itemProps
186
+ } = props;
191
187
  const context = useSelectContext(ITEM_NAME, __scopeSelect);
192
- const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
193
188
  const isSelected = context.value === value;
194
189
  const [textValue, setTextValue] = React.useState(textValueProp != null ? textValueProp : "");
195
190
  const [isFocused, setIsFocused] = React.useState(false);
196
- const composedRefs = useComposedRefs(forwardedRef, isSelected ? contentContext.onSelectedItemChange : void 0);
197
191
  const textId = useId();
198
- const handleSelect = /* @__PURE__ */ __name(() => {
199
- if (!disabled) {
200
- context.onValueChange(value);
201
- context.onOpenChange(false);
192
+ const {
193
+ selectedIndex,
194
+ setSelectedIndex,
195
+ listRef,
196
+ open,
197
+ setOpen,
198
+ onChange,
199
+ activeIndex,
200
+ setActiveIndex,
201
+ dataRef
202
+ } = context;
203
+ const composedRefs = useComposedRefs(forwardedRef, (node) => {
204
+ console.log("node", node);
205
+ if (node instanceof HTMLElement) {
206
+ listRef.current[index] = node;
202
207
  }
203
- }, "handleSelect");
208
+ });
209
+ const timeoutRef = React.useRef();
210
+ const [allowMouseUp, setAllowMouseUp] = React.useState(false);
211
+ function handleSelect() {
212
+ console.log("handling select!");
213
+ setSelectedIndex(index);
214
+ onChange(value);
215
+ setOpen(false);
216
+ }
217
+ __name(handleSelect, "handleSelect");
218
+ React.useEffect(() => {
219
+ clearTimeout(timeoutRef.current);
220
+ if (open) {
221
+ if (selectedIndex !== index) {
222
+ setAllowMouseUp(true);
223
+ } else {
224
+ timeoutRef.current = setTimeout(() => {
225
+ setAllowMouseUp(true);
226
+ }, 300);
227
+ }
228
+ } else {
229
+ setAllowMouseUp(false);
230
+ }
231
+ }, [open, index, setActiveIndex, selectedIndex]);
232
+ function handleKeyDown(event) {
233
+ console.log("item key down");
234
+ if (event.key === "Enter" || event.key === " " && !dataRef.current.typing) {
235
+ event.preventDefault();
236
+ handleSelect();
237
+ }
238
+ }
239
+ __name(handleKeyDown, "handleKeyDown");
240
+ const selectItemProps = context.interactions.getItemProps({
241
+ onClick: allowMouseUp ? handleSelect : void 0,
242
+ onMouseUp: allowMouseUp ? handleSelect : void 0,
243
+ onKeyDown: handleKeyDown
244
+ });
204
245
  return /* @__PURE__ */ React.createElement(SelectItemContextProvider, {
205
246
  scope: __scopeSelect,
206
247
  value,
207
- textId,
248
+ textId: textId || "",
208
249
  isSelected,
209
250
  onItemTextChange: React.useCallback((node) => {
210
- setTextValue((prevTextValue) => {
211
- var _a;
212
- return prevTextValue || ((_a = node == null ? void 0 : node.textContent) != null ? _a : "").trim();
213
- });
214
251
  }, [])
215
- }, /* @__PURE__ */ React.createElement(Collection.ItemSlot, {
216
- scope: __scopeSelect,
217
- value,
218
- disabled,
219
- textValue
220
- }, /* @__PURE__ */ React.createElement(Primitive.div, {
221
- role: "option",
252
+ }, /* @__PURE__ */ React.createElement(SelectItemFrame, {
253
+ ref: composedRefs,
222
254
  "aria-labelledby": textId,
223
255
  "aria-selected": isSelected && isFocused,
224
256
  "data-state": isSelected ? "active" : "inactive",
@@ -226,166 +258,594 @@ const SelectItem = React.forwardRef((props, forwardedRef) => {
226
258
  "data-disabled": disabled ? "" : void 0,
227
259
  tabIndex: disabled ? void 0 : -1,
228
260
  ...itemProps,
229
- ref: composedRefs,
230
- onFocus: composeEventHandlers(itemProps.onFocus, () => setIsFocused(true)),
231
- onBlur: composeEventHandlers(itemProps.onBlur, () => setIsFocused(false)),
232
- onPointerUp: composeEventHandlers(itemProps.onPointerUp, handleSelect),
233
- onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
234
- if (disabled) {
235
- contentContext.onItemLeave();
236
- } else {
237
- event.currentTarget.focus({ preventScroll: true });
238
- }
239
- }),
240
- onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
241
- if (event.currentTarget === document.activeElement) {
242
- contentContext.onItemLeave();
243
- }
244
- }),
245
- onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
246
- const isTypingAhead = contentContext.searchRef.current !== "";
247
- if (isTypingAhead && event.key === " ")
248
- return;
249
- if (SELECTION_KEYS.includes(event.key))
250
- handleSelect();
251
- if (event.key === " ")
252
- event.preventDefault();
253
- })
254
- })));
261
+ ...selectItemProps
262
+ }));
255
263
  });
256
264
  SelectItem.displayName = ITEM_NAME;
257
265
  const ITEM_TEXT_NAME = "SelectItemText";
266
+ const SelectItemTextFrame = styled(Paragraph, {
267
+ name: ITEM_TEXT_NAME,
268
+ cursor: "default"
269
+ });
258
270
  const SelectItemText = React.forwardRef((props, forwardedRef) => {
259
- var _a;
260
271
  const { __scopeSelect, className, style, ...itemTextProps } = props;
261
272
  const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
262
- const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
263
273
  const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
264
274
  const ref = React.useRef(null);
265
- const composedRefs = useComposedRefs(forwardedRef, ref, itemContext.onItemTextChange, itemContext.isSelected ? contentContext.onSelectedItemTextChange : void 0);
266
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Primitive.span, {
275
+ const composedRefs = useComposedRefs(forwardedRef, ref, itemContext.onItemTextChange);
276
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SelectItemTextFrame, {
267
277
  id: itemContext.textId,
268
278
  ...itemTextProps,
269
279
  ref: composedRefs
270
- }), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null, context.bubbleSelect ? ReactDOM.createPortal(/* @__PURE__ */ React.createElement("option", {
271
- value: itemContext.value
272
- }, (_a = ref.current) == null ? void 0 : _a.textContent), context.bubbleSelect) : null);
280
+ }), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null);
273
281
  });
274
282
  SelectItemText.displayName = ITEM_TEXT_NAME;
275
283
  const ITEM_INDICATOR_NAME = "SelectItemIndicator";
284
+ const SelectItemIndicatorFrame = styled(XStack, {
285
+ name: ITEM_TEXT_NAME
286
+ });
276
287
  const SelectItemIndicator = React.forwardRef((props, forwardedRef) => {
277
288
  const { __scopeSelect, ...itemIndicatorProps } = props;
278
289
  const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
279
- return itemContext.isSelected ? /* @__PURE__ */ React.createElement(Primitive.span, {
290
+ return itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, {
280
291
  "aria-hidden": true,
281
292
  ...itemIndicatorProps,
282
293
  ref: forwardedRef
283
294
  }) : null;
284
295
  });
285
296
  SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
297
+ const GROUP_NAME = "SelectGroup";
298
+ const [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
299
+ const SelectGroupFrame = styled(YStack, {
300
+ name: GROUP_NAME,
301
+ width: "100%"
302
+ });
303
+ const SelectGroup = React.forwardRef((props, forwardedRef) => {
304
+ const { __scopeSelect, ...groupProps } = props;
305
+ const groupId = useId();
306
+ return /* @__PURE__ */ React.createElement(SelectGroupContextProvider, {
307
+ scope: __scopeSelect,
308
+ id: groupId || ""
309
+ }, /* @__PURE__ */ React.createElement(SelectGroupFrame, {
310
+ role: "group",
311
+ "aria-labelledby": groupId,
312
+ ...groupProps,
313
+ ref: forwardedRef
314
+ }));
315
+ });
316
+ SelectGroup.displayName = GROUP_NAME;
317
+ const LABEL_NAME = "SelectLabel";
318
+ const SelectLabelFrame = styled(SelectItemTextFrame, {
319
+ name: LABEL_NAME,
320
+ variants: {
321
+ size: {
322
+ "...size": (val, extras) => {
323
+ const size2 = getSelectItemSize(val, extras);
324
+ return {
325
+ ...size2,
326
+ paddingTop: size2.paddingVertical * 4
327
+ };
328
+ }
329
+ }
330
+ },
331
+ defaultVariants: {
332
+ size: "$4"
333
+ }
334
+ });
335
+ const SelectLabel = React.forwardRef((props, forwardedRef) => {
336
+ const { __scopeSelect, ...labelProps } = props;
337
+ const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
338
+ return /* @__PURE__ */ React.createElement(SelectLabelFrame, {
339
+ id: groupContext.id,
340
+ ...labelProps,
341
+ ref: forwardedRef
342
+ });
343
+ });
344
+ SelectLabel.displayName = LABEL_NAME;
286
345
  const SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
287
346
  const SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
288
- const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
289
- const [canScrollUp, setCanScrollUp] = React.useState(false);
290
- const composedRefs = useComposedRefs(forwardedRef, contentContext.onScrollButtonChange);
291
- return canScrollUp ? /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
347
+ return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
348
+ componentName: SCROLL_UP_BUTTON_NAME,
292
349
  ...props,
293
- ref: composedRefs,
294
- onAutoScroll: () => {
295
- const { viewport, selectedItem } = contentContext;
296
- if (viewport && selectedItem) {
297
- viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
298
- }
299
- }
300
- }) : null;
350
+ dir: "up",
351
+ ref: forwardedRef
352
+ });
301
353
  });
302
354
  SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
303
355
  const SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
304
356
  const SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
305
- const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
306
- const [canScrollDown, setCanScrollDown] = React.useState(false);
307
- const composedRefs = useComposedRefs(forwardedRef, contentContext.onScrollButtonChange);
308
- return canScrollDown ? /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
357
+ return /* @__PURE__ */ React.createElement(SelectScrollButtonImpl, {
358
+ componentName: SCROLL_DOWN_BUTTON_NAME,
309
359
  ...props,
310
- ref: composedRefs,
311
- onAutoScroll: () => {
312
- const { viewport, selectedItem } = contentContext;
313
- if (viewport && selectedItem) {
314
- viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
315
- }
316
- }
317
- }) : null;
360
+ dir: "down",
361
+ ref: forwardedRef
362
+ });
318
363
  });
319
364
  SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
320
365
  const SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
321
- const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
322
- const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
323
- const autoScrollTimerRef = React.useRef(null);
366
+ var _a, _b;
367
+ const { __scopeSelect, dir, componentName, ...scrollIndicatorProps } = props;
368
+ const { floatingRef, increaseHeight, forceUpdate, ...context } = useSelectContext(componentName, __scopeSelect);
324
369
  const intervalRef = React.useRef();
325
370
  const loopingRef = React.useRef(false);
371
+ const isVisible = context[dir === "down" ? "canScrollDown" : "canScrollUp"];
326
372
  const { x, y, reference, floating, strategy, update, refs } = useFloating({
327
373
  strategy: "fixed",
328
374
  placement: dir === "up" ? "top" : "bottom",
329
- middleware: [offset(({ floating: floating2 }) => -floating2.height)]
375
+ middleware: [offset(({ rects }) => -rects.floating.height)]
330
376
  });
331
- return /* @__PURE__ */ React.createElement(Primitive.div, {
377
+ const composedRefs = useComposedRefs(forwardedRef, floating);
378
+ React.useLayoutEffect(() => {
379
+ reference(floatingRef.current);
380
+ }, [reference, floatingRef.current]);
381
+ React.useEffect(() => {
382
+ if (!refs.reference.current || !refs.floating.current || !isVisible) {
383
+ return;
384
+ }
385
+ const cleanup = autoUpdate(refs.reference.current, refs.floating.current, update, {
386
+ animationFrame: true
387
+ });
388
+ return () => {
389
+ clearInterval(intervalRef.current);
390
+ loopingRef.current = false;
391
+ cleanup();
392
+ };
393
+ }, [isVisible, update, refs.floating, refs.reference]);
394
+ if (!isVisible) {
395
+ return null;
396
+ }
397
+ const handleScrollArrowChange = /* @__PURE__ */ __name(() => {
398
+ const floating2 = floatingRef.current;
399
+ const isUp = dir === "up";
400
+ if (floating2) {
401
+ const value = isUp ? -SCROLL_ARROW_VELOCITY : SCROLL_ARROW_VELOCITY;
402
+ const multi = isUp && floating2.scrollTop <= SCROLL_ARROW_THRESHOLD * 2 || !isUp && floating2.scrollTop >= floating2.scrollHeight - floating2.clientHeight - SCROLL_ARROW_THRESHOLD * 2 ? 2 : 1;
403
+ floating2.scrollTop += multi * (isUp ? -SCROLL_ARROW_VELOCITY : SCROLL_ARROW_VELOCITY);
404
+ increaseHeight(floating2, multi === 2 ? value * 2 : value);
405
+ forceUpdate();
406
+ }
407
+ }, "handleScrollArrowChange");
408
+ return /* @__PURE__ */ React.createElement(YStack, {
409
+ ref: composedRefs,
410
+ componentName,
332
411
  "aria-hidden": true,
333
412
  ...scrollIndicatorProps,
334
- ref: forwardedRef,
335
- style: { flexShrink: 0, ...scrollIndicatorProps.style },
336
- onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
337
- contentContext.onItemLeave();
338
- if (autoScrollTimerRef.current === null) {
339
- autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
413
+ position: strategy,
414
+ left: x || 0,
415
+ top: y || 0,
416
+ width: `calc(${((_b = (_a = floatingRef.current) == null ? void 0 : _a.offsetWidth) != null ? _b : 0) - 2}px)`,
417
+ background: `linear-gradient(to ${dir === "up" ? "bottom" : "top"}, #29282b 50%, rgba(53, 54, 55, 0.01))`,
418
+ onPointerMove: () => {
419
+ if (!loopingRef.current) {
420
+ intervalRef.current = setInterval(handleScrollArrowChange, 1e3 / 60);
421
+ loopingRef.current = true;
340
422
  }
341
- }),
342
- onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
343
- clearAutoScrollTimer();
344
- })
423
+ },
424
+ onPointerLeave: () => {
425
+ loopingRef.current = false;
426
+ clearInterval(intervalRef.current);
427
+ }
345
428
  });
346
429
  });
347
- const SEPARATOR_NAME = "SelectSeparator";
348
- const SelectSeparator = Separator;
349
- SelectSeparator.displayName = SEPARATOR_NAME;
350
- const BubbleSelect = React.forwardRef((props, forwardedRef) => {
351
- const { value, ...selectProps } = props;
352
- const ref = React.useRef(null);
353
- const composedRefs = useComposedRefs(forwardedRef, ref);
354
- const prevValue = usePrevious(value);
430
+ const SelectSeparator = styled(Separator, {
431
+ name: "SelectSeparator"
432
+ });
433
+ const Select = withStaticProperties((props) => {
434
+ var _a;
435
+ const {
436
+ __scopeSelect,
437
+ children,
438
+ open: openProp,
439
+ defaultOpen,
440
+ onOpenChange,
441
+ value: valueProp,
442
+ defaultValue,
443
+ onValueChange,
444
+ dir,
445
+ name,
446
+ autoComplete
447
+ } = props;
448
+ const [open, setOpen] = useControllableState({
449
+ prop: openProp,
450
+ defaultProp: defaultOpen || false,
451
+ onChange: onOpenChange
452
+ });
453
+ const [value, setValue] = useControllableState({
454
+ prop: valueProp,
455
+ defaultProp: defaultValue || "",
456
+ onChange: onValueChange
457
+ });
458
+ const [activeIndex, setActiveIndex] = React.useState(null);
459
+ const selectedIndexRef = React.useRef(null);
460
+ const activeIndexRef = React.useRef(null);
461
+ const prevActiveIndex = usePrevious(activeIndex);
462
+ const [showArrows, setShowArrows] = React.useState(false);
463
+ const [scrollTop, setScrollTop] = React.useState(0);
464
+ const listItemsRef = React.useRef([]);
465
+ const listContentRef = React.useRef([
466
+ "Select...",
467
+ ...(_a = React.Children.map(children, (child) => React.Children.map(React.isValidElement(child) && child.props.children, (child2) => child2.props.value))) != null ? _a : []
468
+ ]);
469
+ const [selectedIndex, setSelectedIndex] = React.useState(Math.max(0, listContentRef.current.indexOf(value)));
470
+ const [controlledScrolling, setControlledScrolling] = React.useState(false);
471
+ const [middlewareType, setMiddlewareType] = React.useState("align");
472
+ useIsomorphicLayoutEffect(() => {
473
+ selectedIndexRef.current = selectedIndex;
474
+ activeIndexRef.current = activeIndex;
475
+ });
355
476
  React.useEffect(() => {
356
- const select = ref.current;
357
- const selectProto = window.HTMLSelectElement.prototype;
358
- const descriptor = Object.getOwnPropertyDescriptor(selectProto, "value");
359
- const setValue = descriptor.set;
360
- if (prevValue !== value && setValue) {
361
- const event = new Event("change", { bubbles: true });
362
- setValue.call(select, value);
363
- select.dispatchEvent(event);
477
+ const frame = requestAnimationFrame(() => {
478
+ setShowArrows(open);
479
+ if (!open) {
480
+ setScrollTop(0);
481
+ setMiddlewareType("align");
482
+ setActiveIndex(null);
483
+ setControlledScrolling(false);
484
+ }
485
+ });
486
+ return () => {
487
+ cancelAnimationFrame(frame);
488
+ };
489
+ }, [open]);
490
+ function getFloatingPadding(floating2) {
491
+ var _a2;
492
+ if (!floating2) {
493
+ return 0;
364
494
  }
365
- }, [prevValue, value]);
366
- return null;
367
- return /* @__PURE__ */ React.createElement(VisuallyHidden, {
368
- asChild: true
369
- }, /* @__PURE__ */ React.createElement("select", {
370
- ...selectProps,
371
- ref: composedRefs,
372
- defaultValue: value
373
- }));
495
+ return Number((_a2 = getComputedStyle(floating2).paddingLeft) == null ? void 0 : _a2.replace("px", ""));
496
+ }
497
+ __name(getFloatingPadding, "getFloatingPadding");
498
+ const { x, y, reference, floating, strategy, context, refs, middlewareData, update } = useFloating({
499
+ open,
500
+ onOpenChange: setOpen,
501
+ placement: "bottom",
502
+ middleware: middlewareType === "align" ? [
503
+ offset(({ rects }) => {
504
+ var _a2;
505
+ const index = (_a2 = activeIndexRef.current) != null ? _a2 : selectedIndexRef.current;
506
+ if (index == null) {
507
+ return 0;
508
+ }
509
+ const item = listItemsRef.current[index];
510
+ if (item == null) {
511
+ return 0;
512
+ }
513
+ const offsetTop = item.offsetTop;
514
+ const itemHeight = item.offsetHeight;
515
+ const height = rects.reference.height;
516
+ return -offsetTop - height - (itemHeight - height) / 2;
517
+ }),
518
+ {
519
+ name: "size",
520
+ async fn(args) {
521
+ var _a2;
522
+ const {
523
+ elements: { floating: floating2 },
524
+ rects: { reference: reference2 },
525
+ middlewareData: middlewareData2
526
+ } = args;
527
+ const overflow = await detectOverflow(args, {
528
+ padding: WINDOW_PADDING
529
+ });
530
+ const top = Math.max(0, overflow.top);
531
+ const bottom = Math.max(0, overflow.bottom);
532
+ const nextY = args.y + top;
533
+ if ((_a2 = middlewareData2.size) == null ? void 0 : _a2.skip) {
534
+ return {
535
+ y: nextY,
536
+ data: {
537
+ y: middlewareData2.size.y
538
+ }
539
+ };
540
+ }
541
+ Object.assign(floating2.style, {
542
+ maxHeight: `${floating2.scrollHeight - Math.abs(top + bottom)}px`,
543
+ minWidth: `${reference2.width + getFloatingPadding(floating2) * 2}px`
544
+ });
545
+ return {
546
+ y: nextY,
547
+ data: {
548
+ y: top,
549
+ skip: true
550
+ },
551
+ reset: {
552
+ rects: true
553
+ }
554
+ };
555
+ }
556
+ }
557
+ ] : [
558
+ offset(5),
559
+ flip(),
560
+ size({
561
+ apply({ rects, availableHeight, elements }) {
562
+ Object.assign(elements.floating.style, {
563
+ width: `${rects.reference.width}px`,
564
+ maxHeight: `${availableHeight}px`
565
+ });
566
+ },
567
+ padding: WINDOW_PADDING
568
+ })
569
+ ]
570
+ });
571
+ const floatingRef = refs.floating;
572
+ const forceUpdate = React.useReducer(() => ({}), {})[1];
573
+ const showUpArrow = showArrows && scrollTop > SCROLL_ARROW_THRESHOLD;
574
+ const showDownArrow = showArrows && floatingRef.current && scrollTop < floatingRef.current.scrollHeight - floatingRef.current.clientHeight - SCROLL_ARROW_THRESHOLD;
575
+ console.log("Select", {
576
+ activeIndex,
577
+ selectedIndex
578
+ });
579
+ const interactions = useInteractions([
580
+ useClick(context, { pointerDown: true }),
581
+ useRole(context, { role: "listbox" }),
582
+ useDismiss(context),
583
+ useListNavigation(context, {
584
+ listRef: listItemsRef,
585
+ activeIndex,
586
+ selectedIndex,
587
+ onNavigate: setActiveIndex
588
+ }),
589
+ useTypeahead(context, {
590
+ listRef: listContentRef,
591
+ onMatch: open ? setActiveIndex : setSelectedIndex,
592
+ selectedIndex,
593
+ activeIndex
594
+ })
595
+ ]);
596
+ const increaseHeight = React.useCallback((floating2, amount = 0) => {
597
+ if (middlewareType === "fallback") {
598
+ return;
599
+ }
600
+ const currentMaxHeight = Number(floating2.style.maxHeight.replace("px", ""));
601
+ const currentTop = Number(floating2.style.top.replace("px", ""));
602
+ const rect = floating2.getBoundingClientRect();
603
+ const rectTop = rect.top;
604
+ const rectBottom = rect.bottom;
605
+ const visualMaxHeight = visualViewport.height - WINDOW_PADDING * 2;
606
+ if (amount < 0 && selectedIndexRef.current != null && Math.round(rectBottom) < Math.round(visualViewport.height + getVisualOffsetTop() - WINDOW_PADDING)) {
607
+ floating2.style.maxHeight = `${Math.min(visualMaxHeight, currentMaxHeight - amount)}px`;
608
+ }
609
+ if (amount > 0 && Math.round(rectTop) > Math.round(WINDOW_PADDING - getVisualOffsetTop()) && floating2.scrollHeight > floating2.offsetHeight) {
610
+ const nextTop = Math.max(WINDOW_PADDING + getVisualOffsetTop(), currentTop - amount);
611
+ const nextMaxHeight = Math.min(visualMaxHeight, currentMaxHeight + amount);
612
+ Object.assign(floating2.style, {
613
+ maxHeight: `${nextMaxHeight}px`,
614
+ top: `${nextTop}px`
615
+ });
616
+ if (nextTop - WINDOW_PADDING > getVisualOffsetTop()) {
617
+ floating2.scrollTop -= nextMaxHeight - currentMaxHeight + getFloatingPadding(floating2);
618
+ }
619
+ return currentTop - nextTop;
620
+ }
621
+ }, [middlewareType]);
622
+ const touchPageYRef = React.useRef(null);
623
+ const handleWheel = React.useCallback((event) => {
624
+ var _a2, _b;
625
+ const pinching = event.ctrlKey;
626
+ const currentTarget = event.currentTarget;
627
+ function isWheelEvent(event2) {
628
+ return typeof event2.deltaY === "number";
629
+ }
630
+ __name(isWheelEvent, "isWheelEvent");
631
+ function isTouchEvent(event2) {
632
+ return event2.touches != null;
633
+ }
634
+ __name(isTouchEvent, "isTouchEvent");
635
+ if (Math.abs(((_a2 = currentTarget == null ? void 0 : currentTarget.offsetHeight) != null ? _a2 : 0) - (visualViewport.height - WINDOW_PADDING * 2)) > 1 && !pinching) {
636
+ event.preventDefault();
637
+ } else if (isWheelEvent(event) && isFirefox) {
638
+ currentTarget.scrollTop += event.deltaY;
639
+ }
640
+ if (!pinching) {
641
+ let delta = 5;
642
+ if (isTouchEvent(event)) {
643
+ const currentPageY = touchPageYRef.current;
644
+ const pageY = (_b = event.touches[0]) == null ? void 0 : _b.pageY;
645
+ if (pageY != null) {
646
+ touchPageYRef.current = pageY;
647
+ if (currentPageY != null) {
648
+ delta = currentPageY - pageY;
649
+ }
650
+ }
651
+ }
652
+ increaseHeight(currentTarget, isWheelEvent(event) ? event.deltaY : delta);
653
+ setScrollTop(currentTarget.scrollTop);
654
+ forceUpdate();
655
+ }
656
+ }, [increaseHeight, forceUpdate]);
657
+ React.useEffect(() => {
658
+ function onTouchEnd() {
659
+ touchPageYRef.current = null;
660
+ }
661
+ __name(onTouchEnd, "onTouchEnd");
662
+ const floating2 = floatingRef.current;
663
+ if (open && floating2 && middlewareType === "align") {
664
+ floating2.addEventListener("wheel", handleWheel);
665
+ floating2.addEventListener("touchmove", handleWheel);
666
+ floating2.addEventListener("touchend", onTouchEnd, { passive: true });
667
+ return () => {
668
+ floating2.removeEventListener("wheel", handleWheel);
669
+ floating2.removeEventListener("touchmove", handleWheel);
670
+ floating2.removeEventListener("touchend", onTouchEnd);
671
+ };
672
+ }
673
+ }, [open, floatingRef, handleWheel, middlewareType]);
674
+ React.useEffect(() => {
675
+ window.addEventListener("resize", update);
676
+ return () => {
677
+ window.removeEventListener("resize", update);
678
+ };
679
+ }, [update]);
680
+ React.useLayoutEffect(() => {
681
+ var _a2, _b, _c;
682
+ const floating2 = floatingRef.current;
683
+ if (open && controlledScrolling && floating2) {
684
+ const item = activeIndex != null ? listItemsRef.current[activeIndex] : selectedIndex != null ? listItemsRef.current[selectedIndex] : null;
685
+ if (item && prevActiveIndex != null) {
686
+ const itemHeight = (_b = (_a2 = listItemsRef.current[prevActiveIndex]) == null ? void 0 : _a2.offsetHeight) != null ? _b : 0;
687
+ const floatingHeight = floating2.offsetHeight;
688
+ const top = item.offsetTop;
689
+ const bottom = top + itemHeight;
690
+ if (top < floating2.scrollTop + 20) {
691
+ const diff = floating2.scrollTop - top + 20;
692
+ floating2.scrollTop -= diff;
693
+ if (activeIndex != selectedIndex && activeIndex != null) {
694
+ increaseHeight(floating2, -diff);
695
+ }
696
+ } else if (bottom > floatingHeight + floating2.scrollTop - 20) {
697
+ const diff = bottom - floatingHeight - floating2.scrollTop + 20;
698
+ floating2.scrollTop += diff;
699
+ if (activeIndex != selectedIndex && activeIndex != null) {
700
+ floating2.scrollTop -= (_c = increaseHeight(floating2, diff)) != null ? _c : 0;
701
+ }
702
+ }
703
+ }
704
+ }
705
+ }, [
706
+ open,
707
+ controlledScrolling,
708
+ prevActiveIndex,
709
+ activeIndex,
710
+ selectedIndex,
711
+ floatingRef,
712
+ increaseHeight
713
+ ]);
714
+ React.useLayoutEffect(() => {
715
+ var _a2;
716
+ const floating2 = refs.floating.current;
717
+ const reference2 = refs.reference.current;
718
+ if (open && floating2 && reference2 && floating2.offsetHeight < floating2.scrollHeight) {
719
+ const referenceRect = reference2.getBoundingClientRect();
720
+ if (middlewareType === "fallback") {
721
+ const item = listItemsRef.current[selectedIndex];
722
+ if (item) {
723
+ floating2.scrollTop = item.offsetTop - floating2.clientHeight + referenceRect.height;
724
+ }
725
+ return;
726
+ }
727
+ floating2.scrollTop = (_a2 = middlewareData.size) == null ? void 0 : _a2.y;
728
+ const closeToBottom = visualViewport.height + getVisualOffsetTop() - referenceRect.bottom < FALLBACK_THRESHOLD;
729
+ const closeToTop = referenceRect.top < FALLBACK_THRESHOLD;
730
+ if (floating2.offsetHeight < MIN_HEIGHT || closeToTop || closeToBottom) {
731
+ setMiddlewareType("fallback");
732
+ }
733
+ }
734
+ }, [
735
+ open,
736
+ increaseHeight,
737
+ selectedIndex,
738
+ middlewareType,
739
+ refs.floating,
740
+ refs.reference,
741
+ middlewareData
742
+ ]);
743
+ React.useLayoutEffect(() => {
744
+ console.log("focusin", selectedIndex, listItemsRef.current[selectedIndex], listItemsRef.current);
745
+ if (open && selectedIndex != null) {
746
+ requestAnimationFrame(() => {
747
+ var _a2;
748
+ (_a2 = listItemsRef.current[selectedIndex]) == null ? void 0 : _a2.focus({ preventScroll: true });
749
+ });
750
+ }
751
+ }, [listItemsRef, selectedIndex, open]);
752
+ React.useEffect(() => {
753
+ const frame = requestAnimationFrame(() => {
754
+ setShowArrows(open);
755
+ if (!open) {
756
+ setScrollTop(0);
757
+ setMiddlewareType("align");
758
+ setActiveIndex(null);
759
+ setControlledScrolling(false);
760
+ }
761
+ });
762
+ return () => cancelAnimationFrame(frame);
763
+ }, [open]);
764
+ const [valueNode, setValueNode] = React.useState(null);
765
+ const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
766
+ return /* @__PURE__ */ React.createElement(SelectProvider, {
767
+ scope: __scopeSelect,
768
+ increaseHeight,
769
+ forceUpdate,
770
+ floatingRef,
771
+ valueNode,
772
+ onValueNodeChange: setValueNode,
773
+ valueNodeHasChildren,
774
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
775
+ interactions: {
776
+ ...interactions,
777
+ getReferenceProps() {
778
+ return interactions.getReferenceProps({
779
+ ref: reference,
780
+ className: "SelectTrigger",
781
+ onKeyDown(event) {
782
+ if (event.key === "Enter" || event.key === " " && !context.dataRef.current.typing) {
783
+ event.preventDefault();
784
+ setOpen(true);
785
+ }
786
+ }
787
+ });
788
+ },
789
+ getFloatingProps() {
790
+ return interactions.getFloatingProps({
791
+ ref: floating,
792
+ className: "Select",
793
+ style: {
794
+ position: strategy,
795
+ top: y != null ? y : "",
796
+ left: x != null ? x : ""
797
+ },
798
+ onPointerEnter() {
799
+ setControlledScrolling(false);
800
+ },
801
+ onPointerMove() {
802
+ setControlledScrolling(false);
803
+ },
804
+ onKeyDown() {
805
+ setControlledScrolling(true);
806
+ },
807
+ onScroll(event) {
808
+ setScrollTop(event.currentTarget.scrollTop);
809
+ }
810
+ });
811
+ }
812
+ },
813
+ floatingContext: context,
814
+ activeIndex,
815
+ canScrollDown: !!showDownArrow,
816
+ canScrollUp: !!showUpArrow,
817
+ controlledScrolling: true,
818
+ dataRef: context.dataRef,
819
+ listRef: listItemsRef,
820
+ onChange: setValue,
821
+ selectedIndex: 0,
822
+ setActiveIndex,
823
+ setOpen,
824
+ setSelectedIndex,
825
+ value,
826
+ open
827
+ }, children);
828
+ }, {
829
+ Content: SelectContent,
830
+ Group: SelectGroup,
831
+ Icon: SelectIcon,
832
+ Item: SelectItem,
833
+ ItemIndicator: SelectItemIndicator,
834
+ ItemText: SelectItemText,
835
+ Label: SelectLabel,
836
+ ScrollDownButton: SelectScrollDownButton,
837
+ ScrollUpButton: SelectScrollUpButton,
838
+ Trigger: SelectTrigger,
839
+ Value: SelectValue,
840
+ Viewport: SelectViewport
374
841
  });
842
+ Select.displayName = SELECT_NAME;
375
843
  export {
376
844
  Select,
377
- SelectContent,
378
- SelectGroup,
379
845
  SelectIcon,
380
- SelectItem,
381
- SelectItemIndicator,
382
- SelectItemText,
383
- SelectLabel,
384
- SelectScrollDownButton,
385
- SelectScrollUpButton,
386
846
  SelectSeparator,
387
847
  SelectTrigger,
388
- SelectValue,
848
+ SelectViewportFrame,
389
849
  createSelectScope
390
850
  };
391
851
  //# sourceMappingURL=Select.js.map