@tamagui/select 1.0.1-beta.149 → 1.0.1-beta.152

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/cjs/BubbleSelect.js +24 -19
  2. package/dist/cjs/BubbleSelect.js.map +1 -1
  3. package/dist/cjs/Select.js +342 -301
  4. package/dist/cjs/Select.js.map +3 -3
  5. package/dist/cjs/SelectContent.js +18 -15
  6. package/dist/cjs/SelectContent.js.map +1 -1
  7. package/dist/cjs/SelectContent.native.js.map +1 -1
  8. package/dist/cjs/SelectImpl.js +9 -4
  9. package/dist/cjs/SelectImpl.js.map +2 -2
  10. package/dist/cjs/SelectScrollButton.js +109 -95
  11. package/dist/cjs/SelectScrollButton.js.map +2 -2
  12. package/dist/cjs/SelectViewport.js +49 -35
  13. package/dist/cjs/SelectViewport.js.map +2 -2
  14. package/dist/cjs/SelectViewport.native.js +5 -7
  15. package/dist/cjs/SelectViewport.native.js.map +1 -1
  16. package/dist/cjs/context.js.map +1 -1
  17. package/dist/esm/BubbleSelect.js +20 -18
  18. package/dist/esm/BubbleSelect.js.map +1 -1
  19. package/dist/esm/Select.js +338 -300
  20. package/dist/esm/Select.js.map +3 -3
  21. package/dist/esm/SelectContent.js +18 -12
  22. package/dist/esm/SelectContent.js.map +1 -1
  23. package/dist/esm/SelectContent.native.js.map +1 -1
  24. package/dist/esm/SelectImpl.js +5 -3
  25. package/dist/esm/SelectImpl.js.map +2 -2
  26. package/dist/esm/SelectScrollButton.js +105 -94
  27. package/dist/esm/SelectScrollButton.js.map +2 -2
  28. package/dist/esm/SelectViewport.js +45 -34
  29. package/dist/esm/SelectViewport.js.map +1 -1
  30. package/dist/esm/SelectViewport.native.js +5 -4
  31. package/dist/esm/SelectViewport.native.js.map +1 -1
  32. package/dist/esm/context.js.map +1 -1
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/jsx/BubbleSelect.js +20 -18
  35. package/dist/jsx/BubbleSelect.js.map +1 -1
  36. package/dist/jsx/Select.js +217 -196
  37. package/dist/jsx/Select.js.map +3 -3
  38. package/dist/jsx/SelectContent.js.map +1 -1
  39. package/dist/jsx/SelectContent.native.js.map +1 -1
  40. package/dist/jsx/SelectImpl.js.map +2 -2
  41. package/dist/jsx/SelectScrollButton.js +79 -69
  42. package/dist/jsx/SelectScrollButton.js.map +1 -1
  43. package/dist/jsx/SelectViewport.js +25 -23
  44. package/dist/jsx/SelectViewport.js.map +1 -1
  45. package/dist/jsx/SelectViewport.native.js.map +1 -1
  46. package/dist/jsx/context.js.map +1 -1
  47. package/dist/jsx/index.js.map +1 -1
  48. package/package.json +12 -12
  49. package/src/Select.tsx +1 -1
@@ -1,3 +1,4 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
2
  import { useComposedRefs } from "@tamagui/compose-refs";
2
3
  import { isWeb, useMedia } from "@tamagui/core";
3
4
  import { styled, useGet, useIsomorphicLayoutEffect, withStaticProperties } from "@tamagui/core";
@@ -18,211 +19,232 @@ import { SelectInlineImpl } from "./SelectImpl";
18
19
  import { SelectScrollDownButton, SelectScrollUpButton } from "./SelectScrollButton";
19
20
  import { SelectViewport } from "./SelectViewport";
20
21
  const TRIGGER_NAME = "SelectTrigger";
21
- const SelectTrigger = React.forwardRef((props, forwardedRef) => {
22
- const {
23
- __scopeSelect,
24
- disabled = false,
25
- "aria-labelledby": ariaLabelledby,
26
- ...triggerProps
27
- } = props;
28
- const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
29
- const labelledBy = ariaLabelledby;
30
- return /* @__PURE__ */ React.createElement(ListItem, {
31
- componentName: TRIGGER_NAME,
32
- backgrounded: true,
33
- radiused: true,
34
- hoverTheme: true,
35
- pressTheme: true,
36
- focusTheme: true,
37
- focusable: true,
38
- borderWidth: 1,
39
- size: context.size,
40
- "aria-expanded": context.open,
41
- "aria-autocomplete": "none",
42
- "aria-labelledby": labelledBy,
43
- dir: context.dir,
44
- disabled,
45
- "data-disabled": disabled ? "" : void 0,
46
- ...triggerProps,
47
- ref: forwardedRef,
48
- ...context.interactions ? context.interactions.getReferenceProps() : {
49
- onPress() {
50
- context.setOpen(!context.open);
22
+ const SelectTrigger = React.forwardRef(
23
+ (props, forwardedRef) => {
24
+ const {
25
+ __scopeSelect,
26
+ disabled = false,
27
+ "aria-labelledby": ariaLabelledby,
28
+ ...triggerProps
29
+ } = props;
30
+ const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
31
+ const labelledBy = ariaLabelledby;
32
+ return /* @__PURE__ */ jsx(ListItem, {
33
+ componentName: TRIGGER_NAME,
34
+ backgrounded: true,
35
+ radiused: true,
36
+ hoverTheme: true,
37
+ pressTheme: true,
38
+ focusTheme: true,
39
+ focusable: true,
40
+ borderWidth: 1,
41
+ size: context.size,
42
+ "aria-expanded": context.open,
43
+ "aria-autocomplete": "none",
44
+ "aria-labelledby": labelledBy,
45
+ dir: context.dir,
46
+ disabled,
47
+ "data-disabled": disabled ? "" : void 0,
48
+ ...triggerProps,
49
+ ref: forwardedRef,
50
+ ...process.env.TAMAGUI_TARGET === "web" && context.interactions ? context.interactions.getReferenceProps() : {
51
+ onPress() {
52
+ context.setOpen(!context.open);
53
+ }
51
54
  }
52
- }
53
- });
54
- });
55
+ });
56
+ }
57
+ );
55
58
  SelectTrigger.displayName = TRIGGER_NAME;
56
59
  const VALUE_NAME = "SelectValue";
57
60
  const SelectValueFrame = styled(Paragraph, {
58
61
  name: VALUE_NAME,
59
62
  selectable: false
60
63
  });
61
- const SelectValue = SelectValueFrame.extractable(React.forwardRef(({ __scopeSelect, children: childrenProp, placeholder }, forwardedRef) => {
62
- const context = useSelectContext(VALUE_NAME, __scopeSelect);
63
- const { onValueNodeHasChildrenChange } = context;
64
- const hasChildren = childrenProp !== void 0;
65
- const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
66
- useIsomorphicLayoutEffect(() => {
67
- onValueNodeHasChildrenChange(hasChildren);
68
- }, [onValueNodeHasChildrenChange, hasChildren]);
69
- const children = childrenProp ?? context.selectedItem;
70
- return /* @__PURE__ */ React.createElement(SelectValueFrame, {
71
- size: context.size,
72
- ref: composedRefs,
73
- pointerEvents: "none"
74
- }, context.value === void 0 && placeholder !== void 0 ? placeholder : children);
75
- }));
64
+ const SelectValue = SelectValueFrame.extractable(
65
+ React.forwardRef(
66
+ ({ __scopeSelect, children: childrenProp, placeholder }, forwardedRef) => {
67
+ const context = useSelectContext(VALUE_NAME, __scopeSelect);
68
+ const { onValueNodeHasChildrenChange } = context;
69
+ const hasChildren = childrenProp !== void 0;
70
+ const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
71
+ useIsomorphicLayoutEffect(() => {
72
+ onValueNodeHasChildrenChange(hasChildren);
73
+ }, [onValueNodeHasChildrenChange, hasChildren]);
74
+ const children = childrenProp ?? context.selectedItem;
75
+ return /* @__PURE__ */ jsx(SelectValueFrame, {
76
+ size: context.size,
77
+ ref: composedRefs,
78
+ pointerEvents: "none",
79
+ children: context.value === void 0 && placeholder !== void 0 ? placeholder : children
80
+ });
81
+ }
82
+ )
83
+ );
76
84
  SelectValue.displayName = VALUE_NAME;
77
85
  const SelectIcon = styled(XStack, {
78
86
  name: "SelectIcon",
79
87
  "aria-hidden": true,
80
- children: /* @__PURE__ */ React.createElement(Paragraph, null, "\u25BC")
88
+ children: /* @__PURE__ */ jsx(Paragraph, {
89
+ children: "\u25BC"
90
+ })
81
91
  });
82
92
  const ITEM_NAME = "SelectItem";
83
93
  const [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
84
- const SelectItem = React.forwardRef((props, forwardedRef) => {
85
- const {
86
- __scopeSelect,
87
- value,
88
- disabled = false,
89
- textValue: textValueProp,
90
- index,
91
- ...itemProps
92
- } = props;
93
- const context = useSelectContext(ITEM_NAME, __scopeSelect);
94
- const isSelected = context.value === value;
95
- const textId = useId();
96
- const {
97
- selectedIndex,
98
- setSelectedIndex,
99
- listRef,
100
- open,
101
- setOpen,
102
- onChange,
103
- setActiveIndex,
104
- allowMouseUpRef,
105
- allowSelectRef,
106
- setValueAtIndex,
107
- selectTimeoutRef,
108
- dataRef
109
- } = context;
110
- const composedRefs = useComposedRefs(forwardedRef, (node) => {
111
- if (!isWeb)
112
- return;
113
- if (node instanceof HTMLElement) {
114
- if (listRef) {
115
- listRef.current[index] = node;
94
+ const SelectItem = React.forwardRef(
95
+ (props, forwardedRef) => {
96
+ const {
97
+ __scopeSelect,
98
+ value,
99
+ disabled = false,
100
+ textValue: textValueProp,
101
+ index,
102
+ ...itemProps
103
+ } = props;
104
+ const context = useSelectContext(ITEM_NAME, __scopeSelect);
105
+ const isSelected = context.value === value;
106
+ const textId = useId();
107
+ const {
108
+ selectedIndex,
109
+ setSelectedIndex,
110
+ listRef,
111
+ open,
112
+ setOpen,
113
+ onChange,
114
+ setActiveIndex,
115
+ allowMouseUpRef,
116
+ allowSelectRef,
117
+ setValueAtIndex,
118
+ selectTimeoutRef,
119
+ dataRef
120
+ } = context;
121
+ const composedRefs = useComposedRefs(forwardedRef, (node) => {
122
+ if (!isWeb)
123
+ return;
124
+ if (node instanceof HTMLElement) {
125
+ if (listRef) {
126
+ listRef.current[index] = node;
127
+ }
116
128
  }
129
+ });
130
+ React.useEffect(() => {
131
+ setValueAtIndex(index, value);
132
+ }, [index, setValueAtIndex, value]);
133
+ function handleSelect() {
134
+ setSelectedIndex(index);
135
+ onChange(value);
136
+ setOpen(false);
117
137
  }
118
- });
119
- React.useEffect(() => {
120
- setValueAtIndex(index, value);
121
- }, [index, setValueAtIndex, value]);
122
- function handleSelect() {
123
- setSelectedIndex(index);
124
- onChange(value);
125
- setOpen(false);
126
- }
127
- const selectItemProps = context.interactions ? context.interactions.getItemProps({
128
- onTouchStart() {
129
- allowSelectRef.current = true;
130
- allowMouseUpRef.current = false;
131
- },
132
- onKeyDown(event) {
133
- if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
134
- event.preventDefault();
135
- handleSelect();
136
- } else {
138
+ const selectItemProps = context.interactions ? context.interactions.getItemProps({
139
+ onTouchStart() {
137
140
  allowSelectRef.current = true;
141
+ allowMouseUpRef.current = false;
142
+ },
143
+ onKeyDown(event) {
144
+ if (event.key === "Enter" || event.key === " " && !(dataRef == null ? void 0 : dataRef.current.typing)) {
145
+ event.preventDefault();
146
+ handleSelect();
147
+ } else {
148
+ allowSelectRef.current = true;
149
+ }
150
+ },
151
+ onClick() {
152
+ if (allowSelectRef.current) {
153
+ setSelectedIndex(index);
154
+ setOpen(false);
155
+ }
156
+ },
157
+ onMouseUp() {
158
+ if (!allowMouseUpRef.current) {
159
+ return;
160
+ }
161
+ if (allowSelectRef.current) {
162
+ handleSelect();
163
+ }
164
+ clearTimeout(selectTimeoutRef.current);
165
+ selectTimeoutRef.current = setTimeout(() => {
166
+ allowSelectRef.current = true;
167
+ });
138
168
  }
139
- },
140
- onClick() {
141
- if (allowSelectRef.current) {
142
- setSelectedIndex(index);
143
- setOpen(false);
144
- }
145
- },
146
- onMouseUp() {
147
- if (!allowMouseUpRef.current) {
148
- return;
149
- }
150
- if (allowSelectRef.current) {
151
- handleSelect();
152
- }
153
- clearTimeout(selectTimeoutRef.current);
154
- selectTimeoutRef.current = setTimeout(() => {
155
- allowSelectRef.current = true;
156
- });
157
- }
158
- }) : {
159
- onPress: handleSelect
160
- };
161
- return /* @__PURE__ */ React.createElement(SelectItemContextProvider, {
162
- scope: __scopeSelect,
163
- value,
164
- textId: textId || "",
165
- isSelected
166
- }, /* @__PURE__ */ React.createElement(ListItem, {
167
- backgrounded: true,
168
- pressTheme: true,
169
- focusTheme: true,
170
- componentName: ITEM_NAME,
171
- ref: composedRefs,
172
- "aria-labelledby": textId,
173
- "aria-selected": isSelected,
174
- "data-state": isSelected ? "active" : "inactive",
175
- "aria-disabled": disabled || void 0,
176
- "data-disabled": disabled ? "" : void 0,
177
- tabIndex: disabled ? void 0 : -1,
178
- size: context.size,
179
- ...itemProps,
180
- ...selectItemProps
181
- }));
182
- });
169
+ }) : {
170
+ onPress: handleSelect
171
+ };
172
+ return /* @__PURE__ */ jsx(SelectItemContextProvider, {
173
+ scope: __scopeSelect,
174
+ value,
175
+ textId: textId || "",
176
+ isSelected,
177
+ children: /* @__PURE__ */ jsx(ListItem, {
178
+ backgrounded: true,
179
+ pressTheme: true,
180
+ focusTheme: true,
181
+ componentName: ITEM_NAME,
182
+ ref: composedRefs,
183
+ "aria-labelledby": textId,
184
+ "aria-selected": isSelected,
185
+ "data-state": isSelected ? "active" : "inactive",
186
+ "aria-disabled": disabled || void 0,
187
+ "data-disabled": disabled ? "" : void 0,
188
+ tabIndex: disabled ? void 0 : -1,
189
+ size: context.size,
190
+ ...itemProps,
191
+ ...selectItemProps
192
+ })
193
+ });
194
+ }
195
+ );
183
196
  SelectItem.displayName = ITEM_NAME;
184
197
  const ITEM_TEXT_NAME = "SelectItemText";
185
198
  const SelectItemTextFrame = styled(Paragraph, {
186
199
  name: ITEM_TEXT_NAME,
187
200
  selectable: false
188
201
  });
189
- const SelectItemText = React.forwardRef((props, forwardedRef) => {
190
- const { __scopeSelect, className, ...itemTextProps } = props;
191
- const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
192
- const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
193
- const ref = React.useRef(null);
194
- const composedRefs = useComposedRefs(forwardedRef, ref);
195
- const isSelected = itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren;
196
- const contents = /* @__PURE__ */ React.createElement(SelectItemTextFrame, {
197
- className,
198
- size: context.size,
199
- id: itemContext.textId,
200
- ...itemTextProps,
201
- ref: composedRefs
202
- });
203
- if (!isWeb) {
204
- React.useEffect(() => {
205
- if (isSelected) {
206
- context.setSelectedItem(contents);
207
- }
208
- }, [isSelected]);
202
+ const SelectItemText = React.forwardRef(
203
+ (props, forwardedRef) => {
204
+ const { __scopeSelect, className, ...itemTextProps } = props;
205
+ const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
206
+ const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
207
+ const ref = React.useRef(null);
208
+ const composedRefs = useComposedRefs(forwardedRef, ref);
209
+ const isSelected = itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren;
210
+ const contents = /* @__PURE__ */ jsx(SelectItemTextFrame, {
211
+ className,
212
+ size: context.size,
213
+ id: itemContext.textId,
214
+ ...itemTextProps,
215
+ ref: composedRefs
216
+ });
217
+ if (!isWeb) {
218
+ React.useEffect(() => {
219
+ if (isSelected) {
220
+ context.setSelectedItem(contents);
221
+ }
222
+ }, [isSelected]);
223
+ }
224
+ return /* @__PURE__ */ jsxs(Fragment, {
225
+ children: [
226
+ contents,
227
+ isWeb && isSelected ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
228
+ ]
229
+ });
209
230
  }
210
- return /* @__PURE__ */ React.createElement(React.Fragment, null, contents, isWeb && isSelected ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null);
211
- });
231
+ );
212
232
  SelectItemText.displayName = ITEM_TEXT_NAME;
213
233
  const ITEM_INDICATOR_NAME = "SelectItemIndicator";
214
234
  const SelectItemIndicatorFrame = styled(XStack, {
215
235
  name: ITEM_TEXT_NAME
216
236
  });
217
- const SelectItemIndicator = React.forwardRef((props, forwardedRef) => {
218
- const { __scopeSelect, ...itemIndicatorProps } = props;
219
- const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
220
- return itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, {
221
- "aria-hidden": true,
222
- ...itemIndicatorProps,
223
- ref: forwardedRef
224
- }) : null;
225
- });
237
+ const SelectItemIndicator = React.forwardRef(
238
+ (props, forwardedRef) => {
239
+ const { __scopeSelect, ...itemIndicatorProps } = props;
240
+ const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
241
+ return itemContext.isSelected ? /* @__PURE__ */ jsx(SelectItemIndicatorFrame, {
242
+ "aria-hidden": true,
243
+ ...itemIndicatorProps,
244
+ ref: forwardedRef
245
+ }) : null;
246
+ }
247
+ );
226
248
  SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
227
249
  const GROUP_NAME = "SelectGroup";
228
250
  const [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
@@ -230,34 +252,39 @@ const SelectGroupFrame = styled(YStack, {
230
252
  name: GROUP_NAME,
231
253
  width: "100%"
232
254
  });
233
- const SelectGroup = React.forwardRef((props, forwardedRef) => {
234
- const { __scopeSelect, ...groupProps } = props;
235
- const groupId = useId();
236
- return /* @__PURE__ */ React.createElement(SelectGroupContextProvider, {
237
- scope: __scopeSelect,
238
- id: groupId || ""
239
- }, /* @__PURE__ */ React.createElement(SelectGroupFrame, {
240
- role: "group",
241
- "aria-labelledby": groupId,
242
- ...groupProps,
243
- ref: forwardedRef
244
- }));
245
- });
255
+ const SelectGroup = React.forwardRef(
256
+ (props, forwardedRef) => {
257
+ const { __scopeSelect, ...groupProps } = props;
258
+ const groupId = useId();
259
+ return /* @__PURE__ */ jsx(SelectGroupContextProvider, {
260
+ scope: __scopeSelect,
261
+ id: groupId || "",
262
+ children: /* @__PURE__ */ jsx(SelectGroupFrame, {
263
+ role: "group",
264
+ "aria-labelledby": groupId,
265
+ ...groupProps,
266
+ ref: forwardedRef
267
+ })
268
+ });
269
+ }
270
+ );
246
271
  SelectGroup.displayName = GROUP_NAME;
247
272
  const LABEL_NAME = "SelectLabel";
248
- const SelectLabel = React.forwardRef((props, forwardedRef) => {
249
- const { __scopeSelect, ...labelProps } = props;
250
- const context = useSelectContext(LABEL_NAME, __scopeSelect);
251
- const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
252
- return /* @__PURE__ */ React.createElement(ListItem, {
253
- componentName: LABEL_NAME,
254
- fontWeight: "800",
255
- id: groupContext.id,
256
- size: context.size,
257
- ...labelProps,
258
- ref: forwardedRef
259
- });
260
- });
273
+ const SelectLabel = React.forwardRef(
274
+ (props, forwardedRef) => {
275
+ const { __scopeSelect, ...labelProps } = props;
276
+ const context = useSelectContext(LABEL_NAME, __scopeSelect);
277
+ const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
278
+ return /* @__PURE__ */ jsx(ListItem, {
279
+ componentName: LABEL_NAME,
280
+ fontWeight: "800",
281
+ id: groupContext.id,
282
+ size: context.size,
283
+ ...labelProps,
284
+ ref: forwardedRef
285
+ });
286
+ }
287
+ );
261
288
  SelectLabel.displayName = LABEL_NAME;
262
289
  const SelectSeparator = styled(Separator, {
263
290
  name: "SelectSeparator"
@@ -275,121 +302,132 @@ const SelectSheetController = (props) => {
275
302
  const showSheet = useShowSelectSheet(context);
276
303
  const breakpointActive = useSelectBreakpointActive(context.sheetBreakpoint);
277
304
  const getShowSheet = useGet(showSheet);
278
- return /* @__PURE__ */ React.createElement(SheetController, {
305
+ return /* @__PURE__ */ jsx(SheetController, {
279
306
  onChangeOpen: (val) => {
280
307
  if (getShowSheet()) {
281
308
  props.onChangeOpen(val);
282
309
  }
283
310
  },
284
311
  open: context.open,
285
- hidden: breakpointActive === false
286
- }, props.children);
312
+ hidden: breakpointActive === false,
313
+ children: props.children
314
+ });
287
315
  };
288
316
  const SHEET_CONTENTS_NAME = "SelectSheetContents";
289
317
  const SelectSheetContents = ({ __scopeSelect }) => {
290
318
  const context = useSelectContext(SHEET_CONTENTS_NAME, __scopeSelect);
291
- return /* @__PURE__ */ React.createElement(PortalHost, {
319
+ return /* @__PURE__ */ jsx(PortalHost, {
292
320
  name: `${context.scopeKey}SheetContents`
293
321
  });
294
322
  };
295
323
  SelectSheetContents.displayName = SHEET_CONTENTS_NAME;
296
324
  const SelectSheetImpl = (props) => {
297
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
298
- };
299
- const Select = withStaticProperties((props) => {
300
- const {
301
- __scopeSelect,
302
- children,
303
- open: openProp,
304
- defaultOpen,
305
- onOpenChange,
306
- value: valueProp,
307
- defaultValue,
308
- onValueChange,
309
- size: sizeProp = "$4",
310
- sheetBreakpoint = false,
311
- dir
312
- } = props;
313
- const isSheet = useSelectBreakpointActive(sheetBreakpoint);
314
- const SelectImpl = isSheet ? SelectSheetImpl : SelectInlineImpl;
315
- const forceUpdate = React.useReducer(() => ({}), {})[1];
316
- const [selectedItem, setSelectedItem] = React.useState(null);
317
- const [open, setOpen] = useControllableState({
318
- prop: openProp,
319
- defaultProp: defaultOpen || false,
320
- onChange: onOpenChange,
321
- strategy: "most-recent-wins"
322
- });
323
- const [value, setValue] = useControllableState({
324
- prop: valueProp,
325
- defaultProp: defaultValue || "",
326
- onChange: onValueChange,
327
- strategy: "most-recent-wins"
325
+ return /* @__PURE__ */ jsx(Fragment, {
326
+ children: props.children
328
327
  });
329
- const [activeIndex, setActiveIndex] = React.useState(null);
330
- const selectedIndexRef = React.useRef(null);
331
- const activeIndexRef = React.useRef(null);
332
- const listContentRef = React.useRef([]);
333
- const [selectedIndex, setSelectedIndex] = React.useState(Math.max(0, listContentRef.current.indexOf(value)));
334
- const [valueNode, setValueNode] = React.useState(null);
335
- const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
336
- useIsomorphicLayoutEffect(() => {
337
- selectedIndexRef.current = selectedIndex;
338
- activeIndexRef.current = activeIndex;
339
- });
340
- return /* @__PURE__ */ React.createElement(SelectProvider, {
341
- dir,
342
- blockSelection: false,
343
- size: sizeProp,
344
- fallback: false,
345
- selectedItem,
346
- setSelectedItem,
347
- forceUpdate,
348
- valueNode,
349
- onValueNodeChange: setValueNode,
350
- onValueNodeHasChildrenChange: setValueNodeHasChildren,
351
- valueNodeHasChildren,
352
- scopeKey: __scopeSelect ? Object.keys(__scopeSelect)[0] : "",
353
- sheetBreakpoint,
354
- scope: __scopeSelect,
355
- setValueAtIndex: (index, value2) => {
356
- listContentRef.current[index] = value2;
357
- },
358
- activeIndex,
359
- onChange: setValue,
360
- selectedIndex,
361
- setActiveIndex,
362
- setOpen,
363
- setSelectedIndex,
364
- value,
365
- open
366
- }, /* @__PURE__ */ React.createElement(SelectSheetController, {
367
- onChangeOpen: setOpen,
368
- __scopeSelect
369
- }, /* @__PURE__ */ React.createElement(SelectImpl, {
370
- activeIndexRef,
371
- listContentRef,
372
- selectedIndexRef,
373
- ...props,
374
- open,
375
- value
376
- }, children)));
377
- }, {
378
- Content: SelectContent,
379
- Group: SelectGroup,
380
- Icon: SelectIcon,
381
- Item: SelectItem,
382
- ItemIndicator: SelectItemIndicator,
383
- ItemText: SelectItemText,
384
- Label: SelectLabel,
385
- ScrollDownButton: SelectScrollDownButton,
386
- ScrollUpButton: SelectScrollUpButton,
387
- Trigger: SelectTrigger,
388
- Value: SelectValue,
389
- Viewport: SelectViewport,
390
- SheetContents: SelectSheetContents,
391
- Sheet
392
- });
328
+ };
329
+ const Select = withStaticProperties(
330
+ (props) => {
331
+ const {
332
+ __scopeSelect,
333
+ children,
334
+ open: openProp,
335
+ defaultOpen,
336
+ onOpenChange,
337
+ value: valueProp,
338
+ defaultValue,
339
+ onValueChange,
340
+ size: sizeProp = "$4",
341
+ sheetBreakpoint = false,
342
+ dir
343
+ } = props;
344
+ const isSheet = useSelectBreakpointActive(sheetBreakpoint);
345
+ const SelectImpl = isSheet ? SelectSheetImpl : SelectInlineImpl;
346
+ const forceUpdate = React.useReducer(() => ({}), {})[1];
347
+ const [selectedItem, setSelectedItem] = React.useState(null);
348
+ const [open, setOpen] = useControllableState({
349
+ prop: openProp,
350
+ defaultProp: defaultOpen || false,
351
+ onChange: onOpenChange,
352
+ strategy: "most-recent-wins"
353
+ });
354
+ const [value, setValue] = useControllableState({
355
+ prop: valueProp,
356
+ defaultProp: defaultValue || "",
357
+ onChange: onValueChange,
358
+ strategy: "most-recent-wins"
359
+ });
360
+ const [activeIndex, setActiveIndex] = React.useState(null);
361
+ const selectedIndexRef = React.useRef(null);
362
+ const activeIndexRef = React.useRef(null);
363
+ const listContentRef = React.useRef([]);
364
+ const [selectedIndex, setSelectedIndex] = React.useState(
365
+ Math.max(0, listContentRef.current.indexOf(value))
366
+ );
367
+ const [valueNode, setValueNode] = React.useState(null);
368
+ const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
369
+ useIsomorphicLayoutEffect(() => {
370
+ selectedIndexRef.current = selectedIndex;
371
+ activeIndexRef.current = activeIndex;
372
+ });
373
+ return /* @__PURE__ */ jsx(SelectProvider, {
374
+ dir,
375
+ blockSelection: false,
376
+ size: sizeProp,
377
+ fallback: false,
378
+ selectedItem,
379
+ setSelectedItem,
380
+ forceUpdate,
381
+ valueNode,
382
+ onValueNodeChange: setValueNode,
383
+ onValueNodeHasChildrenChange: setValueNodeHasChildren,
384
+ valueNodeHasChildren,
385
+ scopeKey: __scopeSelect ? Object.keys(__scopeSelect)[0] : "",
386
+ sheetBreakpoint,
387
+ scope: __scopeSelect,
388
+ setValueAtIndex: (index, value2) => {
389
+ listContentRef.current[index] = value2;
390
+ },
391
+ activeIndex,
392
+ onChange: setValue,
393
+ selectedIndex,
394
+ setActiveIndex,
395
+ setOpen,
396
+ setSelectedIndex,
397
+ value,
398
+ open,
399
+ children: /* @__PURE__ */ jsx(SelectSheetController, {
400
+ onChangeOpen: setOpen,
401
+ __scopeSelect,
402
+ children: /* @__PURE__ */ jsx(SelectImpl, {
403
+ activeIndexRef,
404
+ listContentRef,
405
+ selectedIndexRef,
406
+ ...props,
407
+ open,
408
+ value,
409
+ children
410
+ })
411
+ })
412
+ });
413
+ },
414
+ {
415
+ Content: SelectContent,
416
+ Group: SelectGroup,
417
+ Icon: SelectIcon,
418
+ Item: SelectItem,
419
+ ItemIndicator: SelectItemIndicator,
420
+ ItemText: SelectItemText,
421
+ Label: SelectLabel,
422
+ ScrollDownButton: SelectScrollDownButton,
423
+ ScrollUpButton: SelectScrollUpButton,
424
+ Trigger: SelectTrigger,
425
+ Value: SelectValue,
426
+ Viewport: SelectViewport,
427
+ SheetContents: SelectSheetContents,
428
+ Sheet
429
+ }
430
+ );
393
431
  Select.displayName = SELECT_NAME;
394
432
  export {
395
433
  Select,