@tamagui/select 1.135.4 → 1.135.6

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 (82) hide show
  1. package/dist/cjs/BubbleSelect.cjs +1 -1
  2. package/dist/cjs/BubbleSelect.js +1 -1
  3. package/dist/cjs/BubbleSelect.native.js +19 -13
  4. package/dist/cjs/BubbleSelect.native.js.map +1 -6
  5. package/dist/cjs/Select.cjs +1 -1
  6. package/dist/cjs/Select.js +1 -1
  7. package/dist/cjs/Select.js.map +1 -1
  8. package/dist/cjs/Select.native.js +342 -242
  9. package/dist/cjs/Select.native.js.map +1 -6
  10. package/dist/cjs/SelectContent.cjs +1 -1
  11. package/dist/cjs/SelectContent.js +1 -1
  12. package/dist/cjs/SelectContent.js.map +1 -1
  13. package/dist/cjs/SelectContent.native.js +20 -15
  14. package/dist/cjs/SelectContent.native.js.map +1 -6
  15. package/dist/cjs/SelectImpl.cjs +1 -1
  16. package/dist/cjs/SelectImpl.js +1 -1
  17. package/dist/cjs/SelectImpl.js.map +1 -1
  18. package/dist/cjs/SelectImpl.native.js +22 -18
  19. package/dist/cjs/SelectImpl.native.js.map +1 -6
  20. package/dist/cjs/SelectItem.cjs +1 -1
  21. package/dist/cjs/SelectItem.js +1 -1
  22. package/dist/cjs/SelectItem.js.map +1 -1
  23. package/dist/cjs/SelectItem.native.js +158 -117
  24. package/dist/cjs/SelectItem.native.js.map +1 -6
  25. package/dist/cjs/SelectItemText.cjs +1 -1
  26. package/dist/cjs/SelectItemText.js +1 -1
  27. package/dist/cjs/SelectItemText.js.map +1 -1
  28. package/dist/cjs/SelectItemText.native.js +72 -51
  29. package/dist/cjs/SelectItemText.native.js.map +1 -6
  30. package/dist/cjs/SelectScrollButton.cjs +1 -1
  31. package/dist/cjs/SelectScrollButton.js +1 -1
  32. package/dist/cjs/SelectScrollButton.js.map +1 -1
  33. package/dist/cjs/SelectScrollButton.native.js +22 -19
  34. package/dist/cjs/SelectScrollButton.native.js.map +1 -6
  35. package/dist/cjs/SelectTrigger.cjs +1 -1
  36. package/dist/cjs/SelectTrigger.js +1 -1
  37. package/dist/cjs/SelectTrigger.js.map +1 -1
  38. package/dist/cjs/SelectTrigger.native.js +74 -51
  39. package/dist/cjs/SelectTrigger.native.js.map +1 -6
  40. package/dist/cjs/SelectViewport.native.js +43 -28
  41. package/dist/cjs/SelectViewport.native.js.map +1 -6
  42. package/dist/cjs/constants.native.js +24 -21
  43. package/dist/cjs/constants.native.js.map +1 -6
  44. package/dist/cjs/context.native.js +43 -30
  45. package/dist/cjs/context.native.js.map +1 -6
  46. package/dist/cjs/index.native.js +14 -14
  47. package/dist/cjs/index.native.js.map +1 -6
  48. package/dist/cjs/types.native.js +9 -5
  49. package/dist/cjs/types.native.js.map +1 -6
  50. package/dist/cjs/useSelectBreakpointActive.native.js +22 -18
  51. package/dist/cjs/useSelectBreakpointActive.native.js.map +1 -6
  52. package/dist/esm/SelectItem.native.js +4 -1
  53. package/dist/esm/SelectItem.native.js.map +1 -1
  54. package/dist/jsx/BubbleSelect.native.js +28 -4
  55. package/dist/jsx/BubbleSelect.native.js.map +1 -6
  56. package/dist/jsx/Select.native.js +363 -257
  57. package/dist/jsx/Select.native.js.map +1 -6
  58. package/dist/jsx/SelectContent.native.js +31 -5
  59. package/dist/jsx/SelectContent.native.js.map +1 -6
  60. package/dist/jsx/SelectImpl.native.js +33 -9
  61. package/dist/jsx/SelectImpl.native.js.map +1 -6
  62. package/dist/jsx/SelectItem.native.js +174 -109
  63. package/dist/jsx/SelectItem.native.js.map +1 -6
  64. package/dist/jsx/SelectItemText.native.js +90 -45
  65. package/dist/jsx/SelectItemText.native.js.map +1 -6
  66. package/dist/jsx/SelectScrollButton.native.js +34 -9
  67. package/dist/jsx/SelectScrollButton.native.js.map +1 -6
  68. package/dist/jsx/SelectTrigger.native.js +90 -44
  69. package/dist/jsx/SelectTrigger.native.js.map +1 -6
  70. package/dist/jsx/SelectViewport.native.js +55 -24
  71. package/dist/jsx/SelectViewport.native.js.map +1 -6
  72. package/dist/jsx/constants.native.js +41 -11
  73. package/dist/jsx/constants.native.js.map +1 -6
  74. package/dist/jsx/context.native.js +58 -22
  75. package/dist/jsx/context.native.js.map +1 -6
  76. package/dist/jsx/index.native.js +22 -3
  77. package/dist/jsx/index.native.js.map +1 -6
  78. package/dist/jsx/types.native.js +19 -1
  79. package/dist/jsx/types.native.js.map +1 -6
  80. package/dist/jsx/useSelectBreakpointActive.native.js +33 -9
  81. package/dist/jsx/useSelectBreakpointActive.native.js.map +1 -6
  82. package/package.json +25 -24
@@ -1,293 +1,405 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Adapt, AdaptParent, useAdaptIsActive } from "@tamagui/adapt";
3
- import { useComposedRefs } from "@tamagui/compose-refs";
4
- import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
5
- import { createStyledContext, getVariableValue, styled, useEvent, useGet } from "@tamagui/core";
6
- import { FocusScopeController } from "@tamagui/focus-scope";
7
- import { registerFocusable } from "@tamagui/focusable";
8
- import { getSpace } from "@tamagui/get-token";
9
- import { withStaticProperties } from "@tamagui/helpers";
10
- import { ListItem } from "@tamagui/list-item";
11
- import { Separator } from "@tamagui/separator";
12
- import { Sheet, SheetController } from "@tamagui/sheet";
13
- import { ThemeableStack, XStack, YStack } from "@tamagui/stacks";
14
- import { Paragraph, SizableText } from "@tamagui/text";
15
- import { useControllableState } from "@tamagui/use-controllable-state";
16
- import { useDebounce } from "@tamagui/use-debounce";
17
- import * as React from "react";
18
- import { SelectItemParentProvider, SelectProvider, useSelectContext, useSelectItemParentContext } from "./context";
19
- import { SelectContent } from "./SelectContent";
20
- import { SelectInlineImpl } from "./SelectImpl";
21
- import { SelectItem, useSelectItemContext } from "./SelectItem";
22
- import { ITEM_TEXT_NAME, SelectItemText } from "./SelectItemText";
23
- import { SelectScrollDownButton, SelectScrollUpButton } from "./SelectScrollButton";
24
- import { SelectTrigger } from "./SelectTrigger";
25
- import { SelectViewport } from "./SelectViewport";
26
- import { useShowSelectSheet } from "./useSelectBreakpointActive";
27
- var VALUE_NAME = "SelectValue", SelectValueFrame = styled(SizableText, {
28
- name: VALUE_NAME,
29
- userSelect: "none"
30
- }), SelectValue = SelectValueFrame.styleable(function(param, forwardedRef) {
31
- var { scope, children: childrenProp, placeholder, ...props } = param, context = useSelectContext(scope), itemParentContext = useSelectItemParentContext(scope), composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange), children = childrenProp ?? context.selectedItem, isEmptyValue = context.value == null || context.value === "", selectValueChildren = isEmptyValue ? placeholder ?? children : children;
32
- return /* @__PURE__ */ _jsx(SelectValueFrame, {
33
- ...!props.unstyled && {
34
- size: itemParentContext.size,
35
- ellipse: !0,
36
- // we don't want events from the portalled `SelectValue` children to bubble
37
- // through the item they came from
38
- pointerEvents: "none"
39
- },
40
- ref: composedRefs,
41
- ...props,
42
- children: unwrapSelectItem(selectValueChildren)
43
- });
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: !0
13
+ });
14
+ },
15
+ __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: !0
30
+ }) : target, mod)),
31
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: !0
33
+ }), mod);
34
+ var Select_exports = {};
35
+ __export(Select_exports, {
36
+ Select: () => Select,
37
+ SelectGroupFrame: () => SelectGroupFrame,
38
+ SelectIcon: () => SelectIcon,
39
+ SelectSeparator: () => SelectSeparator
44
40
  });
41
+ module.exports = __toCommonJS(Select_exports);
42
+ var import_jsx_runtime = require("react/jsx-runtime"),
43
+ import_adapt = require("@tamagui/adapt"),
44
+ import_compose_refs = require("@tamagui/compose-refs"),
45
+ import_constants = require("@tamagui/constants"),
46
+ import_core = require("@tamagui/core"),
47
+ import_focus_scope = require("@tamagui/focus-scope"),
48
+ import_focusable = require("@tamagui/focusable"),
49
+ import_get_token = require("@tamagui/get-token"),
50
+ import_helpers = require("@tamagui/helpers"),
51
+ import_list_item = require("@tamagui/list-item"),
52
+ import_separator = require("@tamagui/separator"),
53
+ import_sheet = require("@tamagui/sheet"),
54
+ import_stacks = require("@tamagui/stacks"),
55
+ import_text = require("@tamagui/text"),
56
+ import_use_controllable_state = require("@tamagui/use-controllable-state"),
57
+ import_use_debounce = require("@tamagui/use-debounce"),
58
+ React = __toESM(require("react"), 1),
59
+ import_context = require("./context.native.js"),
60
+ import_SelectContent = require("./SelectContent.native.js"),
61
+ import_SelectImpl = require("./SelectImpl.native.js"),
62
+ import_SelectItem = require("./SelectItem.native.js"),
63
+ import_SelectItemText = require("./SelectItemText.native.js"),
64
+ import_SelectScrollButton = require("./SelectScrollButton.native.js"),
65
+ import_SelectTrigger = require("./SelectTrigger.native.js"),
66
+ import_SelectViewport = require("./SelectViewport.native.js"),
67
+ import_useSelectBreakpointActive = require("./useSelectBreakpointActive.native.js"),
68
+ VALUE_NAME = "SelectValue",
69
+ SelectValueFrame = (0, import_core.styled)(import_text.SizableText, {
70
+ name: VALUE_NAME,
71
+ userSelect: "none"
72
+ }),
73
+ SelectValue = SelectValueFrame.styleable(function (param, forwardedRef) {
74
+ var {
75
+ scope,
76
+ children: childrenProp,
77
+ placeholder,
78
+ ...props
79
+ } = param,
80
+ context = (0, import_context.useSelectContext)(scope),
81
+ itemParentContext = (0, import_context.useSelectItemParentContext)(scope),
82
+ composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange),
83
+ children = childrenProp ?? context.selectedItem,
84
+ isEmptyValue = context.value == null || context.value === "",
85
+ selectValueChildren = isEmptyValue ? placeholder ?? children : children;
86
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectValueFrame, {
87
+ ...(!props.unstyled && {
88
+ size: itemParentContext.size,
89
+ ellipse: !0,
90
+ // we don't want events from the portalled `SelectValue` children to bubble
91
+ // through the item they came from
92
+ pointerEvents: "none"
93
+ }),
94
+ ref: composedRefs,
95
+ ...props,
96
+ children: unwrapSelectItem(selectValueChildren)
97
+ });
98
+ });
45
99
  function unwrapSelectItem(selectValueChildren) {
46
- return React.Children.map(selectValueChildren, function(child) {
100
+ return React.Children.map(selectValueChildren, function (child) {
47
101
  if (child) {
48
102
  var _child_type_staticConfig, _child_type, _child_props;
49
- if (((_child_type = child.type) === null || _child_type === void 0 || (_child_type_staticConfig = _child_type.staticConfig) === null || _child_type_staticConfig === void 0 ? void 0 : _child_type_staticConfig.componentName) === ITEM_TEXT_NAME)
50
- return child.props.children;
51
- if (!((_child_props = child.props) === null || _child_props === void 0) && _child_props.children)
52
- return unwrapSelectItem(child.props.children);
103
+ if (((_child_type = child.type) === null || _child_type === void 0 || (_child_type_staticConfig = _child_type.staticConfig) === null || _child_type_staticConfig === void 0 ? void 0 : _child_type_staticConfig.componentName) === import_SelectItemText.ITEM_TEXT_NAME) return child.props.children;
104
+ if (!((_child_props = child.props) === null || _child_props === void 0) && _child_props.children) return unwrapSelectItem(child.props.children);
53
105
  }
54
106
  return child;
55
107
  });
56
108
  }
57
- var SelectIcon = styled(XStack, {
58
- name: "SelectIcon",
59
- // @ts-ignore
60
- "aria-hidden": !0,
61
- children: /* @__PURE__ */ _jsx(Paragraph, {
62
- children: "\u25BC"
63
- })
64
- }), SelectItemIndicatorFrame = styled(XStack, {
65
- name: "SelectItemIndicator"
66
- }), SelectItemIndicator = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
67
- var { scope, ...itemIndicatorProps } = props, context = useSelectItemParentContext(scope), itemContext = useSelectItemContext(scope);
68
- return context.shouldRenderWebNative ? null : itemContext.isSelected ? /* @__PURE__ */ _jsx(SelectItemIndicatorFrame, {
109
+ var SelectIcon = (0, import_core.styled)(import_stacks.XStack, {
110
+ name: "SelectIcon",
111
+ // @ts-ignore
69
112
  "aria-hidden": !0,
70
- ...itemIndicatorProps,
71
- ref: forwardedRef
72
- }) : null;
73
- }), GROUP_NAME = "SelectGroup", { Provider: SelectGroupContextProvider, useStyledContext: useSelectGroupContext } = createStyledContext({
74
- id: ""
75
- }, "SelectGroup"), SelectGroupFrame = styled(YStack, {
76
- name: GROUP_NAME,
77
- width: "100%"
78
- }), NativeSelectTextFrame = styled(SizableText, {
79
- tag: "select",
80
- backgroundColor: "$background",
81
- borderColor: "$borderColor",
82
- hoverStyle: {
83
- backgroundColor: "$backgroundHover"
84
- }
85
- }), NativeSelectFrame = styled(ThemeableStack, {
86
- name: "NativeSelect",
87
- bordered: !0,
88
- userSelect: "none",
89
- outlineWidth: 0,
90
- paddingRight: 10,
91
- variants: {
92
- size: {
93
- "...size": function(val, extras) {
94
- var { tokens } = extras, paddingHorizontal = getVariableValue(tokens.space[val]), _tokens_radius_val;
95
- return {
96
- borderRadius: (_tokens_radius_val = tokens.radius[val]) !== null && _tokens_radius_val !== void 0 ? _tokens_radius_val : val,
97
- minHeight: tokens.size[val],
98
- paddingRight: paddingHorizontal + 20,
99
- paddingLeft: paddingHorizontal,
100
- paddingVertical: getSpace(val, {
101
- shift: -3
102
- })
103
- };
113
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.Paragraph, {
114
+ children: "\u25BC"
115
+ })
116
+ }),
117
+ SelectItemIndicatorFrame = (0, import_core.styled)(import_stacks.XStack, {
118
+ name: "SelectItemIndicator"
119
+ }),
120
+ SelectItemIndicator = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
121
+ var {
122
+ scope,
123
+ ...itemIndicatorProps
124
+ } = props,
125
+ context = (0, import_context.useSelectItemParentContext)(scope),
126
+ itemContext = (0, import_SelectItem.useSelectItemContext)(scope);
127
+ return context.shouldRenderWebNative ? null : itemContext.isSelected ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectItemIndicatorFrame, {
128
+ "aria-hidden": !0,
129
+ ...itemIndicatorProps,
130
+ ref: forwardedRef
131
+ }) : null;
132
+ }),
133
+ GROUP_NAME = "SelectGroup",
134
+ {
135
+ Provider: SelectGroupContextProvider,
136
+ useStyledContext: useSelectGroupContext
137
+ } = (0, import_core.createStyledContext)({
138
+ id: ""
139
+ }, "SelectGroup"),
140
+ SelectGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
141
+ name: GROUP_NAME,
142
+ width: "100%"
143
+ }),
144
+ NativeSelectTextFrame = (0, import_core.styled)(import_text.SizableText, {
145
+ tag: "select",
146
+ backgroundColor: "$background",
147
+ borderColor: "$borderColor",
148
+ hoverStyle: {
149
+ backgroundColor: "$backgroundHover"
150
+ }
151
+ }),
152
+ NativeSelectFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
153
+ name: "NativeSelect",
154
+ bordered: !0,
155
+ userSelect: "none",
156
+ outlineWidth: 0,
157
+ paddingRight: 10,
158
+ variants: {
159
+ size: {
160
+ "...size": function (val, extras) {
161
+ var {
162
+ tokens
163
+ } = extras,
164
+ paddingHorizontal = (0, import_core.getVariableValue)(tokens.space[val]),
165
+ _tokens_radius_val;
166
+ return {
167
+ borderRadius: (_tokens_radius_val = tokens.radius[val]) !== null && _tokens_radius_val !== void 0 ? _tokens_radius_val : val,
168
+ minHeight: tokens.size[val],
169
+ paddingRight: paddingHorizontal + 20,
170
+ paddingLeft: paddingHorizontal,
171
+ paddingVertical: (0, import_get_token.getSpace)(val, {
172
+ shift: -3
173
+ })
174
+ };
175
+ }
104
176
  }
177
+ },
178
+ defaultVariants: {
179
+ size: "$2"
105
180
  }
106
- },
107
- defaultVariants: {
108
- size: "$2"
109
- }
110
- }), SelectGroup = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
111
- var { scope, ...groupProps } = props, groupId = React.useId(), context = useSelectContext(scope), itemParentContext = useSelectItemParentContext(scope), _itemParentContext_size, size = (_itemParentContext_size = itemParentContext.size) !== null && _itemParentContext_size !== void 0 ? _itemParentContext_size : "$true", nativeSelectRef = React.useRef(null), content = function() {
112
- return itemParentContext.shouldRenderWebNative ? /* @__PURE__ */ _jsx(NativeSelectFrame, {
113
- asChild: !0,
114
- size,
115
- // @ts-expect-error until we support typing based on tag
116
- value: context.value,
117
- id: itemParentContext.id,
118
- children: /* @__PURE__ */ _jsx(NativeSelectTextFrame, {
119
- // @ts-ignore it's ok since tag="select"
120
- onChange: function(event) {
121
- itemParentContext.onChange(event.currentTarget.value);
122
- },
123
- size,
124
- ref: nativeSelectRef,
125
- style: {
126
- color: "var(--color)",
181
+ }),
182
+ SelectGroup = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
183
+ var {
184
+ scope,
185
+ ...groupProps
186
+ } = props,
187
+ groupId = React.useId(),
188
+ context = (0, import_context.useSelectContext)(scope),
189
+ itemParentContext = (0, import_context.useSelectItemParentContext)(scope),
190
+ _itemParentContext_size,
191
+ size = (_itemParentContext_size = itemParentContext.size) !== null && _itemParentContext_size !== void 0 ? _itemParentContext_size : "$true",
192
+ nativeSelectRef = React.useRef(null),
193
+ content = function () {
194
+ return itemParentContext.shouldRenderWebNative ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeSelectFrame, {
195
+ asChild: !0,
196
+ size,
197
+ // @ts-expect-error until we support typing based on tag
198
+ value: context.value,
199
+ id: itemParentContext.id,
200
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeSelectTextFrame, {
201
+ // @ts-ignore it's ok since tag="select"
202
+ onChange: function (event) {
203
+ itemParentContext.onChange(event.currentTarget.value);
204
+ },
205
+ size,
206
+ ref: nativeSelectRef,
207
+ style: {
208
+ color: "var(--color)",
209
+ // @ts-ignore
210
+ appearance: "none"
211
+ },
212
+ children: props.children
213
+ })
214
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectGroupFrame, {
127
215
  // @ts-ignore
128
- appearance: "none"
129
- },
130
- children: props.children
131
- })
132
- }) : /* @__PURE__ */ _jsx(SelectGroupFrame, {
133
- // @ts-ignore
134
- role: "group",
135
- "aria-labelledby": groupId,
136
- ...groupProps,
137
- ref: forwardedRef
216
+ role: "group",
217
+ "aria-labelledby": groupId,
218
+ ...groupProps,
219
+ ref: forwardedRef
220
+ });
221
+ }();
222
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectGroupContextProvider, {
223
+ scope,
224
+ id: groupId || "",
225
+ children: content
138
226
  });
139
- }();
140
- return /* @__PURE__ */ _jsx(SelectGroupContextProvider, {
141
- scope,
142
- id: groupId || "",
143
- children: content
144
227
  });
145
- });
146
228
  SelectGroup.displayName = GROUP_NAME;
147
- var LABEL_NAME = "SelectLabel", SelectLabel = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
148
- var { scope, ...labelProps } = props, context = useSelectItemParentContext(scope), groupContext = useSelectGroupContext(scope);
149
- return context.shouldRenderWebNative ? null : /* @__PURE__ */ _jsx(ListItem, {
150
- tag: "div",
151
- componentName: LABEL_NAME,
152
- fontWeight: "800",
153
- id: groupContext.id,
154
- size: context.size,
155
- ...labelProps,
156
- ref: forwardedRef
229
+ var LABEL_NAME = "SelectLabel",
230
+ SelectLabel = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
231
+ var {
232
+ scope,
233
+ ...labelProps
234
+ } = props,
235
+ context = (0, import_context.useSelectItemParentContext)(scope),
236
+ groupContext = useSelectGroupContext(scope);
237
+ return context.shouldRenderWebNative ? null : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_list_item.ListItem, {
238
+ tag: "div",
239
+ componentName: LABEL_NAME,
240
+ fontWeight: "800",
241
+ id: groupContext.id,
242
+ size: context.size,
243
+ ...labelProps,
244
+ ref: forwardedRef
245
+ });
157
246
  });
158
- });
159
247
  SelectLabel.displayName = LABEL_NAME;
160
- var SelectSeparator = styled(Separator, {
161
- name: "SelectSeparator"
162
- }), SelectSheetController = function(props) {
163
- var context = useSelectContext(props.scope), showSheet = useShowSelectSheet(context), isAdapted = useAdaptIsActive(context.adaptScope), getShowSheet = useGet(showSheet);
164
- return /* @__PURE__ */ _jsx(SheetController, {
165
- onOpenChange: function(val) {
166
- getShowSheet() && props.onOpenChange(val);
167
- },
168
- open: context.open,
169
- hidden: !isAdapted,
170
- children: props.children
171
- });
172
- }, SelectSheetImpl = function(props) {
173
- return /* @__PURE__ */ _jsx(_Fragment, {
174
- children: props.children
175
- });
176
- }, Select = withStaticProperties(function(props) {
177
- var adaptScope = `AdaptSelect${props.scope || ""}`;
178
- return /* @__PURE__ */ _jsx(AdaptParent, {
179
- scope: adaptScope,
180
- portal: !0,
181
- children: /* @__PURE__ */ _jsx(SelectInner, {
182
- scope: props.scope,
183
- adaptScope,
184
- ...props
185
- })
248
+ var SelectSeparator = (0, import_core.styled)(import_separator.Separator, {
249
+ name: "SelectSeparator"
250
+ }),
251
+ SelectSheetController = function (props) {
252
+ var context = (0, import_context.useSelectContext)(props.scope),
253
+ showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context),
254
+ isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope),
255
+ getShowSheet = (0, import_core.useGet)(showSheet);
256
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_sheet.SheetController, {
257
+ onOpenChange: function (val) {
258
+ getShowSheet() && props.onOpenChange(val);
259
+ },
260
+ open: context.open,
261
+ hidden: !isAdapted,
262
+ children: props.children
263
+ });
264
+ },
265
+ SelectSheetImpl = function (props) {
266
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
267
+ children: props.children
268
+ });
269
+ },
270
+ Select = (0, import_helpers.withStaticProperties)(function (props) {
271
+ var adaptScope = `AdaptSelect${props.scope || ""}`;
272
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
273
+ scope: adaptScope,
274
+ portal: !0,
275
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectInner, {
276
+ scope: props.scope,
277
+ adaptScope,
278
+ ...props
279
+ })
280
+ });
281
+ }, {
282
+ Adapt: import_adapt.Adapt,
283
+ Content: import_SelectContent.SelectContent,
284
+ Group: SelectGroup,
285
+ Icon: SelectIcon,
286
+ Item: import_SelectItem.SelectItem,
287
+ ItemIndicator: SelectItemIndicator,
288
+ ItemText: import_SelectItemText.SelectItemText,
289
+ Label: SelectLabel,
290
+ ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
291
+ ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
292
+ Trigger: import_SelectTrigger.SelectTrigger,
293
+ Value: SelectValue,
294
+ Viewport: import_SelectViewport.SelectViewport,
295
+ Sheet: import_sheet.Sheet.Controlled,
296
+ FocusScope: import_focus_scope.FocusScopeController
186
297
  });
187
- }, {
188
- Adapt,
189
- Content: SelectContent,
190
- Group: SelectGroup,
191
- Icon: SelectIcon,
192
- Item: SelectItem,
193
- ItemIndicator: SelectItemIndicator,
194
- ItemText: SelectItemText,
195
- Label: SelectLabel,
196
- ScrollDownButton: SelectScrollDownButton,
197
- ScrollUpButton: SelectScrollUpButton,
198
- Trigger: SelectTrigger,
199
- Value: SelectValue,
200
- Viewport: SelectViewport,
201
- Sheet: Sheet.Controlled,
202
- FocusScope: FocusScopeController
203
- });
204
298
  function useEmitter() {
205
299
  var listeners = React.useRef(null);
206
- listeners.current || (listeners.current = /* @__PURE__ */ new Set());
207
- var emit = function(value) {
208
- listeners.current.forEach(function(l) {
209
- return l(value);
210
- });
211
- }, subscribe = React.useCallback(function(listener) {
212
- return listeners.current.add(listener), function() {
213
- listeners.current.delete(listener);
214
- };
215
- }, []);
216
- return [
217
- emit,
218
- subscribe
219
- ];
300
+ listeners.current || (listeners.current = /* @__PURE__ */new Set());
301
+ var emit = function (value) {
302
+ listeners.current.forEach(function (l) {
303
+ return l(value);
304
+ });
305
+ },
306
+ subscribe = React.useCallback(function (listener) {
307
+ return listeners.current.add(listener), function () {
308
+ listeners.current.delete(listener);
309
+ };
310
+ }, []);
311
+ return [emit, subscribe];
220
312
  }
221
313
  function SelectInner(props) {
222
- var { scope = "", adaptScope, native, children, open: openProp, defaultOpen, onOpenChange, value: valueProp, defaultValue, onValueChange, disablePreventBodyScroll, size: sizeProp = "$true", onActiveChange, dir, id } = props, isAdapted = useAdaptIsActive(adaptScope), SelectImpl = isAdapted || !isWeb ? SelectSheetImpl : SelectInlineImpl, forceUpdate = React.useReducer(function() {
223
- return {};
224
- }, {})[1], [selectedItem, setSelectedItem] = React.useState(null), [open, setOpen] = useControllableState({
225
- prop: openProp,
226
- defaultProp: defaultOpen || !1,
227
- onChange: onOpenChange
228
- }), [value, setValue] = useControllableState({
229
- prop: valueProp,
230
- defaultProp: defaultValue || "",
231
- onChange: onValueChange,
232
- transition: !0
233
- });
234
- React.useEffect(function() {
314
+ var {
315
+ scope = "",
316
+ adaptScope,
317
+ native,
318
+ children,
319
+ open: openProp,
320
+ defaultOpen,
321
+ onOpenChange,
322
+ value: valueProp,
323
+ defaultValue,
324
+ onValueChange,
325
+ disablePreventBodyScroll,
326
+ size: sizeProp = "$true",
327
+ onActiveChange,
328
+ dir,
329
+ id
330
+ } = props,
331
+ isAdapted = (0, import_adapt.useAdaptIsActive)(adaptScope),
332
+ SelectImpl = isAdapted || !import_constants.isWeb ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl,
333
+ forceUpdate = React.useReducer(function () {
334
+ return {};
335
+ }, {})[1],
336
+ [selectedItem, setSelectedItem] = React.useState(null),
337
+ [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
338
+ prop: openProp,
339
+ defaultProp: defaultOpen || !1,
340
+ onChange: onOpenChange
341
+ }),
342
+ [value, setValue] = (0, import_use_controllable_state.useControllableState)({
343
+ prop: valueProp,
344
+ defaultProp: defaultValue || "",
345
+ onChange: onValueChange,
346
+ transition: !0
347
+ });
348
+ React.useEffect(function () {
235
349
  open && emitValue(value);
236
- }, [
237
- open
238
- ]), React.useEffect(function() {
350
+ }, [open]), React.useEffect(function () {
239
351
  emitValue(value);
240
- }, [
241
- value
242
- ]), React.useEffect(function() {
243
- if (props.id)
244
- return registerFocusable(props.id, {
245
- focusAndSelect: function() {
246
- setOpen == null || setOpen(function(value2) {
247
- return !value2;
248
- });
249
- },
250
- focus: function() {
251
- }
252
- });
253
- }, [
254
- props.id
255
- ]);
256
- var [activeIndex, setActiveIndex] = React.useState(0), [emitValue, valueSubscribe] = useEmitter(), [emitActiveIndex, activeIndexSubscribe] = useEmitter(), selectedIndexRef = React.useRef(null), activeIndexRef = React.useRef(null), listContentRef = React.useRef([]), [selectedIndex, setSelectedIndex] = React.useState(0), [valueNode, setValueNode] = React.useState(null);
257
- useIsomorphicLayoutEffect(function() {
352
+ }, [value]), React.useEffect(function () {
353
+ if (props.id) return (0, import_focusable.registerFocusable)(props.id, {
354
+ focusAndSelect: function () {
355
+ setOpen?.(function (value2) {
356
+ return !value2;
357
+ });
358
+ },
359
+ focus: function () {}
360
+ });
361
+ }, [props.id]);
362
+ var [activeIndex, setActiveIndex] = React.useState(0),
363
+ [emitValue, valueSubscribe] = useEmitter(),
364
+ [emitActiveIndex, activeIndexSubscribe] = useEmitter(),
365
+ selectedIndexRef = React.useRef(null),
366
+ activeIndexRef = React.useRef(null),
367
+ listContentRef = React.useRef([]),
368
+ [selectedIndex, setSelectedIndex] = React.useState(0),
369
+ [valueNode, setValueNode] = React.useState(null);
370
+ (0, import_constants.useIsomorphicLayoutEffect)(function () {
258
371
  selectedIndexRef.current = selectedIndex, activeIndexRef.current = activeIndex;
259
372
  });
260
- var shouldRenderWebNative = isWeb && (native === !0 || native === "web" || Array.isArray(native) && native.includes("web")), setActiveIndexDebounced = useDebounce(function(index) {
261
- setActiveIndex(function(prev) {
262
- return prev !== index ? (typeof index == "number" && emitActiveIndex(index), index) : prev;
263
- });
264
- }, 1, {}, []);
265
- return /* @__PURE__ */ _jsx(SelectItemParentProvider, {
373
+ var shouldRenderWebNative = import_constants.isWeb && (native === !0 || native === "web" || Array.isArray(native) && native.includes("web")),
374
+ setActiveIndexDebounced = (0, import_use_debounce.useDebounce)(function (index) {
375
+ setActiveIndex(function (prev) {
376
+ return prev !== index ? (typeof index == "number" && emitActiveIndex(index), index) : prev;
377
+ });
378
+ }, 1, {}, []);
379
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.SelectItemParentProvider, {
266
380
  scopeName: scope,
267
381
  scope,
268
382
  adaptScope,
269
- initialValue: React.useMemo(function() {
383
+ initialValue: React.useMemo(function () {
270
384
  return value;
271
- }, [
272
- open
273
- ]),
385
+ }, [open]),
274
386
  size: sizeProp,
275
387
  activeIndexSubscribe,
276
388
  valueSubscribe,
277
389
  setOpen,
278
390
  id,
279
- onChange: React.useCallback(function(val) {
391
+ onChange: React.useCallback(function (val) {
280
392
  setValue(val), emitValue(val);
281
393
  }, []),
282
- onActiveChange: useEvent(function(value2, index) {
283
- onActiveChange == null || onActiveChange(value2, index);
394
+ onActiveChange: (0, import_core.useEvent)(function (value2, index) {
395
+ onActiveChange?.(value2, index);
284
396
  }),
285
397
  setSelectedIndex,
286
- setValueAtIndex: React.useCallback(function(index, value2) {
398
+ setValueAtIndex: React.useCallback(function (index, value2) {
287
399
  listContentRef.current[index] = value2;
288
400
  }, []),
289
401
  shouldRenderWebNative,
290
- children: /* @__PURE__ */ _jsx(SelectProvider, {
402
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.SelectProvider, {
291
403
  scope,
292
404
  scopeName: scope,
293
405
  adaptScope,
@@ -306,10 +418,10 @@ function SelectInner(props) {
306
418
  value,
307
419
  open,
308
420
  native,
309
- children: /* @__PURE__ */ _jsx(SelectSheetController, {
421
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectSheetController, {
310
422
  onOpenChange: setOpen,
311
423
  scope,
312
- children: shouldRenderWebNative ? children : /* @__PURE__ */ _jsx(SelectImpl, {
424
+ children: shouldRenderWebNative ? children : /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectImpl, {
313
425
  activeIndexRef,
314
426
  listContentRef,
315
427
  selectedIndexRef,
@@ -322,10 +434,4 @@ function SelectInner(props) {
322
434
  })
323
435
  });
324
436
  }
325
- export {
326
- Select,
327
- SelectGroupFrame,
328
- SelectIcon,
329
- SelectSeparator
330
- };
331
- //# sourceMappingURL=Select.js.map
437
+ //# sourceMappingURL=Select.native.js.map