@aheart-ui/ai 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +21 -2
- package/es/actions.vue.d.ts +34 -0
- package/es/actions.vue.js +27 -0
- package/es/actions.vue2.js +4 -0
- package/es/agent-execution.vue.d.ts +106 -0
- package/es/agent-execution.vue.js +441 -0
- package/es/agent-execution.vue2.js +4 -0
- package/es/agent-workbench.vue.d.ts +186 -0
- package/es/agent-workbench.vue.js +537 -0
- package/es/agent-workbench.vue2.js +4 -0
- package/es/attachments.vue.d.ts +39 -0
- package/es/attachments.vue.js +39 -0
- package/es/attachments.vue2.js +4 -0
- package/es/bubble.vue.d.ts +27 -0
- package/es/bubble.vue.js +82 -0
- package/es/bubble.vue2.js +4 -0
- package/es/chat-panel.vue.d.ts +108 -0
- package/es/chat-panel.vue.js +330 -0
- package/es/chat-panel.vue2.js +4 -0
- package/es/conversations.vue.d.ts +39 -0
- package/es/conversations.vue.js +29 -0
- package/es/conversations.vue2.js +4 -0
- package/es/form-field.vue.d.ts +28 -0
- package/es/form-field.vue.js +176 -0
- package/es/form-field.vue2.js +4 -0
- package/es/form-schema.d.ts +73 -0
- package/es/form-schema.js +105 -0
- package/es/form.vue.d.ts +81 -0
- package/es/form.vue.js +376 -0
- package/es/form.vue2.js +4 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +42 -0
- package/es/package.json +3 -0
- package/es/process.vue.d.ts +30 -0
- package/es/process.vue.js +29 -0
- package/es/process.vue2.js +4 -0
- package/es/prompts.vue.d.ts +39 -0
- package/es/prompts.vue.js +33 -0
- package/es/prompts.vue2.js +4 -0
- package/es/safe-markdown.d.ts +3 -0
- package/es/safe-markdown.js +23 -0
- package/es/sender.vue.d.ts +52 -0
- package/es/sender.vue.js +46 -0
- package/es/sender.vue2.js +4 -0
- package/es/sources.vue.d.ts +30 -0
- package/es/sources.vue.js +34 -0
- package/es/sources.vue2.js +4 -0
- package/es/stream-reducer.d.ts +35 -0
- package/es/stream-reducer.js +85 -0
- package/es/style.css +1586 -0
- package/es/thought-chain.vue.d.ts +30 -0
- package/es/thought-chain.vue.js +15 -0
- package/es/thought-chain.vue2.js +4 -0
- package/es/types.d.ts +203 -0
- package/es/welcome.vue.d.ts +41 -0
- package/es/welcome.vue.js +27 -0
- package/es/welcome.vue2.js +4 -0
- package/lib/actions.vue.d.ts +34 -0
- package/lib/actions.vue.js +1 -0
- package/lib/actions.vue2.js +1 -0
- package/lib/agent-execution.vue.d.ts +106 -0
- package/lib/agent-execution.vue.js +1 -0
- package/lib/agent-execution.vue2.js +1 -0
- package/lib/agent-workbench.vue.d.ts +186 -0
- package/lib/agent-workbench.vue.js +1 -0
- package/lib/agent-workbench.vue2.js +1 -0
- package/lib/attachments.vue.d.ts +39 -0
- package/lib/attachments.vue.js +1 -0
- package/lib/attachments.vue2.js +1 -0
- package/lib/bubble.vue.d.ts +27 -0
- package/lib/bubble.vue.js +1 -0
- package/lib/bubble.vue2.js +1 -0
- package/lib/chat-panel.vue.d.ts +108 -0
- package/lib/chat-panel.vue.js +1 -0
- package/lib/chat-panel.vue2.js +1 -0
- package/lib/conversations.vue.d.ts +39 -0
- package/lib/conversations.vue.js +1 -0
- package/lib/conversations.vue2.js +1 -0
- package/lib/form-field.vue.d.ts +28 -0
- package/lib/form-field.vue.js +1 -0
- package/lib/form-field.vue2.js +1 -0
- package/lib/form-schema.d.ts +73 -0
- package/lib/form-schema.js +1 -0
- package/lib/form.vue.d.ts +81 -0
- package/lib/form.vue.js +1 -0
- package/lib/form.vue2.js +1 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +1 -0
- package/lib/package.json +3 -0
- package/lib/process.vue.d.ts +30 -0
- package/lib/process.vue.js +1 -0
- package/lib/process.vue2.js +1 -0
- package/lib/prompts.vue.d.ts +39 -0
- package/lib/prompts.vue.js +1 -0
- package/lib/prompts.vue2.js +1 -0
- package/lib/safe-markdown.d.ts +3 -0
- package/lib/safe-markdown.js +2 -0
- package/lib/sender.vue.d.ts +52 -0
- package/lib/sender.vue.js +1 -0
- package/lib/sender.vue2.js +1 -0
- package/lib/sources.vue.d.ts +30 -0
- package/lib/sources.vue.js +1 -0
- package/lib/sources.vue2.js +1 -0
- package/lib/stream-reducer.d.ts +35 -0
- package/lib/stream-reducer.js +1 -0
- package/lib/style.css +1586 -0
- package/lib/thought-chain.vue.d.ts +30 -0
- package/lib/thought-chain.vue.js +1 -0
- package/lib/thought-chain.vue2.js +1 -0
- package/lib/types.d.ts +203 -0
- package/lib/welcome.vue.d.ts +41 -0
- package/lib/welcome.vue.js +1 -0
- package/lib/welcome.vue2.js +1 -0
- package/package.json +70 -3
package/es/form.vue.js
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { defineComponent as Ae, computed as R, reactive as D, ref as q, onMounted as Fe, watch as k, toRaw as J, onBeforeUnmount as Ve, openBlock as c, createBlock as Q, unref as X, withCtx as W, createElementBlock as d, toDisplayString as v, createCommentVNode as V, createElementVNode as j, Fragment as K, renderList as I, resolveDynamicComponent as je, createVNode as ne, createTextVNode as we, nextTick as le } from "vue";
|
|
2
|
+
import { Form as Ee, FormItem as $e, Button as Se } from "aheart-ui";
|
|
3
|
+
import Re from "./form-field.vue.js";
|
|
4
|
+
import { validateAIFormSchema as qe } from "./form-schema.js";
|
|
5
|
+
const Ce = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "aheart-ai-form__header"
|
|
8
|
+
}, xe = { key: 0 }, Me = { key: 1 }, Ne = {
|
|
9
|
+
key: 1,
|
|
10
|
+
class: "aheart-ai-form__error-summary",
|
|
11
|
+
role: "alert",
|
|
12
|
+
tabindex: "-1"
|
|
13
|
+
}, Te = ["onClick"], Pe = { key: 0 }, Ue = { key: 0 }, Be = {
|
|
14
|
+
key: 2,
|
|
15
|
+
class: "aheart-ai-form__submit-error",
|
|
16
|
+
role: "alert"
|
|
17
|
+
}, De = { class: "aheart-ai-form__footer" }, We = {
|
|
18
|
+
key: 1,
|
|
19
|
+
class: "aheart-ai-form__error",
|
|
20
|
+
role: "alert"
|
|
21
|
+
}, Qe = /* @__PURE__ */ Ae({
|
|
22
|
+
name: "AAIForm",
|
|
23
|
+
__name: "form",
|
|
24
|
+
props: {
|
|
25
|
+
modelValue: { default: () => ({}) },
|
|
26
|
+
schema: {},
|
|
27
|
+
disabled: { type: Boolean, default: !1 },
|
|
28
|
+
submitting: { type: Boolean, default: !1 },
|
|
29
|
+
submitText: { default: "提交" },
|
|
30
|
+
submitError: { default: void 0 },
|
|
31
|
+
validators: { default: () => ({}) }
|
|
32
|
+
},
|
|
33
|
+
emits: ["update:modelValue", "submit", "schema-error", "validation-error"],
|
|
34
|
+
setup(p, { expose: ie, emit: ce }) {
|
|
35
|
+
const u = p, w = ce, i = R(() => {
|
|
36
|
+
const e = qe(u.schema);
|
|
37
|
+
if (!e.valid || !e.schema) return e;
|
|
38
|
+
const t = e.schema.fields.flatMap((r) => (r.rules ?? []).filter((a) => a.kind === "async" && !(Object.prototype.hasOwnProperty.call(u.validators, a.validator) && typeof u.validators[a.validator] == "function")).map((a) => `fields.${r.key}.rules.${a.validator} validator 不存在`));
|
|
39
|
+
return t.length ? { valid: !1, errors: [...e.errors, ...t] } : e;
|
|
40
|
+
}), h = R(() => u.modelValue), b = R(
|
|
41
|
+
() => {
|
|
42
|
+
var e;
|
|
43
|
+
return (((e = i.value.schema) == null ? void 0 : e.fields) ?? []).reduce(
|
|
44
|
+
(t, r) => {
|
|
45
|
+
const a = Object.prototype.hasOwnProperty.call(h.value, r.key);
|
|
46
|
+
return !a && P.has(r.key) || (t[r.key] = a ? h.value[r.key] : r.defaultValue), t;
|
|
47
|
+
},
|
|
48
|
+
{ ...h.value }
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
), l = D({}), N = D({}), T = /* @__PURE__ */ new Map(), L = D({}), z = /* @__PURE__ */ new Map(), _ = q(), m = /* @__PURE__ */ new Map(), Z = () => {
|
|
52
|
+
for (const e of m.values()) e.abort();
|
|
53
|
+
m.clear();
|
|
54
|
+
}, G = q({}), P = D(/* @__PURE__ */ new Set()), g = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), ue = q(!1);
|
|
55
|
+
Fe(() => {
|
|
56
|
+
ue.value = !0;
|
|
57
|
+
});
|
|
58
|
+
const ee = q(!1), de = q(0), $ = q(!1);
|
|
59
|
+
k(
|
|
60
|
+
i,
|
|
61
|
+
(e) => {
|
|
62
|
+
e.valid || w("schema-error", e.errors);
|
|
63
|
+
},
|
|
64
|
+
{ immediate: !0 }
|
|
65
|
+
), k(b, (e) => {
|
|
66
|
+
Object.keys(G.value).length || (G.value = M(e));
|
|
67
|
+
}, { immediate: !0, deep: !0 }), k(
|
|
68
|
+
b,
|
|
69
|
+
(e, t) => {
|
|
70
|
+
Object.keys(N).forEach((r) => {
|
|
71
|
+
Object.prototype.hasOwnProperty.call(e, r) || delete N[r];
|
|
72
|
+
}), Object.entries(e).forEach(([r, a]) => {
|
|
73
|
+
const s = T.get(r);
|
|
74
|
+
T.has(r) ? F(a, s) && (T.delete(r), delete l[r]) : t && !F(a, t[r]) && delete l[r], N[r] = M(a);
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
{ immediate: !0, deep: !0 }
|
|
78
|
+
), k(h, (e) => {
|
|
79
|
+
for (const t of [...g]) {
|
|
80
|
+
const r = O.get(t), a = A.get(t), s = J(e);
|
|
81
|
+
if (s !== r) {
|
|
82
|
+
if (s !== r && !F(s, a)) {
|
|
83
|
+
g.delete(t), E.delete(t), O.delete(t), A.delete(t);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
Object.prototype.hasOwnProperty.call(e, t) ? (g.delete(t), E.delete(t), O.delete(t), A.delete(t)) : (P.add(t), g.delete(t), E.delete(t), O.delete(t), A.delete(t));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, { deep: !0 });
|
|
90
|
+
const H = (e) => {
|
|
91
|
+
if (!e) return !0;
|
|
92
|
+
const t = b.value[e.field];
|
|
93
|
+
return e.operator === "equals" ? t === e.value : e.operator === "not-equals" ? t !== e.value : e.operator === "includes" ? Array.isArray(t) ? t.includes(e.value) : String(t ?? "").includes(String(e.value ?? "")) : e.operator === "not-includes" ? Array.isArray(t) ? !t.includes(e.value) : !String(t ?? "").includes(String(e.value ?? "")) : e.operator === "is-empty" ? S(t) : !S(t);
|
|
94
|
+
}, C = R(
|
|
95
|
+
() => {
|
|
96
|
+
var e;
|
|
97
|
+
return ((e = i.value.schema) == null ? void 0 : e.fields.filter((t) => H(t.visibleWhen))) ?? [];
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
k(b, (e, t) => {
|
|
101
|
+
var n;
|
|
102
|
+
const r = t ?? {}, a = { ...h.value };
|
|
103
|
+
let s = !1;
|
|
104
|
+
for (const o of ((n = i.value.schema) == null ? void 0 : n.fields) ?? []) {
|
|
105
|
+
const f = te(o.visibleWhen, r), y = te(o.visibleWhen, e);
|
|
106
|
+
y && g.has(o.key) && !P.has(o.key) && (g.delete(o.key), E.delete(o.key), O.delete(o.key), A.delete(o.key)), f && !y && o.preserve === !1 && (delete a[o.key], g.add(o.key), E.set(o.key, Object.prototype.hasOwnProperty.call(h.value, o.key)), O.set(o.key, J(h.value)), A.set(o.key, J(a)), s = !0);
|
|
107
|
+
}
|
|
108
|
+
s && w("update:modelValue", a);
|
|
109
|
+
}, { deep: !0 }), k(b, (e, t) => {
|
|
110
|
+
var a, s;
|
|
111
|
+
const r = t ?? {};
|
|
112
|
+
for (const n of ((a = i.value.schema) == null ? void 0 : a.fields) ?? []) {
|
|
113
|
+
const o = oe(n);
|
|
114
|
+
(!F(e[n.key], r[n.key]) || o.some((y) => !F(e[y], r[y]))) && ((s = m.get(n.key)) == null || s.abort(), m.delete(n.key));
|
|
115
|
+
}
|
|
116
|
+
}, { deep: !0 }), k(() => u.schema, () => {
|
|
117
|
+
for (const e of m.values()) e.abort();
|
|
118
|
+
m.clear();
|
|
119
|
+
});
|
|
120
|
+
const te = (e, t) => {
|
|
121
|
+
if (!e) return !0;
|
|
122
|
+
const r = t[e.field];
|
|
123
|
+
return e.operator === "equals" ? r === e.value : e.operator === "not-equals" ? r !== e.value : e.operator === "is-empty" ? S(r) : e.operator === "is-not-empty" ? !S(r) : e.operator === "includes" ? Array.isArray(r) ? r.includes(e.value) : String(r ?? "").includes(String(e.value ?? "")) : Array.isArray(r) ? !r.includes(e.value) : !String(r ?? "").includes(String(e.value ?? ""));
|
|
124
|
+
}, x = (e) => u.disabled || u.submitting || !!(e.disabledWhen && H(e.disabledWhen)), me = R(() => {
|
|
125
|
+
const e = i.value.schema;
|
|
126
|
+
if (!e) return [];
|
|
127
|
+
const t = (e.groups ?? []).map((a) => ({
|
|
128
|
+
key: a.key,
|
|
129
|
+
group: a,
|
|
130
|
+
fields: C.value.filter((s) => s.group === a.key)
|
|
131
|
+
})).filter((a) => a.fields.length > 0), r = C.value.filter((a) => !a.group);
|
|
132
|
+
return r.length && t.push({ key: "__ungrouped", fields: r }), t;
|
|
133
|
+
}), Y = R(
|
|
134
|
+
() => C.value.filter((e) => l[e.key]).map((e) => ({ key: e.key, message: l[e.key] }))
|
|
135
|
+
);
|
|
136
|
+
k([b, C], () => {
|
|
137
|
+
var t;
|
|
138
|
+
const e = ((t = i.value.schema) == null ? void 0 : t.fields) ?? [];
|
|
139
|
+
Object.keys(l).forEach((r) => {
|
|
140
|
+
const a = e.find((s) => s.key === r);
|
|
141
|
+
(!a || !H(a.visibleWhen) || x(a)) && delete l[r];
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
function S(e) {
|
|
145
|
+
return e == null || e === "" || e === !1 || Array.isArray(e) && (e.length === 0 || e.every((t) => t == null || t === ""));
|
|
146
|
+
}
|
|
147
|
+
function F(e, t) {
|
|
148
|
+
if (Object.is(e, t)) return !0;
|
|
149
|
+
if (Array.isArray(e) || Array.isArray(t))
|
|
150
|
+
return Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((r, a) => F(r, t[a]));
|
|
151
|
+
if (e && t && typeof e == "object" && typeof t == "object") {
|
|
152
|
+
const r = e, a = t, s = Object.keys(r), n = Object.keys(a);
|
|
153
|
+
return s.length === n.length && s.every((o) => Object.prototype.hasOwnProperty.call(a, o) && F(r[o], a[o]));
|
|
154
|
+
}
|
|
155
|
+
return !1;
|
|
156
|
+
}
|
|
157
|
+
function M(e) {
|
|
158
|
+
return Array.isArray(e) ? e.map((t) => M(t)) : e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype ? Object.fromEntries(Object.entries(e).map(([t, r]) => [t, M(r)])) : e;
|
|
159
|
+
}
|
|
160
|
+
const fe = (e, t) => e.type === "date-range" || e.type === "time-range" ? !Array.isArray(t) || t.length !== 2 || t.some((r) => r == null || r === "") : S(t), ye = (e) => {
|
|
161
|
+
const t = b.value[e.key];
|
|
162
|
+
if (t !== void 0) return t;
|
|
163
|
+
if (e.type === "checkbox" || e.type === "upload") return [];
|
|
164
|
+
if (!(e.type === "date-range" || e.type === "time-range"))
|
|
165
|
+
return "";
|
|
166
|
+
}, pe = (e) => `${e.key}-${L[e.key] ?? 0}`, he = (e, t) => {
|
|
167
|
+
t && typeof t.focus == "function" ? z.set(e, t) : z.delete(e);
|
|
168
|
+
}, re = (e) => {
|
|
169
|
+
var t;
|
|
170
|
+
return (t = z.get(e)) == null ? void 0 : t.focus();
|
|
171
|
+
}, be = async (e, t) => {
|
|
172
|
+
T.set(e, t), w("update:modelValue", { ...h.value, [e]: t }), await le(), h.value[e] !== t && (L[e] = (L[e] ?? 0) + 1);
|
|
173
|
+
}, ve = (e) => {
|
|
174
|
+
if (x(e)) return [];
|
|
175
|
+
const t = [];
|
|
176
|
+
if (e.required && !x(e)) {
|
|
177
|
+
const r = `${e.label}为必填项`;
|
|
178
|
+
t.push({ required: !0, message: r }, { message: r, validator: (a, s) => fe(e, s) ? r : void 0 });
|
|
179
|
+
}
|
|
180
|
+
for (const r of e.rules ?? []) t.push(ge(e, r));
|
|
181
|
+
return t;
|
|
182
|
+
}, ae = (e) => {
|
|
183
|
+
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
|
|
184
|
+
const [t, r, a] = e.split("-").map(Number), s = new Date(Date.UTC(t, r - 1, a));
|
|
185
|
+
return s.getUTCFullYear() === t && s.getUTCMonth() === r - 1 && s.getUTCDate() === a;
|
|
186
|
+
}, se = (e) => typeof e == "string" && /^\d{2}:\d{2}:\d{2}$/.test(e) && e.split(":").map(Number).every((t, r) => r === 0 ? t < 24 : t < 60), ge = (e, t) => ({
|
|
187
|
+
...t.kind === "format" && t.format === "email" ? { type: "email" } : {},
|
|
188
|
+
...t.kind === "range" && t.min !== void 0 ? { min: t.min } : {},
|
|
189
|
+
...t.kind === "range" && t.max !== void 0 ? { max: t.max } : {},
|
|
190
|
+
message: t.message ?? `${e.label}校验失败`,
|
|
191
|
+
validator: (r, a) => {
|
|
192
|
+
if (!e.required && S(a)) return;
|
|
193
|
+
if (t.kind === "range") {
|
|
194
|
+
const o = t.valueType === "number" ? typeof a == "number" && Number.isFinite(a) ? a : void 0 : typeof a == "string" || Array.isArray(a) ? a.length : void 0;
|
|
195
|
+
return o === void 0 || t.min !== void 0 && o < t.min || t.max !== void 0 && o > t.max ? t.message ?? `${e.label}范围不合法` : void 0;
|
|
196
|
+
}
|
|
197
|
+
if (t.kind === "format")
|
|
198
|
+
return typeof a != "string" ? t.message ?? `${e.label}格式不合法` : (t.format === "email" ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a) : t.format === "url" ? (() => {
|
|
199
|
+
try {
|
|
200
|
+
const f = new URL(a);
|
|
201
|
+
return f.protocol === "http:" || f.protocol === "https:";
|
|
202
|
+
} catch {
|
|
203
|
+
return !1;
|
|
204
|
+
}
|
|
205
|
+
})() : t.format === "date" ? /^\d{4}-\d{2}-\d{2}$/.test(a) && ae(a) : se(a)) ? void 0 : t.message ?? `${e.label}格式不合法`;
|
|
206
|
+
if (t.kind === "compare") {
|
|
207
|
+
const o = b.value[t.field];
|
|
208
|
+
if (!(typeof a == typeof o && (typeof a == "number" ? Number.isFinite(a) && Number.isFinite(o) : !0))) return t.message ?? `${e.label}与${t.field}类型不匹配`;
|
|
209
|
+
if (["greater-than", "greater-than-or-equal", "less-than", "less-than-or-equal"].includes(t.operator)) {
|
|
210
|
+
const U = (B) => typeof B == "number" && Number.isFinite(B) ? "number" : ae(B) ? "date" : se(B) ? "time" : void 0;
|
|
211
|
+
if (!U(a) || !U(o) || U(a) !== U(o)) return t.message ?? `${e.label}有序比较不合法`;
|
|
212
|
+
}
|
|
213
|
+
return (t.operator === "equals" ? a === o : t.operator === "not-equals" ? a !== o : t.operator === "greater-than" ? a > o : t.operator === "greater-than-or-equal" ? a >= o : t.operator === "less-than" ? a < o : a <= o) ? void 0 : t.message ?? `${e.label}比较不成立`;
|
|
214
|
+
}
|
|
215
|
+
const s = m.get(e.key) ?? new AbortController();
|
|
216
|
+
m.set(e.key, s);
|
|
217
|
+
const n = Object.prototype.hasOwnProperty.call(u.validators, t.validator) && typeof u.validators[t.validator] == "function" ? u.validators[t.validator] : void 0;
|
|
218
|
+
if (!n) return `${e.label}校验器不存在`;
|
|
219
|
+
try {
|
|
220
|
+
const o = n(a, { values: b.value, field: e, signal: s.signal }), f = (y) => {
|
|
221
|
+
if (!s.signal.aborted) {
|
|
222
|
+
if (y === !1) return t.message ?? `${e.label}校验失败`;
|
|
223
|
+
if (typeof y == "string") return y;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
return o && typeof o.then == "function" ? o.then(f) : f(o);
|
|
227
|
+
} catch (o) {
|
|
228
|
+
return s.signal.aborted ? void 0 : o instanceof Error ? o.message : t.message ?? `${e.label}校验失败`;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}), ke = () => {
|
|
232
|
+
var e, t;
|
|
233
|
+
u.disabled || u.submitting || ($.value = !1, Z(), (t = (e = _.value) == null ? void 0 : e.clearValidate) == null || t.call(e), Object.keys(l).forEach((r) => delete l[r]), ee.value = !1);
|
|
234
|
+
}, oe = (e) => Array.from(/* @__PURE__ */ new Set([...e.dependencies ?? [], ...(e.rules ?? []).filter((t) => t.kind === "compare").map((t) => t.field)])), _e = (e) => {
|
|
235
|
+
if ($.value) {
|
|
236
|
+
$.value = !1;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
u.disabled || u.submitting || ee.value || w("submit", { ...e });
|
|
240
|
+
}, Oe = (e) => {
|
|
241
|
+
if ($.value) {
|
|
242
|
+
$.value = !1;
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (u.disabled || u.submitting) return;
|
|
246
|
+
const t = e.errorFields.map((r) => {
|
|
247
|
+
var o;
|
|
248
|
+
const a = typeof r.name == "string" ? r.name : String(r.name[0]), s = (o = i.value.schema) == null ? void 0 : o.fields.find((f) => f.key === a), n = r.errors[0] || `${(s == null ? void 0 : s.label) ?? a}为必填项`;
|
|
249
|
+
return { key: a, message: n };
|
|
250
|
+
}).filter((r) => C.value.some((a) => a.key === r.key) && !x(i.value.schema.fields.find((a) => a.key === r.key)));
|
|
251
|
+
t.forEach((r) => {
|
|
252
|
+
l[r.key] = r.message;
|
|
253
|
+
}), t.length && (w("validation-error", t), le(() => re(t[0].key)));
|
|
254
|
+
};
|
|
255
|
+
return ie({ validate: () => {
|
|
256
|
+
var e, t;
|
|
257
|
+
return Z(), Promise.resolve(((t = (e = _.value) == null ? void 0 : e.validate) == null ? void 0 : t.call(e)) ?? { errorFields: [] }).then((r) => {
|
|
258
|
+
var a;
|
|
259
|
+
Object.keys(l).forEach((s) => delete l[s]);
|
|
260
|
+
for (const s of r.errorFields ?? []) {
|
|
261
|
+
const n = typeof s.name == "string" ? s.name : String(s.name[0]);
|
|
262
|
+
(a = s.errors) != null && a[0] && (l[n] = s.errors[0]);
|
|
263
|
+
}
|
|
264
|
+
return r;
|
|
265
|
+
});
|
|
266
|
+
}, resetFields: () => {
|
|
267
|
+
var t, r, a, s, n;
|
|
268
|
+
for (const o of m.values()) o.abort();
|
|
269
|
+
m.clear(), P.clear(), g.clear(), E.clear(), O.clear(), A.clear(), de.value += 1, $.value = !0, Object.keys(l).forEach((o) => delete l[o]);
|
|
270
|
+
const e = (((t = i.value.schema) == null ? void 0 : t.fields) ?? []).map((o) => ({ name: o.key, errors: [] }));
|
|
271
|
+
(a = (r = _.value) == null ? void 0 : r.clearValidate) == null || a.call(r), (n = (s = _.value) == null ? void 0 : s.setFieldsErrors) == null || n.call(s, e), Object.keys(l).forEach((o) => delete l[o]), w("update:modelValue", M(G.value));
|
|
272
|
+
}, clearValidate: (e) => {
|
|
273
|
+
var t, r;
|
|
274
|
+
e ? e.forEach((a) => delete l[a]) : Object.keys(l).forEach((a) => delete l[a]), (r = (t = _.value) == null ? void 0 : t.clearValidate) == null || r.call(t, e);
|
|
275
|
+
}, setFieldsErrors: (e) => {
|
|
276
|
+
var t, r;
|
|
277
|
+
e.forEach((a) => {
|
|
278
|
+
a.errors[0] ? l[a.name] = a.errors[0] : delete l[a.name];
|
|
279
|
+
}), (r = (t = _.value) == null ? void 0 : t.setFieldsErrors) == null || r.call(t, e);
|
|
280
|
+
} }), Ve(() => {
|
|
281
|
+
for (const e of m.values()) e.abort();
|
|
282
|
+
}), (e, t) => i.value.valid && i.value.schema ? (c(), Q(X(Ee), {
|
|
283
|
+
key: 0,
|
|
284
|
+
ref_key: "formElement",
|
|
285
|
+
ref: _,
|
|
286
|
+
class: "aheart-ai-form",
|
|
287
|
+
model: N,
|
|
288
|
+
disabled: p.disabled || p.submitting,
|
|
289
|
+
"required-mark": !1,
|
|
290
|
+
layout: "vertical",
|
|
291
|
+
"aria-busy": p.submitting ? "true" : "false",
|
|
292
|
+
onSubmit: ke,
|
|
293
|
+
onFinish: _e,
|
|
294
|
+
onFinishFailed: Oe
|
|
295
|
+
}, {
|
|
296
|
+
default: W(() => [
|
|
297
|
+
i.value.schema.title || i.value.schema.description ? (c(), d("header", Ce, [
|
|
298
|
+
i.value.schema.title ? (c(), d("h2", xe, v(i.value.schema.title), 1)) : V("", !0),
|
|
299
|
+
i.value.schema.description ? (c(), d("p", Me, v(i.value.schema.description), 1)) : V("", !0)
|
|
300
|
+
])) : V("", !0),
|
|
301
|
+
Y.value.length ? (c(), d("div", Ne, [
|
|
302
|
+
j("strong", null, "请解决 " + v(Y.value.length) + " 个校验问题", 1),
|
|
303
|
+
j("ul", null, [
|
|
304
|
+
(c(!0), d(K, null, I(Y.value, (r) => (c(), d("li", {
|
|
305
|
+
key: r.key
|
|
306
|
+
}, [
|
|
307
|
+
j("button", {
|
|
308
|
+
type: "button",
|
|
309
|
+
onClick: (a) => re(r.key)
|
|
310
|
+
}, v(r.message), 9, Te)
|
|
311
|
+
]))), 128))
|
|
312
|
+
])
|
|
313
|
+
])) : V("", !0),
|
|
314
|
+
(c(!0), d(K, null, I(me.value, (r) => {
|
|
315
|
+
var a;
|
|
316
|
+
return c(), Q(je(r.group ? "fieldset" : "section"), {
|
|
317
|
+
key: r.key,
|
|
318
|
+
class: "aheart-ai-form__group",
|
|
319
|
+
"data-group-key": (a = r.group) == null ? void 0 : a.key
|
|
320
|
+
}, {
|
|
321
|
+
default: W(() => [
|
|
322
|
+
r.group ? (c(), d("legend", Pe, [
|
|
323
|
+
j("span", null, v(r.group.title), 1),
|
|
324
|
+
r.group.description ? (c(), d("small", Ue, v(r.group.description), 1)) : V("", !0)
|
|
325
|
+
])) : V("", !0),
|
|
326
|
+
(c(!0), d(K, null, I(r.fields, (s) => (c(), Q(X($e), {
|
|
327
|
+
key: pe(s),
|
|
328
|
+
name: s.key,
|
|
329
|
+
rules: ve(s),
|
|
330
|
+
dependencies: oe(s),
|
|
331
|
+
"no-style": ""
|
|
332
|
+
}, {
|
|
333
|
+
default: W(() => [
|
|
334
|
+
ne(Re, {
|
|
335
|
+
ref_for: !0,
|
|
336
|
+
ref: (n) => he(s.key, n),
|
|
337
|
+
field: s,
|
|
338
|
+
value: ye(s),
|
|
339
|
+
disabled: x(s),
|
|
340
|
+
error: l[s.key],
|
|
341
|
+
onUpdate: (n) => be(s.key, n)
|
|
342
|
+
}, null, 8, ["field", "value", "disabled", "error", "onUpdate"])
|
|
343
|
+
]),
|
|
344
|
+
_: 2
|
|
345
|
+
}, 1032, ["name", "rules", "dependencies"]))), 128))
|
|
346
|
+
]),
|
|
347
|
+
_: 2
|
|
348
|
+
}, 1032, ["data-group-key"]);
|
|
349
|
+
}), 128)),
|
|
350
|
+
p.submitError ? (c(), d("p", Be, v(p.submitError), 1)) : V("", !0),
|
|
351
|
+
j("footer", De, [
|
|
352
|
+
ne(X(Se), {
|
|
353
|
+
"html-type": "submit",
|
|
354
|
+
type: "primary",
|
|
355
|
+
loading: p.submitting,
|
|
356
|
+
disabled: p.disabled
|
|
357
|
+
}, {
|
|
358
|
+
default: W(() => [
|
|
359
|
+
we(v(p.submitText), 1)
|
|
360
|
+
]),
|
|
361
|
+
_: 1
|
|
362
|
+
}, 8, ["loading", "disabled"])
|
|
363
|
+
])
|
|
364
|
+
]),
|
|
365
|
+
_: 1
|
|
366
|
+
}, 8, ["model", "disabled", "aria-busy"])) : (c(), d("div", We, [
|
|
367
|
+
t[0] || (t[0] = j("strong", null, "表单配置无效", -1)),
|
|
368
|
+
j("ul", null, [
|
|
369
|
+
(c(!0), d(K, null, I(i.value.errors, (r) => (c(), d("li", { key: r }, v(r), 1))), 128))
|
|
370
|
+
])
|
|
371
|
+
]));
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
export {
|
|
375
|
+
Qe as default
|
|
376
|
+
};
|
package/es/form.vue2.js
ADDED
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import AIChatPanel from './chat-panel.vue';
|
|
2
|
+
import AIActions from './actions.vue';
|
|
3
|
+
import AIAttachments from './attachments.vue';
|
|
4
|
+
import AIBubble from './bubble.vue';
|
|
5
|
+
import AIConversations from './conversations.vue';
|
|
6
|
+
import AIProcess from './process.vue';
|
|
7
|
+
import AIPrompts from './prompts.vue';
|
|
8
|
+
import AISender from './sender.vue';
|
|
9
|
+
import AISources from './sources.vue';
|
|
10
|
+
import AIThoughtChain from './thought-chain.vue';
|
|
11
|
+
import AIWelcome from './welcome.vue';
|
|
12
|
+
import AIForm from './form.vue';
|
|
13
|
+
import AIAgentWorkbench from './agent-workbench.vue';
|
|
14
|
+
export { AIActions, AIAgentWorkbench, AIAttachments, AIBubble, AIChatPanel, AIConversations, AIForm, AIProcess, AIPrompts, AISender, AISources, AIThoughtChain, AIWelcome };
|
|
15
|
+
export * from './types';
|
|
16
|
+
export * from './form-schema';
|
|
17
|
+
export * from './stream-reducer';
|
|
18
|
+
declare const AheartAI: Plugin;
|
|
19
|
+
export default AheartAI;
|
|
20
|
+
import type { Plugin } from 'vue';
|
package/es/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import m from "./chat-panel.vue.js";
|
|
2
|
+
import n from "./actions.vue.js";
|
|
3
|
+
import t from "./attachments.vue.js";
|
|
4
|
+
import e from "./bubble.vue.js";
|
|
5
|
+
import r from "./conversations.vue.js";
|
|
6
|
+
import A from "./process.vue.js";
|
|
7
|
+
import s from "./prompts.vue.js";
|
|
8
|
+
import c from "./sender.vue.js";
|
|
9
|
+
import a from "./sources.vue.js";
|
|
10
|
+
import i from "./thought-chain.vue.js";
|
|
11
|
+
import I from "./welcome.vue.js";
|
|
12
|
+
import _ from "./form.vue.js";
|
|
13
|
+
import f from "./agent-workbench.vue.js";
|
|
14
|
+
/* empty css */
|
|
15
|
+
import { AI_FORM_CONDITION_OPERATORS as W, AI_FORM_FIELD_TYPES as x, validateAIFormSchema as k } from "./form-schema.js";
|
|
16
|
+
import { createAIStreamReducer as D, reduceAIStreamEvent as M } from "./stream-reducer.js";
|
|
17
|
+
const g = {
|
|
18
|
+
install(o) {
|
|
19
|
+
o.component("AAIActions", n), o.component("AAIAgentWorkbench", f), o.component("AAIAttachments", t), o.component("AAIBubble", e), o.component("AAIChatPanel", m), o.component("AAIConversations", r), o.component("AAIForm", _), o.component("AAIProcess", A), o.component("AAIPrompts", s), o.component("AAISender", c), o.component("AAISources", a), o.component("AAIThoughtChain", i), o.component("AAIWelcome", I);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
n as AIActions,
|
|
24
|
+
f as AIAgentWorkbench,
|
|
25
|
+
t as AIAttachments,
|
|
26
|
+
e as AIBubble,
|
|
27
|
+
m as AIChatPanel,
|
|
28
|
+
r as AIConversations,
|
|
29
|
+
_ as AIForm,
|
|
30
|
+
A as AIProcess,
|
|
31
|
+
s as AIPrompts,
|
|
32
|
+
c as AISender,
|
|
33
|
+
a as AISources,
|
|
34
|
+
i as AIThoughtChain,
|
|
35
|
+
I as AIWelcome,
|
|
36
|
+
W as AI_FORM_CONDITION_OPERATORS,
|
|
37
|
+
x as AI_FORM_FIELD_TYPES,
|
|
38
|
+
D as createAIStreamReducer,
|
|
39
|
+
g as default,
|
|
40
|
+
M as reduceAIStreamEvent,
|
|
41
|
+
k as validateAIFormSchema
|
|
42
|
+
};
|
package/es/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AIProcessItem } from './types';
|
|
2
|
+
declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
3
|
+
items?: AIProcessItem[] | undefined;
|
|
4
|
+
}>, {
|
|
5
|
+
items: () => never[];
|
|
6
|
+
}>>, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
items?: AIProcessItem[] | undefined;
|
|
8
|
+
}>, {
|
|
9
|
+
items: () => never[];
|
|
10
|
+
}>>> & Readonly<{}>, {
|
|
11
|
+
items: AIProcessItem[];
|
|
12
|
+
}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
15
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
16
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
17
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
18
|
+
} : {
|
|
19
|
+
type: import('vue').PropType<T[K]>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type __VLS_WithDefaults<P, D> = {
|
|
24
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
25
|
+
default: D[K];
|
|
26
|
+
}> : P[K];
|
|
27
|
+
};
|
|
28
|
+
type __VLS_Prettify<T> = {
|
|
29
|
+
[K in keyof T]: T[K];
|
|
30
|
+
} & {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineComponent as i, openBlock as t, createElementBlock as s, createElementVNode as l, Fragment as c, renderList as u, normalizeClass as m, toDisplayString as r, createCommentVNode as o } from "vue";
|
|
2
|
+
const d = {
|
|
3
|
+
key: 0,
|
|
4
|
+
class: "aheart-ai-process",
|
|
5
|
+
"aria-label": "执行进度"
|
|
6
|
+
}, p = { key: 0 }, k = /* @__PURE__ */ i({
|
|
7
|
+
name: "AAIProcess",
|
|
8
|
+
__name: "process",
|
|
9
|
+
props: {
|
|
10
|
+
items: { default: () => [] }
|
|
11
|
+
},
|
|
12
|
+
setup(n) {
|
|
13
|
+
return (_, a) => n.items.length ? (t(), s("section", d, [
|
|
14
|
+
a[0] || (a[0] = l("h3", null, "执行进度", -1)),
|
|
15
|
+
l("ol", null, [
|
|
16
|
+
(t(!0), s(c, null, u(n.items, (e) => (t(), s("li", {
|
|
17
|
+
key: e.id,
|
|
18
|
+
class: m(`is-${e.status}`)
|
|
19
|
+
}, [
|
|
20
|
+
l("span", null, r(e.label), 1),
|
|
21
|
+
e.detail ? (t(), s("small", p, r(e.detail), 1)) : o("", !0)
|
|
22
|
+
], 2))), 128))
|
|
23
|
+
])
|
|
24
|
+
])) : o("", !0);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
k as default
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AIPrompt } from './types';
|
|
2
|
+
declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
3
|
+
prompts?: AIPrompt[] | undefined;
|
|
4
|
+
disabled?: boolean | undefined;
|
|
5
|
+
}>, {
|
|
6
|
+
prompts: () => never[];
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
}>>, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
|
|
9
|
+
select: (prompt: AIPrompt) => void;
|
|
10
|
+
}, string, import("@vue/runtime-core").PublicProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
11
|
+
prompts?: AIPrompt[] | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
prompts: () => never[];
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}>>> & Readonly<{
|
|
17
|
+
onSelect?: ((prompt: AIPrompt) => any) | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
prompts: AIPrompt[];
|
|
21
|
+
}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
|
|
22
|
+
export default _default;
|
|
23
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
24
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
25
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
26
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
27
|
+
} : {
|
|
28
|
+
type: import('vue').PropType<T[K]>;
|
|
29
|
+
required: true;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type __VLS_WithDefaults<P, D> = {
|
|
33
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
34
|
+
default: D[K];
|
|
35
|
+
}> : P[K];
|
|
36
|
+
};
|
|
37
|
+
type __VLS_Prettify<T> = {
|
|
38
|
+
[K in keyof T]: T[K];
|
|
39
|
+
} & {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineComponent as r, openBlock as t, createElementBlock as n, Fragment as c, renderList as d, createElementVNode as o, toDisplayString as l, createCommentVNode as m } from "vue";
|
|
2
|
+
const u = {
|
|
3
|
+
class: "aheart-ai-prompts",
|
|
4
|
+
"aria-label": "建议任务"
|
|
5
|
+
}, p = ["disabled", "onClick"], _ = { key: 0 }, h = /* @__PURE__ */ r({
|
|
6
|
+
name: "AAIPrompts",
|
|
7
|
+
__name: "prompts",
|
|
8
|
+
props: {
|
|
9
|
+
prompts: { default: () => [] },
|
|
10
|
+
disabled: { type: Boolean, default: !1 }
|
|
11
|
+
},
|
|
12
|
+
emits: ["select"],
|
|
13
|
+
setup(s, { emit: a }) {
|
|
14
|
+
const i = a;
|
|
15
|
+
return (b, f) => (t(), n("ul", u, [
|
|
16
|
+
(t(!0), n(c, null, d(s.prompts, (e) => (t(), n("li", {
|
|
17
|
+
key: e.key
|
|
18
|
+
}, [
|
|
19
|
+
o("button", {
|
|
20
|
+
type: "button",
|
|
21
|
+
disabled: s.disabled,
|
|
22
|
+
onClick: (k) => i("select", e)
|
|
23
|
+
}, [
|
|
24
|
+
o("strong", null, l(e.label), 1),
|
|
25
|
+
e.description ? (t(), n("span", _, l(e.description), 1)) : m("", !0)
|
|
26
|
+
], 8, p)
|
|
27
|
+
]))), 128))
|
|
28
|
+
]));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
h as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { h as s } from "vue";
|
|
2
|
+
const l = (e) => e && /^(https?:|mailto:)/i.test(e) ? e : void 0, h = /(\*\*([^*]+)\*\*|\*([^*]+)\*|\[([^\]]+)\]\(([^)]+)\))/g, c = (e) => {
|
|
3
|
+
const r = [];
|
|
4
|
+
let n = 0;
|
|
5
|
+
for (const t of e.matchAll(h)) {
|
|
6
|
+
const o = t.index ?? 0;
|
|
7
|
+
if (o > n && r.push(e.slice(n, o)), t[2])
|
|
8
|
+
r.push(s("strong", t[2]));
|
|
9
|
+
else if (t[3])
|
|
10
|
+
r.push(s("em", t[3]));
|
|
11
|
+
else {
|
|
12
|
+
const i = l(t[5]);
|
|
13
|
+
r.push(i ? s("a", { href: i, target: "_blank", rel: "noreferrer" }, t[4]) : t[4]);
|
|
14
|
+
}
|
|
15
|
+
n = o + t[0].length;
|
|
16
|
+
}
|
|
17
|
+
return n < e.length && r.push(e.slice(n)), r;
|
|
18
|
+
}, p = (e) => e.split(`
|
|
19
|
+
`).flatMap((n, t) => t === 0 ? c(n) : [s("br"), ...c(n)]);
|
|
20
|
+
export {
|
|
21
|
+
l as getSafeUrl,
|
|
22
|
+
p as renderSafeMarkdown
|
|
23
|
+
};
|