@vunk/plus 1.7.5 → 1.8.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.
Files changed (120) hide show
  1. package/components/scrollbar/index.mjs +595 -0
  2. package/package.json +5 -1
  3. package/components/agent-chat-provider/index.d.ts +0 -8
  4. package/components/agent-chat-provider/src/MessageView.d.ts +0 -29
  5. package/components/agent-chat-provider/src/api.d.ts +0 -3
  6. package/components/agent-chat-provider/src/const-roles.d.ts +0 -8
  7. package/components/agent-chat-provider/src/const.d.ts +0 -1
  8. package/components/agent-chat-provider/src/index.vue.d.ts +0 -22
  9. package/components/agent-chat-provider/src/types.d.ts +0 -56
  10. package/components/agent-chat-provider/src/use.d.ts +0 -6
  11. package/components/avatar/index.d.ts +0 -4
  12. package/components/avatar/src/ctx.d.ts +0 -6
  13. package/components/avatar/src/index.vue.d.ts +0 -261
  14. package/components/avatar/src/types.d.ts +0 -1
  15. package/components/broadcasting-markdown/index.d.ts +0 -7
  16. package/components/broadcasting-markdown/src/const.d.ts +0 -13
  17. package/components/broadcasting-markdown/src/ctx.d.ts +0 -126
  18. package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +0 -58
  19. package/components/broadcasting-markdown/src/index.vue.d.ts +0 -373
  20. package/components/broadcasting-markdown/src/paragraph.vue.d.ts +0 -79
  21. package/components/broadcasting-markdown/src/speech-error.vue.d.ts +0 -60
  22. package/components/broadcasting-markdown/src/types.d.ts +0 -26
  23. package/components/broadcasting-markdown/src/use.d.ts +0 -19
  24. package/components/bubble-list/index.d.ts +0 -5
  25. package/components/bubble-list/src/ctx.d.ts +0 -28
  26. package/components/bubble-list/src/index.vue.d.ts +0 -484
  27. package/components/bubble-list/src/types.d.ts +0 -4
  28. package/components/bubble-templates/index.d.ts +0 -5
  29. package/components/bubble-templates/src/core.d.ts +0 -69
  30. package/components/bubble-templates/src/index.vue.d.ts +0 -242
  31. package/components/bubble-templates/src/legacy.vue.d.ts +0 -153
  32. package/components/bubble-templates/src/types.d.ts +0 -45
  33. package/components/chat-independent/index.d.ts +0 -4
  34. package/components/chat-independent/src/const.d.ts +0 -13
  35. package/components/chat-independent/src/ctx.d.ts +0 -21
  36. package/components/chat-independent/src/index.vue.d.ts +0 -2407
  37. package/components/chat-independent/src/types.d.ts +0 -13
  38. package/components/index.d.ts +0 -0
  39. package/components/lottie-animation/index.d.ts +0 -4
  40. package/components/lottie-animation/src/ctx.d.ts +0 -10
  41. package/components/lottie-animation/src/index.vue.d.ts +0 -21
  42. package/components/lottie-animation/src/types.d.ts +0 -4
  43. package/components/metahuman-broadcasting/index.d.ts +0 -5
  44. package/components/metahuman-broadcasting/src/ctx.d.ts +0 -57
  45. package/components/metahuman-broadcasting/src/index.vue.d.ts +0 -826
  46. package/components/metahuman-broadcasting/src/types.d.ts +0 -1
  47. package/components/monaco-editor/index.d.ts +0 -5
  48. package/components/monaco-editor/src/ctx.d.ts +0 -23
  49. package/components/monaco-editor/src/index.vue.d.ts +0 -40
  50. package/components/monaco-editor/src/types.d.ts +0 -1
  51. package/components/monaco-environment/index.d.ts +0 -4
  52. package/components/monaco-environment/src/ctx.d.ts +0 -8
  53. package/components/monaco-environment/src/index.vue.d.ts +0 -2
  54. package/components/monaco-environment/src/types.d.ts +0 -1
  55. package/components/pixi-frame/index.d.ts +0 -11
  56. package/components/pixi-frame/src/apng.vue.d.ts +0 -161
  57. package/components/pixi-frame/src/bitmap.vue.d.ts +0 -158
  58. package/components/pixi-frame/src/core.vue.d.ts +0 -173
  59. package/components/pixi-frame/src/ctx.d.ts +0 -55
  60. package/components/pixi-frame/src/index.vue.d.ts +0 -591
  61. package/components/pixi-frame/src/provider.vue.d.ts +0 -2
  62. package/components/pixi-frame/src/types.d.ts +0 -17
  63. package/components/pixi-frame/src/use.d.ts +0 -16
  64. package/components/pixi-frame/src/useSprite.d.ts +0 -12
  65. package/components/pixi-frame/src/video.vue.d.ts +0 -159
  66. package/components/pixi-frame/src/view.vue.d.ts +0 -29
  67. package/components/recorder-button/index.d.ts +0 -4
  68. package/components/recorder-button/src/ctx.d.ts +0 -41
  69. package/components/recorder-button/src/index.vue.d.ts +0 -489
  70. package/components/recorder-button/src/speech-to-text.d.ts +0 -1
  71. package/components/recorder-button/src/types.d.ts +0 -7
  72. package/components/routes-menu-content/index.d.ts +0 -4
  73. package/components/routes-menu-content/src/ctx.d.ts +0 -17
  74. package/components/routes-menu-content/src/index.vue.d.ts +0 -573
  75. package/components/routes-menu-content/src/item/core/ctx.d.ts +0 -18
  76. package/components/routes-menu-content/src/item/core/index.vue.d.ts +0 -408
  77. package/components/routes-menu-content/src/item/ctx.d.ts +0 -14
  78. package/components/routes-menu-content/src/item/index.vue.d.ts +0 -539
  79. package/components/routes-menu-content/src/types.d.ts +0 -1
  80. package/components/sender/index.d.ts +0 -4
  81. package/components/sender/src/SenderHeader.vue.d.ts +0 -256
  82. package/components/sender/src/ctx.d.ts +0 -64
  83. package/components/sender/src/index.vue.d.ts +0 -765
  84. package/components/sender/src/types.d.ts +0 -1
  85. package/components/speech-button/index.d.ts +0 -4
  86. package/components/speech-button/src/LoadingIcon.vue.d.ts +0 -2
  87. package/components/speech-button/src/RecordingIcon.vue.d.ts +0 -2
  88. package/components/speech-button/src/ctx.d.ts +0 -10
  89. package/components/speech-button/src/index.vue.d.ts +0 -22
  90. package/components/speech-button/src/types.d.ts +0 -1
  91. package/components/table-columns/index.d.ts +0 -5
  92. package/components/table-columns/src/ctx.d.ts +0 -59
  93. package/components/table-columns/src/el-ctx.d.ts +0 -57
  94. package/components/table-columns/src/index.vue.d.ts +0 -132
  95. package/components/table-columns/src/types.d.ts +0 -21
  96. package/components/tables-v1/index.d.ts +0 -5
  97. package/components/tables-v1/src/ctx.d.ts +0 -337
  98. package/components/tables-v1/src/el-ctx.d.ts +0 -262
  99. package/components/tables-v1/src/index.vue.d.ts +0 -3085
  100. package/components/tables-v1/src/types.d.ts +0 -3
  101. package/components/tables-v1-checkbox/index.d.ts +0 -5
  102. package/components/tables-v1-checkbox/src/ctx.d.ts +0 -370
  103. package/components/tables-v1-checkbox/src/index.vue.d.ts +0 -3972
  104. package/components/tables-v1-checkbox/src/types.d.ts +0 -1
  105. package/components/text/index.d.ts +0 -4
  106. package/components/text/src/ctx.d.ts +0 -356
  107. package/components/text/src/index.vue.d.ts +0 -2335
  108. package/components/text/src/types.d.ts +0 -1
  109. package/components/typing-markdown/index.d.ts +0 -4
  110. package/components/typing-markdown/src/core.d.ts +0 -2
  111. package/components/typing-markdown/src/ctx.d.ts +0 -41
  112. package/components/typing-markdown/src/index.vue.d.ts +0 -75
  113. package/components/typing-markdown/src/types.d.ts +0 -1
  114. package/components/vditor/index.d.ts +0 -5
  115. package/components/vditor/src/ctx.d.ts +0 -38
  116. package/components/vditor/src/handle-fullscreen.vue.d.ts +0 -18
  117. package/components/vditor/src/handle-value.vue.d.ts +0 -18
  118. package/components/vditor/src/index.vue.d.ts +0 -143
  119. package/components/vditor/src/types.d.ts +0 -9
  120. package/components/vditor/src/use.d.ts +0 -4
@@ -0,0 +1,595 @@
1
+ import { defineComponent, inject, ref, computed, onBeforeUnmount, toRef, openBlock, createBlock, Transition, withCtx, withDirectives, createElementVNode, normalizeClass, withModifiers, normalizeStyle, vShow, createElementBlock, Fragment, createVNode, watch, nextTick, provide, reactive, onActivated, onMounted, onUpdated, resolveDynamicComponent, renderSlot, createCommentVNode } from 'vue';
2
+ import { useEventListener, isClient, useResizeObserver, isObject } from '@vueuse/core';
3
+ import { VkAsyncTeleport } from '@vunk/core/components/async-teleport';
4
+ import { scrollbarContextKey, useNamespace, BAR_MAP, renderThumbStyle, GAP, SCOPE, scrollbarProps, scrollbarEmits } from 'element-plus';
5
+ import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
6
+
7
+ const barProps = {
8
+ always: {
9
+ type: Boolean,
10
+ default: true
11
+ },
12
+ minSize: {
13
+ type: Number,
14
+ required: true
15
+ }
16
+ };
17
+
18
+ const thumbProps = {
19
+ vertical: Boolean,
20
+ size: String,
21
+ move: Number,
22
+ ratio: {
23
+ type: Number,
24
+ required: true
25
+ },
26
+ always: Boolean
27
+ };
28
+
29
+ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
30
+ __name: "thumb",
31
+ props: thumbProps,
32
+ setup(__props, { expose: __expose }) {
33
+ __expose();
34
+ const props = __props;
35
+ const scrollbar = inject(scrollbarContextKey);
36
+ const ns = useNamespace("scrollbar");
37
+ const instance = ref();
38
+ const thumb = ref();
39
+ const thumbState = ref({});
40
+ const visible = ref(false);
41
+ let cursorDown = false;
42
+ let cursorLeave = false;
43
+ let baseScrollHeight = 0;
44
+ let baseScrollWidth = 0;
45
+ let originalOnSelectStart = isClient ? document.onselectstart : null;
46
+ const bar = computed(() => BAR_MAP[props.vertical ? "vertical" : "horizontal"]);
47
+ const thumbStyle = computed(
48
+ () => renderThumbStyle({
49
+ size: props.size,
50
+ move: props.move,
51
+ bar: bar.value
52
+ })
53
+ );
54
+ const offsetRatio = computed(
55
+ () => (
56
+ // offsetRatioX = original width of thumb / current width of thumb / ratioX
57
+ // offsetRatioY = original height of thumb / current height of thumb / ratioY
58
+ // instance height = wrap height - GAP
59
+ instance.value[bar.value.offset] ** 2 / scrollbar.wrapElement[bar.value.scrollSize] / props.ratio / thumb.value[bar.value.offset]
60
+ )
61
+ );
62
+ function clickThumbHandler(e) {
63
+ e.stopPropagation();
64
+ if (e.ctrlKey || [1, 2].includes(e.button))
65
+ return;
66
+ window.getSelection()?.removeAllRanges();
67
+ startDrag(e);
68
+ const el = e.currentTarget;
69
+ if (!el)
70
+ return;
71
+ thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
72
+ }
73
+ function clickTrackHandler(e) {
74
+ if (!thumb.value || !instance.value || !scrollbar.wrapElement)
75
+ return;
76
+ const offset = Math.abs(
77
+ e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]
78
+ );
79
+ const thumbHalf = thumb.value[bar.value.offset] / 2;
80
+ const thumbPositionPercentage = (offset - thumbHalf) * 100 * offsetRatio.value / instance.value[bar.value.offset];
81
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement[bar.value.scrollSize] / 100;
82
+ }
83
+ function startDrag(e) {
84
+ e.stopImmediatePropagation();
85
+ cursorDown = true;
86
+ baseScrollHeight = scrollbar.wrapElement.scrollHeight;
87
+ baseScrollWidth = scrollbar.wrapElement.scrollWidth;
88
+ document.addEventListener("mousemove", mouseMoveDocumentHandler);
89
+ document.addEventListener("mouseup", mouseUpDocumentHandler);
90
+ originalOnSelectStart = document.onselectstart;
91
+ document.onselectstart = () => false;
92
+ }
93
+ function mouseMoveDocumentHandler(e) {
94
+ if (!instance.value || !thumb.value)
95
+ return;
96
+ if (cursorDown === false)
97
+ return;
98
+ const prevPage = thumbState.value[bar.value.axis];
99
+ if (!prevPage)
100
+ return;
101
+ const offset = (instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
102
+ const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
103
+ const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * offsetRatio.value / instance.value[bar.value.offset];
104
+ if (bar.value.scroll === "scrollLeft") {
105
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * baseScrollWidth / 100;
106
+ } else {
107
+ scrollbar.wrapElement[bar.value.scroll] = thumbPositionPercentage * baseScrollHeight / 100;
108
+ }
109
+ }
110
+ function mouseUpDocumentHandler() {
111
+ cursorDown = false;
112
+ thumbState.value[bar.value.axis] = 0;
113
+ document.removeEventListener("mousemove", mouseMoveDocumentHandler);
114
+ document.removeEventListener("mouseup", mouseUpDocumentHandler);
115
+ restoreOnselectstart();
116
+ if (cursorLeave)
117
+ visible.value = false;
118
+ }
119
+ function mouseMoveScrollbarHandler() {
120
+ cursorLeave = false;
121
+ visible.value = !!props.size;
122
+ }
123
+ function mouseLeaveScrollbarHandler() {
124
+ cursorLeave = true;
125
+ visible.value = cursorDown;
126
+ }
127
+ onBeforeUnmount(() => {
128
+ restoreOnselectstart();
129
+ document.removeEventListener("mouseup", mouseUpDocumentHandler);
130
+ });
131
+ function restoreOnselectstart() {
132
+ if (document.onselectstart !== originalOnSelectStart)
133
+ document.onselectstart = originalOnSelectStart;
134
+ }
135
+ useEventListener(
136
+ toRef(scrollbar, "scrollbarElement"),
137
+ "mousemove",
138
+ mouseMoveScrollbarHandler
139
+ );
140
+ useEventListener(
141
+ toRef(scrollbar, "scrollbarElement"),
142
+ "mouseleave",
143
+ mouseLeaveScrollbarHandler
144
+ );
145
+ const __returned__ = { props, scrollbar, ns, instance, thumb, thumbState, visible, get cursorDown() {
146
+ return cursorDown;
147
+ }, set cursorDown(v) {
148
+ cursorDown = v;
149
+ }, get cursorLeave() {
150
+ return cursorLeave;
151
+ }, set cursorLeave(v) {
152
+ cursorLeave = v;
153
+ }, get baseScrollHeight() {
154
+ return baseScrollHeight;
155
+ }, set baseScrollHeight(v) {
156
+ baseScrollHeight = v;
157
+ }, get baseScrollWidth() {
158
+ return baseScrollWidth;
159
+ }, set baseScrollWidth(v) {
160
+ baseScrollWidth = v;
161
+ }, get originalOnSelectStart() {
162
+ return originalOnSelectStart;
163
+ }, set originalOnSelectStart(v) {
164
+ originalOnSelectStart = v;
165
+ }, bar, thumbStyle, offsetRatio, clickThumbHandler, clickTrackHandler, startDrag, mouseMoveDocumentHandler, mouseUpDocumentHandler, mouseMoveScrollbarHandler, mouseLeaveScrollbarHandler, restoreOnselectstart };
166
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
167
+ return __returned__;
168
+ }
169
+ });
170
+
171
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
172
+ return openBlock(), createBlock(Transition, {
173
+ name: $setup.ns.b("fade"),
174
+ persisted: ""
175
+ }, {
176
+ default: withCtx(() => [
177
+ withDirectives(createElementVNode(
178
+ "div",
179
+ {
180
+ ref: "instance",
181
+ class: normalizeClass([$setup.ns.e("bar"), $setup.ns.is($setup.bar.key)]),
182
+ onMousedown: $setup.clickTrackHandler,
183
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
184
+ }, ["stop"]))
185
+ },
186
+ [
187
+ createElementVNode(
188
+ "div",
189
+ {
190
+ ref: "thumb",
191
+ class: normalizeClass($setup.ns.e("thumb")),
192
+ style: normalizeStyle($setup.thumbStyle),
193
+ onMousedown: $setup.clickThumbHandler
194
+ },
195
+ null,
196
+ 38
197
+ /* CLASS, STYLE, NEED_HYDRATION */
198
+ )
199
+ ],
200
+ 34
201
+ /* CLASS, NEED_HYDRATION */
202
+ ), [
203
+ [vShow, _ctx.always || $setup.visible]
204
+ ])
205
+ ]),
206
+ _: 1
207
+ /* STABLE */
208
+ }, 8, ["name"]);
209
+ }
210
+ var Thumb = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/scrollbar/src/thumb.vue"]]);
211
+
212
+ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
213
+ __name: "bar",
214
+ props: barProps,
215
+ setup(__props, { expose: __expose }) {
216
+ const props = __props;
217
+ const scrollbar = inject(scrollbarContextKey);
218
+ const moveX = ref(0);
219
+ const moveY = ref(0);
220
+ const sizeWidth = ref("");
221
+ const sizeHeight = ref("");
222
+ const ratioY = ref(1);
223
+ const ratioX = ref(1);
224
+ function handleScroll(wrap) {
225
+ if (wrap) {
226
+ const offsetHeight = wrap.offsetHeight - GAP;
227
+ const offsetWidth = wrap.offsetWidth - GAP;
228
+ moveY.value = wrap.scrollTop * 100 / offsetHeight * ratioY.value;
229
+ moveX.value = wrap.scrollLeft * 100 / offsetWidth * ratioX.value;
230
+ }
231
+ }
232
+ function update() {
233
+ const wrap = scrollbar?.wrapElement;
234
+ if (!wrap)
235
+ return;
236
+ const offsetHeight = wrap.offsetHeight - GAP;
237
+ const offsetWidth = wrap.offsetWidth - GAP;
238
+ const originalHeight = offsetHeight ** 2 / wrap.scrollHeight;
239
+ const originalWidth = offsetWidth ** 2 / wrap.scrollWidth;
240
+ const height = Math.max(originalHeight, props.minSize);
241
+ const width = Math.max(originalWidth, props.minSize);
242
+ ratioY.value = originalHeight / (offsetHeight - originalHeight) / (height / (offsetHeight - height));
243
+ ratioX.value = originalWidth / (offsetWidth - originalWidth) / (width / (offsetWidth - width));
244
+ sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : "";
245
+ sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : "";
246
+ }
247
+ __expose({
248
+ handleScroll,
249
+ update
250
+ });
251
+ const __returned__ = { props, scrollbar, moveX, moveY, sizeWidth, sizeHeight, ratioY, ratioX, handleScroll, update, Thumb };
252
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
253
+ return __returned__;
254
+ }
255
+ });
256
+
257
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
258
+ return openBlock(), createElementBlock(
259
+ Fragment,
260
+ null,
261
+ [
262
+ createVNode($setup["Thumb"], {
263
+ move: $setup.moveX,
264
+ ratio: $setup.ratioX,
265
+ size: $setup.sizeWidth,
266
+ always: _ctx.always
267
+ }, null, 8, ["move", "ratio", "size", "always"]),
268
+ createVNode($setup["Thumb"], {
269
+ move: $setup.moveY,
270
+ ratio: $setup.ratioY,
271
+ size: $setup.sizeHeight,
272
+ vertical: "",
273
+ always: _ctx.always
274
+ }, null, 8, ["move", "ratio", "size", "always"])
275
+ ],
276
+ 64
277
+ /* STABLE_FRAGMENT */
278
+ );
279
+ }
280
+ var Bar = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/scrollbar/src/bar.vue"]]);
281
+
282
+ /**
283
+ * @vue/shared v3.5.13
284
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
285
+ * @license MIT
286
+ **/
287
+
288
+
289
+
290
+ !!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
291
+ !!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
292
+ const isString = (val) => typeof val === "string";
293
+
294
+ const isNumber = (val) => typeof val === "number";
295
+ function isStringNumber(val) {
296
+ if (!isString(val)) {
297
+ return false;
298
+ }
299
+ return !Number.isNaN(Number(val));
300
+ }
301
+ function addUnit(value, defaultUnit = "px") {
302
+ if (!value)
303
+ return "";
304
+ if (isNumber(value) || isStringNumber(value)) {
305
+ return `${value}${defaultUnit}`;
306
+ } else if (isString(value)) {
307
+ return value;
308
+ }
309
+ console.warn(SCOPE, "binding value must be a string or number");
310
+ }
311
+
312
+ const COMPONENT_NAME = "ElScrollbar";
313
+ var _sfc_main = /* @__PURE__ */ defineComponent({
314
+ __name: "index",
315
+ props: {
316
+ ...scrollbarProps,
317
+ appendTo: null
318
+ },
319
+ emits: scrollbarEmits,
320
+ setup(__props, { expose: __expose, emit: __emit }) {
321
+ const props = __props;
322
+ const emit = __emit;
323
+ const ns = useNamespace("scrollbar");
324
+ let stopResizeObserver;
325
+ let stopWrapResizeObserver;
326
+ let stopResizeListener;
327
+ let wrapScrollTop = 0;
328
+ let wrapScrollLeft = 0;
329
+ let direction = "";
330
+ const distanceScrollState = {
331
+ bottom: false,
332
+ top: false,
333
+ right: false,
334
+ left: false
335
+ };
336
+ const scrollbarRef = ref();
337
+ const wrapRef = ref();
338
+ const resizeRef = ref();
339
+ const barRef = ref();
340
+ const wrapStyle = computed(() => {
341
+ const style = {};
342
+ if (props.height)
343
+ style.height = addUnit(props.height);
344
+ if (props.maxHeight)
345
+ style.maxHeight = addUnit(props.maxHeight);
346
+ return [props.wrapStyle, style];
347
+ });
348
+ const wrapKls = computed(() => {
349
+ return [
350
+ props.wrapClass,
351
+ ns.e("wrap"),
352
+ { [ns.em("wrap", "hidden-default")]: !props.native }
353
+ ];
354
+ });
355
+ const resizeKls = computed(() => {
356
+ return [ns.e("view"), props.viewClass];
357
+ });
358
+ function shouldSkipDirection(direction2) {
359
+ return distanceScrollState[direction2] ?? false;
360
+ }
361
+ const DIRECTION_PAIRS = {
362
+ top: "bottom",
363
+ bottom: "top",
364
+ left: "right",
365
+ right: "left"
366
+ };
367
+ function updateTriggerStatus(arrivedStates) {
368
+ const oppositeDirection = DIRECTION_PAIRS[direction];
369
+ if (!oppositeDirection)
370
+ return;
371
+ const arrived = arrivedStates[direction];
372
+ const oppositeArrived = arrivedStates[oppositeDirection];
373
+ if (arrived && !distanceScrollState[direction]) {
374
+ distanceScrollState[direction] = true;
375
+ }
376
+ if (!oppositeArrived && distanceScrollState[oppositeDirection]) {
377
+ distanceScrollState[oppositeDirection] = false;
378
+ }
379
+ }
380
+ function handleScroll() {
381
+ if (wrapRef.value) {
382
+ barRef.value?.handleScroll(wrapRef.value);
383
+ const prevTop = wrapScrollTop;
384
+ const prevLeft = wrapScrollLeft;
385
+ wrapScrollTop = wrapRef.value.scrollTop;
386
+ wrapScrollLeft = wrapRef.value.scrollLeft;
387
+ const arrivedStates = {
388
+ bottom: wrapScrollTop + wrapRef.value.clientHeight >= wrapRef.value.scrollHeight - props.distance,
389
+ top: wrapScrollTop <= props.distance && prevTop !== 0,
390
+ right: wrapScrollLeft + wrapRef.value.clientWidth >= wrapRef.value.scrollWidth - props.distance && prevLeft !== wrapScrollLeft,
391
+ left: wrapScrollLeft <= props.distance && prevLeft !== 0
392
+ };
393
+ emit("scroll", {
394
+ scrollTop: wrapScrollTop,
395
+ scrollLeft: wrapScrollLeft
396
+ });
397
+ if (prevTop !== wrapScrollTop) {
398
+ direction = wrapScrollTop > prevTop ? "bottom" : "top";
399
+ }
400
+ if (prevLeft !== wrapScrollLeft) {
401
+ direction = wrapScrollLeft > prevLeft ? "right" : "left";
402
+ }
403
+ if (props.distance > 0) {
404
+ if (shouldSkipDirection(direction)) {
405
+ return;
406
+ }
407
+ updateTriggerStatus(arrivedStates);
408
+ }
409
+ if (arrivedStates[direction])
410
+ emit("end-reached", direction);
411
+ }
412
+ }
413
+ function scrollTo(arg1, arg2) {
414
+ if (isObject(arg1)) {
415
+ wrapRef.value.scrollTo(arg1);
416
+ } else if (isNumber(arg1) && isNumber(arg2)) {
417
+ wrapRef.value.scrollTo(arg1, arg2);
418
+ }
419
+ }
420
+ function setScrollTop(value) {
421
+ if (!isNumber(value)) {
422
+ console.warn(COMPONENT_NAME, "value must be a number");
423
+ return;
424
+ }
425
+ wrapRef.value.scrollTop = value;
426
+ }
427
+ function setScrollLeft(value) {
428
+ if (!isNumber(value)) {
429
+ console.warn(COMPONENT_NAME, "value must be a number");
430
+ return;
431
+ }
432
+ wrapRef.value.scrollLeft = value;
433
+ }
434
+ function update() {
435
+ barRef.value?.update();
436
+ distanceScrollState[direction] = false;
437
+ }
438
+ watch(
439
+ () => props.noresize,
440
+ (noresize) => {
441
+ if (noresize) {
442
+ stopResizeObserver?.();
443
+ stopWrapResizeObserver?.();
444
+ stopResizeListener?.();
445
+ } else {
446
+ ({ stop: stopResizeObserver } = useResizeObserver(resizeRef, update));
447
+ ({ stop: stopWrapResizeObserver } = useResizeObserver(wrapRef, update));
448
+ stopResizeListener = useEventListener("resize", update);
449
+ }
450
+ },
451
+ { immediate: true }
452
+ );
453
+ watch(
454
+ () => [props.maxHeight, props.height],
455
+ () => {
456
+ if (!props.native) {
457
+ nextTick(() => {
458
+ update();
459
+ if (wrapRef.value) {
460
+ barRef.value?.handleScroll(wrapRef.value);
461
+ }
462
+ });
463
+ }
464
+ }
465
+ );
466
+ provide(
467
+ scrollbarContextKey,
468
+ reactive({
469
+ scrollbarElement: scrollbarRef,
470
+ wrapElement: wrapRef
471
+ })
472
+ );
473
+ onActivated(() => {
474
+ if (wrapRef.value) {
475
+ wrapRef.value.scrollTop = wrapScrollTop;
476
+ wrapRef.value.scrollLeft = wrapScrollLeft;
477
+ }
478
+ });
479
+ onMounted(() => {
480
+ if (!props.native) {
481
+ nextTick(() => {
482
+ update();
483
+ });
484
+ }
485
+ });
486
+ onUpdated(() => update());
487
+ __expose({
488
+ /** @description scrollbar wrap ref */
489
+ wrapRef,
490
+ /** @description update scrollbar state manually */
491
+ update,
492
+ /** @description scrolls to a particular set of coordinates */
493
+ scrollTo,
494
+ /** @description set distance to scroll top */
495
+ setScrollTop,
496
+ /** @description set distance to scroll left */
497
+ setScrollLeft,
498
+ /** @description handle scroll event */
499
+ handleScroll
500
+ });
501
+ const __returned__ = { props, emit, COMPONENT_NAME, ns, get stopResizeObserver() {
502
+ return stopResizeObserver;
503
+ }, set stopResizeObserver(v) {
504
+ stopResizeObserver = v;
505
+ }, get stopWrapResizeObserver() {
506
+ return stopWrapResizeObserver;
507
+ }, set stopWrapResizeObserver(v) {
508
+ stopWrapResizeObserver = v;
509
+ }, get stopResizeListener() {
510
+ return stopResizeListener;
511
+ }, set stopResizeListener(v) {
512
+ stopResizeListener = v;
513
+ }, get wrapScrollTop() {
514
+ return wrapScrollTop;
515
+ }, set wrapScrollTop(v) {
516
+ wrapScrollTop = v;
517
+ }, get wrapScrollLeft() {
518
+ return wrapScrollLeft;
519
+ }, set wrapScrollLeft(v) {
520
+ wrapScrollLeft = v;
521
+ }, get direction() {
522
+ return direction;
523
+ }, set direction(v) {
524
+ direction = v;
525
+ }, distanceScrollState, scrollbarRef, wrapRef, resizeRef, barRef, wrapStyle, wrapKls, resizeKls, shouldSkipDirection, DIRECTION_PAIRS, updateTriggerStatus, handleScroll, scrollTo, setScrollTop, setScrollLeft, update, get VkAsyncTeleport() {
526
+ return VkAsyncTeleport;
527
+ }, Bar };
528
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
529
+ return __returned__;
530
+ }
531
+ });
532
+
533
+ const _hoisted_1 = ["tabindex"];
534
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
535
+ return openBlock(), createElementBlock(
536
+ "div",
537
+ {
538
+ ref: "scrollbarRef",
539
+ class: normalizeClass($setup.ns.b())
540
+ },
541
+ [
542
+ createElementVNode("div", {
543
+ ref: "wrapRef",
544
+ class: normalizeClass($setup.wrapKls),
545
+ style: normalizeStyle($setup.wrapStyle),
546
+ tabindex: _ctx.tabindex,
547
+ onScroll: $setup.handleScroll
548
+ }, [
549
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
550
+ id: _ctx.id,
551
+ ref: "resizeRef",
552
+ class: normalizeClass($setup.resizeKls),
553
+ style: normalizeStyle(_ctx.viewStyle),
554
+ role: _ctx.role,
555
+ "aria-label": _ctx.ariaLabel,
556
+ "aria-orientation": _ctx.ariaOrientation
557
+ }, {
558
+ default: withCtx(() => [
559
+ renderSlot(_ctx.$slots, "default")
560
+ ]),
561
+ _: 3
562
+ /* FORWARDED */
563
+ }, 8, ["id", "class", "style", "role", "aria-label", "aria-orientation"]))
564
+ ], 46, _hoisted_1),
565
+ !_ctx.native ? (openBlock(), createBlock($setup["VkAsyncTeleport"], {
566
+ key: 0,
567
+ disabled: !$props.appendTo,
568
+ to: $props.appendTo
569
+ }, {
570
+ default: withCtx(() => [
571
+ createVNode($setup["Bar"], {
572
+ ref: "barRef",
573
+ always: _ctx.always,
574
+ "min-size": _ctx.minSize
575
+ }, null, 8, ["always", "min-size"])
576
+ ]),
577
+ _: 1
578
+ /* STABLE */
579
+ }, 8, ["disabled", "to"])) : createCommentVNode("v-if", true)
580
+ ],
581
+ 2
582
+ /* CLASS */
583
+ );
584
+ }
585
+ var VkScrollbar = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/scrollbar/src/index.vue"]]);
586
+
587
+ var types = /*#__PURE__*/Object.freeze({
588
+ __proto__: null
589
+ });
590
+
591
+ VkScrollbar.install = (app) => {
592
+ app.component(VkScrollbar.name || "VkScrollbar", VkScrollbar);
593
+ };
594
+
595
+ export { VkScrollbar, types as __VkScrollbar, VkScrollbar as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/plus",
3
- "version": "1.7.5",
3
+ "version": "1.8.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -103,6 +103,10 @@
103
103
  "import": "./components/sender/index.mjs",
104
104
  "types": "./components/sender/index.d.ts"
105
105
  },
106
+ "./components/scrollbar": {
107
+ "import": "./components/scrollbar/index.mjs",
108
+ "types": "./components/scrollbar/index.d.ts"
109
+ },
106
110
  "./components/routes-menu-content": {
107
111
  "import": "./components/routes-menu-content/index.mjs",
108
112
  "types": "./components/routes-menu-content/index.d.ts"
@@ -1,8 +0,0 @@
1
- import VkAgentChatProvider from './src/index.vue';
2
- export * from './src/const';
3
- export * from './src/const-roles';
4
- export { type MessageView, MessageViewManager } from './src/MessageView';
5
- export * as __VkAgentChatProvider from './src/types';
6
- export { useAgentChat } from './src/use';
7
- export { VkAgentChatProvider, };
8
- export default VkAgentChatProvider;
@@ -1,29 +0,0 @@
1
- export interface MessageView {
2
- content: string;
3
- type: string;
4
- updating: boolean;
5
- }
6
- export declare class MessageViewManager {
7
- private views;
8
- getViews(): MessageView[];
9
- createView(view: MessageView): void;
10
- /**
11
- * @description 创建或更新最后一个 view
12
- */
13
- upsertView(data: MessageView, callbacks?: {
14
- onCreate?: (view: MessageView) => void;
15
- onUpdate?: (view: MessageView) => void;
16
- }): MessageView;
17
- /**
18
- * @description 获取当前view 的上一个 view
19
- */
20
- getPrevView(view: MessageView): MessageView | undefined;
21
- /**
22
- * @description 获取最后一个正在更新的 view
23
- */
24
- getLastUpdatingView(type: string): MessageView | undefined;
25
- /**
26
- * @description 所有 view 更新结束
27
- */
28
- allViewUpdated(): void;
29
- }
@@ -1,3 +0,0 @@
1
- import type { NormalObject } from '@vunk/shared';
2
- import type { RestFetchReaderOnmessage } from '@vunk/shared/fetch';
3
- export declare function agentRequest(onmessage: RestFetchReaderOnmessage, data: NormalObject): Promise<void>;
@@ -1,8 +0,0 @@
1
- import type { RoleMedia } from './types';
2
- export declare enum Role {
3
- User = "user",
4
- Assistant = "assistant",
5
- Broadcasting = "broadcasting"
6
- }
7
- export declare const roleOptions: RoleMedia[];
8
- export declare const roleMap: Record<Role, RoleMedia>;
@@ -1 +0,0 @@
1
- export declare const ChatAgentInjectKey = "vk_agent_chat_inject_key";
@@ -1,22 +0,0 @@
1
- import type { AnyFunc } from '@vunk/shared';
2
- import type { PropType } from 'vue';
3
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
- request: {
5
- type: PropType<AnyFunc>;
6
- };
7
- parser: {
8
- type: PropType<AnyFunc>;
9
- };
10
- }>, import("vue").Slot<any> | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
- load: null;
12
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
- request: {
14
- type: PropType<AnyFunc>;
15
- };
16
- parser: {
17
- type: PropType<AnyFunc>;
18
- };
19
- }>> & Readonly<{
20
- onLoad?: ((...args: any[]) => any) | undefined;
21
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
- export default _default;