@radix-ui/react-select 2.0.1-rc.9 → 2.1.0-rc.2
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/index.d.mts +81 -69
- package/dist/index.d.ts +81 -69
- package/dist/index.js +1064 -1229
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +1077 -1199
- package/dist/index.mjs.map +7 -1
- package/package.json +20 -21
- package/dist/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,1311 +1,1146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
$parcel$export(module.exports, "createSelectScope", () => $1345bda09ffc1bc6$export$286727a75dc039bd);
|
|
34
|
-
$parcel$export(module.exports, "Select", () => $1345bda09ffc1bc6$export$ef9b1a59e592288f);
|
|
35
|
-
$parcel$export(module.exports, "SelectTrigger", () => $1345bda09ffc1bc6$export$3ac1e88a1c0b9f1);
|
|
36
|
-
$parcel$export(module.exports, "SelectValue", () => $1345bda09ffc1bc6$export$e288731fd71264f0);
|
|
37
|
-
$parcel$export(module.exports, "SelectIcon", () => $1345bda09ffc1bc6$export$99b400cabb58c515);
|
|
38
|
-
$parcel$export(module.exports, "SelectPortal", () => $1345bda09ffc1bc6$export$b2af6c9944296213);
|
|
39
|
-
$parcel$export(module.exports, "SelectContent", () => $1345bda09ffc1bc6$export$c973a4b3cb86a03d);
|
|
40
|
-
$parcel$export(module.exports, "SelectViewport", () => $1345bda09ffc1bc6$export$9ed6e7b40248d36d);
|
|
41
|
-
$parcel$export(module.exports, "SelectGroup", () => $1345bda09ffc1bc6$export$ee25a334c55de1f4);
|
|
42
|
-
$parcel$export(module.exports, "SelectLabel", () => $1345bda09ffc1bc6$export$f67338d29bd972f8);
|
|
43
|
-
$parcel$export(module.exports, "SelectItem", () => $1345bda09ffc1bc6$export$13ef48a934230896);
|
|
44
|
-
$parcel$export(module.exports, "SelectItemText", () => $1345bda09ffc1bc6$export$3572fb0fb821ff49);
|
|
45
|
-
$parcel$export(module.exports, "SelectItemIndicator", () => $1345bda09ffc1bc6$export$6b9198de19accfe6);
|
|
46
|
-
$parcel$export(module.exports, "SelectScrollUpButton", () => $1345bda09ffc1bc6$export$d8117927658af6d7);
|
|
47
|
-
$parcel$export(module.exports, "SelectScrollDownButton", () => $1345bda09ffc1bc6$export$ff951e476c12189);
|
|
48
|
-
$parcel$export(module.exports, "SelectSeparator", () => $1345bda09ffc1bc6$export$eba4b1df07cb1d3);
|
|
49
|
-
$parcel$export(module.exports, "SelectArrow", () => $1345bda09ffc1bc6$export$314f4cb8f8099628);
|
|
50
|
-
$parcel$export(module.exports, "Root", () => $1345bda09ffc1bc6$export$be92b6f5f03c0fe9);
|
|
51
|
-
$parcel$export(module.exports, "Trigger", () => $1345bda09ffc1bc6$export$41fb9f06171c75f4);
|
|
52
|
-
$parcel$export(module.exports, "Value", () => $1345bda09ffc1bc6$export$4c8d1a57a761ef94);
|
|
53
|
-
$parcel$export(module.exports, "Icon", () => $1345bda09ffc1bc6$export$f04a61298a47a40f);
|
|
54
|
-
$parcel$export(module.exports, "Portal", () => $1345bda09ffc1bc6$export$602eac185826482c);
|
|
55
|
-
$parcel$export(module.exports, "Content", () => $1345bda09ffc1bc6$export$7c6e2c02157bb7d2);
|
|
56
|
-
$parcel$export(module.exports, "Viewport", () => $1345bda09ffc1bc6$export$d5c6c08dc2d3ca7);
|
|
57
|
-
$parcel$export(module.exports, "Group", () => $1345bda09ffc1bc6$export$eb2fcfdbd7ba97d4);
|
|
58
|
-
$parcel$export(module.exports, "Label", () => $1345bda09ffc1bc6$export$b04be29aa201d4f5);
|
|
59
|
-
$parcel$export(module.exports, "Item", () => $1345bda09ffc1bc6$export$6d08773d2e66f8f2);
|
|
60
|
-
$parcel$export(module.exports, "ItemText", () => $1345bda09ffc1bc6$export$d6e5bf9c43ea9319);
|
|
61
|
-
$parcel$export(module.exports, "ItemIndicator", () => $1345bda09ffc1bc6$export$c3468e2714d175fa);
|
|
62
|
-
$parcel$export(module.exports, "ScrollUpButton", () => $1345bda09ffc1bc6$export$2f60d3ec9ad468f2);
|
|
63
|
-
$parcel$export(module.exports, "ScrollDownButton", () => $1345bda09ffc1bc6$export$bf1aedc3039c8d63);
|
|
64
|
-
$parcel$export(module.exports, "Separator", () => $1345bda09ffc1bc6$export$1ff3c3f08ae963c0);
|
|
65
|
-
$parcel$export(module.exports, "Arrow", () => $1345bda09ffc1bc6$export$21b07c8f274aebd5);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
(() => {
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
90
32
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
33
|
+
// packages/react/select/src/Select.tsx
|
|
34
|
+
var React = __toESM(__require("react"));
|
|
35
|
+
var ReactDOM = __toESM(__require("react-dom"));
|
|
36
|
+
var import_number = __require("@radix-ui/number");
|
|
37
|
+
var import_primitive = __require("@radix-ui/primitive");
|
|
38
|
+
var import_react_collection = __require("@radix-ui/react-collection");
|
|
39
|
+
var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
|
|
40
|
+
var import_react_context = __require("@radix-ui/react-context");
|
|
41
|
+
var import_react_direction = __require("@radix-ui/react-direction");
|
|
42
|
+
var import_react_dismissable_layer = __require("@radix-ui/react-dismissable-layer");
|
|
43
|
+
var import_react_focus_guards = __require("@radix-ui/react-focus-guards");
|
|
44
|
+
var import_react_focus_scope = __require("@radix-ui/react-focus-scope");
|
|
45
|
+
var import_react_id = __require("@radix-ui/react-id");
|
|
46
|
+
var PopperPrimitive = __toESM(__require("@radix-ui/react-popper"));
|
|
47
|
+
var import_react_popper = __require("@radix-ui/react-popper");
|
|
48
|
+
var import_react_portal = __require("@radix-ui/react-portal");
|
|
49
|
+
var import_react_primitive = __require("@radix-ui/react-primitive");
|
|
50
|
+
var import_react_slot = __require("@radix-ui/react-slot");
|
|
51
|
+
var import_react_use_callback_ref = __require("@radix-ui/react-use-callback-ref");
|
|
52
|
+
var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
|
|
53
|
+
var import_react_use_layout_effect = __require("@radix-ui/react-use-layout-effect");
|
|
54
|
+
var import_react_use_previous = __require("@radix-ui/react-use-previous");
|
|
55
|
+
var import_react_visually_hidden = __require("@radix-ui/react-visually-hidden");
|
|
56
|
+
var import_aria_hidden = __require("aria-hidden");
|
|
57
|
+
var import_react_remove_scroll = __require("react-remove-scroll");
|
|
58
|
+
var import_jsx_runtime = __require("react/jsx-runtime");
|
|
59
|
+
var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
|
|
60
|
+
var SELECTION_KEYS = [" ", "Enter"];
|
|
61
|
+
var SELECT_NAME = "Select";
|
|
62
|
+
var [Collection, useCollection, createCollectionScope] = (0, import_react_collection.createCollection)(SELECT_NAME);
|
|
63
|
+
var [createSelectContext, createSelectScope] = (0, import_react_context.createContextScope)(SELECT_NAME, [
|
|
64
|
+
createCollectionScope,
|
|
65
|
+
import_react_popper.createPopperScope
|
|
66
|
+
]);
|
|
67
|
+
var usePopperScope = (0, import_react_popper.createPopperScope)();
|
|
68
|
+
var [SelectProvider, useSelectContext] = createSelectContext(SELECT_NAME);
|
|
69
|
+
var [SelectNativeOptionsProvider, useSelectNativeOptionsContext] = createSelectContext(SELECT_NAME);
|
|
70
|
+
var Select = (props) => {
|
|
71
|
+
const {
|
|
72
|
+
__scopeSelect,
|
|
73
|
+
children,
|
|
74
|
+
open: openProp,
|
|
75
|
+
defaultOpen,
|
|
76
|
+
onOpenChange,
|
|
77
|
+
value: valueProp,
|
|
78
|
+
defaultValue,
|
|
79
|
+
onValueChange,
|
|
80
|
+
dir,
|
|
81
|
+
name,
|
|
82
|
+
autoComplete,
|
|
83
|
+
disabled,
|
|
84
|
+
required
|
|
85
|
+
} = props;
|
|
86
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
87
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
88
|
+
const [valueNode, setValueNode] = React.useState(null);
|
|
89
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = React.useState(false);
|
|
90
|
+
const direction = (0, import_react_direction.useDirection)(dir);
|
|
91
|
+
const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
|
|
92
|
+
prop: openProp,
|
|
93
|
+
defaultProp: defaultOpen,
|
|
94
|
+
onChange: onOpenChange
|
|
123
95
|
});
|
|
124
|
-
const [value, setValue] =
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
96
|
+
const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
|
|
97
|
+
prop: valueProp,
|
|
98
|
+
defaultProp: defaultValue,
|
|
99
|
+
onChange: onValueChange
|
|
128
100
|
});
|
|
129
|
-
const triggerPointerDownPosRef =
|
|
130
|
-
const isFormControl = trigger ? Boolean(trigger.closest(
|
|
131
|
-
const [nativeOptionsSet, setNativeOptionsSet] =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
).join(';');
|
|
138
|
-
return /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactpopper.Root, popperScope, /*#__PURE__*/ $cg2C9$react.createElement($1345bda09ffc1bc6$var$SelectProvider, {
|
|
139
|
-
required: required,
|
|
101
|
+
const triggerPointerDownPosRef = React.useRef(null);
|
|
102
|
+
const isFormControl = trigger ? Boolean(trigger.closest("form")) : true;
|
|
103
|
+
const [nativeOptionsSet, setNativeOptionsSet] = React.useState(/* @__PURE__ */ new Set());
|
|
104
|
+
const nativeSelectKey = Array.from(nativeOptionsSet).map((option) => option.props.value).join(";");
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
106
|
+
SelectProvider,
|
|
107
|
+
{
|
|
108
|
+
required,
|
|
140
109
|
scope: __scopeSelect,
|
|
141
|
-
trigger
|
|
110
|
+
trigger,
|
|
142
111
|
onTriggerChange: setTrigger,
|
|
143
|
-
valueNode
|
|
112
|
+
valueNode,
|
|
144
113
|
onValueNodeChange: setValueNode,
|
|
145
|
-
valueNodeHasChildren
|
|
114
|
+
valueNodeHasChildren,
|
|
146
115
|
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
147
|
-
contentId:
|
|
148
|
-
value
|
|
116
|
+
contentId: (0, import_react_id.useId)(),
|
|
117
|
+
value,
|
|
149
118
|
onValueChange: setValue,
|
|
150
|
-
open
|
|
119
|
+
open,
|
|
151
120
|
onOpenChange: setOpen,
|
|
152
121
|
dir: direction,
|
|
153
|
-
triggerPointerDownPosRef
|
|
154
|
-
disabled
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
122
|
+
triggerPointerDownPosRef,
|
|
123
|
+
disabled,
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Provider, { scope: __scopeSelect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
+
SelectNativeOptionsProvider,
|
|
127
|
+
{
|
|
128
|
+
scope: props.__scopeSelect,
|
|
129
|
+
onNativeOptionAdd: React.useCallback((option) => {
|
|
130
|
+
setNativeOptionsSet((prev) => new Set(prev).add(option));
|
|
131
|
+
}, []),
|
|
132
|
+
onNativeOptionRemove: React.useCallback((option) => {
|
|
133
|
+
setNativeOptionsSet((prev) => {
|
|
134
|
+
const optionsSet = new Set(prev);
|
|
135
|
+
optionsSet.delete(option);
|
|
136
|
+
return optionsSet;
|
|
137
|
+
});
|
|
138
|
+
}, []),
|
|
139
|
+
children
|
|
140
|
+
}
|
|
141
|
+
) }),
|
|
142
|
+
isFormControl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
143
|
+
BubbleSelect,
|
|
144
|
+
{
|
|
145
|
+
"aria-hidden": true,
|
|
146
|
+
required,
|
|
147
|
+
tabIndex: -1,
|
|
148
|
+
name,
|
|
149
|
+
autoComplete,
|
|
150
|
+
value,
|
|
151
|
+
onChange: (event) => setValue(event.target.value),
|
|
152
|
+
disabled,
|
|
153
|
+
children: [
|
|
154
|
+
value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "" }) : null,
|
|
155
|
+
Array.from(nativeOptionsSet)
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
nativeSelectKey
|
|
159
|
+
) : null
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
) });
|
|
163
|
+
};
|
|
164
|
+
Select.displayName = SELECT_NAME;
|
|
165
|
+
var TRIGGER_NAME = "SelectTrigger";
|
|
166
|
+
var SelectTrigger = React.forwardRef(
|
|
167
|
+
(props, forwardedRef) => {
|
|
168
|
+
const { __scopeSelect, disabled = false, ...triggerProps } = props;
|
|
169
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
170
|
+
const context = useSelectContext(TRIGGER_NAME, __scopeSelect);
|
|
171
|
+
const isDisabled = context.disabled || disabled;
|
|
172
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.onTriggerChange);
|
|
173
|
+
const getItems = useCollection(__scopeSelect);
|
|
174
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = useTypeaheadSearch((search) => {
|
|
175
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
176
|
+
const currentItem = enabledItems.find((item) => item.value === context.value);
|
|
177
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
178
|
+
if (nextItem !== void 0) {
|
|
179
|
+
context.onValueChange(nextItem.value);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
const handleOpen = () => {
|
|
208
183
|
if (!isDisabled) {
|
|
209
|
-
|
|
210
|
-
|
|
184
|
+
context.onOpenChange(true);
|
|
185
|
+
resetTypeahead();
|
|
211
186
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
onClick: $cg2C9$radixuiprimitive.composeEventHandlers(triggerProps.onClick, (event)=>{
|
|
231
|
-
// Whilst browsers generally have no issue focusing the trigger when clicking
|
|
232
|
-
// on a label, Safari seems to struggle with the fact that there's no `onClick`.
|
|
233
|
-
// We force `focus` in this case. Note: this doesn't create any other side-effect
|
|
234
|
-
// because we are preventing default in `onPointerDown` so effectively
|
|
235
|
-
// this only runs for a label "click"
|
|
187
|
+
};
|
|
188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
189
|
+
import_react_primitive.Primitive.button,
|
|
190
|
+
{
|
|
191
|
+
type: "button",
|
|
192
|
+
role: "combobox",
|
|
193
|
+
"aria-controls": context.contentId,
|
|
194
|
+
"aria-expanded": context.open,
|
|
195
|
+
"aria-required": context.required,
|
|
196
|
+
"aria-autocomplete": "none",
|
|
197
|
+
dir: context.dir,
|
|
198
|
+
"data-state": context.open ? "open" : "closed",
|
|
199
|
+
disabled: isDisabled,
|
|
200
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
201
|
+
"data-placeholder": shouldShowPlaceholder(context.value) ? "" : void 0,
|
|
202
|
+
...triggerProps,
|
|
203
|
+
ref: composedRefs,
|
|
204
|
+
onClick: (0, import_primitive.composeEventHandlers)(triggerProps.onClick, (event) => {
|
|
236
205
|
event.currentTarget.focus();
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// prevent implicit pointer capture
|
|
240
|
-
// https://www.w3.org/TR/pointerevents3/#implicit-pointer-capture
|
|
206
|
+
}),
|
|
207
|
+
onPointerDown: (0, import_primitive.composeEventHandlers)(triggerProps.onPointerDown, (event) => {
|
|
241
208
|
const target = event.target;
|
|
242
|
-
if (target.hasPointerCapture(event.pointerId))
|
|
243
|
-
|
|
244
|
-
|
|
209
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
210
|
+
target.releasePointerCapture(event.pointerId);
|
|
211
|
+
}
|
|
245
212
|
if (event.button === 0 && event.ctrlKey === false) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
213
|
+
handleOpen();
|
|
214
|
+
context.triggerPointerDownPosRef.current = {
|
|
215
|
+
x: Math.round(event.pageX),
|
|
216
|
+
y: Math.round(event.pageY)
|
|
217
|
+
};
|
|
218
|
+
event.preventDefault();
|
|
252
219
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const isTypingAhead = searchRef.current !==
|
|
220
|
+
}),
|
|
221
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(triggerProps.onKeyDown, (event) => {
|
|
222
|
+
const isTypingAhead = searchRef.current !== "";
|
|
256
223
|
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
257
224
|
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
258
|
-
if (isTypingAhead && event.key ===
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
225
|
+
if (isTypingAhead && event.key === " ") return;
|
|
226
|
+
if (OPEN_KEYS.includes(event.key)) {
|
|
227
|
+
handleOpen();
|
|
228
|
+
event.preventDefault();
|
|
262
229
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const composedRefs = $cg2C9$radixuireactcomposerefs.useComposedRefs(forwardedRef, context.onValueNodeChange);
|
|
279
|
-
$cg2C9$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
) });
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
SelectTrigger.displayName = TRIGGER_NAME;
|
|
236
|
+
var VALUE_NAME = "SelectValue";
|
|
237
|
+
var SelectValue = React.forwardRef(
|
|
238
|
+
(props, forwardedRef) => {
|
|
239
|
+
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
|
240
|
+
const context = useSelectContext(VALUE_NAME, __scopeSelect);
|
|
241
|
+
const { onValueNodeHasChildrenChange } = context;
|
|
242
|
+
const hasChildren = children !== void 0;
|
|
243
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.onValueNodeChange);
|
|
244
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
280
245
|
onValueNodeHasChildrenChange(hasChildren);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
pointerEvents: 'none'
|
|
246
|
+
}, [onValueNodeHasChildrenChange, hasChildren]);
|
|
247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
248
|
+
import_react_primitive.Primitive.span,
|
|
249
|
+
{
|
|
250
|
+
...valueProps,
|
|
251
|
+
ref: composedRefs,
|
|
252
|
+
style: { pointerEvents: "none" },
|
|
253
|
+
children: shouldShowPlaceholder(context.value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: placeholder }) : children
|
|
290
254
|
}
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactportal.Portal, ($parcel$interopDefault($cg2C9$babelruntimehelpersextends))({
|
|
315
|
-
asChild: true
|
|
316
|
-
}, props));
|
|
317
|
-
};
|
|
318
|
-
/*#__PURE__*/ Object.assign($1345bda09ffc1bc6$export$b2af6c9944296213, {
|
|
319
|
-
displayName: $1345bda09ffc1bc6$var$PORTAL_NAME
|
|
320
|
-
});
|
|
321
|
-
/* -------------------------------------------------------------------------------------------------
|
|
322
|
-
* SelectContent
|
|
323
|
-
* -----------------------------------------------------------------------------------------------*/ const $1345bda09ffc1bc6$var$CONTENT_NAME = 'SelectContent';
|
|
324
|
-
const $1345bda09ffc1bc6$export$c973a4b3cb86a03d = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
325
|
-
const context = $1345bda09ffc1bc6$var$useSelectContext($1345bda09ffc1bc6$var$CONTENT_NAME, props.__scopeSelect);
|
|
326
|
-
const [fragment, setFragment] = $cg2C9$react.useState(); // setting the fragment in `useLayoutEffect` as `DocumentFragment` doesn't exist on the server
|
|
327
|
-
$cg2C9$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
SelectValue.displayName = VALUE_NAME;
|
|
259
|
+
var ICON_NAME = "SelectIcon";
|
|
260
|
+
var SelectIcon = React.forwardRef(
|
|
261
|
+
(props, forwardedRef) => {
|
|
262
|
+
const { __scopeSelect, children, ...iconProps } = props;
|
|
263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "\u25BC" });
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
SelectIcon.displayName = ICON_NAME;
|
|
267
|
+
var PORTAL_NAME = "SelectPortal";
|
|
268
|
+
var SelectPortal = (props) => {
|
|
269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_portal.Portal, { asChild: true, ...props });
|
|
270
|
+
};
|
|
271
|
+
SelectPortal.displayName = PORTAL_NAME;
|
|
272
|
+
var CONTENT_NAME = "SelectContent";
|
|
273
|
+
var SelectContent = React.forwardRef(
|
|
274
|
+
(props, forwardedRef) => {
|
|
275
|
+
const context = useSelectContext(CONTENT_NAME, props.__scopeSelect);
|
|
276
|
+
const [fragment, setFragment] = React.useState();
|
|
277
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
328
278
|
setFragment(new DocumentFragment());
|
|
329
|
-
|
|
330
|
-
|
|
279
|
+
}, []);
|
|
280
|
+
if (!context.open) {
|
|
331
281
|
const frag = fragment;
|
|
332
|
-
return frag ?
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
282
|
+
return frag ? ReactDOM.createPortal(
|
|
283
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContentProvider, { scope: props.__scopeSelect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, { scope: props.__scopeSelect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: props.children }) }) }),
|
|
284
|
+
frag
|
|
285
|
+
) : null;
|
|
286
|
+
}
|
|
287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContentImpl, { ...props, ref: forwardedRef });
|
|
337
288
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
289
|
+
);
|
|
290
|
+
SelectContent.displayName = CONTENT_NAME;
|
|
291
|
+
var CONTENT_MARGIN = 10;
|
|
292
|
+
var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME);
|
|
293
|
+
var CONTENT_IMPL_NAME = "SelectContentImpl";
|
|
294
|
+
var SelectContentImpl = React.forwardRef(
|
|
295
|
+
(props, forwardedRef) => {
|
|
296
|
+
const {
|
|
297
|
+
__scopeSelect,
|
|
298
|
+
position = "item-aligned",
|
|
299
|
+
onCloseAutoFocus,
|
|
300
|
+
onEscapeKeyDown,
|
|
301
|
+
onPointerDownOutside,
|
|
302
|
+
//
|
|
303
|
+
// PopperContent props
|
|
304
|
+
side,
|
|
305
|
+
sideOffset,
|
|
306
|
+
align,
|
|
307
|
+
alignOffset,
|
|
308
|
+
arrowPadding,
|
|
309
|
+
collisionBoundary,
|
|
310
|
+
collisionPadding,
|
|
311
|
+
sticky,
|
|
312
|
+
hideWhenDetached,
|
|
313
|
+
avoidCollisions,
|
|
314
|
+
//
|
|
315
|
+
...contentProps
|
|
316
|
+
} = props;
|
|
317
|
+
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
318
|
+
const [content, setContent] = React.useState(null);
|
|
319
|
+
const [viewport, setViewport] = React.useState(null);
|
|
320
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node) => setContent(node));
|
|
321
|
+
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
322
|
+
const [selectedItemText, setSelectedItemText] = React.useState(
|
|
323
|
+
null
|
|
324
|
+
);
|
|
325
|
+
const getItems = useCollection(__scopeSelect);
|
|
326
|
+
const [isPositioned, setIsPositioned] = React.useState(false);
|
|
327
|
+
const firstValidItemFoundRef = React.useRef(false);
|
|
328
|
+
React.useEffect(() => {
|
|
329
|
+
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
330
|
+
}, [content]);
|
|
331
|
+
(0, import_react_focus_guards.useFocusGuards)();
|
|
332
|
+
const focusFirst = React.useCallback(
|
|
333
|
+
(candidates) => {
|
|
334
|
+
const [firstItem, ...restItems] = getItems().map((item) => item.ref.current);
|
|
335
|
+
const [lastItem] = restItems.slice(-1);
|
|
336
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
337
|
+
for (const candidate of candidates) {
|
|
379
338
|
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
380
|
-
candidate
|
|
381
|
-
block: 'nearest'
|
|
382
|
-
}); // viewport might have padding so scroll to its edges when focusing first/last items.
|
|
339
|
+
candidate?.scrollIntoView({ block: "nearest" });
|
|
383
340
|
if (candidate === firstItem && viewport) viewport.scrollTop = 0;
|
|
384
341
|
if (candidate === lastItem && viewport) viewport.scrollTop = viewport.scrollHeight;
|
|
385
|
-
candidate
|
|
342
|
+
candidate?.focus();
|
|
386
343
|
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
[getItems, viewport]
|
|
347
|
+
);
|
|
348
|
+
const focusSelectedItem = React.useCallback(
|
|
349
|
+
() => focusFirst([selectedItem, content]),
|
|
350
|
+
[focusFirst, selectedItem, content]
|
|
351
|
+
);
|
|
352
|
+
React.useEffect(() => {
|
|
353
|
+
if (isPositioned) {
|
|
354
|
+
focusSelectedItem();
|
|
387
355
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
]);
|
|
392
|
-
const focusSelectedItem = $cg2C9$react.useCallback(()=>focusFirst([
|
|
393
|
-
selectedItem,
|
|
394
|
-
content
|
|
395
|
-
])
|
|
396
|
-
, [
|
|
397
|
-
focusFirst,
|
|
398
|
-
selectedItem,
|
|
399
|
-
content
|
|
400
|
-
]); // Since this is not dependent on layout, we want to ensure this runs at the same time as
|
|
401
|
-
// other effects across components. Hence why we don't call `focusSelectedItem` inside `position`.
|
|
402
|
-
$cg2C9$react.useEffect(()=>{
|
|
403
|
-
if (isPositioned) focusSelectedItem();
|
|
404
|
-
}, [
|
|
405
|
-
isPositioned,
|
|
406
|
-
focusSelectedItem
|
|
407
|
-
]); // prevent selecting items on `pointerup` in some cases after opening from `pointerdown`
|
|
408
|
-
// and close on `pointerup` outside.
|
|
409
|
-
const { onOpenChange: onOpenChange , triggerPointerDownPosRef: triggerPointerDownPosRef } = context;
|
|
410
|
-
$cg2C9$react.useEffect(()=>{
|
|
356
|
+
}, [isPositioned, focusSelectedItem]);
|
|
357
|
+
const { onOpenChange, triggerPointerDownPosRef } = context;
|
|
358
|
+
React.useEffect(() => {
|
|
411
359
|
if (content) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
|
|
418
|
-
pointerMoveDelta = {
|
|
419
|
-
x: Math.abs(Math.round(event.pageX) - ((_triggerPointerDownPo = (_triggerPointerDownPo2 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo2 === void 0 ? void 0 : _triggerPointerDownPo2.x) !== null && _triggerPointerDownPo !== void 0 ? _triggerPointerDownPo : 0)),
|
|
420
|
-
y: Math.abs(Math.round(event.pageY) - ((_triggerPointerDownPo3 = (_triggerPointerDownPo4 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo4 === void 0 ? void 0 : _triggerPointerDownPo4.y) !== null && _triggerPointerDownPo3 !== void 0 ? _triggerPointerDownPo3 : 0))
|
|
421
|
-
};
|
|
360
|
+
let pointerMoveDelta = { x: 0, y: 0 };
|
|
361
|
+
const handlePointerMove = (event) => {
|
|
362
|
+
pointerMoveDelta = {
|
|
363
|
+
x: Math.abs(Math.round(event.pageX) - (triggerPointerDownPosRef.current?.x ?? 0)),
|
|
364
|
+
y: Math.abs(Math.round(event.pageY) - (triggerPointerDownPosRef.current?.y ?? 0))
|
|
422
365
|
};
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (triggerPointerDownPosRef.current !== null) {
|
|
432
|
-
document.addEventListener('pointermove', handlePointerMove);
|
|
433
|
-
document.addEventListener('pointerup', handlePointerUp, {
|
|
434
|
-
capture: true,
|
|
435
|
-
once: true
|
|
436
|
-
});
|
|
366
|
+
};
|
|
367
|
+
const handlePointerUp = (event) => {
|
|
368
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10) {
|
|
369
|
+
event.preventDefault();
|
|
370
|
+
} else {
|
|
371
|
+
if (!content.contains(event.target)) {
|
|
372
|
+
onOpenChange(false);
|
|
373
|
+
}
|
|
437
374
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
};
|
|
375
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
376
|
+
triggerPointerDownPosRef.current = null;
|
|
377
|
+
};
|
|
378
|
+
if (triggerPointerDownPosRef.current !== null) {
|
|
379
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
380
|
+
document.addEventListener("pointerup", handlePointerUp, { capture: true, once: true });
|
|
381
|
+
}
|
|
382
|
+
return () => {
|
|
383
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
384
|
+
document.removeEventListener("pointerup", handlePointerUp, { capture: true });
|
|
385
|
+
};
|
|
444
386
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
onOpenChange
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
window.addEventListener('blur', close);
|
|
454
|
-
window.addEventListener('resize', close);
|
|
455
|
-
return ()=>{
|
|
456
|
-
window.removeEventListener('blur', close);
|
|
457
|
-
window.removeEventListener('resize', close);
|
|
387
|
+
}, [content, onOpenChange, triggerPointerDownPosRef]);
|
|
388
|
+
React.useEffect(() => {
|
|
389
|
+
const close = () => onOpenChange(false);
|
|
390
|
+
window.addEventListener("blur", close);
|
|
391
|
+
window.addEventListener("resize", close);
|
|
392
|
+
return () => {
|
|
393
|
+
window.removeEventListener("blur", close);
|
|
394
|
+
window.removeEventListener("resize", close);
|
|
458
395
|
};
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const
|
|
464
|
-
)
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
});
|
|
474
|
-
const itemRefCallback = $cg2C9$react.useCallback((node, value, disabled)=>{
|
|
475
|
-
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
476
|
-
const isSelectedItem = context.value !== undefined && context.value === value;
|
|
477
|
-
if (isSelectedItem || isFirstValidItem) {
|
|
396
|
+
}, [onOpenChange]);
|
|
397
|
+
const [searchRef, handleTypeaheadSearch] = useTypeaheadSearch((search) => {
|
|
398
|
+
const enabledItems = getItems().filter((item) => !item.disabled);
|
|
399
|
+
const currentItem = enabledItems.find((item) => item.ref.current === document.activeElement);
|
|
400
|
+
const nextItem = findNextItem(enabledItems, search, currentItem);
|
|
401
|
+
if (nextItem) {
|
|
402
|
+
setTimeout(() => nextItem.ref.current.focus());
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
const itemRefCallback = React.useCallback(
|
|
406
|
+
(node, value, disabled) => {
|
|
407
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
408
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
409
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
478
410
|
setSelectedItem(node);
|
|
479
411
|
if (isFirstValidItem) firstValidItemFoundRef.current = true;
|
|
480
|
-
|
|
481
|
-
}, [
|
|
482
|
-
context.value
|
|
483
|
-
]);
|
|
484
|
-
const handleItemLeave = $cg2C9$react.useCallback(()=>content === null || content === void 0 ? void 0 : content.focus()
|
|
485
|
-
, [
|
|
486
|
-
content
|
|
487
|
-
]);
|
|
488
|
-
const itemTextRefCallback = $cg2C9$react.useCallback((node, value, disabled)=>{
|
|
489
|
-
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
490
|
-
const isSelectedItem = context.value !== undefined && context.value === value;
|
|
491
|
-
if (isSelectedItem || isFirstValidItem) setSelectedItemText(node);
|
|
492
|
-
}, [
|
|
493
|
-
context.value
|
|
494
|
-
]);
|
|
495
|
-
const SelectPosition = position === 'popper' ? $1345bda09ffc1bc6$var$SelectPopperPosition : $1345bda09ffc1bc6$var$SelectItemAlignedPosition; // Silently ignore props that are not supported by `SelectItemAlignedPosition`
|
|
496
|
-
const popperContentProps = SelectPosition === $1345bda09ffc1bc6$var$SelectPopperPosition ? {
|
|
497
|
-
side: side,
|
|
498
|
-
sideOffset: sideOffset,
|
|
499
|
-
align: align,
|
|
500
|
-
alignOffset: alignOffset,
|
|
501
|
-
arrowPadding: arrowPadding,
|
|
502
|
-
collisionBoundary: collisionBoundary,
|
|
503
|
-
collisionPadding: collisionPadding,
|
|
504
|
-
sticky: sticky,
|
|
505
|
-
hideWhenDetached: hideWhenDetached,
|
|
506
|
-
avoidCollisions: avoidCollisions
|
|
507
|
-
} : {};
|
|
508
|
-
return /*#__PURE__*/ $cg2C9$react.createElement($1345bda09ffc1bc6$var$SelectContentProvider, {
|
|
509
|
-
scope: __scopeSelect,
|
|
510
|
-
content: content,
|
|
511
|
-
viewport: viewport,
|
|
512
|
-
onViewportChange: setViewport,
|
|
513
|
-
itemRefCallback: itemRefCallback,
|
|
514
|
-
selectedItem: selectedItem,
|
|
515
|
-
onItemLeave: handleItemLeave,
|
|
516
|
-
itemTextRefCallback: itemTextRefCallback,
|
|
517
|
-
focusSelectedItem: focusSelectedItem,
|
|
518
|
-
selectedItemText: selectedItemText,
|
|
519
|
-
position: position,
|
|
520
|
-
isPositioned: isPositioned,
|
|
521
|
-
searchRef: searchRef
|
|
522
|
-
}, /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$reactremovescroll.RemoveScroll, {
|
|
523
|
-
as: $cg2C9$radixuireactslot.Slot,
|
|
524
|
-
allowPinchZoom: true
|
|
525
|
-
}, /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactfocusscope.FocusScope, {
|
|
526
|
-
asChild: true // we make sure we're not trapping once it's been closed
|
|
527
|
-
,
|
|
528
|
-
trapped: context.open,
|
|
529
|
-
onMountAutoFocus: (event)=>{
|
|
530
|
-
// we prevent open autofocus because we manually focus the selected item
|
|
531
|
-
event.preventDefault();
|
|
412
|
+
}
|
|
532
413
|
},
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
onEscapeKeyDown: onEscapeKeyDown,
|
|
544
|
-
onPointerDownOutside: onPointerDownOutside // When focus is trapped, a focusout event may still happen.
|
|
545
|
-
,
|
|
546
|
-
onFocusOutside: (event)=>event.preventDefault()
|
|
547
|
-
,
|
|
548
|
-
onDismiss: ()=>context.onOpenChange(false)
|
|
549
|
-
}, /*#__PURE__*/ $cg2C9$react.createElement(SelectPosition, ($parcel$interopDefault($cg2C9$babelruntimehelpersextends))({
|
|
550
|
-
role: "listbox",
|
|
551
|
-
id: context.contentId,
|
|
552
|
-
"data-state": context.open ? 'open' : 'closed',
|
|
553
|
-
dir: context.dir,
|
|
554
|
-
onContextMenu: (event)=>event.preventDefault()
|
|
555
|
-
}, contentProps, popperContentProps, {
|
|
556
|
-
onPlaced: ()=>setIsPositioned(true)
|
|
557
|
-
,
|
|
558
|
-
ref: composedRefs,
|
|
559
|
-
style: {
|
|
560
|
-
// flex layout so we can place the scroll buttons properly
|
|
561
|
-
display: 'flex',
|
|
562
|
-
flexDirection: 'column',
|
|
563
|
-
// reset the outline by default as the content MAY get focused
|
|
564
|
-
outline: 'none',
|
|
565
|
-
...contentProps.style
|
|
414
|
+
[context.value]
|
|
415
|
+
);
|
|
416
|
+
const handleItemLeave = React.useCallback(() => content?.focus(), [content]);
|
|
417
|
+
const itemTextRefCallback = React.useCallback(
|
|
418
|
+
(node, value, disabled) => {
|
|
419
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
420
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
421
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
422
|
+
setSelectedItemText(node);
|
|
423
|
+
}
|
|
566
424
|
},
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
425
|
+
[context.value]
|
|
426
|
+
);
|
|
427
|
+
const SelectPosition = position === "popper" ? SelectPopperPosition : SelectItemAlignedPosition;
|
|
428
|
+
const popperContentProps = SelectPosition === SelectPopperPosition ? {
|
|
429
|
+
side,
|
|
430
|
+
sideOffset,
|
|
431
|
+
align,
|
|
432
|
+
alignOffset,
|
|
433
|
+
arrowPadding,
|
|
434
|
+
collisionBoundary,
|
|
435
|
+
collisionPadding,
|
|
436
|
+
sticky,
|
|
437
|
+
hideWhenDetached,
|
|
438
|
+
avoidCollisions
|
|
439
|
+
} : {};
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
441
|
+
SelectContentProvider,
|
|
442
|
+
{
|
|
443
|
+
scope: __scopeSelect,
|
|
444
|
+
content,
|
|
445
|
+
viewport,
|
|
446
|
+
onViewportChange: setViewport,
|
|
447
|
+
itemRefCallback,
|
|
448
|
+
selectedItem,
|
|
449
|
+
onItemLeave: handleItemLeave,
|
|
450
|
+
itemTextRefCallback,
|
|
451
|
+
focusSelectedItem,
|
|
452
|
+
selectedItemText,
|
|
453
|
+
position,
|
|
454
|
+
isPositioned,
|
|
455
|
+
searchRef,
|
|
456
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_remove_scroll.RemoveScroll, { as: import_react_slot.Slot, allowPinchZoom: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
457
|
+
import_react_focus_scope.FocusScope,
|
|
458
|
+
{
|
|
459
|
+
asChild: true,
|
|
460
|
+
trapped: context.open,
|
|
461
|
+
onMountAutoFocus: (event) => {
|
|
598
462
|
event.preventDefault();
|
|
463
|
+
},
|
|
464
|
+
onUnmountAutoFocus: (0, import_primitive.composeEventHandlers)(onCloseAutoFocus, (event) => {
|
|
465
|
+
context.trigger?.focus({ preventScroll: true });
|
|
466
|
+
event.preventDefault();
|
|
467
|
+
}),
|
|
468
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
469
|
+
import_react_dismissable_layer.DismissableLayer,
|
|
470
|
+
{
|
|
471
|
+
asChild: true,
|
|
472
|
+
disableOutsidePointerEvents: true,
|
|
473
|
+
onEscapeKeyDown,
|
|
474
|
+
onPointerDownOutside,
|
|
475
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
476
|
+
onDismiss: () => context.onOpenChange(false),
|
|
477
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
478
|
+
SelectPosition,
|
|
479
|
+
{
|
|
480
|
+
role: "listbox",
|
|
481
|
+
id: context.contentId,
|
|
482
|
+
"data-state": context.open ? "open" : "closed",
|
|
483
|
+
dir: context.dir,
|
|
484
|
+
onContextMenu: (event) => event.preventDefault(),
|
|
485
|
+
...contentProps,
|
|
486
|
+
...popperContentProps,
|
|
487
|
+
onPlaced: () => setIsPositioned(true),
|
|
488
|
+
ref: composedRefs,
|
|
489
|
+
style: {
|
|
490
|
+
// flex layout so we can place the scroll buttons properly
|
|
491
|
+
display: "flex",
|
|
492
|
+
flexDirection: "column",
|
|
493
|
+
// reset the outline by default as the content MAY get focused
|
|
494
|
+
outline: "none",
|
|
495
|
+
...contentProps.style
|
|
496
|
+
},
|
|
497
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(contentProps.onKeyDown, (event) => {
|
|
498
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
499
|
+
if (event.key === "Tab") event.preventDefault();
|
|
500
|
+
if (!isModifierKey && event.key.length === 1) handleTypeaheadSearch(event.key);
|
|
501
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
|
|
502
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
503
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
|
504
|
+
if (["ArrowUp", "End"].includes(event.key)) {
|
|
505
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
506
|
+
}
|
|
507
|
+
if (["ArrowUp", "ArrowDown"].includes(event.key)) {
|
|
508
|
+
const currentElement = event.target;
|
|
509
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
510
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
511
|
+
}
|
|
512
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
513
|
+
event.preventDefault();
|
|
514
|
+
}
|
|
515
|
+
})
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
)
|
|
599
520
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const
|
|
610
|
-
const
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
);
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
contentWrapper.style.top = "0px";
|
|
688
|
-
const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
|
|
689
|
-
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
690
|
-
contentWrapper.style.height = height + 'px';
|
|
691
|
-
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
692
|
-
}
|
|
693
|
-
contentWrapper.style.margin = `${$1345bda09ffc1bc6$var$CONTENT_MARGIN}px 0`;
|
|
694
|
-
contentWrapper.style.minHeight = minContentHeight + 'px';
|
|
695
|
-
contentWrapper.style.maxHeight = availableHeight + 'px'; // -----------------------------------------------------------------------------------------
|
|
696
|
-
onPlaced === null || onPlaced === void 0 || onPlaced(); // we don't want the initial scroll position adjustment to trigger "expand on scroll"
|
|
697
|
-
// so we explicitly turn it on only after they've registered.
|
|
698
|
-
requestAnimationFrame(()=>shouldExpandOnScrollRef.current = true
|
|
699
|
-
);
|
|
521
|
+
) })
|
|
522
|
+
}
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
SelectContentImpl.displayName = CONTENT_IMPL_NAME;
|
|
527
|
+
var ITEM_ALIGNED_POSITION_NAME = "SelectItemAlignedPosition";
|
|
528
|
+
var SelectItemAlignedPosition = React.forwardRef((props, forwardedRef) => {
|
|
529
|
+
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
|
530
|
+
const context = useSelectContext(CONTENT_NAME, __scopeSelect);
|
|
531
|
+
const contentContext = useSelectContentContext(CONTENT_NAME, __scopeSelect);
|
|
532
|
+
const [contentWrapper, setContentWrapper] = React.useState(null);
|
|
533
|
+
const [content, setContent] = React.useState(null);
|
|
534
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node) => setContent(node));
|
|
535
|
+
const getItems = useCollection(__scopeSelect);
|
|
536
|
+
const shouldExpandOnScrollRef = React.useRef(false);
|
|
537
|
+
const shouldRepositionRef = React.useRef(true);
|
|
538
|
+
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
|
539
|
+
const position = React.useCallback(() => {
|
|
540
|
+
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
541
|
+
const triggerRect = context.trigger.getBoundingClientRect();
|
|
542
|
+
const contentRect = content.getBoundingClientRect();
|
|
543
|
+
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
544
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
545
|
+
if (context.dir !== "rtl") {
|
|
546
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
547
|
+
const left = valueNodeRect.left - itemTextOffset;
|
|
548
|
+
const leftDelta = triggerRect.left - left;
|
|
549
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
|
550
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
551
|
+
const rightEdge = window.innerWidth - CONTENT_MARGIN;
|
|
552
|
+
const clampedLeft = (0, import_number.clamp)(left, [CONTENT_MARGIN, rightEdge - contentWidth]);
|
|
553
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
554
|
+
contentWrapper.style.left = clampedLeft + "px";
|
|
555
|
+
} else {
|
|
556
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
557
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
558
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
559
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
|
560
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
561
|
+
const leftEdge = window.innerWidth - CONTENT_MARGIN;
|
|
562
|
+
const clampedRight = (0, import_number.clamp)(right, [CONTENT_MARGIN, leftEdge - contentWidth]);
|
|
563
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
564
|
+
contentWrapper.style.right = clampedRight + "px";
|
|
565
|
+
}
|
|
566
|
+
const items = getItems();
|
|
567
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
568
|
+
const itemsHeight = viewport.scrollHeight;
|
|
569
|
+
const contentStyles = window.getComputedStyle(content);
|
|
570
|
+
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
571
|
+
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
572
|
+
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
573
|
+
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
574
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
|
575
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
576
|
+
const viewportStyles = window.getComputedStyle(viewport);
|
|
577
|
+
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
578
|
+
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
579
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - CONTENT_MARGIN;
|
|
580
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
581
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
582
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
583
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
584
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
585
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
586
|
+
if (willAlignWithoutTopOverflow) {
|
|
587
|
+
const isLastItem = selectedItem === items[items.length - 1].ref.current;
|
|
588
|
+
contentWrapper.style.bottom = "0px";
|
|
589
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
590
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(
|
|
591
|
+
triggerMiddleToBottomEdge,
|
|
592
|
+
selectedItemHalfHeight + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
593
|
+
(isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth
|
|
594
|
+
);
|
|
595
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
596
|
+
contentWrapper.style.height = height + "px";
|
|
597
|
+
} else {
|
|
598
|
+
const isFirstItem = selectedItem === items[0].ref.current;
|
|
599
|
+
contentWrapper.style.top = "0px";
|
|
600
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(
|
|
601
|
+
topEdgeToTriggerMiddle,
|
|
602
|
+
contentBorderTopWidth + viewport.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
603
|
+
(isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight
|
|
604
|
+
);
|
|
605
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
606
|
+
contentWrapper.style.height = height + "px";
|
|
607
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
700
608
|
}
|
|
609
|
+
contentWrapper.style.margin = `${CONTENT_MARGIN}px 0`;
|
|
610
|
+
contentWrapper.style.minHeight = minContentHeight + "px";
|
|
611
|
+
contentWrapper.style.maxHeight = availableHeight + "px";
|
|
612
|
+
onPlaced?.();
|
|
613
|
+
requestAnimationFrame(() => shouldExpandOnScrollRef.current = true);
|
|
614
|
+
}
|
|
701
615
|
}, [
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
616
|
+
getItems,
|
|
617
|
+
context.trigger,
|
|
618
|
+
context.valueNode,
|
|
619
|
+
contentWrapper,
|
|
620
|
+
content,
|
|
621
|
+
viewport,
|
|
622
|
+
selectedItem,
|
|
623
|
+
selectedItemText,
|
|
624
|
+
context.dir,
|
|
625
|
+
onPlaced
|
|
712
626
|
]);
|
|
713
|
-
|
|
714
|
-
,
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}, [
|
|
721
|
-
content
|
|
722
|
-
]); // When the viewport becomes scrollable at the top, the scroll up button will mount.
|
|
723
|
-
// Because it is part of the normal flow, it will push down the viewport, thus throwing our
|
|
724
|
-
// trigger => selectedItem alignment off by the amount the viewport was pushed down.
|
|
725
|
-
// We wait for this to happen and then re-run the positining logic one more time to account for it.
|
|
726
|
-
const handleScrollButtonChange = $cg2C9$react.useCallback((node)=>{
|
|
627
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => position(), [position]);
|
|
628
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
|
629
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
630
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
631
|
+
}, [content]);
|
|
632
|
+
const handleScrollButtonChange = React.useCallback(
|
|
633
|
+
(node) => {
|
|
727
634
|
if (node && shouldRepositionRef.current === true) {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
635
|
+
position();
|
|
636
|
+
focusSelectedItem?.();
|
|
637
|
+
shouldRepositionRef.current = false;
|
|
731
638
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
639
|
+
},
|
|
640
|
+
[position, focusSelectedItem]
|
|
641
|
+
);
|
|
642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
643
|
+
SelectViewportProvider,
|
|
644
|
+
{
|
|
737
645
|
scope: __scopeSelect,
|
|
738
|
-
contentWrapper
|
|
739
|
-
shouldExpandOnScrollRef
|
|
740
|
-
onScrollButtonChange: handleScrollButtonChange
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
646
|
+
contentWrapper,
|
|
647
|
+
shouldExpandOnScrollRef,
|
|
648
|
+
onScrollButtonChange: handleScrollButtonChange,
|
|
649
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
650
|
+
"div",
|
|
651
|
+
{
|
|
652
|
+
ref: setContentWrapper,
|
|
653
|
+
style: {
|
|
654
|
+
display: "flex",
|
|
655
|
+
flexDirection: "column",
|
|
656
|
+
position: "fixed",
|
|
657
|
+
zIndex: contentZIndex
|
|
658
|
+
},
|
|
659
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
660
|
+
import_react_primitive.Primitive.div,
|
|
661
|
+
{
|
|
662
|
+
...popperProps,
|
|
663
|
+
ref: composedRefs,
|
|
664
|
+
style: {
|
|
665
|
+
// When we get the height of the content, it includes borders. If we were to set
|
|
666
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
667
|
+
boxSizing: "border-box",
|
|
668
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
|
669
|
+
maxHeight: "100%",
|
|
670
|
+
...popperProps.style
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
)
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
}
|
|
677
|
+
);
|
|
678
|
+
});
|
|
679
|
+
SelectItemAlignedPosition.displayName = ITEM_ALIGNED_POSITION_NAME;
|
|
680
|
+
var POPPER_POSITION_NAME = "SelectPopperPosition";
|
|
681
|
+
var SelectPopperPosition = React.forwardRef((props, forwardedRef) => {
|
|
682
|
+
const {
|
|
683
|
+
__scopeSelect,
|
|
684
|
+
align = "start",
|
|
685
|
+
collisionPadding = CONTENT_MARGIN,
|
|
686
|
+
...popperProps
|
|
687
|
+
} = props;
|
|
688
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
690
|
+
PopperPrimitive.Content,
|
|
691
|
+
{
|
|
692
|
+
...popperScope,
|
|
693
|
+
...popperProps,
|
|
771
694
|
ref: forwardedRef,
|
|
772
|
-
align
|
|
773
|
-
collisionPadding
|
|
695
|
+
align,
|
|
696
|
+
collisionPadding,
|
|
774
697
|
style: {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
698
|
+
// Ensure border-box for floating-ui calculations
|
|
699
|
+
boxSizing: "border-box",
|
|
700
|
+
...popperProps.style,
|
|
701
|
+
// re-namespace exposed content custom properties
|
|
702
|
+
...{
|
|
703
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
704
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
705
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
706
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
707
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
708
|
+
}
|
|
783
709
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
const
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
710
|
+
}
|
|
711
|
+
);
|
|
712
|
+
});
|
|
713
|
+
SelectPopperPosition.displayName = POPPER_POSITION_NAME;
|
|
714
|
+
var [SelectViewportProvider, useSelectViewportContext] = createSelectContext(CONTENT_NAME, {});
|
|
715
|
+
var VIEWPORT_NAME = "SelectViewport";
|
|
716
|
+
var SelectViewport = React.forwardRef(
|
|
717
|
+
(props, forwardedRef) => {
|
|
718
|
+
const { __scopeSelect, nonce, ...viewportProps } = props;
|
|
719
|
+
const contentContext = useSelectContentContext(VIEWPORT_NAME, __scopeSelect);
|
|
720
|
+
const viewportContext = useSelectViewportContext(VIEWPORT_NAME, __scopeSelect);
|
|
721
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, contentContext.onViewportChange);
|
|
722
|
+
const prevScrollTopRef = React.useRef(0);
|
|
723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
725
|
+
"style",
|
|
726
|
+
{
|
|
727
|
+
dangerouslySetInnerHTML: {
|
|
728
|
+
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
|
|
729
|
+
},
|
|
730
|
+
nonce
|
|
731
|
+
}
|
|
732
|
+
),
|
|
733
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Collection.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
734
|
+
import_react_primitive.Primitive.div,
|
|
735
|
+
{
|
|
736
|
+
"data-radix-select-viewport": "",
|
|
737
|
+
role: "presentation",
|
|
738
|
+
...viewportProps,
|
|
739
|
+
ref: composedRefs,
|
|
740
|
+
style: {
|
|
741
|
+
// we use position: 'relative' here on the `viewport` so that when we call
|
|
742
|
+
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
743
|
+
// (independent of the scrollUpButton).
|
|
744
|
+
position: "relative",
|
|
745
|
+
flex: 1,
|
|
746
|
+
overflow: "auto",
|
|
747
|
+
...viewportProps.style
|
|
748
|
+
},
|
|
749
|
+
onScroll: (0, import_primitive.composeEventHandlers)(viewportProps.onScroll, (event) => {
|
|
750
|
+
const viewport = event.currentTarget;
|
|
751
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
|
752
|
+
if (shouldExpandOnScrollRef?.current && contentWrapper) {
|
|
824
753
|
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
|
825
754
|
if (scrolledBy > 0) {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
}
|
|
755
|
+
const availableHeight = window.innerHeight - CONTENT_MARGIN * 2;
|
|
756
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
|
757
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
|
758
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
759
|
+
if (prevHeight < availableHeight) {
|
|
760
|
+
const nextHeight = prevHeight + scrolledBy;
|
|
761
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
762
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
|
763
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
|
764
|
+
if (contentWrapper.style.bottom === "0px") {
|
|
765
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
766
|
+
contentWrapper.style.justifyContent = "flex-end";
|
|
839
767
|
}
|
|
768
|
+
}
|
|
840
769
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
})
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const contentContext = $1345bda09ffc1bc6$var$useSelectContentContext($1345bda09ffc1bc6$var$ITEM_NAME, __scopeSelect);
|
|
892
|
-
const isSelected = context.value === value;
|
|
893
|
-
const [textValue, setTextValue] = $cg2C9$react.useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : '');
|
|
894
|
-
const [isFocused, setIsFocused] = $cg2C9$react.useState(false);
|
|
895
|
-
const composedRefs = $cg2C9$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>{
|
|
896
|
-
var _contentContext$itemR;
|
|
897
|
-
return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
|
|
898
|
-
});
|
|
899
|
-
const textId = $cg2C9$radixuireactid.useId();
|
|
900
|
-
const handleSelect = ()=>{
|
|
770
|
+
}
|
|
771
|
+
prevScrollTopRef.current = viewport.scrollTop;
|
|
772
|
+
})
|
|
773
|
+
}
|
|
774
|
+
) })
|
|
775
|
+
] });
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
SelectViewport.displayName = VIEWPORT_NAME;
|
|
779
|
+
var GROUP_NAME = "SelectGroup";
|
|
780
|
+
var [SelectGroupContextProvider, useSelectGroupContext] = createSelectContext(GROUP_NAME);
|
|
781
|
+
var SelectGroup = React.forwardRef(
|
|
782
|
+
(props, forwardedRef) => {
|
|
783
|
+
const { __scopeSelect, ...groupProps } = props;
|
|
784
|
+
const groupId = (0, import_react_id.useId)();
|
|
785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
|
|
786
|
+
}
|
|
787
|
+
);
|
|
788
|
+
SelectGroup.displayName = GROUP_NAME;
|
|
789
|
+
var LABEL_NAME = "SelectLabel";
|
|
790
|
+
var SelectLabel = React.forwardRef(
|
|
791
|
+
(props, forwardedRef) => {
|
|
792
|
+
const { __scopeSelect, ...labelProps } = props;
|
|
793
|
+
const groupContext = useSelectGroupContext(LABEL_NAME, __scopeSelect);
|
|
794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
|
|
795
|
+
}
|
|
796
|
+
);
|
|
797
|
+
SelectLabel.displayName = LABEL_NAME;
|
|
798
|
+
var ITEM_NAME = "SelectItem";
|
|
799
|
+
var [SelectItemContextProvider, useSelectItemContext] = createSelectContext(ITEM_NAME);
|
|
800
|
+
var SelectItem = React.forwardRef(
|
|
801
|
+
(props, forwardedRef) => {
|
|
802
|
+
const {
|
|
803
|
+
__scopeSelect,
|
|
804
|
+
value,
|
|
805
|
+
disabled = false,
|
|
806
|
+
textValue: textValueProp,
|
|
807
|
+
...itemProps
|
|
808
|
+
} = props;
|
|
809
|
+
const context = useSelectContext(ITEM_NAME, __scopeSelect);
|
|
810
|
+
const contentContext = useSelectContentContext(ITEM_NAME, __scopeSelect);
|
|
811
|
+
const isSelected = context.value === value;
|
|
812
|
+
const [textValue, setTextValue] = React.useState(textValueProp ?? "");
|
|
813
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
814
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(
|
|
815
|
+
forwardedRef,
|
|
816
|
+
(node) => contentContext.itemRefCallback?.(node, value, disabled)
|
|
817
|
+
);
|
|
818
|
+
const textId = (0, import_react_id.useId)();
|
|
819
|
+
const handleSelect = () => {
|
|
901
820
|
if (!disabled) {
|
|
902
|
-
|
|
903
|
-
|
|
821
|
+
context.onValueChange(value);
|
|
822
|
+
context.onOpenChange(false);
|
|
904
823
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
});
|
|
966
|
-
/*#__PURE__*/ Object.assign($1345bda09ffc1bc6$export$13ef48a934230896, {
|
|
967
|
-
displayName: $1345bda09ffc1bc6$var$ITEM_NAME
|
|
968
|
-
});
|
|
969
|
-
/* -------------------------------------------------------------------------------------------------
|
|
970
|
-
* SelectItemText
|
|
971
|
-
* -----------------------------------------------------------------------------------------------*/ const $1345bda09ffc1bc6$var$ITEM_TEXT_NAME = 'SelectItemText';
|
|
972
|
-
const $1345bda09ffc1bc6$export$3572fb0fb821ff49 = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
973
|
-
// We ignore `className` and `style` as this part shouldn't be styled.
|
|
974
|
-
const { __scopeSelect: __scopeSelect , className: className , style: style , ...itemTextProps } = props;
|
|
975
|
-
const context = $1345bda09ffc1bc6$var$useSelectContext($1345bda09ffc1bc6$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
976
|
-
const contentContext = $1345bda09ffc1bc6$var$useSelectContentContext($1345bda09ffc1bc6$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
977
|
-
const itemContext = $1345bda09ffc1bc6$var$useSelectItemContext($1345bda09ffc1bc6$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
978
|
-
const nativeOptionsContext = $1345bda09ffc1bc6$var$useSelectNativeOptionsContext($1345bda09ffc1bc6$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
979
|
-
const [itemTextNode, setItemTextNode] = $cg2C9$react.useState(null);
|
|
980
|
-
const composedRefs = $cg2C9$radixuireactcomposerefs.useComposedRefs(forwardedRef, (node)=>setItemTextNode(node)
|
|
981
|
-
, itemContext.onItemTextChange, (node)=>{
|
|
982
|
-
var _contentContext$itemT;
|
|
983
|
-
return (_contentContext$itemT = contentContext.itemTextRefCallback) === null || _contentContext$itemT === void 0 ? void 0 : _contentContext$itemT.call(contentContext, node, itemContext.value, itemContext.disabled);
|
|
984
|
-
});
|
|
985
|
-
const textContent = itemTextNode === null || itemTextNode === void 0 ? void 0 : itemTextNode.textContent;
|
|
986
|
-
const nativeOption = $cg2C9$react.useMemo(()=>/*#__PURE__*/ $cg2C9$react.createElement("option", {
|
|
987
|
-
key: itemContext.value,
|
|
988
|
-
value: itemContext.value,
|
|
989
|
-
disabled: itemContext.disabled
|
|
990
|
-
}, textContent)
|
|
991
|
-
, [
|
|
992
|
-
itemContext.disabled,
|
|
993
|
-
itemContext.value,
|
|
994
|
-
textContent
|
|
995
|
-
]);
|
|
996
|
-
const { onNativeOptionAdd: onNativeOptionAdd , onNativeOptionRemove: onNativeOptionRemove } = nativeOptionsContext;
|
|
997
|
-
$cg2C9$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
998
|
-
onNativeOptionAdd(nativeOption);
|
|
999
|
-
return ()=>onNativeOptionRemove(nativeOption)
|
|
1000
|
-
;
|
|
1001
|
-
}, [
|
|
1002
|
-
onNativeOptionAdd,
|
|
1003
|
-
onNativeOptionRemove,
|
|
1004
|
-
nativeOption
|
|
1005
|
-
]);
|
|
1006
|
-
return /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$react.Fragment, null, /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($cg2C9$babelruntimehelpersextends))({
|
|
1007
|
-
id: itemContext.textId
|
|
1008
|
-
}, itemTextProps, {
|
|
1009
|
-
ref: composedRefs
|
|
1010
|
-
})), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? /*#__PURE__*/ $cg2C9$reactdom.createPortal(itemTextProps.children, context.valueNode) : null);
|
|
1011
|
-
});
|
|
1012
|
-
/*#__PURE__*/ Object.assign($1345bda09ffc1bc6$export$3572fb0fb821ff49, {
|
|
1013
|
-
displayName: $1345bda09ffc1bc6$var$ITEM_TEXT_NAME
|
|
1014
|
-
});
|
|
1015
|
-
/* -------------------------------------------------------------------------------------------------
|
|
1016
|
-
* SelectItemIndicator
|
|
1017
|
-
* -----------------------------------------------------------------------------------------------*/ const $1345bda09ffc1bc6$var$ITEM_INDICATOR_NAME = 'SelectItemIndicator';
|
|
1018
|
-
const $1345bda09ffc1bc6$export$6b9198de19accfe6 = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
1019
|
-
const { __scopeSelect: __scopeSelect , ...itemIndicatorProps } = props;
|
|
1020
|
-
const itemContext = $1345bda09ffc1bc6$var$useSelectItemContext($1345bda09ffc1bc6$var$ITEM_INDICATOR_NAME, __scopeSelect);
|
|
1021
|
-
return itemContext.isSelected ? /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactprimitive.Primitive.span, ($parcel$interopDefault($cg2C9$babelruntimehelpersextends))({
|
|
1022
|
-
"aria-hidden": true
|
|
1023
|
-
}, itemIndicatorProps, {
|
|
1024
|
-
ref: forwardedRef
|
|
1025
|
-
})) : null;
|
|
1026
|
-
});
|
|
1027
|
-
/*#__PURE__*/ Object.assign($1345bda09ffc1bc6$export$6b9198de19accfe6, {
|
|
1028
|
-
displayName: $1345bda09ffc1bc6$var$ITEM_INDICATOR_NAME
|
|
1029
|
-
});
|
|
1030
|
-
/* -------------------------------------------------------------------------------------------------
|
|
1031
|
-
* SelectScrollUpButton
|
|
1032
|
-
* -----------------------------------------------------------------------------------------------*/ const $1345bda09ffc1bc6$var$SCROLL_UP_BUTTON_NAME = 'SelectScrollUpButton';
|
|
1033
|
-
const $1345bda09ffc1bc6$export$d8117927658af6d7 = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
1034
|
-
const contentContext = $1345bda09ffc1bc6$var$useSelectContentContext($1345bda09ffc1bc6$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
1035
|
-
const viewportContext = $1345bda09ffc1bc6$var$useSelectViewportContext($1345bda09ffc1bc6$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
1036
|
-
const [canScrollUp1, setCanScrollUp] = $cg2C9$react.useState(false);
|
|
1037
|
-
const composedRefs = $cg2C9$radixuireactcomposerefs.useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
1038
|
-
$cg2C9$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
1039
|
-
if (contentContext.viewport && contentContext.isPositioned) {
|
|
1040
|
-
const viewport = contentContext.viewport;
|
|
1041
|
-
function handleScroll() {
|
|
1042
|
-
const canScrollUp = viewport.scrollTop > 0;
|
|
1043
|
-
setCanScrollUp(canScrollUp);
|
|
824
|
+
};
|
|
825
|
+
if (value === "") {
|
|
826
|
+
throw new Error(
|
|
827
|
+
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
831
|
+
SelectItemContextProvider,
|
|
832
|
+
{
|
|
833
|
+
scope: __scopeSelect,
|
|
834
|
+
value,
|
|
835
|
+
disabled,
|
|
836
|
+
textId,
|
|
837
|
+
isSelected,
|
|
838
|
+
onItemTextChange: React.useCallback((node) => {
|
|
839
|
+
setTextValue((prevTextValue) => prevTextValue || (node?.textContent ?? "").trim());
|
|
840
|
+
}, []),
|
|
841
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
842
|
+
Collection.ItemSlot,
|
|
843
|
+
{
|
|
844
|
+
scope: __scopeSelect,
|
|
845
|
+
value,
|
|
846
|
+
disabled,
|
|
847
|
+
textValue,
|
|
848
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
849
|
+
import_react_primitive.Primitive.div,
|
|
850
|
+
{
|
|
851
|
+
role: "option",
|
|
852
|
+
"aria-labelledby": textId,
|
|
853
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
854
|
+
"aria-selected": isSelected && isFocused,
|
|
855
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
|
856
|
+
"aria-disabled": disabled || void 0,
|
|
857
|
+
"data-disabled": disabled ? "" : void 0,
|
|
858
|
+
tabIndex: disabled ? void 0 : -1,
|
|
859
|
+
...itemProps,
|
|
860
|
+
ref: composedRefs,
|
|
861
|
+
onFocus: (0, import_primitive.composeEventHandlers)(itemProps.onFocus, () => setIsFocused(true)),
|
|
862
|
+
onBlur: (0, import_primitive.composeEventHandlers)(itemProps.onBlur, () => setIsFocused(false)),
|
|
863
|
+
onPointerUp: (0, import_primitive.composeEventHandlers)(itemProps.onPointerUp, handleSelect),
|
|
864
|
+
onPointerMove: (0, import_primitive.composeEventHandlers)(itemProps.onPointerMove, (event) => {
|
|
865
|
+
if (disabled) {
|
|
866
|
+
contentContext.onItemLeave?.();
|
|
867
|
+
} else {
|
|
868
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
869
|
+
}
|
|
870
|
+
}),
|
|
871
|
+
onPointerLeave: (0, import_primitive.composeEventHandlers)(itemProps.onPointerLeave, (event) => {
|
|
872
|
+
if (event.currentTarget === document.activeElement) {
|
|
873
|
+
contentContext.onItemLeave?.();
|
|
874
|
+
}
|
|
875
|
+
}),
|
|
876
|
+
onKeyDown: (0, import_primitive.composeEventHandlers)(itemProps.onKeyDown, (event) => {
|
|
877
|
+
const isTypingAhead = contentContext.searchRef?.current !== "";
|
|
878
|
+
if (isTypingAhead && event.key === " ") return;
|
|
879
|
+
if (SELECTION_KEYS.includes(event.key)) handleSelect();
|
|
880
|
+
if (event.key === " ") event.preventDefault();
|
|
881
|
+
})
|
|
882
|
+
}
|
|
883
|
+
)
|
|
1044
884
|
}
|
|
1045
|
-
|
|
1046
|
-
viewport.addEventListener('scroll', handleScroll);
|
|
1047
|
-
return ()=>viewport.removeEventListener('scroll', handleScroll)
|
|
1048
|
-
;
|
|
885
|
+
)
|
|
1049
886
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
);
|
|
890
|
+
SelectItem.displayName = ITEM_NAME;
|
|
891
|
+
var ITEM_TEXT_NAME = "SelectItemText";
|
|
892
|
+
var SelectItemText = React.forwardRef(
|
|
893
|
+
(props, forwardedRef) => {
|
|
894
|
+
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
|
895
|
+
const context = useSelectContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
896
|
+
const contentContext = useSelectContentContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
897
|
+
const itemContext = useSelectItemContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
898
|
+
const nativeOptionsContext = useSelectNativeOptionsContext(ITEM_TEXT_NAME, __scopeSelect);
|
|
899
|
+
const [itemTextNode, setItemTextNode] = React.useState(null);
|
|
900
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(
|
|
901
|
+
forwardedRef,
|
|
902
|
+
(node) => setItemTextNode(node),
|
|
903
|
+
itemContext.onItemTextChange,
|
|
904
|
+
(node) => contentContext.itemTextRefCallback?.(node, itemContext.value, itemContext.disabled)
|
|
905
|
+
);
|
|
906
|
+
const textContent = itemTextNode?.textContent;
|
|
907
|
+
const nativeOption = React.useMemo(
|
|
908
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: itemContext.value, disabled: itemContext.disabled, children: textContent }, itemContext.value),
|
|
909
|
+
[itemContext.disabled, itemContext.value, textContent]
|
|
910
|
+
);
|
|
911
|
+
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
|
912
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
913
|
+
onNativeOptionAdd(nativeOption);
|
|
914
|
+
return () => onNativeOptionRemove(nativeOption);
|
|
915
|
+
}, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
|
|
916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
917
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
|
|
918
|
+
itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
|
|
919
|
+
] });
|
|
920
|
+
}
|
|
921
|
+
);
|
|
922
|
+
SelectItemText.displayName = ITEM_TEXT_NAME;
|
|
923
|
+
var ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
924
|
+
var SelectItemIndicator = React.forwardRef(
|
|
925
|
+
(props, forwardedRef) => {
|
|
926
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
927
|
+
const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME, __scopeSelect);
|
|
928
|
+
return itemContext.isSelected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
|
|
929
|
+
}
|
|
930
|
+
);
|
|
931
|
+
SelectItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
932
|
+
var SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
933
|
+
var SelectScrollUpButton = React.forwardRef((props, forwardedRef) => {
|
|
934
|
+
const contentContext = useSelectContentContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
935
|
+
const viewportContext = useSelectViewportContext(SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
936
|
+
const [canScrollUp, setCanScrollUp] = React.useState(false);
|
|
937
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, viewportContext.onScrollButtonChange);
|
|
938
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
939
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
940
|
+
let handleScroll2 = function() {
|
|
941
|
+
const canScrollUp2 = viewport.scrollTop > 0;
|
|
942
|
+
setCanScrollUp(canScrollUp2);
|
|
943
|
+
};
|
|
944
|
+
var handleScroll = handleScroll2;
|
|
945
|
+
const viewport = contentContext.viewport;
|
|
946
|
+
handleScroll2();
|
|
947
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
948
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
949
|
+
}
|
|
950
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
951
|
+
return canScrollUp ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
952
|
+
SelectScrollButtonImpl,
|
|
953
|
+
{
|
|
954
|
+
...props,
|
|
1055
955
|
ref: composedRefs,
|
|
1056
|
-
onAutoScroll: ()=>{
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
});
|
|
1062
|
-
/*#__PURE__*/ Object.assign($1345bda09ffc1bc6$export$d8117927658af6d7, {
|
|
1063
|
-
displayName: $1345bda09ffc1bc6$var$SCROLL_UP_BUTTON_NAME
|
|
1064
|
-
});
|
|
1065
|
-
/* -------------------------------------------------------------------------------------------------
|
|
1066
|
-
* SelectScrollDownButton
|
|
1067
|
-
* -----------------------------------------------------------------------------------------------*/ const $1345bda09ffc1bc6$var$SCROLL_DOWN_BUTTON_NAME = 'SelectScrollDownButton';
|
|
1068
|
-
const $1345bda09ffc1bc6$export$ff951e476c12189 = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
1069
|
-
const contentContext = $1345bda09ffc1bc6$var$useSelectContentContext($1345bda09ffc1bc6$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
1070
|
-
const viewportContext = $1345bda09ffc1bc6$var$useSelectViewportContext($1345bda09ffc1bc6$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
1071
|
-
const [canScrollDown1, setCanScrollDown] = $cg2C9$react.useState(false);
|
|
1072
|
-
const composedRefs = $cg2C9$radixuireactcomposerefs.useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
1073
|
-
$cg2C9$radixuireactuselayouteffect.useLayoutEffect(()=>{
|
|
1074
|
-
if (contentContext.viewport && contentContext.isPositioned) {
|
|
1075
|
-
const viewport = contentContext.viewport;
|
|
1076
|
-
function handleScroll() {
|
|
1077
|
-
const maxScroll = viewport.scrollHeight - viewport.clientHeight; // we use Math.ceil here because if the UI is zoomed-in
|
|
1078
|
-
// `scrollTop` is not always reported as an integer
|
|
1079
|
-
const canScrollDown = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
1080
|
-
setCanScrollDown(canScrollDown);
|
|
1081
|
-
}
|
|
1082
|
-
handleScroll();
|
|
1083
|
-
viewport.addEventListener('scroll', handleScroll);
|
|
1084
|
-
return ()=>viewport.removeEventListener('scroll', handleScroll)
|
|
1085
|
-
;
|
|
956
|
+
onAutoScroll: () => {
|
|
957
|
+
const { viewport, selectedItem } = contentContext;
|
|
958
|
+
if (viewport && selectedItem) {
|
|
959
|
+
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
|
960
|
+
}
|
|
1086
961
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
962
|
+
}
|
|
963
|
+
) : null;
|
|
964
|
+
});
|
|
965
|
+
SelectScrollUpButton.displayName = SCROLL_UP_BUTTON_NAME;
|
|
966
|
+
var SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
967
|
+
var SelectScrollDownButton = React.forwardRef((props, forwardedRef) => {
|
|
968
|
+
const contentContext = useSelectContentContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
969
|
+
const viewportContext = useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
970
|
+
const [canScrollDown, setCanScrollDown] = React.useState(false);
|
|
971
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, viewportContext.onScrollButtonChange);
|
|
972
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
973
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
974
|
+
let handleScroll2 = function() {
|
|
975
|
+
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
|
976
|
+
const canScrollDown2 = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
977
|
+
setCanScrollDown(canScrollDown2);
|
|
978
|
+
};
|
|
979
|
+
var handleScroll = handleScroll2;
|
|
980
|
+
const viewport = contentContext.viewport;
|
|
981
|
+
handleScroll2();
|
|
982
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
983
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
984
|
+
}
|
|
985
|
+
}, [contentContext.viewport, contentContext.isPositioned]);
|
|
986
|
+
return canScrollDown ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
987
|
+
SelectScrollButtonImpl,
|
|
988
|
+
{
|
|
989
|
+
...props,
|
|
1092
990
|
ref: composedRefs,
|
|
1093
|
-
onAutoScroll: ()=>{
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
});
|
|
1099
|
-
/*#__PURE__*/ Object.assign($1345bda09ffc1bc6$export$ff951e476c12189, {
|
|
1100
|
-
displayName: $1345bda09ffc1bc6$var$SCROLL_DOWN_BUTTON_NAME
|
|
1101
|
-
});
|
|
1102
|
-
const $1345bda09ffc1bc6$var$SelectScrollButtonImpl = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
1103
|
-
const { __scopeSelect: __scopeSelect , onAutoScroll: onAutoScroll , ...scrollIndicatorProps } = props;
|
|
1104
|
-
const contentContext = $1345bda09ffc1bc6$var$useSelectContentContext('SelectScrollButton', __scopeSelect);
|
|
1105
|
-
const autoScrollTimerRef = $cg2C9$react.useRef(null);
|
|
1106
|
-
const getItems = $1345bda09ffc1bc6$var$useCollection(__scopeSelect);
|
|
1107
|
-
const clearAutoScrollTimer = $cg2C9$react.useCallback(()=>{
|
|
1108
|
-
if (autoScrollTimerRef.current !== null) {
|
|
1109
|
-
window.clearInterval(autoScrollTimerRef.current);
|
|
1110
|
-
autoScrollTimerRef.current = null;
|
|
991
|
+
onAutoScroll: () => {
|
|
992
|
+
const { viewport, selectedItem } = contentContext;
|
|
993
|
+
if (viewport && selectedItem) {
|
|
994
|
+
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
995
|
+
}
|
|
1111
996
|
}
|
|
997
|
+
}
|
|
998
|
+
) : null;
|
|
999
|
+
});
|
|
1000
|
+
SelectScrollDownButton.displayName = SCROLL_DOWN_BUTTON_NAME;
|
|
1001
|
+
var SelectScrollButtonImpl = React.forwardRef((props, forwardedRef) => {
|
|
1002
|
+
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
|
1003
|
+
const contentContext = useSelectContentContext("SelectScrollButton", __scopeSelect);
|
|
1004
|
+
const autoScrollTimerRef = React.useRef(null);
|
|
1005
|
+
const getItems = useCollection(__scopeSelect);
|
|
1006
|
+
const clearAutoScrollTimer = React.useCallback(() => {
|
|
1007
|
+
if (autoScrollTimerRef.current !== null) {
|
|
1008
|
+
window.clearInterval(autoScrollTimerRef.current);
|
|
1009
|
+
autoScrollTimerRef.current = null;
|
|
1010
|
+
}
|
|
1112
1011
|
}, []);
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
);
|
|
1126
|
-
activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
|
|
1127
|
-
block: 'nearest'
|
|
1128
|
-
});
|
|
1129
|
-
}, [
|
|
1130
|
-
getItems
|
|
1131
|
-
]);
|
|
1132
|
-
return /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($cg2C9$babelruntimehelpersextends))({
|
|
1133
|
-
"aria-hidden": true
|
|
1134
|
-
}, scrollIndicatorProps, {
|
|
1012
|
+
React.useEffect(() => {
|
|
1013
|
+
return () => clearAutoScrollTimer();
|
|
1014
|
+
}, [clearAutoScrollTimer]);
|
|
1015
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
1016
|
+
const activeItem = getItems().find((item) => item.ref.current === document.activeElement);
|
|
1017
|
+
activeItem?.ref.current?.scrollIntoView({ block: "nearest" });
|
|
1018
|
+
}, [getItems]);
|
|
1019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1020
|
+
import_react_primitive.Primitive.div,
|
|
1021
|
+
{
|
|
1022
|
+
"aria-hidden": true,
|
|
1023
|
+
...scrollIndicatorProps,
|
|
1135
1024
|
ref: forwardedRef,
|
|
1136
|
-
style: {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
if (autoScrollTimerRef.current === null) autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1025
|
+
style: { flexShrink: 0, ...scrollIndicatorProps.style },
|
|
1026
|
+
onPointerDown: (0, import_primitive.composeEventHandlers)(scrollIndicatorProps.onPointerDown, () => {
|
|
1027
|
+
if (autoScrollTimerRef.current === null) {
|
|
1028
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1029
|
+
}
|
|
1142
1030
|
}),
|
|
1143
|
-
onPointerMove:
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1031
|
+
onPointerMove: (0, import_primitive.composeEventHandlers)(scrollIndicatorProps.onPointerMove, () => {
|
|
1032
|
+
contentContext.onItemLeave?.();
|
|
1033
|
+
if (autoScrollTimerRef.current === null) {
|
|
1034
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
1035
|
+
}
|
|
1147
1036
|
}),
|
|
1148
|
-
onPointerLeave:
|
|
1149
|
-
|
|
1037
|
+
onPointerLeave: (0, import_primitive.composeEventHandlers)(scrollIndicatorProps.onPointerLeave, () => {
|
|
1038
|
+
clearAutoScrollTimer();
|
|
1150
1039
|
})
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
return value === '' || value === undefined;
|
|
1184
|
-
}
|
|
1185
|
-
const $1345bda09ffc1bc6$var$BubbleSelect = /*#__PURE__*/ $cg2C9$react.forwardRef((props, forwardedRef)=>{
|
|
1186
|
-
const { value: value , ...selectProps } = props;
|
|
1187
|
-
const ref = $cg2C9$react.useRef(null);
|
|
1188
|
-
const composedRefs = $cg2C9$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
|
|
1189
|
-
const prevValue = $cg2C9$radixuireactuseprevious.usePrevious(value); // Bubble value change to parents (e.g form change event)
|
|
1190
|
-
$cg2C9$react.useEffect(()=>{
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
});
|
|
1043
|
+
var SEPARATOR_NAME = "SelectSeparator";
|
|
1044
|
+
var SelectSeparator = React.forwardRef(
|
|
1045
|
+
(props, forwardedRef) => {
|
|
1046
|
+
const { __scopeSelect, ...separatorProps } = props;
|
|
1047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
|
|
1048
|
+
}
|
|
1049
|
+
);
|
|
1050
|
+
SelectSeparator.displayName = SEPARATOR_NAME;
|
|
1051
|
+
var ARROW_NAME = "SelectArrow";
|
|
1052
|
+
var SelectArrow = React.forwardRef(
|
|
1053
|
+
(props, forwardedRef) => {
|
|
1054
|
+
const { __scopeSelect, ...arrowProps } = props;
|
|
1055
|
+
const popperScope = usePopperScope(__scopeSelect);
|
|
1056
|
+
const context = useSelectContext(ARROW_NAME, __scopeSelect);
|
|
1057
|
+
const contentContext = useSelectContentContext(ARROW_NAME, __scopeSelect);
|
|
1058
|
+
return context.open && contentContext.position === "popper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef }) : null;
|
|
1059
|
+
}
|
|
1060
|
+
);
|
|
1061
|
+
SelectArrow.displayName = ARROW_NAME;
|
|
1062
|
+
function shouldShowPlaceholder(value) {
|
|
1063
|
+
return value === "" || value === void 0;
|
|
1064
|
+
}
|
|
1065
|
+
var BubbleSelect = React.forwardRef(
|
|
1066
|
+
(props, forwardedRef) => {
|
|
1067
|
+
const { value, ...selectProps } = props;
|
|
1068
|
+
const ref = React.useRef(null);
|
|
1069
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
1070
|
+
const prevValue = (0, import_react_use_previous.usePrevious)(value);
|
|
1071
|
+
React.useEffect(() => {
|
|
1191
1072
|
const select = ref.current;
|
|
1192
1073
|
const selectProto = window.HTMLSelectElement.prototype;
|
|
1193
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1074
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1075
|
+
selectProto,
|
|
1076
|
+
"value"
|
|
1077
|
+
);
|
|
1194
1078
|
const setValue = descriptor.set;
|
|
1195
1079
|
if (prevValue !== value && setValue) {
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
setValue.call(select, value);
|
|
1200
|
-
select.dispatchEvent(event);
|
|
1080
|
+
const event = new Event("change", { bubbles: true });
|
|
1081
|
+
setValue.call(select, value);
|
|
1082
|
+
select.dispatchEvent(event);
|
|
1201
1083
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
* dispatch a duplicate and it will get swallowed.
|
|
1214
|
-
*
|
|
1215
|
-
* We use `VisuallyHidden` rather than `display: "none"` because Safari autofill
|
|
1216
|
-
* won't work otherwise.
|
|
1217
|
-
*/ return /*#__PURE__*/ $cg2C9$react.createElement($cg2C9$radixuireactvisuallyhidden.VisuallyHidden, {
|
|
1218
|
-
asChild: true
|
|
1219
|
-
}, /*#__PURE__*/ $cg2C9$react.createElement("select", ($parcel$interopDefault($cg2C9$babelruntimehelpersextends))({}, selectProps, {
|
|
1220
|
-
ref: composedRefs,
|
|
1221
|
-
defaultValue: value
|
|
1222
|
-
})));
|
|
1223
|
-
});
|
|
1224
|
-
$1345bda09ffc1bc6$var$BubbleSelect.displayName = 'BubbleSelect';
|
|
1225
|
-
function $1345bda09ffc1bc6$var$useTypeaheadSearch(onSearchChange) {
|
|
1226
|
-
const handleSearchChange = $cg2C9$radixuireactusecallbackref.useCallbackRef(onSearchChange);
|
|
1227
|
-
const searchRef = $cg2C9$react.useRef('');
|
|
1228
|
-
const timerRef = $cg2C9$react.useRef(0);
|
|
1229
|
-
const handleTypeaheadSearch = $cg2C9$react.useCallback((key)=>{
|
|
1084
|
+
}, [prevValue, value]);
|
|
1085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_visually_hidden.VisuallyHidden, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ...selectProps, ref: composedRefs, defaultValue: value }) });
|
|
1086
|
+
}
|
|
1087
|
+
);
|
|
1088
|
+
BubbleSelect.displayName = "BubbleSelect";
|
|
1089
|
+
function useTypeaheadSearch(onSearchChange) {
|
|
1090
|
+
const handleSearchChange = (0, import_react_use_callback_ref.useCallbackRef)(onSearchChange);
|
|
1091
|
+
const searchRef = React.useRef("");
|
|
1092
|
+
const timerRef = React.useRef(0);
|
|
1093
|
+
const handleTypeaheadSearch = React.useCallback(
|
|
1094
|
+
(key) => {
|
|
1230
1095
|
const search = searchRef.current + key;
|
|
1231
1096
|
handleSearchChange(search);
|
|
1232
1097
|
(function updateSearch(value) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
, 1000);
|
|
1098
|
+
searchRef.current = value;
|
|
1099
|
+
window.clearTimeout(timerRef.current);
|
|
1100
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
1237
1101
|
})(search);
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
const resetTypeahead =
|
|
1242
|
-
|
|
1243
|
-
|
|
1102
|
+
},
|
|
1103
|
+
[handleSearchChange]
|
|
1104
|
+
);
|
|
1105
|
+
const resetTypeahead = React.useCallback(() => {
|
|
1106
|
+
searchRef.current = "";
|
|
1107
|
+
window.clearTimeout(timerRef.current);
|
|
1244
1108
|
}, []);
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
;
|
|
1109
|
+
React.useEffect(() => {
|
|
1110
|
+
return () => window.clearTimeout(timerRef.current);
|
|
1248
1111
|
}, []);
|
|
1249
|
-
return [
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
];
|
|
1254
|
-
}
|
|
1255
|
-
/**
|
|
1256
|
-
* This is the "meat" of the typeahead matching logic. It takes in a list of items,
|
|
1257
|
-
* the search and the current item, and returns the next item (or `undefined`).
|
|
1258
|
-
*
|
|
1259
|
-
* We normalize the search because if a user has repeatedly pressed a character,
|
|
1260
|
-
* we want the exact same behavior as if we only had that one character
|
|
1261
|
-
* (ie. cycle through items starting with that character)
|
|
1262
|
-
*
|
|
1263
|
-
* We also reorder the items by wrapping the array around the current item.
|
|
1264
|
-
* This is so we always look forward from the current item, and picking the first
|
|
1265
|
-
* item will always be the correct one.
|
|
1266
|
-
*
|
|
1267
|
-
* Finally, if the normalized search is exactly one character, we exclude the
|
|
1268
|
-
* current item from the values because otherwise it would be the first to match always
|
|
1269
|
-
* and focus would never move. This is as opposed to the regular case, where we
|
|
1270
|
-
* don't want focus to move if the current item still matches.
|
|
1271
|
-
*/ function $1345bda09ffc1bc6$var$findNextItem(items, search, currentItem) {
|
|
1272
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char)=>char === search[0]
|
|
1273
|
-
);
|
|
1112
|
+
return [searchRef, handleTypeaheadSearch, resetTypeahead];
|
|
1113
|
+
}
|
|
1114
|
+
function findNextItem(items, search, currentItem) {
|
|
1115
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
1274
1116
|
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1275
1117
|
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
1276
|
-
let wrappedItems =
|
|
1118
|
+
let wrappedItems = wrapArray(items, Math.max(currentItemIndex, 0));
|
|
1277
1119
|
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
1278
|
-
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v)=>v !== currentItem
|
|
1279
|
-
|
|
1280
|
-
|
|
1120
|
+
if (excludeCurrentItem) wrappedItems = wrappedItems.filter((v) => v !== currentItem);
|
|
1121
|
+
const nextItem = wrappedItems.find(
|
|
1122
|
+
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1281
1123
|
);
|
|
1282
|
-
return nextItem !== currentItem ? nextItem :
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
const $1345bda09ffc1bc6$export$bf1aedc3039c8d63 = $1345bda09ffc1bc6$export$ff951e476c12189;
|
|
1305
|
-
const $1345bda09ffc1bc6$export$1ff3c3f08ae963c0 = $1345bda09ffc1bc6$export$eba4b1df07cb1d3;
|
|
1306
|
-
const $1345bda09ffc1bc6$export$21b07c8f274aebd5 = $1345bda09ffc1bc6$export$314f4cb8f8099628;
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1124
|
+
return nextItem !== currentItem ? nextItem : void 0;
|
|
1125
|
+
}
|
|
1126
|
+
function wrapArray(array, startIndex) {
|
|
1127
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
1128
|
+
}
|
|
1129
|
+
var Root2 = Select;
|
|
1130
|
+
var Trigger = SelectTrigger;
|
|
1131
|
+
var Value = SelectValue;
|
|
1132
|
+
var Icon = SelectIcon;
|
|
1133
|
+
var Portal = SelectPortal;
|
|
1134
|
+
var Content2 = SelectContent;
|
|
1135
|
+
var Viewport = SelectViewport;
|
|
1136
|
+
var Group = SelectGroup;
|
|
1137
|
+
var Label = SelectLabel;
|
|
1138
|
+
var Item = SelectItem;
|
|
1139
|
+
var ItemText = SelectItemText;
|
|
1140
|
+
var ItemIndicator = SelectItemIndicator;
|
|
1141
|
+
var ScrollUpButton = SelectScrollUpButton;
|
|
1142
|
+
var ScrollDownButton = SelectScrollDownButton;
|
|
1143
|
+
var Separator = SelectSeparator;
|
|
1144
|
+
var Arrow2 = SelectArrow;
|
|
1145
|
+
})();
|
|
1311
1146
|
//# sourceMappingURL=index.js.map
|