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