@opentiny/tiny-robot 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/sender/index.js +386 -380
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/dist/sender/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { ref as I, watch as te, reactive as
|
|
1
|
+
import { ref as I, watch as te, reactive as We, computed as K, nextTick as W, defineComponent as be, createElementBlock as O, openBlock as D, createCommentVNode as P, createBlock as Q, unref as T, withCtx as Y, createVNode as G, normalizeClass as oe, resolveDynamicComponent as it, createElementVNode as U, toDisplayString as le, mergeModels as De, useModel as rt, onMounted as ut, useSlots as ct, Transition as ve, renderSlot as se, isRef as Fe, createTextVNode as Le, normalizeStyle as Ie, Fragment as Oe, renderList as Ae, withModifiers as dt } from "vue";
|
|
2
2
|
import { I as ft } from "../index5.js";
|
|
3
|
-
import { g as z, i as pt, t as
|
|
3
|
+
import { g as z, i as pt, t as ht } from "../utils.js";
|
|
4
4
|
import { B as fe } from "../index3.js";
|
|
5
|
-
import { T as
|
|
6
|
-
import { i as
|
|
5
|
+
import { T as Me } from "../index4.js";
|
|
6
|
+
import { i as mt } from "../close.js";
|
|
7
7
|
import { I as gt, L as vt, v as yt, w as bt, P as Ct, _ as St } from "../tiny-robot-svgs.js";
|
|
8
8
|
function wt(t, y) {
|
|
9
|
-
const
|
|
9
|
+
const m = I(t.modelValue || t.defaultValue || ""), a = I(null);
|
|
10
10
|
te(
|
|
11
11
|
() => t.modelValue,
|
|
12
12
|
(f) => {
|
|
13
|
-
f !== void 0 && f !==
|
|
13
|
+
f !== void 0 && f !== m.value && (m.value = f);
|
|
14
14
|
}
|
|
15
15
|
), te(
|
|
16
|
-
() =>
|
|
16
|
+
() => m.value,
|
|
17
17
|
(f) => {
|
|
18
18
|
y("update:modelValue", f);
|
|
19
19
|
}
|
|
20
20
|
);
|
|
21
21
|
const x = (f) => {
|
|
22
|
-
|
|
22
|
+
m.value = f, y("update:modelValue", f);
|
|
23
23
|
}, u = (f) => {
|
|
24
24
|
f == null || f.preventDefault();
|
|
25
|
-
const p =
|
|
25
|
+
const p = m.value;
|
|
26
26
|
!t.disabled && !t.loading && p.trim() && y("submit", p);
|
|
27
27
|
}, i = () => {
|
|
28
|
-
|
|
28
|
+
m.value = "", y("update:modelValue", ""), y("clear");
|
|
29
29
|
}, r = I(!1);
|
|
30
30
|
return {
|
|
31
|
-
inputValue:
|
|
32
|
-
inputWrapper:
|
|
31
|
+
inputValue: m,
|
|
32
|
+
inputWrapper: a,
|
|
33
33
|
isComposing: r,
|
|
34
34
|
handleChange: x,
|
|
35
35
|
handleSubmit: u,
|
|
@@ -39,88 +39,88 @@ function wt(t, y) {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
const y = t.textContent || "",
|
|
44
|
-
return !
|
|
45
|
-
},
|
|
42
|
+
const $e = "", ee = (t) => t.split("").every((y) => y === $e), J = (t) => t.replace(/\u200B/g, ""), ye = () => document.createTextNode($e), Et = (t) => {
|
|
43
|
+
const y = t.textContent || "", m = J(y);
|
|
44
|
+
return !m || m.trim() === "";
|
|
45
|
+
}, Ve = (t) => {
|
|
46
46
|
const y = t.nextSibling;
|
|
47
47
|
if (y && y.nodeType === Node.TEXT_NODE && ee(y.textContent || ""))
|
|
48
48
|
return;
|
|
49
|
-
const
|
|
50
|
-
t.parentNode && t.parentNode.insertBefore(
|
|
51
|
-
},
|
|
52
|
-
Array.from(t.childNodes).forEach((
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
49
|
+
const m = ye();
|
|
50
|
+
t.parentNode && t.parentNode.insertBefore(m, t.nextSibling);
|
|
51
|
+
}, Tt = (t) => {
|
|
52
|
+
Array.from(t.childNodes).forEach((m) => {
|
|
53
|
+
if (m.nodeType === Node.TEXT_NODE && ee(m.textContent || "")) {
|
|
54
|
+
const a = m.previousSibling;
|
|
55
|
+
a && a.nodeType === Node.ELEMENT_NODE && a.classList.contains("template-field") || m.parentNode && m.parentNode.removeChild(m);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
}, R = (
|
|
63
|
-
if (!(
|
|
59
|
+
function _t(t, y, m, a, x, u, i, r, c, f, p, o, b, L) {
|
|
60
|
+
const E = (h) => !(t.disabled || t.loading || h.trim().length === 0 || o.value), v = () => {
|
|
61
|
+
E(m.value) && y("submit", m.value.trim());
|
|
62
|
+
}, R = (h, $) => {
|
|
63
|
+
if (!(h.key === "Enter")) return !1;
|
|
64
64
|
switch ($) {
|
|
65
65
|
case "enter":
|
|
66
|
-
return !
|
|
66
|
+
return !h.shiftKey && !h.ctrlKey && !h.metaKey;
|
|
67
67
|
case "ctrlEnter":
|
|
68
|
-
return (
|
|
68
|
+
return (h.ctrlKey || h.metaKey) && !h.shiftKey;
|
|
69
69
|
case "shiftEnter":
|
|
70
|
-
return
|
|
70
|
+
return h.shiftKey && !h.ctrlKey && !h.metaKey;
|
|
71
71
|
default:
|
|
72
72
|
return !1;
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
return {
|
|
76
|
-
handleKeyPress: (
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
const V =
|
|
81
|
-
|
|
76
|
+
handleKeyPress: (h) => {
|
|
77
|
+
if (a.value) return;
|
|
78
|
+
if (h.key === "Enter" && h.shiftKey && (b == null ? void 0 : b.value) === "single" && L) {
|
|
79
|
+
h.preventDefault(), L();
|
|
80
|
+
const V = h.target, H = V.selectionStart, C = m.value;
|
|
81
|
+
m.value = C.substring(0, H) + `
|
|
82
82
|
` + C.substring(H), setTimeout(() => {
|
|
83
83
|
V.selectionStart = V.selectionEnd = H + 1;
|
|
84
84
|
}, 0);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
87
|
+
if (h.key === "Tab" && u.value && i.value) {
|
|
88
|
+
h.preventDefault(), r();
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
if (u.value) {
|
|
92
|
-
if (
|
|
93
|
-
|
|
92
|
+
if (h.key === "ArrowDown") {
|
|
93
|
+
h.preventDefault(), f("down");
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
96
|
+
if (h.key === "ArrowUp") {
|
|
97
|
+
h.preventDefault(), f("up");
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
100
|
+
if (h.key === "Enter" && i.value) {
|
|
101
|
+
h.preventDefault(), r();
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
106
|
-
u.value ? (c(),
|
|
105
|
+
if (h.key === "Escape") {
|
|
106
|
+
u.value ? (c(), h.preventDefault()) : x.isRecording && (p(), h.preventDefault()), y("escape-press");
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
R(
|
|
109
|
+
R(h, t.submitType) && E(m.value) && (h.preventDefault(), v());
|
|
110
110
|
},
|
|
111
111
|
triggerSubmit: v
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
function Nt(t) {
|
|
115
115
|
const y = (u, i, r) => {
|
|
116
|
-
var L,
|
|
116
|
+
var L, E;
|
|
117
117
|
const { startOffset: c, collapsed: f } = i;
|
|
118
118
|
let p = i.startContainer;
|
|
119
119
|
if ((L = p.parentElement) != null && L.classList.contains("template-field") && (p = p.parentElement), !f) return !1;
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
120
|
+
const o = p.nodeType === Node.TEXT_NODE && c === 0 && u.key === "ArrowLeft", b = p.nodeType === Node.TEXT_NODE && c === (((E = p.textContent) == null ? void 0 : E.length) || 0) && u.key === "ArrowRight";
|
|
121
|
+
if (o || b) {
|
|
122
122
|
let v = null, R = "inside";
|
|
123
|
-
if (
|
|
123
|
+
if (o)
|
|
124
124
|
if (p.parentNode && p.parentNode.classList.contains("template-field"))
|
|
125
125
|
v = p.parentNode, R = "before";
|
|
126
126
|
else {
|
|
@@ -136,47 +136,47 @@ function Nt(t) {
|
|
|
136
136
|
}
|
|
137
137
|
if (v) {
|
|
138
138
|
u.preventDefault();
|
|
139
|
-
const w = document.createRange(),
|
|
140
|
-
return
|
|
139
|
+
const w = document.createRange(), h = z(r);
|
|
140
|
+
return h && (R === "before" ? w.setStartBefore(v) : R === "after" ? w.setStartAfter(v) : (w.selectNodeContents(v), w.collapse(u.key === "ArrowLeft")), h.removeAllRanges(), h.addRange(w)), !0;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
if (p.nodeType === Node.ELEMENT_NODE && p.classList.contains("template-field")) {
|
|
144
144
|
const R = p.textContent || "", w = J(R);
|
|
145
145
|
if (!w || w.trim() === "") {
|
|
146
146
|
u.preventDefault();
|
|
147
|
-
const
|
|
147
|
+
const h = document.createRange(), $ = z(r);
|
|
148
148
|
if (!$) return !0;
|
|
149
149
|
if (u.key === "ArrowLeft")
|
|
150
|
-
|
|
150
|
+
h.setStartBefore(p);
|
|
151
151
|
else {
|
|
152
152
|
const V = p.nextSibling;
|
|
153
|
-
V && V.nodeType === Node.TEXT_NODE && ee(V.textContent || "") ? (
|
|
153
|
+
V && V.nodeType === Node.TEXT_NODE && ee(V.textContent || "") ? (h.setStart(V, 0), h.setEnd(V, 0)) : h.setStartAfter(p);
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return h.collapse(!0), $.removeAllRanges(), $.addRange(h), !0;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
if (p.nodeType === Node.TEXT_NODE && ee(p.textContent || "")) {
|
|
159
159
|
const v = p.previousSibling, R = p.nextSibling;
|
|
160
160
|
u.preventDefault();
|
|
161
|
-
const w = document.createRange(),
|
|
162
|
-
return
|
|
161
|
+
const w = document.createRange(), h = z(r);
|
|
162
|
+
return h && (u.key === "ArrowLeft" ? v && v.nodeType === Node.ELEMENT_NODE && v.classList.contains("template-field") ? (w.selectNodeContents(v), w.collapse(!1)) : w.setStartBefore(p) : R ? R.nodeType === Node.ELEMENT_NODE && R.classList.contains("template-field") ? (w.selectNodeContents(R), w.collapse(!0)) : pt(r) ? (w.setStart(R, 1), w.collapse(!0)) : w.setStartAfter(p) : w.setStartAfter(p), h.removeAllRanges(), h.addRange(w)), !0;
|
|
163
163
|
}
|
|
164
164
|
return !1;
|
|
165
|
-
},
|
|
165
|
+
}, m = (u, i, r) => {
|
|
166
166
|
if (!i.collapsed) return !1;
|
|
167
167
|
const { startContainer: c, startOffset: f } = i;
|
|
168
168
|
if (c.nodeType === Node.TEXT_NODE && ee(c.textContent || "")) {
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
const b =
|
|
172
|
-
if (!
|
|
169
|
+
const o = c.previousSibling;
|
|
170
|
+
if (o && o.nodeType === Node.ELEMENT_NODE && o.classList.contains("template-field")) {
|
|
171
|
+
const b = o, L = b.textContent || "", E = J(L);
|
|
172
|
+
if (!E || E.trim() === "") {
|
|
173
173
|
u.preventDefault();
|
|
174
174
|
const v = b.previousSibling, R = c.nextSibling;
|
|
175
175
|
b.parentNode && b.parentNode.removeChild(b), c.parentNode && c.parentNode.removeChild(c);
|
|
176
176
|
const w = z(r);
|
|
177
177
|
if (w) {
|
|
178
|
-
const
|
|
179
|
-
v ? v.nodeType === Node.ELEMENT_NODE && v.classList.contains("template-field") ? (
|
|
178
|
+
const h = document.createRange();
|
|
179
|
+
v ? v.nodeType === Node.ELEMENT_NODE && v.classList.contains("template-field") ? (h.selectNodeContents(v), h.collapse(!1)) : v.nodeType === Node.TEXT_NODE && ee(v.textContent || "") ? (h.setStart(v, 0), h.setEnd(v, 0)) : h.setStartAfter(v) : R ? h.setStartBefore(R) : h.setStart(r, 0), h.collapse(!0), w.removeAllRanges(), w.addRange(h);
|
|
180
180
|
}
|
|
181
181
|
return t.handleInput(), !0;
|
|
182
182
|
} else {
|
|
@@ -191,37 +191,37 @@ function Nt(t) {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
if (c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && c.textContent) {
|
|
194
|
-
const
|
|
195
|
-
if (J(
|
|
194
|
+
const o = c.textContent;
|
|
195
|
+
if (J(o).length === 1 && f === o.length) {
|
|
196
196
|
u.preventDefault(), c.textContent = "";
|
|
197
|
-
const L = c.parentNode,
|
|
198
|
-
if (
|
|
197
|
+
const L = c.parentNode, E = z(r);
|
|
198
|
+
if (E) {
|
|
199
199
|
const v = document.createRange();
|
|
200
|
-
v.selectNodeContents(L), v.collapse(!0),
|
|
200
|
+
v.selectNodeContents(L), v.collapse(!0), E.removeAllRanges(), E.addRange(v);
|
|
201
201
|
}
|
|
202
202
|
return t.handleInput(), !0;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
if (f === 0) {
|
|
206
|
-
let
|
|
207
|
-
if (c.nodeType === Node.ELEMENT_NODE && c.classList.contains("template-field") ?
|
|
206
|
+
let o = null;
|
|
207
|
+
if (c.nodeType === Node.ELEMENT_NODE && c.classList.contains("template-field") ? o = c : c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && (o = c.parentNode), o) {
|
|
208
208
|
u.preventDefault();
|
|
209
209
|
const b = z(r);
|
|
210
|
-
return b && (i.setStartBefore(
|
|
210
|
+
return b && (i.setStartBefore(o), i.collapse(!0), b.removeAllRanges(), b.addRange(i)), !0;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
return !1;
|
|
214
|
-
},
|
|
214
|
+
}, a = (u, i, r) => {
|
|
215
215
|
if (!i.collapsed) return !1;
|
|
216
216
|
const { startContainer: c, startOffset: f } = i;
|
|
217
217
|
if (c.nodeType === Node.TEXT_NODE && c.parentNode && c.parentNode.classList.contains("template-field") && c.textContent) {
|
|
218
|
-
const
|
|
219
|
-
if (f ===
|
|
218
|
+
const o = c.textContent, b = J(o);
|
|
219
|
+
if (f === o.length && b.length === 1) {
|
|
220
220
|
u.preventDefault(), c.textContent = "";
|
|
221
|
-
const L = c.parentNode,
|
|
222
|
-
if (
|
|
221
|
+
const L = c.parentNode, E = z(r);
|
|
222
|
+
if (E) {
|
|
223
223
|
const v = document.createRange();
|
|
224
|
-
v.selectNodeContents(L), v.collapse(!0),
|
|
224
|
+
v.selectNodeContents(L), v.collapse(!0), E.removeAllRanges(), E.addRange(v);
|
|
225
225
|
}
|
|
226
226
|
return t.handleInput(), !0;
|
|
227
227
|
}
|
|
@@ -240,42 +240,42 @@ function Nt(t) {
|
|
|
240
240
|
u.preventDefault(), t.onSubmit(t.getValueFromDOM());
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
|
-
(u.key === "ArrowLeft" || u.key === "ArrowRight") && !u.shiftKey && y(u, c, i) || u.key === "Backspace" &&
|
|
243
|
+
(u.key === "ArrowLeft" || u.key === "ArrowRight") && !u.shiftKey && y(u, c, i) || u.key === "Backspace" && m(u, c, i) || u.key === "Delete" && a(u, c, i);
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
function xt(t) {
|
|
248
|
-
const y =
|
|
248
|
+
const y = We({
|
|
249
249
|
isRecording: !1,
|
|
250
250
|
isSupported: typeof window < "u" && "webkitSpeechRecognition" in window || "SpeechRecognition" in window,
|
|
251
251
|
error: void 0
|
|
252
|
-
}),
|
|
253
|
-
|
|
252
|
+
}), m = y.isSupported ? new (window.webkitSpeechRecognition || window.SpeechRecognition)() : void 0;
|
|
253
|
+
m !== void 0 && (m.continuous = t.continuous ?? !1, m.interimResults = t.interimResults ?? !0, m.lang = t.lang ?? navigator.language, m.onstart = () => {
|
|
254
254
|
var i;
|
|
255
255
|
y.isRecording = !0, y.error = void 0, (i = t.onStart) == null || i.call(t);
|
|
256
|
-
},
|
|
256
|
+
}, m.onend = () => {
|
|
257
257
|
var i;
|
|
258
258
|
y.isRecording = !1, (i = t.onEnd) == null || i.call(t);
|
|
259
|
-
},
|
|
259
|
+
}, m.onresult = (i) => {
|
|
260
260
|
var c, f;
|
|
261
261
|
const r = Array.from(i.results).map((p) => p[0].transcript).join("");
|
|
262
262
|
i.results[0].isFinal ? (c = t.onFinal) == null || c.call(t, r) : (f = t.onInterim) == null || f.call(t, r);
|
|
263
|
-
},
|
|
263
|
+
}, m.onerror = (i) => {
|
|
264
264
|
var r;
|
|
265
265
|
y.error = new Error(i.error), y.isRecording = !1, (r = t.onError) == null || r.call(t, y.error);
|
|
266
266
|
});
|
|
267
|
-
const
|
|
267
|
+
const a = () => {
|
|
268
268
|
var i;
|
|
269
|
-
if (!
|
|
269
|
+
if (!m) {
|
|
270
270
|
const r = new Error("浏览器不支持语音识别");
|
|
271
271
|
y.error = r, (i = t.onError) == null || i.call(t, r);
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
274
|
if (y.isRecording) {
|
|
275
275
|
try {
|
|
276
|
-
|
|
276
|
+
m.stop(), setTimeout(() => {
|
|
277
277
|
try {
|
|
278
|
-
|
|
278
|
+
m.start();
|
|
279
279
|
} catch (r) {
|
|
280
280
|
u(r);
|
|
281
281
|
}
|
|
@@ -286,14 +286,14 @@ function xt(t) {
|
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
288
|
try {
|
|
289
|
-
|
|
289
|
+
m.start();
|
|
290
290
|
} catch (r) {
|
|
291
291
|
u(r);
|
|
292
292
|
}
|
|
293
293
|
}, x = () => {
|
|
294
|
-
if (
|
|
294
|
+
if (m && y.isRecording)
|
|
295
295
|
try {
|
|
296
|
-
|
|
296
|
+
m.stop();
|
|
297
297
|
} catch (i) {
|
|
298
298
|
u(i);
|
|
299
299
|
}
|
|
@@ -303,17 +303,17 @@ function xt(t) {
|
|
|
303
303
|
};
|
|
304
304
|
return {
|
|
305
305
|
speechState: y,
|
|
306
|
-
start:
|
|
306
|
+
start: a,
|
|
307
307
|
stop: x
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
310
|
const kt = (t, y) => {
|
|
311
311
|
if (!y || !t)
|
|
312
312
|
return [{ text: t, isMatch: !1 }];
|
|
313
|
-
const
|
|
313
|
+
const m = t.toLowerCase(), a = y.toLowerCase(), x = [];
|
|
314
314
|
let u = 0;
|
|
315
|
-
for (; u <
|
|
316
|
-
const f =
|
|
315
|
+
for (; u < m.length; ) {
|
|
316
|
+
const f = m.indexOf(a, u);
|
|
317
317
|
if (f === -1) break;
|
|
318
318
|
x.push({
|
|
319
319
|
start: f,
|
|
@@ -345,33 +345,33 @@ const kt = (t, y) => {
|
|
|
345
345
|
isMatch: !1
|
|
346
346
|
}), r;
|
|
347
347
|
};
|
|
348
|
-
function Rt(t, y,
|
|
349
|
-
const x = I(!1), u = I(-1), i = I(-1), r = I(""), c = I(!1), f = I(null), p = I(!1),
|
|
350
|
-
if (!t.suggestions || !
|
|
351
|
-
const e =
|
|
348
|
+
function Rt(t, y, m, a) {
|
|
349
|
+
const x = I(!1), u = I(-1), i = I(-1), r = I(""), c = I(!1), f = I(null), p = I(!1), o = I(null), b = K(() => {
|
|
350
|
+
if (!t.suggestions || !m.value || t.template) return [];
|
|
351
|
+
const e = m.value.toLowerCase();
|
|
352
352
|
return t.suggestions.filter((l) => l.toLowerCase().includes(e));
|
|
353
|
-
}), L =
|
|
353
|
+
}), L = K(() => {
|
|
354
354
|
let e = -1;
|
|
355
|
-
return
|
|
356
|
-
}),
|
|
357
|
-
if (
|
|
355
|
+
return o.value === "mouse" && i.value !== -1 ? e = i.value : o.value === "keyboard" && u.value !== -1 && (e = u.value), b.value[e] || null;
|
|
356
|
+
}), E = (e) => e === u.value || e === i.value, v = (e) => {
|
|
357
|
+
if (o.value === null) {
|
|
358
358
|
r.value = "", c.value = !1;
|
|
359
359
|
return;
|
|
360
360
|
}
|
|
361
361
|
const l = e || L.value;
|
|
362
|
-
l &&
|
|
362
|
+
l && m.value && l.toLowerCase().startsWith(m.value.toLowerCase()) ? (r.value = l.substring(m.value.length), c.value = !0) : (r.value = "", c.value = !1);
|
|
363
363
|
}, R = () => {
|
|
364
|
-
x.value = !1, u.value = -1, i.value = -1,
|
|
364
|
+
x.value = !1, u.value = -1, i.value = -1, o.value = null, r.value = "", c.value = !1;
|
|
365
365
|
}, w = () => {
|
|
366
|
-
x.value = !0, u.value = -1, i.value = -1,
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
x.value = !0, u.value = -1, i.value = -1, o.value = null, v();
|
|
367
|
+
}, h = () => {
|
|
368
|
+
a.value || p.value || W(() => {
|
|
369
|
+
m.value && t.suggestions && t.suggestions.length > 0 && !t.template && b.value.length > 0 ? w() : R();
|
|
370
370
|
});
|
|
371
371
|
};
|
|
372
|
-
te(
|
|
372
|
+
te(m, h), te(() => t.suggestions, h);
|
|
373
373
|
const $ = (e) => {
|
|
374
|
-
p.value = !0,
|
|
374
|
+
p.value = !0, m.value = e, y("update:modelValue", e), y("suggestion-select", e), H(), W(() => {
|
|
375
375
|
p.value = !1;
|
|
376
376
|
});
|
|
377
377
|
}, V = () => {
|
|
@@ -386,15 +386,15 @@ function Rt(t, y, h, o) {
|
|
|
386
386
|
suggestionsListRef: f,
|
|
387
387
|
filteredSuggestions: b,
|
|
388
388
|
activeSuggestion: L,
|
|
389
|
-
isItemHighlighted:
|
|
389
|
+
isItemHighlighted: E,
|
|
390
390
|
updateCompletionPlaceholder: v,
|
|
391
|
-
updateSuggestionsState:
|
|
391
|
+
updateSuggestionsState: h,
|
|
392
392
|
selectSuggestion: $,
|
|
393
393
|
acceptCurrentSuggestion: V,
|
|
394
394
|
closeSuggestionsPopup: H,
|
|
395
395
|
navigateSuggestions: (e) => {
|
|
396
396
|
if (!x.value || b.value.length === 0) return;
|
|
397
|
-
|
|
397
|
+
o.value = "keyboard", u.value === -1 ? u.value = e === "down" ? 0 : b.value.length - 1 : e === "down" ? u.value = (u.value + 1) % b.value.length : u.value = (u.value - 1 + b.value.length) % b.value.length;
|
|
398
398
|
const l = b.value[u.value];
|
|
399
399
|
l && v(l);
|
|
400
400
|
const n = f.value;
|
|
@@ -404,15 +404,15 @@ function Rt(t, y, h, o) {
|
|
|
404
404
|
}
|
|
405
405
|
},
|
|
406
406
|
handleSuggestionItemHover: (e) => {
|
|
407
|
-
|
|
407
|
+
o.value = "mouse", i.value = e, v(b.value[e]);
|
|
408
408
|
},
|
|
409
409
|
handleSuggestionItemLeave: () => {
|
|
410
410
|
if (i.value = -1, u.value !== -1) {
|
|
411
|
-
|
|
411
|
+
o.value = "keyboard";
|
|
412
412
|
const e = b.value[u.value];
|
|
413
413
|
e && v(e);
|
|
414
414
|
} else
|
|
415
|
-
|
|
415
|
+
o.value = null, v();
|
|
416
416
|
},
|
|
417
417
|
handleClickOutside: () => {
|
|
418
418
|
H();
|
|
@@ -424,9 +424,9 @@ const Dt = { class: "action-buttons" }, Ft = {
|
|
|
424
424
|
key: 0,
|
|
425
425
|
class: "action-buttons__utility"
|
|
426
426
|
}, Lt = { class: "action-buttons__submit-content" }, It = {
|
|
427
|
-
key:
|
|
428
|
-
class: "action-buttons__cancel"
|
|
429
|
-
},
|
|
427
|
+
key: 0,
|
|
428
|
+
class: "action-buttons__cancel-text"
|
|
429
|
+
}, Be = /* @__PURE__ */ be({
|
|
430
430
|
__name: "ActionButtons",
|
|
431
431
|
props: {
|
|
432
432
|
loading: { type: Boolean, default: !1 },
|
|
@@ -441,37 +441,38 @@ const Dt = { class: "action-buttons" }, Ft = {
|
|
|
441
441
|
allowFiles: { type: Boolean, default: !1 },
|
|
442
442
|
submitType: { default: "enter" },
|
|
443
443
|
showShortcuts: { type: Boolean },
|
|
444
|
-
isOverLimit: { type: Boolean, default: !1 }
|
|
444
|
+
isOverLimit: { type: Boolean, default: !1 },
|
|
445
|
+
stopText: { default: void 0 }
|
|
445
446
|
},
|
|
446
447
|
emits: ["clear", "toggle-speech", "submit", "cancel"],
|
|
447
448
|
setup(t, { emit: y }) {
|
|
448
|
-
const
|
|
449
|
+
const m = mt(), a = t, x = y, u = K(() => a.allowSpeech), i = K(() => a.speechStatus.isRecording), r = K(() => a.disabled), c = K(() => r.value || a.isOverLimit), f = K(() => a.allowFiles || a.allowSpeech || a.showClear), p = () => {
|
|
449
450
|
r.value || x("clear");
|
|
450
|
-
},
|
|
451
|
+
}, o = () => {
|
|
451
452
|
if (!r.value) {
|
|
452
|
-
const
|
|
453
|
-
x("toggle-speech",
|
|
453
|
+
const E = !a.speechStatus.isRecording;
|
|
454
|
+
x("toggle-speech", E);
|
|
454
455
|
}
|
|
455
456
|
}, b = () => {
|
|
456
457
|
c.value || x("submit");
|
|
457
458
|
}, L = () => {
|
|
458
459
|
r.value || x("cancel");
|
|
459
460
|
};
|
|
460
|
-
return (
|
|
461
|
-
f.value ? (D(),
|
|
462
|
-
|
|
461
|
+
return (E, v) => (D(), O("div", Dt, [
|
|
462
|
+
f.value ? (D(), O("div", Ft, [
|
|
463
|
+
E.allowFiles && !E.loading ? (D(), Q(T(Me), {
|
|
463
464
|
key: 0,
|
|
464
465
|
content: "上传文件",
|
|
465
466
|
placement: "top"
|
|
466
467
|
}, {
|
|
467
468
|
default: Y(() => [
|
|
468
|
-
G(
|
|
469
|
+
G(T(fe), {
|
|
469
470
|
class: "action-buttons__button action-buttons__file-button",
|
|
470
471
|
type: "text",
|
|
471
472
|
disabled: r.value
|
|
472
473
|
}, {
|
|
473
474
|
default: Y(() => [
|
|
474
|
-
G(
|
|
475
|
+
G(T(gt), {
|
|
475
476
|
class: "action-buttons__icon",
|
|
476
477
|
alt: "上传文件"
|
|
477
478
|
})
|
|
@@ -480,64 +481,67 @@ const Dt = { class: "action-buttons" }, Ft = {
|
|
|
480
481
|
}, 8, ["disabled"])
|
|
481
482
|
]),
|
|
482
483
|
_: 1
|
|
483
|
-
})) :
|
|
484
|
-
u.value && !
|
|
484
|
+
})) : P("", !0),
|
|
485
|
+
u.value && !E.loading ? (D(), Q(T(fe), {
|
|
485
486
|
key: 1,
|
|
486
|
-
class:
|
|
487
|
+
class: oe(["action-buttons__button action-buttons__speech-button", { "is-recording": i.value }]),
|
|
487
488
|
type: "text",
|
|
488
489
|
disabled: r.value,
|
|
489
|
-
onClick:
|
|
490
|
+
onClick: o
|
|
490
491
|
}, {
|
|
491
492
|
default: Y(() => [
|
|
492
|
-
i.value ? (D(), Q(
|
|
493
|
+
i.value ? (D(), Q(T(yt), {
|
|
493
494
|
key: 1,
|
|
494
495
|
class: "action-buttons__icon action-buttons__icon--recording",
|
|
495
496
|
alt: "语音中"
|
|
496
|
-
})) : (D(), Q(
|
|
497
|
+
})) : (D(), Q(T(vt), {
|
|
497
498
|
key: 0,
|
|
498
499
|
class: "action-buttons__icon",
|
|
499
500
|
alt: "录音"
|
|
500
501
|
}))
|
|
501
502
|
]),
|
|
502
503
|
_: 1
|
|
503
|
-
}, 8, ["disabled", "class"])) :
|
|
504
|
-
|
|
504
|
+
}, 8, ["disabled", "class"])) : P("", !0),
|
|
505
|
+
E.showClear ? (D(), Q(T(Me), {
|
|
505
506
|
key: 2,
|
|
506
507
|
content: "清空内容",
|
|
507
508
|
placement: "top"
|
|
508
509
|
}, {
|
|
509
510
|
default: Y(() => [
|
|
510
|
-
G(
|
|
511
|
+
G(T(fe), {
|
|
511
512
|
class: "action-buttons__button action-buttons__clear-button",
|
|
512
513
|
type: "text",
|
|
513
|
-
disabled: r.value || !
|
|
514
|
+
disabled: r.value || !E.hasContent,
|
|
514
515
|
onClick: p
|
|
515
516
|
}, {
|
|
516
517
|
default: Y(() => [
|
|
517
|
-
(D(), Q(it(
|
|
518
|
+
(D(), Q(it(T(m)), { class: "action-buttons__icon action-buttons__icon--close" }))
|
|
518
519
|
]),
|
|
519
520
|
_: 1
|
|
520
521
|
}, 8, ["disabled"])
|
|
521
522
|
]),
|
|
522
523
|
_: 1
|
|
523
|
-
})) :
|
|
524
|
-
])) :
|
|
525
|
-
|
|
524
|
+
})) : P("", !0)
|
|
525
|
+
])) : P("", !0),
|
|
526
|
+
E.hasContent || E.loading ? (D(), Q(T(fe), {
|
|
526
527
|
key: 1,
|
|
527
528
|
type: "text",
|
|
528
529
|
class: "action-buttons__button action-buttons__submit",
|
|
529
|
-
disabled:
|
|
530
|
-
onClick: v[0] || (v[0] = (R) =>
|
|
530
|
+
disabled: E.loading ? r.value : c.value,
|
|
531
|
+
onClick: v[0] || (v[0] = (R) => E.loading ? L() : b())
|
|
531
532
|
}, {
|
|
532
533
|
default: Y(() => [
|
|
533
534
|
U("div", Lt, [
|
|
534
|
-
|
|
535
|
-
|
|
535
|
+
E.loading ? (D(), O("div", {
|
|
536
|
+
key: 1,
|
|
537
|
+
class: oe(["action-buttons__cancel", { "action-buttons__cancel--icon-only": !E.stopText }])
|
|
538
|
+
}, [
|
|
539
|
+
G(T(Ct), {
|
|
536
540
|
class: "action-buttons__icon action-buttons__icon--stop",
|
|
537
|
-
alt: "
|
|
541
|
+
alt: "停止"
|
|
538
542
|
}),
|
|
539
|
-
|
|
540
|
-
])) : (D(), Q(
|
|
543
|
+
E.stopText ? (D(), O("span", It, le(E.stopText), 1)) : P("", !0)
|
|
544
|
+
], 2)) : (D(), Q(T(bt), {
|
|
541
545
|
key: 0,
|
|
542
546
|
class: "action-buttons__icon action-buttons__icon--send",
|
|
543
547
|
alt: "发送"
|
|
@@ -545,13 +549,13 @@ const Dt = { class: "action-buttons" }, Ft = {
|
|
|
545
549
|
])
|
|
546
550
|
]),
|
|
547
551
|
_: 1
|
|
548
|
-
}, 8, ["disabled"])) :
|
|
552
|
+
}, 8, ["disabled"])) : P("", !0)
|
|
549
553
|
]));
|
|
550
554
|
}
|
|
551
555
|
});
|
|
552
556
|
function Ot(t, y) {
|
|
553
|
-
const
|
|
554
|
-
Object.assign(
|
|
557
|
+
const m = I(!1), a = We({ ...y }), x = (e) => {
|
|
558
|
+
Object.assign(a, e);
|
|
555
559
|
}, u = (e) => {
|
|
556
560
|
const l = [];
|
|
557
561
|
let n = 0;
|
|
@@ -571,24 +575,24 @@ function Ot(t, y) {
|
|
|
571
575
|
} else if (n.nodeType === Node.ELEMENT_NODE) {
|
|
572
576
|
const g = n;
|
|
573
577
|
if (g.classList.contains("template-field")) {
|
|
574
|
-
const
|
|
575
|
-
s += J(
|
|
578
|
+
const _ = g.textContent || "";
|
|
579
|
+
s += J(_);
|
|
576
580
|
} else if (g.tagName.toLowerCase() === "span") {
|
|
577
|
-
const
|
|
578
|
-
s += J(
|
|
581
|
+
const _ = g.textContent || "";
|
|
582
|
+
s += J(_);
|
|
579
583
|
} else if (g.tagName.toLowerCase() === "br")
|
|
580
584
|
s += `
|
|
581
585
|
`;
|
|
582
586
|
else
|
|
583
|
-
for (const
|
|
584
|
-
s += l(
|
|
587
|
+
for (const _ of Array.from(g.childNodes))
|
|
588
|
+
s += l(_);
|
|
585
589
|
}
|
|
586
590
|
return s;
|
|
587
591
|
};
|
|
588
592
|
return t.value.childNodes.forEach((n) => {
|
|
589
593
|
e += l(n);
|
|
590
594
|
}), e;
|
|
591
|
-
}, r = (e) =>
|
|
595
|
+
}, r = (e) => a.initialValues && typeof a.initialValues[e] == "string" ? a.initialValues[e] : "", c = (e, l) => {
|
|
592
596
|
const n = document.createElement("span");
|
|
593
597
|
return n.className = "template-field", n.setAttribute("data-placeholder", e), l && (n.textContent = l), W(() => {
|
|
594
598
|
f(n, l || "");
|
|
@@ -600,19 +604,19 @@ function Ot(t, y) {
|
|
|
600
604
|
s ? p(e, s, !0) : (e.style.minWidth = "", e.style.width = "");
|
|
601
605
|
} else
|
|
602
606
|
p(e, n, !1);
|
|
603
|
-
|
|
607
|
+
Ve(e);
|
|
604
608
|
}, p = (e, l, n) => {
|
|
605
609
|
const s = document.createElement("span");
|
|
606
610
|
s.className = "template-field", s.style.visibility = "hidden", s.style.position = "absolute", s.style.top = "-9999px", s.style.left = "-9999px", s.style.whiteSpace = "nowrap", s.style.padding = "3px 8px", s.style.margin = "0 2px", s.style.boxSizing = "border-box", s.textContent = l, document.body.appendChild(s);
|
|
607
|
-
const g = getComputedStyle(s),
|
|
611
|
+
const g = getComputedStyle(s), _ = s.offsetWidth, A = parseFloat(g.fontSize);
|
|
608
612
|
document.body.removeChild(s);
|
|
609
|
-
const M = n ? 1.5 : 2, j =
|
|
613
|
+
const M = n ? 1.5 : 2, j = _ / A, B = Math.max(M, Math.ceil(j));
|
|
610
614
|
e.style.setProperty("min-width", `${B}em`, "important");
|
|
611
615
|
const X = 20;
|
|
612
616
|
B > X ? (e.style.setProperty("max-width", `${X}em`, "important"), e.style.setProperty("white-space", "normal", "important"), e.style.setProperty("word-break", "break-word", "important")) : e.style.removeProperty("max-width");
|
|
613
|
-
},
|
|
617
|
+
}, o = (e) => {
|
|
614
618
|
const n = (e === void 0 ? i() : e).trim().length > 0;
|
|
615
|
-
|
|
619
|
+
m.value !== n && (m.value = n, a.onContentStatusChange(n));
|
|
616
620
|
}, b = (e, l = "inside", n = !1) => {
|
|
617
621
|
W(() => {
|
|
618
622
|
const s = z(t.value);
|
|
@@ -640,64 +644,64 @@ function Ot(t, y) {
|
|
|
640
644
|
l.selectNodeContents(e), l.collapse(!1), n && (n.removeAllRanges(), n.addRange(l)), e.focus();
|
|
641
645
|
}
|
|
642
646
|
});
|
|
643
|
-
},
|
|
647
|
+
}, E = (e, l) => {
|
|
644
648
|
const n = t.value;
|
|
645
649
|
if (!n) return null;
|
|
646
650
|
n.innerHTML = "";
|
|
647
651
|
let s = null;
|
|
648
|
-
if (!l || l ===
|
|
652
|
+
if (!l || l === a.template)
|
|
649
653
|
e.forEach((g) => {
|
|
650
654
|
if (g.type === "field") {
|
|
651
|
-
const
|
|
652
|
-
n.appendChild(
|
|
655
|
+
const _ = r(g.content), A = c(g.content, _);
|
|
656
|
+
n.appendChild(A);
|
|
653
657
|
const M = ye();
|
|
654
|
-
n.appendChild(M), s || (s =
|
|
658
|
+
n.appendChild(M), s || (s = A);
|
|
655
659
|
} else
|
|
656
660
|
n.appendChild(document.createTextNode(g.content));
|
|
657
|
-
}),
|
|
661
|
+
}), a.initialValues && Object.keys(a.initialValues).length > 0 && W(() => {
|
|
658
662
|
const g = i();
|
|
659
|
-
g !==
|
|
663
|
+
g !== a.value && (a.onValueChange(g), a.onInput(g));
|
|
660
664
|
});
|
|
661
665
|
else {
|
|
662
666
|
const g = v(e, l);
|
|
663
|
-
g.success ? g.elements.forEach((
|
|
664
|
-
if (n.appendChild(
|
|
665
|
-
const
|
|
666
|
-
n.appendChild(
|
|
667
|
+
g.success ? g.elements.forEach((_) => {
|
|
668
|
+
if (n.appendChild(_.node), _.isField) {
|
|
669
|
+
const A = ye();
|
|
670
|
+
n.appendChild(A);
|
|
667
671
|
}
|
|
668
|
-
|
|
672
|
+
_.isField && !s && (s = _.node);
|
|
669
673
|
}) : (n.appendChild(document.createTextNode(l)), s = null);
|
|
670
674
|
}
|
|
671
675
|
return s;
|
|
672
676
|
}, v = (e, l) => {
|
|
673
677
|
const n = [];
|
|
674
|
-
let s = 0, g = 0,
|
|
675
|
-
for (; g < e.length && s <= l.length &&
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
l.substring(s).startsWith(
|
|
679
|
-
node: document.createTextNode(
|
|
678
|
+
let s = 0, g = 0, _ = !0;
|
|
679
|
+
for (; g < e.length && s <= l.length && _; ) {
|
|
680
|
+
const A = e[g];
|
|
681
|
+
if (A.type === "text")
|
|
682
|
+
l.substring(s).startsWith(A.content) ? (n.push({
|
|
683
|
+
node: document.createTextNode(A.content),
|
|
680
684
|
isField: !1
|
|
681
|
-
}), s +=
|
|
685
|
+
}), s += A.content.length, g++) : _ = !1;
|
|
682
686
|
else {
|
|
683
687
|
let M = "";
|
|
684
688
|
const j = e.find((B, X) => X > g && B.type === "text");
|
|
685
689
|
if (j) {
|
|
686
690
|
const B = l.substring(s), X = B.indexOf(j.content);
|
|
687
|
-
X !== -1 ? (M = B.substring(0, X), s += M.length) :
|
|
691
|
+
X !== -1 ? (M = B.substring(0, X), s += M.length) : _ = !1;
|
|
688
692
|
} else
|
|
689
693
|
M = l.substring(s), s = l.length;
|
|
690
|
-
if (
|
|
691
|
-
const B = c(
|
|
694
|
+
if (_) {
|
|
695
|
+
const B = c(A.content, M);
|
|
692
696
|
n.push({ node: B, isField: !0 }), g++;
|
|
693
697
|
}
|
|
694
698
|
}
|
|
695
699
|
}
|
|
696
|
-
if (
|
|
697
|
-
for (let
|
|
698
|
-
const M = e[
|
|
700
|
+
if (_ && g < e.length)
|
|
701
|
+
for (let A = g; A < e.length; A++) {
|
|
702
|
+
const M = e[A];
|
|
699
703
|
if (M.type === "field") {
|
|
700
|
-
const j = !
|
|
704
|
+
const j = !a.value || a.value === "" ? r(M.content) : "", B = c(M.content, j);
|
|
701
705
|
n.push({ node: B, isField: !0 });
|
|
702
706
|
} else
|
|
703
707
|
n.push({
|
|
@@ -705,28 +709,28 @@ function Ot(t, y) {
|
|
|
705
709
|
isField: !1
|
|
706
710
|
});
|
|
707
711
|
}
|
|
708
|
-
return { success:
|
|
712
|
+
return { success: _, elements: n };
|
|
709
713
|
}, R = () => {
|
|
710
714
|
if (!t.value) return;
|
|
711
|
-
|
|
712
|
-
const e = u(
|
|
713
|
-
|
|
715
|
+
a.isInternalUpdate = !0;
|
|
716
|
+
const e = u(a.template), l = E(e, a.value);
|
|
717
|
+
o(), W(() => {
|
|
714
718
|
if (S(), l) {
|
|
715
719
|
const n = l.textContent || "", s = J(n);
|
|
716
720
|
s && s.trim() !== "" ? b(l, "inside", !1) : b(l, "inside", !0);
|
|
717
721
|
} else
|
|
718
722
|
L();
|
|
719
|
-
|
|
723
|
+
a.isInternalUpdate = !1;
|
|
720
724
|
});
|
|
721
725
|
}, w = () => {
|
|
722
|
-
if (
|
|
723
|
-
$(), C(),
|
|
726
|
+
if (a.isComposing) return;
|
|
727
|
+
$(), C(), h(), S();
|
|
724
728
|
const e = i();
|
|
725
|
-
e !==
|
|
726
|
-
},
|
|
729
|
+
e !== a.value && (a.onValueChange(e), a.onInput(e)), o(e), e === "" && t.value && Array.from(t.value.childNodes).every((n) => n.nodeType === Node.ELEMENT_NODE && n.classList.contains("template-field") ? Et(n) : !!(n.nodeType === Node.TEXT_NODE && ee(n.textContent || ""))) && $();
|
|
730
|
+
}, h = () => {
|
|
727
731
|
if (!t.value) return;
|
|
728
|
-
|
|
729
|
-
|
|
732
|
+
Tt(t.value), t.value.querySelectorAll(".template-field").forEach((l) => {
|
|
733
|
+
Ve(l);
|
|
730
734
|
});
|
|
731
735
|
}, $ = () => {
|
|
732
736
|
if (!t.value) return;
|
|
@@ -745,9 +749,9 @@ function Ot(t, y) {
|
|
|
745
749
|
l.parentNode && l.parentNode.removeChild(l);
|
|
746
750
|
});
|
|
747
751
|
}, V = (e) => {
|
|
748
|
-
if (!
|
|
752
|
+
if (!a.template || !a.initialValues)
|
|
749
753
|
return "字段";
|
|
750
|
-
for (const [l, n] of Object.entries(
|
|
754
|
+
for (const [l, n] of Object.entries(a.initialValues))
|
|
751
755
|
if (n === e)
|
|
752
756
|
return l;
|
|
753
757
|
return e.length <= 2 || /^[[\]{}()]+$/.test(e) || e.includes("[") && e.includes("]") ? e : "字段";
|
|
@@ -763,14 +767,14 @@ function Ot(t, y) {
|
|
|
763
767
|
}, C = () => {
|
|
764
768
|
if (!t.value) return;
|
|
765
769
|
t.value.querySelectorAll("span").forEach((l) => {
|
|
766
|
-
const n = l, s = n.style, g = n.classList.contains("template-field"),
|
|
767
|
-
if (g &&
|
|
770
|
+
const n = l, s = n.style, g = n.classList.contains("template-field"), _ = n.hasAttribute("data-placeholder");
|
|
771
|
+
if (g && _)
|
|
768
772
|
return;
|
|
769
|
-
const
|
|
773
|
+
const A = s.backgroundColor && // 标准格式
|
|
770
774
|
(s.backgroundColor === "rgba(0, 0, 0, 0.05)" || s.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
|
|
771
775
|
s.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || s.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
|
|
772
776
|
s.backgroundColor.toLowerCase().includes("0.05") || s.backgroundColor.toLowerCase().includes("0.08")), M = s.borderRadius === "4px" || s.padding === "3px 8px" || s.margin === "0px 2px" || s.whiteSpace === "nowrap" && s.padding && s.margin;
|
|
773
|
-
if (
|
|
777
|
+
if (A || M || _) {
|
|
774
778
|
if (n.className = "template-field", !n.getAttribute("data-placeholder")) {
|
|
775
779
|
const B = H(n);
|
|
776
780
|
B && n.setAttribute("data-placeholder", B);
|
|
@@ -789,7 +793,7 @@ function Ot(t, y) {
|
|
|
789
793
|
};
|
|
790
794
|
return {
|
|
791
795
|
// 状态
|
|
792
|
-
hasContent:
|
|
796
|
+
hasContent: m,
|
|
793
797
|
// 解析和DOM操作
|
|
794
798
|
parseTemplateToParts: u,
|
|
795
799
|
getValueFromDOM: i,
|
|
@@ -800,10 +804,10 @@ function Ot(t, y) {
|
|
|
800
804
|
setCursorToEnd: L,
|
|
801
805
|
// DOM更新
|
|
802
806
|
updateEditorDOM: R,
|
|
803
|
-
renderTemplateToDOM:
|
|
807
|
+
renderTemplateToDOM: E,
|
|
804
808
|
// 事件处理
|
|
805
809
|
handleInput: w,
|
|
806
|
-
checkHasContent:
|
|
810
|
+
checkHasContent: o,
|
|
807
811
|
cleanupEmptyTextNodes: $,
|
|
808
812
|
// 推断 placeholder
|
|
809
813
|
inferPlaceholderForContent: V,
|
|
@@ -811,19 +815,19 @@ function Ot(t, y) {
|
|
|
811
815
|
// 方法
|
|
812
816
|
resetFields: () => {
|
|
813
817
|
if (!t.value) return;
|
|
814
|
-
|
|
818
|
+
a.isInternalUpdate = !0;
|
|
815
819
|
const e = t.value;
|
|
816
820
|
e.innerHTML = "";
|
|
817
|
-
const l = u(
|
|
821
|
+
const l = u(a.template);
|
|
818
822
|
let n = "";
|
|
819
823
|
l.forEach((s) => {
|
|
820
824
|
if (s.type === "field") {
|
|
821
|
-
const g = r(s.content),
|
|
822
|
-
g && (n += g), e.appendChild(
|
|
825
|
+
const g = r(s.content), _ = c(s.content, g);
|
|
826
|
+
g && (n += g), e.appendChild(_);
|
|
823
827
|
} else
|
|
824
828
|
e.appendChild(document.createTextNode(s.content)), n += s.content;
|
|
825
|
-
}),
|
|
826
|
-
|
|
829
|
+
}), a.onValueChange(n), L(), o(n), W(() => {
|
|
830
|
+
a.isInternalUpdate = !1;
|
|
827
831
|
});
|
|
828
832
|
},
|
|
829
833
|
activateFirstField: () => {
|
|
@@ -837,25 +841,25 @@ function Ot(t, y) {
|
|
|
837
841
|
}
|
|
838
842
|
const At = /* @__PURE__ */ be({
|
|
839
843
|
__name: "TemplateEditor",
|
|
840
|
-
props: /* @__PURE__ */
|
|
844
|
+
props: /* @__PURE__ */ De({
|
|
841
845
|
value: {},
|
|
842
846
|
autofocus: { type: Boolean }
|
|
843
847
|
}, {
|
|
844
848
|
value: { default: "" },
|
|
845
849
|
valueModifiers: {}
|
|
846
850
|
}),
|
|
847
|
-
emits: /* @__PURE__ */
|
|
848
|
-
setup(t, { expose: y, emit:
|
|
849
|
-
const
|
|
851
|
+
emits: /* @__PURE__ */ De(["input", "content-status", "submit", "focus", "blur", "empty-content"], ["update:value"]),
|
|
852
|
+
setup(t, { expose: y, emit: m }) {
|
|
853
|
+
const a = rt(t, "value"), x = t, u = m, i = I(null), r = I(""), c = I({}), f = I(!1), p = I(!1), o = Ot(i, {
|
|
850
854
|
template: r.value,
|
|
851
|
-
value:
|
|
855
|
+
value: a.value,
|
|
852
856
|
initialValues: c.value,
|
|
853
857
|
isInternalUpdate: f,
|
|
854
858
|
isComposing: p,
|
|
855
859
|
onValueChange: (C) => {
|
|
856
|
-
if (
|
|
860
|
+
if (a.value !== C) {
|
|
857
861
|
const S = f.value;
|
|
858
|
-
f.value = !0,
|
|
862
|
+
f.value = !0, a.value = C, W(() => {
|
|
859
863
|
f.value = S;
|
|
860
864
|
});
|
|
861
865
|
}
|
|
@@ -868,8 +872,8 @@ const At = /* @__PURE__ */ be({
|
|
|
868
872
|
}), b = Nt({
|
|
869
873
|
editor: i,
|
|
870
874
|
isComposing: p,
|
|
871
|
-
getValueFromDOM:
|
|
872
|
-
handleInput:
|
|
875
|
+
getValueFromDOM: o.getValueFromDOM,
|
|
876
|
+
handleInput: o.handleInput,
|
|
873
877
|
onSubmit: (C) => u("submit", C)
|
|
874
878
|
}), L = (C, S) => {
|
|
875
879
|
let N = C;
|
|
@@ -877,21 +881,21 @@ const At = /* @__PURE__ */ be({
|
|
|
877
881
|
const l = `[${q}]`;
|
|
878
882
|
N = N.replace(new RegExp(l.replace(/[[\]]/g, "\\$&"), "g"), e);
|
|
879
883
|
}), N;
|
|
880
|
-
},
|
|
884
|
+
}, E = (C) => {
|
|
881
885
|
f.value = !0, r.value = C.template, c.value = C.initialValues || {};
|
|
882
886
|
const S = L(r.value, c.value);
|
|
883
|
-
|
|
887
|
+
o.updateOptions({
|
|
884
888
|
template: r.value,
|
|
885
889
|
value: S,
|
|
886
890
|
// 使用新生成的内容而不是旧的inputValue
|
|
887
891
|
initialValues: c.value
|
|
888
|
-
}),
|
|
892
|
+
}), o.updateEditorDOM(), a.value = S, W(() => {
|
|
889
893
|
f.value = !1;
|
|
890
894
|
});
|
|
891
895
|
}, v = () => {
|
|
892
896
|
p.value = !0;
|
|
893
897
|
}, R = () => {
|
|
894
|
-
p.value = !1,
|
|
898
|
+
p.value = !1, o.handleInput();
|
|
895
899
|
}, w = (C) => {
|
|
896
900
|
var q;
|
|
897
901
|
if (!i.value) return;
|
|
@@ -901,7 +905,7 @@ const At = /* @__PURE__ */ be({
|
|
|
901
905
|
const e = z(i.value), l = document.createRange();
|
|
902
906
|
e && (l.selectNodeContents(N), l.collapse(!0), e.removeAllRanges(), e.addRange(l), N.focus(), C.preventDefault(), C.stopPropagation());
|
|
903
907
|
}
|
|
904
|
-
},
|
|
908
|
+
}, h = (C) => {
|
|
905
909
|
if (typeof ShadowRoot.prototype.getSelection != "function")
|
|
906
910
|
return;
|
|
907
911
|
C.preventDefault();
|
|
@@ -914,13 +918,13 @@ const At = /* @__PURE__ */ be({
|
|
|
914
918
|
const l = e.querySelectorAll("span");
|
|
915
919
|
let n = !1;
|
|
916
920
|
if (l.forEach((s) => {
|
|
917
|
-
const g = s,
|
|
918
|
-
(
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
if (
|
|
921
|
+
const g = s, _ = g.style, A = g.classList.contains("template-field"), M = g.hasAttribute("data-placeholder"), j = _.backgroundColor && // 标准格式
|
|
922
|
+
(_.backgroundColor === "rgba(0, 0, 0, 0.05)" || _.backgroundColor === "rgba(0, 0, 0, 0.08)" || // 可能的变体格式
|
|
923
|
+
_.backgroundColor.includes("rgba(0, 0, 0, 0.05)") || _.backgroundColor.includes("rgba(0, 0, 0, 0.08)") || // 十六进制或其他可能的格式
|
|
924
|
+
_.backgroundColor.toLowerCase().includes("0.05") || _.backgroundColor.toLowerCase().includes("0.08")), B = _.borderRadius === "4px" || _.padding === "3px 8px" || _.margin === "0px 2px" || _.whiteSpace === "nowrap";
|
|
925
|
+
if (A || M || j || B) {
|
|
922
926
|
if (n = !0, g.className = "template-field", !g.getAttribute("data-placeholder")) {
|
|
923
|
-
const X =
|
|
927
|
+
const X = o.extractPlaceholderFromElement(g);
|
|
924
928
|
X && g.setAttribute("data-placeholder", X);
|
|
925
929
|
}
|
|
926
930
|
g.removeAttribute("style");
|
|
@@ -949,76 +953,76 @@ const At = /* @__PURE__ */ be({
|
|
|
949
953
|
}
|
|
950
954
|
}, H = () => {
|
|
951
955
|
p.value = !1, W(() => {
|
|
952
|
-
|
|
953
|
-
const C =
|
|
954
|
-
if (C !==
|
|
956
|
+
o.handleInput();
|
|
957
|
+
const C = o.getValueFromDOM();
|
|
958
|
+
if (C !== a.value) {
|
|
955
959
|
const S = f.value;
|
|
956
|
-
f.value = !0,
|
|
960
|
+
f.value = !0, a.value = C, u("input", C), W(() => {
|
|
957
961
|
f.value = S;
|
|
958
962
|
});
|
|
959
963
|
}
|
|
960
964
|
setTimeout(() => {
|
|
961
|
-
const S =
|
|
962
|
-
S !==
|
|
965
|
+
const S = o.getValueFromDOM();
|
|
966
|
+
S !== a.value && (f.value = !0, a.value = S, u("input", S), W(() => {
|
|
963
967
|
f.value = !1;
|
|
964
968
|
}));
|
|
965
969
|
}, 50);
|
|
966
970
|
});
|
|
967
971
|
};
|
|
968
972
|
return ut(() => {
|
|
969
|
-
r.value &&
|
|
973
|
+
r.value && o.updateEditorDOM(), x.autofocus && i.value && o.setCursorToEnd();
|
|
970
974
|
}), te(
|
|
971
975
|
() => r.value,
|
|
972
976
|
() => {
|
|
973
|
-
f.value || (
|
|
977
|
+
f.value || (o.updateOptions({
|
|
974
978
|
template: r.value,
|
|
975
|
-
value:
|
|
979
|
+
value: a.value,
|
|
976
980
|
initialValues: c.value
|
|
977
|
-
}),
|
|
981
|
+
}), o.updateEditorDOM());
|
|
978
982
|
}
|
|
979
983
|
), te(
|
|
980
984
|
() => c.value,
|
|
981
985
|
() => {
|
|
982
|
-
f.value || (
|
|
986
|
+
f.value || (o.updateOptions({
|
|
983
987
|
template: r.value,
|
|
984
|
-
value:
|
|
988
|
+
value: a.value,
|
|
985
989
|
initialValues: c.value
|
|
986
|
-
}),
|
|
990
|
+
}), o.updateEditorDOM());
|
|
987
991
|
},
|
|
988
992
|
{ deep: !0 }
|
|
989
993
|
), te(
|
|
990
|
-
() =>
|
|
994
|
+
() => a.value,
|
|
991
995
|
(C) => {
|
|
992
|
-
f.value || (
|
|
996
|
+
f.value || (o.updateOptions({
|
|
993
997
|
template: r.value,
|
|
994
998
|
value: C,
|
|
995
999
|
initialValues: c.value
|
|
996
|
-
}),
|
|
1000
|
+
}), o.updateEditorDOM()), (!C || C.trim() === "") && u("empty-content");
|
|
997
1001
|
}
|
|
998
1002
|
), y({
|
|
999
1003
|
focus: () => {
|
|
1000
1004
|
var C;
|
|
1001
|
-
(C = i.value) == null || C.focus(),
|
|
1005
|
+
(C = i.value) == null || C.focus(), o.setCursorToEnd();
|
|
1002
1006
|
},
|
|
1003
|
-
resetFields:
|
|
1004
|
-
activateFirstField:
|
|
1005
|
-
getValueFromDOM:
|
|
1006
|
-
setTemplate:
|
|
1007
|
-
}), (C, S) => (D(),
|
|
1007
|
+
resetFields: o.resetFields,
|
|
1008
|
+
activateFirstField: o.activateFirstField,
|
|
1009
|
+
getValueFromDOM: o.getValueFromDOM,
|
|
1010
|
+
setTemplate: E
|
|
1011
|
+
}), (C, S) => (D(), O("div", {
|
|
1008
1012
|
class: "template-editor",
|
|
1009
1013
|
ref_key: "contentEditableRef",
|
|
1010
1014
|
ref: i,
|
|
1011
1015
|
contenteditable: "true",
|
|
1012
1016
|
onInput: S[0] || (S[0] = //@ts-ignore
|
|
1013
|
-
(...N) =>
|
|
1017
|
+
(...N) => T(o).handleInput && T(o).handleInput(...N)),
|
|
1014
1018
|
onKeydown: S[1] || (S[1] = //@ts-ignore
|
|
1015
|
-
(...N) =>
|
|
1019
|
+
(...N) => T(b).handleTemplateKeyDown && T(b).handleTemplateKeyDown(...N)),
|
|
1016
1020
|
onClick: w,
|
|
1017
1021
|
onCompositionstart: v,
|
|
1018
1022
|
onCompositionend: R,
|
|
1019
1023
|
onFocus: S[2] || (S[2] = (N) => C.$emit("focus", N)),
|
|
1020
1024
|
onBlur: S[3] || (S[3] = (N) => C.$emit("blur", N)),
|
|
1021
|
-
onPaste:
|
|
1025
|
+
onPaste: h
|
|
1022
1026
|
}, null, 544));
|
|
1023
1027
|
}
|
|
1024
1028
|
}), Mt = ["data-theme"], Vt = { class: "tiny-sender__container" }, Bt = {
|
|
@@ -1074,16 +1078,17 @@ const At = /* @__PURE__ */ be({
|
|
|
1074
1078
|
theme: { default: "light" },
|
|
1075
1079
|
template: { default: "" },
|
|
1076
1080
|
hasContent: { type: Boolean, default: void 0 },
|
|
1077
|
-
templateInitialValues: { default: () => ({}) }
|
|
1081
|
+
templateInitialValues: { default: () => ({}) },
|
|
1082
|
+
stopText: { default: "" }
|
|
1078
1083
|
},
|
|
1079
1084
|
emits: ["update:modelValue", "submit", "clear", "speech-start", "speech-end", "speech-interim", "speech-error", "suggestion-select", "focus", "blur", "escape-press", "cancel", "reset-template"],
|
|
1080
|
-
setup(t, { expose: y, emit:
|
|
1081
|
-
const
|
|
1082
|
-
showSuggestionsPopup:
|
|
1085
|
+
setup(t, { expose: y, emit: m }) {
|
|
1086
|
+
const a = t, x = m, u = I(null), i = I(null), r = I(null), c = I(null), f = I(null), p = I(!1), { inputValue: o, isComposing: b, clearInput: L } = wt(a, x), {
|
|
1087
|
+
showSuggestionsPopup: E,
|
|
1083
1088
|
completionPlaceholder: v,
|
|
1084
1089
|
showTabHint: R,
|
|
1085
1090
|
suggestionsListRef: w,
|
|
1086
|
-
filteredSuggestions:
|
|
1091
|
+
filteredSuggestions: h,
|
|
1087
1092
|
activeSuggestion: $,
|
|
1088
1093
|
isItemHighlighted: V,
|
|
1089
1094
|
updateSuggestionsState: H,
|
|
@@ -1094,28 +1099,28 @@ const At = /* @__PURE__ */ be({
|
|
|
1094
1099
|
handleSuggestionItemHover: e,
|
|
1095
1100
|
handleSuggestionItemLeave: l,
|
|
1096
1101
|
highlightSuggestionText: n
|
|
1097
|
-
} = Rt(
|
|
1102
|
+
} = Rt(a, x, o, b), s = I(a.mode), g = I(!1), _ = () => {
|
|
1098
1103
|
s.value === "single" && (s.value = "multiple", W(() => {
|
|
1099
1104
|
setTimeout(() => {
|
|
1100
1105
|
const d = document.querySelector(".tiny-textarea__inner");
|
|
1101
1106
|
if (d) {
|
|
1102
1107
|
d.style.whiteSpace = "pre-wrap";
|
|
1103
|
-
const k =
|
|
1108
|
+
const k = o.value.length;
|
|
1104
1109
|
d.focus(), d.setSelectionRange(k, k);
|
|
1105
1110
|
}
|
|
1106
1111
|
}, 50);
|
|
1107
1112
|
}));
|
|
1108
|
-
},
|
|
1113
|
+
}, A = (d, k) => {
|
|
1109
1114
|
const F = document.createElement("span");
|
|
1110
1115
|
F.style.visibility = "hidden", F.style.position = "absolute", F.style.whiteSpace = "nowrap", F.style.font = k, F.textContent = d, document.body.appendChild(F);
|
|
1111
1116
|
const ne = F.offsetWidth;
|
|
1112
1117
|
return document.body.removeChild(F), ne;
|
|
1113
1118
|
}, M = () => {
|
|
1114
|
-
var ce,
|
|
1115
|
-
if (
|
|
1119
|
+
var ce, Ne, xe;
|
|
1120
|
+
if (a.mode !== "single" || !u.value || g.value || !i.value || !c.value) return;
|
|
1116
1121
|
const d = i.value.querySelector(".tiny-sender__content-area");
|
|
1117
1122
|
if (!d) return;
|
|
1118
|
-
const k = ((
|
|
1123
|
+
const k = ((Ne = (ce = u.value) == null ? void 0 : ce.querySelector) == null ? void 0 : Ne.call(ce, ".tiny-input__inner")) || d.querySelector(".tiny-input__inner"), F = f.value || i.value.querySelector(".tiny-sender__buttons-container");
|
|
1119
1124
|
if (!k) {
|
|
1120
1125
|
console.warn("Cannot find input element for overflow check");
|
|
1121
1126
|
return;
|
|
@@ -1125,15 +1130,15 @@ const At = /* @__PURE__ */ be({
|
|
|
1125
1130
|
setTimeout(() => M(), 50);
|
|
1126
1131
|
return;
|
|
1127
1132
|
}
|
|
1128
|
-
const ge = window.getComputedStyle(k).font, nt =
|
|
1129
|
-
nt >
|
|
1133
|
+
const ge = window.getComputedStyle(k).font, nt = A(o.value, ge), Te = (xe = i.value) == null ? void 0 : xe.classList.contains("tr-sender-compact"), st = Te ? 12 : 20, lt = ne.width, ot = (Z == null ? void 0 : Z.width) || 0, _e = lt - ot - st, at = Te ? 50 : 80;
|
|
1134
|
+
nt > _e && _e > at && s.value === "single" && (g.value = !0, s.value = "multiple", W(() => {
|
|
1130
1135
|
u.value ? setTimeout(() => {
|
|
1131
|
-
var
|
|
1132
|
-
const de = (
|
|
1136
|
+
var ke;
|
|
1137
|
+
const de = (ke = i.value) == null ? void 0 : ke.querySelector(".tiny-textarea__inner");
|
|
1133
1138
|
if (de) {
|
|
1134
1139
|
de.style.whiteSpace = "pre-wrap";
|
|
1135
|
-
const
|
|
1136
|
-
de.focus(), de.setSelectionRange(
|
|
1140
|
+
const Re = o.value.length;
|
|
1141
|
+
de.focus(), de.setSelectionRange(Re, Re);
|
|
1137
1142
|
}
|
|
1138
1143
|
g.value = !1;
|
|
1139
1144
|
}, 300) : g.value = !1;
|
|
@@ -1149,25 +1154,25 @@ const At = /* @__PURE__ */ be({
|
|
|
1149
1154
|
}
|
|
1150
1155
|
}, B = () => {
|
|
1151
1156
|
p.value = !1, x("reset-template"), W(() => {
|
|
1152
|
-
|
|
1157
|
+
o.value === "" && (s.value = a.mode || "single"), setTimeout(() => {
|
|
1153
1158
|
j();
|
|
1154
1159
|
}, 50);
|
|
1155
1160
|
});
|
|
1156
1161
|
}, X = () => {
|
|
1157
1162
|
var d;
|
|
1158
1163
|
L(), p.value ? B() : (d = i.value) == null || d.focus(), W(() => {
|
|
1159
|
-
|
|
1164
|
+
o.value === "" && (s.value = a.mode || "single");
|
|
1160
1165
|
}), N();
|
|
1161
|
-
},
|
|
1166
|
+
}, Pe = (d) => {
|
|
1162
1167
|
x("update:modelValue", d);
|
|
1163
1168
|
}, Ce = () => {
|
|
1164
1169
|
r.value && r.value.activateFirstField();
|
|
1165
|
-
},
|
|
1170
|
+
}, Ke = (d, k) => {
|
|
1166
1171
|
p.value = !0, W(() => {
|
|
1167
1172
|
r.value && r.value.setTemplate({ template: d, initialValues: k });
|
|
1168
1173
|
});
|
|
1169
|
-
},
|
|
1170
|
-
const d = typeof
|
|
1174
|
+
}, He = K(() => {
|
|
1175
|
+
const d = typeof a.speech == "object" ? a.speech : {};
|
|
1171
1176
|
return {
|
|
1172
1177
|
...d,
|
|
1173
1178
|
onStart: () => x("speech-start"),
|
|
@@ -1175,10 +1180,10 @@ const At = /* @__PURE__ */ be({
|
|
|
1175
1180
|
onInterim: (k) => x("speech-interim", k),
|
|
1176
1181
|
onFinal: (k) => {
|
|
1177
1182
|
if (d.autoReplace)
|
|
1178
|
-
|
|
1183
|
+
o.value = k;
|
|
1179
1184
|
else {
|
|
1180
|
-
const F =
|
|
1181
|
-
F && k && !F.endsWith(" ") && !k.startsWith(" ") && F.length > 0 ?
|
|
1185
|
+
const F = o.value;
|
|
1186
|
+
F && k && !F.endsWith(" ") && !k.startsWith(" ") && F.length > 0 ? o.value = F + " " + k : o.value = F + k;
|
|
1182
1187
|
}
|
|
1183
1188
|
x("speech-end", k);
|
|
1184
1189
|
},
|
|
@@ -1186,51 +1191,51 @@ const At = /* @__PURE__ */ be({
|
|
|
1186
1191
|
et(k.message), x("speech-error", k);
|
|
1187
1192
|
}
|
|
1188
1193
|
};
|
|
1189
|
-
}), { speechState: ie, start: Se, stop: we } = xt(
|
|
1194
|
+
}), { speechState: ie, start: Se, stop: we } = xt(He.value), he = () => {
|
|
1190
1195
|
ie.isRecording ? we() : Se();
|
|
1191
|
-
}, re =
|
|
1192
|
-
o,
|
|
1193
|
-
x,
|
|
1196
|
+
}, re = K(() => a.maxLength !== 1 / 0 && o.value.length > a.maxLength), { handleKeyPress: qe, triggerSubmit: me } = _t(
|
|
1194
1197
|
a,
|
|
1198
|
+
x,
|
|
1199
|
+
o,
|
|
1195
1200
|
b,
|
|
1196
1201
|
ie,
|
|
1197
|
-
|
|
1202
|
+
E,
|
|
1198
1203
|
$,
|
|
1199
1204
|
S,
|
|
1200
1205
|
N,
|
|
1201
1206
|
q,
|
|
1202
|
-
|
|
1207
|
+
he,
|
|
1203
1208
|
re,
|
|
1204
1209
|
s,
|
|
1205
|
-
|
|
1206
|
-
),
|
|
1207
|
-
x("focus", d),
|
|
1208
|
-
},
|
|
1210
|
+
_
|
|
1211
|
+
), Xe = (d) => {
|
|
1212
|
+
x("focus", d), o.value && h.value.length > 0 && !a.template && (E.value = !0, R.value = !0);
|
|
1213
|
+
}, ze = (d) => {
|
|
1209
1214
|
x("blur", d), N();
|
|
1210
|
-
},
|
|
1215
|
+
}, je = K(() => s.value === "multiple" ? "textarea" : "text"), Ue = K(
|
|
1211
1216
|
() => ({
|
|
1212
1217
|
display: "flex",
|
|
1213
|
-
justifyContent:
|
|
1218
|
+
justifyContent: a.showWordLimit && a.maxLength !== 1 / 0 ? "space-between" : "flex-end",
|
|
1214
1219
|
alignItems: "center"
|
|
1215
1220
|
})
|
|
1216
|
-
),
|
|
1221
|
+
), Ze = ct(), Ge = K(() => !!Ze.decorativeContent), ue = K(() => a.disabled || Ge.value), Je = K(() => a.loading), Ee = K(() => a.hasContent !== void 0 ? a.hasContent : !!o.value), Qe = K(() => ({
|
|
1217
1222
|
"is-disabled": ue.value,
|
|
1218
|
-
"is-loading":
|
|
1219
|
-
"has-error": !!
|
|
1223
|
+
"is-loading": Je.value,
|
|
1224
|
+
"has-error": !!ae.value,
|
|
1220
1225
|
"is-auto-switching": g.value
|
|
1221
|
-
})), Ye =
|
|
1222
|
-
width:
|
|
1226
|
+
})), Ye = K(() => ({
|
|
1227
|
+
width: ht(a.suggestionPopupWidth),
|
|
1223
1228
|
maxWidth: "100%"
|
|
1224
1229
|
// 确保不超出父容器宽度
|
|
1225
|
-
})),
|
|
1226
|
-
|
|
1230
|
+
})), ae = I(""), et = (d) => {
|
|
1231
|
+
ae.value = d, setTimeout(() => ae.value = "", 5e3);
|
|
1227
1232
|
}, tt = () => {
|
|
1228
1233
|
b.value = !1, setTimeout(() => {
|
|
1229
1234
|
b.value = !1, H();
|
|
1230
1235
|
}, 50);
|
|
1231
1236
|
};
|
|
1232
|
-
return te(
|
|
1233
|
-
W(M),
|
|
1237
|
+
return te(o, () => {
|
|
1238
|
+
W(M), o.value === "" && a.mode === "single" && (s.value = "single");
|
|
1234
1239
|
}), te(
|
|
1235
1240
|
() => p.value,
|
|
1236
1241
|
(d) => {
|
|
@@ -1247,15 +1252,15 @@ const At = /* @__PURE__ */ be({
|
|
|
1247
1252
|
}
|
|
1248
1253
|
},
|
|
1249
1254
|
clear: X,
|
|
1250
|
-
submit:
|
|
1255
|
+
submit: me,
|
|
1251
1256
|
startSpeech: Se,
|
|
1252
1257
|
stopSpeech: we,
|
|
1253
1258
|
activateTemplateFirstField: Ce,
|
|
1254
|
-
setTemplate:
|
|
1255
|
-
}), (d, k) => (D(),
|
|
1259
|
+
setTemplate: Ke
|
|
1260
|
+
}), (d, k) => (D(), O("div", {
|
|
1256
1261
|
ref_key: "senderRef",
|
|
1257
1262
|
ref: i,
|
|
1258
|
-
class:
|
|
1263
|
+
class: oe(["tiny-sender", [Qe.value, `theme-${d.theme}`, `mode-${s.value}`]]),
|
|
1259
1264
|
"data-theme": d.theme
|
|
1260
1265
|
}, [
|
|
1261
1266
|
U("div", Vt, [
|
|
@@ -1266,86 +1271,86 @@ const At = /* @__PURE__ */ be({
|
|
|
1266
1271
|
}, [
|
|
1267
1272
|
G(ve, { name: "tiny-sender-slide-down" }, {
|
|
1268
1273
|
default: Y(() => [
|
|
1269
|
-
d.$slots.header ? (D(),
|
|
1274
|
+
d.$slots.header ? (D(), O("div", Bt, [
|
|
1270
1275
|
se(d.$slots, "header")
|
|
1271
|
-
])) :
|
|
1276
|
+
])) : P("", !0)
|
|
1272
1277
|
]),
|
|
1273
1278
|
_: 3
|
|
1274
1279
|
}),
|
|
1275
1280
|
U("div", {
|
|
1276
|
-
class:
|
|
1281
|
+
class: oe(["tiny-sender__input-row", { "has-prefix": d.$slots.prefix, "has-header": d.$slots.header }])
|
|
1277
1282
|
}, [
|
|
1278
|
-
d.$slots.prefix ? (D(),
|
|
1283
|
+
d.$slots.prefix ? (D(), O("div", Wt, [
|
|
1279
1284
|
se(d.$slots, "prefix")
|
|
1280
|
-
])) :
|
|
1285
|
+
])) : P("", !0),
|
|
1281
1286
|
U("div", $t, [
|
|
1282
|
-
d.$slots.decorativeContent ? (D(),
|
|
1287
|
+
d.$slots.decorativeContent ? (D(), O("div", Pt, [
|
|
1283
1288
|
se(d.$slots, "decorativeContent")
|
|
1284
|
-
])) :
|
|
1289
|
+
])) : P("", !0),
|
|
1285
1290
|
p.value ? (D(), Q(At, {
|
|
1286
1291
|
key: 1,
|
|
1287
1292
|
ref_key: "templateEditorRef",
|
|
1288
1293
|
ref: r,
|
|
1289
|
-
value:
|
|
1290
|
-
"onUpdate:value": k[0] || (k[0] = (F) =>
|
|
1291
|
-
onInput:
|
|
1294
|
+
value: T(o),
|
|
1295
|
+
"onUpdate:value": k[0] || (k[0] = (F) => Fe(o) ? o.value = F : null),
|
|
1296
|
+
onInput: Pe,
|
|
1292
1297
|
onEmptyContent: B
|
|
1293
|
-
}, null, 8, ["value"])) : (D(),
|
|
1294
|
-
G(
|
|
1298
|
+
}, null, 8, ["value"])) : (D(), O("div", Kt, [
|
|
1299
|
+
G(T(ft), {
|
|
1295
1300
|
ref_key: "inputRef",
|
|
1296
1301
|
ref: u,
|
|
1297
1302
|
autosize: d.autoSize,
|
|
1298
|
-
type:
|
|
1299
|
-
readonly: Ee.value,
|
|
1303
|
+
type: je.value,
|
|
1300
1304
|
resize: "none",
|
|
1301
|
-
modelValue:
|
|
1302
|
-
"onUpdate:modelValue": k[1] || (k[1] = (F) =>
|
|
1305
|
+
modelValue: T(o),
|
|
1306
|
+
"onUpdate:modelValue": k[1] || (k[1] = (F) => Fe(o) ? o.value = F : null),
|
|
1303
1307
|
disabled: ue.value,
|
|
1304
1308
|
placeholder: d.placeholder,
|
|
1305
1309
|
autofocus: d.autofocus,
|
|
1306
|
-
onKeydown:
|
|
1310
|
+
onKeydown: T(qe),
|
|
1307
1311
|
onCompositionstart: k[2] || (k[2] = (F) => b.value = !0),
|
|
1308
1312
|
onCompositionend: tt,
|
|
1309
|
-
onFocus:
|
|
1310
|
-
onBlur:
|
|
1311
|
-
}, null, 8, ["autosize", "type", "
|
|
1312
|
-
|
|
1313
|
-
U("span", qt, le(
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
])) :
|
|
1313
|
+
onFocus: Xe,
|
|
1314
|
+
onBlur: ze
|
|
1315
|
+
}, null, 8, ["autosize", "type", "modelValue", "disabled", "placeholder", "autofocus", "onKeydown"]),
|
|
1316
|
+
T(v) && !T(b) ? (D(), O("div", Ht, [
|
|
1317
|
+
U("span", qt, le(T(o)), 1),
|
|
1318
|
+
Le(le(T(v)) + " ", 1),
|
|
1319
|
+
T(R) ? (D(), O("div", Xt, "TAB")) : P("", !0)
|
|
1320
|
+
])) : P("", !0)
|
|
1317
1321
|
]))
|
|
1318
1322
|
]),
|
|
1319
|
-
s.value === "single" ? (D(),
|
|
1323
|
+
s.value === "single" ? (D(), O("div", zt, [
|
|
1320
1324
|
U("div", {
|
|
1321
1325
|
class: "tiny-sender__buttons-container",
|
|
1322
1326
|
ref_key: "buttonsContainerRef",
|
|
1323
1327
|
ref: f
|
|
1324
1328
|
}, [
|
|
1325
1329
|
se(d.$slots, "actions"),
|
|
1326
|
-
G(
|
|
1330
|
+
G(Be, {
|
|
1327
1331
|
"allow-speech": d.allowSpeech,
|
|
1328
1332
|
"allow-files": d.allowFiles,
|
|
1329
1333
|
loading: d.loading,
|
|
1330
1334
|
disabled: ue.value,
|
|
1331
1335
|
"show-clear": d.clearable,
|
|
1332
|
-
"has-content":
|
|
1333
|
-
"speech-status":
|
|
1336
|
+
"has-content": Ee.value,
|
|
1337
|
+
"speech-status": T(ie),
|
|
1334
1338
|
"submit-type": d.submitType,
|
|
1335
1339
|
"is-over-limit": re.value,
|
|
1340
|
+
"stop-text": d.stopText,
|
|
1336
1341
|
onClear: X,
|
|
1337
|
-
onToggleSpeech:
|
|
1338
|
-
onSubmit:
|
|
1342
|
+
onToggleSpeech: he,
|
|
1343
|
+
onSubmit: T(me),
|
|
1339
1344
|
onCancel: k[3] || (k[3] = (F) => d.$emit("cancel"))
|
|
1340
|
-
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
|
|
1345
|
+
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "stop-text", "onSubmit"])
|
|
1341
1346
|
], 512)
|
|
1342
|
-
])) :
|
|
1347
|
+
])) : P("", !0)
|
|
1343
1348
|
], 2),
|
|
1344
1349
|
G(ve, { name: "tiny-sender-slide-up" }, {
|
|
1345
1350
|
default: Y(() => [
|
|
1346
|
-
s.value === "multiple" ? (D(),
|
|
1351
|
+
s.value === "multiple" ? (D(), O("div", {
|
|
1347
1352
|
key: 0,
|
|
1348
|
-
style:
|
|
1353
|
+
style: Ie(Ue.value),
|
|
1349
1354
|
class: "tiny-sender__footer-slot tiny-sender__bottom-row"
|
|
1350
1355
|
}, [
|
|
1351
1356
|
U("div", jt, [
|
|
@@ -1353,36 +1358,37 @@ const At = /* @__PURE__ */ be({
|
|
|
1353
1358
|
]),
|
|
1354
1359
|
U("div", Ut, [
|
|
1355
1360
|
se(d.$slots, "footer-right"),
|
|
1356
|
-
d.showWordLimit && d.maxLength !== 1 / 0 ? (D(),
|
|
1361
|
+
d.showWordLimit && d.maxLength !== 1 / 0 ? (D(), O("div", {
|
|
1357
1362
|
key: 0,
|
|
1358
|
-
class:
|
|
1363
|
+
class: oe(["tiny-sender__word-limit", { "is-over-limit": re.value }])
|
|
1359
1364
|
}, [
|
|
1360
|
-
U("span", Zt, le(
|
|
1361
|
-
|
|
1362
|
-
], 2)) :
|
|
1363
|
-
s.value === "multiple" ? (D(),
|
|
1365
|
+
U("span", Zt, le(T(o).length), 1),
|
|
1366
|
+
Le("/" + le(d.maxLength), 1)
|
|
1367
|
+
], 2)) : P("", !0),
|
|
1368
|
+
s.value === "multiple" ? (D(), O("div", Gt, [
|
|
1364
1369
|
U("div", Jt, [
|
|
1365
|
-
G(
|
|
1370
|
+
G(Be, {
|
|
1366
1371
|
"allow-speech": d.allowSpeech,
|
|
1367
1372
|
"allow-files": d.allowFiles,
|
|
1368
1373
|
loading: d.loading,
|
|
1369
1374
|
disabled: ue.value,
|
|
1370
1375
|
"show-clear": d.clearable,
|
|
1371
|
-
"has-content":
|
|
1372
|
-
"speech-status":
|
|
1376
|
+
"has-content": Ee.value,
|
|
1377
|
+
"speech-status": T(ie),
|
|
1373
1378
|
"submit-type": d.submitType,
|
|
1374
1379
|
"is-over-limit": re.value,
|
|
1380
|
+
"stop-text": d.stopText,
|
|
1375
1381
|
onClear: X,
|
|
1376
|
-
onToggleSpeech:
|
|
1377
|
-
onSubmit:
|
|
1382
|
+
onToggleSpeech: he,
|
|
1383
|
+
onSubmit: T(me),
|
|
1378
1384
|
onCancel: k[4] || (k[4] = (F) => d.$emit("cancel"))
|
|
1379
|
-
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "onSubmit"])
|
|
1385
|
+
}, null, 8, ["allow-speech", "allow-files", "loading", "disabled", "show-clear", "has-content", "speech-status", "submit-type", "is-over-limit", "stop-text", "onSubmit"])
|
|
1380
1386
|
])
|
|
1381
|
-
])) :
|
|
1387
|
+
])) : P("", !0)
|
|
1382
1388
|
])
|
|
1383
|
-
], 4)) : d.$slots.footer ? (D(),
|
|
1389
|
+
], 4)) : d.$slots.footer ? (D(), O("div", Qt, [
|
|
1384
1390
|
se(d.$slots, "footer")
|
|
1385
|
-
])) :
|
|
1391
|
+
])) : P("", !0)
|
|
1386
1392
|
]),
|
|
1387
1393
|
_: 3
|
|
1388
1394
|
})
|
|
@@ -1390,34 +1396,34 @@ const At = /* @__PURE__ */ be({
|
|
|
1390
1396
|
]),
|
|
1391
1397
|
G(ve, { name: "tiny-sender-slide-up" }, {
|
|
1392
1398
|
default: Y(() => [
|
|
1393
|
-
E
|
|
1399
|
+
T(E) && T(h).length ? (D(), O("div", {
|
|
1394
1400
|
key: 0,
|
|
1395
1401
|
ref_key: "suggestionsListRef",
|
|
1396
1402
|
ref: w,
|
|
1397
1403
|
class: "tiny-sender__suggestions",
|
|
1398
|
-
style:
|
|
1404
|
+
style: Ie(Ye.value)
|
|
1399
1405
|
}, [
|
|
1400
|
-
(D(!0),
|
|
1406
|
+
(D(!0), O(Oe, null, Ae(T(h), (F, ne) => (D(), O("div", {
|
|
1401
1407
|
key: ne,
|
|
1402
|
-
class:
|
|
1403
|
-
onMouseenter: (Z) =>
|
|
1408
|
+
class: oe(["suggestion-item", { highlighted: T(V)(ne) }]),
|
|
1409
|
+
onMouseenter: (Z) => T(e)(ne),
|
|
1404
1410
|
onMouseleave: k[5] || (k[5] = //@ts-ignore
|
|
1405
|
-
(...Z) =>
|
|
1406
|
-
onMousedown: dt((Z) =>
|
|
1411
|
+
(...Z) => T(l) && T(l)(...Z)),
|
|
1412
|
+
onMousedown: dt((Z) => T(C)(F), ["prevent"])
|
|
1407
1413
|
}, [
|
|
1408
|
-
G(
|
|
1414
|
+
G(T(St), { class: "suggestion-item__icon" }),
|
|
1409
1415
|
U("span", en, [
|
|
1410
|
-
(D(!0),
|
|
1416
|
+
(D(!0), O(Oe, null, Ae(T(n)(F, T(o)), (Z, ge) => (D(), O("span", {
|
|
1411
1417
|
key: ge,
|
|
1412
|
-
class:
|
|
1418
|
+
class: oe({ "suggestion-item__text--match": Z.isMatch, "suggestion-item__text--normal": !Z.isMatch })
|
|
1413
1419
|
}, le(Z.text), 3))), 128))
|
|
1414
1420
|
])
|
|
1415
1421
|
], 42, Yt))), 128))
|
|
1416
|
-
], 4)) :
|
|
1422
|
+
], 4)) : P("", !0)
|
|
1417
1423
|
]),
|
|
1418
1424
|
_: 1
|
|
1419
1425
|
}),
|
|
1420
|
-
|
|
1426
|
+
ae.value ? (D(), O("div", tn, le(ae.value), 1)) : P("", !0)
|
|
1421
1427
|
], 10, Mt));
|
|
1422
1428
|
}
|
|
1423
1429
|
});
|