@tamagui/select 1.125.6 → 1.125.7
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/esm/BubbleSelect.native.js +1 -1
- package/dist/esm/BubbleSelect.native.js.map +1 -6
- package/dist/esm/Select.native.js +299 -236
- package/dist/esm/Select.native.js.map +1 -6
- package/dist/esm/SelectContent.native.js +5 -5
- package/dist/esm/SelectContent.native.js.map +1 -6
- package/dist/esm/SelectImpl.native.js +3 -5
- package/dist/esm/SelectImpl.native.js.map +1 -6
- package/dist/esm/SelectItem.native.js +125 -105
- package/dist/esm/SelectItem.native.js.map +1 -6
- package/dist/esm/SelectItemText.native.js +46 -40
- package/dist/esm/SelectItemText.native.js.map +1 -6
- package/dist/esm/SelectScrollButton.native.js +7 -9
- package/dist/esm/SelectScrollButton.native.js.map +1 -6
- package/dist/esm/SelectTrigger.native.js +48 -39
- package/dist/esm/SelectTrigger.native.js.map +1 -6
- package/dist/esm/SelectViewport.native.js +16 -11
- package/dist/esm/SelectViewport.native.js.map +1 -6
- package/dist/esm/constants.native.js +9 -11
- package/dist/esm/constants.native.js.map +1 -6
- package/dist/esm/context.native.js +24 -25
- package/dist/esm/context.native.js.map +1 -6
- package/dist/esm/index.native.js +3 -3
- package/dist/esm/index.native.js.map +1 -6
- package/dist/esm/types.native.js +2 -1
- package/dist/esm/types.native.js.map +1 -6
- package/dist/esm/useSelectBreakpointActive.native.js +3 -5
- package/dist/esm/useSelectBreakpointActive.native.js.map +1 -6
- package/package.json +23 -23
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Users/n8/tamagui/code/ui/select/src/BubbleSelect.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAASA,uBAAuB;AAChC,SAASC,mBAAmB;AAC5B,YAAYC,WAAW;",
|
|
5
|
-
"names": ["useComposedRefs", "usePrevious", "React"]
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["useComposedRefs","usePrevious","React"],"sources":["../../src/BubbleSelect.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAuB;AAChC,SAASC,WAAA,QAAmB;AAC5B,YAAYC,KAAA,MAAW","ignoreList":[]}
|
|
@@ -14,277 +14,345 @@ import { Paragraph, SizableText } from "@tamagui/text";
|
|
|
14
14
|
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
15
15
|
import { useDebounce } from "@tamagui/use-debounce";
|
|
16
16
|
import * as React from "react";
|
|
17
|
-
import { SelectItemParentProvider, SelectProvider, createSelectContext, useSelectContext, useSelectItemParentContext } from "./context";
|
|
18
|
-
import { SelectContent } from "./SelectContent";
|
|
19
|
-
import { SelectInlineImpl } from "./SelectImpl";
|
|
20
|
-
import { SelectItem, useSelectItemContext } from "./SelectItem";
|
|
21
|
-
import { ITEM_TEXT_NAME, SelectItemText } from "./SelectItemText";
|
|
22
|
-
import { SelectScrollDownButton, SelectScrollUpButton } from "./SelectScrollButton";
|
|
23
|
-
import { SelectTrigger } from "./SelectTrigger";
|
|
24
|
-
import { SelectViewport } from "./SelectViewport";
|
|
25
|
-
import { useShowSelectSheet } from "./useSelectBreakpointActive";
|
|
26
|
-
var VALUE_NAME = "SelectValue",
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
import { SelectItemParentProvider, SelectProvider, createSelectContext, useSelectContext, useSelectItemParentContext } from "./context.native.js";
|
|
18
|
+
import { SelectContent } from "./SelectContent.native.js";
|
|
19
|
+
import { SelectInlineImpl } from "./SelectImpl.native.js";
|
|
20
|
+
import { SelectItem, useSelectItemContext } from "./SelectItem.native.js";
|
|
21
|
+
import { ITEM_TEXT_NAME, SelectItemText } from "./SelectItemText.native.js";
|
|
22
|
+
import { SelectScrollDownButton, SelectScrollUpButton } from "./SelectScrollButton.native.js";
|
|
23
|
+
import { SelectTrigger } from "./SelectTrigger.native.js";
|
|
24
|
+
import { SelectViewport } from "./SelectViewport.native.js";
|
|
25
|
+
import { useShowSelectSheet } from "./useSelectBreakpointActive.native.js";
|
|
26
|
+
var VALUE_NAME = "SelectValue",
|
|
27
|
+
SelectValueFrame = styled(SizableText, {
|
|
28
|
+
name: VALUE_NAME,
|
|
29
|
+
userSelect: "none"
|
|
30
|
+
}),
|
|
31
|
+
SelectValue = SelectValueFrame.styleable(function (param, forwardedRef) {
|
|
32
|
+
var {
|
|
33
|
+
__scopeSelect,
|
|
34
|
+
children: childrenProp,
|
|
35
|
+
placeholder,
|
|
36
|
+
...props
|
|
37
|
+
} = param,
|
|
38
|
+
context = useSelectContext(VALUE_NAME, __scopeSelect),
|
|
39
|
+
itemParentContext = useSelectItemParentContext(VALUE_NAME, __scopeSelect),
|
|
40
|
+
composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange),
|
|
41
|
+
children = childrenProp ?? context.selectedItem,
|
|
42
|
+
isEmptyValue = context.value == null || context.value === "",
|
|
43
|
+
selectValueChildren = isEmptyValue ? placeholder ?? children : children;
|
|
44
|
+
return /* @__PURE__ */_jsx(SelectValueFrame, {
|
|
45
|
+
...(!props.unstyled && {
|
|
46
|
+
size: itemParentContext.size,
|
|
47
|
+
ellipse: !0,
|
|
48
|
+
// we don't want events from the portalled `SelectValue` children to bubble
|
|
49
|
+
// through the item they came from
|
|
50
|
+
pointerEvents: "none"
|
|
51
|
+
}),
|
|
52
|
+
ref: composedRefs,
|
|
53
|
+
...props,
|
|
54
|
+
children: unwrapSelectItem(selectValueChildren)
|
|
55
|
+
});
|
|
42
56
|
});
|
|
43
|
-
});
|
|
44
57
|
function unwrapSelectItem(selectValueChildren) {
|
|
45
|
-
return React.Children.map(selectValueChildren, function(child) {
|
|
58
|
+
return React.Children.map(selectValueChildren, function (child) {
|
|
46
59
|
if (child) {
|
|
47
60
|
var _child_type_staticConfig, _child_type, _child_props;
|
|
48
|
-
if (((_child_type = child.type) === null || _child_type === void 0 || (_child_type_staticConfig = _child_type.staticConfig) === null || _child_type_staticConfig === void 0 ? void 0 : _child_type_staticConfig.componentName) === ITEM_TEXT_NAME)
|
|
49
|
-
|
|
50
|
-
if (!((_child_props = child.props) === null || _child_props === void 0) && _child_props.children)
|
|
51
|
-
return unwrapSelectItem(child.props.children);
|
|
61
|
+
if (((_child_type = child.type) === null || _child_type === void 0 || (_child_type_staticConfig = _child_type.staticConfig) === null || _child_type_staticConfig === void 0 ? void 0 : _child_type_staticConfig.componentName) === ITEM_TEXT_NAME) return child.props.children;
|
|
62
|
+
if (!((_child_props = child.props) === null || _child_props === void 0) && _child_props.children) return unwrapSelectItem(child.props.children);
|
|
52
63
|
}
|
|
53
64
|
return child;
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
67
|
var SelectIcon = styled(XStack, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"aria-hidden": !0,
|
|
60
|
-
children: /* @__PURE__ */ _jsx(Paragraph, {
|
|
61
|
-
children: "\u25BC"
|
|
62
|
-
})
|
|
63
|
-
}), ITEM_INDICATOR_NAME = "SelectItemIndicator", SelectItemIndicatorFrame = styled(XStack, {
|
|
64
|
-
name: ITEM_TEXT_NAME
|
|
65
|
-
}), SelectItemIndicator = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
66
|
-
var { __scopeSelect, ...itemIndicatorProps } = props, context = useSelectItemParentContext(ITEM_INDICATOR_NAME, __scopeSelect), itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
67
|
-
return context.shouldRenderWebNative ? null : itemContext.isSelected ? /* @__PURE__ */ _jsx(SelectItemIndicatorFrame, {
|
|
68
|
+
name: "SelectIcon",
|
|
69
|
+
// @ts-ignore
|
|
68
70
|
"aria-hidden": !0,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
71
|
+
children: /* @__PURE__ */_jsx(Paragraph, {
|
|
72
|
+
children: "\u25BC"
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
75
|
+
ITEM_INDICATOR_NAME = "SelectItemIndicator",
|
|
76
|
+
SelectItemIndicatorFrame = styled(XStack, {
|
|
77
|
+
name: ITEM_TEXT_NAME
|
|
78
|
+
}),
|
|
79
|
+
SelectItemIndicator = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
80
|
+
var {
|
|
81
|
+
__scopeSelect,
|
|
82
|
+
...itemIndicatorProps
|
|
83
|
+
} = props,
|
|
84
|
+
context = useSelectItemParentContext(ITEM_INDICATOR_NAME, __scopeSelect),
|
|
85
|
+
itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
86
|
+
return context.shouldRenderWebNative ? null : itemContext.isSelected ? /* @__PURE__ */_jsx(SelectItemIndicatorFrame, {
|
|
87
|
+
"aria-hidden": !0,
|
|
88
|
+
...itemIndicatorProps,
|
|
89
|
+
ref: forwardedRef
|
|
90
|
+
}) : null;
|
|
91
|
+
});
|
|
73
92
|
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
74
|
-
var GROUP_NAME = "SelectGroup",
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
backgroundColor: "$
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
var GROUP_NAME = "SelectGroup",
|
|
94
|
+
[SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME),
|
|
95
|
+
SelectGroupFrame = styled(YStack, {
|
|
96
|
+
name: GROUP_NAME,
|
|
97
|
+
width: "100%"
|
|
98
|
+
}),
|
|
99
|
+
NativeSelectTextFrame = styled(SizableText, {
|
|
100
|
+
tag: "select",
|
|
101
|
+
backgroundColor: "$background",
|
|
102
|
+
borderColor: "$borderColor",
|
|
103
|
+
hoverStyle: {
|
|
104
|
+
backgroundColor: "$backgroundHover"
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
NativeSelectFrame = styled(ThemeableStack, {
|
|
108
|
+
name: "NativeSelect",
|
|
109
|
+
bordered: !0,
|
|
110
|
+
userSelect: "none",
|
|
111
|
+
outlineWidth: 0,
|
|
112
|
+
paddingRight: 10,
|
|
113
|
+
variants: {
|
|
114
|
+
size: {
|
|
115
|
+
"...size": function (val, extras) {
|
|
116
|
+
var {
|
|
117
|
+
tokens
|
|
118
|
+
} = extras,
|
|
119
|
+
paddingHorizontal = getVariableValue(tokens.space[val]),
|
|
120
|
+
_tokens_radius_val;
|
|
121
|
+
return {
|
|
122
|
+
borderRadius: (_tokens_radius_val = tokens.radius[val]) !== null && _tokens_radius_val !== void 0 ? _tokens_radius_val : val,
|
|
123
|
+
minHeight: tokens.size[val],
|
|
124
|
+
paddingRight: paddingHorizontal + 20,
|
|
125
|
+
paddingLeft: paddingHorizontal,
|
|
126
|
+
paddingVertical: getSpace(val, {
|
|
127
|
+
shift: -3
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
}
|
|
103
131
|
}
|
|
132
|
+
},
|
|
133
|
+
defaultVariants: {
|
|
134
|
+
size: "$2"
|
|
104
135
|
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
}),
|
|
137
|
+
SelectGroup = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
138
|
+
var {
|
|
139
|
+
__scopeSelect,
|
|
140
|
+
...groupProps
|
|
141
|
+
} = props,
|
|
142
|
+
groupId = React.useId(),
|
|
143
|
+
context = useSelectContext(GROUP_NAME, __scopeSelect),
|
|
144
|
+
itemParentContext = useSelectItemParentContext(GROUP_NAME, __scopeSelect),
|
|
145
|
+
_itemParentContext_size,
|
|
146
|
+
size = (_itemParentContext_size = itemParentContext.size) !== null && _itemParentContext_size !== void 0 ? _itemParentContext_size : "$true",
|
|
147
|
+
nativeSelectRef = React.useRef(null),
|
|
148
|
+
content = function () {
|
|
149
|
+
return itemParentContext.shouldRenderWebNative ? /* @__PURE__ */_jsx(NativeSelectFrame, {
|
|
150
|
+
asChild: !0,
|
|
151
|
+
size,
|
|
152
|
+
// @ts-expect-error until we support typing based on tag
|
|
153
|
+
value: context.value,
|
|
154
|
+
id: itemParentContext.id,
|
|
155
|
+
children: /* @__PURE__ */_jsx(NativeSelectTextFrame, {
|
|
156
|
+
// @ts-ignore it's ok since tag="select"
|
|
157
|
+
onChange: function (event) {
|
|
158
|
+
itemParentContext.onChange(event.currentTarget.value);
|
|
159
|
+
},
|
|
160
|
+
size,
|
|
161
|
+
ref: nativeSelectRef,
|
|
162
|
+
style: {
|
|
163
|
+
color: "var(--color)",
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
appearance: "none"
|
|
166
|
+
},
|
|
167
|
+
children: props.children
|
|
168
|
+
})
|
|
169
|
+
}) : /* @__PURE__ */_jsx(SelectGroupFrame, {
|
|
126
170
|
// @ts-ignore
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
171
|
+
role: "group",
|
|
172
|
+
"aria-labelledby": groupId,
|
|
173
|
+
...groupProps,
|
|
174
|
+
ref: forwardedRef
|
|
175
|
+
});
|
|
176
|
+
}();
|
|
177
|
+
return /* @__PURE__ */_jsx(SelectGroupContextProvider, {
|
|
178
|
+
scope: __scopeSelect,
|
|
179
|
+
id: groupId || "",
|
|
180
|
+
children: content
|
|
137
181
|
});
|
|
138
|
-
}();
|
|
139
|
-
return /* @__PURE__ */ _jsx(SelectGroupContextProvider, {
|
|
140
|
-
scope: __scopeSelect,
|
|
141
|
-
id: groupId || "",
|
|
142
|
-
children: content
|
|
143
182
|
});
|
|
144
|
-
});
|
|
145
183
|
SelectGroup.displayName = GROUP_NAME;
|
|
146
|
-
var LABEL_NAME = "SelectLabel",
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
184
|
+
var LABEL_NAME = "SelectLabel",
|
|
185
|
+
SelectLabel = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
186
|
+
var {
|
|
187
|
+
__scopeSelect,
|
|
188
|
+
...labelProps
|
|
189
|
+
} = props,
|
|
190
|
+
context = useSelectItemParentContext(LABEL_NAME, __scopeSelect),
|
|
191
|
+
groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
192
|
+
return context.shouldRenderWebNative ? null : /* @__PURE__ */_jsx(ListItem, {
|
|
193
|
+
tag: "div",
|
|
194
|
+
componentName: LABEL_NAME,
|
|
195
|
+
fontWeight: "800",
|
|
196
|
+
id: groupContext.id,
|
|
197
|
+
size: context.size,
|
|
198
|
+
...labelProps,
|
|
199
|
+
ref: forwardedRef
|
|
200
|
+
});
|
|
156
201
|
});
|
|
157
|
-
});
|
|
158
202
|
SelectLabel.displayName = LABEL_NAME;
|
|
159
203
|
var SelectSeparator = styled(Separator, {
|
|
160
|
-
|
|
161
|
-
}),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
204
|
+
name: "SelectSeparator"
|
|
205
|
+
}),
|
|
206
|
+
SelectSheetController = function (props) {
|
|
207
|
+
var context = useSelectContext("SelectSheetController", props.__scopeSelect),
|
|
208
|
+
showSheet = useShowSelectSheet(context),
|
|
209
|
+
isAdapted = useAdaptIsActive(),
|
|
210
|
+
getShowSheet = useGet(showSheet);
|
|
211
|
+
return /* @__PURE__ */_jsx(SheetController, {
|
|
212
|
+
onOpenChange: function (val) {
|
|
213
|
+
getShowSheet() && props.onOpenChange(val);
|
|
214
|
+
},
|
|
215
|
+
open: context.open,
|
|
216
|
+
hidden: isAdapted === !1,
|
|
217
|
+
children: props.children
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
SelectSheetImpl = function (props) {
|
|
221
|
+
return /* @__PURE__ */_jsx(_Fragment, {
|
|
222
|
+
children: props.children
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
Select = withStaticProperties(function (props) {
|
|
226
|
+
var internalId = React.useId(),
|
|
227
|
+
_Object_keys_,
|
|
228
|
+
scopeKey = props.__scopeSelect && (_Object_keys_ = Object.keys(props.__scopeSelect)[0]) !== null && _Object_keys_ !== void 0 ? _Object_keys_ : internalId;
|
|
229
|
+
return /* @__PURE__ */_jsx(AdaptParent, {
|
|
230
|
+
scope: `${scopeKey}SheetContents`,
|
|
231
|
+
portal: !0,
|
|
232
|
+
children: /* @__PURE__ */_jsx(SelectInner, {
|
|
233
|
+
scopeKey,
|
|
234
|
+
...props
|
|
235
|
+
})
|
|
236
|
+
});
|
|
237
|
+
}, {
|
|
238
|
+
Adapt,
|
|
239
|
+
Content: SelectContent,
|
|
240
|
+
Group: SelectGroup,
|
|
241
|
+
Icon: SelectIcon,
|
|
242
|
+
Item: SelectItem,
|
|
243
|
+
ItemIndicator: SelectItemIndicator,
|
|
244
|
+
ItemText: SelectItemText,
|
|
245
|
+
Label: SelectLabel,
|
|
246
|
+
ScrollDownButton: SelectScrollDownButton,
|
|
247
|
+
ScrollUpButton: SelectScrollUpButton,
|
|
248
|
+
Trigger: SelectTrigger,
|
|
249
|
+
Value: SelectValue,
|
|
250
|
+
Viewport: SelectViewport,
|
|
251
|
+
Sheet: Sheet.Controlled
|
|
184
252
|
});
|
|
185
|
-
}, {
|
|
186
|
-
Adapt,
|
|
187
|
-
Content: SelectContent,
|
|
188
|
-
Group: SelectGroup,
|
|
189
|
-
Icon: SelectIcon,
|
|
190
|
-
Item: SelectItem,
|
|
191
|
-
ItemIndicator: SelectItemIndicator,
|
|
192
|
-
ItemText: SelectItemText,
|
|
193
|
-
Label: SelectLabel,
|
|
194
|
-
ScrollDownButton: SelectScrollDownButton,
|
|
195
|
-
ScrollUpButton: SelectScrollUpButton,
|
|
196
|
-
Trigger: SelectTrigger,
|
|
197
|
-
Value: SelectValue,
|
|
198
|
-
Viewport: SelectViewport,
|
|
199
|
-
Sheet: Sheet.Controlled
|
|
200
|
-
});
|
|
201
253
|
function useEmitter() {
|
|
202
254
|
var listeners = React.useRef();
|
|
203
|
-
listeners.current || (listeners.current = /* @__PURE__ */
|
|
204
|
-
var emit = function(value) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
listeners.current.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
subscribe
|
|
216
|
-
];
|
|
255
|
+
listeners.current || (listeners.current = /* @__PURE__ */new Set());
|
|
256
|
+
var emit = function (value) {
|
|
257
|
+
listeners.current.forEach(function (l) {
|
|
258
|
+
return l(value);
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
subscribe = React.useCallback(function (listener) {
|
|
262
|
+
return listeners.current.add(listener), function () {
|
|
263
|
+
listeners.current.delete(listener);
|
|
264
|
+
};
|
|
265
|
+
}, []);
|
|
266
|
+
return [emit, subscribe];
|
|
217
267
|
}
|
|
218
268
|
function SelectInner(props) {
|
|
219
|
-
var {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
269
|
+
var {
|
|
270
|
+
__scopeSelect,
|
|
271
|
+
native,
|
|
272
|
+
children,
|
|
273
|
+
open: openProp,
|
|
274
|
+
defaultOpen,
|
|
275
|
+
onOpenChange,
|
|
276
|
+
value: valueProp,
|
|
277
|
+
defaultValue,
|
|
278
|
+
onValueChange,
|
|
279
|
+
disablePreventBodyScroll,
|
|
280
|
+
size: sizeProp = "$true",
|
|
281
|
+
onActiveChange,
|
|
282
|
+
dir,
|
|
283
|
+
id
|
|
284
|
+
} = props,
|
|
285
|
+
isAdapted = useAdaptIsActive(),
|
|
286
|
+
SelectImpl = isAdapted || !isWeb ? SelectSheetImpl : SelectInlineImpl,
|
|
287
|
+
forceUpdate = React.useReducer(function () {
|
|
288
|
+
return {};
|
|
289
|
+
}, {})[1],
|
|
290
|
+
[selectedItem, setSelectedItem] = React.useState(null),
|
|
291
|
+
[open, setOpen] = useControllableState({
|
|
292
|
+
prop: openProp,
|
|
293
|
+
defaultProp: defaultOpen || !1,
|
|
294
|
+
onChange: onOpenChange
|
|
295
|
+
}),
|
|
296
|
+
[value, setValue] = useControllableState({
|
|
297
|
+
prop: valueProp,
|
|
298
|
+
defaultProp: defaultValue || "",
|
|
299
|
+
onChange: onValueChange,
|
|
300
|
+
transition: !0
|
|
301
|
+
});
|
|
302
|
+
React.useEffect(function () {
|
|
232
303
|
open && emitValue(value);
|
|
233
|
-
}, [
|
|
234
|
-
open
|
|
235
|
-
]), React.useEffect(function() {
|
|
304
|
+
}, [open]), React.useEffect(function () {
|
|
236
305
|
emitValue(value);
|
|
237
|
-
}, [
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
306
|
+
}, [value]), React.useEffect(function () {
|
|
307
|
+
if (props.id) return registerFocusable(props.id, {
|
|
308
|
+
focusAndSelect: function () {
|
|
309
|
+
setOpen?.(function (value2) {
|
|
310
|
+
return !value2;
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
focus: function () {}
|
|
314
|
+
});
|
|
315
|
+
}, [props.id]);
|
|
316
|
+
var [activeIndex, setActiveIndex] = React.useState(0),
|
|
317
|
+
[emitValue, valueSubscribe] = useEmitter(),
|
|
318
|
+
[emitActiveIndex, activeIndexSubscribe] = useEmitter(),
|
|
319
|
+
selectedIndexRef = React.useRef(null),
|
|
320
|
+
activeIndexRef = React.useRef(null),
|
|
321
|
+
listContentRef = React.useRef([]),
|
|
322
|
+
[selectedIndex, setSelectedIndex] = React.useState(0),
|
|
323
|
+
[valueNode, setValueNode] = React.useState(null);
|
|
324
|
+
useIsomorphicLayoutEffect(function () {
|
|
255
325
|
selectedIndexRef.current = selectedIndex, activeIndexRef.current = activeIndex;
|
|
256
326
|
});
|
|
257
|
-
var shouldRenderWebNative = isWeb && (native === !0 || native === "web" || Array.isArray(native) && native.includes("web")),
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
327
|
+
var shouldRenderWebNative = isWeb && (native === !0 || native === "web" || Array.isArray(native) && native.includes("web")),
|
|
328
|
+
setActiveIndexDebounced = useDebounce(function (index) {
|
|
329
|
+
setActiveIndex(function (prev) {
|
|
330
|
+
return prev !== index ? (typeof index == "number" && emitActiveIndex(index), index) : prev;
|
|
331
|
+
});
|
|
332
|
+
}, 1, {}, []);
|
|
333
|
+
return /* @__PURE__ */_jsx(SelectItemParentProvider, {
|
|
263
334
|
scope: __scopeSelect,
|
|
264
|
-
initialValue: React.useMemo(function() {
|
|
335
|
+
initialValue: React.useMemo(function () {
|
|
265
336
|
return value;
|
|
266
|
-
}, [
|
|
267
|
-
open
|
|
268
|
-
]),
|
|
337
|
+
}, [open]),
|
|
269
338
|
size: sizeProp,
|
|
270
339
|
activeIndexSubscribe,
|
|
271
340
|
valueSubscribe,
|
|
272
341
|
setOpen,
|
|
273
342
|
id,
|
|
274
|
-
onChange: React.useCallback(function(val) {
|
|
343
|
+
onChange: React.useCallback(function (val) {
|
|
275
344
|
setValue(val), emitValue(val);
|
|
276
345
|
}, []),
|
|
277
|
-
onActiveChange: useEvent(function() {
|
|
278
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)
|
|
279
|
-
args[_key] = arguments[_key];
|
|
346
|
+
onActiveChange: useEvent(function () {
|
|
347
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
|
|
280
348
|
onActiveChange?.(...args);
|
|
281
349
|
}),
|
|
282
350
|
setSelectedIndex,
|
|
283
|
-
setValueAtIndex: React.useCallback(function(index, value2) {
|
|
351
|
+
setValueAtIndex: React.useCallback(function (index, value2) {
|
|
284
352
|
listContentRef.current[index] = value2;
|
|
285
353
|
}, []),
|
|
286
354
|
shouldRenderWebNative,
|
|
287
|
-
children: /* @__PURE__ */
|
|
355
|
+
children: /* @__PURE__ */_jsx(SelectProvider, {
|
|
288
356
|
scope: __scopeSelect,
|
|
289
357
|
disablePreventBodyScroll,
|
|
290
358
|
dir,
|
|
@@ -302,10 +370,10 @@ function SelectInner(props) {
|
|
|
302
370
|
value,
|
|
303
371
|
open,
|
|
304
372
|
native,
|
|
305
|
-
children: /* @__PURE__ */
|
|
373
|
+
children: /* @__PURE__ */_jsx(SelectSheetController, {
|
|
306
374
|
onOpenChange: setOpen,
|
|
307
375
|
__scopeSelect,
|
|
308
|
-
children: shouldRenderWebNative ? children : /* @__PURE__ */
|
|
376
|
+
children: shouldRenderWebNative ? children : /* @__PURE__ */_jsx(SelectImpl, {
|
|
309
377
|
activeIndexRef,
|
|
310
378
|
listContentRef,
|
|
311
379
|
selectedIndexRef,
|
|
@@ -318,10 +386,5 @@ function SelectInner(props) {
|
|
|
318
386
|
})
|
|
319
387
|
});
|
|
320
388
|
}
|
|
321
|
-
export {
|
|
322
|
-
|
|
323
|
-
SelectGroupFrame,
|
|
324
|
-
SelectIcon,
|
|
325
|
-
SelectSeparator
|
|
326
|
-
};
|
|
327
|
-
//# sourceMappingURL=Select.js.map
|
|
389
|
+
export { Select, SelectGroupFrame, SelectIcon, SelectSeparator };
|
|
390
|
+
//# sourceMappingURL=Select.native.js.map
|