@tamagui/select 2.0.0-rc.4 → 2.0.0-rc.40
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 +28 -23
- package/dist/cjs/BubbleSelect.native.js +12 -10
- package/dist/cjs/BubbleSelect.native.js.map +1 -1
- package/dist/cjs/Select.cjs +402 -376
- package/dist/cjs/Select.native.js +428 -414
- package/dist/cjs/Select.native.js.map +1 -1
- package/dist/cjs/SelectContent.cjs +73 -66
- package/dist/cjs/SelectContent.native.js +12 -10
- package/dist/cjs/SelectContent.native.js.map +1 -1
- package/dist/cjs/SelectImpl.cjs +239 -176
- package/dist/cjs/SelectImpl.native.js +21 -16
- package/dist/cjs/SelectImpl.native.js.map +1 -1
- package/dist/cjs/SelectItem.cjs +189 -137
- package/dist/cjs/SelectItem.native.js +211 -164
- package/dist/cjs/SelectItem.native.js.map +1 -1
- package/dist/cjs/SelectItemText.cjs +82 -68
- package/dist/cjs/SelectItemText.native.js +81 -69
- package/dist/cjs/SelectItemText.native.js.map +1 -1
- package/dist/cjs/SelectScrollButton.cjs +104 -83
- package/dist/cjs/SelectScrollButton.native.js +17 -15
- package/dist/cjs/SelectScrollButton.native.js.map +1 -1
- package/dist/cjs/SelectTrigger.cjs +81 -77
- package/dist/cjs/SelectTrigger.native.js +43 -40
- package/dist/cjs/SelectTrigger.native.js.map +1 -1
- package/dist/cjs/SelectViewport.cjs +141 -103
- package/dist/cjs/SelectViewport.native.js +39 -37
- package/dist/cjs/SelectViewport.native.js.map +1 -1
- package/dist/cjs/constants.cjs +19 -17
- package/dist/cjs/constants.native.js +19 -17
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/context.cjs +38 -27
- package/dist/cjs/context.native.js +46 -38
- package/dist/cjs/context.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useSelectBreakpointActive.cjs +13 -11
- package/dist/cjs/useSelectBreakpointActive.native.js +17 -15
- package/dist/cjs/useSelectBreakpointActive.native.js.map +1 -1
- package/dist/esm/BubbleSelect.mjs +16 -13
- package/dist/esm/BubbleSelect.mjs.map +1 -1
- package/dist/esm/Select.mjs +356 -331
- package/dist/esm/Select.mjs.map +1 -1
- package/dist/esm/Select.native.js +381 -369
- package/dist/esm/Select.native.js.map +1 -1
- package/dist/esm/SelectContent.mjs +55 -39
- package/dist/esm/SelectContent.mjs.map +1 -1
- package/dist/esm/SelectImpl.mjs +208 -147
- package/dist/esm/SelectImpl.mjs.map +1 -1
- package/dist/esm/SelectImpl.native.js +4 -1
- package/dist/esm/SelectImpl.native.js.map +1 -1
- package/dist/esm/SelectItem.mjs +157 -107
- package/dist/esm/SelectItem.mjs.map +1 -1
- package/dist/esm/SelectItem.native.js +180 -135
- package/dist/esm/SelectItem.native.js.map +1 -1
- package/dist/esm/SelectItemText.mjs +50 -38
- package/dist/esm/SelectItemText.mjs.map +1 -1
- package/dist/esm/SelectItemText.native.js +50 -40
- package/dist/esm/SelectItemText.native.js.map +1 -1
- package/dist/esm/SelectScrollButton.mjs +74 -55
- package/dist/esm/SelectScrollButton.mjs.map +1 -1
- package/dist/esm/SelectScrollButton.native.js +5 -5
- package/dist/esm/SelectScrollButton.native.js.map +1 -1
- package/dist/esm/SelectTrigger.mjs +51 -49
- package/dist/esm/SelectTrigger.mjs.map +1 -1
- package/dist/esm/SelectTrigger.native.js +13 -12
- package/dist/esm/SelectTrigger.native.js.map +1 -1
- package/dist/esm/SelectViewport.mjs +108 -83
- package/dist/esm/SelectViewport.mjs.map +1 -1
- package/dist/esm/SelectViewport.native.js +7 -7
- package/dist/esm/SelectViewport.native.js.map +1 -1
- package/dist/esm/constants.mjs +7 -7
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +7 -7
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/context.mjs +22 -14
- package/dist/esm/context.mjs.map +1 -1
- package/dist/esm/context.native.js +30 -25
- package/dist/esm/context.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useSelectBreakpointActive.mjs +1 -1
- package/dist/esm/useSelectBreakpointActive.mjs.map +1 -1
- package/dist/esm/useSelectBreakpointActive.native.js +1 -1
- package/dist/esm/useSelectBreakpointActive.native.js.map +1 -1
- package/dist/jsx/BubbleSelect.mjs +16 -13
- package/dist/jsx/BubbleSelect.mjs.map +1 -1
- package/dist/jsx/BubbleSelect.native.js +12 -10
- package/dist/jsx/BubbleSelect.native.js.map +1 -1
- package/dist/jsx/Select.mjs +356 -331
- package/dist/jsx/Select.mjs.map +1 -1
- package/dist/jsx/Select.native.js +428 -414
- package/dist/jsx/Select.native.js.map +1 -1
- package/dist/jsx/SelectContent.mjs +55 -39
- package/dist/jsx/SelectContent.mjs.map +1 -1
- package/dist/jsx/SelectContent.native.js +12 -10
- package/dist/jsx/SelectContent.native.js.map +1 -1
- package/dist/jsx/SelectImpl.mjs +208 -147
- package/dist/jsx/SelectImpl.mjs.map +1 -1
- package/dist/jsx/SelectImpl.native.js +21 -16
- package/dist/jsx/SelectImpl.native.js.map +1 -1
- package/dist/jsx/SelectItem.mjs +157 -107
- package/dist/jsx/SelectItem.mjs.map +1 -1
- package/dist/jsx/SelectItem.native.js +211 -164
- package/dist/jsx/SelectItem.native.js.map +1 -1
- package/dist/jsx/SelectItemText.mjs +50 -38
- package/dist/jsx/SelectItemText.mjs.map +1 -1
- package/dist/jsx/SelectItemText.native.js +81 -69
- package/dist/jsx/SelectItemText.native.js.map +1 -1
- package/dist/jsx/SelectScrollButton.mjs +74 -55
- package/dist/jsx/SelectScrollButton.mjs.map +1 -1
- package/dist/jsx/SelectScrollButton.native.js +17 -15
- package/dist/jsx/SelectScrollButton.native.js.map +1 -1
- package/dist/jsx/SelectTrigger.mjs +51 -49
- package/dist/jsx/SelectTrigger.mjs.map +1 -1
- package/dist/jsx/SelectTrigger.native.js +43 -40
- package/dist/jsx/SelectTrigger.native.js.map +1 -1
- package/dist/jsx/SelectViewport.mjs +108 -83
- package/dist/jsx/SelectViewport.mjs.map +1 -1
- package/dist/jsx/SelectViewport.native.js +39 -37
- package/dist/jsx/SelectViewport.native.js.map +1 -1
- package/dist/jsx/constants.mjs +7 -7
- package/dist/jsx/constants.mjs.map +1 -1
- package/dist/jsx/constants.native.js +19 -17
- package/dist/jsx/constants.native.js.map +1 -1
- package/dist/jsx/context.mjs +22 -14
- package/dist/jsx/context.mjs.map +1 -1
- package/dist/jsx/context.native.js +46 -38
- package/dist/jsx/context.native.js.map +1 -1
- package/dist/jsx/index.js +2 -2
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/types.native.js +7 -5
- package/dist/jsx/useSelectBreakpointActive.mjs +1 -1
- package/dist/jsx/useSelectBreakpointActive.mjs.map +1 -1
- package/dist/jsx/useSelectBreakpointActive.native.js +17 -15
- package/dist/jsx/useSelectBreakpointActive.native.js.map +1 -1
- package/package.json +31 -35
- package/src/Select.tsx +16 -1
- package/src/SelectContent.tsx +47 -36
- package/src/SelectImpl.tsx +51 -49
- package/src/SelectItem.tsx +17 -7
- package/src/SelectScrollButton.tsx +1 -1
- package/src/SelectTrigger.tsx +1 -1
- package/src/SelectViewport.tsx +42 -22
- package/src/context.tsx +4 -0
- package/src/types.tsx +44 -4
- package/types/Select.d.ts +2 -2
- package/types/Select.d.ts.map +1 -1
- package/types/SelectContent.d.ts +1 -1
- package/types/SelectContent.d.ts.map +1 -1
- package/types/SelectImpl.d.ts.map +1 -1
- package/types/SelectItem.d.ts.map +1 -1
- package/types/SelectTrigger.d.ts +1 -1
- package/types/SelectViewport.d.ts.map +1 -1
- package/types/context.d.ts +1 -0
- package/types/context.d.ts.map +1 -1
- package/types/types.d.ts +33 -3
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/BubbleSelect.js +0 -34
- package/dist/cjs/BubbleSelect.js.map +0 -6
- package/dist/cjs/Select.js +0 -402
- package/dist/cjs/Select.js.map +0 -6
- package/dist/cjs/SelectContent.js +0 -57
- package/dist/cjs/SelectContent.js.map +0 -6
- package/dist/cjs/SelectImpl.js +0 -222
- package/dist/cjs/SelectImpl.js.map +0 -6
- package/dist/cjs/SelectItem.js +0 -166
- package/dist/cjs/SelectItem.js.map +0 -6
- package/dist/cjs/SelectItemText.js +0 -64
- package/dist/cjs/SelectItemText.js.map +0 -6
- package/dist/cjs/SelectScrollButton.js +0 -105
- package/dist/cjs/SelectScrollButton.js.map +0 -6
- package/dist/cjs/SelectTrigger.js +0 -81
- package/dist/cjs/SelectTrigger.js.map +0 -6
- package/dist/cjs/SelectViewport.js +0 -114
- package/dist/cjs/SelectViewport.js.map +0 -6
- package/dist/cjs/constants.js +0 -27
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/context.js +0 -33
- package/dist/cjs/context.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useSelectBreakpointActive.js +0 -25
- package/dist/cjs/useSelectBreakpointActive.js.map +0 -6
- package/dist/esm/BubbleSelect.js +0 -17
- package/dist/esm/BubbleSelect.js.map +0 -6
- package/dist/esm/Select.js +0 -412
- package/dist/esm/Select.js.map +0 -6
- package/dist/esm/SelectContent.js +0 -39
- package/dist/esm/SelectContent.js.map +0 -6
- package/dist/esm/SelectImpl.js +0 -223
- package/dist/esm/SelectImpl.js.map +0 -6
- package/dist/esm/SelectItem.js +0 -148
- package/dist/esm/SelectItem.js.map +0 -6
- package/dist/esm/SelectItemText.js +0 -46
- package/dist/esm/SelectItemText.js.map +0 -6
- package/dist/esm/SelectScrollButton.js +0 -87
- package/dist/esm/SelectScrollButton.js.map +0 -6
- package/dist/esm/SelectTrigger.js +0 -61
- package/dist/esm/SelectTrigger.js.map +0 -6
- package/dist/esm/SelectViewport.js +0 -112
- package/dist/esm/SelectViewport.js.map +0 -6
- package/dist/esm/constants.js +0 -11
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/context.js +0 -19
- package/dist/esm/context.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useSelectBreakpointActive.js +0 -9
- package/dist/esm/useSelectBreakpointActive.js.map +0 -6
- package/dist/jsx/BubbleSelect.js +0 -17
- package/dist/jsx/BubbleSelect.js.map +0 -6
- package/dist/jsx/Select.js +0 -412
- package/dist/jsx/Select.js.map +0 -6
- package/dist/jsx/SelectContent.js +0 -39
- package/dist/jsx/SelectContent.js.map +0 -6
- package/dist/jsx/SelectImpl.js +0 -223
- package/dist/jsx/SelectImpl.js.map +0 -6
- package/dist/jsx/SelectItem.js +0 -148
- package/dist/jsx/SelectItem.js.map +0 -6
- package/dist/jsx/SelectItemText.js +0 -46
- package/dist/jsx/SelectItemText.js.map +0 -6
- package/dist/jsx/SelectScrollButton.js +0 -87
- package/dist/jsx/SelectScrollButton.js.map +0 -6
- package/dist/jsx/SelectTrigger.js +0 -61
- package/dist/jsx/SelectTrigger.js.map +0 -6
- package/dist/jsx/SelectViewport.js +0 -112
- package/dist/jsx/SelectViewport.js.map +0 -6
- package/dist/jsx/constants.js +0 -11
- package/dist/jsx/constants.js.map +0 -6
- package/dist/jsx/context.js +0 -19
- package/dist/jsx/context.js.map +0 -6
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -6
- package/dist/jsx/useSelectBreakpointActive.js +0 -9
- package/dist/jsx/useSelectBreakpointActive.js.map +0 -6
package/dist/cjs/Select.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var Select_exports = {};
|
|
33
35
|
__export(Select_exports, {
|
|
34
36
|
Select: () => Select,
|
|
@@ -37,63 +39,60 @@ __export(Select_exports, {
|
|
|
37
39
|
SelectSeparator: () => SelectSeparator
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(Select_exports);
|
|
40
|
-
var import_adapt = require("@tamagui/adapt")
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
ref: composedRefs,
|
|
93
|
-
...props,
|
|
94
|
-
children: unwrapSelectItem(selectValueChildren)
|
|
95
|
-
});
|
|
42
|
+
var import_adapt = require("@tamagui/adapt");
|
|
43
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
44
|
+
var import_constants = require("@tamagui/constants");
|
|
45
|
+
var import_core = require("@tamagui/core");
|
|
46
|
+
var import_focus_scope = require("@tamagui/focus-scope");
|
|
47
|
+
require("@tamagui/focusable");
|
|
48
|
+
var import_get_token = require("@tamagui/get-token");
|
|
49
|
+
var import_helpers = require("@tamagui/helpers");
|
|
50
|
+
var import_separator = require("@tamagui/separator");
|
|
51
|
+
var import_controller = require("@tamagui/sheet/controller");
|
|
52
|
+
var import_stacks = require("@tamagui/stacks");
|
|
53
|
+
var import_text = require("@tamagui/text");
|
|
54
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
55
|
+
var React = __toESM(require("react"), 1);
|
|
56
|
+
var import_context = require("./context.cjs");
|
|
57
|
+
var import_SelectContent = require("./SelectContent.cjs");
|
|
58
|
+
var import_SelectImpl = require("./SelectImpl.cjs");
|
|
59
|
+
var import_SelectItem = require("./SelectItem.cjs");
|
|
60
|
+
var import_SelectItemText = require("./SelectItemText.cjs");
|
|
61
|
+
var import_SelectScrollButton = require("./SelectScrollButton.cjs");
|
|
62
|
+
var import_SelectTrigger = require("./SelectTrigger.cjs");
|
|
63
|
+
var import_SelectViewport = require("./SelectViewport.cjs");
|
|
64
|
+
var import_useSelectBreakpointActive = require("./useSelectBreakpointActive.cjs");
|
|
65
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
66
|
+
const SelectValueFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
67
|
+
name: "SelectValue",
|
|
68
|
+
userSelect: "none"
|
|
69
|
+
});
|
|
70
|
+
const SelectValue = SelectValueFrame.styleable(function SelectValue2({
|
|
71
|
+
scope,
|
|
72
|
+
children: childrenProp,
|
|
73
|
+
placeholder,
|
|
74
|
+
...props
|
|
75
|
+
}, forwardedRef) {
|
|
76
|
+
const context = (0, import_context.useSelectContext)(scope);
|
|
77
|
+
const itemParentContext = (0, import_context.useSelectItemParentContext)(scope);
|
|
78
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(
|
|
79
|
+
// @ts-ignore TODO react 19 type needs fix
|
|
80
|
+
forwardedRef, context.onValueNodeChange);
|
|
81
|
+
const isEmptyValue = context.value == null || context.value === "";
|
|
82
|
+
const renderedValue = context.renderValue?.(context.value);
|
|
83
|
+
const children = childrenProp ?? renderedValue ?? itemParentContext.selectedItem ?? context.value;
|
|
84
|
+
const selectValueChildren = isEmptyValue ? placeholder ?? children : children;
|
|
85
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectValueFrame, {
|
|
86
|
+
...(!props.unstyled && {
|
|
87
|
+
size: itemParentContext.size,
|
|
88
|
+
ellipsis: true,
|
|
89
|
+
pointerEvents: "none"
|
|
90
|
+
}),
|
|
91
|
+
ref: composedRefs,
|
|
92
|
+
...props,
|
|
93
|
+
children: unwrapSelectItem(selectValueChildren)
|
|
96
94
|
});
|
|
95
|
+
});
|
|
97
96
|
function unwrapSelectItem(selectValueChildren) {
|
|
98
97
|
return React.Children.map(selectValueChildren, child => {
|
|
99
98
|
if (child) {
|
|
@@ -104,341 +103,362 @@ function unwrapSelectItem(selectValueChildren) {
|
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
105
|
const SelectIcon = (0, import_core.styled)(import_stacks.XStack, {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
children:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const {
|
|
119
|
-
scope,
|
|
120
|
-
...itemIndicatorProps
|
|
121
|
-
} = props,
|
|
122
|
-
context = (0, import_context.useSelectItemParentContext)(scope),
|
|
123
|
-
itemContext = (0, import_SelectItem.useSelectItemContext)(scope);
|
|
124
|
-
return context.shouldRenderWebNative ? null : itemContext.isSelected ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectItemIndicatorFrame, {
|
|
125
|
-
"aria-hidden": !0,
|
|
126
|
-
...itemIndicatorProps,
|
|
127
|
-
ref: forwardedRef
|
|
128
|
-
}) : null;
|
|
129
|
-
}),
|
|
130
|
-
SelectIndicatorFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
131
|
-
name: "SelectIndicator",
|
|
132
|
-
variants: {
|
|
133
|
-
unstyled: {
|
|
134
|
-
false: {
|
|
135
|
-
position: "absolute",
|
|
136
|
-
top: 0,
|
|
137
|
-
left: 0,
|
|
138
|
-
pointerEvents: "none",
|
|
139
|
-
zIndex: 10,
|
|
140
|
-
backgroundColor: "$background",
|
|
141
|
-
borderRadius: 0
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
defaultVariants: {
|
|
146
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
147
|
-
}
|
|
148
|
-
}),
|
|
149
|
-
SelectIndicator = SelectIndicatorFrame.styleable(function ({
|
|
106
|
+
name: "SelectIcon",
|
|
107
|
+
"aria-hidden": true,
|
|
108
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.Paragraph, {
|
|
109
|
+
children: "▼"
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
const SelectItemIndicatorFrame = (0, import_core.styled)(import_stacks.XStack, {
|
|
113
|
+
name: "SelectItemIndicator"
|
|
114
|
+
});
|
|
115
|
+
const SelectItemIndicator = React.forwardRef(function SelectItemIndicator2(props, forwardedRef) {
|
|
116
|
+
const {
|
|
150
117
|
scope,
|
|
151
|
-
...
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
x: layout.x,
|
|
176
|
-
y: layout.y
|
|
177
|
-
}) : null;
|
|
178
|
-
}),
|
|
179
|
-
GROUP_NAME = "SelectGroup",
|
|
180
|
-
{
|
|
181
|
-
Provider: SelectGroupContextProvider,
|
|
182
|
-
useStyledContext: useSelectGroupContext
|
|
183
|
-
} = (0, import_core.createStyledContext)({
|
|
184
|
-
id: ""
|
|
185
|
-
}, "SelectGroup"),
|
|
186
|
-
SelectGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
187
|
-
name: GROUP_NAME,
|
|
188
|
-
width: "100%"
|
|
189
|
-
}),
|
|
190
|
-
NativeSelectTextFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
191
|
-
render: "select",
|
|
192
|
-
backgroundColor: "$background",
|
|
193
|
-
borderColor: "$borderColor",
|
|
194
|
-
hoverStyle: {
|
|
195
|
-
backgroundColor: "$backgroundHover"
|
|
118
|
+
...itemIndicatorProps
|
|
119
|
+
} = props;
|
|
120
|
+
const context = (0, import_context.useSelectItemParentContext)(scope);
|
|
121
|
+
const itemContext = (0, import_SelectItem.useSelectItemContext)(scope);
|
|
122
|
+
if (context.shouldRenderWebNative) return null;
|
|
123
|
+
return itemContext.isSelected ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectItemIndicatorFrame, {
|
|
124
|
+
"aria-hidden": true,
|
|
125
|
+
...itemIndicatorProps,
|
|
126
|
+
ref: forwardedRef
|
|
127
|
+
}) : null;
|
|
128
|
+
});
|
|
129
|
+
const SelectIndicatorFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
130
|
+
name: "SelectIndicator",
|
|
131
|
+
variants: {
|
|
132
|
+
unstyled: {
|
|
133
|
+
false: {
|
|
134
|
+
position: "absolute",
|
|
135
|
+
top: 0,
|
|
136
|
+
left: 0,
|
|
137
|
+
pointerEvents: "none",
|
|
138
|
+
zIndex: 10,
|
|
139
|
+
backgroundColor: "$background",
|
|
140
|
+
borderRadius: 0
|
|
141
|
+
}
|
|
196
142
|
}
|
|
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
|
-
|
|
143
|
+
},
|
|
144
|
+
defaultVariants: {
|
|
145
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const SelectIndicator = SelectIndicatorFrame.styleable(function SelectIndicator2({
|
|
149
|
+
scope,
|
|
150
|
+
...props
|
|
151
|
+
}, forwardedRef) {
|
|
152
|
+
const itemContext = (0, import_context.useSelectItemParentContext)(scope);
|
|
153
|
+
const context = (0, import_context.useSelectContext)(scope);
|
|
154
|
+
const [layout, setLayout] = React.useState(null);
|
|
155
|
+
const rafRef = React.useRef(0);
|
|
156
|
+
React.useLayoutEffect(() => {
|
|
157
|
+
const update = index => {
|
|
158
|
+
if (typeof index !== "number") return;
|
|
159
|
+
cancelAnimationFrame(rafRef.current);
|
|
160
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
161
|
+
const node = itemContext.listRef?.current?.[index];
|
|
162
|
+
if (node) setLayout({
|
|
163
|
+
width: Math.round(node.offsetWidth),
|
|
164
|
+
height: Math.round(node.offsetHeight),
|
|
165
|
+
x: Math.round(node.offsetLeft),
|
|
166
|
+
y: Math.round(node.offsetTop)
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
if (context.open && context.activeIndexRef.current !== null) update(context.activeIndexRef.current);
|
|
171
|
+
return itemContext.activeIndexSubscribe(update);
|
|
172
|
+
}, [context.open, itemContext.listRef]);
|
|
173
|
+
if (!layout) return null;
|
|
174
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectIndicatorFrame, {
|
|
175
|
+
ref: forwardedRef,
|
|
176
|
+
...props,
|
|
177
|
+
width: layout.width,
|
|
178
|
+
height: layout.height,
|
|
179
|
+
x: layout.x,
|
|
180
|
+
y: layout.y
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
const GROUP_NAME = "SelectGroup";
|
|
184
|
+
const {
|
|
185
|
+
Provider: SelectGroupContextProvider,
|
|
186
|
+
useStyledContext: useSelectGroupContext
|
|
187
|
+
} = (0, import_core.createStyledContext)({
|
|
188
|
+
id: ""
|
|
189
|
+
}, "SelectGroup");
|
|
190
|
+
const SelectGroupFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
191
|
+
name: GROUP_NAME,
|
|
192
|
+
width: "100%"
|
|
193
|
+
});
|
|
194
|
+
const NativeSelectTextFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
195
|
+
render: "select",
|
|
196
|
+
backgroundColor: "$background",
|
|
197
|
+
borderColor: "$borderColor",
|
|
198
|
+
hoverStyle: {
|
|
199
|
+
backgroundColor: "$backgroundHover"
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
const NativeSelectFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
203
|
+
name: "NativeSelect",
|
|
204
|
+
variants: {
|
|
205
|
+
size: {
|
|
206
|
+
"...size": (val, extras) => {
|
|
207
|
+
const {
|
|
208
|
+
tokens
|
|
209
|
+
} = extras;
|
|
210
|
+
const paddingHorizontal = (0, import_core.getVariableValue)(tokens.space[val]);
|
|
211
|
+
return {
|
|
212
|
+
borderRadius: tokens.radius[val] ?? val,
|
|
213
|
+
minHeight: tokens.size[val],
|
|
214
|
+
paddingRight: paddingHorizontal + 20,
|
|
215
|
+
paddingLeft: paddingHorizontal,
|
|
216
|
+
paddingVertical: (0, import_get_token.getSpace)(val, {
|
|
217
|
+
shift: -3
|
|
218
|
+
})
|
|
219
|
+
};
|
|
226
220
|
}
|
|
227
221
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
222
|
+
unstyled: {
|
|
223
|
+
false: {
|
|
224
|
+
borderWidth: 1,
|
|
225
|
+
borderColor: "$borderColor",
|
|
226
|
+
userSelect: "none",
|
|
227
|
+
outlineWidth: 0,
|
|
228
|
+
paddingRight: 10
|
|
229
|
+
}
|
|
231
230
|
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
231
|
+
},
|
|
232
|
+
defaultVariants: {
|
|
233
|
+
size: "$2",
|
|
234
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1" ? true : false
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
const SelectGroup = React.forwardRef((props, forwardedRef) => {
|
|
238
|
+
const {
|
|
239
|
+
scope,
|
|
240
|
+
...groupProps
|
|
241
|
+
} = props;
|
|
242
|
+
const groupId = React.useId();
|
|
243
|
+
const context = (0, import_context.useSelectContext)(scope);
|
|
244
|
+
const itemParentContext = (0, import_context.useSelectItemParentContext)(scope);
|
|
245
|
+
const size = itemParentContext.size ?? "$true";
|
|
246
|
+
const nativeSelectRef = React.useRef(null);
|
|
247
|
+
const content = (() => {
|
|
248
|
+
if (itemParentContext.shouldRenderWebNative) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeSelectFrame, {
|
|
249
|
+
asChild: true,
|
|
250
|
+
size,
|
|
251
|
+
value: context.value,
|
|
252
|
+
id: itemParentContext.id,
|
|
253
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(NativeSelectTextFrame, {
|
|
254
|
+
onChange: event => {
|
|
255
|
+
itemParentContext.onChange(event.currentTarget.value);
|
|
256
|
+
},
|
|
245
257
|
size,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
children: props.children
|
|
260
|
-
})
|
|
261
|
-
}) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectGroupFrame, {
|
|
262
|
-
role: "group",
|
|
263
|
-
"aria-labelledby": groupId,
|
|
264
|
-
...groupProps,
|
|
265
|
-
ref: forwardedRef
|
|
266
|
-
});
|
|
267
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectGroupContextProvider, {
|
|
268
|
-
scope,
|
|
269
|
-
id: groupId || "",
|
|
270
|
-
children: content
|
|
258
|
+
ref: nativeSelectRef,
|
|
259
|
+
style: {
|
|
260
|
+
color: "var(--color)",
|
|
261
|
+
appearance: "none"
|
|
262
|
+
},
|
|
263
|
+
children: props.children
|
|
264
|
+
})
|
|
265
|
+
});
|
|
266
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectGroupFrame, {
|
|
267
|
+
role: "group",
|
|
268
|
+
"aria-labelledby": groupId,
|
|
269
|
+
...groupProps,
|
|
270
|
+
ref: forwardedRef
|
|
271
271
|
});
|
|
272
|
+
})();
|
|
273
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectGroupContextProvider, {
|
|
274
|
+
scope,
|
|
275
|
+
id: groupId || "",
|
|
276
|
+
children: content
|
|
272
277
|
});
|
|
278
|
+
});
|
|
273
279
|
SelectGroup.displayName = GROUP_NAME;
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
size: {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
280
|
+
const SelectLabelFrame = (0, import_core.styled)(import_text.SizableText, {
|
|
281
|
+
name: "SelectLabel",
|
|
282
|
+
variants: {
|
|
283
|
+
unstyled: {
|
|
284
|
+
false: {
|
|
285
|
+
size: "$true",
|
|
286
|
+
ellipsis: true,
|
|
287
|
+
maxWidth: "100%",
|
|
288
|
+
cursor: "default"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
size: {
|
|
292
|
+
"...size": (val, {
|
|
293
|
+
tokens
|
|
294
|
+
}) => {
|
|
295
|
+
return {
|
|
290
296
|
paddingHorizontal: tokens.space[val],
|
|
291
297
|
paddingVertical: (0, import_get_token.getSpace)(tokens.space[val], {
|
|
292
298
|
shift: -4
|
|
293
299
|
})
|
|
294
|
-
}
|
|
300
|
+
};
|
|
295
301
|
}
|
|
296
|
-
},
|
|
297
|
-
defaultVariants: {
|
|
298
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
299
302
|
}
|
|
300
|
-
}),
|
|
301
|
-
SelectLabel = SelectLabelFrame.styleable((props, forwardedRef) => {
|
|
302
|
-
const {
|
|
303
|
-
scope,
|
|
304
|
-
...labelProps
|
|
305
|
-
} = props,
|
|
306
|
-
context = (0, import_context.useSelectItemParentContext)(scope),
|
|
307
|
-
groupContext = useSelectGroupContext(scope);
|
|
308
|
-
return context.shouldRenderWebNative ? null : /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectLabelFrame, {
|
|
309
|
-
render: "div",
|
|
310
|
-
id: groupContext.id,
|
|
311
|
-
size: context.size,
|
|
312
|
-
...labelProps,
|
|
313
|
-
ref: forwardedRef
|
|
314
|
-
});
|
|
315
|
-
}),
|
|
316
|
-
SelectSeparator = (0, import_core.styled)(import_separator.Separator, {
|
|
317
|
-
name: "SelectSeparator"
|
|
318
|
-
}),
|
|
319
|
-
SelectSheetController = props => {
|
|
320
|
-
const context = (0, import_context.useSelectContext)(props.scope),
|
|
321
|
-
showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context),
|
|
322
|
-
isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope),
|
|
323
|
-
getShowSheet = (0, import_core.useGet)(showSheet);
|
|
324
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_controller.SheetController, {
|
|
325
|
-
onOpenChange: val => {
|
|
326
|
-
getShowSheet() && props.onOpenChange(val);
|
|
327
|
-
},
|
|
328
|
-
open: context.open,
|
|
329
|
-
hidden: !isAdapted,
|
|
330
|
-
children: props.children
|
|
331
|
-
});
|
|
332
303
|
},
|
|
333
|
-
|
|
304
|
+
defaultVariants: {
|
|
305
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
const SelectLabel = SelectLabelFrame.styleable((props, forwardedRef) => {
|
|
309
|
+
const {
|
|
310
|
+
scope,
|
|
311
|
+
...labelProps
|
|
312
|
+
} = props;
|
|
313
|
+
const context = (0, import_context.useSelectItemParentContext)(scope);
|
|
314
|
+
const groupContext = useSelectGroupContext(scope);
|
|
315
|
+
if (context.shouldRenderWebNative) return null;
|
|
316
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectLabelFrame, {
|
|
317
|
+
render: "div",
|
|
318
|
+
id: groupContext.id,
|
|
319
|
+
size: context.size,
|
|
320
|
+
...labelProps,
|
|
321
|
+
ref: forwardedRef
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
const SelectSeparator = (0, import_core.styled)(import_separator.Separator, {
|
|
325
|
+
name: "SelectSeparator"
|
|
326
|
+
});
|
|
327
|
+
const SelectSheetController = props => {
|
|
328
|
+
const context = (0, import_context.useSelectContext)(props.scope);
|
|
329
|
+
const showSheet = (0, import_useSelectBreakpointActive.useShowSelectSheet)(context);
|
|
330
|
+
const isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
331
|
+
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
332
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_controller.SheetController, {
|
|
333
|
+
onOpenChange: val => {
|
|
334
|
+
if (getShowSheet()) props.onOpenChange(val);
|
|
335
|
+
},
|
|
336
|
+
open: context.open,
|
|
337
|
+
hidden: !isAdapted,
|
|
334
338
|
children: props.children
|
|
335
|
-
}),
|
|
336
|
-
Select = (0, import_helpers.withStaticProperties)(function (props) {
|
|
337
|
-
const adaptScope = `AdaptSelect${props.scope || ""}`;
|
|
338
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
339
|
-
scope: adaptScope,
|
|
340
|
-
portal: !0,
|
|
341
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectInner, {
|
|
342
|
-
scope: props.scope,
|
|
343
|
-
adaptScope,
|
|
344
|
-
...props
|
|
345
|
-
})
|
|
346
|
-
});
|
|
347
|
-
}, {
|
|
348
|
-
Adapt: import_adapt.Adapt,
|
|
349
|
-
Content: import_SelectContent.SelectContent,
|
|
350
|
-
Group: SelectGroup,
|
|
351
|
-
Icon: SelectIcon,
|
|
352
|
-
Item: import_SelectItem.SelectItem,
|
|
353
|
-
ItemIndicator: SelectItemIndicator,
|
|
354
|
-
ItemText: import_SelectItemText.SelectItemText,
|
|
355
|
-
Label: SelectLabel,
|
|
356
|
-
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
357
|
-
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
358
|
-
Trigger: import_SelectTrigger.SelectTrigger,
|
|
359
|
-
Value: SelectValue,
|
|
360
|
-
Viewport: import_SelectViewport.SelectViewport,
|
|
361
|
-
Indicator: SelectIndicator,
|
|
362
|
-
FocusScope: import_focus_scope.FocusScopeController
|
|
363
339
|
});
|
|
340
|
+
};
|
|
341
|
+
const SelectSheetImpl = props => {
|
|
342
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
343
|
+
children: props.children
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
const Select = (0, import_helpers.withStaticProperties)(function Select2(props) {
|
|
347
|
+
const adaptScope = `AdaptSelect${props.scope || ""}`;
|
|
348
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
349
|
+
scope: adaptScope,
|
|
350
|
+
portal: true,
|
|
351
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectInner, {
|
|
352
|
+
scope: props.scope,
|
|
353
|
+
adaptScope,
|
|
354
|
+
...props
|
|
355
|
+
})
|
|
356
|
+
});
|
|
357
|
+
}, {
|
|
358
|
+
Adapt: import_adapt.Adapt,
|
|
359
|
+
Content: import_SelectContent.SelectContent,
|
|
360
|
+
Group: SelectGroup,
|
|
361
|
+
Icon: SelectIcon,
|
|
362
|
+
Item: import_SelectItem.SelectItem,
|
|
363
|
+
ItemIndicator: SelectItemIndicator,
|
|
364
|
+
ItemText: import_SelectItemText.SelectItemText,
|
|
365
|
+
Label: SelectLabel,
|
|
366
|
+
ScrollDownButton: import_SelectScrollButton.SelectScrollDownButton,
|
|
367
|
+
ScrollUpButton: import_SelectScrollButton.SelectScrollUpButton,
|
|
368
|
+
Trigger: import_SelectTrigger.SelectTrigger,
|
|
369
|
+
Value: SelectValue,
|
|
370
|
+
Viewport: import_SelectViewport.SelectViewport,
|
|
371
|
+
Indicator: SelectIndicator,
|
|
372
|
+
FocusScope: import_focus_scope.FocusScopeController
|
|
373
|
+
});
|
|
364
374
|
function useEmitter() {
|
|
365
|
-
const listenersRef = React.useRef(/* @__PURE__ */new Set())
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
375
|
+
const listenersRef = React.useRef(/* @__PURE__ */new Set());
|
|
376
|
+
return [React.useCallback(value => {
|
|
377
|
+
listenersRef.current.forEach(l => l(value));
|
|
378
|
+
}, []), React.useCallback(listener => {
|
|
379
|
+
listenersRef.current.add(listener);
|
|
380
|
+
return () => {
|
|
370
381
|
listenersRef.current.delete(listener);
|
|
371
|
-
}
|
|
372
|
-
|
|
382
|
+
};
|
|
383
|
+
}, [])];
|
|
373
384
|
}
|
|
374
385
|
function SelectInner(props) {
|
|
375
386
|
const {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
387
|
+
scope = "",
|
|
388
|
+
adaptScope,
|
|
389
|
+
native,
|
|
390
|
+
children,
|
|
391
|
+
open: openProp,
|
|
392
|
+
defaultOpen,
|
|
393
|
+
onOpenChange,
|
|
394
|
+
value: valueProp,
|
|
395
|
+
defaultValue,
|
|
396
|
+
onValueChange,
|
|
397
|
+
disablePreventBodyScroll,
|
|
398
|
+
size: sizeProp = "$true",
|
|
399
|
+
onActiveChange,
|
|
400
|
+
dir,
|
|
401
|
+
id,
|
|
402
|
+
renderValue,
|
|
403
|
+
lazyMount,
|
|
404
|
+
zIndex
|
|
405
|
+
} = props;
|
|
406
|
+
const SelectImpl = (0, import_adapt.useAdaptIsActive)(adaptScope) || !import_constants.isWeb ? SelectSheetImpl : import_SelectImpl.SelectInlineImpl;
|
|
407
|
+
const forceUpdate = React.useReducer(() => ({}), {})[1];
|
|
408
|
+
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
409
|
+
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
410
|
+
prop: openProp,
|
|
411
|
+
defaultProp: defaultOpen || false,
|
|
412
|
+
onChange: onOpenChange
|
|
413
|
+
});
|
|
414
|
+
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
415
|
+
prop: valueProp,
|
|
416
|
+
defaultProp: defaultValue || "",
|
|
417
|
+
onChange: onValueChange,
|
|
418
|
+
transition: true
|
|
419
|
+
});
|
|
420
|
+
React.useEffect(() => {
|
|
421
|
+
if (open) emitValue(value);
|
|
422
|
+
}, [open]);
|
|
407
423
|
React.useEffect(() => {
|
|
408
|
-
open && emitValue(value);
|
|
409
|
-
}, [open]), React.useEffect(() => {
|
|
410
424
|
emitValue(value);
|
|
411
425
|
}, [value]);
|
|
412
|
-
const activeIndexRef = React.useRef(null)
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
426
|
+
const activeIndexRef = React.useRef(null);
|
|
427
|
+
const [activeIndex, setActiveIndexState] = React.useState(null);
|
|
428
|
+
const [emitValue, valueSubscribe] = useEmitter();
|
|
429
|
+
const [emitActiveIndex, activeIndexSubscribe] = useEmitter();
|
|
430
|
+
const selectedIndexRef = React.useRef(null);
|
|
431
|
+
const listContentRef = React.useRef([]);
|
|
432
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
433
|
+
const [valueNode, setValueNode] = React.useState(null);
|
|
420
434
|
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
421
435
|
selectedIndexRef.current = selectedIndex;
|
|
422
436
|
});
|
|
423
|
-
const shouldRenderWebNative = import_constants.isWeb && (native ===
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
437
|
+
const shouldRenderWebNative = import_constants.isWeb && (native === true || native === "web" || Array.isArray(native) && native.includes("web"));
|
|
438
|
+
const setActiveIndexFast = React.useCallback(index => {
|
|
439
|
+
if (activeIndexRef.current !== index) {
|
|
440
|
+
activeIndexRef.current = index;
|
|
441
|
+
if (typeof index === "number") emitActiveIndex(index);
|
|
442
|
+
}
|
|
443
|
+
}, [emitActiveIndex]);
|
|
444
|
+
const setActiveIndex = React.useCallback(index => {
|
|
445
|
+
setActiveIndexFast(index);
|
|
446
|
+
setActiveIndexState(index);
|
|
447
|
+
}, [setActiveIndexFast]);
|
|
448
|
+
const content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.SelectItemParentProvider, {
|
|
431
449
|
scopeName: scope,
|
|
432
450
|
scope,
|
|
433
451
|
adaptScope,
|
|
434
452
|
initialValue: React.useMemo(() => value, [open]),
|
|
435
453
|
size: sizeProp,
|
|
436
454
|
activeIndexSubscribe,
|
|
455
|
+
activeIndexRef,
|
|
437
456
|
valueSubscribe,
|
|
438
457
|
setOpen,
|
|
439
458
|
id,
|
|
440
459
|
onChange: React.useCallback(val => {
|
|
441
|
-
setValue(val)
|
|
460
|
+
setValue(val);
|
|
461
|
+
emitValue(val);
|
|
442
462
|
}, []),
|
|
443
463
|
onActiveChange: (0, import_core.useEvent)((value2, index) => {
|
|
444
464
|
onActiveChange?.(value2, index);
|
|
@@ -457,8 +477,8 @@ function SelectInner(props) {
|
|
|
457
477
|
adaptScope,
|
|
458
478
|
disablePreventBodyScroll,
|
|
459
479
|
dir,
|
|
460
|
-
blockSelection:
|
|
461
|
-
fallback:
|
|
480
|
+
blockSelection: false,
|
|
481
|
+
fallback: false,
|
|
462
482
|
forceUpdate,
|
|
463
483
|
valueNode,
|
|
464
484
|
onValueNodeChange: setValueNode,
|
|
@@ -470,6 +490,7 @@ function SelectInner(props) {
|
|
|
470
490
|
open,
|
|
471
491
|
native,
|
|
472
492
|
renderValue,
|
|
493
|
+
lazyMount,
|
|
473
494
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SelectSheetController, {
|
|
474
495
|
onOpenChange: setOpen,
|
|
475
496
|
scope,
|
|
@@ -486,4 +507,9 @@ function SelectInner(props) {
|
|
|
486
507
|
})
|
|
487
508
|
})
|
|
488
509
|
});
|
|
510
|
+
if (zIndex !== void 0) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.SelectZIndexContext.Provider, {
|
|
511
|
+
value: zIndex,
|
|
512
|
+
children: content
|
|
513
|
+
});
|
|
514
|
+
return content;
|
|
489
515
|
}
|