vue-agent-input 0.1.0 → 0.2.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/README.md +12 -4
- package/dist/index.js +306 -285
- package/dist/style.css +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
需要 Vue 3.5 或更新的 Vue 3 版本。包以 ESM 发布,附带 TypeScript 声明和编译好的 CSS。
|
|
12
12
|
|
|
13
|
+
浏览器最低支持 Chrome 90。
|
|
14
|
+
|
|
13
15
|
```sh
|
|
14
16
|
npm install vue-agent-input
|
|
15
17
|
```
|
|
@@ -48,10 +50,11 @@ function handleSend({ text }: AgentInputSendPayload) {
|
|
|
48
50
|
<script setup lang="ts">
|
|
49
51
|
import { ref } from 'vue'
|
|
50
52
|
import { AgentInput } from 'vue-agent-input'
|
|
51
|
-
import type { AgentInputContent, AgentInputItem, AgentInputTag } from 'vue-agent-input'
|
|
53
|
+
import type { AgentInputContent, AgentInputExpose, AgentInputItem, AgentInputTag } from 'vue-agent-input'
|
|
52
54
|
import 'vue-agent-input/style.css'
|
|
53
55
|
|
|
54
56
|
const draft = ref<AgentInputContent>([])
|
|
57
|
+
const composer = ref<AgentInputExpose | null>(null)
|
|
55
58
|
const agent = ref<AgentInputItem | null>(null)
|
|
56
59
|
const agents: AgentInputItem[] = [{ label: '研究助手', value: 'research' }]
|
|
57
60
|
const tags: AgentInputTag[] = [{ label: '季度报告', value: 'report.pdf' }]
|
|
@@ -69,7 +72,9 @@ function handleTagClick(item: AgentInputTag) {
|
|
|
69
72
|
</script>
|
|
70
73
|
|
|
71
74
|
<template>
|
|
72
|
-
<
|
|
75
|
+
<button type="button" @click="composer?.openSuggestion('@')">选择智能体</button>
|
|
76
|
+
<button type="button" @click="composer?.openSuggestion('/')">插入标签</button>
|
|
77
|
+
<AgentInput ref="composer" v-model="draft" v-model:agent="agent" @tag-click="handleTagClick">
|
|
73
78
|
<template #suggestion="{ trigger, query, setAgent, insertTag }">
|
|
74
79
|
<button
|
|
75
80
|
v-for="item in filterCandidates(trigger === '@' ? agents : tags, query)"
|
|
@@ -84,7 +89,9 @@ function handleTagClick(item: AgentInputTag) {
|
|
|
84
89
|
</template>
|
|
85
90
|
```
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
组件外部的按钮或快捷键可以通过 ref 调用 `openSuggestion('@')` 或 `openSuggestion('/')`。面板以空查询打开,光标回到最近的编辑位置。有选区时从选区末尾开始,首次编辑时从正文末尾开始。此时正文保持原样,可以直接输入查询词。
|
|
93
|
+
|
|
94
|
+
`setAgent(item)` 和 `insertTag(item)` 都会清除当前查询词及正文中的触发符,并恢复正文焦点。`close()` 收起面板并保留已输入的文字。`close({ clearTrigger: true })` 适用于连接器等自定义候选,会清除查询词及正文中的触发符并恢复焦点。
|
|
88
95
|
|
|
89
96
|
按 Escape 关闭候选面板。需要自定义方向键或 Enter 选择时,监听 `suggestion-keydown`,并对接管的按键调用 `event.preventDefault()`。面板打开时,未接管的 Enter 会收起面板。
|
|
90
97
|
|
|
@@ -138,7 +145,7 @@ const draft: AgentInputContent = [
|
|
|
138
145
|
| --- | --- |
|
|
139
146
|
| `header` | 位于正文上方,可放工具栏或已选连接器。 |
|
|
140
147
|
| `footer` | 填满发送按钮左侧的可用宽度,两者相隔 `0.5rem`。 |
|
|
141
|
-
| `suggestion` | 位于组件内部的 `header` 上方。接收 `{ trigger, query, setAgent, insertTag, close }`,类型为 `AgentInputSuggestion`。最大高度为 `
|
|
148
|
+
| `suggestion` | 位于组件内部的 `header` 上方。接收 `{ trigger, query, setAgent, insertTag, close }`,类型为 `AgentInputSuggestion`。最大高度为 `16rem` 和半个视口高度中的较小值,超出时在面板内滚动。 |
|
|
142
149
|
|
|
143
150
|
### 实例方法
|
|
144
151
|
|
|
@@ -147,6 +154,7 @@ const draft: AgentInputContent = [
|
|
|
147
154
|
| 方法 | 用途 |
|
|
148
155
|
| --- | --- |
|
|
149
156
|
| `focus()` | 将焦点移回正文。 |
|
|
157
|
+
| `openSuggestion(trigger)` | 为 `@` 或 `/` 打开 `#suggestion`,并聚焦正文。 |
|
|
150
158
|
| `setAgent(item)` | 设置首行智能体,传 `null` 清除。 |
|
|
151
159
|
| `insertTag(item)` | 用标签替换当前或最近的正文选区,未建立选区时追加到末尾。 |
|
|
152
160
|
|
package/dist/index.js
CHANGED
|
@@ -1,172 +1,173 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
return
|
|
1
|
+
import { defineComponent as Vt, useSlots as Kt, ref as q, useId as Ft, shallowRef as Q, computed as Y, watch as qt, onMounted as Wt, onBeforeUnmount as zt, openBlock as C, createElementBlock as S, withKeys as Gt, normalizeStyle as Jt, renderSlot as Z, createCommentVNode as L, createElementVNode as _, toDisplayString as ct, withModifiers as Ut } from "vue";
|
|
2
|
+
const pt = (s) => typeof s == "string" ? s.length : 1;
|
|
3
|
+
function ft(s) {
|
|
4
|
+
return s.reduce((n, a) => n + pt(a), 0);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function M(s) {
|
|
7
7
|
const n = [];
|
|
8
|
-
for (const a of
|
|
8
|
+
for (const a of s) {
|
|
9
9
|
if (typeof a != "string") {
|
|
10
10
|
n.push({ ...a });
|
|
11
11
|
continue;
|
|
12
12
|
}
|
|
13
13
|
if (a === "") continue;
|
|
14
|
-
const
|
|
14
|
+
const u = n[n.length - 1], o = a.replace(/\r\n?/g, `
|
|
15
15
|
`);
|
|
16
|
-
typeof
|
|
16
|
+
typeof u == "string" ? n[n.length - 1] = u + o : n.push(o);
|
|
17
17
|
}
|
|
18
18
|
return n;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return
|
|
22
|
-
const o = n[
|
|
20
|
+
function tt(s, n) {
|
|
21
|
+
return s.length === n.length && s.every((a, u) => {
|
|
22
|
+
const o = n[u];
|
|
23
23
|
return typeof a == "string" || typeof o == "string" ? a === o : a.label === o.label && a.value === o.value && a.img === o.img && a.color === o.color;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
26
|
+
function $(s, n, a = 1 / 0) {
|
|
27
|
+
const u = [];
|
|
28
28
|
let o = 0;
|
|
29
|
-
for (const
|
|
30
|
-
const
|
|
29
|
+
for (const p of s) {
|
|
30
|
+
const h = o + pt(p);
|
|
31
31
|
if (o >= a) break;
|
|
32
|
-
|
|
32
|
+
h > n && n < a && u.push(typeof p == "string" ? p.slice(Math.max(0, n - o), a - o) : p), o = h;
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return u;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function dt(s) {
|
|
37
37
|
let n = "", a = !1;
|
|
38
|
-
for (const
|
|
39
|
-
const o = typeof
|
|
40
|
-
|
|
38
|
+
for (const u of s) {
|
|
39
|
+
const o = typeof u != "string", p = o ? u.value : u;
|
|
40
|
+
p !== "" && ((o || a) && n && !/\s$/.test(n) && !/^\s/.test(p) && (n += " "), n += p, a = o);
|
|
41
41
|
}
|
|
42
42
|
return n;
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
function
|
|
46
|
-
const n =
|
|
44
|
+
const ht = "\uFEFF", nt = "data-agent-input-tag", mt = "data-agent-input-guard";
|
|
45
|
+
function vt(s) {
|
|
46
|
+
const n = s.getAttribute(nt);
|
|
47
47
|
return n === null ? void 0 : JSON.parse(n);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function gt(s, n) {
|
|
50
50
|
if (!(n instanceof Element)) return;
|
|
51
|
-
const a = n.closest(`[${
|
|
52
|
-
if (a &&
|
|
51
|
+
const a = n.closest(`[${nt}]`);
|
|
52
|
+
if (a && s.contains(a)) return vt(a);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const a =
|
|
54
|
+
function Xt(s, n) {
|
|
55
|
+
const a = s.ownerDocument, u = a.createDocumentFragment();
|
|
56
56
|
function o() {
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const h = a.createElement("span");
|
|
58
|
+
h.setAttribute(mt, ""), h.textContent = ht, u.append(h);
|
|
59
59
|
}
|
|
60
|
-
for (const [
|
|
61
|
-
if (typeof
|
|
62
|
-
|
|
60
|
+
for (const [h, l] of n.entries()) {
|
|
61
|
+
if (typeof l == "string") {
|
|
62
|
+
u.append(a.createTextNode(l));
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
|
-
typeof n[
|
|
65
|
+
typeof n[h - 1] != "string" && o();
|
|
66
66
|
const i = a.createElement("button");
|
|
67
|
-
if (i.type = "button", i.className = "agent-input__tag", i.contentEditable = "false", i.setAttribute(
|
|
68
|
-
const
|
|
69
|
-
|
|
67
|
+
if (i.type = "button", i.className = "agent-input__tag", i.contentEditable = "false", i.setAttribute(nt, JSON.stringify(l)), l.img) {
|
|
68
|
+
const d = a.createElement("img");
|
|
69
|
+
d.src = l.img, d.alt = "", d.draggable = !1, i.append(d);
|
|
70
70
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
const m = a.createElement("span");
|
|
72
|
+
m.className = "agent-input__tag-label", m.textContent = l.label, l.color && (m.style.color = l.color), i.append(m), u.append(i);
|
|
73
73
|
}
|
|
74
|
-
const
|
|
75
|
-
return (typeof
|
|
76
|
-
`)) && o(),
|
|
74
|
+
const p = n[n.length - 1];
|
|
75
|
+
return (typeof p != "string" || p.endsWith(`
|
|
76
|
+
`)) && o(), s.replaceChildren(u), yt(s);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
const n = [], a = /* @__PURE__ */ new Map(),
|
|
78
|
+
function yt(s) {
|
|
79
|
+
const n = [], a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
80
80
|
let o = 0;
|
|
81
|
-
function
|
|
82
|
-
if (!
|
|
81
|
+
function p(l) {
|
|
82
|
+
if (!l) return;
|
|
83
83
|
const i = n[n.length - 1];
|
|
84
|
-
typeof i == "string" ? n[n.length - 1] = i +
|
|
84
|
+
typeof i == "string" ? n[n.length - 1] = i + l : n.push(l), o += l.length;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
if (
|
|
88
|
-
const y =
|
|
86
|
+
function h(l, i) {
|
|
87
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
88
|
+
const y = l, g = y.data, x = i != null && i.pending ? g.indexOf(ht) : -1;
|
|
89
89
|
x !== -1 && i && (i.pending = !1);
|
|
90
|
-
const
|
|
91
|
-
|
|
90
|
+
const B = o;
|
|
91
|
+
p(x === -1 ? g : g.slice(0, x) + g.slice(x + 1)), u.set(l, { node: y, start: B, end: o, guardIndex: x });
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
a.set(
|
|
94
|
+
if (l.nodeType !== Node.ELEMENT_NODE) return;
|
|
95
|
+
const m = l, d = vt(m);
|
|
96
|
+
if (d) {
|
|
97
|
+
a.set(l, [o, o + 1]), n.push(d), o++;
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
a.set(
|
|
100
|
+
if (m.tagName === "BR") {
|
|
101
|
+
a.set(l, [o]), m.nextSibling && p(`
|
|
102
102
|
`);
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
let
|
|
107
|
-
for (const [y,
|
|
108
|
-
const x = /^(DIV|P)$/.test(
|
|
109
|
-
y > 0 && (x ||
|
|
110
|
-
`),
|
|
105
|
+
const E = [o], D = m.hasAttribute(mt) ? { pending: !0 } : i;
|
|
106
|
+
let b = !1;
|
|
107
|
+
for (const [y, g] of [...l.childNodes].entries()) {
|
|
108
|
+
const x = /^(DIV|P)$/.test(g.nodeName);
|
|
109
|
+
y > 0 && (x || b) && p(`
|
|
110
|
+
`), E[y] = o, h(g, D), E.push(o), b = x;
|
|
111
111
|
}
|
|
112
|
-
a.set(
|
|
112
|
+
a.set(l, E);
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return h(s), {
|
|
115
115
|
content: n,
|
|
116
116
|
length: o,
|
|
117
|
-
offsetAt(
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
117
|
+
offsetAt(l, i) {
|
|
118
|
+
const m = u.get(l);
|
|
119
|
+
if (m) return m.start + i - +(m.guardIndex !== -1 && i > m.guardIndex);
|
|
120
|
+
const d = a.get(l);
|
|
121
|
+
if (d) return d[Math.min(i, d.length - 1)];
|
|
122
122
|
},
|
|
123
|
-
pointAt(
|
|
124
|
-
const i = Math.max(0, Math.min(
|
|
125
|
-
for (const
|
|
126
|
-
if (i <
|
|
127
|
-
const
|
|
128
|
-
return { node:
|
|
123
|
+
pointAt(l) {
|
|
124
|
+
const i = Math.max(0, Math.min(l, o));
|
|
125
|
+
for (const E of u.values()) {
|
|
126
|
+
if (i < E.start || i > E.end) continue;
|
|
127
|
+
const D = i - E.start;
|
|
128
|
+
return { node: E.node, offset: D + +(E.guardIndex !== -1 && D >= E.guardIndex) };
|
|
129
129
|
}
|
|
130
|
-
const
|
|
131
|
-
return { node:
|
|
130
|
+
const d = (a.get(s) ?? [0]).findIndex((E) => E >= i);
|
|
131
|
+
return { node: s, offset: d === -1 ? s.childNodes.length : d };
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
const a =
|
|
137
|
-
if (!a
|
|
138
|
-
const
|
|
139
|
-
return o === void 0 ||
|
|
135
|
+
function jt(s, n) {
|
|
136
|
+
const a = s.ownerDocument.getSelection();
|
|
137
|
+
if (!(a != null && a.rangeCount)) return null;
|
|
138
|
+
const u = a.getRangeAt(0), o = n.offsetAt(u.startContainer, u.startOffset), p = n.offsetAt(u.endContainer, u.endOffset);
|
|
139
|
+
return o === void 0 || p === void 0 ? null : { start: o, end: p };
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
function et(s, n, a) {
|
|
142
|
+
var m, d;
|
|
143
|
+
const u = s.ownerDocument, o = n.pointAt(a.start), p = n.pointAt(a.end), h = u.createRange();
|
|
144
|
+
h.setStart(o.node, o.offset), h.setEnd(p.node, p.offset), (m = u.getSelection()) == null || m.removeAllRanges(), (d = u.getSelection()) == null || d.addRange(h);
|
|
145
|
+
const l = h.getBoundingClientRect(), i = s.getBoundingClientRect();
|
|
146
|
+
l.height && l.bottom > i.bottom && (s.scrollTop += l.bottom - i.bottom), l.height && l.top < i.top && (s.scrollTop -= i.top - l.top);
|
|
146
147
|
}
|
|
147
|
-
const
|
|
148
|
+
const Ht = ["data-theme"], Qt = {
|
|
148
149
|
key: 1,
|
|
149
150
|
class: "agent-input__header"
|
|
150
|
-
},
|
|
151
|
+
}, Yt = {
|
|
151
152
|
key: 0,
|
|
152
153
|
class: "agent-input__agent"
|
|
153
|
-
},
|
|
154
|
+
}, Zt = ["src"], te = { class: "agent-input__agent-label" }, ee = ["aria-label"], ne = {
|
|
154
155
|
key: 1,
|
|
155
156
|
class: "agent-input__placeholder",
|
|
156
157
|
"aria-hidden": "true"
|
|
157
|
-
},
|
|
158
|
+
}, oe = ["aria-label", "aria-placeholder", "aria-controls"], ae = { class: "agent-input__footer" }, ie = {
|
|
158
159
|
key: 0,
|
|
159
160
|
class: "agent-input__footer-content"
|
|
160
|
-
},
|
|
161
|
+
}, re = ["aria-label"], se = {
|
|
161
162
|
key: 0,
|
|
162
163
|
viewBox: "0 0 24 24",
|
|
163
164
|
"aria-hidden": "true"
|
|
164
|
-
},
|
|
165
|
+
}, le = {
|
|
165
166
|
key: 1,
|
|
166
167
|
viewBox: "0 0 24 24",
|
|
167
168
|
fill: "none",
|
|
168
169
|
"aria-hidden": "true"
|
|
169
|
-
},
|
|
170
|
+
}, ce = /* @__PURE__ */ Vt({
|
|
170
171
|
__name: "AgentInput",
|
|
171
172
|
props: {
|
|
172
173
|
modelValue: {},
|
|
@@ -179,257 +180,277 @@ const Ut = ["data-theme"], Xt = {
|
|
|
179
180
|
loading: { type: Boolean, default: !1 }
|
|
180
181
|
},
|
|
181
182
|
emits: ["update:modelValue", "update:agent", "suggestion-keydown", "tag-click", "send", "stop"],
|
|
182
|
-
setup(
|
|
183
|
-
const
|
|
184
|
-
let
|
|
185
|
-
const
|
|
186
|
-
function
|
|
183
|
+
setup(s, { expose: n, emit: a }) {
|
|
184
|
+
const u = s, o = a, p = Kt(), h = q(null), l = q(null), i = q(null), m = `agent-input-suggestion-${Ft()}`, d = Q(M(u.modelValue ?? [])), E = Q(null), D = Y(() => u.agent === void 0 ? E.value : u.agent), b = Q(null), y = q(!1);
|
|
185
|
+
let g = null, x = null, B = null, c, V = !1;
|
|
186
|
+
const ot = Y(() => at(u.minRows, 2)), bt = Y(() => Math.max(ot.value, at(u.maxRows, 6)));
|
|
187
|
+
function at(t, e) {
|
|
187
188
|
return Number.isFinite(t) ? Math.max(1, Math.floor(t)) : e;
|
|
188
189
|
}
|
|
189
|
-
function
|
|
190
|
-
return !i.value || !
|
|
190
|
+
function R() {
|
|
191
|
+
return !i.value || !g || (c == null ? void 0 : c.activeElement) !== i.value ? null : jt(i.value, g);
|
|
192
|
+
}
|
|
193
|
+
function k() {
|
|
194
|
+
const t = (g == null ? void 0 : g.length) ?? ft(d.value);
|
|
195
|
+
return R() ?? x ?? { start: t, end: t };
|
|
191
196
|
}
|
|
192
|
-
function
|
|
193
|
-
const t =
|
|
194
|
-
|
|
197
|
+
function W() {
|
|
198
|
+
const t = i.value, e = l.value;
|
|
199
|
+
if (!t || !e || !g || (c == null ? void 0 : c.activeElement) === t) return;
|
|
200
|
+
const f = k();
|
|
201
|
+
t.focus({ preventScroll: !0 }), et(e, g, f);
|
|
195
202
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
if (!t || !e || !c || E?.activeElement === t) return;
|
|
199
|
-
const f = C();
|
|
200
|
-
t.focus({ preventScroll: !0 }), dt(e, c, f);
|
|
203
|
+
function w() {
|
|
204
|
+
b.value = null;
|
|
201
205
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
206
|
+
function xt(t) {
|
|
207
|
+
const e = i.value, f = l.value;
|
|
208
|
+
if (!p.suggestion || !e || !f || !g || y.value) return;
|
|
209
|
+
const r = k().end, v = { start: r, end: r };
|
|
210
|
+
e.focus({ preventScroll: !0 }), et(f, g, v), x = v, b.value = { ...v, trigger: t, query: "", hasTriggerText: !1 };
|
|
204
211
|
}
|
|
205
|
-
function
|
|
206
|
-
if (!
|
|
207
|
-
|
|
212
|
+
function z(t, e) {
|
|
213
|
+
if (!p.suggestion || !t || t.start !== t.end) {
|
|
214
|
+
w();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const f = t.end, r = b.value, v = e ?? "", T = Math.max(v.lastIndexOf("@"), v.lastIndexOf("/")), N = T === -1 ? r == null ? void 0 : r.start : f - v.length + T, I = T === -1 ? r == null ? void 0 : r.trigger : v[T];
|
|
218
|
+
if (N === void 0 || I === void 0) return;
|
|
219
|
+
const P = T !== -1 || (r == null ? void 0 : r.hasTriggerText) === !0;
|
|
220
|
+
if (!P && e === void 0 && f !== (r == null ? void 0 : r.end)) {
|
|
221
|
+
w();
|
|
208
222
|
return;
|
|
209
223
|
}
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
if (typeof k != "string" || $.length || !/^[@/][^\s@/]*$/u.test(k)) {
|
|
214
|
-
D();
|
|
224
|
+
const [F = "", ...$t] = $(d.value, N, f);
|
|
225
|
+
if (f < N || typeof F != "string" || $t.length || P && F[0] !== I) {
|
|
226
|
+
w();
|
|
215
227
|
return;
|
|
216
228
|
}
|
|
217
|
-
const
|
|
218
|
-
(
|
|
229
|
+
const H = P ? F.slice(1) : F;
|
|
230
|
+
if (/[\s@/]/u.test(H)) {
|
|
231
|
+
w();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
((r == null ? void 0 : r.start) !== N || r.end !== f || r.trigger !== I || r.query !== H || r.hasTriggerText !== P) && (b.value = { start: N, end: f, trigger: I, query: H, hasTriggerText: P });
|
|
219
235
|
}
|
|
220
|
-
function
|
|
236
|
+
function it() {
|
|
221
237
|
if (y.value) return;
|
|
222
|
-
const t =
|
|
223
|
-
t && (x = t,
|
|
224
|
-
}
|
|
225
|
-
function
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
228
|
-
const
|
|
229
|
-
start: Math.min(e.start,
|
|
230
|
-
end: Math.min(e.end,
|
|
238
|
+
const t = R();
|
|
239
|
+
t && (x = t, z(t));
|
|
240
|
+
}
|
|
241
|
+
function O(t, e, f = !1) {
|
|
242
|
+
const r = i.value;
|
|
243
|
+
if (!r || (g = Xt(r, t), !e)) return;
|
|
244
|
+
const v = {
|
|
245
|
+
start: Math.min(e.start, g.length),
|
|
246
|
+
end: Math.min(e.end, g.length)
|
|
231
247
|
};
|
|
232
|
-
x =
|
|
248
|
+
x = v, f && r.focus({ preventScroll: !0 }), l.value && (c == null ? void 0 : c.activeElement) === r && et(l.value, g, v);
|
|
233
249
|
}
|
|
234
|
-
function
|
|
235
|
-
return
|
|
250
|
+
function rt(t) {
|
|
251
|
+
return tt(d.value, t) ? !1 : (d.value = t, !0);
|
|
236
252
|
}
|
|
237
253
|
function A(t, e, f = {}) {
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
...
|
|
241
|
-
|
|
242
|
-
]),
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
function
|
|
254
|
+
const r = M(e), v = M([
|
|
255
|
+
...$(d.value, 0, t.start),
|
|
256
|
+
...r,
|
|
257
|
+
...$(d.value, t.end)
|
|
258
|
+
]), T = t.start + ft(r), N = { start: T, end: T }, I = rt(v);
|
|
259
|
+
O(v, N, f.focus), z(N, f.typed ?? ""), I && o("update:modelValue", M(v));
|
|
260
|
+
}
|
|
261
|
+
function st(t = "") {
|
|
246
262
|
const e = i.value;
|
|
247
263
|
if (!e) return;
|
|
248
|
-
|
|
249
|
-
const f =
|
|
264
|
+
g = yt(e);
|
|
265
|
+
const f = R();
|
|
250
266
|
f && (x = f);
|
|
251
|
-
const
|
|
252
|
-
!
|
|
267
|
+
const r = rt(g.content);
|
|
268
|
+
!g.length && g.pointAt(0).node === e && O([], { start: 0, end: 0 }), z(f, t), r && o("update:modelValue", M(d.value));
|
|
253
269
|
}
|
|
254
|
-
function
|
|
255
|
-
if (
|
|
256
|
-
const e =
|
|
257
|
-
|
|
270
|
+
function lt(t) {
|
|
271
|
+
if (tt(d.value, t)) return;
|
|
272
|
+
const e = R() ?? x;
|
|
273
|
+
d.value = t, w(), O(t, e);
|
|
258
274
|
}
|
|
259
|
-
|
|
275
|
+
qt(() => u.modelValue, (t) => {
|
|
260
276
|
if (t === void 0) return;
|
|
261
|
-
const e =
|
|
262
|
-
y.value ?
|
|
277
|
+
const e = M(t);
|
|
278
|
+
y.value ? B = e : lt(e);
|
|
263
279
|
}, { deep: !0 });
|
|
264
|
-
function
|
|
265
|
-
y.value || t.isComposing ||
|
|
280
|
+
function Et(t) {
|
|
281
|
+
y.value || t.isComposing || st(t.inputType === "insertText" ? t.data ?? "" : "");
|
|
266
282
|
}
|
|
267
|
-
function
|
|
283
|
+
function Tt() {
|
|
268
284
|
y.value = !0;
|
|
269
285
|
}
|
|
270
|
-
function
|
|
271
|
-
if (y.value = !1,
|
|
272
|
-
const e =
|
|
273
|
-
|
|
286
|
+
function wt(t) {
|
|
287
|
+
if (y.value = !1, B !== null) {
|
|
288
|
+
const e = B;
|
|
289
|
+
B = null, tt(d.value, e) ? O(e, x) : lt(e);
|
|
274
290
|
return;
|
|
275
291
|
}
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
function z(t) {
|
|
279
|
-
b.value = t, o("update:agent", t);
|
|
280
|
-
}
|
|
281
|
-
function wt() {
|
|
282
|
-
z(null), q();
|
|
283
|
-
}
|
|
284
|
-
function Dt(t) {
|
|
285
|
-
const e = C();
|
|
286
|
-
D(), A(e, [t], { focus: !0 });
|
|
292
|
+
st(t.data);
|
|
287
293
|
}
|
|
288
294
|
function G(t) {
|
|
289
|
-
|
|
290
|
-
|
|
295
|
+
E.value = t, o("update:agent", t);
|
|
296
|
+
}
|
|
297
|
+
function Dt() {
|
|
298
|
+
G(null), W();
|
|
291
299
|
}
|
|
292
300
|
function kt(t) {
|
|
293
|
-
|
|
301
|
+
const e = k();
|
|
302
|
+
w(), A(e, [t], { focus: !0 });
|
|
303
|
+
}
|
|
304
|
+
function J(t) {
|
|
305
|
+
const e = b.value;
|
|
306
|
+
return e ? (w(), A(e, t, { focus: !0 }), !0) : !1;
|
|
294
307
|
}
|
|
295
308
|
function _t(t) {
|
|
296
|
-
|
|
309
|
+
J([t]);
|
|
297
310
|
}
|
|
298
311
|
function Ct(t) {
|
|
299
|
-
|
|
312
|
+
J([]) && G(t);
|
|
300
313
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
const t = N(u.value);
|
|
304
|
-
o("send", { text: ct(t), content: t, agent: w.value && { ...w.value } });
|
|
314
|
+
function St(t) {
|
|
315
|
+
t != null && t.clearTrigger ? J([]) : w();
|
|
305
316
|
}
|
|
306
|
-
function
|
|
307
|
-
|
|
317
|
+
function U() {
|
|
318
|
+
if (u.loading || y.value) return;
|
|
319
|
+
const t = M(d.value);
|
|
320
|
+
o("send", { text: dt(t), content: t, agent: D.value && { ...D.value } });
|
|
321
|
+
}
|
|
322
|
+
function At() {
|
|
323
|
+
u.loading ? o("stop") : U();
|
|
308
324
|
}
|
|
309
|
-
function
|
|
310
|
-
return
|
|
325
|
+
function X(t) {
|
|
326
|
+
return $(d.value, t.start, t.end).some((e) => typeof e != "string");
|
|
311
327
|
}
|
|
312
|
-
function
|
|
313
|
-
const { start:
|
|
314
|
-
start: e === -1 ? Math.max(0,
|
|
315
|
-
end: e === 1 ?
|
|
328
|
+
function j(t, e, f) {
|
|
329
|
+
const { start: r, end: v } = f, T = r !== v ? f : {
|
|
330
|
+
start: e === -1 ? Math.max(0, r - 1) : r,
|
|
331
|
+
end: e === 1 ? r + 1 : r
|
|
316
332
|
};
|
|
317
|
-
|
|
333
|
+
X(T) && (t.preventDefault(), A(T, []));
|
|
318
334
|
}
|
|
319
|
-
function
|
|
320
|
-
t.button === 0 && i.value &&
|
|
335
|
+
function Nt(t) {
|
|
336
|
+
t.button === 0 && i.value && gt(i.value, t.target) && t.preventDefault();
|
|
321
337
|
}
|
|
322
|
-
function
|
|
338
|
+
function Mt(t) {
|
|
323
339
|
if (!i.value) return;
|
|
324
|
-
const e =
|
|
340
|
+
const e = gt(i.value, t.target);
|
|
325
341
|
e && o("tag-click", e);
|
|
326
342
|
}
|
|
327
|
-
function
|
|
343
|
+
function Bt(t) {
|
|
328
344
|
if (!(t.target !== i.value || y.value || t.isComposing || t.keyCode === 229)) {
|
|
329
|
-
if (
|
|
345
|
+
if (b.value && t.key !== "Escape") {
|
|
330
346
|
if (o("suggestion-keydown", t), t.defaultPrevented) return;
|
|
331
347
|
if (t.key === "Enter" && !t.shiftKey) {
|
|
332
|
-
t.preventDefault(),
|
|
348
|
+
t.preventDefault(), w();
|
|
333
349
|
return;
|
|
334
350
|
}
|
|
335
351
|
}
|
|
336
|
-
t.key === "Enter" ? (t.preventDefault(), t.shiftKey ? A(
|
|
337
|
-
`]) :
|
|
352
|
+
t.key === "Enter" ? (t.preventDefault(), t.shiftKey ? A(k(), [`
|
|
353
|
+
`]) : U()) : !t.metaKey && !t.ctrlKey && !t.altKey && (t.key === "Backspace" && j(t, -1, k()), t.key === "Delete" && j(t, 1, k()));
|
|
338
354
|
}
|
|
339
355
|
}
|
|
340
|
-
function
|
|
356
|
+
function It(t) {
|
|
357
|
+
var e;
|
|
341
358
|
if (!(y.value || t.isComposing || !t.cancelable)) {
|
|
342
359
|
if (t.inputType === "insertParagraph" || t.inputType === "insertLineBreak") {
|
|
343
|
-
t.preventDefault(), t.inputType === "insertLineBreak" ? A(
|
|
344
|
-
`]) :
|
|
360
|
+
t.preventDefault(), t.inputType === "insertLineBreak" ? A(k(), [`
|
|
361
|
+
`]) : b.value ? w() : U();
|
|
345
362
|
return;
|
|
346
363
|
}
|
|
347
364
|
if (t.inputType.startsWith("delete") && t.inputType !== "deleteByCut") {
|
|
348
|
-
let
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
const
|
|
352
|
-
|
|
365
|
+
let f = k();
|
|
366
|
+
const r = (e = t.getTargetRanges) == null ? void 0 : e.call(t)[0];
|
|
367
|
+
if (r && g) {
|
|
368
|
+
const v = g.offsetAt(r.startContainer, r.startOffset), T = g.offsetAt(r.endContainer, r.endOffset);
|
|
369
|
+
v !== void 0 && T !== void 0 && v !== T && (f = { start: v, end: T });
|
|
353
370
|
}
|
|
354
|
-
|
|
371
|
+
j(t, t.inputType.endsWith("Backward") ? -1 : 1, f);
|
|
355
372
|
return;
|
|
356
373
|
}
|
|
357
374
|
if (t.inputType === "insertText" && t.data !== null) {
|
|
358
|
-
const
|
|
359
|
-
|
|
375
|
+
const f = k();
|
|
376
|
+
X(f) && (t.preventDefault(), A(f, [t.data], { typed: t.data }));
|
|
360
377
|
}
|
|
361
378
|
}
|
|
362
379
|
}
|
|
363
|
-
function
|
|
380
|
+
function Lt(t) {
|
|
381
|
+
var f;
|
|
364
382
|
t.preventDefault();
|
|
365
|
-
const e = t.clipboardData
|
|
366
|
-
e && A(
|
|
383
|
+
const e = (f = t.clipboardData) == null ? void 0 : f.getData("text/plain");
|
|
384
|
+
e && A(k(), [e]);
|
|
367
385
|
}
|
|
368
|
-
function
|
|
369
|
-
const e =
|
|
370
|
-
!e || !
|
|
386
|
+
function Rt(t) {
|
|
387
|
+
const e = R();
|
|
388
|
+
!e || !X(e) || !t.clipboardData || (t.preventDefault(), t.clipboardData.setData("text/plain", dt($(d.value, e.start, e.end))), A(e, []));
|
|
371
389
|
}
|
|
372
|
-
function
|
|
373
|
-
|
|
390
|
+
function ut(t) {
|
|
391
|
+
V = h.value !== null && t.composedPath().includes(h.value), V || w();
|
|
374
392
|
}
|
|
375
|
-
function
|
|
376
|
-
|
|
393
|
+
function K() {
|
|
394
|
+
V = !1;
|
|
377
395
|
}
|
|
378
|
-
function
|
|
379
|
-
|
|
380
|
-
|
|
396
|
+
function Ot(t) {
|
|
397
|
+
var e;
|
|
398
|
+
b.value && (t.relatedTarget instanceof Node && ((e = h.value) != null && e.contains(t.relatedTarget)) || !t.relatedTarget && V || queueMicrotask(() => {
|
|
399
|
+
var f;
|
|
400
|
+
(f = h.value) != null && f.contains((c == null ? void 0 : c.activeElement) ?? null) || w();
|
|
381
401
|
}));
|
|
382
402
|
}
|
|
383
|
-
function
|
|
384
|
-
!
|
|
403
|
+
function Pt(t) {
|
|
404
|
+
!b.value || y.value || t.isComposing || t.keyCode === 229 || (t.preventDefault(), w(), W());
|
|
385
405
|
}
|
|
386
|
-
return
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
406
|
+
return Wt(() => {
|
|
407
|
+
var t;
|
|
408
|
+
c = (t = i.value) == null ? void 0 : t.ownerDocument, O(d.value, null), c == null || c.addEventListener("selectionchange", it), c == null || c.addEventListener("pointerdown", ut, !0), c == null || c.addEventListener("pointerup", K, !0), c == null || c.addEventListener("pointercancel", K, !0);
|
|
409
|
+
}), zt(() => {
|
|
410
|
+
c == null || c.removeEventListener("selectionchange", it), c == null || c.removeEventListener("pointerdown", ut, !0), c == null || c.removeEventListener("pointerup", K, !0), c == null || c.removeEventListener("pointercancel", K, !0);
|
|
411
|
+
}), n({ focus: W, openSuggestion: xt, setAgent: G, insertTag: kt }), (t, e) => (C(), S("div", {
|
|
391
412
|
ref_key: "root",
|
|
392
|
-
ref:
|
|
413
|
+
ref: h,
|
|
393
414
|
class: "agent-input",
|
|
394
|
-
"data-theme":
|
|
395
|
-
style:
|
|
396
|
-
onFocusout:
|
|
397
|
-
onKeydown:
|
|
415
|
+
"data-theme": s.theme,
|
|
416
|
+
style: Jt({ "--agent-input-min-rows": ot.value, "--agent-input-max-rows": bt.value }),
|
|
417
|
+
onFocusout: Ot,
|
|
418
|
+
onKeydown: Gt(Pt, ["esc"])
|
|
398
419
|
}, [
|
|
399
|
-
|
|
420
|
+
b.value && t.$slots.suggestion ? (C(), S("div", {
|
|
400
421
|
key: 0,
|
|
401
|
-
id:
|
|
422
|
+
id: m,
|
|
402
423
|
class: "agent-input__suggestion"
|
|
403
424
|
}, [
|
|
404
|
-
|
|
405
|
-
trigger:
|
|
406
|
-
query:
|
|
407
|
-
setAgent:
|
|
408
|
-
insertTag:
|
|
409
|
-
close:
|
|
425
|
+
Z(t.$slots, "suggestion", {
|
|
426
|
+
trigger: b.value.trigger,
|
|
427
|
+
query: b.value.query,
|
|
428
|
+
setAgent: Ct,
|
|
429
|
+
insertTag: _t,
|
|
430
|
+
close: St
|
|
410
431
|
})
|
|
411
|
-
])) :
|
|
412
|
-
t.$slots.header ? (
|
|
413
|
-
|
|
414
|
-
])) :
|
|
432
|
+
])) : L("", !0),
|
|
433
|
+
t.$slots.header ? (C(), S("div", Qt, [
|
|
434
|
+
Z(t.$slots, "header")
|
|
435
|
+
])) : L("", !0),
|
|
415
436
|
_("div", {
|
|
416
437
|
ref_key: "scrollArea",
|
|
417
|
-
ref:
|
|
438
|
+
ref: l,
|
|
418
439
|
class: "agent-input__body"
|
|
419
440
|
}, [
|
|
420
|
-
|
|
421
|
-
|
|
441
|
+
D.value ? (C(), S("div", Yt, [
|
|
442
|
+
D.value.img ? (C(), S("img", {
|
|
422
443
|
key: 0,
|
|
423
|
-
src:
|
|
444
|
+
src: D.value.img,
|
|
424
445
|
alt: "",
|
|
425
446
|
draggable: "false"
|
|
426
|
-
}, null, 8,
|
|
427
|
-
_("span",
|
|
447
|
+
}, null, 8, Zt)) : L("", !0),
|
|
448
|
+
_("span", te, "@" + ct(D.value.label), 1),
|
|
428
449
|
_("button", {
|
|
429
450
|
type: "button",
|
|
430
451
|
class: "agent-input__remove",
|
|
431
|
-
"aria-label": `移除智能体 ${
|
|
432
|
-
onClick:
|
|
452
|
+
"aria-label": `移除智能体 ${D.value.label}`,
|
|
453
|
+
onClick: Dt
|
|
433
454
|
}, [...e[1] || (e[1] = [
|
|
434
455
|
_("svg", {
|
|
435
456
|
viewBox: "0 0 24 24",
|
|
@@ -438,9 +459,9 @@ const Ut = ["data-theme"], Xt = {
|
|
|
438
459
|
}, [
|
|
439
460
|
_("path", { d: "m7 7 10 10M17 7 7 17" })
|
|
440
461
|
], -1)
|
|
441
|
-
])], 8,
|
|
442
|
-
])) :
|
|
443
|
-
|
|
462
|
+
])], 8, ee)
|
|
463
|
+
])) : L("", !0),
|
|
464
|
+
s.placeholder && !d.value.length && !y.value ? (C(), S("div", ne, ct(s.placeholder), 1)) : L("", !0),
|
|
444
465
|
_("div", {
|
|
445
466
|
ref_key: "editor",
|
|
446
467
|
ref: i,
|
|
@@ -448,33 +469,33 @@ const Ut = ["data-theme"], Xt = {
|
|
|
448
469
|
contenteditable: "true",
|
|
449
470
|
role: "textbox",
|
|
450
471
|
"aria-multiline": "true",
|
|
451
|
-
"aria-label":
|
|
452
|
-
"aria-placeholder":
|
|
453
|
-
"aria-controls":
|
|
454
|
-
onMousedown:
|
|
455
|
-
onClick:
|
|
456
|
-
onKeydown:
|
|
457
|
-
onBeforeinput:
|
|
458
|
-
onInput:
|
|
459
|
-
onCompositionstart:
|
|
460
|
-
onCompositionend:
|
|
461
|
-
onPaste:
|
|
462
|
-
onCut:
|
|
463
|
-
onDrop: e[0] || (e[0] =
|
|
472
|
+
"aria-label": s.ariaLabel,
|
|
473
|
+
"aria-placeholder": s.placeholder,
|
|
474
|
+
"aria-controls": b.value ? m : void 0,
|
|
475
|
+
onMousedown: Nt,
|
|
476
|
+
onClick: Mt,
|
|
477
|
+
onKeydown: Bt,
|
|
478
|
+
onBeforeinput: It,
|
|
479
|
+
onInput: Et,
|
|
480
|
+
onCompositionstart: Tt,
|
|
481
|
+
onCompositionend: wt,
|
|
482
|
+
onPaste: Lt,
|
|
483
|
+
onCut: Rt,
|
|
484
|
+
onDrop: e[0] || (e[0] = Ut(() => {
|
|
464
485
|
}, ["prevent"]))
|
|
465
|
-
}, null, 40,
|
|
486
|
+
}, null, 40, oe)
|
|
466
487
|
], 512),
|
|
467
|
-
_("div",
|
|
468
|
-
t.$slots.footer ? (
|
|
469
|
-
|
|
470
|
-
])) :
|
|
488
|
+
_("div", ae, [
|
|
489
|
+
t.$slots.footer ? (C(), S("div", ie, [
|
|
490
|
+
Z(t.$slots, "footer")
|
|
491
|
+
])) : L("", !0),
|
|
471
492
|
_("button", {
|
|
472
493
|
type: "button",
|
|
473
494
|
class: "agent-input__action",
|
|
474
|
-
"aria-label":
|
|
475
|
-
onClick:
|
|
495
|
+
"aria-label": s.loading ? "停止生成" : "发送消息",
|
|
496
|
+
onClick: At
|
|
476
497
|
}, [
|
|
477
|
-
|
|
498
|
+
s.loading ? (C(), S("svg", se, [...e[2] || (e[2] = [
|
|
478
499
|
_("rect", {
|
|
479
500
|
x: "7",
|
|
480
501
|
y: "7",
|
|
@@ -483,14 +504,14 @@ const Ut = ["data-theme"], Xt = {
|
|
|
483
504
|
rx: "2",
|
|
484
505
|
fill: "currentColor"
|
|
485
506
|
}, null, -1)
|
|
486
|
-
])])) : (
|
|
507
|
+
])])) : (C(), S("svg", le, [...e[3] || (e[3] = [
|
|
487
508
|
_("path", { d: "M12 19V5m-5 5 5-5 5 5" }, null, -1)
|
|
488
509
|
])]))
|
|
489
|
-
], 8,
|
|
510
|
+
], 8, re)
|
|
490
511
|
])
|
|
491
|
-
], 44,
|
|
512
|
+
], 44, Ht));
|
|
492
513
|
}
|
|
493
514
|
});
|
|
494
515
|
export {
|
|
495
|
-
|
|
516
|
+
ce as AgentInput
|
|
496
517
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.agent-input{--agent-input-surface: #fff;--agent-input-text: #171717;--agent-input-placeholder: #626262;--agent-input-border: #d4d4d4;--agent-input-focus: #595959;--agent-input-tag-background: #efefef;--agent-input-tag-color: #06f;--agent-input-agent-color: #292929;--agent-input-action-background: #171717;--agent-input-action-hover: #3b3b3b;--agent-input-action-color: #fff;--agent-input-line-height: 1.5rem;position:relative;box-sizing:border-box;display:grid;gap:.375rem;min-inline-size:0;padding:.75rem;border:1px solid var(--agent-input-border);border-radius:1rem;background:var(--agent-input-surface);color:var(--agent-input-text);color-scheme:light}.agent-input[data-theme=dark]{--agent-input-surface: #1c1c1c;--agent-input-text: #f5f5f5;--agent-input-placeholder: #ababab;--agent-input-border: #4a4a4a;--agent-input-focus: #bdbdbd;--agent-input-tag-background: #363636;--agent-input-agent-color: #f2f2f2;--agent-input-action-background: #f5f5f5;--agent-input-action-hover: #d7d7d7;--agent-input-action-color: #171717;color-scheme:dark}.agent-input:focus-within{border-color:var(--agent-input-focus)}.agent-input__header{min-inline-size:0}.agent-input__body{min-inline-size:0;max-block-size:calc(var(--agent-input-line-height) * var(--agent-input-max-rows));padding-inline:.25rem;overflow:auto}.agent-input__editor{min-block-size:calc(var(--agent-input-line-height) * var(--agent-input-min-rows));overflow-wrap:anywhere;white-space:
|
|
1
|
+
@supports not (float: inline-start){:where([dir=ltr i]){--agent-input-float-start: left}:where([dir=rtl i]){--agent-input-float-start: right}}.agent-input{--agent-input-surface: #fff;--agent-input-text: #171717;--agent-input-placeholder: #626262;--agent-input-border: #d4d4d4;--agent-input-focus: #595959;--agent-input-tag-background: #efefef;--agent-input-tag-color: #06f;--agent-input-agent-color: #292929;--agent-input-action-background: #171717;--agent-input-action-hover: #3b3b3b;--agent-input-action-color: #fff;--agent-input-line-height: 1.5rem;position:relative;box-sizing:border-box;display:grid;gap:.375rem;min-inline-size:0;padding:.75rem;border:1px solid var(--agent-input-border);border-radius:1rem;background:var(--agent-input-surface);color:var(--agent-input-text);color-scheme:light}.agent-input[data-theme=dark]{--agent-input-surface: #1c1c1c;--agent-input-text: #f5f5f5;--agent-input-placeholder: #ababab;--agent-input-border: #4a4a4a;--agent-input-focus: #bdbdbd;--agent-input-tag-background: #363636;--agent-input-agent-color: #f2f2f2;--agent-input-action-background: #f5f5f5;--agent-input-action-hover: #d7d7d7;--agent-input-action-color: #171717;color-scheme:dark}.agent-input:focus-within{border-color:var(--agent-input-focus)}.agent-input__header{min-inline-size:0}.agent-input__body{min-inline-size:0;max-block-size:calc(var(--agent-input-line-height) * var(--agent-input-max-rows));padding-inline:.25rem;overflow:auto}.agent-input__editor{min-block-size:calc(var(--agent-input-line-height) * var(--agent-input-min-rows));overflow-wrap:anywhere;white-space:break-spaces;outline:none;font-size:1rem;line-height:var(--agent-input-line-height)}.agent-input__placeholder{block-size:var(--agent-input-line-height);margin-block-end:calc(-1 * var(--agent-input-line-height));overflow:hidden;color:var(--agent-input-placeholder);font-size:1rem;line-height:var(--agent-input-line-height);text-overflow:ellipsis;white-space:nowrap;pointer-events:none}.agent-input__tag,.agent-input__agent{display:inline-flex;box-sizing:border-box;align-items:center;gap:.3rem;max-inline-size:100%;padding-inline:.4rem;border-radius:.375rem;vertical-align:middle}.agent-input__tag img,.agent-input__agent img{flex:none;inline-size:1rem;block-size:1rem;border-radius:.2rem;object-fit:cover}.agent-input__tag{height:1.25rem;margin-inline:.125rem;max-inline-size:calc(100% - .25rem);padding-block:0;border:0;background:transparent;color:var(--agent-input-tag-color);font:inherit;font-size:.875rem;white-space:nowrap;cursor:pointer}.agent-input__tag:hover,.agent-input__tag:focus-visible{background:var(--agent-input-tag-background)}.agent-input__tag:focus-visible{outline:2px solid var(--agent-input-focus);outline-offset:-2px}.agent-input__agent{float:var(--agent-input-float-start, left);max-inline-size:55%;block-size:var(--agent-input-line-height);margin-inline-end:.375rem;background:var(--agent-input-tag-background);color:var(--agent-input-agent-color);font-size:.875rem}@supports (float: inline-start){.agent-input__agent{--agent-input-float-start: inline-start}}.agent-input__tag-label,.agent-input__agent-label{min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.agent-input__footer{display:flex;justify-content:flex-end;align-items:center;gap:.5rem}.agent-input__footer-content{flex:1 1 0;min-inline-size:0}.agent-input__remove,.agent-input__action{display:grid;flex:none;place-items:center;padding:0;border:0;cursor:pointer}.agent-input__remove svg,.agent-input__action svg{inline-size:1.125rem;block-size:1.125rem}.agent-input__remove path,.agent-input__action path{stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.agent-input__remove{inline-size:1.75rem;block-size:1.5rem;appearance:none;background:transparent;box-shadow:none;outline:none;color:inherit;-webkit-tap-highlight-color:transparent}.agent-input__remove:focus-visible path{stroke-width:2.6}.agent-input__action{inline-size:2.75rem;block-size:2.75rem;border-radius:.75rem;background:var(--agent-input-action-background);color:var(--agent-input-action-color)}.agent-input__action:hover{background:var(--agent-input-action-hover)}.agent-input__action:focus-visible{outline:2px solid var(--agent-input-focus);outline-offset:2px}.agent-input__suggestion{box-sizing:border-box;min-inline-size:0;max-block-size:min(16rem,var(--agent-input-half-viewport, 50vh));overflow:auto;overscroll-behavior:contain;border-block-end:1px solid var(--agent-input-border)}@supports (height: 1dvh){.agent-input__suggestion{--agent-input-half-viewport: 50dvh}}
|
package/dist/types.d.ts
CHANGED