@vunk/plus 1.11.10 → 1.12.1

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.
@@ -0,0 +1,357 @@
1
+ import { defineComponent, useSlots, ref, watch, computed, nextTick, openBlock, createElementBlock, normalizeStyle, createElementVNode, normalizeClass, toDisplayString, createVNode, withCtx, withModifiers, createCommentVNode, withDirectives, renderSlot, vShow } from 'vue';
2
+ import { c as arrow_right_bold_default } from '../index2.mjs';
3
+ import { VkScrollbar } from '@vunk/plus/components/scrollbar';
4
+ import { ElCollapseTransition, ElIcon } from 'element-plus';
5
+ import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
6
+
7
+ const props = {
8
+ /**
9
+ * @description 展开/收起状态(v-model)
10
+ */
11
+ modelValue: {
12
+ type: Boolean,
13
+ default: true
14
+ },
15
+ /**
16
+ * @description 思考内容文本
17
+ */
18
+ content: {
19
+ type: String,
20
+ default: ""
21
+ },
22
+ /**
23
+ * @description 当前思考状态
24
+ */
25
+ status: {
26
+ type: String,
27
+ default: "start"
28
+ },
29
+ /**
30
+ * @description 是否禁用交互
31
+ */
32
+ disabled: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ /**
37
+ * @description status=end 时是否自动收起
38
+ */
39
+ autoCollapse: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ /**
44
+ * @description 动画过渡时长
45
+ */
46
+ duration: {
47
+ type: String,
48
+ default: "0.2s"
49
+ },
50
+ /**
51
+ * @description 头部触发按钮最小宽度
52
+ */
53
+ buttonWidth: {
54
+ type: String,
55
+ default: "160px"
56
+ },
57
+ /**
58
+ * @description 组件最大宽度
59
+ */
60
+ maxWidth: {
61
+ type: String,
62
+ default: "100%"
63
+ },
64
+ /**
65
+ * @description 卡片背景色
66
+ */
67
+ backgroundColor: {
68
+ type: String,
69
+ default: "#fcfcfc"
70
+ },
71
+ /**
72
+ * @description 正文字体颜色
73
+ */
74
+ color: {
75
+ type: String,
76
+ default: "var(--el-color-info)"
77
+ },
78
+ /**
79
+ * @description 标题文案
80
+ */
81
+ title: {
82
+ type: String,
83
+ default: "\u5206\u6790\u7528\u6237\u9700\u6C42"
84
+ },
85
+ /**
86
+ * @description 跳过按钮文案
87
+ */
88
+ skipText: {
89
+ type: String,
90
+ default: "\u8DF3\u8FC7\u601D\u8003"
91
+ },
92
+ /**
93
+ * @description 是否显示跳过按钮
94
+ */
95
+ showSkip: {
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ /**
100
+ * @description 卡片圆角
101
+ */
102
+ radius: {
103
+ type: String,
104
+ default: "22px"
105
+ },
106
+ /**
107
+ * @description 卡片边框颜色
108
+ */
109
+ borderColor: {
110
+ type: String,
111
+ default: "#e4e7ed"
112
+ },
113
+ /**
114
+ * @description 内容区域最大高度(超过后滚动)
115
+ */
116
+ maxHeight: {
117
+ type: String,
118
+ default: ""
119
+ }
120
+ };
121
+ const emits = {
122
+ "change": null,
123
+ "update:modelValue": null,
124
+ "skip": null
125
+ };
126
+
127
+ var _sfc_main = /* @__PURE__ */ defineComponent({
128
+ ...{
129
+ name: "VkThinking",
130
+ inheritAttrs: false
131
+ },
132
+ __name: "index",
133
+ props: props,
134
+ emits,
135
+ setup(__props, { expose: __expose, emit: __emit }) {
136
+ __expose();
137
+ const props = __props;
138
+ const emit = __emit;
139
+ const slots = useSlots();
140
+ const isExpanded = ref(props.modelValue);
141
+ watch(
142
+ () => props.modelValue,
143
+ (newVal) => {
144
+ isExpanded.value = newVal;
145
+ }
146
+ );
147
+ watch(
148
+ () => props.status,
149
+ (newVal) => {
150
+ if (newVal === "end" && props.autoCollapse) {
151
+ isExpanded.value = false;
152
+ emit("update:modelValue", false);
153
+ }
154
+ }
155
+ );
156
+ const displayedContent = computed(() => {
157
+ return props.status === "error" ? "\u601D\u8003\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF" : props.content;
158
+ });
159
+ const hasContent = computed(() => {
160
+ return Boolean(slots.default) || Boolean(displayedContent.value);
161
+ });
162
+ const showSkipAction = computed(() => {
163
+ return props.showSkip && !props.disabled && props.status === "thinking";
164
+ });
165
+ const titleText = computed(() => {
166
+ if (props.status === "error")
167
+ return "\u5206\u6790\u51FA\u73B0\u95EE\u9898";
168
+ if (props.status === "cancel")
169
+ return "\u5DF2\u8DF3\u8FC7\u601D\u8003";
170
+ return props.title;
171
+ });
172
+ const cssVars = computed(() => ({
173
+ "--vk-thinking-animation-duration": props.duration,
174
+ "--vk-thinking-button-width": props.buttonWidth,
175
+ "--vk-thinking-max-width": props.maxWidth,
176
+ "--vk-thinking-background-color": props.backgroundColor,
177
+ "--vk-thinking-color": props.color,
178
+ "--vk-thinking-radius": props.radius,
179
+ "--vk-thinking-border-color": props.borderColor,
180
+ "--vk-thinking-body-max-height": props.maxHeight || "none",
181
+ "--vk-thinking-font-size-base": "16px",
182
+ "--vk-thinking-font-size-title": "1.125em",
183
+ "--vk-thinking-font-size-skip": "1em",
184
+ "--vk-thinking-font-size-content": "0.9em",
185
+ "--vk-thinking-font-size-caret": "0.8125em"
186
+ }));
187
+ const scrollbarRef = ref();
188
+ watch(
189
+ () => [props.content, isExpanded.value, props.status],
190
+ () => {
191
+ if (props.status === "thinking" && isExpanded.value) {
192
+ nextTick(() => {
193
+ scrollbarRef.value?.scrollToBottom({
194
+ behavior: "auto"
195
+ });
196
+ });
197
+ }
198
+ },
199
+ { flush: "post" }
200
+ );
201
+ function emitChange() {
202
+ emit("change", {
203
+ value: isExpanded.value,
204
+ status: props.status
205
+ });
206
+ emit("update:modelValue", isExpanded.value);
207
+ }
208
+ function toggleExpand() {
209
+ if (props.disabled || !hasContent.value)
210
+ return;
211
+ isExpanded.value = !isExpanded.value;
212
+ emitChange();
213
+ }
214
+ function skipThinking() {
215
+ if (props.disabled)
216
+ return;
217
+ isExpanded.value = false;
218
+ emitChange();
219
+ emit("skip", {
220
+ value: false,
221
+ status: props.status
222
+ });
223
+ }
224
+ const __returned__ = { props, emit, slots, isExpanded, displayedContent, hasContent, showSkipAction, titleText, cssVars, scrollbarRef, emitChange, toggleExpand, skipThinking, get ArrowRightBold() {
225
+ return arrow_right_bold_default;
226
+ }, get VkScrollbar() {
227
+ return VkScrollbar;
228
+ }, get ElCollapseTransition() {
229
+ return ElCollapseTransition;
230
+ }, get ElIcon() {
231
+ return ElIcon;
232
+ } };
233
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
234
+ return __returned__;
235
+ }
236
+ });
237
+
238
+ const _hoisted_1 = { class: "vk-thinking__header" };
239
+ const _hoisted_2 = ["disabled"];
240
+ const _hoisted_3 = { class: "vk-thinking__title" };
241
+ const _hoisted_4 = { class: "vk-thinking__body" };
242
+ const _hoisted_5 = { class: "vk-thinking__content" };
243
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
244
+ return openBlock(), createElementBlock(
245
+ "div",
246
+ {
247
+ class: "vk-thinking",
248
+ style: normalizeStyle($setup.cssVars)
249
+ },
250
+ [
251
+ createElementVNode(
252
+ "section",
253
+ {
254
+ class: normalizeClass(["vk-thinking__card", [
255
+ `is-${_ctx.status}`,
256
+ {
257
+ "is-disabled": _ctx.disabled,
258
+ "is-expanded": $setup.isExpanded && $setup.hasContent
259
+ }
260
+ ]])
261
+ },
262
+ [
263
+ createElementVNode("header", _hoisted_1, [
264
+ createElementVNode("button", {
265
+ class: "vk-thinking__toggle",
266
+ type: "button",
267
+ disabled: _ctx.disabled,
268
+ onClick: $setup.toggleExpand
269
+ }, [
270
+ createElementVNode(
271
+ "span",
272
+ _hoisted_3,
273
+ toDisplayString($setup.titleText) + "\uFF1A",
274
+ 1
275
+ /* TEXT */
276
+ ),
277
+ createVNode($setup["ElIcon"], {
278
+ class: normalizeClass(["vk-thinking__caret", { "is-expanded": $setup.isExpanded }])
279
+ }, {
280
+ default: withCtx(() => [
281
+ createVNode($setup["ArrowRightBold"])
282
+ ]),
283
+ _: 1
284
+ /* STABLE */
285
+ }, 8, ["class"])
286
+ ], 8, _hoisted_2),
287
+ $setup.showSkipAction ? (openBlock(), createElementBlock(
288
+ "button",
289
+ {
290
+ key: 0,
291
+ class: "vk-thinking__skip",
292
+ type: "button",
293
+ onClick: withModifiers($setup.skipThinking, ["stop"])
294
+ },
295
+ toDisplayString(_ctx.skipText),
296
+ 1
297
+ /* TEXT */
298
+ )) : createCommentVNode("v-if", true)
299
+ ]),
300
+ createVNode($setup["ElCollapseTransition"], null, {
301
+ default: withCtx(() => [
302
+ withDirectives(createElementVNode(
303
+ "div",
304
+ _hoisted_4,
305
+ [
306
+ createVNode($setup["VkScrollbar"], {
307
+ ref: "scrollbarRef",
308
+ class: "vk-thinking__scrollbar",
309
+ "max-height": _ctx.maxHeight
310
+ }, {
311
+ default: withCtx(() => [
312
+ renderSlot(_ctx.$slots, "default", {
313
+ content: $setup.displayedContent,
314
+ status: _ctx.status
315
+ }, () => [
316
+ createElementVNode(
317
+ "div",
318
+ _hoisted_5,
319
+ toDisplayString($setup.displayedContent),
320
+ 1
321
+ /* TEXT */
322
+ )
323
+ ])
324
+ ]),
325
+ _: 3
326
+ /* FORWARDED */
327
+ }, 8, ["max-height"])
328
+ ],
329
+ 512
330
+ /* NEED_PATCH */
331
+ ), [
332
+ [vShow, $setup.isExpanded && $setup.hasContent]
333
+ ])
334
+ ]),
335
+ _: 3
336
+ /* FORWARDED */
337
+ })
338
+ ],
339
+ 2
340
+ /* CLASS */
341
+ )
342
+ ],
343
+ 4
344
+ /* STYLE */
345
+ );
346
+ }
347
+ var VkThinking = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/thinking/src/index.vue"]]);
348
+
349
+ var types = /*#__PURE__*/Object.freeze({
350
+ __proto__: null
351
+ });
352
+
353
+ VkThinking.install = (app) => {
354
+ app.component(VkThinking.name || "VkThinking", VkThinking);
355
+ };
356
+
357
+ export { VkThinking, types as __VkThinking, VkThinking as default };
@@ -0,0 +1,121 @@
1
+ import type { PropType } from 'vue';
2
+ import type { ThinkingStatus } from './types';
3
+ export declare const props: {
4
+ /**
5
+ * @description 展开/收起状态(v-model)
6
+ */
7
+ modelValue: {
8
+ type: BooleanConstructor;
9
+ default: boolean;
10
+ };
11
+ /**
12
+ * @description 思考内容文本
13
+ */
14
+ content: {
15
+ type: StringConstructor;
16
+ default: string;
17
+ };
18
+ /**
19
+ * @description 当前思考状态
20
+ */
21
+ status: {
22
+ type: PropType<ThinkingStatus>;
23
+ default: ThinkingStatus;
24
+ };
25
+ /**
26
+ * @description 是否禁用交互
27
+ */
28
+ disabled: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ /**
33
+ * @description status=end 时是否自动收起
34
+ */
35
+ autoCollapse: {
36
+ type: BooleanConstructor;
37
+ default: boolean;
38
+ };
39
+ /**
40
+ * @description 动画过渡时长
41
+ */
42
+ duration: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ /**
47
+ * @description 头部触发按钮最小宽度
48
+ */
49
+ buttonWidth: {
50
+ type: StringConstructor;
51
+ default: string;
52
+ };
53
+ /**
54
+ * @description 组件最大宽度
55
+ */
56
+ maxWidth: {
57
+ type: StringConstructor;
58
+ default: string;
59
+ };
60
+ /**
61
+ * @description 卡片背景色
62
+ */
63
+ backgroundColor: {
64
+ type: StringConstructor;
65
+ default: string;
66
+ };
67
+ /**
68
+ * @description 正文字体颜色
69
+ */
70
+ color: {
71
+ type: StringConstructor;
72
+ default: string;
73
+ };
74
+ /**
75
+ * @description 标题文案
76
+ */
77
+ title: {
78
+ type: StringConstructor;
79
+ default: string;
80
+ };
81
+ /**
82
+ * @description 跳过按钮文案
83
+ */
84
+ skipText: {
85
+ type: StringConstructor;
86
+ default: string;
87
+ };
88
+ /**
89
+ * @description 是否显示跳过按钮
90
+ */
91
+ showSkip: {
92
+ type: BooleanConstructor;
93
+ default: boolean;
94
+ };
95
+ /**
96
+ * @description 卡片圆角
97
+ */
98
+ radius: {
99
+ type: StringConstructor;
100
+ default: string;
101
+ };
102
+ /**
103
+ * @description 卡片边框颜色
104
+ */
105
+ borderColor: {
106
+ type: StringConstructor;
107
+ default: string;
108
+ };
109
+ /**
110
+ * @description 内容区域最大高度(超过后滚动)
111
+ */
112
+ maxHeight: {
113
+ type: StringConstructor;
114
+ default: string;
115
+ };
116
+ };
117
+ export declare const emits: {
118
+ change: null;
119
+ 'update:modelValue': null;
120
+ skip: null;
121
+ };