yc-agent-ui 1.2.2 → 1.2.3
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/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 +2 -0
- package/es/index.css +8 -8
- 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 +1655 -922
- package/index.min.js +22 -22
- package/index.min.mjs +24 -24
- package/index.mjs +1645 -912
- 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 +2 -0
- package/lib/index.css +10 -10
- 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 +478 -75
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, computed,
|
|
1
|
+
import { defineComponent, ref, watch, computed, onBeforeUnmount, openBlock, createElementBlock, normalizeStyle, normalizeClass, renderSlot, createCommentVNode, createElementVNode, Fragment, renderList, toDisplayString, createVNode, withCtx, withModifiers, nextTick } from 'vue';
|
|
2
2
|
import _sfc_main$1 from './mobile-frame2.vue.mjs';
|
|
3
3
|
import { YC_MOBILE_DEVICE_PRESETS } from './presets.mjs';
|
|
4
4
|
|
|
@@ -37,10 +37,7 @@ const _hoisted_10 = {
|
|
|
37
37
|
const _hoisted_11 = ["aria-selected"];
|
|
38
38
|
const _hoisted_12 = ["aria-selected"];
|
|
39
39
|
const _hoisted_13 = ["disabled"];
|
|
40
|
-
const _hoisted_14 =
|
|
41
|
-
key: 2,
|
|
42
|
-
class: "yc-chat-studio__web-body chat-workspace"
|
|
43
|
-
};
|
|
40
|
+
const _hoisted_14 = ["aria-valuemin", "aria-valuemax", "aria-valuenow"];
|
|
44
41
|
const _hoisted_15 = { class: "yc-chat-studio__main conversation-panel" };
|
|
45
42
|
const _hoisted_16 = { class: "yc-chat-studio__stream-inner" };
|
|
46
43
|
const _hoisted_17 = { class: "yc-chat-studio__composer-dock" };
|
|
@@ -74,6 +71,7 @@ const _hoisted_29 = {
|
|
|
74
71
|
};
|
|
75
72
|
const _hoisted_30 = { class: "yc-chat-studio__mobile-composer" };
|
|
76
73
|
const _hoisted_31 = { class: "yc-chat-studio__mobile-drawer" };
|
|
74
|
+
const DEFAULT_SIDEBAR_WIDTH = 280;
|
|
77
75
|
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
78
76
|
...{
|
|
79
77
|
name: "YcChatStudio"
|
|
@@ -92,23 +90,129 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
92
90
|
caption: { default: "" },
|
|
93
91
|
accentColor: { default: "" },
|
|
94
92
|
showViewportSwitch: { type: Boolean, default: false },
|
|
95
|
-
deviceSimulator: { type: Boolean, default: false }
|
|
93
|
+
deviceSimulator: { type: Boolean, default: false },
|
|
94
|
+
sidebarWidth: { default: DEFAULT_SIDEBAR_WIDTH },
|
|
95
|
+
sidebarMinWidth: { default: 200 },
|
|
96
|
+
sidebarMaxWidth: { default: 520 },
|
|
97
|
+
sidebarResizable: { type: Boolean, default: true }
|
|
96
98
|
},
|
|
97
|
-
emits: ["update:viewport", "update:deviceId", "refresh", "create"],
|
|
99
|
+
emits: ["update:viewport", "update:deviceId", "update:sidebarWidth", "refresh", "create"],
|
|
98
100
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
99
101
|
const props = __props;
|
|
100
|
-
const accentStyle = computed(
|
|
101
|
-
() => props.accentColor ? { "--yc-chat-accent": props.accentColor } : void 0
|
|
102
|
-
);
|
|
103
102
|
const emit = __emit;
|
|
104
103
|
const sidebarCollapsed = ref(false);
|
|
105
104
|
const mobileDrawerOpen = ref(false);
|
|
105
|
+
const isResizingSidebar = ref(false);
|
|
106
|
+
const webBodyRef = ref(null);
|
|
107
|
+
const sidebarWrapRef = ref(null);
|
|
106
108
|
const webScrollRef = ref(null);
|
|
107
109
|
const mobileScrollRef = ref(null);
|
|
108
110
|
const mobileFrameRef = ref(null);
|
|
111
|
+
function clampSidebarWidth(rawWidth) {
|
|
112
|
+
var _a;
|
|
113
|
+
const min = Math.max(160, props.sidebarMinWidth);
|
|
114
|
+
const bodyWidth = ((_a = webBodyRef.value) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
115
|
+
const dynamicMax = bodyWidth > 0 ? Math.max(min, Math.min(props.sidebarMaxWidth, Math.floor(bodyWidth * 0.6))) : Math.max(min, props.sidebarMaxWidth);
|
|
116
|
+
return Math.round(Math.min(dynamicMax, Math.max(min, rawWidth)));
|
|
117
|
+
}
|
|
118
|
+
const currentSidebarWidth = ref(clampSidebarWidth(props.sidebarWidth));
|
|
119
|
+
watch(
|
|
120
|
+
() => props.sidebarWidth,
|
|
121
|
+
(value) => {
|
|
122
|
+
if (typeof value === "number" && !Number.isNaN(value)) {
|
|
123
|
+
currentSidebarWidth.value = clampSidebarWidth(value);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
const accentStyle = computed(
|
|
128
|
+
() => props.accentColor ? { "--yc-chat-accent": props.accentColor } : void 0
|
|
129
|
+
);
|
|
130
|
+
const sidebarInlineStyle = computed(
|
|
131
|
+
() => sidebarCollapsed.value ? void 0 : { width: `${currentSidebarWidth.value}px` }
|
|
132
|
+
);
|
|
109
133
|
const activeDevice = computed(() => {
|
|
110
134
|
return props.devices.find((item) => item.id === props.deviceId) || props.devices[0] || YC_MOBILE_DEVICE_PRESETS[0];
|
|
111
135
|
});
|
|
136
|
+
let cleanupResizeListeners = null;
|
|
137
|
+
function updateSidebarWidth(nextWidth) {
|
|
138
|
+
const clamped = clampSidebarWidth(nextWidth);
|
|
139
|
+
currentSidebarWidth.value = clamped;
|
|
140
|
+
emit("update:sidebarWidth", clamped);
|
|
141
|
+
}
|
|
142
|
+
function startSidebarResize(startX) {
|
|
143
|
+
var _a;
|
|
144
|
+
const measuredWidth = (_a = sidebarWrapRef.value) == null ? void 0 : _a.getBoundingClientRect().width;
|
|
145
|
+
const initialWidth = measuredWidth && measuredWidth > 0 ? measuredWidth : currentSidebarWidth.value;
|
|
146
|
+
cleanupResizeListeners == null ? void 0 : cleanupResizeListeners();
|
|
147
|
+
isResizingSidebar.value = true;
|
|
148
|
+
const prevCursor = typeof document !== "undefined" ? document.body.style.cursor : "";
|
|
149
|
+
const prevUserSelect = typeof document !== "undefined" ? document.body.style.userSelect : "";
|
|
150
|
+
if (typeof document !== "undefined") {
|
|
151
|
+
document.body.style.cursor = "col-resize";
|
|
152
|
+
document.body.style.userSelect = "none";
|
|
153
|
+
}
|
|
154
|
+
const handleMouseMove = (event) => {
|
|
155
|
+
updateSidebarWidth(initialWidth + (event.clientX - startX));
|
|
156
|
+
};
|
|
157
|
+
const handleTouchMove = (event) => {
|
|
158
|
+
const touch = event.touches[0];
|
|
159
|
+
if (!touch) return;
|
|
160
|
+
updateSidebarWidth(initialWidth + (touch.clientX - startX));
|
|
161
|
+
};
|
|
162
|
+
const stopResize = () => {
|
|
163
|
+
isResizingSidebar.value = false;
|
|
164
|
+
if (typeof document !== "undefined") {
|
|
165
|
+
document.body.style.cursor = prevCursor;
|
|
166
|
+
document.body.style.userSelect = prevUserSelect;
|
|
167
|
+
}
|
|
168
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
169
|
+
window.removeEventListener("mouseup", stopResize);
|
|
170
|
+
window.removeEventListener("touchmove", handleTouchMove);
|
|
171
|
+
window.removeEventListener("touchend", stopResize);
|
|
172
|
+
window.removeEventListener("touchcancel", stopResize);
|
|
173
|
+
cleanupResizeListeners = null;
|
|
174
|
+
};
|
|
175
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
176
|
+
window.addEventListener("mouseup", stopResize);
|
|
177
|
+
window.addEventListener("touchmove", handleTouchMove, { passive: true });
|
|
178
|
+
window.addEventListener("touchend", stopResize);
|
|
179
|
+
window.addEventListener("touchcancel", stopResize);
|
|
180
|
+
cleanupResizeListeners = stopResize;
|
|
181
|
+
}
|
|
182
|
+
function handleResizerMouseDown(event) {
|
|
183
|
+
if (event.button !== 0 || !props.sidebarResizable || sidebarCollapsed.value) return;
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
startSidebarResize(event.clientX);
|
|
186
|
+
}
|
|
187
|
+
function handleResizerTouchStart(event) {
|
|
188
|
+
if (!props.sidebarResizable || sidebarCollapsed.value) return;
|
|
189
|
+
const touch = event.touches[0];
|
|
190
|
+
if (!touch) return;
|
|
191
|
+
startSidebarResize(touch.clientX);
|
|
192
|
+
}
|
|
193
|
+
function resetSidebarWidth() {
|
|
194
|
+
if (!props.sidebarResizable) return;
|
|
195
|
+
updateSidebarWidth(DEFAULT_SIDEBAR_WIDTH);
|
|
196
|
+
}
|
|
197
|
+
function handleResizerKeydown(event) {
|
|
198
|
+
if (!props.sidebarResizable || sidebarCollapsed.value) return;
|
|
199
|
+
if (event.key === "ArrowLeft") {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
updateSidebarWidth(currentSidebarWidth.value - 16);
|
|
202
|
+
} else if (event.key === "ArrowRight") {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
updateSidebarWidth(currentSidebarWidth.value + 16);
|
|
205
|
+
} else if (event.key === "Home") {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
updateSidebarWidth(props.sidebarMinWidth);
|
|
208
|
+
} else if (event.key === "End") {
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
updateSidebarWidth(props.sidebarMaxWidth);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
onBeforeUnmount(() => {
|
|
214
|
+
cleanupResizeListeners == null ? void 0 : cleanupResizeListeners();
|
|
215
|
+
});
|
|
112
216
|
function switchViewport(mode) {
|
|
113
217
|
if (mode === props.viewport) return;
|
|
114
218
|
emit("update:viewport", mode);
|
|
@@ -141,7 +245,13 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
141
245
|
return openBlock(), createElementBlock(
|
|
142
246
|
"div",
|
|
143
247
|
{
|
|
144
|
-
class: normalizeClass(["yc-chat-studio tenant-chat-page", [
|
|
248
|
+
class: normalizeClass(["yc-chat-studio tenant-chat-page", [
|
|
249
|
+
`is-${__props.viewport}`,
|
|
250
|
+
{
|
|
251
|
+
"is-simulator": __props.viewport === "mobile" && __props.deviceSimulator,
|
|
252
|
+
"is-resizing-sidebar": isResizingSidebar.value
|
|
253
|
+
}
|
|
254
|
+
]]),
|
|
145
255
|
style: normalizeStyle(accentStyle.value)
|
|
146
256
|
},
|
|
147
257
|
[
|
|
@@ -342,42 +452,84 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
342
452
|
], 8, _hoisted_13)
|
|
343
453
|
])
|
|
344
454
|
])) : createCommentVNode("v-if", true),
|
|
345
|
-
createCommentVNode(" Web \u7AEF\uFF1A\u684C\u9762\u53CC\u680F\u5DE5\u4F5C\u53F0\uFF08\u5DE6\u4FA7\
|
|
346
|
-
__props.viewport === "web" ? (openBlock(), createElementBlock(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
2
|
|
356
|
-
/* CLASS */
|
|
357
|
-
),
|
|
358
|
-
createElementVNode("section", _hoisted_15, [
|
|
455
|
+
createCommentVNode(" Web \u7AEF\uFF1A\u684C\u9762\u53CC\u680F\u5DE5\u4F5C\u53F0\uFF08\u5DE6\u4FA7\u53EF\u6298\u53E0\u4E14\u652F\u6301\u5DE6\u53F3\u62D6\u62FD\u8C03\u5BBD\u7684\u4F1A\u8BDD\u4FA7\u680F + \u53F3\u4FA7\u4E3B\u5BF9\u8BDD\u533A\uFF09 "),
|
|
456
|
+
__props.viewport === "web" ? (openBlock(), createElementBlock(
|
|
457
|
+
"div",
|
|
458
|
+
{
|
|
459
|
+
key: 2,
|
|
460
|
+
ref_key: "webBodyRef",
|
|
461
|
+
ref: webBodyRef,
|
|
462
|
+
class: "yc-chat-studio__web-body chat-workspace"
|
|
463
|
+
},
|
|
464
|
+
[
|
|
359
465
|
createElementVNode(
|
|
360
466
|
"div",
|
|
361
467
|
{
|
|
362
|
-
ref_key: "
|
|
363
|
-
ref:
|
|
364
|
-
class: "yc-chat-
|
|
468
|
+
ref_key: "sidebarWrapRef",
|
|
469
|
+
ref: sidebarWrapRef,
|
|
470
|
+
class: normalizeClass(["yc-chat-studio__sidebar-wrap", { "is-collapsed": sidebarCollapsed.value, "is-resizing": isResizingSidebar.value }]),
|
|
471
|
+
style: normalizeStyle(sidebarInlineStyle.value)
|
|
365
472
|
},
|
|
366
473
|
[
|
|
367
|
-
|
|
368
|
-
renderSlot(_ctx.$slots, "messages")
|
|
369
|
-
])
|
|
474
|
+
renderSlot(_ctx.$slots, "sidebar")
|
|
370
475
|
],
|
|
371
|
-
|
|
372
|
-
/*
|
|
476
|
+
6
|
|
477
|
+
/* CLASS, STYLE */
|
|
373
478
|
),
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
479
|
+
__props.sidebarResizable && !sidebarCollapsed.value ? (openBlock(), createElementBlock("div", {
|
|
480
|
+
key: 0,
|
|
481
|
+
class: normalizeClass(["yc-chat-studio__sidebar-resizer", { "is-active": isResizingSidebar.value }]),
|
|
482
|
+
"data-testid": "sidebar-resizer",
|
|
483
|
+
role: "separator",
|
|
484
|
+
tabindex: "0",
|
|
485
|
+
"aria-label": "\u5DE6\u53F3\u62D6\u62FD\u8C03\u6574\u4F1A\u8BDD\u5217\u8868\u5BBD\u5EA6",
|
|
486
|
+
"aria-orientation": "vertical",
|
|
487
|
+
"aria-valuemin": __props.sidebarMinWidth,
|
|
488
|
+
"aria-valuemax": __props.sidebarMaxWidth,
|
|
489
|
+
"aria-valuenow": currentSidebarWidth.value,
|
|
490
|
+
title: "\u5DE6\u53F3\u62D6\u62FD\u8C03\u6574\u5BBD\u5EA6\uFF0C\u53CC\u51FB\u6062\u590D\u9ED8\u8BA4",
|
|
491
|
+
onMousedown: handleResizerMouseDown,
|
|
492
|
+
onTouchstart: handleResizerTouchStart,
|
|
493
|
+
onDblclick: resetSidebarWidth,
|
|
494
|
+
onKeydown: handleResizerKeydown
|
|
495
|
+
}, [..._cache[13] || (_cache[13] = [
|
|
496
|
+
createElementVNode(
|
|
497
|
+
"span",
|
|
498
|
+
{
|
|
499
|
+
class: "yc-chat-studio__sidebar-resizer-line",
|
|
500
|
+
"aria-hidden": "true"
|
|
501
|
+
},
|
|
502
|
+
null,
|
|
503
|
+
-1
|
|
504
|
+
/* CACHED */
|
|
505
|
+
)
|
|
506
|
+
])], 42, _hoisted_14)) : createCommentVNode("v-if", true),
|
|
507
|
+
createElementVNode("section", _hoisted_15, [
|
|
508
|
+
createElementVNode(
|
|
509
|
+
"div",
|
|
510
|
+
{
|
|
511
|
+
ref_key: "webScrollRef",
|
|
512
|
+
ref: webScrollRef,
|
|
513
|
+
class: "yc-chat-studio__stream message-viewport"
|
|
514
|
+
},
|
|
515
|
+
[
|
|
516
|
+
createElementVNode("div", _hoisted_16, [
|
|
517
|
+
renderSlot(_ctx.$slots, "messages")
|
|
518
|
+
])
|
|
519
|
+
],
|
|
520
|
+
512
|
|
521
|
+
/* NEED_PATCH */
|
|
522
|
+
),
|
|
523
|
+
createElementVNode("div", _hoisted_17, [
|
|
524
|
+
createElementVNode("div", _hoisted_18, [
|
|
525
|
+
renderSlot(_ctx.$slots, "composer")
|
|
526
|
+
])
|
|
377
527
|
])
|
|
378
528
|
])
|
|
379
|
-
]
|
|
380
|
-
|
|
529
|
+
],
|
|
530
|
+
512
|
|
531
|
+
/* NEED_PATCH */
|
|
532
|
+
)) : __props.deviceSimulator ? (openBlock(), createElementBlock(
|
|
381
533
|
Fragment,
|
|
382
534
|
{ key: 3 },
|
|
383
535
|
[
|
|
@@ -440,7 +592,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
440
592
|
"data-testid": "mobile-drawer-trigger",
|
|
441
593
|
onClick: _cache[6] || (_cache[6] = ($event) => mobileDrawerOpen.value = true)
|
|
442
594
|
}, [
|
|
443
|
-
_cache[
|
|
595
|
+
_cache[14] || (_cache[14] = createElementVNode(
|
|
444
596
|
"svg",
|
|
445
597
|
{
|
|
446
598
|
viewBox: "0 0 16 16",
|
|
@@ -500,7 +652,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
500
652
|
"aria-label": "\u65B0\u5EFA\u4F1A\u8BDD",
|
|
501
653
|
disabled: !__props.connected,
|
|
502
654
|
onClick: _cache[7] || (_cache[7] = ($event) => emit("create"))
|
|
503
|
-
}, [..._cache[
|
|
655
|
+
}, [..._cache[15] || (_cache[15] = [
|
|
504
656
|
createElementVNode(
|
|
505
657
|
"svg",
|
|
506
658
|
{
|
|
@@ -549,7 +701,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
549
701
|
}, [
|
|
550
702
|
createElementVNode("aside", _hoisted_31, [
|
|
551
703
|
createElementVNode("div", { class: "yc-chat-studio__mobile-drawer-top" }, [
|
|
552
|
-
_cache[
|
|
704
|
+
_cache[17] || (_cache[17] = createElementVNode(
|
|
553
705
|
"span",
|
|
554
706
|
null,
|
|
555
707
|
"\u5386\u53F2\u4F1A\u8BDD",
|
|
@@ -561,7 +713,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
561
713
|
class: "yc-chat-studio__icon-btn",
|
|
562
714
|
"aria-label": "\u5173\u95ED\u4F1A\u8BDD\u62BD\u5C49",
|
|
563
715
|
onClick: closeMobileDrawer
|
|
564
|
-
}, [..._cache[
|
|
716
|
+
}, [..._cache[16] || (_cache[16] = [
|
|
565
717
|
createElementVNode(
|
|
566
718
|
"svg",
|
|
567
719
|
{
|
package/es/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.2.
|
|
1
|
+
export declare const version = "1.2.3";
|
package/es/version.mjs
CHANGED