@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,129 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, useInstance } from 'intact-vue-next';
|
|
2
|
+
import { useFixBody } from '../../hooks/useFixBody';
|
|
3
|
+
import { mediaAudioCardUrl } from './mediaAssets';
|
|
4
|
+
export function useMediaViewer() {
|
|
5
|
+
var instance = useInstance();
|
|
6
|
+
var fixBody = useFixBody();
|
|
7
|
+
var isListening = false;
|
|
8
|
+
function close() {
|
|
9
|
+
var onClose = instance.get('onClose');
|
|
10
|
+
if (onClose) onClose();
|
|
11
|
+
}
|
|
12
|
+
function prev() {
|
|
13
|
+
var onPrev = instance.get('onPrev');
|
|
14
|
+
if (onPrev && instance.get('hasPrev')) onPrev();
|
|
15
|
+
}
|
|
16
|
+
function next() {
|
|
17
|
+
var onNext = instance.get('onNext');
|
|
18
|
+
if (onNext && instance.get('hasNext')) onNext();
|
|
19
|
+
}
|
|
20
|
+
// 预览层支持 Esc 关闭和左右方向键切换。
|
|
21
|
+
function onKeydown(e) {
|
|
22
|
+
switch (e.keyCode) {
|
|
23
|
+
case 27:
|
|
24
|
+
close();
|
|
25
|
+
break;
|
|
26
|
+
case 37:
|
|
27
|
+
prev();
|
|
28
|
+
break;
|
|
29
|
+
case 39:
|
|
30
|
+
next();
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// 避免重复绑定全局键盘事件。
|
|
35
|
+
function addKeydownListener() {
|
|
36
|
+
if (isListening) return;
|
|
37
|
+
document.addEventListener('keydown', onKeydown);
|
|
38
|
+
isListening = true;
|
|
39
|
+
}
|
|
40
|
+
// Viewer 不可见或卸载时及时移除全局监听。
|
|
41
|
+
function removeKeydownListener() {
|
|
42
|
+
if (!isListening) return;
|
|
43
|
+
document.removeEventListener('keydown', onKeydown);
|
|
44
|
+
isListening = false;
|
|
45
|
+
}
|
|
46
|
+
onMounted(function () {
|
|
47
|
+
if (instance.get('value')) {
|
|
48
|
+
fixBody.onOpen();
|
|
49
|
+
addKeydownListener();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
onUnmounted(function () {
|
|
53
|
+
removeKeydownListener();
|
|
54
|
+
fixBody.onClose();
|
|
55
|
+
});
|
|
56
|
+
instance.watch('value', function (value) {
|
|
57
|
+
if (value) {
|
|
58
|
+
fixBody.onOpen();
|
|
59
|
+
addKeydownListener();
|
|
60
|
+
} else {
|
|
61
|
+
removeKeydownListener();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
// 点击遮罩关闭,内容区域在模板中会阻止冒泡。
|
|
65
|
+
function onMaskClick() {
|
|
66
|
+
close();
|
|
67
|
+
}
|
|
68
|
+
function onCloseClick(e) {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
close();
|
|
71
|
+
}
|
|
72
|
+
function onPrevClick(e) {
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
prev();
|
|
75
|
+
}
|
|
76
|
+
function onNextClick(e) {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
next();
|
|
79
|
+
}
|
|
80
|
+
function isImage() {
|
|
81
|
+
var _instance$get;
|
|
82
|
+
return ((_instance$get = instance.get('item')) == null ? void 0 : _instance$get.resolvedType) === 'image';
|
|
83
|
+
}
|
|
84
|
+
function isVideo() {
|
|
85
|
+
var _instance$get2;
|
|
86
|
+
return ((_instance$get2 = instance.get('item')) == null ? void 0 : _instance$get2.resolvedType) === 'video';
|
|
87
|
+
}
|
|
88
|
+
function isAudio() {
|
|
89
|
+
var _instance$get3;
|
|
90
|
+
return ((_instance$get3 = instance.get('item')) == null ? void 0 : _instance$get3.resolvedType) === 'audio';
|
|
91
|
+
}
|
|
92
|
+
function getTitle() {
|
|
93
|
+
var _instance$get4;
|
|
94
|
+
return ((_instance$get4 = instance.get('item')) == null ? void 0 : _instance$get4.name) || '';
|
|
95
|
+
}
|
|
96
|
+
function getCounterText() {
|
|
97
|
+
var total = instance.get('total') || 0;
|
|
98
|
+
if (total <= 1) return '';
|
|
99
|
+
return (instance.get('index') || 0) + 1 + " / " + total;
|
|
100
|
+
}
|
|
101
|
+
function shouldShowNavigation() {
|
|
102
|
+
return (instance.get('total') || 0) > 1;
|
|
103
|
+
}
|
|
104
|
+
function getAudioCardAssetSrc() {
|
|
105
|
+
return mediaAudioCardUrl;
|
|
106
|
+
}
|
|
107
|
+
// 离场动画完成后释放滚动锁并通知外层卸载。
|
|
108
|
+
function onAfterLeave() {
|
|
109
|
+
if (!instance.get('value')) {
|
|
110
|
+
fixBody.onClose();
|
|
111
|
+
}
|
|
112
|
+
var onAfterClose = instance.get('onAfterClose');
|
|
113
|
+
if (onAfterClose) onAfterClose();
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
onMaskClick: onMaskClick,
|
|
117
|
+
onCloseClick: onCloseClick,
|
|
118
|
+
onPrevClick: onPrevClick,
|
|
119
|
+
onNextClick: onNextClick,
|
|
120
|
+
onAfterLeave: onAfterLeave,
|
|
121
|
+
isImage: isImage,
|
|
122
|
+
isVideo: isVideo,
|
|
123
|
+
isAudio: isAudio,
|
|
124
|
+
getTitle: getTitle,
|
|
125
|
+
getCounterText: getCounterText,
|
|
126
|
+
shouldShowNavigation: shouldShowNavigation,
|
|
127
|
+
getAudioCardAssetSrc: getAudioCardAssetSrc
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component, TypeDefs } from 'intact-vue-next';
|
|
2
|
+
import type { Container } from '../portal';
|
|
3
|
+
import type { MediaViewerItem } from './types';
|
|
4
|
+
export interface MediaViewerProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
value?: boolean;
|
|
7
|
+
item?: MediaViewerItem | null;
|
|
8
|
+
index?: number;
|
|
9
|
+
total?: number;
|
|
10
|
+
hasPrev?: boolean;
|
|
11
|
+
hasNext?: boolean;
|
|
12
|
+
container?: Container;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
onAfterClose?: () => void;
|
|
15
|
+
onPrev?: () => void;
|
|
16
|
+
onNext?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class MediaViewer extends Component<MediaViewerProps> {
|
|
19
|
+
static template: string | import('intact-vue-next').Template<any>;
|
|
20
|
+
static typeDefs: Required<TypeDefs<MediaViewerProps>>;
|
|
21
|
+
static defaults: () => Partial<MediaViewerProps>;
|
|
22
|
+
private config;
|
|
23
|
+
private viewer;
|
|
24
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { Component } from 'intact-vue-next';
|
|
4
|
+
import template from './viewer.vdt';
|
|
5
|
+
import { useConfigContext } from '../config';
|
|
6
|
+
import { useMediaViewer } from './useMediaViewer';
|
|
7
|
+
var typeDefs = {
|
|
8
|
+
className: String,
|
|
9
|
+
value: Boolean,
|
|
10
|
+
item: Object,
|
|
11
|
+
index: Number,
|
|
12
|
+
total: Number,
|
|
13
|
+
hasPrev: Boolean,
|
|
14
|
+
hasNext: Boolean,
|
|
15
|
+
container: [String, Function],
|
|
16
|
+
onClose: Function,
|
|
17
|
+
onAfterClose: Function,
|
|
18
|
+
onPrev: Function,
|
|
19
|
+
onNext: Function
|
|
20
|
+
};
|
|
21
|
+
var defaults = function defaults() {
|
|
22
|
+
return {
|
|
23
|
+
className: undefined,
|
|
24
|
+
value: false,
|
|
25
|
+
item: null,
|
|
26
|
+
index: 0,
|
|
27
|
+
total: 0,
|
|
28
|
+
hasPrev: false,
|
|
29
|
+
hasNext: false,
|
|
30
|
+
container: undefined,
|
|
31
|
+
onClose: undefined,
|
|
32
|
+
onAfterClose: undefined,
|
|
33
|
+
onPrev: undefined,
|
|
34
|
+
onNext: undefined
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export var MediaViewer = /*#__PURE__*/function (_Component) {
|
|
38
|
+
_inheritsLoose(MediaViewer, _Component);
|
|
39
|
+
function MediaViewer() {
|
|
40
|
+
var _context;
|
|
41
|
+
var _this;
|
|
42
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
|
+
args[_key] = arguments[_key];
|
|
44
|
+
}
|
|
45
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
46
|
+
_this.config = useConfigContext();
|
|
47
|
+
_this.viewer = useMediaViewer();
|
|
48
|
+
return _this;
|
|
49
|
+
}
|
|
50
|
+
return MediaViewer;
|
|
51
|
+
}(Component);
|
|
52
|
+
MediaViewer.template = template;
|
|
53
|
+
MediaViewer.typeDefs = typeDefs;
|
|
54
|
+
MediaViewer.defaults = defaults;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createUnknownComponentVNode as _$cc, createElementVNode as _$ce, className as _$cn } from 'intact-vue-next';
|
|
2
|
+
import { Portal } from '../portal';
|
|
3
|
+
import { Icon } from '../icon';
|
|
4
|
+
import { Transition } from 'intact-vue-next';
|
|
5
|
+
import { stopPropagation } from '../utils';
|
|
6
|
+
export default function ($props, $blocks, $__proto__) {
|
|
7
|
+
var _$cn2;
|
|
8
|
+
$blocks || ($blocks = {});
|
|
9
|
+
$props || ($props = {});
|
|
10
|
+
var $this = this;
|
|
11
|
+
var _this$viewer = this.viewer,
|
|
12
|
+
onMaskClick = _this$viewer.onMaskClick,
|
|
13
|
+
onCloseClick = _this$viewer.onCloseClick,
|
|
14
|
+
onPrevClick = _this$viewer.onPrevClick,
|
|
15
|
+
onNextClick = _this$viewer.onNextClick,
|
|
16
|
+
onAfterLeave = _this$viewer.onAfterLeave,
|
|
17
|
+
isImage = _this$viewer.isImage,
|
|
18
|
+
isVideo = _this$viewer.isVideo,
|
|
19
|
+
isAudio = _this$viewer.isAudio,
|
|
20
|
+
getTitle = _this$viewer.getTitle,
|
|
21
|
+
getCounterText = _this$viewer.getCounterText,
|
|
22
|
+
shouldShowNavigation = _this$viewer.shouldShowNavigation,
|
|
23
|
+
getAudioCardAssetSrc = _this$viewer.getAudioCardAssetSrc;
|
|
24
|
+
var _this$get = this.get(),
|
|
25
|
+
item = _this$get.item,
|
|
26
|
+
hasPrev = _this$get.hasPrev,
|
|
27
|
+
hasNext = _this$get.hasNext,
|
|
28
|
+
container = _this$get.container,
|
|
29
|
+
value = _this$get.value;
|
|
30
|
+
var k = this.config.k;
|
|
31
|
+
var currentItem = item || {
|
|
32
|
+
name: '',
|
|
33
|
+
src: '',
|
|
34
|
+
poster: ''
|
|
35
|
+
};
|
|
36
|
+
return _$cc(Portal, {
|
|
37
|
+
'container': container,
|
|
38
|
+
'children': _$cc(Transition, {
|
|
39
|
+
'show': value,
|
|
40
|
+
'appear': value,
|
|
41
|
+
'name': 'k-fade',
|
|
42
|
+
'onAfterLeave': onAfterLeave,
|
|
43
|
+
'children': value ? _$ce(2, 'div', [_$ce(2, 'div', [_$ce(2, 'div', [_$ce(2, 'div', getTitle(), 0, _$cn(k + "-media-viewer-title"), {
|
|
44
|
+
'title': getTitle()
|
|
45
|
+
}), getCounterText() ? _$ce(2, 'div', getCounterText(), 0, _$cn(k + "-media-viewer-counter")) : undefined], 0, _$cn(k + "-media-viewer-heading")), _$ce(2, 'button', _$cc(Icon, {
|
|
46
|
+
'className': _$cn(k + "-icon-close-bold")
|
|
47
|
+
}), 2, _$cn(k + "-media-viewer-close"), {
|
|
48
|
+
'type': 'button',
|
|
49
|
+
'title': '关闭预览',
|
|
50
|
+
'aria-label': '关闭预览',
|
|
51
|
+
'ev-click': onCloseClick
|
|
52
|
+
})], 4, _$cn(k + "-media-viewer-header"), {
|
|
53
|
+
'ev-click': stopPropagation
|
|
54
|
+
}), shouldShowNavigation() ? _$ce(2, 'button', _$cc(Icon, {
|
|
55
|
+
'className': _$cn(k + "-icon-left")
|
|
56
|
+
}), 2, _$cn(k + "-media-viewer-prev"), {
|
|
57
|
+
'type': 'button',
|
|
58
|
+
'title': '上一个',
|
|
59
|
+
'aria-label': '上一个',
|
|
60
|
+
'disabled': !hasPrev,
|
|
61
|
+
'ev-click': onPrevClick
|
|
62
|
+
}) : undefined, shouldShowNavigation() ? _$ce(2, 'button', _$cc(Icon, {
|
|
63
|
+
'className': _$cn(k + "-icon-right")
|
|
64
|
+
}), 2, _$cn(k + "-media-viewer-next"), {
|
|
65
|
+
'type': 'button',
|
|
66
|
+
'title': '下一个',
|
|
67
|
+
'aria-label': '下一个',
|
|
68
|
+
'disabled': !hasNext,
|
|
69
|
+
'ev-click': onNextClick
|
|
70
|
+
}) : undefined, _$ce(2, 'div', isImage() ? _$ce(2, 'img', null, 1, _$cn(k + "-media-viewer-image"), {
|
|
71
|
+
'src': currentItem.src,
|
|
72
|
+
'alt': currentItem.name,
|
|
73
|
+
'draggable': false,
|
|
74
|
+
'ev-click': stopPropagation
|
|
75
|
+
}) : isVideo() ? _$ce(2, 'video', null, 1, _$cn(k + "-media-viewer-video"), {
|
|
76
|
+
'src': currentItem.src,
|
|
77
|
+
'poster': currentItem.poster || undefined,
|
|
78
|
+
'controls': true,
|
|
79
|
+
'autoplay': true,
|
|
80
|
+
'preload': 'metadata',
|
|
81
|
+
'playsinline': true,
|
|
82
|
+
'ev-click': stopPropagation
|
|
83
|
+
}) : isAudio() ? _$ce(2, 'div', [_$ce(2, 'div', _$ce(2, 'img', null, 1, _$cn(k + "-media-viewer-audio-cover-image"), {
|
|
84
|
+
'src': getAudioCardAssetSrc(),
|
|
85
|
+
'alt': '',
|
|
86
|
+
'draggable': false
|
|
87
|
+
}), 2, _$cn(k + "-media-viewer-audio-cover")), _$ce(2, 'div', currentItem.name, 0, _$cn(k + "-media-viewer-audio-title")), _$ce(2, 'audio', null, 1, _$cn(k + "-media-viewer-audio-player"), {
|
|
88
|
+
'src': currentItem.src,
|
|
89
|
+
'controls': true,
|
|
90
|
+
'autoplay': true,
|
|
91
|
+
'preload': 'metadata'
|
|
92
|
+
})], 4, _$cn(k + "-media-viewer-audio"), {
|
|
93
|
+
'ev-click': stopPropagation
|
|
94
|
+
}) : undefined, 0, _$cn(k + "-media-viewer-stage"))], 0, _$cn((_$cn2 = {}, _$cn2[k + "-media-viewer"] = true, _$cn2[this.get('className')] = this.get('className'), _$cn2)), {
|
|
95
|
+
'ev-click': onMaskClick
|
|
96
|
+
}) : undefined
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
;
|
|
@@ -58,6 +58,9 @@ var defaults = {
|
|
|
58
58
|
get color() {
|
|
59
59
|
return theme.color.text;
|
|
60
60
|
},
|
|
61
|
+
get arrowColor() {
|
|
62
|
+
return theme.color.lightBlack;
|
|
63
|
+
},
|
|
61
64
|
get hoverColor() {
|
|
62
65
|
return theme.color.primary;
|
|
63
66
|
},
|
|
@@ -112,7 +115,7 @@ export { menu };
|
|
|
112
115
|
export var makeMenuStyles = cache(function makeMenuStyles(k) {
|
|
113
116
|
// we must increase the priority by adding &.${k}-menu
|
|
114
117
|
// to override the css of dropdownMenu
|
|
115
|
-
return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";position:relative;}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";padding:0 16px;color:", menu.header.color, ";font-size:", menu.header.fontSize, ";font-weight:bold;}.", k, "-menu-body{padding:", menu.item.bodyPadding, ";max-height:calc(100% - ", menu.header.height, ");overflow-y:auto;overflow-x:hidden;scrollbar-width:none;}.", k, "-menu-title{height:", menu.title.height, ";border-top:", menu.border, ";margin-top:4px;.", k, "-menu-name{transition:all ", menu.transition, ";height:", menu.title.height, ";color:", menu.title.color, ";font-weight:bold;}}.", k, "-menu-arrow-box{width:14px;height:60px;cursor:pointer;background:", menu.bgColor, ";border-radius:0 8px 8px 0;position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:calc(", menu.width, " - 2px);transition:left ", menu.transition, ";transform:translateY(-50%);border:", menu.border, ";border-left:none;.", k, "-icon{margin-right:0;}&:hover{.", k, "-menu-arrow:before{color:", menu.item.activeBgColor, ";}}}&.", k, "-light{border-right:1px solid ", theme.color.disabledBg, ";background:", menu.light.bgColor, ";.", k, "-menu-header{color:", menu.light.title.color, ";}.", k, "-menu-item{.", k, "-menu-item-title{color:", menu.light.item.color, ";&:hover{background:", menu.light.item.hoverBg, ";}}.", k, "-menu-item-arrow{color:", menu.light.item.
|
|
118
|
+
return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";position:relative;}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";padding:0 16px;color:", menu.header.color, ";font-size:", menu.header.fontSize, ";font-weight:bold;}.", k, "-menu-body{padding:", menu.item.bodyPadding, ";max-height:calc(100% - ", menu.header.height, ");overflow-y:auto;overflow-x:hidden;scrollbar-width:none;}.", k, "-menu-title{height:", menu.title.height, ";border-top:", menu.border, ";margin-top:4px;.", k, "-menu-name{transition:all ", menu.transition, ";height:", menu.title.height, ";color:", menu.title.color, ";font-weight:bold;}}.", k, "-menu-arrow-box{width:14px;height:60px;cursor:pointer;background:", menu.bgColor, ";border-radius:0 8px 8px 0;position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:calc(", menu.width, " - 2px);transition:left ", menu.transition, ";transform:translateY(-50%);border:", menu.border, ";border-left:none;.", k, "-icon{margin-right:0;}&:hover{.", k, "-menu-arrow:before{color:", menu.item.activeBgColor, ";}}}&.", k, "-light{border-right:1px solid ", theme.color.disabledBg, ";background:", menu.light.bgColor, ";.", k, "-menu-header{color:", menu.light.title.color, ";}.", k, "-menu-item{.", k, "-menu-item-title{color:", menu.light.item.color, ";&:hover{background:", menu.light.item.hoverBg, ";}}.", k, "-menu-item-arrow{color:", menu.light.item.arrowColor, ";}&.", k, "-highlighted{>.", k, "-menu-item-title{color:", menu.light.item.hoverColor, ";}}&.", k, "-disabled{>.", k, "-menu-item-title{color:", menu.light.item.disabledColor, "!important;}}}.", k, "-menu-title{border-top:", menu.light.border, ";.", k, "-menu-name{color:", menu.light.title.color, ";}}.", k, "-menu-arrow-box{background:", menu.light.bgColor, ";border:", menu.light.border, ";border-left:none;&:hover{.", k, "-menu-arrow:before{color:", menu.light.active.color, ";}}}.", k, "-menu:not(.", k, "-dropdown-menu){background:", menu.light.bgColor, ";}&.", k, "-horizontal{.", k, "-menu-header{border-right:", menu.light.border, ";}.", k, "-menu-body>.", k, "-menu-title{border-right:", menu.light.border, ";}}.", k, "-menu-item.", k, "-active{>.", k, "-menu-item-title{color:", menu.light.active.color, "!important;background:", menu.light.active.bgColor, ";}}.", k, "-sub-menu{.", k, "-menu-item-title{color:", menu.light.item.subTitleColor, "!important;}.", k, "-menu-item-arrow{color:", menu.light.item.arrowColor, "!important;}}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
116
119
|
var styles = menu[size];
|
|
117
120
|
return /*#__PURE__*/css("&.", k, "-", size, "{width:", styles.width, ";font-size:", styles.fontSize, ";.", k, "-menu{font-size:", styles.fontSize, ";}.", k, "-menu-arrow-box{left:calc(", styles.width, " - 2px);}}");
|
|
118
121
|
}), "&.", k, "-collapsed{width:calc(", menu.icon.width, " + (", getLeft(menu.item.padding), " + ", getLeft(menu.item.bodyPadding), ") * 2);.", k, "-icon{margin-right:0;}.", k, "-menu-item-arrow{display:none;}}&.", k, "-collapsed-arrow{width:0px;border-left:none;.", k, "-menu-header{padding:0;}.", k, "-menu-body{overflow:hidden;padding:0;}.", k, "-menu-arrow-box{left:0;.", k, "-menu-arrow:before{transform:rotateY(180deg);}}}&.", k, "-dropdown-menu{width:fit-content;min-width:", menu.dropdown.minWidth, ";position:absolute;.", k, "-menu-item-arrow{transform:rotate(-90deg);}}&.", k, "-horizontal{width:auto;display:flex;.", k, "-menu-body{display:flex;align-items:center;.", k, "-menu-title{border-top:none;border-right:", menu.border, ";}}}");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
|
+
import TypesDemo from '~/components/notification/demos/types';
|
|
4
|
+
import EventDemo from '~/components/notification/demos/events';
|
|
5
|
+
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
6
|
+
import { Notification } from './';
|
|
7
|
+
import { createVNode as h } from 'intact-vue-next';
|
|
8
|
+
describe('Notification', function () {
|
|
9
|
+
afterEach(function () {
|
|
10
|
+
unmount();
|
|
11
|
+
});
|
|
12
|
+
it('show basic notification', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
13
|
+
var notification;
|
|
14
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
+
while (1) switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
Notification.notice({
|
|
18
|
+
title: 'Hello, Kingcloud Design!',
|
|
19
|
+
content: '这是一条基础用法的通知'
|
|
20
|
+
});
|
|
21
|
+
_context.next = 3;
|
|
22
|
+
return wait();
|
|
23
|
+
case 3:
|
|
24
|
+
notification = getElement('.k-notification');
|
|
25
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
26
|
+
case 5:
|
|
27
|
+
case "end":
|
|
28
|
+
return _context.stop();
|
|
29
|
+
}
|
|
30
|
+
}, _callee);
|
|
31
|
+
})));
|
|
32
|
+
it('show notifications with different types', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
33
|
+
var _mount, instance, element, _element$querySelecto, info, error, warning, success, notification;
|
|
34
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
35
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_mount = mount(TypesDemo), instance = _mount[0], element = _mount[1];
|
|
38
|
+
_element$querySelecto = element.querySelectorAll('.k-btn'), info = _element$querySelecto[0], error = _element$querySelecto[1], warning = _element$querySelecto[2], success = _element$querySelecto[3];
|
|
39
|
+
info.click();
|
|
40
|
+
_context2.next = 5;
|
|
41
|
+
return wait();
|
|
42
|
+
case 5:
|
|
43
|
+
notification = getElement('.k-notification');
|
|
44
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
45
|
+
error.click();
|
|
46
|
+
_context2.next = 10;
|
|
47
|
+
return wait();
|
|
48
|
+
case 10:
|
|
49
|
+
expect(getElement('.k-notification').outerHTML).to.matchSnapshot();
|
|
50
|
+
warning.click();
|
|
51
|
+
_context2.next = 14;
|
|
52
|
+
return wait();
|
|
53
|
+
case 14:
|
|
54
|
+
expect(getElement('.k-notification').outerHTML).to.matchSnapshot();
|
|
55
|
+
success.click();
|
|
56
|
+
_context2.next = 18;
|
|
57
|
+
return wait();
|
|
58
|
+
case 18:
|
|
59
|
+
expect(getElement('.k-notification').outerHTML).to.matchSnapshot();
|
|
60
|
+
case 19:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context2.stop();
|
|
63
|
+
}
|
|
64
|
+
}, _callee2);
|
|
65
|
+
})));
|
|
66
|
+
it('set duration', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
67
|
+
var notification, notification1;
|
|
68
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
69
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
this.timeout(0);
|
|
72
|
+
Notification.info({
|
|
73
|
+
title: '测试标题',
|
|
74
|
+
content: '测试内容',
|
|
75
|
+
duration: 500
|
|
76
|
+
});
|
|
77
|
+
_context3.next = 4;
|
|
78
|
+
return wait();
|
|
79
|
+
case 4:
|
|
80
|
+
notification = getElement('.k-notification');
|
|
81
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
82
|
+
// should not remove when mouseenter
|
|
83
|
+
dispatchEvent(notification, 'mouseenter');
|
|
84
|
+
_context3.next = 9;
|
|
85
|
+
return wait(1000);
|
|
86
|
+
case 9:
|
|
87
|
+
notification1 = getElement('.k-notification');
|
|
88
|
+
expect(notification1).eql(notification);
|
|
89
|
+
dispatchEvent(notification, 'mouseleave');
|
|
90
|
+
_context3.next = 14;
|
|
91
|
+
return wait(500);
|
|
92
|
+
case 14:
|
|
93
|
+
notification1 = getElement('.k-notification');
|
|
94
|
+
expect(notification1).eql(notification);
|
|
95
|
+
_context3.next = 18;
|
|
96
|
+
return wait(700);
|
|
97
|
+
case 18:
|
|
98
|
+
notification1 = getElement('.k-notification');
|
|
99
|
+
expect(notification1).not.eql(notification);
|
|
100
|
+
case 20:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context3.stop();
|
|
103
|
+
}
|
|
104
|
+
}, _callee3, this);
|
|
105
|
+
})));
|
|
106
|
+
it('set duration to 0 should not auto close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
107
|
+
var notification, notification1;
|
|
108
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
109
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
this.timeout(0);
|
|
112
|
+
Notification.warning({
|
|
113
|
+
title: '不会自动关闭',
|
|
114
|
+
content: '这条通知不会自动关闭',
|
|
115
|
+
duration: 0
|
|
116
|
+
});
|
|
117
|
+
_context4.next = 4;
|
|
118
|
+
return wait();
|
|
119
|
+
case 4:
|
|
120
|
+
notification = getElement('.k-notification'); // wait for a long time, should still exist
|
|
121
|
+
_context4.next = 7;
|
|
122
|
+
return wait(2000);
|
|
123
|
+
case 7:
|
|
124
|
+
notification1 = getElement('.k-notification');
|
|
125
|
+
expect(notification1).eql(notification);
|
|
126
|
+
case 9:
|
|
127
|
+
case "end":
|
|
128
|
+
return _context4.stop();
|
|
129
|
+
}
|
|
130
|
+
}, _callee4, this);
|
|
131
|
+
})));
|
|
132
|
+
it('hide close button when closable is false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
133
|
+
var notification, closeButton;
|
|
134
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
135
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
136
|
+
case 0:
|
|
137
|
+
Notification.info({
|
|
138
|
+
title: '隐藏关闭按钮',
|
|
139
|
+
content: '这条通知隐藏了关闭按钮',
|
|
140
|
+
closable: false
|
|
141
|
+
});
|
|
142
|
+
_context5.next = 3;
|
|
143
|
+
return wait();
|
|
144
|
+
case 3:
|
|
145
|
+
notification = getElement('.k-notification');
|
|
146
|
+
closeButton = notification.querySelector('.k-notification-close');
|
|
147
|
+
expect(closeButton).to.be.null;
|
|
148
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
149
|
+
case 7:
|
|
150
|
+
case "end":
|
|
151
|
+
return _context5.stop();
|
|
152
|
+
}
|
|
153
|
+
}, _callee5);
|
|
154
|
+
})));
|
|
155
|
+
it('should not show icon when type is empty string and icon is not provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
156
|
+
var notification, icon;
|
|
157
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
158
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
159
|
+
case 0:
|
|
160
|
+
Notification.notice({
|
|
161
|
+
title: '无类型通知',
|
|
162
|
+
content: '这条通知没有类型,不应该显示图标',
|
|
163
|
+
type: ''
|
|
164
|
+
});
|
|
165
|
+
_context6.next = 3;
|
|
166
|
+
return wait();
|
|
167
|
+
case 3:
|
|
168
|
+
notification = getElement('.k-notification');
|
|
169
|
+
icon = notification.querySelector('.k-notification-icon');
|
|
170
|
+
expect(icon).to.be.null;
|
|
171
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
172
|
+
case 7:
|
|
173
|
+
case "end":
|
|
174
|
+
return _context6.stop();
|
|
175
|
+
}
|
|
176
|
+
}, _callee6);
|
|
177
|
+
})));
|
|
178
|
+
it('show notification at different positions', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
179
|
+
var positions, _i, _positions, position, containers, container, notification;
|
|
180
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
181
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
182
|
+
case 0:
|
|
183
|
+
positions = ['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'];
|
|
184
|
+
_i = 0, _positions = positions;
|
|
185
|
+
case 2:
|
|
186
|
+
if (!(_i < _positions.length)) {
|
|
187
|
+
_context7.next = 16;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
position = _positions[_i];
|
|
191
|
+
Notification.info({
|
|
192
|
+
title: '位置测试',
|
|
193
|
+
content: "\u901A\u77E5\u51FA\u73B0\u5728" + position + "\u4F4D\u7F6E",
|
|
194
|
+
position: position
|
|
195
|
+
});
|
|
196
|
+
_context7.next = 7;
|
|
197
|
+
return wait();
|
|
198
|
+
case 7:
|
|
199
|
+
containers = document.querySelectorAll(".k-notifications");
|
|
200
|
+
container = containers[containers.length - 1];
|
|
201
|
+
expect(container).to.exist;
|
|
202
|
+
notification = container == null ? void 0 : container.querySelector(".k-notification.k-position-" + position);
|
|
203
|
+
expect(notification).to.exist;
|
|
204
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
205
|
+
case 13:
|
|
206
|
+
_i++;
|
|
207
|
+
_context7.next = 2;
|
|
208
|
+
break;
|
|
209
|
+
case 16:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context7.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee7);
|
|
214
|
+
})));
|
|
215
|
+
it('should trigger onClose callback when notification auto closes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
216
|
+
var onCloseSpy, notification;
|
|
217
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
218
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
this.timeout(0);
|
|
221
|
+
onCloseSpy = sinon.spy();
|
|
222
|
+
Notification.info({
|
|
223
|
+
title: '自动关闭测试',
|
|
224
|
+
content: '这条通知会自动关闭',
|
|
225
|
+
onClose: onCloseSpy,
|
|
226
|
+
duration: 500
|
|
227
|
+
});
|
|
228
|
+
_context8.next = 5;
|
|
229
|
+
return wait();
|
|
230
|
+
case 5:
|
|
231
|
+
notification = getElement('.k-notification');
|
|
232
|
+
expect(notification).to.exist;
|
|
233
|
+
// 等待自动关闭
|
|
234
|
+
_context8.next = 9;
|
|
235
|
+
return wait(700);
|
|
236
|
+
case 9:
|
|
237
|
+
expect(onCloseSpy.callCount).to.eql(1);
|
|
238
|
+
expect(onCloseSpy.calledOnce).to.be.true;
|
|
239
|
+
case 11:
|
|
240
|
+
case "end":
|
|
241
|
+
return _context8.stop();
|
|
242
|
+
}
|
|
243
|
+
}, _callee8, this);
|
|
244
|
+
})));
|
|
245
|
+
it('test notification click and close event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
246
|
+
var _mount2, instance, element, _element$querySelecto2, btn, notification, message1, closeButton, message2;
|
|
247
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
248
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
_mount2 = mount(EventDemo), instance = _mount2[0], element = _mount2[1];
|
|
251
|
+
_element$querySelecto2 = element.querySelectorAll('.k-btn'), btn = _element$querySelecto2[0];
|
|
252
|
+
btn.click();
|
|
253
|
+
_context9.next = 5;
|
|
254
|
+
return wait();
|
|
255
|
+
case 5:
|
|
256
|
+
notification = document.querySelector('.event-test');
|
|
257
|
+
dispatchEvent(notification, 'click');
|
|
258
|
+
_context9.next = 9;
|
|
259
|
+
return wait(500);
|
|
260
|
+
case 9:
|
|
261
|
+
message1 = document.querySelector('.k-info');
|
|
262
|
+
expect(message1.outerHTML).to.matchSnapshot();
|
|
263
|
+
_context9.next = 13;
|
|
264
|
+
return wait(500);
|
|
265
|
+
case 13:
|
|
266
|
+
closeButton = notification.querySelector('.k-notification-close');
|
|
267
|
+
closeButton.click();
|
|
268
|
+
_context9.next = 17;
|
|
269
|
+
return wait(500);
|
|
270
|
+
case 17:
|
|
271
|
+
message2 = document.querySelector('.k-warning');
|
|
272
|
+
expect(message2.outerHTML).to.matchSnapshot();
|
|
273
|
+
case 19:
|
|
274
|
+
case "end":
|
|
275
|
+
return _context9.stop();
|
|
276
|
+
}
|
|
277
|
+
}, _callee9);
|
|
278
|
+
})));
|
|
279
|
+
it('should support VNode as title and content', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
280
|
+
var notification, titleContainer, title, contentContainer, content;
|
|
281
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
282
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
283
|
+
case 0:
|
|
284
|
+
Notification.info({
|
|
285
|
+
title: h('div', {
|
|
286
|
+
class: 'custom-title'
|
|
287
|
+
}, '自定义标题'),
|
|
288
|
+
content: h('div', {
|
|
289
|
+
class: 'custom-content'
|
|
290
|
+
}, [h('span', {
|
|
291
|
+
style: 'color: red;'
|
|
292
|
+
}, '这是'), '一段', h('strong', null, '自定义内容')]),
|
|
293
|
+
className: 'custom-notification'
|
|
294
|
+
});
|
|
295
|
+
_context10.next = 3;
|
|
296
|
+
return wait(100);
|
|
297
|
+
case 3:
|
|
298
|
+
notification = document.querySelector('.custom-notification');
|
|
299
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
300
|
+
titleContainer = notification.querySelector('.k-notification-title');
|
|
301
|
+
expect(titleContainer).to.exist;
|
|
302
|
+
title = titleContainer.querySelector('.custom-title');
|
|
303
|
+
expect(title).to.exist;
|
|
304
|
+
expect(title.textContent).to.eql('自定义标题');
|
|
305
|
+
contentContainer = notification.querySelector('.k-notification-body');
|
|
306
|
+
expect(contentContainer).to.exist;
|
|
307
|
+
content = contentContainer.querySelector('.custom-content');
|
|
308
|
+
expect(content).to.exist;
|
|
309
|
+
expect(content.querySelector('span')).to.exist;
|
|
310
|
+
expect(content.querySelector('strong')).to.exist;
|
|
311
|
+
case 16:
|
|
312
|
+
case "end":
|
|
313
|
+
return _context10.stop();
|
|
314
|
+
}
|
|
315
|
+
}, _callee10);
|
|
316
|
+
})));
|
|
317
|
+
});
|