@opentiny/tiny-robot 0.5.2-alpha.10 → 0.5.2-alpha.14
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/dropdown-menu/index.js +1 -1
- package/dist/extension-manager/index.js +473 -0
- package/dist/floating-ui.dom.js +970 -0
- package/dist/index.d.ts +554 -141
- package/dist/index.js +104 -93
- package/dist/index4.js +2 -2
- package/dist/index6.js +1 -1
- package/dist/index8.js +87 -102
- package/dist/layout/index.js +1 -1
- package/dist/model-selector/index.js +989 -0
- package/dist/sender/index.js +1127 -2060
- package/dist/style.css +1 -1
- package/dist/suggestion-pills/index.js +1 -1
- package/dist/suggestion-popover/index.js +37 -36
- package/dist/useSlotRefs.js +1 -1
- package/dist/useTeleportTarget.js +25 -0
- package/dist/utils.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
import { shallowRef as C, computed as p, watch as j, nextTick as Y, defineComponent as Q, openBlock as g, createElementBlock as w, createElementVNode as I, toDisplayString as K, Fragment as ae, renderList as re, normalizeClass as H, withModifiers as pe, renderSlot as T, createBlock as N, resolveDynamicComponent as se, createCommentVNode as D, unref as P, createSlots as _, withCtx as q, mergeProps as ue, onMounted as de, normalizeProps as F, guardReactiveProps as A, createVNode as U, onScopeDispose as ye, toRaw as be, getCurrentInstance as we, Teleport as ke } from "vue";
|
|
2
|
+
import { IconCheck as $e, IconSearch as Ee, IconNoData as Oe, IconArrowDown as Se } from "@opentiny/tiny-robot-svgs";
|
|
3
|
+
import { a as xe, c as Pe, o as Ve, f as Me, s as Te, b as Ce } from "../floating-ui.dom.js";
|
|
4
|
+
import { u as De } from "../useTeleportTarget.js";
|
|
5
|
+
function Ie(e) {
|
|
6
|
+
const a = C(""), n = p(() => a.value.trim()), t = p(() => {
|
|
7
|
+
const m = e.options(), r = n.value;
|
|
8
|
+
if (!e.searchable() || !r)
|
|
9
|
+
return m;
|
|
10
|
+
const s = e.filterMethod();
|
|
11
|
+
if (s)
|
|
12
|
+
return m.filter((v) => s(r, v.raw));
|
|
13
|
+
const c = r.toLocaleLowerCase();
|
|
14
|
+
return m.filter((v) => v.searchText.includes(c));
|
|
15
|
+
}), u = p(() => {
|
|
16
|
+
const m = /* @__PURE__ */ new Map();
|
|
17
|
+
return t.value.forEach((r) => {
|
|
18
|
+
var c, v;
|
|
19
|
+
const s = m.get(r.groupKey);
|
|
20
|
+
if (s) {
|
|
21
|
+
s.items.push(r);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
m.set(r.groupKey, {
|
|
25
|
+
key: r.groupKey,
|
|
26
|
+
index: m.size,
|
|
27
|
+
group: ((c = r.raw.group) == null ? void 0 : c.trim()) ?? "",
|
|
28
|
+
label: ((v = r.raw.group) == null ? void 0 : v.trim()) ?? "",
|
|
29
|
+
items: [r]
|
|
30
|
+
});
|
|
31
|
+
}), [...m.values()];
|
|
32
|
+
}), f = p(() => t.value.length === 0);
|
|
33
|
+
function i(m) {
|
|
34
|
+
a.value = m;
|
|
35
|
+
}
|
|
36
|
+
function d() {
|
|
37
|
+
a.value = "";
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
query: a,
|
|
41
|
+
visibleOptions: t,
|
|
42
|
+
groups: u,
|
|
43
|
+
isEmpty: f,
|
|
44
|
+
setQuery: i,
|
|
45
|
+
clearQuery: d
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function ze(e) {
|
|
49
|
+
const a = C(null), n = p(() => e.options().find((r) => r.key === a.value) ?? null);
|
|
50
|
+
function t() {
|
|
51
|
+
return e.options().filter((r) => !r.disabled);
|
|
52
|
+
}
|
|
53
|
+
function u(r) {
|
|
54
|
+
if (r === null) {
|
|
55
|
+
a.value = null;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const s = e.options().find((c) => c.key === r);
|
|
59
|
+
s && !s.disabled && (a.value = s.key);
|
|
60
|
+
}
|
|
61
|
+
function f() {
|
|
62
|
+
a.value = null;
|
|
63
|
+
}
|
|
64
|
+
function i(r) {
|
|
65
|
+
const s = t(), c = r === "first" ? s[0] : s[s.length - 1];
|
|
66
|
+
a.value = (c == null ? void 0 : c.key) ?? null;
|
|
67
|
+
}
|
|
68
|
+
function d(r = "first") {
|
|
69
|
+
const s = e.selectedValue(), c = e.options().find((v) => v.value === s && !v.disabled);
|
|
70
|
+
if (c) {
|
|
71
|
+
a.value = c.key;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
i(r);
|
|
75
|
+
}
|
|
76
|
+
function m(r) {
|
|
77
|
+
var y, E;
|
|
78
|
+
const s = t();
|
|
79
|
+
if (s.length === 0) {
|
|
80
|
+
f();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const c = s.findIndex(($) => $.key === a.value);
|
|
84
|
+
if (c < 0) {
|
|
85
|
+
const $ = r === 1 ? 0 : s.length - 1;
|
|
86
|
+
a.value = ((y = s[$]) == null ? void 0 : y.key) ?? null;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const v = (c + r + s.length) % s.length;
|
|
90
|
+
a.value = ((E = s[v]) == null ? void 0 : E.key) ?? null;
|
|
91
|
+
}
|
|
92
|
+
return j(
|
|
93
|
+
() => [e.enabled(), e.options(), e.selectedValue()],
|
|
94
|
+
([r, s, c], v) => {
|
|
95
|
+
if (!r) {
|
|
96
|
+
f();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const y = v == null ? void 0 : v[2], E = s.find((O) => O.value === c && !O.disabled);
|
|
100
|
+
if (c !== y && E) {
|
|
101
|
+
a.value = E.key;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
(a.value ? s.some((O) => O.key === a.value && !O.disabled) : !1) || d("first");
|
|
105
|
+
},
|
|
106
|
+
{ immediate: !0 }
|
|
107
|
+
), j(a, async (r) => {
|
|
108
|
+
if (!r || !e.enabled())
|
|
109
|
+
return;
|
|
110
|
+
await Y();
|
|
111
|
+
const s = e.containerEl.value, c = Array.from(
|
|
112
|
+
(s == null ? void 0 : s.querySelectorAll("[data-model-selector-option-key]")) ?? []
|
|
113
|
+
).find((v) => v.dataset.modelSelectorOptionKey === r);
|
|
114
|
+
c == null || c.scrollIntoView({ block: "nearest" });
|
|
115
|
+
}), {
|
|
116
|
+
highlightedKey: a,
|
|
117
|
+
highlightedOption: n,
|
|
118
|
+
setHighlightedKey: u,
|
|
119
|
+
resetHighlight: f,
|
|
120
|
+
highlightBoundary: i,
|
|
121
|
+
highlightSelectedOrBoundary: d,
|
|
122
|
+
moveHighlight: m
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const Be = { class: "tr-model-selector__effort" }, Le = { class: "tr-model-selector__effort-label" }, Ke = ["aria-label"], Re = ["disabled", "aria-pressed", "data-model-selector-effort-value", "onClick"], qe = /* @__PURE__ */ Q({
|
|
126
|
+
name: "TrModelSelectorEffort",
|
|
127
|
+
__name: "ModelSelectorEffort",
|
|
128
|
+
props: {
|
|
129
|
+
options: {},
|
|
130
|
+
value: {},
|
|
131
|
+
label: {},
|
|
132
|
+
disabled: { type: Boolean }
|
|
133
|
+
},
|
|
134
|
+
emits: ["select"],
|
|
135
|
+
setup(e) {
|
|
136
|
+
return (a, n) => (g(), w("div", Be, [
|
|
137
|
+
I("span", Le, K(e.label), 1),
|
|
138
|
+
I("div", {
|
|
139
|
+
class: "tr-model-selector__effort-options",
|
|
140
|
+
role: "group",
|
|
141
|
+
"aria-label": e.label
|
|
142
|
+
}, [
|
|
143
|
+
(g(!0), w(ae, null, re(e.options, (t) => (g(), w("button", {
|
|
144
|
+
key: t.value,
|
|
145
|
+
type: "button",
|
|
146
|
+
class: H(["tr-model-selector__effort-option", { "is-active": t.value === e.value }]),
|
|
147
|
+
disabled: e.disabled || t.disabled,
|
|
148
|
+
"aria-pressed": t.value === e.value,
|
|
149
|
+
"data-model-selector-effort-value": t.value,
|
|
150
|
+
onClick: (u) => a.$emit("select", t.value)
|
|
151
|
+
}, K(t.label), 11, Re))), 128))
|
|
152
|
+
], 8, Ke)
|
|
153
|
+
]));
|
|
154
|
+
}
|
|
155
|
+
}), Fe = ["id", "data-model-selector-option-key", "aria-selected", "aria-disabled", "aria-describedby"], Ae = { class: "tr-model-selector__option-main" }, He = ["src"], Ue = { class: "tr-model-selector__option-copy" }, je = ["title"], Ne = ["id", "title"], Qe = /* @__PURE__ */ Q({
|
|
156
|
+
name: "TrModelSelectorItem",
|
|
157
|
+
__name: "ModelSelectorItem",
|
|
158
|
+
props: {
|
|
159
|
+
option: {},
|
|
160
|
+
selected: { type: Boolean },
|
|
161
|
+
highlighted: { type: Boolean },
|
|
162
|
+
optionId: {},
|
|
163
|
+
descriptionId: {}
|
|
164
|
+
},
|
|
165
|
+
emits: ["hover", "select"],
|
|
166
|
+
setup(e, { emit: a }) {
|
|
167
|
+
const n = e, t = a;
|
|
168
|
+
function u() {
|
|
169
|
+
n.option.disabled || t("hover", n.option.key);
|
|
170
|
+
}
|
|
171
|
+
function f() {
|
|
172
|
+
n.option.disabled || t("select", n.option.raw);
|
|
173
|
+
}
|
|
174
|
+
return (i, d) => (g(), w("div", {
|
|
175
|
+
id: e.optionId,
|
|
176
|
+
class: H(["tr-model-selector__option", {
|
|
177
|
+
"is-selected": e.selected,
|
|
178
|
+
"is-highlighted": e.highlighted,
|
|
179
|
+
"is-disabled": e.option.disabled
|
|
180
|
+
}]),
|
|
181
|
+
"data-model-selector-option-key": e.option.key,
|
|
182
|
+
role: "option",
|
|
183
|
+
"aria-selected": e.selected,
|
|
184
|
+
"aria-disabled": e.option.disabled || void 0,
|
|
185
|
+
"aria-describedby": e.option.description && !i.$slots.item ? e.descriptionId : void 0,
|
|
186
|
+
onMouseenter: u,
|
|
187
|
+
onMousedown: d[0] || (d[0] = pe(() => {
|
|
188
|
+
}, ["prevent"])),
|
|
189
|
+
onClick: f
|
|
190
|
+
}, [
|
|
191
|
+
T(i.$slots, "item", {
|
|
192
|
+
option: e.option.raw,
|
|
193
|
+
selected: e.selected,
|
|
194
|
+
highlighted: e.highlighted
|
|
195
|
+
}, () => [
|
|
196
|
+
I("span", Ae, [
|
|
197
|
+
typeof e.option.icon == "string" ? (g(), w("img", {
|
|
198
|
+
key: 0,
|
|
199
|
+
src: e.option.icon,
|
|
200
|
+
class: "tr-model-selector__option-icon",
|
|
201
|
+
alt: "",
|
|
202
|
+
"aria-hidden": "true"
|
|
203
|
+
}, null, 8, He)) : e.option.icon ? (g(), N(se(e.option.icon), {
|
|
204
|
+
key: 1,
|
|
205
|
+
class: "tr-model-selector__option-icon",
|
|
206
|
+
"aria-hidden": "true",
|
|
207
|
+
focusable: "false"
|
|
208
|
+
})) : D("", !0),
|
|
209
|
+
I("span", Ue, [
|
|
210
|
+
I("span", {
|
|
211
|
+
class: "tr-model-selector__option-label",
|
|
212
|
+
title: e.option.label
|
|
213
|
+
}, K(e.option.label), 9, je),
|
|
214
|
+
e.option.description ? (g(), w("span", {
|
|
215
|
+
key: 0,
|
|
216
|
+
id: e.descriptionId,
|
|
217
|
+
class: "tr-model-selector__option-description",
|
|
218
|
+
title: e.option.description
|
|
219
|
+
}, K(e.option.description), 9, Ne)) : D("", !0)
|
|
220
|
+
])
|
|
221
|
+
]),
|
|
222
|
+
e.selected ? (g(), N(P($e), {
|
|
223
|
+
key: 0,
|
|
224
|
+
class: "tr-model-selector__option-check",
|
|
225
|
+
"aria-hidden": "true",
|
|
226
|
+
focusable: "false"
|
|
227
|
+
})) : D("", !0)
|
|
228
|
+
])
|
|
229
|
+
], 42, Fe));
|
|
230
|
+
}
|
|
231
|
+
}), We = ["role", "aria-labelledby"], Ge = ["id"], Ye = /* @__PURE__ */ Q({
|
|
232
|
+
name: "TrModelSelectorGroup",
|
|
233
|
+
__name: "ModelSelectorGroup",
|
|
234
|
+
props: {
|
|
235
|
+
group: {},
|
|
236
|
+
selectedValue: {},
|
|
237
|
+
highlightedKey: {},
|
|
238
|
+
optionIdPrefix: {}
|
|
239
|
+
},
|
|
240
|
+
emits: ["hover", "select"],
|
|
241
|
+
setup(e) {
|
|
242
|
+
return (a, n) => (g(), w("div", {
|
|
243
|
+
class: "tr-model-selector__group",
|
|
244
|
+
role: e.group.label ? "group" : "presentation",
|
|
245
|
+
"aria-labelledby": e.group.label ? `${e.optionIdPrefix}-group-${e.group.index}` : void 0
|
|
246
|
+
}, [
|
|
247
|
+
e.group.label ? (g(), w("div", {
|
|
248
|
+
key: 0,
|
|
249
|
+
id: `${e.optionIdPrefix}-group-${e.group.index}`,
|
|
250
|
+
class: "tr-model-selector__group-title"
|
|
251
|
+
}, K(e.group.label), 9, Ge)) : D("", !0),
|
|
252
|
+
(g(!0), w(ae, null, re(e.group.items, (t) => (g(), N(Qe, {
|
|
253
|
+
key: t.key,
|
|
254
|
+
option: t,
|
|
255
|
+
selected: e.selectedValue === t.value,
|
|
256
|
+
highlighted: e.highlightedKey === t.key,
|
|
257
|
+
"option-id": `${e.optionIdPrefix}-option-${t.index}`,
|
|
258
|
+
"description-id": `${e.optionIdPrefix}-option-${t.index}-description`,
|
|
259
|
+
onHover: n[0] || (n[0] = (u) => a.$emit("hover", u)),
|
|
260
|
+
onSelect: n[1] || (n[1] = (u) => a.$emit("select", u))
|
|
261
|
+
}, _({ _: 2 }, [
|
|
262
|
+
a.$slots.item ? {
|
|
263
|
+
name: "item",
|
|
264
|
+
fn: q((u) => [
|
|
265
|
+
T(a.$slots, "item", ue({ ref_for: !0 }, u))
|
|
266
|
+
]),
|
|
267
|
+
key: "0"
|
|
268
|
+
} : void 0
|
|
269
|
+
]), 1032, ["option", "selected", "highlighted", "option-id", "description-id"]))), 128))
|
|
270
|
+
], 8, We));
|
|
271
|
+
}
|
|
272
|
+
}), Je = {
|
|
273
|
+
key: 0,
|
|
274
|
+
class: "tr-model-selector__header"
|
|
275
|
+
}, Xe = {
|
|
276
|
+
key: 1,
|
|
277
|
+
class: "tr-model-selector__search"
|
|
278
|
+
}, Ze = ["value", "placeholder", "aria-label", "aria-controls", "aria-activedescendant"], _e = {
|
|
279
|
+
key: 2,
|
|
280
|
+
class: "tr-model-selector__empty",
|
|
281
|
+
role: "status",
|
|
282
|
+
"aria-live": "polite"
|
|
283
|
+
}, et = ["id", "aria-label", "aria-activedescendant"], tt = {
|
|
284
|
+
key: 3,
|
|
285
|
+
class: "tr-model-selector__footer"
|
|
286
|
+
}, lt = /* @__PURE__ */ Q({
|
|
287
|
+
name: "TrModelSelectorPanel",
|
|
288
|
+
__name: "ModelSelectorPanel",
|
|
289
|
+
props: {
|
|
290
|
+
options: {},
|
|
291
|
+
selectedValue: {},
|
|
292
|
+
searchable: { type: Boolean },
|
|
293
|
+
filterMethod: { type: Function },
|
|
294
|
+
listboxId: {},
|
|
295
|
+
optionIdPrefix: {},
|
|
296
|
+
placeholder: {},
|
|
297
|
+
searchPlaceholder: {},
|
|
298
|
+
emptyText: {},
|
|
299
|
+
effortOptions: {},
|
|
300
|
+
effortValue: {},
|
|
301
|
+
effortLabel: {},
|
|
302
|
+
effortDisabled: { type: Boolean },
|
|
303
|
+
size: {},
|
|
304
|
+
panelClass: {},
|
|
305
|
+
slotContext: {}
|
|
306
|
+
},
|
|
307
|
+
emits: ["select", "select-effort", "close"],
|
|
308
|
+
setup(e, { emit: a }) {
|
|
309
|
+
const n = e, t = a, u = C(null), f = C(null), i = Ie({
|
|
310
|
+
options: () => n.options,
|
|
311
|
+
searchable: () => n.searchable,
|
|
312
|
+
filterMethod: () => n.filterMethod
|
|
313
|
+
}), d = ze({
|
|
314
|
+
enabled: () => !0,
|
|
315
|
+
options: () => i.visibleOptions.value,
|
|
316
|
+
selectedValue: () => n.selectedValue,
|
|
317
|
+
containerEl: f
|
|
318
|
+
}), m = p(() => {
|
|
319
|
+
const o = d.highlightedOption.value;
|
|
320
|
+
return o ? `${n.optionIdPrefix}-option-${o.index}` : void 0;
|
|
321
|
+
}), r = p(() => ({
|
|
322
|
+
...n.slotContext,
|
|
323
|
+
query: i.query.value
|
|
324
|
+
})), s = p(() => ({
|
|
325
|
+
...r.value,
|
|
326
|
+
reasoningEfforts: n.effortOptions,
|
|
327
|
+
reasoningEffortOption: n.effortOptions.find((o) => o.value === n.effortValue) ?? null,
|
|
328
|
+
setReasoningEffort: (o) => t("select-effort", o)
|
|
329
|
+
}));
|
|
330
|
+
function c(o) {
|
|
331
|
+
i.setQuery(o.target.value);
|
|
332
|
+
}
|
|
333
|
+
function v() {
|
|
334
|
+
const o = n.searchable ? u.value : f.value;
|
|
335
|
+
o == null || o.focus({ preventScroll: !0 });
|
|
336
|
+
}
|
|
337
|
+
async function y() {
|
|
338
|
+
var b, S;
|
|
339
|
+
await Y();
|
|
340
|
+
const o = ((b = u.value) == null ? void 0 : b.ownerDocument.defaultView) ?? ((S = f.value) == null ? void 0 : S.ownerDocument.defaultView);
|
|
341
|
+
if (!o || typeof o.requestAnimationFrame != "function") {
|
|
342
|
+
v();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
o.requestAnimationFrame(() => {
|
|
346
|
+
v();
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function E() {
|
|
350
|
+
const o = d.highlightedOption.value;
|
|
351
|
+
o && t("select", o.raw);
|
|
352
|
+
}
|
|
353
|
+
function $(o) {
|
|
354
|
+
return o.isComposing || o.keyCode === 229;
|
|
355
|
+
}
|
|
356
|
+
function O(o) {
|
|
357
|
+
if (!(o.defaultPrevented || $(o))) {
|
|
358
|
+
if (o.key === "ArrowDown" || o.key === "ArrowUp") {
|
|
359
|
+
o.preventDefault(), d.moveHighlight(o.key === "ArrowDown" ? 1 : -1);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (o.key === "Enter") {
|
|
363
|
+
o.preventDefault(), E();
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
o.key === "Escape" && (o.preventDefault(), t("close", !0));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function x(o) {
|
|
370
|
+
if (!(o.defaultPrevented || $(o))) {
|
|
371
|
+
if (o.key === "ArrowDown" || o.key === "ArrowUp") {
|
|
372
|
+
o.preventDefault(), d.moveHighlight(o.key === "ArrowDown" ? 1 : -1);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (o.key === "Home" || o.key === "End") {
|
|
376
|
+
o.preventDefault(), d.highlightBoundary(o.key === "Home" ? "first" : "last");
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
(o.key === "Enter" || o.key === " " || o.key === "Spacebar") && (o.preventDefault(), E());
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function B(o) {
|
|
383
|
+
o.defaultPrevented || o.key === "Escape" && (o.preventDefault(), t("close", !0));
|
|
384
|
+
}
|
|
385
|
+
return de(() => {
|
|
386
|
+
y();
|
|
387
|
+
}), j(
|
|
388
|
+
() => n.searchable,
|
|
389
|
+
async () => {
|
|
390
|
+
i.clearQuery(), await y();
|
|
391
|
+
}
|
|
392
|
+
), (o, b) => (g(), w("div", {
|
|
393
|
+
class: H(["tr-model-selector__panel", [`tr-model-selector__panel--${e.size}`, e.panelClass]]),
|
|
394
|
+
onKeydown: B
|
|
395
|
+
}, [
|
|
396
|
+
o.$slots.header ? (g(), w("div", Je, [
|
|
397
|
+
T(o.$slots, "header", F(A(r.value)))
|
|
398
|
+
])) : D("", !0),
|
|
399
|
+
e.searchable ? (g(), w("div", Xe, [
|
|
400
|
+
U(P(Ee), {
|
|
401
|
+
class: "tr-model-selector__search-icon",
|
|
402
|
+
"aria-hidden": "true",
|
|
403
|
+
focusable: "false"
|
|
404
|
+
}),
|
|
405
|
+
I("input", {
|
|
406
|
+
ref_key: "searchInputEl",
|
|
407
|
+
ref: u,
|
|
408
|
+
type: "text",
|
|
409
|
+
class: "tr-model-selector__search-input",
|
|
410
|
+
"data-model-selector-search-input": "",
|
|
411
|
+
role: "combobox",
|
|
412
|
+
value: P(i).query.value,
|
|
413
|
+
placeholder: e.searchPlaceholder,
|
|
414
|
+
"aria-label": e.searchPlaceholder,
|
|
415
|
+
"aria-controls": e.listboxId,
|
|
416
|
+
"aria-activedescendant": m.value,
|
|
417
|
+
"aria-autocomplete": "list",
|
|
418
|
+
"aria-expanded": "true",
|
|
419
|
+
"aria-haspopup": "listbox",
|
|
420
|
+
autocomplete: "off",
|
|
421
|
+
spellcheck: !1,
|
|
422
|
+
onInput: c,
|
|
423
|
+
onKeydown: O
|
|
424
|
+
}, null, 40, Ze)
|
|
425
|
+
])) : D("", !0),
|
|
426
|
+
P(i).isEmpty.value ? (g(), w("div", _e, [
|
|
427
|
+
T(o.$slots, "empty", {
|
|
428
|
+
query: P(i).query.value
|
|
429
|
+
}, () => [
|
|
430
|
+
U(P(Oe), {
|
|
431
|
+
class: "tr-model-selector__empty-icon",
|
|
432
|
+
"aria-hidden": "true",
|
|
433
|
+
focusable: "false"
|
|
434
|
+
}),
|
|
435
|
+
I("span", null, K(e.emptyText), 1)
|
|
436
|
+
])
|
|
437
|
+
])) : D("", !0),
|
|
438
|
+
I("div", {
|
|
439
|
+
id: e.listboxId,
|
|
440
|
+
ref_key: "listboxEl",
|
|
441
|
+
ref: f,
|
|
442
|
+
class: H(["tr-model-selector__content", { "is-empty": P(i).isEmpty.value }]),
|
|
443
|
+
role: "listbox",
|
|
444
|
+
tabindex: "-1",
|
|
445
|
+
"aria-label": e.placeholder,
|
|
446
|
+
"aria-activedescendant": e.searchable ? void 0 : m.value,
|
|
447
|
+
onKeydown: x
|
|
448
|
+
}, [
|
|
449
|
+
(g(!0), w(ae, null, re(P(i).groups.value, (S) => (g(), N(Ye, {
|
|
450
|
+
key: S.key,
|
|
451
|
+
group: S,
|
|
452
|
+
"selected-value": e.selectedValue,
|
|
453
|
+
"highlighted-key": P(d).highlightedKey.value,
|
|
454
|
+
"option-id-prefix": e.optionIdPrefix,
|
|
455
|
+
onHover: P(d).setHighlightedKey,
|
|
456
|
+
onSelect: b[0] || (b[0] = (L) => o.$emit("select", L))
|
|
457
|
+
}, _({ _: 2 }, [
|
|
458
|
+
o.$slots.item ? {
|
|
459
|
+
name: "item",
|
|
460
|
+
fn: q((L) => [
|
|
461
|
+
T(o.$slots, "item", ue({ ref_for: !0 }, L))
|
|
462
|
+
]),
|
|
463
|
+
key: "0"
|
|
464
|
+
} : void 0
|
|
465
|
+
]), 1032, ["group", "selected-value", "highlighted-key", "option-id-prefix", "onHover"]))), 128))
|
|
466
|
+
], 42, et),
|
|
467
|
+
o.$slots.footer || e.effortOptions.length > 0 ? (g(), w("div", tt, [
|
|
468
|
+
T(o.$slots, "footer", F(A(s.value)), () => [
|
|
469
|
+
U(qe, {
|
|
470
|
+
options: e.effortOptions,
|
|
471
|
+
value: e.effortValue,
|
|
472
|
+
label: e.effortLabel,
|
|
473
|
+
disabled: e.effortDisabled,
|
|
474
|
+
onSelect: b[1] || (b[1] = (S) => o.$emit("select-effort", S))
|
|
475
|
+
}, null, 8, ["options", "value", "label", "disabled"])
|
|
476
|
+
])
|
|
477
|
+
])) : D("", !0)
|
|
478
|
+
], 34));
|
|
479
|
+
}
|
|
480
|
+
}), ot = ["title", "disabled", "aria-label", "aria-expanded", "aria-controls"], nt = { class: "tr-model-selector__trigger-content" }, at = ["src"], rt = { class: "tr-model-selector__trigger-label" }, it = {
|
|
481
|
+
key: 2,
|
|
482
|
+
class: "tr-model-selector__trigger-effort"
|
|
483
|
+
}, st = /* @__PURE__ */ Q({
|
|
484
|
+
name: "TrModelSelectorTrigger",
|
|
485
|
+
__name: "ModelSelectorTrigger",
|
|
486
|
+
props: {
|
|
487
|
+
open: { type: Boolean },
|
|
488
|
+
disabled: { type: Boolean },
|
|
489
|
+
label: {},
|
|
490
|
+
effortLabel: {},
|
|
491
|
+
icon: {},
|
|
492
|
+
controlsId: {},
|
|
493
|
+
variant: {},
|
|
494
|
+
size: {}
|
|
495
|
+
},
|
|
496
|
+
emits: ["click", "enter"],
|
|
497
|
+
setup(e, { emit: a }) {
|
|
498
|
+
const n = e, t = p(() => n.effortLabel ? `${n.label} · ${n.effortLabel}` : n.label), u = a;
|
|
499
|
+
function f(i) {
|
|
500
|
+
i.key === "Enter" && !i.defaultPrevented && (i.preventDefault(), u("enter", i));
|
|
501
|
+
}
|
|
502
|
+
return (i, d) => (g(), w("button", {
|
|
503
|
+
type: "button",
|
|
504
|
+
class: H(["tr-model-selector__trigger", [`tr-model-selector__trigger--${e.variant}`, `tr-model-selector__trigger--${e.size}`, { "is-open": e.open }]]),
|
|
505
|
+
title: t.value,
|
|
506
|
+
disabled: e.disabled,
|
|
507
|
+
"aria-label": t.value,
|
|
508
|
+
"aria-expanded": e.open,
|
|
509
|
+
"aria-controls": e.controlsId,
|
|
510
|
+
"aria-haspopup": "listbox",
|
|
511
|
+
onClick: d[0] || (d[0] = (m) => i.$emit("click", m)),
|
|
512
|
+
onKeydown: f
|
|
513
|
+
}, [
|
|
514
|
+
T(i.$slots, "default", {}, () => [
|
|
515
|
+
I("span", nt, [
|
|
516
|
+
typeof e.icon == "string" ? (g(), w("img", {
|
|
517
|
+
key: 0,
|
|
518
|
+
src: e.icon,
|
|
519
|
+
class: "tr-model-selector__trigger-icon",
|
|
520
|
+
alt: "",
|
|
521
|
+
"aria-hidden": "true"
|
|
522
|
+
}, null, 8, at)) : e.icon ? (g(), N(se(e.icon), {
|
|
523
|
+
key: 1,
|
|
524
|
+
class: "tr-model-selector__trigger-icon",
|
|
525
|
+
"aria-hidden": "true",
|
|
526
|
+
focusable: "false"
|
|
527
|
+
})) : D("", !0),
|
|
528
|
+
I("span", rt, K(e.label), 1),
|
|
529
|
+
e.effortLabel ? (g(), w("span", it, K(e.effortLabel), 1)) : D("", !0)
|
|
530
|
+
]),
|
|
531
|
+
U(P(Se), {
|
|
532
|
+
class: "tr-model-selector__trigger-chevron",
|
|
533
|
+
"aria-hidden": "true",
|
|
534
|
+
focusable: "false"
|
|
535
|
+
})
|
|
536
|
+
])
|
|
537
|
+
], 42, ot));
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
function ut(e) {
|
|
541
|
+
const a = e.controlled, n = C(e.defaultValue), t = p(() => a ? e.value() ?? null : n.value), u = p(() => e.efforts().find((i) => i.value === t.value) ?? null);
|
|
542
|
+
function f(i) {
|
|
543
|
+
if (Object.is(t.value, i))
|
|
544
|
+
return !1;
|
|
545
|
+
if (i !== null) {
|
|
546
|
+
const d = e.efforts().find((m) => m.value === i);
|
|
547
|
+
if (!d || d.disabled)
|
|
548
|
+
return !1;
|
|
549
|
+
}
|
|
550
|
+
return a || (n.value = i), e.onUpdateValue(i), !0;
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
value: t,
|
|
554
|
+
activeOption: u,
|
|
555
|
+
setValue: f
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
function ie(e, a) {
|
|
559
|
+
var u, f;
|
|
560
|
+
if ((((u = e.composedPath) == null ? void 0 : u.call(e)) ?? []).includes(a))
|
|
561
|
+
return !0;
|
|
562
|
+
const t = (f = a.ownerDocument.defaultView) == null ? void 0 : f.Node;
|
|
563
|
+
return !!(t && e.target instanceof t && a.contains(e.target));
|
|
564
|
+
}
|
|
565
|
+
function dt(e) {
|
|
566
|
+
const a = C(!1), n = j(
|
|
567
|
+
() => [
|
|
568
|
+
e.open(),
|
|
569
|
+
e.referenceEl.value,
|
|
570
|
+
e.floatingEl.value,
|
|
571
|
+
e.placement(),
|
|
572
|
+
e.strategy(),
|
|
573
|
+
e.offset(),
|
|
574
|
+
e.teleportTarget()
|
|
575
|
+
],
|
|
576
|
+
async ([t, u, f, i, d, m, r], s, c) => {
|
|
577
|
+
if (a.value = !1, !t || !u || !f)
|
|
578
|
+
return;
|
|
579
|
+
const v = u, y = f;
|
|
580
|
+
let E = !0, $ = 0;
|
|
581
|
+
const O = {}, x = v.ownerDocument, B = (b) => {
|
|
582
|
+
ie(b, v) || ie(b, y) || e.onOutsidePointerDown(b);
|
|
583
|
+
};
|
|
584
|
+
x.addEventListener("pointerdown", B, !0), c(() => {
|
|
585
|
+
var b;
|
|
586
|
+
E = !1, $ += 1, (b = O.current) == null || b.call(O), x.removeEventListener("pointerdown", B, !0), a.value = !1;
|
|
587
|
+
});
|
|
588
|
+
async function o() {
|
|
589
|
+
var S;
|
|
590
|
+
const b = ++$;
|
|
591
|
+
try {
|
|
592
|
+
const L = await Pe(v, y, {
|
|
593
|
+
placement: i,
|
|
594
|
+
strategy: d,
|
|
595
|
+
middleware: [
|
|
596
|
+
Ve(m),
|
|
597
|
+
Me({ padding: 8 }),
|
|
598
|
+
Te({ padding: 8 }),
|
|
599
|
+
Ce({
|
|
600
|
+
padding: 8,
|
|
601
|
+
apply({ availableHeight: le, availableWidth: X, rects: oe, elements: W }) {
|
|
602
|
+
const Z = Math.min(oe.reference.width, Math.max(0, X));
|
|
603
|
+
W.floating.style.minWidth = `${Math.round(Z)}px`, W.floating.style.maxWidth = `${Math.max(0, Math.floor(X))}px`, W.floating.style.setProperty(
|
|
604
|
+
"--tr-model-selector-available-height",
|
|
605
|
+
`${Math.max(0, Math.floor(le))}px`
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
})
|
|
609
|
+
]
|
|
610
|
+
});
|
|
611
|
+
if (!E || b !== $ || !e.open() || e.referenceEl.value !== v || e.floatingEl.value !== y)
|
|
612
|
+
return;
|
|
613
|
+
const V = ((S = x.defaultView) == null ? void 0 : S.devicePixelRatio) || 1, J = Math.round(L.x * V) / V, te = Math.round(L.y * V) / V;
|
|
614
|
+
Object.assign(y.style, {
|
|
615
|
+
left: `${J}px`,
|
|
616
|
+
top: `${te}px`
|
|
617
|
+
}), a.value = !0;
|
|
618
|
+
} catch {
|
|
619
|
+
E && b === $ && (a.value = !1);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
await Y(), !(!E || !e.open()) && (O.current = xe(v, y, () => {
|
|
623
|
+
o();
|
|
624
|
+
}));
|
|
625
|
+
},
|
|
626
|
+
{ flush: "post", immediate: !0 }
|
|
627
|
+
);
|
|
628
|
+
return ye(() => {
|
|
629
|
+
n();
|
|
630
|
+
}), {
|
|
631
|
+
isPositioned: a
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function ct(e) {
|
|
635
|
+
const a = e.valueControlled, n = e.openControlled, t = C(e.defaultValue), u = C(e.defaultOpen), f = p(() => a ? e.value() ?? null : t.value), i = p(() => n ? !!e.open() : u.value);
|
|
636
|
+
function d(r) {
|
|
637
|
+
return Object.is(f.value, r) ? !1 : (a || (t.value = r), e.onUpdateValue(r), !0);
|
|
638
|
+
}
|
|
639
|
+
function m(r) {
|
|
640
|
+
return i.value === r ? !1 : (n || (u.value = r), e.onUpdateOpen(r), !0);
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
value: f,
|
|
644
|
+
open: i,
|
|
645
|
+
setValue: d,
|
|
646
|
+
setOpen: m
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
const ft = Object.freeze([
|
|
650
|
+
Object.freeze({ value: "low", label: "Low" }),
|
|
651
|
+
Object.freeze({ value: "medium", label: "Medium" }),
|
|
652
|
+
Object.freeze({ value: "high", label: "High" })
|
|
653
|
+
]);
|
|
654
|
+
function ht(e) {
|
|
655
|
+
if (!e)
|
|
656
|
+
return [];
|
|
657
|
+
if (e === !0)
|
|
658
|
+
return ft;
|
|
659
|
+
const a = /* @__PURE__ */ new Set(), n = [];
|
|
660
|
+
for (const t of e)
|
|
661
|
+
a.has(t.value) || (a.add(t.value), n.push(t));
|
|
662
|
+
return n;
|
|
663
|
+
}
|
|
664
|
+
function vt(e) {
|
|
665
|
+
if (!e || e === !0)
|
|
666
|
+
return [];
|
|
667
|
+
const a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
668
|
+
for (const t of e)
|
|
669
|
+
a.has(t.value) ? n.add(t.value) : a.add(t.value);
|
|
670
|
+
return Array.from(n);
|
|
671
|
+
}
|
|
672
|
+
const mt = "__tr-model-selector-ungrouped__";
|
|
673
|
+
function ne(e) {
|
|
674
|
+
return (e == null ? void 0 : e.trim()) ?? "";
|
|
675
|
+
}
|
|
676
|
+
function gt(e) {
|
|
677
|
+
return e.filter((a) => !!(a && a.trim())).join(" ").toLocaleLowerCase();
|
|
678
|
+
}
|
|
679
|
+
function pt(e) {
|
|
680
|
+
const a = /* @__PURE__ */ new Set(), n = [];
|
|
681
|
+
return e.forEach((t, u) => {
|
|
682
|
+
if (a.has(t.value))
|
|
683
|
+
return;
|
|
684
|
+
a.add(t.value);
|
|
685
|
+
const f = ne(t.label) || t.value, i = ne(t.description) || void 0, d = ne(t.group), m = d ? `group:${d}` : mt, r = typeof t.icon == "string" ? t.icon : t.icon ? be(t.icon) : void 0;
|
|
686
|
+
n.push({
|
|
687
|
+
key: `value:${t.value}`,
|
|
688
|
+
index: u,
|
|
689
|
+
value: t.value,
|
|
690
|
+
label: f,
|
|
691
|
+
description: i,
|
|
692
|
+
icon: r,
|
|
693
|
+
disabled: !!t.disabled,
|
|
694
|
+
groupKey: m,
|
|
695
|
+
searchText: gt([f, t.value, i, d]),
|
|
696
|
+
raw: t
|
|
697
|
+
});
|
|
698
|
+
}), n;
|
|
699
|
+
}
|
|
700
|
+
function yt(e) {
|
|
701
|
+
const a = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
702
|
+
return e.forEach((t) => {
|
|
703
|
+
a.has(t.value) ? n.add(t.value) : a.add(t.value);
|
|
704
|
+
}), [...n];
|
|
705
|
+
}
|
|
706
|
+
const bt = { class: "tr-model-selector__dropdown-surface" }, ee = /* @__PURE__ */ Q({
|
|
707
|
+
name: "TrModelSelector",
|
|
708
|
+
__name: "index",
|
|
709
|
+
props: {
|
|
710
|
+
models: { default: () => [] },
|
|
711
|
+
modelValue: {},
|
|
712
|
+
defaultValue: { default: null },
|
|
713
|
+
reasoningEffort: { default: void 0 },
|
|
714
|
+
defaultReasoningEffort: { default: null },
|
|
715
|
+
open: { type: Boolean, default: void 0 },
|
|
716
|
+
defaultOpen: { type: Boolean, default: !1 },
|
|
717
|
+
disabled: { type: Boolean, default: !1 },
|
|
718
|
+
searchable: { type: Boolean, default: !1 },
|
|
719
|
+
placeholder: { default: "选择模型" },
|
|
720
|
+
searchPlaceholder: { default: "搜索模型" },
|
|
721
|
+
emptyText: { default: "暂无可用模型" },
|
|
722
|
+
filterMethod: {},
|
|
723
|
+
variant: { default: "outline" },
|
|
724
|
+
size: { default: "normal" },
|
|
725
|
+
placement: { default: "bottom-start" },
|
|
726
|
+
offset: { default: 8 },
|
|
727
|
+
appendTo: { default: "body" },
|
|
728
|
+
panelClass: {},
|
|
729
|
+
reasoningEffortLabel: { default: "Thinking" }
|
|
730
|
+
},
|
|
731
|
+
emits: ["update:modelValue", "change", "update:reasoningEffort", "reasoning-effort-change", "update:open"],
|
|
732
|
+
setup(e, { emit: a }) {
|
|
733
|
+
const n = e, t = a, u = we(), f = (u == null ? void 0 : u.uid) ?? 0, i = (u == null ? void 0 : u.vnode.props) ?? {}, d = (...l) => l.some((h) => Object.prototype.hasOwnProperty.call(i, h)), m = `tr-model-selector-${f}`, r = `${m}-listbox`, s = C(null), c = C(null), v = C(!1), y = C(null), E = De(s), $ = p(() => {
|
|
734
|
+
var M, z;
|
|
735
|
+
if (!v.value)
|
|
736
|
+
return null;
|
|
737
|
+
const l = E.value, h = n.appendTo;
|
|
738
|
+
if (!h)
|
|
739
|
+
return l;
|
|
740
|
+
if (typeof h != "string")
|
|
741
|
+
return h;
|
|
742
|
+
if (h === "body" && l === ((M = s.value) == null ? void 0 : M.ownerDocument.body))
|
|
743
|
+
return l;
|
|
744
|
+
const k = l;
|
|
745
|
+
try {
|
|
746
|
+
return ((z = k.querySelector) == null ? void 0 : z.call(k, h)) ?? l;
|
|
747
|
+
} catch {
|
|
748
|
+
return l;
|
|
749
|
+
}
|
|
750
|
+
}), O = p(() => {
|
|
751
|
+
var k;
|
|
752
|
+
const l = $.value, h = (k = s.value) == null ? void 0 : k.ownerDocument;
|
|
753
|
+
return !!(h && l && l !== h.body && l.nodeType === 1);
|
|
754
|
+
}), x = ct({
|
|
755
|
+
value: () => n.modelValue,
|
|
756
|
+
defaultValue: n.defaultValue,
|
|
757
|
+
valueControlled: d("modelValue", "model-value"),
|
|
758
|
+
open: () => n.open,
|
|
759
|
+
defaultOpen: n.disabled ? !1 : n.defaultOpen,
|
|
760
|
+
openControlled: d("open"),
|
|
761
|
+
onUpdateValue: (l) => t("update:modelValue", l),
|
|
762
|
+
onUpdateOpen: (l) => t("update:open", l)
|
|
763
|
+
}), B = p(() => pt(n.models));
|
|
764
|
+
p(() => yt(n.models));
|
|
765
|
+
const o = p(() => B.value.find((l) => l.value === x.value.value) ?? null), b = p(() => {
|
|
766
|
+
var l;
|
|
767
|
+
return ht((l = o.value) == null ? void 0 : l.raw.reasoningEfforts);
|
|
768
|
+
});
|
|
769
|
+
p(() => {
|
|
770
|
+
var l;
|
|
771
|
+
return vt((l = o.value) == null ? void 0 : l.raw.reasoningEfforts);
|
|
772
|
+
});
|
|
773
|
+
const S = ut({
|
|
774
|
+
value: () => n.reasoningEffort,
|
|
775
|
+
defaultValue: n.defaultReasoningEffort,
|
|
776
|
+
efforts: () => b.value,
|
|
777
|
+
controlled: d("reasoningEffort", "reasoning-effort"),
|
|
778
|
+
onUpdateValue: (l) => t("update:reasoningEffort", l)
|
|
779
|
+
}), L = p(() => {
|
|
780
|
+
var l;
|
|
781
|
+
return ((l = S.activeOption.value) == null ? void 0 : l.value) ?? null;
|
|
782
|
+
}), V = p(() => x.open.value && !n.disabled), J = p(() => {
|
|
783
|
+
var l;
|
|
784
|
+
return ((l = o.value) == null ? void 0 : l.label) ?? n.placeholder;
|
|
785
|
+
}), te = p(() => {
|
|
786
|
+
var l;
|
|
787
|
+
return {
|
|
788
|
+
option: ((l = o.value) == null ? void 0 : l.raw) ?? null,
|
|
789
|
+
label: J.value,
|
|
790
|
+
open: V.value,
|
|
791
|
+
reasoningEffortOption: S.activeOption.value
|
|
792
|
+
};
|
|
793
|
+
}), le = p(() => {
|
|
794
|
+
var l;
|
|
795
|
+
return {
|
|
796
|
+
option: ((l = o.value) == null ? void 0 : l.raw) ?? null,
|
|
797
|
+
close: me
|
|
798
|
+
};
|
|
799
|
+
});
|
|
800
|
+
function X() {
|
|
801
|
+
var l, h;
|
|
802
|
+
(h = (l = s.value) == null ? void 0 : l.querySelector(".tr-model-selector__trigger")) == null || h.focus({ preventScroll: !0 });
|
|
803
|
+
}
|
|
804
|
+
function oe() {
|
|
805
|
+
var h, k;
|
|
806
|
+
let l = ((h = s.value) == null ? void 0 : h.ownerDocument.activeElement) ?? null;
|
|
807
|
+
for (; (k = l == null ? void 0 : l.shadowRoot) != null && k.activeElement; )
|
|
808
|
+
l = l.shadowRoot.activeElement;
|
|
809
|
+
return l;
|
|
810
|
+
}
|
|
811
|
+
function W() {
|
|
812
|
+
var h;
|
|
813
|
+
const l = oe();
|
|
814
|
+
return !!(l && ((h = c.value) != null && h.contains(l)));
|
|
815
|
+
}
|
|
816
|
+
function Z() {
|
|
817
|
+
n.disabled || x.setOpen(!0);
|
|
818
|
+
}
|
|
819
|
+
function G(l) {
|
|
820
|
+
var z;
|
|
821
|
+
if (!V.value || y.value !== null)
|
|
822
|
+
return;
|
|
823
|
+
if (y.value = l, !x.setOpen(!1)) {
|
|
824
|
+
y.value = null;
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const k = () => {
|
|
828
|
+
V.value && y.value === l && (y.value = null);
|
|
829
|
+
}, M = (z = s.value) == null ? void 0 : z.ownerDocument.defaultView;
|
|
830
|
+
M ? M.setTimeout(k, 0) : Y().then(k);
|
|
831
|
+
}
|
|
832
|
+
function ce() {
|
|
833
|
+
V.value ? G(!1) : Z();
|
|
834
|
+
}
|
|
835
|
+
function fe() {
|
|
836
|
+
Z();
|
|
837
|
+
}
|
|
838
|
+
function he(l) {
|
|
839
|
+
const h = B.value.find((M) => M.value === l.value);
|
|
840
|
+
if (!h || h.disabled)
|
|
841
|
+
return;
|
|
842
|
+
x.setValue(h.value) && t("change", h.raw), G(!0);
|
|
843
|
+
}
|
|
844
|
+
function ve(l) {
|
|
845
|
+
var M;
|
|
846
|
+
if (n.disabled || (M = o.value) != null && M.disabled)
|
|
847
|
+
return;
|
|
848
|
+
const h = l === null ? null : b.value.find((z) => z.value === l) ?? null;
|
|
849
|
+
S.setValue(l) && t("reasoning-effort-change", h);
|
|
850
|
+
}
|
|
851
|
+
function me() {
|
|
852
|
+
G(!0);
|
|
853
|
+
}
|
|
854
|
+
const { isPositioned: ge } = dt({
|
|
855
|
+
referenceEl: s,
|
|
856
|
+
floatingEl: c,
|
|
857
|
+
open: () => V.value,
|
|
858
|
+
placement: () => n.placement,
|
|
859
|
+
strategy: () => O.value ? "absolute" : "fixed",
|
|
860
|
+
offset: () => n.offset,
|
|
861
|
+
teleportTarget: () => $.value,
|
|
862
|
+
onOutsidePointerDown: () => G(!1)
|
|
863
|
+
});
|
|
864
|
+
return j(
|
|
865
|
+
() => n.disabled,
|
|
866
|
+
(l) => {
|
|
867
|
+
l && x.open.value && (y.value = !1, x.setOpen(!1));
|
|
868
|
+
}
|
|
869
|
+
), j(
|
|
870
|
+
V,
|
|
871
|
+
async (l, h) => {
|
|
872
|
+
if (!l) {
|
|
873
|
+
if (h) {
|
|
874
|
+
const k = y.value ?? W();
|
|
875
|
+
y.value = null, k && (await Y(), X());
|
|
876
|
+
}
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
{ immediate: !0 }
|
|
881
|
+
), de(() => {
|
|
882
|
+
v.value = !0;
|
|
883
|
+
}), (l, h) => {
|
|
884
|
+
var k, M, z;
|
|
885
|
+
return g(), w("div", {
|
|
886
|
+
class: H(["tr-model-selector", [`tr-model-selector--${e.variant}`, `tr-model-selector--${e.size}`]])
|
|
887
|
+
}, [
|
|
888
|
+
I("span", {
|
|
889
|
+
ref_key: "referenceEl",
|
|
890
|
+
ref: s,
|
|
891
|
+
class: "tr-model-selector__anchor"
|
|
892
|
+
}, [
|
|
893
|
+
U(st, {
|
|
894
|
+
open: V.value,
|
|
895
|
+
disabled: e.disabled,
|
|
896
|
+
label: J.value,
|
|
897
|
+
"effort-label": (k = P(S).activeOption.value) == null ? void 0 : k.label,
|
|
898
|
+
icon: (M = o.value) == null ? void 0 : M.icon,
|
|
899
|
+
"controls-id": r,
|
|
900
|
+
variant: e.variant,
|
|
901
|
+
size: e.size,
|
|
902
|
+
onClick: ce,
|
|
903
|
+
onEnter: fe
|
|
904
|
+
}, _({ _: 2 }, [
|
|
905
|
+
l.$slots.trigger ? {
|
|
906
|
+
name: "default",
|
|
907
|
+
fn: q(() => [
|
|
908
|
+
T(l.$slots, "trigger", F(A(te.value)))
|
|
909
|
+
]),
|
|
910
|
+
key: "0"
|
|
911
|
+
} : void 0
|
|
912
|
+
]), 1032, ["open", "disabled", "label", "effort-label", "icon", "variant", "size"])
|
|
913
|
+
], 512),
|
|
914
|
+
$.value ? (g(), N(ke, {
|
|
915
|
+
key: 0,
|
|
916
|
+
to: $.value
|
|
917
|
+
}, [
|
|
918
|
+
V.value ? (g(), w("div", {
|
|
919
|
+
key: 0,
|
|
920
|
+
ref_key: "floatingEl",
|
|
921
|
+
ref: c,
|
|
922
|
+
class: H(["tr-model-selector__dropdown-wrapper", { "is-positioned": P(ge), "is-absolute": O.value }])
|
|
923
|
+
}, [
|
|
924
|
+
I("div", bt, [
|
|
925
|
+
U(lt, {
|
|
926
|
+
options: B.value,
|
|
927
|
+
"selected-value": P(x).value.value,
|
|
928
|
+
searchable: e.searchable,
|
|
929
|
+
"filter-method": e.filterMethod,
|
|
930
|
+
"listbox-id": r,
|
|
931
|
+
"option-id-prefix": m,
|
|
932
|
+
placeholder: e.placeholder,
|
|
933
|
+
"search-placeholder": e.searchPlaceholder,
|
|
934
|
+
"empty-text": e.emptyText,
|
|
935
|
+
"effort-options": b.value,
|
|
936
|
+
"effort-value": L.value,
|
|
937
|
+
"effort-label": e.reasoningEffortLabel,
|
|
938
|
+
"effort-disabled": !!((z = o.value) != null && z.disabled),
|
|
939
|
+
size: e.size,
|
|
940
|
+
"panel-class": e.panelClass,
|
|
941
|
+
"slot-context": le.value,
|
|
942
|
+
onSelect: he,
|
|
943
|
+
onSelectEffort: ve,
|
|
944
|
+
onClose: G
|
|
945
|
+
}, _({ _: 2 }, [
|
|
946
|
+
l.$slots.header ? {
|
|
947
|
+
name: "header",
|
|
948
|
+
fn: q((R) => [
|
|
949
|
+
T(l.$slots, "header", F(A(R)))
|
|
950
|
+
]),
|
|
951
|
+
key: "0"
|
|
952
|
+
} : void 0,
|
|
953
|
+
l.$slots.item ? {
|
|
954
|
+
name: "item",
|
|
955
|
+
fn: q((R) => [
|
|
956
|
+
T(l.$slots, "item", F(A(R)))
|
|
957
|
+
]),
|
|
958
|
+
key: "1"
|
|
959
|
+
} : void 0,
|
|
960
|
+
l.$slots.empty ? {
|
|
961
|
+
name: "empty",
|
|
962
|
+
fn: q((R) => [
|
|
963
|
+
T(l.$slots, "empty", F(A(R)))
|
|
964
|
+
]),
|
|
965
|
+
key: "2"
|
|
966
|
+
} : void 0,
|
|
967
|
+
l.$slots.footer ? {
|
|
968
|
+
name: "footer",
|
|
969
|
+
fn: q((R) => [
|
|
970
|
+
T(l.$slots, "footer", F(A(R)))
|
|
971
|
+
]),
|
|
972
|
+
key: "3"
|
|
973
|
+
} : void 0
|
|
974
|
+
]), 1032, ["options", "selected-value", "searchable", "filter-method", "placeholder", "search-placeholder", "empty-text", "effort-options", "effort-value", "effort-label", "effort-disabled", "size", "panel-class", "slot-context"])
|
|
975
|
+
])
|
|
976
|
+
], 2)) : D("", !0)
|
|
977
|
+
], 8, ["to"])) : D("", !0)
|
|
978
|
+
], 2);
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
ee.name = "TrModelSelector";
|
|
983
|
+
const wt = function(e) {
|
|
984
|
+
e.component(ee.name, ee);
|
|
985
|
+
};
|
|
986
|
+
ee.install = wt;
|
|
987
|
+
export {
|
|
988
|
+
ee as default
|
|
989
|
+
};
|