@tamagui/select 1.89.26 → 1.89.27-1708113113238
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.
- package/dist/cjs/BubbleSelect.native.js +0 -13
- package/dist/cjs/BubbleSelect.native.js.map +2 -2
- package/dist/cjs/Select.native.js +335 -242
- package/dist/cjs/Select.native.js.map +3 -3
- package/dist/cjs/SelectContent.native.js +4 -1
- package/dist/cjs/SelectContent.native.js.map +3 -3
- package/dist/cjs/SelectImpl.native.js +3 -2
- package/dist/cjs/SelectImpl.native.js.map +3 -3
- package/dist/cjs/SelectItem.native.js +172 -97
- package/dist/cjs/SelectItem.native.js.map +3 -3
- package/dist/cjs/SelectItemText.native.js +73 -16
- package/dist/cjs/SelectItemText.native.js.map +3 -3
- package/dist/cjs/SelectScrollButton.native.js +5 -1
- package/dist/cjs/SelectScrollButton.native.js.map +3 -3
- package/dist/cjs/SelectTrigger.native.js +92 -42
- package/dist/cjs/SelectTrigger.native.js.map +3 -3
- package/dist/cjs/SelectViewport.native.js +13 -12
- package/dist/cjs/SelectViewport.native.js.map +3 -3
- package/dist/cjs/constants.native.js +1 -1
- package/dist/cjs/constants.native.js.map +3 -3
- package/dist/cjs/context.native.js +76 -7
- package/dist/cjs/context.native.js.map +3 -3
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/cjs/types.native.js.map +2 -2
- package/dist/cjs/useSelectBreakpointActive.native.js +4 -5
- package/dist/cjs/useSelectBreakpointActive.native.js.map +3 -3
- package/dist/esm/BubbleSelect.native.js +0 -13
- package/dist/esm/BubbleSelect.native.js.map +3 -3
- package/dist/esm/Select.native.js +336 -253
- package/dist/esm/Select.native.js.map +3 -3
- package/dist/esm/SelectContent.native.js +4 -1
- package/dist/esm/SelectContent.native.js.map +3 -3
- package/dist/esm/SelectImpl.native.js +3 -2
- package/dist/esm/SelectImpl.native.js.map +3 -3
- package/dist/esm/SelectItem.native.js +171 -97
- package/dist/esm/SelectItem.native.js.map +3 -3
- package/dist/esm/SelectItemText.native.js +72 -16
- package/dist/esm/SelectItemText.native.js.map +3 -3
- package/dist/esm/SelectScrollButton.native.js +5 -1
- package/dist/esm/SelectScrollButton.native.js.map +3 -3
- package/dist/esm/SelectTrigger.native.js +91 -42
- package/dist/esm/SelectTrigger.native.js.map +3 -3
- package/dist/esm/SelectViewport.native.js +14 -17
- package/dist/esm/SelectViewport.native.js.map +3 -3
- package/dist/esm/constants.native.js +1 -1
- package/dist/esm/constants.native.js.map +3 -3
- package/dist/esm/context.native.js +75 -7
- package/dist/esm/context.native.js.map +3 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/useSelectBreakpointActive.native.js +4 -4
- package/dist/esm/useSelectBreakpointActive.native.js.map +3 -3
- package/dist/jsx/BubbleSelect.native.js +0 -13
- package/dist/jsx/BubbleSelect.native.js.map +3 -3
- package/dist/jsx/Select.native.js +336 -253
- package/dist/jsx/Select.native.js.map +3 -3
- package/dist/jsx/SelectContent.native.js +4 -1
- package/dist/jsx/SelectContent.native.js.map +3 -3
- package/dist/jsx/SelectImpl.native.js +3 -2
- package/dist/jsx/SelectImpl.native.js.map +3 -3
- package/dist/jsx/SelectItem.native.js +171 -97
- package/dist/jsx/SelectItem.native.js.map +3 -3
- package/dist/jsx/SelectItemText.native.js +72 -16
- package/dist/jsx/SelectItemText.native.js.map +3 -3
- package/dist/jsx/SelectScrollButton.native.js +5 -1
- package/dist/jsx/SelectScrollButton.native.js.map +3 -3
- package/dist/jsx/SelectTrigger.native.js +91 -42
- package/dist/jsx/SelectTrigger.native.js.map +3 -3
- package/dist/jsx/SelectViewport.native.js +14 -17
- package/dist/jsx/SelectViewport.native.js.map +3 -3
- package/dist/jsx/constants.native.js +1 -1
- package/dist/jsx/constants.native.js.map +3 -3
- package/dist/jsx/context.native.js +75 -7
- package/dist/jsx/context.native.js.map +3 -3
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useSelectBreakpointActive.native.js +4 -4
- package/dist/jsx/useSelectBreakpointActive.native.js.map +3 -3
- package/package.json +24 -24
|
@@ -29,62 +29,171 @@ __export(Select_exports, {
|
|
|
29
29
|
SelectSeparator: () => SelectSeparator
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(Select_exports);
|
|
32
|
-
var import_adapt = require("@tamagui/adapt"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_get_token = require("@tamagui/get-token"), import_helpers = require("@tamagui/helpers"), import_list_item = require("@tamagui/list-item"), import_portal = require("@tamagui/portal"), 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"), React = __toESM(require("react")), import_use_debounce = require("@tamagui/use-debounce"), import_constants2 = require("./constants"), 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")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
32
|
+
var import_adapt = require("@tamagui/adapt"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_get_token = require("@tamagui/get-token"), import_helpers = require("@tamagui/helpers"), import_list_item = require("@tamagui/list-item"), import_portal = require("@tamagui/portal"), 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"), React = __toESM(require("react")), import_use_debounce = require("@tamagui/use-debounce"), import_constants2 = require("./constants"), 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");
|
|
33
|
+
function _array_like_to_array(arr, len) {
|
|
34
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
35
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
36
|
+
arr2[i] = arr[i];
|
|
37
|
+
return arr2;
|
|
38
|
+
}
|
|
39
|
+
function _array_with_holes(arr) {
|
|
40
|
+
if (Array.isArray(arr))
|
|
41
|
+
return arr;
|
|
42
|
+
}
|
|
43
|
+
function _array_without_holes(arr) {
|
|
44
|
+
if (Array.isArray(arr))
|
|
45
|
+
return _array_like_to_array(arr);
|
|
46
|
+
}
|
|
47
|
+
function _define_property(obj, key, value) {
|
|
48
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
49
|
+
value,
|
|
50
|
+
enumerable: !0,
|
|
51
|
+
configurable: !0,
|
|
52
|
+
writable: !0
|
|
53
|
+
}) : obj[key] = value, obj;
|
|
54
|
+
}
|
|
55
|
+
function _iterable_to_array(iter) {
|
|
56
|
+
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
57
|
+
return Array.from(iter);
|
|
58
|
+
}
|
|
59
|
+
function _iterable_to_array_limit(arr, i) {
|
|
60
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
61
|
+
if (_i != null) {
|
|
62
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
63
|
+
try {
|
|
64
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
65
|
+
;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
_d = !0, _e = err;
|
|
68
|
+
} finally {
|
|
69
|
+
try {
|
|
70
|
+
!_n && _i.return != null && _i.return();
|
|
71
|
+
} finally {
|
|
72
|
+
if (_d)
|
|
73
|
+
throw _e;
|
|
57
74
|
}
|
|
58
|
-
|
|
75
|
+
}
|
|
76
|
+
return _arr;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function _non_iterable_rest() {
|
|
80
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
81
|
+
}
|
|
82
|
+
function _non_iterable_spread() {
|
|
83
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
84
|
+
}
|
|
85
|
+
function _object_spread(target) {
|
|
86
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
87
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
88
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
89
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
90
|
+
}))), ownKeys2.forEach(function(key) {
|
|
91
|
+
_define_property(target, key, source[key]);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return target;
|
|
95
|
+
}
|
|
96
|
+
function ownKeys(object, enumerableOnly) {
|
|
97
|
+
var keys = Object.keys(object);
|
|
98
|
+
if (Object.getOwnPropertySymbols) {
|
|
99
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
100
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
101
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
102
|
+
})), keys.push.apply(keys, symbols);
|
|
103
|
+
}
|
|
104
|
+
return keys;
|
|
105
|
+
}
|
|
106
|
+
function _object_spread_props(target, source) {
|
|
107
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
108
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
109
|
+
}), target;
|
|
110
|
+
}
|
|
111
|
+
function _object_without_properties(source, excluded) {
|
|
112
|
+
if (source == null)
|
|
113
|
+
return {};
|
|
114
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
115
|
+
if (Object.getOwnPropertySymbols) {
|
|
116
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
117
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
118
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
function _object_without_properties_loose(source, excluded) {
|
|
123
|
+
if (source == null)
|
|
124
|
+
return {};
|
|
125
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
126
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
127
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
128
|
+
return target;
|
|
129
|
+
}
|
|
130
|
+
function _sliced_to_array(arr, i) {
|
|
131
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
132
|
+
}
|
|
133
|
+
function _to_consumable_array(arr) {
|
|
134
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
135
|
+
}
|
|
136
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
137
|
+
if (o) {
|
|
138
|
+
if (typeof o == "string")
|
|
139
|
+
return _array_like_to_array(o, minLen);
|
|
140
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
141
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
142
|
+
return Array.from(n);
|
|
143
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
144
|
+
return _array_like_to_array(o, minLen);
|
|
59
145
|
}
|
|
60
|
-
|
|
146
|
+
}
|
|
147
|
+
var VALUE_NAME = "SelectValue", SelectValueFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
148
|
+
name: VALUE_NAME,
|
|
149
|
+
userSelect: "none"
|
|
150
|
+
}), SelectValue = SelectValueFrame.styleable(function(_param, forwardedRef) {
|
|
151
|
+
var __scopeSelect = _param.__scopeSelect, childrenProp = _param.children, placeholder = _param.placeholder, props = _object_without_properties(_param, [
|
|
152
|
+
"__scopeSelect",
|
|
153
|
+
"children",
|
|
154
|
+
"placeholder"
|
|
155
|
+
]), context = (0, import_context.useSelectContext)(VALUE_NAME, __scopeSelect), itemParentContext = (0, import_context.useSelectItemParentContext)(VALUE_NAME, __scopeSelect), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange), children = childrenProp ?? context.selectedItem, isEmptyValue = context.value == null || context.value === "", selectValueChildren = isEmptyValue ? placeholder ?? children : children;
|
|
156
|
+
return /* @__PURE__ */ React.createElement(SelectValueFrame, _object_spread(_object_spread_props(_object_spread({}, !props.unstyled && {
|
|
157
|
+
size: itemParentContext.size,
|
|
158
|
+
ellipse: !0,
|
|
159
|
+
// we don't want events from the portalled `SelectValue` children to bubble
|
|
160
|
+
// through the item they came from
|
|
161
|
+
pointerEvents: "none"
|
|
162
|
+
}), {
|
|
163
|
+
ref: composedRefs
|
|
164
|
+
}), props), unwrapSelectItem(selectValueChildren));
|
|
165
|
+
});
|
|
61
166
|
function unwrapSelectItem(selectValueChildren) {
|
|
62
|
-
return React.Children.map(selectValueChildren, (child)
|
|
63
|
-
var _a, _b, _c;
|
|
167
|
+
return React.Children.map(selectValueChildren, function(child) {
|
|
64
168
|
if (child) {
|
|
65
|
-
|
|
169
|
+
var _child_type_staticConfig, _child_type, _child_props;
|
|
170
|
+
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)
|
|
66
171
|
return child.props.children;
|
|
67
|
-
if ((
|
|
172
|
+
if (!((_child_props = child.props) === null || _child_props === void 0) && _child_props.children)
|
|
68
173
|
return unwrapSelectItem(child.props.children);
|
|
69
174
|
}
|
|
70
175
|
return child;
|
|
71
176
|
});
|
|
72
177
|
}
|
|
73
|
-
|
|
178
|
+
var SelectIcon = (0, import_core.styled)(import_stacks.XStack, {
|
|
74
179
|
name: "SelectIcon",
|
|
75
180
|
// @ts-ignore
|
|
76
181
|
"aria-hidden": !0,
|
|
77
|
-
children: /* @__PURE__ */
|
|
182
|
+
children: /* @__PURE__ */ React.createElement(import_text.Paragraph, null, "\u25BC")
|
|
78
183
|
}), ITEM_INDICATOR_NAME = "SelectItemIndicator", SelectItemIndicatorFrame = (0, import_core.styled)(import_stacks.XStack, {
|
|
79
184
|
name: import_SelectItemText.ITEM_TEXT_NAME
|
|
80
|
-
}), SelectItemIndicator = React.forwardRef(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
185
|
+
}), SelectItemIndicator = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
186
|
+
var __scopeSelect = props.__scopeSelect, itemIndicatorProps = _object_without_properties(props, [
|
|
187
|
+
"__scopeSelect"
|
|
188
|
+
]), context = (0, import_context.useSelectItemParentContext)(ITEM_INDICATOR_NAME, __scopeSelect), itemContext = (0, import_SelectItem.useSelectItemContext)(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
189
|
+
return context.shouldRenderWebNative ? null : itemContext.isSelected ? /* @__PURE__ */ React.createElement(SelectItemIndicatorFrame, _object_spread_props(_object_spread({
|
|
190
|
+
"aria-hidden": !0
|
|
191
|
+
}, itemIndicatorProps), {
|
|
192
|
+
ref: forwardedRef
|
|
193
|
+
})) : null;
|
|
194
|
+
});
|
|
86
195
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
87
|
-
|
|
196
|
+
var GROUP_NAME = "SelectGroup", _createSelectContext = _sliced_to_array((0, import_context.createSelectContext)(GROUP_NAME), 2), SelectGroupContextProvider = _createSelectContext[0], useSelectGroupContext = _createSelectContext[1], SelectGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
88
197
|
name: GROUP_NAME,
|
|
89
198
|
width: "100%"
|
|
90
199
|
}), NativeSelectTextFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
@@ -102,10 +211,10 @@ const GROUP_NAME = "SelectGroup", [SelectGroupContextProvider, useSelectGroupCon
|
|
|
102
211
|
paddingRight: 10,
|
|
103
212
|
variants: {
|
|
104
213
|
size: {
|
|
105
|
-
"...size": (val, extras)
|
|
106
|
-
|
|
214
|
+
"...size": function(val, extras) {
|
|
215
|
+
var tokens = extras.tokens, paddingHorizontal = (0, import_core.getVariableValue)(tokens.space[val]), _tokens_radius_val;
|
|
107
216
|
return {
|
|
108
|
-
borderRadius: tokens.radius[val]
|
|
217
|
+
borderRadius: (_tokens_radius_val = tokens.radius[val]) !== null && _tokens_radius_val !== void 0 ? _tokens_radius_val : val,
|
|
109
218
|
minHeight: tokens.size[val],
|
|
110
219
|
paddingRight: paddingHorizontal + 20,
|
|
111
220
|
paddingLeft: paddingHorizontal,
|
|
@@ -119,212 +228,196 @@ const GROUP_NAME = "SelectGroup", [SelectGroupContextProvider, useSelectGroupCon
|
|
|
119
228
|
defaultVariants: {
|
|
120
229
|
size: "$2"
|
|
121
230
|
}
|
|
122
|
-
}), SelectGroup = React.forwardRef(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
children: props.children
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
149
|
-
SelectGroupFrame,
|
|
150
|
-
{
|
|
151
|
-
role: "group",
|
|
152
|
-
"aria-labelledby": groupId,
|
|
153
|
-
...groupProps,
|
|
154
|
-
ref: forwardedRef
|
|
231
|
+
}), SelectGroup = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
232
|
+
var __scopeSelect = props.__scopeSelect, groupProps = _object_without_properties(props, [
|
|
233
|
+
"__scopeSelect"
|
|
234
|
+
]), groupId = React.useId(), context = (0, import_context.useSelectContext)(GROUP_NAME, __scopeSelect), itemParentContext = (0, import_context.useSelectItemParentContext)(GROUP_NAME, __scopeSelect), _itemParentContext_size, size = (_itemParentContext_size = itemParentContext.size) !== null && _itemParentContext_size !== void 0 ? _itemParentContext_size : "$true", nativeSelectRef = React.useRef(null), content = function() {
|
|
235
|
+
return itemParentContext.shouldRenderWebNative ? /* @__PURE__ */ React.createElement(NativeSelectFrame, {
|
|
236
|
+
asChild: !0,
|
|
237
|
+
size,
|
|
238
|
+
// @ts-expect-error until we support typing based on tag
|
|
239
|
+
value: context.value,
|
|
240
|
+
id: itemParentContext.id
|
|
241
|
+
}, /* @__PURE__ */ React.createElement(NativeSelectTextFrame, {
|
|
242
|
+
// @ts-ignore it's ok since tag="select"
|
|
243
|
+
onChange: function(event) {
|
|
244
|
+
itemParentContext.onChange(event.currentTarget.value);
|
|
245
|
+
},
|
|
246
|
+
size,
|
|
247
|
+
ref: nativeSelectRef,
|
|
248
|
+
style: {
|
|
249
|
+
color: "var(--color)",
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
appearance: "none"
|
|
155
252
|
}
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
253
|
+
}, props.children)) : /* @__PURE__ */ React.createElement(SelectGroupFrame, _object_spread_props(_object_spread({
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
role: "group",
|
|
256
|
+
"aria-labelledby": groupId
|
|
257
|
+
}, groupProps), {
|
|
258
|
+
ref: forwardedRef
|
|
259
|
+
}));
|
|
260
|
+
}();
|
|
261
|
+
return /* @__PURE__ */ React.createElement(SelectGroupContextProvider, {
|
|
262
|
+
scope: __scopeSelect,
|
|
263
|
+
id: groupId || ""
|
|
264
|
+
}, content);
|
|
265
|
+
});
|
|
160
266
|
SelectGroup.displayName = GROUP_NAME;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
);
|
|
267
|
+
var LABEL_NAME = "SelectLabel", SelectLabel = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
268
|
+
var __scopeSelect = props.__scopeSelect, labelProps = _object_without_properties(props, [
|
|
269
|
+
"__scopeSelect"
|
|
270
|
+
]), context = (0, import_context.useSelectItemParentContext)(LABEL_NAME, __scopeSelect), groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
271
|
+
return context.shouldRenderWebNative ? null : /* @__PURE__ */ React.createElement(import_list_item.ListItem, _object_spread_props(_object_spread({
|
|
272
|
+
tag: "div",
|
|
273
|
+
componentName: LABEL_NAME,
|
|
274
|
+
fontWeight: "800",
|
|
275
|
+
id: groupContext.id,
|
|
276
|
+
size: context.size
|
|
277
|
+
}, labelProps), {
|
|
278
|
+
ref: forwardedRef
|
|
279
|
+
}));
|
|
280
|
+
});
|
|
178
281
|
SelectLabel.displayName = LABEL_NAME;
|
|
179
|
-
|
|
282
|
+
var SelectSeparator = (0, import_core.styled)(import_separator.Separator, {
|
|
180
283
|
name: "SelectSeparator"
|
|
181
|
-
}), SelectSheetController = (props)
|
|
182
|
-
|
|
183
|
-
return /* @__PURE__ */ (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
emitValue(value);
|
|
230
|
-
}, [value]);
|
|
231
|
-
const [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);
|
|
232
|
-
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
233
|
-
selectedIndexRef.current = selectedIndex, activeIndexRef.current = activeIndex;
|
|
284
|
+
}), SelectSheetController = function(props) {
|
|
285
|
+
var context = (0, import_context.useSelectContext)("SelectSheetController", props.__scopeSelect), showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context), breakpointActive = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(context.sheetBreakpoint), getShowSheet = (0, import_core.useGet)(showSheet);
|
|
286
|
+
return /* @__PURE__ */ React.createElement(import_sheet.SheetController, {
|
|
287
|
+
onOpenChange: function(val) {
|
|
288
|
+
getShowSheet() && props.onOpenChange(val);
|
|
289
|
+
},
|
|
290
|
+
open: context.open,
|
|
291
|
+
hidden: breakpointActive === !1
|
|
292
|
+
}, props.children);
|
|
293
|
+
}, SelectSheetImpl = function(props) {
|
|
294
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
|
|
295
|
+
}, Select = (0, import_helpers.withStaticProperties)(function(props) {
|
|
296
|
+
var __scopeSelect = props.__scopeSelect, native = props.native, children = props.children, openProp = props.open, defaultOpen = props.defaultOpen, onOpenChange = props.onOpenChange, valueProp = props.value, defaultValue = props.defaultValue, onValueChange = props.onValueChange, disablePreventBodyScroll = props.disablePreventBodyScroll, tmp = props.size, sizeProp = tmp === void 0 ? "$true" : tmp, onActiveChange = props.onActiveChange, dir = props.dir, id = props.id, internalId = React.useId(), _Object_keys_, scopeKey = __scopeSelect && (_Object_keys_ = Object.keys(__scopeSelect)[0]) !== null && _Object_keys_ !== void 0 ? _Object_keys_ : internalId, _useAdaptParent = (0, import_adapt.useAdaptParent)({
|
|
297
|
+
Contents: React.useCallback(function() {
|
|
298
|
+
return /* @__PURE__ */ React.createElement(import_portal.PortalHost, {
|
|
299
|
+
name: "".concat(scopeKey, "SheetContents")
|
|
300
|
+
});
|
|
301
|
+
}, [
|
|
302
|
+
scopeKey
|
|
303
|
+
])
|
|
304
|
+
}), when = _useAdaptParent.when, AdaptProvider = _useAdaptParent.AdaptProvider, sheetBreakpoint = when, isSheet = (0, import_useSelectBreakpointActive.useSelectBreakpointActive)(sheetBreakpoint), SelectImpl = isSheet || !import_constants.isWeb ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl, forceUpdate = React.useReducer(function() {
|
|
305
|
+
return {};
|
|
306
|
+
}, {})[1], _React_useState = _sliced_to_array(React.useState(null), 2), selectedItem = _React_useState[0], setSelectedItem = _React_useState[1], _useControllableState = _sliced_to_array((0, import_use_controllable_state.useControllableState)({
|
|
307
|
+
prop: openProp,
|
|
308
|
+
defaultProp: defaultOpen || !1,
|
|
309
|
+
onChange: onOpenChange
|
|
310
|
+
}), 2), open = _useControllableState[0], setOpen = _useControllableState[1], _useControllableState1 = _sliced_to_array((0, import_use_controllable_state.useControllableState)({
|
|
311
|
+
prop: valueProp,
|
|
312
|
+
defaultProp: defaultValue || "",
|
|
313
|
+
onChange: onValueChange,
|
|
314
|
+
transition: !0
|
|
315
|
+
}), 2), value = _useControllableState1[0], setValue = _useControllableState1[1];
|
|
316
|
+
React.useEffect(function() {
|
|
317
|
+
open && emitValue(value);
|
|
318
|
+
}, [
|
|
319
|
+
open
|
|
320
|
+
]), React.useEffect(function() {
|
|
321
|
+
emitValue(value);
|
|
322
|
+
}, [
|
|
323
|
+
value
|
|
324
|
+
]);
|
|
325
|
+
var _React_useState1 = _sliced_to_array(React.useState(0), 2), activeIndex = _React_useState1[0], setActiveIndex = _React_useState1[1], _useEmitter = _sliced_to_array(useEmitter(), 2), emitValue = _useEmitter[0], valueSubscribe = _useEmitter[1], _useEmitter1 = _sliced_to_array(useEmitter(), 2), emitActiveIndex = _useEmitter1[0], activeIndexSubscribe = _useEmitter1[1], selectedIndexRef = React.useRef(null), activeIndexRef = React.useRef(null), listContentRef = React.useRef([]), _React_useState2 = _sliced_to_array(React.useState(0), 2), selectedIndex = _React_useState2[0], setSelectedIndex = _React_useState2[1], _React_useState3 = _sliced_to_array(React.useState(null), 2), valueNode = _React_useState3[0], setValueNode = _React_useState3[1];
|
|
326
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
327
|
+
selectedIndexRef.current = selectedIndex, activeIndexRef.current = activeIndex;
|
|
328
|
+
});
|
|
329
|
+
var shouldRenderWebNative = import_constants.isWeb && (native === !0 || native === "web" || Array.isArray(native) && native.includes("web")), setActiveIndexDebounced = (0, import_use_debounce.useDebounce)(function(index) {
|
|
330
|
+
setActiveIndex(function(prev) {
|
|
331
|
+
return prev !== index ? (typeof index == "number" && emitActiveIndex(index), index) : prev;
|
|
234
332
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
Item: import_SelectItem.SelectItem,
|
|
308
|
-
ItemIndicator: SelectItemIndicator,
|
|
309
|
-
ItemText: import_SelectItemText.SelectItemText,
|
|
310
|
-
Label: SelectLabel,
|
|
311
|
-
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
312
|
-
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
313
|
-
Trigger: import_SelectTrigger.SelectTrigger,
|
|
314
|
-
Value: SelectValue,
|
|
315
|
-
Viewport: import_SelectViewport.SelectViewport,
|
|
316
|
-
Sheet: import_sheet.Sheet.Controlled
|
|
317
|
-
}
|
|
318
|
-
);
|
|
333
|
+
}, 1, {}, []);
|
|
334
|
+
return /* @__PURE__ */ React.createElement(AdaptProvider, null, /* @__PURE__ */ React.createElement(import_context.SelectItemParentProvider, {
|
|
335
|
+
scope: __scopeSelect,
|
|
336
|
+
initialValue: React.useMemo(function() {
|
|
337
|
+
return value;
|
|
338
|
+
}, [
|
|
339
|
+
open
|
|
340
|
+
]),
|
|
341
|
+
size: sizeProp,
|
|
342
|
+
activeIndexSubscribe,
|
|
343
|
+
valueSubscribe,
|
|
344
|
+
setOpen,
|
|
345
|
+
id,
|
|
346
|
+
onChange: React.useCallback(function(val) {
|
|
347
|
+
setValue(val), emitValue(val);
|
|
348
|
+
}, []),
|
|
349
|
+
onActiveChange: (0, import_core.useEvent)(function() {
|
|
350
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
|
|
351
|
+
args[_key] = arguments[_key];
|
|
352
|
+
onActiveChange == null || onActiveChange.apply(void 0, _to_consumable_array(args));
|
|
353
|
+
}),
|
|
354
|
+
setSelectedIndex,
|
|
355
|
+
setValueAtIndex: React.useCallback(function(index, value2) {
|
|
356
|
+
listContentRef.current[index] = value2;
|
|
357
|
+
}, []),
|
|
358
|
+
shouldRenderWebNative
|
|
359
|
+
}, /* @__PURE__ */ React.createElement(import_context.SelectProvider, {
|
|
360
|
+
scope: __scopeSelect,
|
|
361
|
+
disablePreventBodyScroll,
|
|
362
|
+
dir,
|
|
363
|
+
blockSelection: !1,
|
|
364
|
+
fallback: !1,
|
|
365
|
+
selectedItem,
|
|
366
|
+
setSelectedItem,
|
|
367
|
+
forceUpdate,
|
|
368
|
+
valueNode,
|
|
369
|
+
onValueNodeChange: setValueNode,
|
|
370
|
+
scopeKey,
|
|
371
|
+
sheetBreakpoint,
|
|
372
|
+
activeIndex,
|
|
373
|
+
selectedIndex,
|
|
374
|
+
setActiveIndex: setActiveIndexDebounced,
|
|
375
|
+
value,
|
|
376
|
+
open,
|
|
377
|
+
native
|
|
378
|
+
}, /* @__PURE__ */ React.createElement(SelectSheetController, {
|
|
379
|
+
onOpenChange: setOpen,
|
|
380
|
+
__scopeSelect
|
|
381
|
+
}, shouldRenderWebNative ? children : /* @__PURE__ */ React.createElement(SelectImpl, _object_spread_props(_object_spread({
|
|
382
|
+
activeIndexRef,
|
|
383
|
+
listContentRef,
|
|
384
|
+
selectedIndexRef
|
|
385
|
+
}, props), {
|
|
386
|
+
open,
|
|
387
|
+
value
|
|
388
|
+
}), children)))));
|
|
389
|
+
}, {
|
|
390
|
+
Adapt: import_adapt.Adapt,
|
|
391
|
+
Content: import_SelectContent.SelectContent,
|
|
392
|
+
Group: SelectGroup,
|
|
393
|
+
Icon: SelectIcon,
|
|
394
|
+
Item: import_SelectItem.SelectItem,
|
|
395
|
+
ItemIndicator: SelectItemIndicator,
|
|
396
|
+
ItemText: import_SelectItemText.SelectItemText,
|
|
397
|
+
Label: SelectLabel,
|
|
398
|
+
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
399
|
+
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
400
|
+
Trigger: import_SelectTrigger.SelectTrigger,
|
|
401
|
+
Value: SelectValue,
|
|
402
|
+
Viewport: import_SelectViewport.SelectViewport,
|
|
403
|
+
Sheet: import_sheet.Sheet.Controlled
|
|
404
|
+
});
|
|
319
405
|
function useEmitter() {
|
|
320
|
-
|
|
406
|
+
var listeners = React.useRef();
|
|
321
407
|
listeners.current || (listeners.current = /* @__PURE__ */ new Set());
|
|
322
|
-
|
|
323
|
-
listeners.current.forEach((l)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
408
|
+
var emit = function(value) {
|
|
409
|
+
listeners.current.forEach(function(l) {
|
|
410
|
+
return l(value);
|
|
411
|
+
});
|
|
412
|
+
}, subscribe = React.useCallback(function(listener) {
|
|
413
|
+
return listeners.current.add(listener), function() {
|
|
414
|
+
listeners.current.delete(listener);
|
|
415
|
+
};
|
|
416
|
+
}, []);
|
|
417
|
+
return [
|
|
418
|
+
emit,
|
|
419
|
+
subscribe
|
|
420
|
+
];
|
|
328
421
|
}
|
|
329
422
|
Select.displayName = import_constants2.SELECT_NAME;
|
|
330
423
|
// Annotate the CommonJS export names for ESM import in node:
|