@king-design/vue 3.6.2 → 3.8.0-beta.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/__tests__/__snapshots__/Vue Next Demos.md +399 -0
- package/components/anchor/constants.d.ts +2 -0
- package/components/anchor/constants.js +2 -0
- package/components/anchor/index.d.ts +41 -0
- package/components/anchor/index.js +141 -0
- package/components/anchor/index.spec.d.ts +1 -0
- package/components/anchor/index.spec.js +230 -0
- package/components/anchor/index.vdt.js +31 -0
- package/components/anchor/link.d.ts +16 -0
- package/components/anchor/link.js +52 -0
- package/components/anchor/link.vdt.js +49 -0
- package/components/anchor/styles.d.ts +5 -0
- package/components/anchor/styles.js +30 -0
- package/components/anchor/useScroll.d.ts +7 -0
- package/components/anchor/useScroll.js +218 -0
- package/components/bubble/bubble.d.ts +61 -0
- package/components/bubble/bubble.js +81 -0
- package/components/bubble/bubble.vdt.js +85 -0
- package/components/bubble/index.d.ts +1 -0
- package/components/bubble/index.js +1 -0
- package/components/bubble/index.spec.d.ts +1 -0
- package/components/bubble/index.spec.js +771 -0
- package/components/bubble/styles.d.ts +5 -0
- package/components/bubble/styles.js +53 -0
- package/components/bubble/useBubbleDisplay.d.ts +18 -0
- package/components/bubble/useBubbleDisplay.js +300 -0
- package/components/bubbleList/bubbleList.d.ts +87 -0
- package/components/bubbleList/bubbleList.js +75 -0
- package/components/bubbleList/bubbleList.vdt.js +143 -0
- package/components/bubbleList/index.d.ts +1 -0
- package/components/bubbleList/index.js +1 -0
- package/components/bubbleList/index.spec.d.ts +1 -0
- package/components/bubbleList/index.spec.js +1268 -0
- package/components/bubbleList/item.d.ts +16 -0
- package/components/bubbleList/item.js +27 -0
- package/components/bubbleList/item.vdt.js +36 -0
- package/components/bubbleList/styles.d.ts +5 -0
- package/components/bubbleList/styles.js +33 -0
- package/components/bubbleList/useBubbleList.d.ts +28 -0
- package/components/bubbleList/useBubbleList.js +455 -0
- package/components/checkbox/index.d.ts +3 -3
- package/components/dialog/base.vdt.js +1 -1
- package/components/drawer/index.d.ts +3 -0
- package/components/drawer/index.js +22 -3
- package/components/drawer/index.spec.js +83 -0
- package/components/drawer/index.vdt.js +23 -3
- package/components/drawer/styles.js +1 -1
- package/components/drawer/useDrawerResizable.d.ts +10 -0
- package/components/drawer/useDrawerResizable.js +162 -0
- package/components/fileCard/fileCard.d.ts +65 -0
- package/components/fileCard/fileCard.js +72 -0
- package/components/fileCard/fileCard.vdt.js +161 -0
- package/components/fileCard/fileCardAssets.d.ts +1 -0
- package/components/fileCard/fileCardAssets.js +54 -0
- package/components/fileCard/fileCardUtils.d.ts +14 -0
- package/components/fileCard/fileCardUtils.js +94 -0
- package/components/fileCard/index.d.ts +2 -0
- package/components/fileCard/index.js +2 -0
- package/components/fileCard/index.spec.d.ts +1 -0
- package/components/fileCard/index.spec.js +1096 -0
- package/components/fileCard/list.d.ts +29 -0
- package/components/fileCard/list.js +46 -0
- package/components/fileCard/list.vdt.js +71 -0
- package/components/fileCard/styles.d.ts +5 -0
- package/components/fileCard/styles.js +83 -0
- package/components/fileCard/useFileCard.d.ts +45 -0
- package/components/fileCard/useFileCard.js +330 -0
- package/components/fileCard/useFileCardList.d.ts +14 -0
- package/components/fileCard/useFileCardList.js +49 -0
- package/components/form/form.js +2 -1
- package/components/media/context.d.ts +6 -0
- package/components/media/context.js +2 -0
- package/components/media/group.d.ts +12 -0
- package/components/media/group.js +32 -0
- package/components/media/group.vdt.js +50 -0
- package/components/media/index.d.ts +2 -0
- package/components/media/index.js +2 -0
- package/components/media/index.spec.d.ts +1 -0
- package/components/media/index.spec.js +1691 -0
- package/components/media/media.d.ts +37 -0
- package/components/media/media.js +67 -0
- package/components/media/media.vdt.js +202 -0
- package/components/media/mediaAssets.d.ts +4 -0
- package/components/media/mediaAssets.js +9 -0
- package/components/media/mediaUtils.d.ts +6 -0
- package/components/media/mediaUtils.js +66 -0
- package/components/media/styles.d.ts +13 -0
- package/components/media/styles.js +52 -0
- package/components/media/types.d.ts +37 -0
- package/components/media/types.js +1 -0
- package/components/media/useMedia.d.ts +70 -0
- package/components/media/useMedia.js +471 -0
- package/components/media/useMediaGroup.d.ts +15 -0
- package/components/media/useMediaGroup.js +136 -0
- package/components/media/useMediaViewer.d.ts +14 -0
- package/components/media/useMediaViewer.js +129 -0
- package/components/media/viewer.d.ts +24 -0
- package/components/media/viewer.js +54 -0
- package/components/media/viewer.vdt.js +100 -0
- package/components/menu/styles.d.ts +1 -0
- package/components/menu/styles.js +4 -1
- package/components/notification/index.d.ts +1 -0
- package/components/notification/index.js +1 -0
- package/components/notification/index.spec.d.ts +1 -0
- package/components/notification/index.spec.js +317 -0
- package/components/notification/notification.d.ts +39 -0
- package/components/notification/notification.js +183 -0
- package/components/notification/notification.vdt.js +56 -0
- package/components/notification/notifications.d.ts +16 -0
- package/components/notification/notifications.js +51 -0
- package/components/notification/notifications.vdt.js +24 -0
- package/components/notification/styles.d.ts +9 -0
- package/components/notification/styles.js +110 -0
- package/components/radio/index.d.ts +3 -3
- package/components/select/styles.js +1 -1
- package/components/sender/icons.d.ts +3 -0
- package/components/sender/icons.js +17 -0
- package/components/sender/index.d.ts +1 -0
- package/components/sender/index.js +1 -0
- package/components/sender/index.spec.d.ts +1 -0
- package/components/sender/index.spec.js +1597 -0
- package/components/sender/sender.d.ts +104 -0
- package/components/sender/sender.js +111 -0
- package/components/sender/sender.vdt.js +230 -0
- package/components/sender/styles.d.ts +5 -0
- package/components/sender/styles.js +56 -0
- package/components/sender/useAutoResize.d.ts +4 -0
- package/components/sender/useAutoResize.js +99 -0
- package/components/sender/useSenderDrag.d.ts +6 -0
- package/components/sender/useSenderDrag.js +320 -0
- package/components/sender/useSenderInput.d.ts +16 -0
- package/components/sender/useSenderInput.js +101 -0
- package/components/sender/useSenderPaste.d.ts +5 -0
- package/components/sender/useSenderPaste.js +36 -0
- package/components/sender/useSenderUpload.d.ts +11 -0
- package/components/sender/useSenderUpload.js +395 -0
- package/components/skeleton/skeleton.d.ts +2 -1
- package/components/skeleton/skeleton.js +1 -1
- package/components/table/styles.js +1 -1
- package/components/tabs/useActiveBar.js +7 -3
- package/components/tag/base.d.ts +2 -0
- package/components/tag/base.js +3 -0
- package/components/tag/index.spec.js +17 -0
- package/components/tag/index.vdt.js +12 -5
- package/components/tag/styles.d.ts +9 -0
- package/components/tag/styles.js +14 -1
- package/components/tag/useColor.d.ts +7 -0
- package/components/tag/useColor.js +71 -0
- package/components/think/index.d.ts +1 -0
- package/components/think/index.js +1 -0
- package/components/think/index.spec.d.ts +1 -0
- package/components/think/index.spec.js +345 -0
- package/components/think/index.vdt.js +82 -0
- package/components/think/styles.d.ts +5 -0
- package/components/think/styles.js +25 -0
- package/components/think/think.d.ts +28 -0
- package/components/think/think.js +48 -0
- package/components/think/useThinkExpand.d.ts +10 -0
- package/components/think/useThinkExpand.js +56 -0
- package/components/timepicker/index.spec.js +70 -42
- package/components/timepicker/useDefaultValue.js +12 -7
- package/components/timepicker/useStep.js +4 -2
- package/components/transfer/index.d.ts +13 -0
- package/components/transfer/index.js +6 -2
- package/components/transfer/index.spec.js +197 -0
- package/components/transfer/index.vdt.js +28 -5
- package/components/transfer/styles.js +4 -1
- package/components/transfer/useCheck.js +2 -1
- package/components/transfer/usePagination.d.ts +12 -0
- package/components/transfer/usePagination.js +79 -0
- package/components/types.d.ts +4 -2
- package/components/upload/ajaxUploader.d.ts +1 -0
- package/components/upload/ajaxUploader.js +6 -0
- package/components/xmarkdown/index.d.ts +2 -0
- package/components/xmarkdown/index.js +1 -0
- package/components/xmarkdown/index.spec.d.ts +1 -0
- package/components/xmarkdown/index.spec.js +1666 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.d.ts +8 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.js +52 -0
- package/components/xmarkdown/markdown/codeblock.d.ts +8 -0
- package/components/xmarkdown/markdown/codeblock.js +74 -0
- package/components/xmarkdown/markdown/highlight.d.ts +17 -0
- package/components/xmarkdown/markdown/highlight.js +83 -0
- package/components/xmarkdown/markdown/index.d.ts +14 -0
- package/components/xmarkdown/markdown/index.js +14 -0
- package/components/xmarkdown/markdown/mermaid.d.ts +8 -0
- package/components/xmarkdown/markdown/mermaid.js +104 -0
- package/components/xmarkdown/markdown/renderTree.d.ts +54 -0
- package/components/xmarkdown/markdown/renderTree.js +386 -0
- package/components/xmarkdown/markdown/renderer.d.ts +18 -0
- package/components/xmarkdown/markdown/renderer.js +461 -0
- package/components/xmarkdown/markdown/streaming.d.ts +24 -0
- package/components/xmarkdown/markdown/streaming.js +513 -0
- package/components/xmarkdown/markdown/types.d.ts +124 -0
- package/components/xmarkdown/markdown/types.js +6 -0
- package/components/xmarkdown/markdown/utils.d.ts +7 -0
- package/components/xmarkdown/markdown/utils.js +9 -0
- package/components/xmarkdown/markdown.d.ts +1 -0
- package/components/xmarkdown/markdown.js +1 -0
- package/components/xmarkdown/styles.d.ts +5 -0
- package/components/xmarkdown/styles.js +50 -0
- package/components/xmarkdown/useMermaid.d.ts +27 -0
- package/components/xmarkdown/useMermaid.js +745 -0
- package/components/xmarkdown/useXMarkdownContent.d.ts +14 -0
- package/components/xmarkdown/useXMarkdownContent.js +218 -0
- package/components/xmarkdown/useXMarkdownDisplay.d.ts +26 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +569 -0
- package/components/xmarkdown/xmarkdown.d.ts +61 -0
- package/components/xmarkdown/xmarkdown.js +109 -0
- package/components/xmarkdown/xmarkdown.vdt.js +43 -0
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.svg +235 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/fonts/ionicons.woff2 +0 -0
- package/dist/i18n/en-US.js +1439 -0
- package/dist/i18n/en-US.js.map +1 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/i18n/index.js +283 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.min.js +1 -0
- package/dist/index.js +121177 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1569 -0
- package/dist/kpc.css +4 -0
- package/dist/ksyun.css +4 -0
- package/i18n/en-US.d.ts +27 -0
- package/i18n/en-US.js +29 -1
- package/index.d.ts +11 -2
- package/index.js +11 -2
- package/install.js +2 -0
- package/package.json +10 -2
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.svg +38 -0
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/global.js +12 -6
- package/styles/theme.d.ts +8 -0
- package/styles/theme.js +5 -1
- package/yarn-error.log +0 -1013
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
2
|
+
import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
|
|
3
|
+
import _Symbol from "@babel/runtime-corejs3/core-js/symbol";
|
|
4
|
+
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
import { useInstance } from 'intact-vue-next';
|
|
9
|
+
import { useState } from '../../hooks/useState';
|
|
10
|
+
export function useScroll() {
|
|
11
|
+
var instance = useInstance();
|
|
12
|
+
var isScrolling = useState(false);
|
|
13
|
+
var scrollTimer = null;
|
|
14
|
+
var rafId = null;
|
|
15
|
+
var scrollContainer = window;
|
|
16
|
+
// 回调函数,用于通知外部这是滚动触发的 value 变化
|
|
17
|
+
var setIsSettingFromScroll = null;
|
|
18
|
+
function getScrollContainer() {
|
|
19
|
+
var _instance$get = instance.get(),
|
|
20
|
+
container = _instance$get.container;
|
|
21
|
+
if (!container) {
|
|
22
|
+
return window;
|
|
23
|
+
}
|
|
24
|
+
if (typeof container === 'string') {
|
|
25
|
+
var el = document.querySelector(container);
|
|
26
|
+
return el || window;
|
|
27
|
+
}
|
|
28
|
+
return container;
|
|
29
|
+
}
|
|
30
|
+
// 获取当前滚动距离
|
|
31
|
+
function getScrollTop() {
|
|
32
|
+
if (scrollContainer === window) {
|
|
33
|
+
return window.scrollY || document.documentElement.scrollTop;
|
|
34
|
+
}
|
|
35
|
+
return scrollContainer.scrollTop;
|
|
36
|
+
}
|
|
37
|
+
// 获取滚动容器的高度
|
|
38
|
+
function getScrollHeight() {
|
|
39
|
+
if (scrollContainer === window) {
|
|
40
|
+
return document.documentElement.scrollHeight;
|
|
41
|
+
}
|
|
42
|
+
return scrollContainer.scrollHeight;
|
|
43
|
+
}
|
|
44
|
+
// 获取视口高度
|
|
45
|
+
function getViewportHeight() {
|
|
46
|
+
if (scrollContainer === window) {
|
|
47
|
+
return window.innerHeight;
|
|
48
|
+
}
|
|
49
|
+
return scrollContainer.clientHeight;
|
|
50
|
+
}
|
|
51
|
+
function getElementTop(element, container) {
|
|
52
|
+
if (container === window) {
|
|
53
|
+
// window: 累加 offsetTop
|
|
54
|
+
var offsetTop = 0;
|
|
55
|
+
var currentElement = element;
|
|
56
|
+
while (currentElement && currentElement !== document.body) {
|
|
57
|
+
offsetTop += currentElement.offsetTop;
|
|
58
|
+
currentElement = currentElement.offsetParent;
|
|
59
|
+
}
|
|
60
|
+
return offsetTop;
|
|
61
|
+
}
|
|
62
|
+
// 自定义容器: 使用 getBoundingClientRect
|
|
63
|
+
var containerEl = container;
|
|
64
|
+
var elementRect = element.getBoundingClientRect();
|
|
65
|
+
var containerRect = containerEl.getBoundingClientRect();
|
|
66
|
+
// 元素相对于容器内容区的位置 =
|
|
67
|
+
// (元素到视口顶部的距离 - 容器到视口顶部的距离) + 容器已滚动的距离
|
|
68
|
+
return elementRect.top - containerRect.top + containerEl.scrollTop;
|
|
69
|
+
}
|
|
70
|
+
function scrollTo(target) {
|
|
71
|
+
var _instance$get2 = instance.get(),
|
|
72
|
+
_instance$get2$offset = _instance$get2.offset,
|
|
73
|
+
offset = _instance$get2$offset === void 0 ? 0 : _instance$get2$offset,
|
|
74
|
+
_instance$get2$durati = _instance$get2.duration,
|
|
75
|
+
duration = _instance$get2$durati === void 0 ? 700 : _instance$get2$durati;
|
|
76
|
+
// 目标位置
|
|
77
|
+
var targetTop = getElementTop(target, scrollContainer) - offset;
|
|
78
|
+
// 当前位置
|
|
79
|
+
var currentTop = getScrollTop();
|
|
80
|
+
if (Math.abs(currentTop - targetTop) < 1) return;
|
|
81
|
+
if (scrollTimer) {
|
|
82
|
+
clearTimeout(scrollTimer);
|
|
83
|
+
}
|
|
84
|
+
isScrolling.set(true);
|
|
85
|
+
if (scrollContainer === window) {
|
|
86
|
+
window.scrollTo({
|
|
87
|
+
top: targetTop,
|
|
88
|
+
behavior: 'smooth'
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
scrollContainer.scrollTo({
|
|
92
|
+
top: targetTop,
|
|
93
|
+
behavior: 'smooth'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
scrollTimer = window.setTimeout(function () {
|
|
97
|
+
isScrolling.set(false);
|
|
98
|
+
}, duration);
|
|
99
|
+
}
|
|
100
|
+
// 滚动触发的 value 更新
|
|
101
|
+
function setValueFromScroll(href) {
|
|
102
|
+
if (setIsSettingFromScroll) {
|
|
103
|
+
setIsSettingFromScroll(true);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
instance.set('value', href);
|
|
107
|
+
} finally {
|
|
108
|
+
if (setIsSettingFromScroll) {
|
|
109
|
+
setIsSettingFromScroll(false);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// 更新当前激活的锚点
|
|
114
|
+
function updateActive() {
|
|
115
|
+
if (isScrolling.value) return;
|
|
116
|
+
var _instance$get3 = instance.get(),
|
|
117
|
+
_instance$get3$offset = _instance$get3.offset,
|
|
118
|
+
offset = _instance$get3$offset === void 0 ? 0 : _instance$get3$offset,
|
|
119
|
+
_instance$get3$thresh = _instance$get3.threshold,
|
|
120
|
+
threshold = _instance$get3$thresh === void 0 ? 50 : _instance$get3$thresh;
|
|
121
|
+
var links = instance.getLinks();
|
|
122
|
+
// 只处理当前存在且可见的锚点
|
|
123
|
+
var candidates = [];
|
|
124
|
+
for (var _iterator = _createForOfIteratorHelperLoose(links), _step; !(_step = _iterator()).done;) {
|
|
125
|
+
var _href = _step.value;
|
|
126
|
+
var _element = instance.getTargetElement(_href);
|
|
127
|
+
if (_element && _element.getClientRects().length > 0) {
|
|
128
|
+
candidates.push({
|
|
129
|
+
href: _href,
|
|
130
|
+
element: _element
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (candidates.length === 0) return;
|
|
135
|
+
var scrollTop = getScrollTop();
|
|
136
|
+
var viewportHeight = getViewportHeight();
|
|
137
|
+
var totalHeight = getScrollHeight();
|
|
138
|
+
var activeHref = candidates[0].href;
|
|
139
|
+
if (scrollTop + viewportHeight >= totalHeight - 10) {
|
|
140
|
+
// 接近底部,激活最后一个可见锚点
|
|
141
|
+
activeHref = candidates[candidates.length - 1].href;
|
|
142
|
+
} else if (scrollTop <= threshold) {
|
|
143
|
+
// 接近顶部,激活第一个可见锚点
|
|
144
|
+
activeHref = candidates[0].href;
|
|
145
|
+
} else {
|
|
146
|
+
// 正常滚动,寻找最后一个被“滚到”的锚点
|
|
147
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(candidates), _step2; !(_step2 = _iterator2()).done;) {
|
|
148
|
+
var _step2$value = _step2.value,
|
|
149
|
+
href = _step2$value.href,
|
|
150
|
+
element = _step2$value.element;
|
|
151
|
+
var sectionTop = getElementTop(element, scrollContainer) - offset - threshold;
|
|
152
|
+
if (scrollTop >= sectionTop) {
|
|
153
|
+
activeHref = href;
|
|
154
|
+
} else {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (activeHref !== instance.get('value')) {
|
|
160
|
+
setValueFromScroll(activeHref);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// 滚动事件处理
|
|
164
|
+
function onScroll() {
|
|
165
|
+
if (isScrolling.value) return;
|
|
166
|
+
if (rafId) {
|
|
167
|
+
cancelAnimationFrame(rafId);
|
|
168
|
+
}
|
|
169
|
+
// 使用 requestAnimationFrame 优化滚动性能
|
|
170
|
+
rafId = requestAnimationFrame(updateActive);
|
|
171
|
+
}
|
|
172
|
+
// 挂载后的初始化
|
|
173
|
+
function init() {
|
|
174
|
+
setTimeout(function () {
|
|
175
|
+
scrollContainer = getScrollContainer();
|
|
176
|
+
if (scrollContainer === window) {
|
|
177
|
+
window.addEventListener('scroll', onScroll, {
|
|
178
|
+
passive: true
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
scrollContainer.addEventListener('scroll', onScroll, {
|
|
182
|
+
passive: true
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
var initialValue = instance.get('value');
|
|
186
|
+
if (initialValue) {
|
|
187
|
+
var element = instance.getTargetElement(initialValue);
|
|
188
|
+
if (element) {
|
|
189
|
+
scrollTo(element);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, 100);
|
|
194
|
+
return function () {
|
|
195
|
+
if (scrollTimer) {
|
|
196
|
+
clearTimeout(scrollTimer);
|
|
197
|
+
}
|
|
198
|
+
if (rafId) {
|
|
199
|
+
cancelAnimationFrame(rafId);
|
|
200
|
+
}
|
|
201
|
+
var currentContainer = scrollContainer;
|
|
202
|
+
if (currentContainer === window) {
|
|
203
|
+
window.removeEventListener('scroll', onScroll);
|
|
204
|
+
} else {
|
|
205
|
+
currentContainer.removeEventListener('scroll', onScroll);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
scrollTo: scrollTo,
|
|
211
|
+
updateActive: updateActive,
|
|
212
|
+
init: init,
|
|
213
|
+
isScrolling: isScrolling,
|
|
214
|
+
set setIsSettingFromScroll(fn) {
|
|
215
|
+
setIsSettingFromScroll = fn;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Component, TypeDefs } from 'intact-vue-next';
|
|
2
|
+
import type { Events } from '../types';
|
|
3
|
+
export interface BubbleTyping {
|
|
4
|
+
interval?: number;
|
|
5
|
+
step?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface BubbleRenderSlots {
|
|
8
|
+
avatar?: Function;
|
|
9
|
+
roleName?: Function;
|
|
10
|
+
beforeContent?: Function;
|
|
11
|
+
attachments?: Function;
|
|
12
|
+
content?: Function;
|
|
13
|
+
bottom?: Function;
|
|
14
|
+
footer?: Function;
|
|
15
|
+
loading?: Function;
|
|
16
|
+
extra?: Function;
|
|
17
|
+
}
|
|
18
|
+
export type BubbleRenderSlotName = keyof BubbleRenderSlots;
|
|
19
|
+
export interface BubbleProps {
|
|
20
|
+
content?: string | number;
|
|
21
|
+
placement?: 'start' | 'middle' | 'end';
|
|
22
|
+
avatar?: string | boolean;
|
|
23
|
+
roleName?: string;
|
|
24
|
+
loading?: boolean;
|
|
25
|
+
streaming?: boolean;
|
|
26
|
+
variant?: 'filled' | 'outlined' | 'plain';
|
|
27
|
+
shape?: 'round' | 'square' | 'corner';
|
|
28
|
+
maxWidthString?: string;
|
|
29
|
+
typing?: boolean | BubbleTyping;
|
|
30
|
+
}
|
|
31
|
+
interface BubbleInternalProps extends BubbleProps {
|
|
32
|
+
slotRenderers?: BubbleRenderSlots;
|
|
33
|
+
}
|
|
34
|
+
export interface BubbleEvents {
|
|
35
|
+
typing: [string, string];
|
|
36
|
+
typingComplete: [string];
|
|
37
|
+
}
|
|
38
|
+
export interface BubbleBlocks {
|
|
39
|
+
avatar: null;
|
|
40
|
+
roleName: null;
|
|
41
|
+
beforeContent: null;
|
|
42
|
+
attachments: null;
|
|
43
|
+
content: null;
|
|
44
|
+
bottom: null;
|
|
45
|
+
footer: null;
|
|
46
|
+
loading: null;
|
|
47
|
+
extra: null;
|
|
48
|
+
}
|
|
49
|
+
export declare class Bubble extends Component<BubbleInternalProps, BubbleEvents, BubbleBlocks> {
|
|
50
|
+
static template: string | import('intact-vue-next').Template<any>;
|
|
51
|
+
static typeDefs: Required<TypeDefs<BubbleInternalProps>>;
|
|
52
|
+
static defaults: () => Partial<BubbleProps>;
|
|
53
|
+
static events: Events<BubbleEvents>;
|
|
54
|
+
private config;
|
|
55
|
+
private display;
|
|
56
|
+
private getSlotRenderer;
|
|
57
|
+
private getSlotRenderers;
|
|
58
|
+
mounted(): void;
|
|
59
|
+
beforeUnmount(): void;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
4
|
+
import { Component } from 'intact-vue-next';
|
|
5
|
+
import template from './bubble.vdt';
|
|
6
|
+
import { useConfigContext } from '../config';
|
|
7
|
+
import { useBubbleDisplay } from './useBubbleDisplay';
|
|
8
|
+
var BUBBLE_RENDER_SLOT_NAMES = ['avatar', 'roleName', 'beforeContent', 'attachments', 'content', 'bottom', 'footer', 'loading', 'extra'];
|
|
9
|
+
var typeDefs = {
|
|
10
|
+
content: [String, Number],
|
|
11
|
+
placement: ['start', 'middle', 'end'],
|
|
12
|
+
avatar: [Boolean, String],
|
|
13
|
+
roleName: String,
|
|
14
|
+
loading: Boolean,
|
|
15
|
+
streaming: Boolean,
|
|
16
|
+
variant: ['filled', 'outlined', 'plain'],
|
|
17
|
+
shape: ['round', 'square', 'corner'],
|
|
18
|
+
maxWidthString: String,
|
|
19
|
+
typing: [Boolean, Object]
|
|
20
|
+
};
|
|
21
|
+
var internalTypeDefs = _extends({}, typeDefs, {
|
|
22
|
+
slotRenderers: Object
|
|
23
|
+
});
|
|
24
|
+
var defaults = function defaults() {
|
|
25
|
+
return {
|
|
26
|
+
placement: 'start',
|
|
27
|
+
avatar: false,
|
|
28
|
+
roleName: undefined,
|
|
29
|
+
loading: false,
|
|
30
|
+
streaming: false,
|
|
31
|
+
variant: 'filled',
|
|
32
|
+
shape: 'square',
|
|
33
|
+
maxWidthString: '640px',
|
|
34
|
+
typing: false
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var events = {
|
|
38
|
+
typing: true,
|
|
39
|
+
typingComplete: true
|
|
40
|
+
};
|
|
41
|
+
export var Bubble = /*#__PURE__*/function (_Component) {
|
|
42
|
+
_inheritsLoose(Bubble, _Component);
|
|
43
|
+
function Bubble() {
|
|
44
|
+
var _context;
|
|
45
|
+
var _this;
|
|
46
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
|
+
args[_key] = arguments[_key];
|
|
48
|
+
}
|
|
49
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
50
|
+
_this.config = useConfigContext();
|
|
51
|
+
_this.display = useBubbleDisplay();
|
|
52
|
+
return _this;
|
|
53
|
+
}
|
|
54
|
+
var _proto = Bubble.prototype;
|
|
55
|
+
// React/Vue 包装层通过 slotRenderers 传入插槽,Intact 原生插槽仍走 $blocks。
|
|
56
|
+
_proto.getSlotRenderer = function getSlotRenderer(name) {
|
|
57
|
+
var slotRenderers = this.get('slotRenderers');
|
|
58
|
+
return slotRenderers && slotRenderers[name] ? slotRenderers[name] : undefined;
|
|
59
|
+
};
|
|
60
|
+
_proto.getSlotRenderers = function getSlotRenderers() {
|
|
61
|
+
var _this2 = this;
|
|
62
|
+
return BUBBLE_RENDER_SLOT_NAMES.reduce(function (slotRenderers, name) {
|
|
63
|
+
var renderer = _this2.getSlotRenderer(name);
|
|
64
|
+
if (renderer) {
|
|
65
|
+
slotRenderers[name] = renderer;
|
|
66
|
+
}
|
|
67
|
+
return slotRenderers;
|
|
68
|
+
}, {});
|
|
69
|
+
};
|
|
70
|
+
_proto.mounted = function mounted() {
|
|
71
|
+
this.display.onMounted();
|
|
72
|
+
};
|
|
73
|
+
_proto.beforeUnmount = function beforeUnmount() {
|
|
74
|
+
this.display.onBeforeUnmount();
|
|
75
|
+
};
|
|
76
|
+
return Bubble;
|
|
77
|
+
}(Component);
|
|
78
|
+
Bubble.template = template;
|
|
79
|
+
Bubble.typeDefs = internalTypeDefs;
|
|
80
|
+
Bubble.defaults = defaults;
|
|
81
|
+
Bubble.events = events;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { createVNode as _$cv, className as _$cn, createElementVNode as _$ce, createUnknownComponentVNode as _$cc } from 'intact-vue-next';
|
|
3
|
+
import { Icon } from '../icon';
|
|
4
|
+
import { isInvalid } from 'intact-shared';
|
|
5
|
+
import { getRestProps, isEmptyString } from '../utils';
|
|
6
|
+
import { makeStyles } from './styles';
|
|
7
|
+
var _$tmp0 = {
|
|
8
|
+
'className': 'ion-person'
|
|
9
|
+
};
|
|
10
|
+
export default function ($props, $blocks, $__proto__) {
|
|
11
|
+
var _classNameObj;
|
|
12
|
+
$blocks || ($blocks = {});
|
|
13
|
+
$props || ($props = {});
|
|
14
|
+
var $this = this;
|
|
15
|
+
var _this$display = this.display,
|
|
16
|
+
shouldShowLoadingShell = _this$display.shouldShowLoadingShell,
|
|
17
|
+
shouldShowAvatar = _this$display.shouldShowAvatar,
|
|
18
|
+
hasRoleName = _this$display.hasRoleName,
|
|
19
|
+
shouldShowContentBlock = _this$display.shouldShowContentBlock,
|
|
20
|
+
getBubbleStyle = _this$display.getBubbleStyle,
|
|
21
|
+
getRoleNameText = _this$display.getRoleNameText,
|
|
22
|
+
getAvatarText = _this$display.getAvatarText,
|
|
23
|
+
hasNonEmptyContentProp = _this$display.hasNonEmptyContentProp,
|
|
24
|
+
getDisplayedContent = _this$display.getDisplayedContent;
|
|
25
|
+
var _this$get = this.get(),
|
|
26
|
+
className = _this$get.className,
|
|
27
|
+
placement = _this$get.placement,
|
|
28
|
+
avatar = _this$get.avatar,
|
|
29
|
+
variant = _this$get.variant,
|
|
30
|
+
shape = _this$get.shape,
|
|
31
|
+
children = _this$get.children;
|
|
32
|
+
var k = this.config.k;
|
|
33
|
+
var showLoadingShell = shouldShowLoadingShell();
|
|
34
|
+
var slotRenderers = this.getSlotRenderers();
|
|
35
|
+
var renderSlot = function renderSlot(name) {
|
|
36
|
+
if (slotRenderers[name]) return slotRenderers[name]();
|
|
37
|
+
if ($blocks[name]) return $blocks[name](function () {
|
|
38
|
+
return undefined;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var isEmptySlot = function isEmptySlot(value) {
|
|
42
|
+
if (isInvalid(value) || isEmptyString(value)) return true;
|
|
43
|
+
if (Array.isArray(value)) return value.every(function (item) {
|
|
44
|
+
return isEmptySlot(item);
|
|
45
|
+
});
|
|
46
|
+
if (value.type === 1) return isEmptySlot(value.children);
|
|
47
|
+
return false;
|
|
48
|
+
};
|
|
49
|
+
var avatarSlot = renderSlot('avatar');
|
|
50
|
+
var roleNameSlot = renderSlot('roleName');
|
|
51
|
+
var beforeContentSlot = renderSlot('beforeContent');
|
|
52
|
+
var attachmentsSlot = renderSlot('attachments');
|
|
53
|
+
var contentSlot = showLoadingShell ? undefined : renderSlot('content');
|
|
54
|
+
var bottomSlot = renderSlot('bottom');
|
|
55
|
+
var footerSlot = renderSlot('footer');
|
|
56
|
+
var loadingSlot = showLoadingShell ? renderSlot('loading') : undefined;
|
|
57
|
+
var extraSlot = renderSlot('extra');
|
|
58
|
+
var hasAvatarSlot = !isEmptySlot(avatarSlot);
|
|
59
|
+
var hasRoleNameSlot = !isEmptySlot(roleNameSlot);
|
|
60
|
+
var hasBeforeContentSlot = !isEmptySlot(beforeContentSlot);
|
|
61
|
+
var hasAttachmentsSlot = !isEmptySlot(attachmentsSlot);
|
|
62
|
+
var hasContentSlot = !isEmptySlot(contentSlot);
|
|
63
|
+
var hasBottomSlot = !isEmptySlot(bottomSlot);
|
|
64
|
+
var hasFooterSlot = !isEmptySlot(footerSlot);
|
|
65
|
+
var hasLoadingSlot = !isEmptySlot(loadingSlot);
|
|
66
|
+
var hasExtraSlot = !isEmptySlot(extraSlot);
|
|
67
|
+
var showAvatar = hasAvatarSlot || shouldShowAvatar();
|
|
68
|
+
var showHeader = hasRoleNameSlot || hasRoleName();
|
|
69
|
+
var showBeforeContent = hasBeforeContentSlot;
|
|
70
|
+
var showAttachments = hasAttachmentsSlot;
|
|
71
|
+
var showContent = showAttachments || hasContentSlot || !!children || shouldShowContentBlock();
|
|
72
|
+
var showFooter = hasFooterSlot;
|
|
73
|
+
var showBubble = showBeforeContent || showContent || showFooter;
|
|
74
|
+
var showMeta = (showBeforeContent || showContent) && (showAvatar || showHeader);
|
|
75
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-bubble"] = true, _classNameObj[k + "-bubble-" + placement] = true, _classNameObj[k + "-bubble-" + variant] = true, _classNameObj[k + "-bubble-" + shape] = true, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
76
|
+
return showBubble ? _$cv('div', _extends({
|
|
77
|
+
'className': _$cn(classNameObj)
|
|
78
|
+
}, getRestProps(this)), _$ce(2, 'div', [showMeta ? _$ce(2, 'div', [showAvatar ? _$ce(2, 'div', hasAvatarSlot ? avatarSlot : typeof avatar === 'string' && avatar ? _$ce(2, 'img', null, 1, _$cn(k + "-bubble-avatar-image"), {
|
|
79
|
+
'src': avatar,
|
|
80
|
+
'alt': getRoleNameText() || 'avatar'
|
|
81
|
+
}) : getAvatarText() ? _$ce(2, 'span', getAvatarText(), 0) : _$cc(Icon, _$tmp0), 0, _$cn(k + "-bubble-avatar")) : undefined, showHeader ? _$ce(2, 'div', hasRoleNameSlot ? roleNameSlot : _$ce(2, 'span', getRoleNameText(), 0), 0, _$cn(k + "-bubble-header")) : undefined], 0, _$cn(k + "-bubble-meta")) : undefined, showBeforeContent ? _$ce(2, 'div', beforeContentSlot, 0, _$cn(k + "-bubble-before-content")) : undefined, showContent ? _$ce(2, 'div', [showAttachments ? _$ce(2, 'div', attachmentsSlot, 0, _$cn(k + "-bubble-attachments")) : undefined, showLoadingShell ? hasLoadingSlot ? loadingSlot : _$ce(2, 'div', [_$ce(2, 'span', null, 1, _$cn(k + "-bubble-loading-dot")), _$ce(2, 'span', null, 1, _$cn(k + "-bubble-loading-dot")), _$ce(2, 'span', null, 1, _$cn(k + "-bubble-loading-dot"))], 4, _$cn(k + "-bubble-loading")) : hasContentSlot ? contentSlot : children ? children : hasNonEmptyContentProp() || getDisplayedContent() ? _$ce(2, 'div', getDisplayedContent(), 0, _$cn(k + "-bubble-text")) : undefined, hasBottomSlot ? _$ce(2, 'div', bottomSlot, 0, _$cn(k + "-bubble-bottom")) : undefined], 0, _$cn(k + "-bubble-content")) : undefined, showFooter ? _$ce(2, 'div', footerSlot, 0, _$cn(k + "-bubble-footer")) : undefined, hasExtraSlot ? _$ce(2, 'div', extraSlot, 0, _$cn(k + "-bubble-extra")) : undefined], 0, _$cn(k + "-bubble-main"), {
|
|
82
|
+
'style': getBubbleStyle()
|
|
83
|
+
})) : undefined;
|
|
84
|
+
}
|
|
85
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bubble';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bubble';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|