@tamagui/select 1.135.4 → 1.135.5

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