yc-agent-ui 1.2.2 → 1.2.4
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/es/components/dialog/index.d.ts +6 -6
- package/es/components/dialog/src/index.vue.d.ts +2 -2
- package/es/components/dialog-form/index.d.ts +6 -6
- package/es/components/dialog-form/src/index.vue.d.ts +6 -6
- package/es/components/display-item/index.d.ts +21 -21
- package/es/components/display-item/src/index.vue.d.ts +19 -19
- package/es/components/drawer-form/index.d.ts +18 -18
- package/es/components/drawer-form/src/index.vue.d.ts +10 -10
- package/es/components/form/index.d.ts +12 -12
- package/es/components/form/src/form-content.vue.d.ts +12 -12
- package/es/components/form/src/index.vue.d.ts +12 -12
- package/es/components/form-item/index.d.ts +12 -12
- package/es/components/form-item/src/index.vue.d.ts +10 -10
- package/es/components/page/index.d.ts +258 -258
- package/es/components/page/src/index.vue.d.ts +90 -90
- package/es/components/render/index.d.ts +1 -1
- package/es/components/render/src/index.vue.d.ts +1 -1
- package/es/components/search/index.d.ts +78 -78
- package/es/components/search/src/index.vue.d.ts +30 -30
- package/es/components/table/src/table-column.vue.d.ts +46 -46
- package/es/components/yc-ai-chat/index.d.ts +2 -1
- package/es/components/yc-ai-chat/src/question-card.vue.d.ts +17 -0
- package/es/components/yc-ai-chat/src/question-validation.d.ts +5 -0
- package/es/components/yc-ai-chat/src/sidebar.vue.d.ts +19 -1
- package/es/components/yc-ai-chat/src/studio.vue.d.ts +6 -0
- package/es/components/yc-ai-chat/src/type.d.ts +53 -0
- package/es/components/yc-plus-page/src/index.vue.d.ts +264 -264
- package/es/components/yc-select-v2/src/index.vue.d.ts +1 -1
- package/es/hooks/usePlusFormReset.d.ts +144 -144
- package/es/index.css +10 -10
- package/es/index.mjs +1 -0
- package/es/packages/components/index.mjs +1 -0
- package/es/packages/components/yc-ai-chat/index.mjs +1 -0
- package/es/packages/components/yc-ai-chat/src/question-card.vue.mjs +5 -0
- package/es/packages/components/yc-ai-chat/src/question-card2.vue.mjs +459 -0
- package/es/packages/components/yc-ai-chat/src/question-validation.mjs +77 -0
- package/es/packages/components/yc-ai-chat/src/sidebar2.vue.mjs +709 -129
- package/es/packages/components/yc-ai-chat/src/studio2.vue.mjs +194 -42
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/index.css +1 -1
- package/index.js +2932 -1667
- package/index.min.js +26 -26
- package/index.min.mjs +25 -25
- package/index.mjs +2915 -1651
- package/lib/components/dialog/index.d.ts +6 -6
- package/lib/components/dialog/src/index.vue.d.ts +2 -2
- package/lib/components/dialog-form/index.d.ts +6 -6
- package/lib/components/dialog-form/src/index.vue.d.ts +6 -6
- package/lib/components/display-item/index.d.ts +21 -21
- package/lib/components/display-item/src/index.vue.d.ts +19 -19
- package/lib/components/drawer-form/index.d.ts +18 -18
- package/lib/components/drawer-form/src/index.vue.d.ts +10 -10
- package/lib/components/form/index.d.ts +12 -12
- package/lib/components/form/src/form-content.vue.d.ts +12 -12
- package/lib/components/form/src/index.vue.d.ts +12 -12
- package/lib/components/form-item/index.d.ts +12 -12
- package/lib/components/form-item/src/index.vue.d.ts +10 -10
- package/lib/components/page/index.d.ts +258 -258
- package/lib/components/page/src/index.vue.d.ts +90 -90
- package/lib/components/render/index.d.ts +1 -1
- package/lib/components/render/src/index.vue.d.ts +1 -1
- package/lib/components/search/index.d.ts +78 -78
- package/lib/components/search/src/index.vue.d.ts +30 -30
- package/lib/components/table/src/table-column.vue.d.ts +46 -46
- package/lib/components/yc-ai-chat/index.d.ts +2 -1
- package/lib/components/yc-ai-chat/src/question-card.vue.d.ts +17 -0
- package/lib/components/yc-ai-chat/src/question-validation.d.ts +5 -0
- package/lib/components/yc-ai-chat/src/sidebar.vue.d.ts +19 -1
- package/lib/components/yc-ai-chat/src/studio.vue.d.ts +6 -0
- package/lib/components/yc-ai-chat/src/type.d.ts +53 -0
- package/lib/components/yc-plus-page/src/index.vue.d.ts +264 -264
- package/lib/components/yc-select-v2/src/index.vue.d.ts +1 -1
- package/lib/hooks/usePlusFormReset.d.ts +144 -144
- package/lib/index.css +9 -9
- package/lib/index.js +2 -0
- package/lib/packages/components/index.js +2 -0
- package/lib/packages/components/yc-ai-chat/index.js +2 -0
- package/lib/packages/components/yc-ai-chat/src/question-card.vue.js +9 -0
- package/lib/packages/components/yc-ai-chat/src/question-card2.vue.js +463 -0
- package/lib/packages/components/yc-ai-chat/src/question-validation.js +81 -0
- package/lib/packages/components/yc-ai-chat/src/sidebar2.vue.js +708 -128
- package/lib/packages/components/yc-ai-chat/src/studio2.vue.js +193 -41
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/locale/en.js +1 -1
- package/locale/en.min.js +1 -1
- package/locale/en.min.mjs +1 -1
- package/locale/en.mjs +1 -1
- package/locale/ja.js +1 -1
- package/locale/ja.min.js +1 -1
- package/locale/ja.min.mjs +1 -1
- package/locale/ja.mjs +1 -1
- package/locale/ko.js +1 -1
- package/locale/ko.min.js +1 -1
- package/locale/ko.min.mjs +1 -1
- package/locale/ko.mjs +1 -1
- package/locale/zh-cn.js +1 -1
- package/locale/zh-cn.min.js +1 -1
- package/locale/zh-cn.min.mjs +1 -1
- package/locale/zh-cn.mjs +1 -1
- package/locale/zh-tw.js +1 -1
- package/locale/zh-tw.min.js +1 -1
- package/locale/zh-tw.min.mjs +1 -1
- package/locale/zh-tw.mjs +1 -1
- package/package.json +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/plus-yc-ai-chat.css +1 -1
- package/theme-chalk/src/yc-ai-chat.scss +914 -103
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
var questionValidation = require('./question-validation.js');
|
|
7
|
+
|
|
8
|
+
const _hoisted_1 = ["data-state", "data-testid"];
|
|
9
|
+
const _hoisted_2 = { class: "yc-chat-question-card__header question-card__header" };
|
|
10
|
+
const _hoisted_3 = { class: "yc-chat-question-card__title-wrap" };
|
|
11
|
+
const _hoisted_4 = { class: "yc-chat-question-card__title" };
|
|
12
|
+
const _hoisted_5 = { class: "yc-chat-question-card__questions" };
|
|
13
|
+
const _hoisted_6 = ["disabled"];
|
|
14
|
+
const _hoisted_7 = { class: "yc-chat-question-card__legend" };
|
|
15
|
+
const _hoisted_8 = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "yc-chat-question-card__mode-tag"
|
|
18
|
+
};
|
|
19
|
+
const _hoisted_9 = { class: "yc-chat-question-card__options" };
|
|
20
|
+
const _hoisted_10 = ["data-testid", "type", "name", "checked", "onChange"];
|
|
21
|
+
const _hoisted_11 = {
|
|
22
|
+
key: 0,
|
|
23
|
+
viewBox: "0 0 12 12",
|
|
24
|
+
fill: "none"
|
|
25
|
+
};
|
|
26
|
+
const _hoisted_12 = { class: "yc-chat-question-card__option-body" };
|
|
27
|
+
const _hoisted_13 = { class: "yc-chat-question-card__option-label" };
|
|
28
|
+
const _hoisted_14 = {
|
|
29
|
+
key: 0,
|
|
30
|
+
class: "yc-chat-question-card__option-desc"
|
|
31
|
+
};
|
|
32
|
+
const _hoisted_15 = {
|
|
33
|
+
key: 1,
|
|
34
|
+
class: "yc-chat-question-card__event question-card__event"
|
|
35
|
+
};
|
|
36
|
+
const _hoisted_16 = ["data-testid", "type", "name", "checked", "onChange"];
|
|
37
|
+
const _hoisted_17 = {
|
|
38
|
+
key: 0,
|
|
39
|
+
viewBox: "0 0 12 12",
|
|
40
|
+
fill: "none"
|
|
41
|
+
};
|
|
42
|
+
const _hoisted_18 = { class: "yc-chat-question-card__option-body" };
|
|
43
|
+
const _hoisted_19 = { class: "yc-chat-question-card__option-label" };
|
|
44
|
+
const _hoisted_20 = {
|
|
45
|
+
key: 0,
|
|
46
|
+
class: "yc-chat-question-card__textarea-box"
|
|
47
|
+
};
|
|
48
|
+
const _hoisted_21 = ["onUpdate:modelValue", "data-testid"];
|
|
49
|
+
const _hoisted_22 = {
|
|
50
|
+
key: 0,
|
|
51
|
+
class: "yc-chat-question-card__notice question-card__notice"
|
|
52
|
+
};
|
|
53
|
+
const _hoisted_23 = {
|
|
54
|
+
key: 1,
|
|
55
|
+
class: "yc-chat-question-card__notice question-card__notice"
|
|
56
|
+
};
|
|
57
|
+
const _hoisted_24 = {
|
|
58
|
+
key: 2,
|
|
59
|
+
class: "yc-chat-question-card__notice question-card__notice",
|
|
60
|
+
"data-testid": "client-event-not-executed"
|
|
61
|
+
};
|
|
62
|
+
const _hoisted_25 = {
|
|
63
|
+
key: 3,
|
|
64
|
+
class: "yc-chat-question-card__actions question-card__actions"
|
|
65
|
+
};
|
|
66
|
+
const _hoisted_26 = ["disabled"];
|
|
67
|
+
const _hoisted_27 = ["disabled"];
|
|
68
|
+
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
69
|
+
...{
|
|
70
|
+
name: "YcChatQuestionCard"
|
|
71
|
+
},
|
|
72
|
+
__name: "question-card",
|
|
73
|
+
props: {
|
|
74
|
+
interaction: {},
|
|
75
|
+
submitting: { type: Boolean, default: false },
|
|
76
|
+
answerEnabled: { type: Boolean, default: true },
|
|
77
|
+
unavailableReason: { default: "" },
|
|
78
|
+
title: { default: "\u9700\u8981\u4F60\u7684\u56DE\u7B54" },
|
|
79
|
+
compact: { type: Boolean, default: false }
|
|
80
|
+
},
|
|
81
|
+
emits: ["answer", "cancel"],
|
|
82
|
+
setup(__props, { emit: __emit }) {
|
|
83
|
+
const props = __props;
|
|
84
|
+
const emit = __emit;
|
|
85
|
+
const selected = vue.reactive({});
|
|
86
|
+
const otherActive = vue.reactive({});
|
|
87
|
+
const otherText = vue.reactive({});
|
|
88
|
+
const statusLabels = {
|
|
89
|
+
preparing: "\u51C6\u5907\u4E2D",
|
|
90
|
+
pending: "\u5F85\u56DE\u7B54",
|
|
91
|
+
answered: "\u5DF2\u56DE\u7B54",
|
|
92
|
+
invalidated: "\u5DF2\u5931\u6548",
|
|
93
|
+
expired: "\u5DF2\u8FC7\u671F",
|
|
94
|
+
cancelled: "\u5DF2\u53D6\u6D88",
|
|
95
|
+
superseded: "\u5DF2\u88AB\u65B0\u6D88\u606F\u66FF\u4EE3"
|
|
96
|
+
};
|
|
97
|
+
vue.watch(
|
|
98
|
+
() => [props.interaction.request.request_id, props.interaction.answers],
|
|
99
|
+
() => {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
for (const question of props.interaction.request.questions) {
|
|
102
|
+
const answer = props.interaction.answers.find(
|
|
103
|
+
(item) => item.question_id === question.id
|
|
104
|
+
);
|
|
105
|
+
selected[question.id] = [...(_a = answer == null ? void 0 : answer.selected_option_ids) != null ? _a : []];
|
|
106
|
+
otherActive[question.id] = (answer == null ? void 0 : answer.other_text) != null;
|
|
107
|
+
otherText[question.id] = (_b = answer == null ? void 0 : answer.other_text) != null ? _b : "";
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{ immediate: true, deep: true }
|
|
111
|
+
);
|
|
112
|
+
const requestIsValid = vue.computed(
|
|
113
|
+
() => questionValidation.validChatQuestionRequest(props.interaction.request)
|
|
114
|
+
);
|
|
115
|
+
const canAnswer = vue.computed(
|
|
116
|
+
() => props.answerEnabled && props.interaction.state === "pending" && requestIsValid.value
|
|
117
|
+
);
|
|
118
|
+
const complete = vue.computed(
|
|
119
|
+
() => props.interaction.request.questions.every((question) => {
|
|
120
|
+
var _a, _b, _c;
|
|
121
|
+
if (otherActive[question.id]) {
|
|
122
|
+
return questionValidation.validChatOtherText((_a = otherText[question.id]) != null ? _a : "");
|
|
123
|
+
}
|
|
124
|
+
return ((_c = (_b = selected[question.id]) == null ? void 0 : _b.length) != null ? _c : 0) > 0;
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
function optionChecked(question, optionId) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
return (_b = (_a = selected[question.id]) == null ? void 0 : _a.includes(optionId)) != null ? _b : false;
|
|
130
|
+
}
|
|
131
|
+
function selectOption(question, optionId) {
|
|
132
|
+
var _a;
|
|
133
|
+
if (!canAnswer.value) return;
|
|
134
|
+
otherActive[question.id] = false;
|
|
135
|
+
otherText[question.id] = "";
|
|
136
|
+
if (question.selection_mode === "single") {
|
|
137
|
+
selected[question.id] = [optionId];
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const current = (_a = selected[question.id]) != null ? _a : [];
|
|
141
|
+
selected[question.id] = current.includes(optionId) ? current.filter((id) => id !== optionId) : [...current, optionId];
|
|
142
|
+
}
|
|
143
|
+
function selectOther(question, enabled) {
|
|
144
|
+
if (!canAnswer.value) return;
|
|
145
|
+
otherActive[question.id] = enabled;
|
|
146
|
+
if (enabled) selected[question.id] = [];
|
|
147
|
+
}
|
|
148
|
+
function eventSummary(option) {
|
|
149
|
+
if (!option.event) return "";
|
|
150
|
+
const text = JSON.stringify(option.event.payload);
|
|
151
|
+
return text.length > 160 ? `${text.slice(0, 157)}...` : text;
|
|
152
|
+
}
|
|
153
|
+
function submit() {
|
|
154
|
+
if (!canAnswer.value || !complete.value || props.submitting) return;
|
|
155
|
+
const answers = props.interaction.request.questions.map((question) => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
return {
|
|
158
|
+
question_id: question.id,
|
|
159
|
+
selected_option_ids: otherActive[question.id] ? [] : [...(_a = selected[question.id]) != null ? _a : []].sort(),
|
|
160
|
+
other_text: otherActive[question.id] ? ((_b = otherText[question.id]) == null ? void 0 : _b.trim()) || null : null
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
if (questionValidation.validChatAnswersForRequest(props.interaction.request, answers)) {
|
|
164
|
+
emit("answer", answers);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return (_ctx, _cache) => {
|
|
168
|
+
var _a;
|
|
169
|
+
return vue.openBlock(), vue.createElementBlock("section", {
|
|
170
|
+
class: vue.normalizeClass(["yc-chat-question-card question-card", { "is-compact": __props.compact, "is-readonly": !canAnswer.value }]),
|
|
171
|
+
"data-state": __props.interaction.state,
|
|
172
|
+
"data-testid": `question-card-${__props.interaction.request.request_id}`
|
|
173
|
+
}, [
|
|
174
|
+
vue.createElementVNode("header", _hoisted_2, [
|
|
175
|
+
vue.createElementVNode("div", _hoisted_3, [
|
|
176
|
+
_cache[1] || (_cache[1] = vue.createElementVNode(
|
|
177
|
+
"span",
|
|
178
|
+
{
|
|
179
|
+
class: "yc-chat-question-card__badge-icon",
|
|
180
|
+
"aria-hidden": "true"
|
|
181
|
+
},
|
|
182
|
+
[
|
|
183
|
+
vue.createElementVNode("svg", {
|
|
184
|
+
viewBox: "0 0 18 18",
|
|
185
|
+
fill: "none"
|
|
186
|
+
}, [
|
|
187
|
+
vue.createElementVNode("path", {
|
|
188
|
+
d: "M9 2.25C9.42 5.45 10.75 6.78 13.95 7.2C10.75 7.62 9.42 8.95 9 12.15C8.58 8.95 7.25 7.62 4.05 7.2C7.25 6.78 8.58 5.45 9 2.25Z",
|
|
189
|
+
fill: "currentColor"
|
|
190
|
+
}),
|
|
191
|
+
vue.createElementVNode("circle", {
|
|
192
|
+
cx: "14.2",
|
|
193
|
+
cy: "13.2",
|
|
194
|
+
r: "1.35",
|
|
195
|
+
fill: "currentColor",
|
|
196
|
+
opacity: "0.7"
|
|
197
|
+
})
|
|
198
|
+
])
|
|
199
|
+
],
|
|
200
|
+
-1
|
|
201
|
+
/* CACHED */
|
|
202
|
+
)),
|
|
203
|
+
vue.createElementVNode(
|
|
204
|
+
"strong",
|
|
205
|
+
_hoisted_4,
|
|
206
|
+
vue.toDisplayString(__props.title),
|
|
207
|
+
1
|
|
208
|
+
/* TEXT */
|
|
209
|
+
)
|
|
210
|
+
]),
|
|
211
|
+
vue.createElementVNode(
|
|
212
|
+
"span",
|
|
213
|
+
{
|
|
214
|
+
class: vue.normalizeClass(["yc-chat-question-card__status question-card__status", `is-${__props.interaction.state}`])
|
|
215
|
+
},
|
|
216
|
+
vue.toDisplayString(statusLabels[__props.interaction.state]),
|
|
217
|
+
3
|
|
218
|
+
/* TEXT, CLASS */
|
|
219
|
+
)
|
|
220
|
+
]),
|
|
221
|
+
vue.createElementVNode("div", _hoisted_5, [
|
|
222
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
223
|
+
vue.Fragment,
|
|
224
|
+
null,
|
|
225
|
+
vue.renderList(__props.interaction.request.questions, (question) => {
|
|
226
|
+
return vue.openBlock(), vue.createElementBlock("fieldset", {
|
|
227
|
+
key: question.id,
|
|
228
|
+
class: "yc-chat-question-card__question question-card__question",
|
|
229
|
+
disabled: !canAnswer.value
|
|
230
|
+
}, [
|
|
231
|
+
vue.createElementVNode("legend", _hoisted_7, [
|
|
232
|
+
vue.createElementVNode(
|
|
233
|
+
"span",
|
|
234
|
+
null,
|
|
235
|
+
vue.toDisplayString(question.title),
|
|
236
|
+
1
|
|
237
|
+
/* TEXT */
|
|
238
|
+
),
|
|
239
|
+
question.selection_mode === "multiple" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_8, " \u53EF\u591A\u9009 ")) : vue.createCommentVNode("v-if", true)
|
|
240
|
+
]),
|
|
241
|
+
vue.createElementVNode("div", _hoisted_9, [
|
|
242
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
243
|
+
vue.Fragment,
|
|
244
|
+
null,
|
|
245
|
+
vue.renderList(question.options, (option) => {
|
|
246
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
247
|
+
"label",
|
|
248
|
+
{
|
|
249
|
+
key: option.id,
|
|
250
|
+
class: vue.normalizeClass(["yc-chat-question-card__option question-card__option", {
|
|
251
|
+
"is-selected": optionChecked(question, option.id),
|
|
252
|
+
"is-disabled": !canAnswer.value
|
|
253
|
+
}])
|
|
254
|
+
},
|
|
255
|
+
[
|
|
256
|
+
vue.createElementVNode("input", {
|
|
257
|
+
class: "yc-chat-question-card__native-input",
|
|
258
|
+
"data-testid": `option-${question.id}-${option.id}`,
|
|
259
|
+
type: question.selection_mode === "single" ? "radio" : "checkbox",
|
|
260
|
+
name: `question-${__props.interaction.request.request_id}-${question.id}`,
|
|
261
|
+
checked: optionChecked(question, option.id),
|
|
262
|
+
onChange: ($event) => selectOption(question, option.id)
|
|
263
|
+
}, null, 40, _hoisted_10),
|
|
264
|
+
vue.createElementVNode(
|
|
265
|
+
"span",
|
|
266
|
+
{
|
|
267
|
+
class: vue.normalizeClass(["yc-chat-question-card__control", [
|
|
268
|
+
`is-${question.selection_mode}`,
|
|
269
|
+
{ "is-checked": optionChecked(question, option.id) }
|
|
270
|
+
]]),
|
|
271
|
+
"aria-hidden": "true"
|
|
272
|
+
},
|
|
273
|
+
[
|
|
274
|
+
question.selection_mode === "multiple" && optionChecked(question, option.id) ? (vue.openBlock(), vue.createElementBlock("svg", _hoisted_11, [..._cache[2] || (_cache[2] = [
|
|
275
|
+
vue.createElementVNode(
|
|
276
|
+
"path",
|
|
277
|
+
{
|
|
278
|
+
d: "M2.5 6.2L4.9 8.6L9.5 3.6",
|
|
279
|
+
stroke: "currentColor",
|
|
280
|
+
"stroke-width": "1.7",
|
|
281
|
+
"stroke-linecap": "round",
|
|
282
|
+
"stroke-linejoin": "round"
|
|
283
|
+
},
|
|
284
|
+
null,
|
|
285
|
+
-1
|
|
286
|
+
/* CACHED */
|
|
287
|
+
)
|
|
288
|
+
])])) : vue.createCommentVNode("v-if", true)
|
|
289
|
+
],
|
|
290
|
+
2
|
|
291
|
+
/* CLASS */
|
|
292
|
+
),
|
|
293
|
+
vue.createElementVNode("span", _hoisted_12, [
|
|
294
|
+
vue.createElementVNode(
|
|
295
|
+
"strong",
|
|
296
|
+
_hoisted_13,
|
|
297
|
+
vue.toDisplayString(option.label),
|
|
298
|
+
1
|
|
299
|
+
/* TEXT */
|
|
300
|
+
),
|
|
301
|
+
option.description ? (vue.openBlock(), vue.createElementBlock(
|
|
302
|
+
"small",
|
|
303
|
+
_hoisted_14,
|
|
304
|
+
vue.toDisplayString(option.description),
|
|
305
|
+
1
|
|
306
|
+
/* TEXT */
|
|
307
|
+
)) : vue.createCommentVNode("v-if", true),
|
|
308
|
+
option.event ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_15, [
|
|
309
|
+
vue.createElementVNode(
|
|
310
|
+
"span",
|
|
311
|
+
null,
|
|
312
|
+
vue.toDisplayString(option.event.type) + " \xB7 v" + vue.toDisplayString(option.event.version) + " \xB7 \u53C2\u6570",
|
|
313
|
+
1
|
|
314
|
+
/* TEXT */
|
|
315
|
+
),
|
|
316
|
+
vue.createElementVNode(
|
|
317
|
+
"code",
|
|
318
|
+
null,
|
|
319
|
+
vue.toDisplayString(eventSummary(option)),
|
|
320
|
+
1
|
|
321
|
+
/* TEXT */
|
|
322
|
+
),
|
|
323
|
+
_cache[3] || (_cache[3] = vue.createElementVNode(
|
|
324
|
+
"em",
|
|
325
|
+
null,
|
|
326
|
+
"Admin \u4E0D\u652F\u6301\u6267\u884C\u5BA2\u6237\u7AEF\u4E8B\u4EF6",
|
|
327
|
+
-1
|
|
328
|
+
/* CACHED */
|
|
329
|
+
))
|
|
330
|
+
])) : vue.createCommentVNode("v-if", true)
|
|
331
|
+
])
|
|
332
|
+
],
|
|
333
|
+
2
|
|
334
|
+
/* CLASS */
|
|
335
|
+
);
|
|
336
|
+
}),
|
|
337
|
+
128
|
|
338
|
+
/* KEYED_FRAGMENT */
|
|
339
|
+
)),
|
|
340
|
+
vue.createElementVNode(
|
|
341
|
+
"div",
|
|
342
|
+
{
|
|
343
|
+
class: vue.normalizeClass(["yc-chat-question-card__other-wrap", { "is-selected": otherActive[question.id] }])
|
|
344
|
+
},
|
|
345
|
+
[
|
|
346
|
+
vue.createElementVNode(
|
|
347
|
+
"label",
|
|
348
|
+
{
|
|
349
|
+
class: vue.normalizeClass(["yc-chat-question-card__option yc-chat-question-card__other question-card__option question-card__other", {
|
|
350
|
+
"is-selected": otherActive[question.id],
|
|
351
|
+
"is-disabled": !canAnswer.value
|
|
352
|
+
}])
|
|
353
|
+
},
|
|
354
|
+
[
|
|
355
|
+
vue.createElementVNode("input", {
|
|
356
|
+
class: "yc-chat-question-card__native-input",
|
|
357
|
+
"data-testid": `other-${question.id}`,
|
|
358
|
+
type: question.selection_mode === "single" ? "radio" : "checkbox",
|
|
359
|
+
name: `question-${__props.interaction.request.request_id}-${question.id}`,
|
|
360
|
+
checked: otherActive[question.id],
|
|
361
|
+
onChange: ($event) => selectOther(question, $event.target.checked)
|
|
362
|
+
}, null, 40, _hoisted_16),
|
|
363
|
+
vue.createElementVNode(
|
|
364
|
+
"span",
|
|
365
|
+
{
|
|
366
|
+
class: vue.normalizeClass(["yc-chat-question-card__control", [
|
|
367
|
+
`is-${question.selection_mode}`,
|
|
368
|
+
{ "is-checked": otherActive[question.id] }
|
|
369
|
+
]]),
|
|
370
|
+
"aria-hidden": "true"
|
|
371
|
+
},
|
|
372
|
+
[
|
|
373
|
+
question.selection_mode === "multiple" && otherActive[question.id] ? (vue.openBlock(), vue.createElementBlock("svg", _hoisted_17, [..._cache[4] || (_cache[4] = [
|
|
374
|
+
vue.createElementVNode(
|
|
375
|
+
"path",
|
|
376
|
+
{
|
|
377
|
+
d: "M2.5 6.2L4.9 8.6L9.5 3.6",
|
|
378
|
+
stroke: "currentColor",
|
|
379
|
+
"stroke-width": "1.7",
|
|
380
|
+
"stroke-linecap": "round",
|
|
381
|
+
"stroke-linejoin": "round"
|
|
382
|
+
},
|
|
383
|
+
null,
|
|
384
|
+
-1
|
|
385
|
+
/* CACHED */
|
|
386
|
+
)
|
|
387
|
+
])])) : vue.createCommentVNode("v-if", true)
|
|
388
|
+
],
|
|
389
|
+
2
|
|
390
|
+
/* CLASS */
|
|
391
|
+
),
|
|
392
|
+
vue.createElementVNode("span", _hoisted_18, [
|
|
393
|
+
vue.createElementVNode(
|
|
394
|
+
"strong",
|
|
395
|
+
_hoisted_19,
|
|
396
|
+
vue.toDisplayString(question.other.label),
|
|
397
|
+
1
|
|
398
|
+
/* TEXT */
|
|
399
|
+
)
|
|
400
|
+
])
|
|
401
|
+
],
|
|
402
|
+
2
|
|
403
|
+
/* CLASS */
|
|
404
|
+
),
|
|
405
|
+
otherActive[question.id] ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_20, [
|
|
406
|
+
vue.withDirectives(vue.createElementVNode("textarea", {
|
|
407
|
+
"onUpdate:modelValue": ($event) => otherText[question.id] = $event,
|
|
408
|
+
class: "yc-chat-question-card__textarea",
|
|
409
|
+
"data-testid": `other-text-${question.id}`,
|
|
410
|
+
rows: "2",
|
|
411
|
+
placeholder: "\u8BF7\u8F93\u5165\u4F60\u7684\u8865\u5145\u8BF4\u660E\u6216\u81EA\u5B9A\u4E49\u7B54\u6848\u2026"
|
|
412
|
+
}, null, 8, _hoisted_21), [
|
|
413
|
+
[vue.vModelText, otherText[question.id]]
|
|
414
|
+
])
|
|
415
|
+
])) : vue.createCommentVNode("v-if", true)
|
|
416
|
+
],
|
|
417
|
+
2
|
|
418
|
+
/* CLASS */
|
|
419
|
+
)
|
|
420
|
+
])
|
|
421
|
+
], 8, _hoisted_6);
|
|
422
|
+
}),
|
|
423
|
+
128
|
|
424
|
+
/* KEYED_FRAGMENT */
|
|
425
|
+
))
|
|
426
|
+
]),
|
|
427
|
+
!requestIsValid.value ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_22, " \u4EA4\u4E92\u8BF7\u6C42\u4E0D\u7B26\u5408\u5BA2\u6237\u7AEF\u4E8B\u4EF6\u7EA6\u675F\uFF0C\u65E0\u6CD5\u63D0\u4EA4\u56DE\u7B54\u3002 ")) : vue.createCommentVNode("v-if", true),
|
|
428
|
+
!__props.answerEnabled && __props.interaction.state === "pending" ? (vue.openBlock(), vue.createElementBlock(
|
|
429
|
+
"p",
|
|
430
|
+
_hoisted_23,
|
|
431
|
+
vue.toDisplayString(__props.unavailableReason || "\u5F53\u524D\u754C\u9762\u6682\u4E0D\u652F\u6301\u63D0\u4EA4\u56DE\u7B54"),
|
|
432
|
+
1
|
|
433
|
+
/* TEXT */
|
|
434
|
+
)) : vue.createCommentVNode("v-if", true),
|
|
435
|
+
((_a = __props.interaction.receipt) == null ? void 0 : _a.clientEvent) ? (vue.openBlock(), vue.createElementBlock(
|
|
436
|
+
"p",
|
|
437
|
+
_hoisted_24,
|
|
438
|
+
" \u5BA2\u6237\u7AEF\u4E8B\u4EF6 " + vue.toDisplayString(__props.interaction.receipt.clientEvent.type) + " \u672A\u5728 Admin \u6267\u884C\u3002 ",
|
|
439
|
+
1
|
|
440
|
+
/* TEXT */
|
|
441
|
+
)) : vue.createCommentVNode("v-if", true),
|
|
442
|
+
__props.interaction.state === "pending" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_25, [
|
|
443
|
+
vue.createElementVNode("button", {
|
|
444
|
+
type: "button",
|
|
445
|
+
class: "yc-chat-question-card__btn yc-chat-question-card__btn--cancel question-card__cancel",
|
|
446
|
+
"data-testid": "cancel-interaction",
|
|
447
|
+
disabled: !__props.answerEnabled || __props.submitting,
|
|
448
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("cancel"))
|
|
449
|
+
}, " \u53D6\u6D88 ", 8, _hoisted_26),
|
|
450
|
+
vue.createElementVNode("button", {
|
|
451
|
+
type: "button",
|
|
452
|
+
class: "yc-chat-question-card__btn yc-chat-question-card__btn--submit",
|
|
453
|
+
"data-testid": "submit-answers",
|
|
454
|
+
disabled: !canAnswer.value || !complete.value || __props.submitting,
|
|
455
|
+
onClick: submit
|
|
456
|
+
}, vue.toDisplayString(__props.submitting ? "\u63D0\u4EA4\u4E2D\u2026" : "\u63D0\u4EA4\u56DE\u7B54"), 9, _hoisted_27)
|
|
457
|
+
])) : vue.createCommentVNode("v-if", true)
|
|
458
|
+
], 10, _hoisted_1);
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
4
|
+
const EVENT_TYPE_PATTERN = /^[A-Za-z0-9._-]{1,100}$/;
|
|
5
|
+
function codePointLength(value) {
|
|
6
|
+
return Array.from(value).length;
|
|
7
|
+
}
|
|
8
|
+
function hasForbiddenControl(value, allowLineBreaks) {
|
|
9
|
+
var _a;
|
|
10
|
+
for (const character of value) {
|
|
11
|
+
const point = (_a = character.codePointAt(0)) != null ? _a : 0;
|
|
12
|
+
if ((point >= 0 && point <= 31 || point >= 127 && point <= 159) && (!allowLineBreaks || point !== 9 && point !== 10 && point !== 13)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
function validText(value, minimum, maximum, allowLineBreaks = false) {
|
|
19
|
+
const length = codePointLength(value);
|
|
20
|
+
return length >= minimum && length <= maximum && value.trim().length > 0 && !hasForbiddenControl(value, allowLineBreaks);
|
|
21
|
+
}
|
|
22
|
+
function validChatOtherText(value) {
|
|
23
|
+
return validText(value, 1, 2e3, true);
|
|
24
|
+
}
|
|
25
|
+
function validChatQuestionRequest(request) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
if (request.schema !== "interaction.question.v1" || !validText(request.request_id, 1, 256) || !validText(request.tool_call_id, 1, 256) || request.questions.length < 1 || request.questions.length > 5) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const questionIds = /* @__PURE__ */ new Set();
|
|
31
|
+
let hasEvent = false;
|
|
32
|
+
for (const question of request.questions) {
|
|
33
|
+
if (!ID_PATTERN.test(question.id) || questionIds.has(question.id) || !validText(question.title, 1, 500) || !["single", "multiple"].includes(question.selection_mode) || question.options.length < 1 || question.options.length > 10 || ((_a = question.other) == null ? void 0 : _a.enabled) !== true || ((_b = question.other) == null ? void 0 : _b.label) !== "\u5176\u4ED6") {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
questionIds.add(question.id);
|
|
37
|
+
const optionIds = /* @__PURE__ */ new Set();
|
|
38
|
+
const optionLabels = /* @__PURE__ */ new Set();
|
|
39
|
+
for (const option of question.options) {
|
|
40
|
+
const normalizedLabel = option.label.trim();
|
|
41
|
+
if (!ID_PATTERN.test(option.id) || optionIds.has(option.id) || !validText(option.label, 1, 100) || normalizedLabel === "\u5176\u4ED6" || optionLabels.has(normalizedLabel) || option.description !== void 0 && option.description !== "" && !validText(option.description, 1, 300)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
optionIds.add(option.id);
|
|
45
|
+
optionLabels.add(normalizedLabel);
|
|
46
|
+
if (option.event) {
|
|
47
|
+
hasEvent = true;
|
|
48
|
+
if (!EVENT_TYPE_PATTERN.test(option.event.type) || !Number.isInteger(option.event.version) || option.event.version < 1 || option.event.payload === null || typeof option.event.payload !== "object" || Array.isArray(option.event.payload)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (hasEvent && (request.questions.length !== 1 || ((_c = request.questions[0]) == null ? void 0 : _c.selection_mode) !== "single")) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
function validChatAnswersForRequest(request, answers) {
|
|
60
|
+
if (!validChatQuestionRequest(request)) return false;
|
|
61
|
+
if (answers.length !== request.questions.length) return false;
|
|
62
|
+
return request.questions.every((question, index) => {
|
|
63
|
+
const answer = answers[index];
|
|
64
|
+
if (!answer || answer.question_id !== question.id) return false;
|
|
65
|
+
const allowed = new Set(question.options.map((option) => option.id));
|
|
66
|
+
if (new Set(answer.selected_option_ids).size !== answer.selected_option_ids.length || answer.selected_option_ids.some((id) => !allowed.has(id))) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (answer.other_text !== null) {
|
|
70
|
+
return answer.selected_option_ids.length === 0 && validChatOtherText(answer.other_text);
|
|
71
|
+
}
|
|
72
|
+
if (question.selection_mode === "single") {
|
|
73
|
+
return answer.selected_option_ids.length === 1;
|
|
74
|
+
}
|
|
75
|
+
return answer.selected_option_ids.length >= 1;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.validChatAnswersForRequest = validChatAnswersForRequest;
|
|
80
|
+
exports.validChatOtherText = validChatOtherText;
|
|
81
|
+
exports.validChatQuestionRequest = validChatQuestionRequest;
|