@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.
- package/dist/cjs/BubbleSelect.cjs +1 -1
- package/dist/cjs/BubbleSelect.js +1 -1
- package/dist/cjs/BubbleSelect.native.js +19 -13
- package/dist/cjs/BubbleSelect.native.js.map +1 -6
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Select.js +1 -1
- package/dist/cjs/Select.js.map +1 -1
- package/dist/cjs/Select.native.js +342 -242
- package/dist/cjs/Select.native.js.map +1 -6
- package/dist/cjs/SelectContent.cjs +1 -1
- package/dist/cjs/SelectContent.js +1 -1
- package/dist/cjs/SelectContent.js.map +1 -1
- package/dist/cjs/SelectContent.native.js +20 -15
- package/dist/cjs/SelectContent.native.js.map +1 -6
- package/dist/cjs/SelectImpl.cjs +1 -1
- package/dist/cjs/SelectImpl.js +1 -1
- package/dist/cjs/SelectImpl.js.map +1 -1
- package/dist/cjs/SelectImpl.native.js +22 -18
- package/dist/cjs/SelectImpl.native.js.map +1 -6
- package/dist/cjs/SelectItem.cjs +1 -1
- package/dist/cjs/SelectItem.js +1 -1
- package/dist/cjs/SelectItem.js.map +1 -1
- package/dist/cjs/SelectItem.native.js +158 -117
- package/dist/cjs/SelectItem.native.js.map +1 -6
- package/dist/cjs/SelectItemText.cjs +1 -1
- package/dist/cjs/SelectItemText.js +1 -1
- package/dist/cjs/SelectItemText.js.map +1 -1
- package/dist/cjs/SelectItemText.native.js +72 -51
- package/dist/cjs/SelectItemText.native.js.map +1 -6
- package/dist/cjs/SelectScrollButton.cjs +1 -1
- package/dist/cjs/SelectScrollButton.js +1 -1
- package/dist/cjs/SelectScrollButton.js.map +1 -1
- package/dist/cjs/SelectScrollButton.native.js +22 -19
- package/dist/cjs/SelectScrollButton.native.js.map +1 -6
- package/dist/cjs/SelectTrigger.cjs +1 -1
- package/dist/cjs/SelectTrigger.js +1 -1
- package/dist/cjs/SelectTrigger.js.map +1 -1
- package/dist/cjs/SelectTrigger.native.js +74 -51
- package/dist/cjs/SelectTrigger.native.js.map +1 -6
- package/dist/cjs/SelectViewport.native.js +43 -28
- package/dist/cjs/SelectViewport.native.js.map +1 -6
- package/dist/cjs/constants.native.js +24 -21
- package/dist/cjs/constants.native.js.map +1 -6
- package/dist/cjs/context.native.js +43 -30
- package/dist/cjs/context.native.js.map +1 -6
- package/dist/cjs/index.native.js +14 -14
- package/dist/cjs/index.native.js.map +1 -6
- package/dist/cjs/types.native.js +9 -5
- package/dist/cjs/types.native.js.map +1 -6
- package/dist/cjs/useSelectBreakpointActive.native.js +22 -18
- package/dist/cjs/useSelectBreakpointActive.native.js.map +1 -6
- package/dist/esm/SelectItem.native.js +4 -1
- package/dist/esm/SelectItem.native.js.map +1 -1
- package/dist/jsx/BubbleSelect.native.js +28 -4
- package/dist/jsx/BubbleSelect.native.js.map +1 -6
- package/dist/jsx/Select.native.js +363 -257
- package/dist/jsx/Select.native.js.map +1 -6
- package/dist/jsx/SelectContent.native.js +31 -5
- package/dist/jsx/SelectContent.native.js.map +1 -6
- package/dist/jsx/SelectImpl.native.js +33 -9
- package/dist/jsx/SelectImpl.native.js.map +1 -6
- package/dist/jsx/SelectItem.native.js +174 -109
- package/dist/jsx/SelectItem.native.js.map +1 -6
- package/dist/jsx/SelectItemText.native.js +90 -45
- package/dist/jsx/SelectItemText.native.js.map +1 -6
- package/dist/jsx/SelectScrollButton.native.js +34 -9
- package/dist/jsx/SelectScrollButton.native.js.map +1 -6
- package/dist/jsx/SelectTrigger.native.js +90 -44
- package/dist/jsx/SelectTrigger.native.js.map +1 -6
- package/dist/jsx/SelectViewport.native.js +55 -24
- package/dist/jsx/SelectViewport.native.js.map +1 -6
- package/dist/jsx/constants.native.js +41 -11
- package/dist/jsx/constants.native.js.map +1 -6
- package/dist/jsx/context.native.js +58 -22
- package/dist/jsx/context.native.js.map +1 -6
- package/dist/jsx/index.native.js +22 -3
- package/dist/jsx/index.native.js.map +1 -6
- package/dist/jsx/types.native.js +19 -1
- package/dist/jsx/types.native.js.map +1 -6
- package/dist/jsx/useSelectBreakpointActive.native.js +33 -9
- package/dist/jsx/useSelectBreakpointActive.native.js.map +1 -6
- 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,
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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", {
|
|
22
|
-
|
|
23
|
-
|
|
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"),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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",
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
167
|
-
}),
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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__ */
|
|
212
|
-
var emit = function(value) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
listeners.current.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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 {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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")),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
|
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__ */
|
|
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__ */
|
|
421
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectSheetController, {
|
|
315
422
|
onOpenChange: setOpen,
|
|
316
423
|
scope,
|
|
317
|
-
children: shouldRenderWebNative ? children : /* @__PURE__ */
|
|
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
|
-
|
|
331
|
-
0 && (module.exports = {
|
|
332
|
-
Select,
|
|
333
|
-
SelectGroupFrame,
|
|
334
|
-
SelectIcon,
|
|
335
|
-
SelectSeparator
|
|
336
|
-
});
|
|
337
|
-
//# sourceMappingURL=Select.js.map
|
|
437
|
+
//# sourceMappingURL=Select.native.js.map
|