@king-design/vue 3.7.0 → 3.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/__snapshots__/Vue Next Demos.md +399 -0
- package/components/bubble/bubble.d.ts +62 -0
- package/components/bubble/bubble.js +81 -0
- package/components/bubble/bubble.vdt.js +89 -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 +824 -0
- package/components/bubble/styles.d.ts +5 -0
- package/components/bubble/styles.js +53 -0
- package/components/bubble/useBubbleDisplay.d.ts +19 -0
- package/components/bubble/useBubbleDisplay.js +308 -0
- package/components/bubbleList/bubbleList.d.ts +87 -0
- package/components/bubbleList/bubbleList.js +75 -0
- package/components/bubbleList/bubbleList.vdt.js +145 -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 +1332 -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 +462 -0
- package/components/checkbox/index.d.ts +3 -3
- 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 +1168 -0
- package/components/fileCard/list.d.ts +30 -0
- package/components/fileCard/list.js +46 -0
- package/components/fileCard/list.vdt.js +73 -0
- package/components/fileCard/styles.d.ts +5 -0
- package/components/fileCard/styles.js +85 -0
- package/components/fileCard/useFileCard.d.ts +45 -0
- package/components/fileCard/useFileCard.js +301 -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 +1880 -0
- package/components/media/media.d.ts +37 -0
- package/components/media/media.js +67 -0
- package/components/media/media.vdt.js +213 -0
- package/components/media/mediaAssets.d.ts +6 -0
- package/components/media/mediaAssets.js +13 -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 +54 -0
- package/components/media/types.d.ts +37 -0
- package/components/media/types.js +1 -0
- package/components/media/useMedia.d.ts +74 -0
- package/components/media/useMedia.js +493 -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/radio/index.d.ts +3 -3
- 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 +2201 -0
- package/components/sender/sender.d.ts +127 -0
- package/components/sender/sender.js +122 -0
- package/components/sender/sender.vdt.js +302 -0
- package/components/sender/styles.d.ts +5 -0
- package/components/sender/styles.js +65 -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 +329 -0
- package/components/sender/useSenderInput.d.ts +19 -0
- package/components/sender/useSenderInput.js +118 -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 +404 -0
- package/components/skeleton/skeleton.d.ts +2 -1
- package/components/skeleton/skeleton.js +1 -1
- 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/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 +1797 -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 +546 -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 +27 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +577 -0
- package/components/xmarkdown/xmarkdown.d.ts +62 -0
- package/components/xmarkdown/xmarkdown.js +109 -0
- package/components/xmarkdown/xmarkdown.vdt.js +47 -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/i18n/en-US.js +30 -1
- package/dist/i18n/en-US.js.map +1 -1
- package/dist/i18n/en-US.min.js +1 -1
- package/dist/index.js +100694 -37438
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1569 -1
- package/dist/kpc.css +4 -0
- package/dist/ksyun.css +4 -0
- package/i18n/en-US.d.ts +28 -0
- package/i18n/en-US.js +30 -1
- package/index.d.ts +9 -2
- package/index.js +9 -2
- package/package.json +8 -2
- package/styles/global.js +12 -6
- package/yarn-error.log +0 -1012
|
@@ -0,0 +1,1168 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
4
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
5
|
+
import { Component } from 'intact-vue-next';
|
|
6
|
+
import { getElement, mount, unmount, wait } from '../../test/utils';
|
|
7
|
+
import { FileCard, FileCardList } from '.';
|
|
8
|
+
describe('FileCard', function () {
|
|
9
|
+
afterEach(function () {
|
|
10
|
+
unmount();
|
|
11
|
+
});
|
|
12
|
+
function expectViewerClosed() {
|
|
13
|
+
var viewer = document.querySelector('.k-media-viewer');
|
|
14
|
+
if (!viewer) {
|
|
15
|
+
expect(viewer).to.eql(null);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
expect(viewer.classList.contains('k-fade-leave-active') || viewer.classList.contains('k-fade-leave-to')).to.be.true;
|
|
19
|
+
}
|
|
20
|
+
// 文件卡片和显式媒体卡片走不同外形,媒体内部复用 Media。
|
|
21
|
+
it('should render file and media card types with Media inside', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
22
|
+
var Demo, _mount, element;
|
|
23
|
+
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
24
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
25
|
+
case 0:
|
|
26
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
27
|
+
_inheritsLoose(Demo, _Component);
|
|
28
|
+
function Demo() {
|
|
29
|
+
var _context;
|
|
30
|
+
var _this;
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
35
|
+
_this.FileCard = FileCard;
|
|
36
|
+
_this.FileCardList = FileCardList;
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
return Demo;
|
|
40
|
+
}(Component);
|
|
41
|
+
Demo.template = "\n const { FileCard, FileCardList } = this;\n <div>\n <FileCard name=\"spec.pdf\" type=\"file\" byte={1024} src=\"https://example.com/spec.pdf\" />\n <FileCard name=\"cover.png\" type=\"image\" src=\"https://example.com/cover.png\" />\n <FileCardList items={[\n {key: 'video', name: 'demo.mp4', type: 'video', src: 'https://example.com/demo.mp4'},\n {key: 'audio', name: 'voice.mp3', type: 'audio', src: 'https://example.com/voice.mp3'},\n ]} />\n </div>\n ";
|
|
42
|
+
_mount = mount(Demo), element = _mount[1];
|
|
43
|
+
expect(element.querySelectorAll('.k-file-card').length).to.eql(4);
|
|
44
|
+
expect(element.querySelector('.k-file-card-file')).not.to.eql(null);
|
|
45
|
+
expect(element.querySelectorAll('.k-file-card-media').length).to.eql(3);
|
|
46
|
+
expect(element.querySelector('.k-file-card-type-image .k-media-image')).not.to.eql(null);
|
|
47
|
+
expect(element.querySelector('.k-file-card-type-video .k-media-video')).not.to.eql(null);
|
|
48
|
+
expect(element.querySelector('.k-file-card-type-audio .k-media-audio')).not.to.eql(null);
|
|
49
|
+
case 9:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context2.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
})));
|
|
55
|
+
// 显式媒体卡片可开启名称 Tooltip,文件行左侧媒体缩略图固定关闭。
|
|
56
|
+
it('should pass name tooltip setting to media cards only', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
57
|
+
var Demo, _mount2, element, imageMedia, videoMedia, audioMedia, listMedia, listMediaViews, listFileRowMedia, defaultMedia, fileRowMedia;
|
|
58
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context4) {
|
|
59
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
Demo = /*#__PURE__*/function (_Component2) {
|
|
62
|
+
_inheritsLoose(Demo, _Component2);
|
|
63
|
+
function Demo() {
|
|
64
|
+
var _context3;
|
|
65
|
+
var _this2;
|
|
66
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
67
|
+
args[_key2] = arguments[_key2];
|
|
68
|
+
}
|
|
69
|
+
_this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
|
|
70
|
+
_this2.FileCard = FileCard;
|
|
71
|
+
_this2.FileCardList = FileCardList;
|
|
72
|
+
return _this2;
|
|
73
|
+
}
|
|
74
|
+
return Demo;
|
|
75
|
+
}(Component);
|
|
76
|
+
Demo.template = "\n const { FileCard, FileCardList } = this;\n <div>\n <FileCard className=\"image-tooltip\" name=\"cover.png\" type=\"image\" src=\"https://example.com/cover.png\" showNameTooltip />\n <FileCard className=\"video-tooltip\" name=\"demo.mp4\" type=\"video\" src=\"https://example.com/demo.mp4\" showNameTooltip />\n <FileCard className=\"audio-tooltip\" name=\"voice.mp3\" type=\"audio\" src=\"https://example.com/voice.mp3\" showNameTooltip />\n <FileCard className=\"default-media-tooltip\" name=\"default.png\" type=\"image\" src=\"https://example.com/default.png\" />\n <FileCard className=\"file-row-tooltip\" name=\"row.png\" type=\"file\" src=\"https://example.com/row.png\" showNameTooltip />\n <FileCardList className=\"list-tooltip\" showNameTooltip items={[\n {key: 'audio', name: 'list.mp3', type: 'audio', src: 'https://example.com/list.mp3'},\n {key: 'image', name: 'list.png', type: 'image', src: 'https://example.com/list.png'},\n {key: 'video-off', name: 'off.mp4', type: 'video', src: 'https://example.com/off.mp4', showNameTooltip: false},\n {key: 'file-row', name: 'row-list.png', type: 'file', src: 'https://example.com/row-list.png'},\n ]} />\n </div>\n ";
|
|
77
|
+
_mount2 = mount(Demo), element = _mount2[1];
|
|
78
|
+
imageMedia = element.querySelector('.image-tooltip .k-file-card-media-view');
|
|
79
|
+
videoMedia = element.querySelector('.video-tooltip .k-file-card-media-view');
|
|
80
|
+
audioMedia = element.querySelector('.audio-tooltip .k-file-card-media-view');
|
|
81
|
+
listMedia = element.querySelector('.list-tooltip .k-file-card-media-view');
|
|
82
|
+
listMediaViews = element.querySelectorAll('.list-tooltip .k-file-card-media-view');
|
|
83
|
+
listFileRowMedia = element.querySelector('.list-tooltip .k-file-card-file-media-view');
|
|
84
|
+
defaultMedia = element.querySelector('.default-media-tooltip .k-file-card-media-view');
|
|
85
|
+
fileRowMedia = element.querySelector('.file-row-tooltip .k-file-card-file-media-view');
|
|
86
|
+
[imageMedia, videoMedia, audioMedia, listMedia, listMediaViews[1]].forEach(function (media) {
|
|
87
|
+
expect(media.querySelector('.k-media-name-tooltip-trigger')).not.to.eql(null);
|
|
88
|
+
expect(media.getAttribute('title')).to.eql(null);
|
|
89
|
+
});
|
|
90
|
+
expect(listMediaViews[2].querySelector('.k-media-name-tooltip-trigger')).to.eql(null);
|
|
91
|
+
expect(listMediaViews[2].getAttribute('title')).to.eql('off.mp4');
|
|
92
|
+
expect(listFileRowMedia.querySelector('.k-media-name-tooltip-trigger')).to.eql(null);
|
|
93
|
+
expect(listFileRowMedia.getAttribute('title')).to.eql('row-list.png');
|
|
94
|
+
expect(defaultMedia.querySelector('.k-media-name-tooltip-trigger')).to.eql(null);
|
|
95
|
+
expect(defaultMedia.getAttribute('title')).to.eql('default.png');
|
|
96
|
+
expect(fileRowMedia.querySelector('.k-media-name-tooltip-trigger')).to.eql(null);
|
|
97
|
+
expect(fileRowMedia.getAttribute('title')).to.eql('row.png');
|
|
98
|
+
case 20:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context4.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee2);
|
|
103
|
+
})));
|
|
104
|
+
// 普通文件按扩展名使用内置设计图标。
|
|
105
|
+
it('should render builtin file icons by extension', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
106
|
+
var Demo, _mount3, element, word, sheet, txt, pdf, md, code, ppt, zip, fallback, imageNoSrc, videoNoPreview, audioNoPreview;
|
|
107
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context6) {
|
|
108
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
Demo = /*#__PURE__*/function (_Component3) {
|
|
111
|
+
_inheritsLoose(Demo, _Component3);
|
|
112
|
+
function Demo() {
|
|
113
|
+
var _context5;
|
|
114
|
+
var _this3;
|
|
115
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
116
|
+
args[_key3] = arguments[_key3];
|
|
117
|
+
}
|
|
118
|
+
_this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context5 = [this]).call(_context5, args)) || this;
|
|
119
|
+
_this3.FileCard = FileCard;
|
|
120
|
+
return _this3;
|
|
121
|
+
}
|
|
122
|
+
return Demo;
|
|
123
|
+
}(Component);
|
|
124
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard className=\"word\" name=\"a.docx\" type=\"file\" />\n <FileCard className=\"sheet\" name=\"b.csv\" type=\"file\" />\n <FileCard className=\"txt\" name=\"c.txt\" type=\"file\" />\n <FileCard className=\"pdf\" name=\"d.pdf\" type=\"file\" />\n <FileCard className=\"md\" name=\"e.md\" type=\"file\" />\n <FileCard className=\"code\" name=\"f.ts\" type=\"file\" />\n <FileCard className=\"ppt\" name=\"g.pptx\" type=\"file\" />\n <FileCard className=\"zip\" name=\"h.zip\" type=\"file\" />\n <FileCard className=\"fallback\" name=\"i.unknown\" type=\"file\" />\n <FileCard className=\"image-no-src\" name=\"k.png\" type=\"file\" />\n <FileCard className=\"video-no-preview\" name=\"l.mp4\" type=\"file\" showPreview={false} src=\"https://example.com/l.mp4\" />\n <FileCard className=\"audio-no-preview\" name=\"m.mp3\" type=\"file\" showPreview={false} src=\"https://example.com/m.mp3\" />\n </div>\n ";
|
|
125
|
+
_mount3 = mount(Demo), element = _mount3[1];
|
|
126
|
+
word = element.querySelector('.word .k-file-card-file-icon-img').src;
|
|
127
|
+
sheet = element.querySelector('.sheet .k-file-card-file-icon-img').src;
|
|
128
|
+
txt = element.querySelector('.txt .k-file-card-file-icon-img').src;
|
|
129
|
+
pdf = element.querySelector('.pdf .k-file-card-file-icon-img').src;
|
|
130
|
+
md = element.querySelector('.md .k-file-card-file-icon-img').src;
|
|
131
|
+
code = element.querySelector('.code .k-file-card-file-icon-img').src;
|
|
132
|
+
ppt = element.querySelector('.ppt .k-file-card-file-icon-img').src;
|
|
133
|
+
zip = element.querySelector('.zip .k-file-card-file-icon-img').src;
|
|
134
|
+
fallback = element.querySelector('.fallback .k-file-card-file-icon-img').src;
|
|
135
|
+
imageNoSrc = element.querySelector('.image-no-src .k-file-card-file-icon-img').src;
|
|
136
|
+
videoNoPreview = element.querySelector('.video-no-preview .k-file-card-file-icon-img').src;
|
|
137
|
+
audioNoPreview = element.querySelector('.audio-no-preview .k-file-card-file-icon-img').src;
|
|
138
|
+
[word, sheet, txt, pdf, md, code, ppt, zip, fallback, imageNoSrc, videoNoPreview, audioNoPreview].forEach(function (src) {
|
|
139
|
+
expect(src).to.contain('data:image/svg+xml');
|
|
140
|
+
});
|
|
141
|
+
expect(word).not.to.eql(pdf);
|
|
142
|
+
expect(sheet).not.to.eql(zip);
|
|
143
|
+
expect(md).not.to.eql(code);
|
|
144
|
+
expect(imageNoSrc).not.to.eql(videoNoPreview);
|
|
145
|
+
expect(videoNoPreview).not.to.eql(audioNoPreview);
|
|
146
|
+
expect(element.querySelector('.video-no-preview .k-file-card-file-media-view')).to.eql(null);
|
|
147
|
+
expect(element.querySelector('.audio-no-preview .k-file-card-file-media-view')).to.eql(null);
|
|
148
|
+
case 23:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context6.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee3);
|
|
153
|
+
})));
|
|
154
|
+
// type=file 始终保持文件行外形,但媒体资源会用左侧小 Media 缩略图。
|
|
155
|
+
it('should keep file layout and render media thumbnail for explicit file type', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
156
|
+
var _element$querySelecto, _element$querySelecto2;
|
|
157
|
+
var Demo, _mount4, element, card, media;
|
|
158
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context8) {
|
|
159
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
160
|
+
case 0:
|
|
161
|
+
Demo = /*#__PURE__*/function (_Component4) {
|
|
162
|
+
_inheritsLoose(Demo, _Component4);
|
|
163
|
+
function Demo() {
|
|
164
|
+
var _context7;
|
|
165
|
+
var _this4;
|
|
166
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
167
|
+
args[_key4] = arguments[_key4];
|
|
168
|
+
}
|
|
169
|
+
_this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context7 = [this]).call(_context7, args)) || this;
|
|
170
|
+
_this4.FileCard = FileCard;
|
|
171
|
+
return _this4;
|
|
172
|
+
}
|
|
173
|
+
return Demo;
|
|
174
|
+
}(Component);
|
|
175
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"\u5C01\u9762\u56FE.png\"\n type=\"file\"\n status=\"loading\"\n percent={30}\n src=\"https://example.com/cover.png\"\n />\n </div>\n ";
|
|
176
|
+
_mount4 = mount(Demo), element = _mount4[1];
|
|
177
|
+
card = element.querySelector('.k-file-card');
|
|
178
|
+
media = element.querySelector('.k-file-card-file-media-view');
|
|
179
|
+
expect(card.className).to.contain('k-file-card-file');
|
|
180
|
+
expect(card.className).not.to.contain('k-file-card-media');
|
|
181
|
+
expect(media).not.to.eql(null);
|
|
182
|
+
expect(media.className).to.contain('k-media-loading');
|
|
183
|
+
expect(media.className).not.to.contain('k-media-custom-loading');
|
|
184
|
+
expect(element.querySelector('.k-file-card-file-shell').style.getPropertyValue('--file-card-progress-percent')).to.eql('30%');
|
|
185
|
+
expect((_element$querySelecto = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto.textContent).to.contain('上传中... 30%');
|
|
186
|
+
expect((_element$querySelecto2 = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto2.textContent).not.to.contain('KB');
|
|
187
|
+
case 13:
|
|
188
|
+
case "end":
|
|
189
|
+
return _context8.stop();
|
|
190
|
+
}
|
|
191
|
+
}, _callee4);
|
|
192
|
+
})));
|
|
193
|
+
// 显式视频卡片 loading 时,进度展示在 loading 圈右侧,文案居中展示。
|
|
194
|
+
it('should pass status to media card and show video progress beside spinner', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
195
|
+
var _element$querySelecto3, _element$querySelecto4;
|
|
196
|
+
var Demo, _mount5, element, card, media;
|
|
197
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context10) {
|
|
198
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
Demo = /*#__PURE__*/function (_Component5) {
|
|
201
|
+
_inheritsLoose(Demo, _Component5);
|
|
202
|
+
function Demo() {
|
|
203
|
+
var _context9;
|
|
204
|
+
var _this5;
|
|
205
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
206
|
+
args[_key5] = arguments[_key5];
|
|
207
|
+
}
|
|
208
|
+
_this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
|
|
209
|
+
_this5.FileCard = FileCard;
|
|
210
|
+
return _this5;
|
|
211
|
+
}
|
|
212
|
+
return Demo;
|
|
213
|
+
}(Component);
|
|
214
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"result.mp4\"\n type=\"video\"\n status=\"loading\"\n percent={56}\n loadingText=\"\u5904\u7406\u4E2D\"\n src=\"https://example.com/result.mp4\"\n />\n </div>\n ";
|
|
215
|
+
_mount5 = mount(Demo), element = _mount5[1];
|
|
216
|
+
card = element.querySelector('.k-file-card');
|
|
217
|
+
media = element.querySelector('.k-file-card-media-view');
|
|
218
|
+
expect(card.className).to.contain('k-file-card-media');
|
|
219
|
+
expect(card.className).to.contain('k-file-card-progressing');
|
|
220
|
+
expect(media.className).to.contain('k-media-loading');
|
|
221
|
+
expect(element.querySelector('.k-media-loading-indicator')).not.to.eql(null);
|
|
222
|
+
expect((_element$querySelecto3 = element.querySelector('.k-file-card-media-loading-text')) == null ? void 0 : _element$querySelecto3.textContent).to.contain('处理中');
|
|
223
|
+
expect((_element$querySelecto4 = element.querySelector('.k-file-card-media-progress-text')) == null ? void 0 : _element$querySelecto4.textContent).to.contain('56%');
|
|
224
|
+
case 11:
|
|
225
|
+
case "end":
|
|
226
|
+
return _context10.stop();
|
|
227
|
+
}
|
|
228
|
+
}, _callee5);
|
|
229
|
+
})));
|
|
230
|
+
// 显式图片卡片 loading 且有 percent 时,同样展示进度文案。
|
|
231
|
+
it('should show image progress beside spinner when loading', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
232
|
+
var _element$querySelecto5;
|
|
233
|
+
var Demo, _mount6, element;
|
|
234
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context12) {
|
|
235
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
236
|
+
case 0:
|
|
237
|
+
Demo = /*#__PURE__*/function (_Component6) {
|
|
238
|
+
_inheritsLoose(Demo, _Component6);
|
|
239
|
+
function Demo() {
|
|
240
|
+
var _context11;
|
|
241
|
+
var _this6;
|
|
242
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
243
|
+
args[_key6] = arguments[_key6];
|
|
244
|
+
}
|
|
245
|
+
_this6 = _Component6.call.apply(_Component6, _concatInstanceProperty(_context11 = [this]).call(_context11, args)) || this;
|
|
246
|
+
_this6.FileCard = FileCard;
|
|
247
|
+
return _this6;
|
|
248
|
+
}
|
|
249
|
+
return Demo;
|
|
250
|
+
}(Component);
|
|
251
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n status=\"loading\"\n percent={43}\n src=\"https://example.com/cover.png\"\n />\n </div>\n ";
|
|
252
|
+
_mount6 = mount(Demo), element = _mount6[1];
|
|
253
|
+
expect(element.querySelector('.k-media-loading-indicator')).not.to.eql(null);
|
|
254
|
+
expect((_element$querySelecto5 = element.querySelector('.k-file-card-media-progress-text')) == null ? void 0 : _element$querySelecto5.textContent).to.contain('43%');
|
|
255
|
+
case 5:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context12.stop();
|
|
258
|
+
}
|
|
259
|
+
}, _callee6);
|
|
260
|
+
})));
|
|
261
|
+
// 显式媒体卡片外层不额外定义尺寸,宽高完全跟随内部 Media。
|
|
262
|
+
it('should let media card size follow inner Media', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
263
|
+
var Demo, _mount7, element, card, media;
|
|
264
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context14) {
|
|
265
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
266
|
+
case 0:
|
|
267
|
+
Demo = /*#__PURE__*/function (_Component7) {
|
|
268
|
+
_inheritsLoose(Demo, _Component7);
|
|
269
|
+
function Demo() {
|
|
270
|
+
var _context13;
|
|
271
|
+
var _this7;
|
|
272
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
273
|
+
args[_key7] = arguments[_key7];
|
|
274
|
+
}
|
|
275
|
+
_this7 = _Component7.call.apply(_Component7, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
|
|
276
|
+
_this7.FileCard = FileCard;
|
|
277
|
+
return _this7;
|
|
278
|
+
}
|
|
279
|
+
return Demo;
|
|
280
|
+
}(Component);
|
|
281
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"cover.png\" type=\"image\" size=\"small\" src=\"https://example.com/cover.png\" />\n </div>\n ";
|
|
282
|
+
_mount7 = mount(Demo), element = _mount7[1];
|
|
283
|
+
card = element.querySelector('.k-file-card');
|
|
284
|
+
media = element.querySelector('.k-media');
|
|
285
|
+
expect(getComputedStyle(card).width).to.eql(getComputedStyle(media).width);
|
|
286
|
+
expect(getComputedStyle(card).height).to.eql(getComputedStyle(media).height);
|
|
287
|
+
case 7:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context14.stop();
|
|
290
|
+
}
|
|
291
|
+
}, _callee7);
|
|
292
|
+
})));
|
|
293
|
+
// 普通文件卡片默认宽度为 160px。
|
|
294
|
+
it('should render default file card width as 160px', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
295
|
+
var Demo, _mount8, element, card;
|
|
296
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context16) {
|
|
297
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
Demo = /*#__PURE__*/function (_Component8) {
|
|
300
|
+
_inheritsLoose(Demo, _Component8);
|
|
301
|
+
function Demo() {
|
|
302
|
+
var _context15;
|
|
303
|
+
var _this8;
|
|
304
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
305
|
+
args[_key8] = arguments[_key8];
|
|
306
|
+
}
|
|
307
|
+
_this8 = _Component8.call.apply(_Component8, _concatInstanceProperty(_context15 = [this]).call(_context15, args)) || this;
|
|
308
|
+
_this8.FileCard = FileCard;
|
|
309
|
+
return _this8;
|
|
310
|
+
}
|
|
311
|
+
return Demo;
|
|
312
|
+
}(Component);
|
|
313
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"a.pdf\" type=\"file\" />\n </div>\n ";
|
|
314
|
+
_mount8 = mount(Demo), element = _mount8[1];
|
|
315
|
+
card = element.querySelector('.k-file-card');
|
|
316
|
+
expect(getComputedStyle(card).width).to.eql('160px');
|
|
317
|
+
case 5:
|
|
318
|
+
case "end":
|
|
319
|
+
return _context16.stop();
|
|
320
|
+
}
|
|
321
|
+
}, _callee8);
|
|
322
|
+
})));
|
|
323
|
+
// 显式媒体 loading 文案仅在指定 loadingText 时展示。
|
|
324
|
+
it('should show media loading text only when loadingText is specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
325
|
+
var _element$querySelecto6;
|
|
326
|
+
var Demo, _mount9, element;
|
|
327
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context18) {
|
|
328
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
329
|
+
case 0:
|
|
330
|
+
Demo = /*#__PURE__*/function (_Component9) {
|
|
331
|
+
_inheritsLoose(Demo, _Component9);
|
|
332
|
+
function Demo() {
|
|
333
|
+
var _context17;
|
|
334
|
+
var _this9;
|
|
335
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
336
|
+
args[_key9] = arguments[_key9];
|
|
337
|
+
}
|
|
338
|
+
_this9 = _Component9.call.apply(_Component9, _concatInstanceProperty(_context17 = [this]).call(_context17, args)) || this;
|
|
339
|
+
_this9.FileCard = FileCard;
|
|
340
|
+
return _this9;
|
|
341
|
+
}
|
|
342
|
+
return Demo;
|
|
343
|
+
}(Component);
|
|
344
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"a.png\" type=\"image\" status=\"loading\" src=\"https://example.com/a.png\" />\n <FileCard name=\"b.png\" type=\"image\" status=\"loading\" loadingText=\"\u5904\u7406\u4E2D\" src=\"https://example.com/b.png\" />\n <FileCard name=\"a.mp4\" type=\"video\" status=\"loading\" loadingText=\"\" src=\"https://example.com/a.mp4\" />\n </div>\n ";
|
|
345
|
+
_mount9 = mount(Demo), element = _mount9[1];
|
|
346
|
+
expect(element.querySelectorAll('.k-media-loading-indicator').length).to.eql(3);
|
|
347
|
+
expect(element.querySelectorAll('.k-file-card-media-loading-text').length).to.eql(1);
|
|
348
|
+
expect((_element$querySelecto6 = element.querySelector('.k-file-card-media-loading-text')) == null ? void 0 : _element$querySelecto6.textContent).to.contain('处理中');
|
|
349
|
+
case 6:
|
|
350
|
+
case "end":
|
|
351
|
+
return _context18.stop();
|
|
352
|
+
}
|
|
353
|
+
}, _callee9);
|
|
354
|
+
})));
|
|
355
|
+
// mini 文件卡片默认只展示图标和文件名,不展示描述区。
|
|
356
|
+
it('should hide description in mini file card', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
357
|
+
var _element$querySelecto7;
|
|
358
|
+
var Demo, _mount10, element, card;
|
|
359
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context20) {
|
|
360
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
361
|
+
case 0:
|
|
362
|
+
Demo = /*#__PURE__*/function (_Component10) {
|
|
363
|
+
_inheritsLoose(Demo, _Component10);
|
|
364
|
+
function Demo() {
|
|
365
|
+
var _context19;
|
|
366
|
+
var _this10;
|
|
367
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
368
|
+
args[_key10] = arguments[_key10];
|
|
369
|
+
}
|
|
370
|
+
_this10 = _Component10.call.apply(_Component10, _concatInstanceProperty(_context19 = [this]).call(_context19, args)) || this;
|
|
371
|
+
_this10.FileCard = FileCard;
|
|
372
|
+
return _this10;
|
|
373
|
+
}
|
|
374
|
+
return Demo;
|
|
375
|
+
}(Component);
|
|
376
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"voice.mp3\" type=\"file\" size=\"mini\" byte={1024} />\n </div>\n ";
|
|
377
|
+
_mount10 = mount(Demo), element = _mount10[1];
|
|
378
|
+
card = element.querySelector('.k-file-card');
|
|
379
|
+
expect(card.className).to.contain('k-file-card-mini');
|
|
380
|
+
expect((_element$querySelecto7 = element.querySelector('.k-file-card-title')) == null ? void 0 : _element$querySelecto7.textContent).to.contain('voice.mp3');
|
|
381
|
+
expect(element.querySelector('.k-file-card-description')).to.eql(null);
|
|
382
|
+
case 7:
|
|
383
|
+
case "end":
|
|
384
|
+
return _context20.stop();
|
|
385
|
+
}
|
|
386
|
+
}, _callee10);
|
|
387
|
+
})));
|
|
388
|
+
// mini 文件卡片在 loading/error 时,状态文案占据标题位置。
|
|
389
|
+
it('should show loading and error status text in mini file title area', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
390
|
+
var _cards$0$querySelecto, _cards$0$querySelecto2, _cards$1$querySelecto, _cards$1$querySelecto2;
|
|
391
|
+
var Demo, _mount11, element, cards;
|
|
392
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context22) {
|
|
393
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
394
|
+
case 0:
|
|
395
|
+
Demo = /*#__PURE__*/function (_Component11) {
|
|
396
|
+
_inheritsLoose(Demo, _Component11);
|
|
397
|
+
function Demo() {
|
|
398
|
+
var _context21;
|
|
399
|
+
var _this11;
|
|
400
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
401
|
+
args[_key11] = arguments[_key11];
|
|
402
|
+
}
|
|
403
|
+
_this11 = _Component11.call.apply(_Component11, _concatInstanceProperty(_context21 = [this]).call(_context21, args)) || this;
|
|
404
|
+
_this11.FileCard = FileCard;
|
|
405
|
+
return _this11;
|
|
406
|
+
}
|
|
407
|
+
return Demo;
|
|
408
|
+
}(Component);
|
|
409
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"uploading.pdf\" type=\"file\" size=\"mini\" status=\"loading\" percent={80} />\n <FileCard name=\"error.pdf\" type=\"file\" size=\"mini\" status=\"error\" />\n </div>\n ";
|
|
410
|
+
_mount11 = mount(Demo), element = _mount11[1];
|
|
411
|
+
cards = element.querySelectorAll('.k-file-card');
|
|
412
|
+
expect((_cards$0$querySelecto = cards[0].querySelector('.k-file-card-title')) == null ? void 0 : _cards$0$querySelecto.textContent).to.contain('上传中... 80%');
|
|
413
|
+
expect((_cards$0$querySelecto2 = cards[0].querySelector('.k-file-card-title')) == null ? void 0 : _cards$0$querySelecto2.textContent).not.to.contain('uploading.pdf');
|
|
414
|
+
expect((_cards$1$querySelecto = cards[1].querySelector('.k-file-card-title')) == null ? void 0 : _cards$1$querySelecto.textContent).to.contain('上传失败');
|
|
415
|
+
expect((_cards$1$querySelecto2 = cards[1].querySelector('.k-file-card-title')) == null ? void 0 : _cards$1$querySelecto2.textContent).not.to.contain('error.pdf');
|
|
416
|
+
expect(cards[1].querySelector('.k-file-card-title-status-error')).not.to.eql(null);
|
|
417
|
+
case 9:
|
|
418
|
+
case "end":
|
|
419
|
+
return _context22.stop();
|
|
420
|
+
}
|
|
421
|
+
}, _callee11);
|
|
422
|
+
})));
|
|
423
|
+
// type=file 的背景进度使用整张卡片底色,不再渲染 Progress 组件。
|
|
424
|
+
it('should render file progress as card background instead of Progress component', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
425
|
+
var _element$querySelecto8, _element$querySelecto9;
|
|
426
|
+
var Demo, _mount12, element, card;
|
|
427
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context24) {
|
|
428
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
429
|
+
case 0:
|
|
430
|
+
Demo = /*#__PURE__*/function (_Component12) {
|
|
431
|
+
_inheritsLoose(Demo, _Component12);
|
|
432
|
+
function Demo() {
|
|
433
|
+
var _context23;
|
|
434
|
+
var _this12;
|
|
435
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
436
|
+
args[_key12] = arguments[_key12];
|
|
437
|
+
}
|
|
438
|
+
_this12 = _Component12.call.apply(_Component12, _concatInstanceProperty(_context23 = [this]).call(_context23, args)) || this;
|
|
439
|
+
_this12.FileCard = FileCard;
|
|
440
|
+
return _this12;
|
|
441
|
+
}
|
|
442
|
+
return Demo;
|
|
443
|
+
}(Component);
|
|
444
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"assets.zip\" type=\"file\" status=\"loading\" percent={62} byte={1024 * 20} />\n </div>\n ";
|
|
445
|
+
_mount12 = mount(Demo), element = _mount12[1];
|
|
446
|
+
card = element.querySelector('.k-file-card');
|
|
447
|
+
expect(element.querySelector('.k-file-card-file-shell').style.getPropertyValue('--file-card-progress-percent')).to.eql('62%');
|
|
448
|
+
expect(element.querySelector('.k-progress')).to.eql(null);
|
|
449
|
+
expect((_element$querySelecto8 = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto8.textContent).to.contain('上传中... 62%');
|
|
450
|
+
expect((_element$querySelecto9 = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto9.textContent).not.to.contain('KB');
|
|
451
|
+
case 8:
|
|
452
|
+
case "end":
|
|
453
|
+
return _context24.stop();
|
|
454
|
+
}
|
|
455
|
+
}, _callee12);
|
|
456
|
+
})));
|
|
457
|
+
// errorText 在文件错误状态下优先于 description 和 byte。
|
|
458
|
+
it('should prioritize errorText over description and byte when status is error', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
459
|
+
var _element$querySelecto10;
|
|
460
|
+
var Demo, _mount13, element, text;
|
|
461
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context26) {
|
|
462
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
463
|
+
case 0:
|
|
464
|
+
Demo = /*#__PURE__*/function (_Component13) {
|
|
465
|
+
_inheritsLoose(Demo, _Component13);
|
|
466
|
+
function Demo() {
|
|
467
|
+
var _context25;
|
|
468
|
+
var _this13;
|
|
469
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
470
|
+
args[_key13] = arguments[_key13];
|
|
471
|
+
}
|
|
472
|
+
_this13 = _Component13.call.apply(_Component13, _concatInstanceProperty(_context25 = [this]).call(_context25, args)) || this;
|
|
473
|
+
_this13.FileCard = FileCard;
|
|
474
|
+
return _this13;
|
|
475
|
+
}
|
|
476
|
+
return Demo;
|
|
477
|
+
}(Component);
|
|
478
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"broken.pdf\"\n type=\"file\"\n status=\"error\"\n description=\"\u666E\u901A\u63CF\u8FF0\"\n errorText=\"\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\"\n byte={1024 * 20}\n />\n </div>\n ";
|
|
479
|
+
_mount13 = mount(Demo), element = _mount13[1];
|
|
480
|
+
text = ((_element$querySelecto10 = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto10.textContent) || '';
|
|
481
|
+
expect(text).to.contain('上传失败,请重试');
|
|
482
|
+
expect(text).not.to.contain('普通描述');
|
|
483
|
+
expect(text).not.to.contain('20 KB');
|
|
484
|
+
case 7:
|
|
485
|
+
case "end":
|
|
486
|
+
return _context26.stop();
|
|
487
|
+
}
|
|
488
|
+
}, _callee13);
|
|
489
|
+
})));
|
|
490
|
+
// 显式图片/视频上传失败时,有 src 也展示错误占位,错误文案仅在指定 errorText 时展示。
|
|
491
|
+
it('should render media error state with source and show text only when specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
492
|
+
var _cards$1$querySelecto3;
|
|
493
|
+
var Demo, _mount14, element, cards, artwork, icon;
|
|
494
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context28) {
|
|
495
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
496
|
+
case 0:
|
|
497
|
+
Demo = /*#__PURE__*/function (_Component14) {
|
|
498
|
+
_inheritsLoose(Demo, _Component14);
|
|
499
|
+
function Demo() {
|
|
500
|
+
var _context27;
|
|
501
|
+
var _this14;
|
|
502
|
+
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
503
|
+
args[_key14] = arguments[_key14];
|
|
504
|
+
}
|
|
505
|
+
_this14 = _Component14.call.apply(_Component14, _concatInstanceProperty(_context27 = [this]).call(_context27, args)) || this;
|
|
506
|
+
_this14.FileCard = FileCard;
|
|
507
|
+
return _this14;
|
|
508
|
+
}
|
|
509
|
+
return Demo;
|
|
510
|
+
}(Component);
|
|
511
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n src=\"https://example.com/cover.png\"\n status=\"error\"\n />\n <FileCard\n name=\"clip.mp4\"\n type=\"video\"\n src=\"https://example.com/clip.mp4\"\n status=\"error\"\n errorText=\"\u4E0A\u4F20\u5931\u8D25\"\n />\n </div>\n ";
|
|
512
|
+
_mount14 = mount(Demo), element = _mount14[1];
|
|
513
|
+
cards = element.querySelectorAll('.k-file-card');
|
|
514
|
+
artwork = cards[1].querySelector('.k-file-card-media-error-artwork-content');
|
|
515
|
+
icon = artwork.querySelector('.k-file-card-media-error-artwork-icon');
|
|
516
|
+
expect(cards[0].className).to.contain('k-file-card-error');
|
|
517
|
+
expect(cards[0].querySelector('img.k-media-image')).to.eql(null);
|
|
518
|
+
expect(cards[1].querySelector('video.k-media-video')).to.eql(null);
|
|
519
|
+
expect(cards[0].querySelector('.k-media-error-card')).not.to.eql(null);
|
|
520
|
+
expect(cards[1].querySelector('.k-media-error-card')).to.eql(null);
|
|
521
|
+
expect(cards[0].querySelector('.k-file-card-error-text')).to.eql(null);
|
|
522
|
+
expect((_cards$1$querySelecto3 = cards[1].querySelector('.k-file-card-error-text')) == null ? void 0 : _cards$1$querySelecto3.textContent).to.contain('上传失败');
|
|
523
|
+
expect(cards[1].className).to.contain('k-file-card-media-error-artwork');
|
|
524
|
+
expect(icon.src).to.contain('ECECEC');
|
|
525
|
+
expect(getComputedStyle(cards[0]).borderColor).not.to.eql('rgb(237, 64, 64)');
|
|
526
|
+
expect(element.querySelector('.k-media-placeholder')).to.eql(null);
|
|
527
|
+
expect(element.querySelector('.k-media-preview-trigger')).to.eql(null);
|
|
528
|
+
case 18:
|
|
529
|
+
case "end":
|
|
530
|
+
return _context28.stop();
|
|
531
|
+
}
|
|
532
|
+
}, _callee14);
|
|
533
|
+
})));
|
|
534
|
+
// 显式图片上传失败时,不再等待 src 加载失败,直接展示上传失败 artwork。
|
|
535
|
+
it('should render upload error artwork immediately for visual media with source', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
536
|
+
var _artwork$querySelecto;
|
|
537
|
+
var Demo, _mount15, element, artwork;
|
|
538
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context30) {
|
|
539
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
540
|
+
case 0:
|
|
541
|
+
Demo = /*#__PURE__*/function (_Component15) {
|
|
542
|
+
_inheritsLoose(Demo, _Component15);
|
|
543
|
+
function Demo() {
|
|
544
|
+
var _context29;
|
|
545
|
+
var _this15;
|
|
546
|
+
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
|
547
|
+
args[_key15] = arguments[_key15];
|
|
548
|
+
}
|
|
549
|
+
_this15 = _Component15.call.apply(_Component15, _concatInstanceProperty(_context29 = [this]).call(_context29, args)) || this;
|
|
550
|
+
_this15.FileCard = FileCard;
|
|
551
|
+
return _this15;
|
|
552
|
+
}
|
|
553
|
+
return Demo;
|
|
554
|
+
}(Component);
|
|
555
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n src=\"https://example.com/cover.png\"\n status=\"error\"\n errorText=\"\u4E0A\u4F20\u5931\u8D25\"\n />\n </div>\n ";
|
|
556
|
+
_mount15 = mount(Demo), element = _mount15[1];
|
|
557
|
+
artwork = element.querySelector('.k-file-card-media-error-artwork-content');
|
|
558
|
+
expect(artwork).not.to.eql(null);
|
|
559
|
+
expect(element.querySelector('img.k-media-image')).to.eql(null);
|
|
560
|
+
expect(element.querySelector('.k-file-card-media-status-layer')).to.eql(null);
|
|
561
|
+
expect((_artwork$querySelecto = artwork.querySelector('.k-file-card-error-text')) == null ? void 0 : _artwork$querySelecto.textContent).to.contain('上传失败');
|
|
562
|
+
case 8:
|
|
563
|
+
case "end":
|
|
564
|
+
return _context30.stop();
|
|
565
|
+
}
|
|
566
|
+
}, _callee15);
|
|
567
|
+
})));
|
|
568
|
+
// 无 src 的显式媒体错误态使用灰色图标,错误文案仅在指定 errorText 时展示。
|
|
569
|
+
it('should render gray media error icon and show text only when errorText is specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
570
|
+
var Demo, _mount16, element, cards, shell, artwork, text, icon, style, artworkStyle;
|
|
571
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context32) {
|
|
572
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
573
|
+
case 0:
|
|
574
|
+
Demo = /*#__PURE__*/function (_Component16) {
|
|
575
|
+
_inheritsLoose(Demo, _Component16);
|
|
576
|
+
function Demo() {
|
|
577
|
+
var _context31;
|
|
578
|
+
var _this16;
|
|
579
|
+
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
|
580
|
+
args[_key16] = arguments[_key16];
|
|
581
|
+
}
|
|
582
|
+
_this16 = _Component16.call.apply(_Component16, _concatInstanceProperty(_context31 = [this]).call(_context31, args)) || this;
|
|
583
|
+
_this16.FileCard = FileCard;
|
|
584
|
+
return _this16;
|
|
585
|
+
}
|
|
586
|
+
return Demo;
|
|
587
|
+
}(Component);
|
|
588
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n status=\"error\"\n errorText=\"\u4E0A\u4F20\u5931\u8D25\"\n />\n <FileCard\n name=\"clip.mp4\"\n type=\"video\"\n status=\"error\"\n />\n </div>\n ";
|
|
589
|
+
_mount16 = mount(Demo), element = _mount16[1];
|
|
590
|
+
cards = element.querySelectorAll('.k-file-card');
|
|
591
|
+
shell = cards[0].querySelector('.k-file-card-media-view .k-media-shell');
|
|
592
|
+
artwork = cards[0].querySelector('.k-file-card-media-error-artwork-content');
|
|
593
|
+
text = artwork.querySelector('.k-file-card-error-text');
|
|
594
|
+
icon = artwork.querySelector('.k-file-card-media-error-artwork-icon');
|
|
595
|
+
style = getComputedStyle(shell);
|
|
596
|
+
artworkStyle = getComputedStyle(artwork);
|
|
597
|
+
expect(style.boxShadow).to.eql('none');
|
|
598
|
+
expect(getComputedStyle(cards[0]).borderColor).not.to.eql('rgb(237, 64, 64)');
|
|
599
|
+
expect(style.borderTopColor).not.to.eql('rgb(237, 64, 64)');
|
|
600
|
+
expect(artwork).not.to.eql(null);
|
|
601
|
+
expect(icon.src).to.contain('ECECEC');
|
|
602
|
+
expect(text == null ? void 0 : text.textContent).to.contain('上传失败');
|
|
603
|
+
expect(artworkStyle.display).to.eql('flex');
|
|
604
|
+
expect(artworkStyle.flexDirection).to.eql('column');
|
|
605
|
+
expect(artworkStyle.alignItems).to.eql('center');
|
|
606
|
+
expect(artworkStyle.justifyContent).to.eql('center');
|
|
607
|
+
expect(artworkStyle.gap).to.eql('4px');
|
|
608
|
+
expect(getComputedStyle(icon).width).to.eql('32px');
|
|
609
|
+
expect(getComputedStyle(icon).height).to.eql('32px');
|
|
610
|
+
expect(getComputedStyle(text).color).to.eql('rgb(255, 68, 51)');
|
|
611
|
+
expect(cards[0].className).to.contain('k-file-card-media-error-artwork');
|
|
612
|
+
expect(cards[1].querySelector('.k-file-card-error-text')).to.eql(null);
|
|
613
|
+
expect(cards[1].querySelector('.k-file-card-media-error-artwork-content')).to.eql(null);
|
|
614
|
+
expect(cards[1].querySelector('.k-media-error-card')).not.to.eql(null);
|
|
615
|
+
case 28:
|
|
616
|
+
case "end":
|
|
617
|
+
return _context32.stop();
|
|
618
|
+
}
|
|
619
|
+
}, _callee16);
|
|
620
|
+
})));
|
|
621
|
+
// 显式视频在 mini 尺寸下,percent 仍会展示进度文本。
|
|
622
|
+
it('should show video progress text in mini size when percent is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
|
623
|
+
var _element$querySelecto11;
|
|
624
|
+
var Demo, _mount17, element;
|
|
625
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context34) {
|
|
626
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
627
|
+
case 0:
|
|
628
|
+
Demo = /*#__PURE__*/function (_Component17) {
|
|
629
|
+
_inheritsLoose(Demo, _Component17);
|
|
630
|
+
function Demo() {
|
|
631
|
+
var _context33;
|
|
632
|
+
var _this17;
|
|
633
|
+
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
|
634
|
+
args[_key17] = arguments[_key17];
|
|
635
|
+
}
|
|
636
|
+
_this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context33 = [this]).call(_context33, args)) || this;
|
|
637
|
+
_this17.FileCard = FileCard;
|
|
638
|
+
return _this17;
|
|
639
|
+
}
|
|
640
|
+
return Demo;
|
|
641
|
+
}(Component);
|
|
642
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"result.mp4\"\n type=\"video\"\n size=\"mini\"\n status=\"loading\"\n percent={56}\n src=\"https://example.com/result.mp4\"\n />\n </div>\n ";
|
|
643
|
+
_mount17 = mount(Demo), element = _mount17[1];
|
|
644
|
+
expect((_element$querySelecto11 = element.querySelector('.k-file-card-media-progress-text')) == null ? void 0 : _element$querySelecto11.textContent).to.contain('56%');
|
|
645
|
+
case 4:
|
|
646
|
+
case "end":
|
|
647
|
+
return _context34.stop();
|
|
648
|
+
}
|
|
649
|
+
}, _callee17);
|
|
650
|
+
})));
|
|
651
|
+
// 文件行卡片 loading 时不展示 hover mask,避免和进度/状态层冲突。
|
|
652
|
+
it('should not render file mask slot when status is loading', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
653
|
+
var Demo, _mount18, element, mask;
|
|
654
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context36) {
|
|
655
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
656
|
+
case 0:
|
|
657
|
+
Demo = /*#__PURE__*/function (_Component18) {
|
|
658
|
+
_inheritsLoose(Demo, _Component18);
|
|
659
|
+
function Demo() {
|
|
660
|
+
var _context35;
|
|
661
|
+
var _this18;
|
|
662
|
+
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
|
663
|
+
args[_key18] = arguments[_key18];
|
|
664
|
+
}
|
|
665
|
+
_this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context35 = [this]).call(_context35, args)) || this;
|
|
666
|
+
_this18.FileCard = FileCard;
|
|
667
|
+
return _this18;
|
|
668
|
+
}
|
|
669
|
+
return Demo;
|
|
670
|
+
}(Component);
|
|
671
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"a.pdf\"\n type=\"file\"\n status=\"loading\"\n >\n <b:mask>\n <span class=\"mask-content\">\u64CD\u4F5C\u533A</span>\n </b:mask>\n </FileCard>\n </div>\n ";
|
|
672
|
+
_mount18 = mount(Demo), element = _mount18[1];
|
|
673
|
+
mask = element.querySelector('.k-file-card-file-mask');
|
|
674
|
+
expect(mask).to.eql(null);
|
|
675
|
+
expect(element.querySelector('.mask-content')).to.eql(null);
|
|
676
|
+
case 6:
|
|
677
|
+
case "end":
|
|
678
|
+
return _context36.stop();
|
|
679
|
+
}
|
|
680
|
+
}, _callee18);
|
|
681
|
+
})));
|
|
682
|
+
// 文件行的 description/mask 插槽为空时,不保留空描述行和空遮罩层。
|
|
683
|
+
it('should not render wrappers for empty file description and mask slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
684
|
+
var Demo, _mount19, element;
|
|
685
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context38) {
|
|
686
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
687
|
+
case 0:
|
|
688
|
+
Demo = /*#__PURE__*/function (_Component19) {
|
|
689
|
+
_inheritsLoose(Demo, _Component19);
|
|
690
|
+
function Demo() {
|
|
691
|
+
var _context37;
|
|
692
|
+
var _this19;
|
|
693
|
+
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
|
694
|
+
args[_key19] = arguments[_key19];
|
|
695
|
+
}
|
|
696
|
+
_this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context37 = [this]).call(_context37, args)) || this;
|
|
697
|
+
_this19.FileCard = FileCard;
|
|
698
|
+
return _this19;
|
|
699
|
+
}
|
|
700
|
+
return Demo;
|
|
701
|
+
}(Component);
|
|
702
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"a.pdf\"\n type=\"file\"\n >\n <b:description>\n <span v-if={false} class=\"empty-description\">\u63CF\u8FF0</span>\n </b:description>\n <b:mask>\n <span v-if={false} class=\"empty-mask\">\u64CD\u4F5C</span>\n </b:mask>\n </FileCard>\n </div>\n ";
|
|
703
|
+
_mount19 = mount(Demo), element = _mount19[1];
|
|
704
|
+
expect(element.querySelector('.k-file-card-description')).to.eql(null);
|
|
705
|
+
expect(element.querySelector('.k-file-card-file-mask')).to.eql(null);
|
|
706
|
+
case 5:
|
|
707
|
+
case "end":
|
|
708
|
+
return _context38.stop();
|
|
709
|
+
}
|
|
710
|
+
}, _callee19);
|
|
711
|
+
})));
|
|
712
|
+
// 显式媒体卡片会将 mask 扩展点透传给 Media,并由自定义按钮触发预览。
|
|
713
|
+
it('should forward mask slot to media card and open preview via mask action', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
|
|
714
|
+
var _getElement;
|
|
715
|
+
var Demo, _mount20, instance, element, button;
|
|
716
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context40) {
|
|
717
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
718
|
+
case 0:
|
|
719
|
+
Demo = /*#__PURE__*/function (_Component20) {
|
|
720
|
+
_inheritsLoose(Demo, _Component20);
|
|
721
|
+
function Demo() {
|
|
722
|
+
var _context39;
|
|
723
|
+
var _this20;
|
|
724
|
+
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
|
725
|
+
args[_key20] = arguments[_key20];
|
|
726
|
+
}
|
|
727
|
+
_this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context39 = [this]).call(_context39, args)) || this;
|
|
728
|
+
_this20.FileCard = FileCard;
|
|
729
|
+
return _this20;
|
|
730
|
+
}
|
|
731
|
+
Demo.defaults = function defaults() {
|
|
732
|
+
return {
|
|
733
|
+
previewCount: 0
|
|
734
|
+
};
|
|
735
|
+
};
|
|
736
|
+
return Demo;
|
|
737
|
+
}(Component);
|
|
738
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n status=\"done\"\n src=\"https://example.com/cover.png\"\n ev-preview={() => this.set('previewCount', this.get('previewCount') + 1)}\n >\n <b:mask args=\"media\">\n <button\n class=\"media-mask-open\"\n type=\"button\"\n disabled={!media.canPreview}\n ev-click={media.preview}\n >open</button>\n </b:mask>\n </FileCard>\n </div>\n ";
|
|
739
|
+
_mount20 = mount(Demo), instance = _mount20[0], element = _mount20[1];
|
|
740
|
+
button = element.querySelector('.media-mask-open');
|
|
741
|
+
expect(button).not.to.eql(null);
|
|
742
|
+
expect(element.querySelector('.k-media-preview-trigger')).to.eql(null);
|
|
743
|
+
button.click();
|
|
744
|
+
_context40.next = 9;
|
|
745
|
+
return wait();
|
|
746
|
+
case 9:
|
|
747
|
+
expect(instance.get('previewCount')).to.eql(1);
|
|
748
|
+
expect(getElement('.k-media-viewer')).not.to.eql(null);
|
|
749
|
+
expect((_getElement = getElement('.k-media-viewer-title')) == null ? void 0 : _getElement.textContent).to.contain('cover.png');
|
|
750
|
+
case 12:
|
|
751
|
+
case "end":
|
|
752
|
+
return _context40.stop();
|
|
753
|
+
}
|
|
754
|
+
}, _callee20);
|
|
755
|
+
})));
|
|
756
|
+
// 显式音频媒体仅在有 loading 文案或进度时展示 loading 蒙层,文案颜色与图片/视频一致。
|
|
757
|
+
it('should render audio loading overlay only when status text or progress is visible', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
|
|
758
|
+
var _textAudio$querySelec;
|
|
759
|
+
var Demo, _mount21, element, emptyAudio, textAudio, loadingText;
|
|
760
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context42) {
|
|
761
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
762
|
+
case 0:
|
|
763
|
+
Demo = /*#__PURE__*/function (_Component21) {
|
|
764
|
+
_inheritsLoose(Demo, _Component21);
|
|
765
|
+
function Demo() {
|
|
766
|
+
var _context41;
|
|
767
|
+
var _this21;
|
|
768
|
+
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
|
769
|
+
args[_key21] = arguments[_key21];
|
|
770
|
+
}
|
|
771
|
+
_this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context41 = [this]).call(_context41, args)) || this;
|
|
772
|
+
_this21.FileCard = FileCard;
|
|
773
|
+
return _this21;
|
|
774
|
+
}
|
|
775
|
+
return Demo;
|
|
776
|
+
}(Component);
|
|
777
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n className=\"audio-loading-empty\"\n name=\"plain.mp3\"\n type=\"audio\"\n status=\"loading\"\n src=\"https://example.com/plain.mp3\"\n />\n <FileCard\n className=\"audio-loading-text\"\n name=\"voice.mp3\"\n type=\"audio\"\n status=\"loading\"\n loadingText=\"\u4E0A\u4F20\u4E2D\"\n percent={37}\n src=\"https://example.com/voice.mp3\"\n />\n </div>\n ";
|
|
778
|
+
_mount21 = mount(Demo), element = _mount21[1];
|
|
779
|
+
emptyAudio = element.querySelector('.audio-loading-empty');
|
|
780
|
+
textAudio = element.querySelector('.audio-loading-text');
|
|
781
|
+
loadingText = textAudio.querySelector('.k-file-card-media-loading-text');
|
|
782
|
+
expect(emptyAudio.querySelector('.k-file-card-media-loading-overlay')).to.eql(null);
|
|
783
|
+
expect(textAudio.querySelector('.k-file-card-media-loading-overlay')).not.to.eql(null);
|
|
784
|
+
expect(textAudio.querySelector('.k-media-loading-overlay')).to.eql(null);
|
|
785
|
+
expect(textAudio.querySelector('.k-media-loading-indicator')).not.to.eql(null);
|
|
786
|
+
expect(loadingText.textContent).to.contain('上传中');
|
|
787
|
+
expect(getComputedStyle(loadingText).color).to.eql('rgb(255, 255, 255)');
|
|
788
|
+
expect((_textAudio$querySelec = textAudio.querySelector('.k-file-card-media-progress-text')) == null ? void 0 : _textAudio$querySelec.textContent).to.contain('37%');
|
|
789
|
+
expect(textAudio.querySelector('.k-media-preview-trigger')).to.eql(null);
|
|
790
|
+
case 14:
|
|
791
|
+
case "end":
|
|
792
|
+
return _context42.stop();
|
|
793
|
+
}
|
|
794
|
+
}, _callee21);
|
|
795
|
+
})));
|
|
796
|
+
// 小尺寸媒体卡片不展示居中的 loading 文案。
|
|
797
|
+
it('should hide loading text in compact image and video cards', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
|
|
798
|
+
var Demo, _mount22, element;
|
|
799
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context44) {
|
|
800
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
801
|
+
case 0:
|
|
802
|
+
Demo = /*#__PURE__*/function (_Component22) {
|
|
803
|
+
_inheritsLoose(Demo, _Component22);
|
|
804
|
+
function Demo() {
|
|
805
|
+
var _context43;
|
|
806
|
+
var _this22;
|
|
807
|
+
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
|
808
|
+
args[_key22] = arguments[_key22];
|
|
809
|
+
}
|
|
810
|
+
_this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
|
|
811
|
+
_this22.FileCard = FileCard;
|
|
812
|
+
return _this22;
|
|
813
|
+
}
|
|
814
|
+
return Demo;
|
|
815
|
+
}(Component);
|
|
816
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n size=\"small\"\n status=\"loading\"\n src=\"https://example.com/cover.png\"\n />\n <FileCard\n name=\"clip.mp4\"\n type=\"video\"\n size=\"mini\"\n status=\"loading\"\n src=\"https://example.com/clip.mp4\"\n />\n </div>\n ";
|
|
817
|
+
_mount22 = mount(Demo), element = _mount22[1];
|
|
818
|
+
expect(element.querySelectorAll('.k-file-card-media-loading-text').length).to.eql(0);
|
|
819
|
+
expect(getElement('.k-tooltip-content')).to.not.exist;
|
|
820
|
+
case 5:
|
|
821
|
+
case "end":
|
|
822
|
+
return _context44.stop();
|
|
823
|
+
}
|
|
824
|
+
}, _callee22);
|
|
825
|
+
})));
|
|
826
|
+
// 音频 error 文案仅在指定 errorText 时展示,mini 尺寸不展示文案。
|
|
827
|
+
it('should render audio error artwork when errorText is specified and hide text in mini size', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
|
|
828
|
+
var _cards$0$querySelecto3;
|
|
829
|
+
var Demo, _mount23, element, cards, artwork, icon;
|
|
830
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context46) {
|
|
831
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
832
|
+
case 0:
|
|
833
|
+
Demo = /*#__PURE__*/function (_Component23) {
|
|
834
|
+
_inheritsLoose(Demo, _Component23);
|
|
835
|
+
function Demo() {
|
|
836
|
+
var _context45;
|
|
837
|
+
var _this23;
|
|
838
|
+
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
|
839
|
+
args[_key23] = arguments[_key23];
|
|
840
|
+
}
|
|
841
|
+
_this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
|
|
842
|
+
_this23.FileCard = FileCard;
|
|
843
|
+
return _this23;
|
|
844
|
+
}
|
|
845
|
+
return Demo;
|
|
846
|
+
}(Component);
|
|
847
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"voice.mp3\"\n type=\"audio\"\n status=\"error\"\n errorText=\"\u4E0A\u4F20\u5931\u8D25\"\n src=\"https://example.com/voice.mp3\"\n />\n <FileCard\n name=\"voice-mini.mp3\"\n type=\"audio\"\n size=\"mini\"\n status=\"error\"\n errorText=\"\u4E0A\u4F20\u5931\u8D25\"\n src=\"https://example.com/voice-mini.mp3\"\n />\n </div>\n ";
|
|
848
|
+
_mount23 = mount(Demo), element = _mount23[1];
|
|
849
|
+
cards = element.querySelectorAll('.k-file-card');
|
|
850
|
+
artwork = cards[0].querySelector('.k-file-card-media-error-artwork-content');
|
|
851
|
+
icon = artwork.querySelector('.k-file-card-media-error-artwork-icon');
|
|
852
|
+
expect((_cards$0$querySelecto3 = cards[0].querySelector('.k-file-card-error-text')) == null ? void 0 : _cards$0$querySelecto3.textContent).to.contain('上传失败');
|
|
853
|
+
expect(getComputedStyle(artwork).gap).to.eql('4px');
|
|
854
|
+
expect(cards[0].querySelector('.k-file-card-media-status-layer')).to.eql(null);
|
|
855
|
+
expect(cards[0].className).to.contain('k-file-card-media-error-artwork');
|
|
856
|
+
expect(icon.src).to.contain('ECECEC');
|
|
857
|
+
expect(cards[1].querySelector('.k-file-card-error-text')).to.eql(null);
|
|
858
|
+
expect(cards[1].querySelector('.k-file-card-media-error-artwork-content')).to.eql(null);
|
|
859
|
+
case 13:
|
|
860
|
+
case "end":
|
|
861
|
+
return _context46.stop();
|
|
862
|
+
}
|
|
863
|
+
}, _callee23);
|
|
864
|
+
})));
|
|
865
|
+
// 删除按钮位于右上角外侧,并阻止触发卡片点击。
|
|
866
|
+
it('should render corner delete button and trigger delete only', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
|
|
867
|
+
var calls, Demo, _mount24, element, button, style;
|
|
868
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context48) {
|
|
869
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
870
|
+
case 0:
|
|
871
|
+
calls = [];
|
|
872
|
+
Demo = /*#__PURE__*/function (_Component24) {
|
|
873
|
+
_inheritsLoose(Demo, _Component24);
|
|
874
|
+
function Demo() {
|
|
875
|
+
var _context47;
|
|
876
|
+
var _this24;
|
|
877
|
+
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
|
878
|
+
args[_key24] = arguments[_key24];
|
|
879
|
+
}
|
|
880
|
+
_this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context47 = [this]).call(_context47, args)) || this;
|
|
881
|
+
_this24.FileCard = FileCard;
|
|
882
|
+
_this24.onClick = function () {
|
|
883
|
+
calls.push('click');
|
|
884
|
+
};
|
|
885
|
+
_this24.onDelete = function () {
|
|
886
|
+
calls.push('delete');
|
|
887
|
+
};
|
|
888
|
+
return _this24;
|
|
889
|
+
}
|
|
890
|
+
return Demo;
|
|
891
|
+
}(Component);
|
|
892
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"spec.pdf\"\n showDelIcon\n ev-click={this.onClick}\n ev-delete={this.onDelete}\n />\n </div>\n ";
|
|
893
|
+
_mount24 = mount(Demo), element = _mount24[1];
|
|
894
|
+
button = element.querySelector('.k-file-card-delete');
|
|
895
|
+
style = getComputedStyle(button);
|
|
896
|
+
button.click();
|
|
897
|
+
_context48.next = 9;
|
|
898
|
+
return wait();
|
|
899
|
+
case 9:
|
|
900
|
+
expect(button.tagName).to.eql('DIV');
|
|
901
|
+
expect(button.className).not.to.contain('k-btn');
|
|
902
|
+
expect(style.top).to.eql('2px');
|
|
903
|
+
expect(style.right).to.eql('2px');
|
|
904
|
+
expect(style.zIndex).to.eql('5');
|
|
905
|
+
expect(style.transform).to.eql('none');
|
|
906
|
+
expect(calls).to.eql(['delete']);
|
|
907
|
+
case 16:
|
|
908
|
+
case "end":
|
|
909
|
+
return _context48.stop();
|
|
910
|
+
}
|
|
911
|
+
}, _callee24);
|
|
912
|
+
})));
|
|
913
|
+
// 视频卡片的播放触发器覆盖在卡片中间,删除按钮需要保持更高层级。
|
|
914
|
+
it('should keep video delete button above preview trigger and not open preview', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
|
|
915
|
+
var calls, Demo, _mount25, element, button, previewTrigger;
|
|
916
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context50) {
|
|
917
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
918
|
+
case 0:
|
|
919
|
+
calls = [];
|
|
920
|
+
Demo = /*#__PURE__*/function (_Component25) {
|
|
921
|
+
_inheritsLoose(Demo, _Component25);
|
|
922
|
+
function Demo() {
|
|
923
|
+
var _context49;
|
|
924
|
+
var _this25;
|
|
925
|
+
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
|
|
926
|
+
args[_key25] = arguments[_key25];
|
|
927
|
+
}
|
|
928
|
+
_this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context49 = [this]).call(_context49, args)) || this;
|
|
929
|
+
_this25.FileCard = FileCard;
|
|
930
|
+
_this25.onClick = function () {
|
|
931
|
+
calls.push('click');
|
|
932
|
+
};
|
|
933
|
+
_this25.onPreview = function () {
|
|
934
|
+
calls.push('preview');
|
|
935
|
+
};
|
|
936
|
+
_this25.onDelete = function () {
|
|
937
|
+
calls.push('delete');
|
|
938
|
+
};
|
|
939
|
+
return _this25;
|
|
940
|
+
}
|
|
941
|
+
return Demo;
|
|
942
|
+
}(Component);
|
|
943
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"clip.mp4\"\n type=\"video\"\n status=\"done\"\n src=\"https://example.com/clip.mp4\"\n showDelIcon\n ev-click={this.onClick}\n ev-preview={this.onPreview}\n ev-delete={this.onDelete}\n />\n </div>\n ";
|
|
944
|
+
_mount25 = mount(Demo), element = _mount25[1];
|
|
945
|
+
button = element.querySelector('.k-file-card-delete');
|
|
946
|
+
previewTrigger = element.querySelector('.k-media-video-preview-trigger');
|
|
947
|
+
expect(+getComputedStyle(button).zIndex).to.be.greaterThan(+getComputedStyle(previewTrigger).zIndex);
|
|
948
|
+
button.click();
|
|
949
|
+
_context50.next = 10;
|
|
950
|
+
return wait();
|
|
951
|
+
case 10:
|
|
952
|
+
expect(calls).to.eql(['delete']);
|
|
953
|
+
expectViewerClosed();
|
|
954
|
+
case 12:
|
|
955
|
+
case "end":
|
|
956
|
+
return _context50.stop();
|
|
957
|
+
}
|
|
958
|
+
}, _callee25);
|
|
959
|
+
})));
|
|
960
|
+
// 媒体预览由内部 Media 负责,同时 FileCard 继续抛出 preview 事件。
|
|
961
|
+
it('should preview media through Media viewer and trigger preview event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
|
|
962
|
+
var _getElement2;
|
|
963
|
+
var Demo, _mount26, instance, element, previewTrigger;
|
|
964
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context52) {
|
|
965
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
966
|
+
case 0:
|
|
967
|
+
Demo = /*#__PURE__*/function (_Component26) {
|
|
968
|
+
_inheritsLoose(Demo, _Component26);
|
|
969
|
+
function Demo() {
|
|
970
|
+
var _context51;
|
|
971
|
+
var _this26;
|
|
972
|
+
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
|
|
973
|
+
args[_key26] = arguments[_key26];
|
|
974
|
+
}
|
|
975
|
+
_this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context51 = [this]).call(_context51, args)) || this;
|
|
976
|
+
_this26.FileCard = FileCard;
|
|
977
|
+
return _this26;
|
|
978
|
+
}
|
|
979
|
+
Demo.defaults = function defaults() {
|
|
980
|
+
return {
|
|
981
|
+
previewCount: 0
|
|
982
|
+
};
|
|
983
|
+
};
|
|
984
|
+
return Demo;
|
|
985
|
+
}(Component);
|
|
986
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard\n name=\"cover.png\"\n type=\"image\"\n status=\"done\"\n src=\"https://example.com/cover.png\"\n ev-preview={() => this.set('previewCount', this.get('previewCount') + 1)}\n />\n </div>\n ";
|
|
987
|
+
_mount26 = mount(Demo), instance = _mount26[0], element = _mount26[1];
|
|
988
|
+
previewTrigger = element.querySelector('.k-media-preview-trigger');
|
|
989
|
+
previewTrigger.click();
|
|
990
|
+
_context52.next = 7;
|
|
991
|
+
return wait();
|
|
992
|
+
case 7:
|
|
993
|
+
expect(instance.get('previewCount')).to.eql(1);
|
|
994
|
+
expect(getElement('.k-media-viewer')).not.to.eql(null);
|
|
995
|
+
expect((_getElement2 = getElement('.k-media-viewer-title')) == null ? void 0 : _getElement2.textContent).to.contain('cover.png');
|
|
996
|
+
case 10:
|
|
997
|
+
case "end":
|
|
998
|
+
return _context52.stop();
|
|
999
|
+
}
|
|
1000
|
+
}, _callee26);
|
|
1001
|
+
})));
|
|
1002
|
+
// showPreview=false 会同步关闭显式媒体和文件行媒体缩略图的预览入口。
|
|
1003
|
+
it('should disable preview for media and file media thumbnail', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
|
|
1004
|
+
var Demo, _mount27, element;
|
|
1005
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context54) {
|
|
1006
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
1007
|
+
case 0:
|
|
1008
|
+
Demo = /*#__PURE__*/function (_Component27) {
|
|
1009
|
+
_inheritsLoose(Demo, _Component27);
|
|
1010
|
+
function Demo() {
|
|
1011
|
+
var _context53;
|
|
1012
|
+
var _this27;
|
|
1013
|
+
for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
|
|
1014
|
+
args[_key27] = arguments[_key27];
|
|
1015
|
+
}
|
|
1016
|
+
_this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context53 = [this]).call(_context53, args)) || this;
|
|
1017
|
+
_this27.FileCard = FileCard;
|
|
1018
|
+
return _this27;
|
|
1019
|
+
}
|
|
1020
|
+
return Demo;
|
|
1021
|
+
}(Component);
|
|
1022
|
+
Demo.template = "\n const { FileCard } = this;\n <div>\n <FileCard name=\"cover.png\" type=\"image\" status=\"done\" showPreview={false} src=\"https://example.com/cover.png\" />\n <FileCard name=\"clip.mp4\" type=\"file\" showPreview={false} src=\"https://example.com/clip.mp4\" />\n </div>\n ";
|
|
1023
|
+
_mount27 = mount(Demo), element = _mount27[1];
|
|
1024
|
+
expect(element.querySelector('.k-media-preview-trigger')).to.eql(null);
|
|
1025
|
+
case 4:
|
|
1026
|
+
case "end":
|
|
1027
|
+
return _context54.stop();
|
|
1028
|
+
}
|
|
1029
|
+
}, _callee27);
|
|
1030
|
+
})));
|
|
1031
|
+
// FileCardList 继承默认尺寸、删除开关,并透传新增的 loadingText。
|
|
1032
|
+
it('should proxy FileCardList props and events', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
|
|
1033
|
+
var _element$querySelecto12;
|
|
1034
|
+
var calls, Demo, _mount28, element, card, button;
|
|
1035
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context56) {
|
|
1036
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
1037
|
+
case 0:
|
|
1038
|
+
calls = [];
|
|
1039
|
+
Demo = /*#__PURE__*/function (_Component28) {
|
|
1040
|
+
_inheritsLoose(Demo, _Component28);
|
|
1041
|
+
function Demo() {
|
|
1042
|
+
var _context55;
|
|
1043
|
+
var _this28;
|
|
1044
|
+
for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
|
|
1045
|
+
args[_key28] = arguments[_key28];
|
|
1046
|
+
}
|
|
1047
|
+
_this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
|
|
1048
|
+
_this28.FileCardList = FileCardList;
|
|
1049
|
+
_this28.onDelete = function (item) {
|
|
1050
|
+
calls.push(item.key);
|
|
1051
|
+
};
|
|
1052
|
+
return _this28;
|
|
1053
|
+
}
|
|
1054
|
+
return Demo;
|
|
1055
|
+
}(Component);
|
|
1056
|
+
Demo.template = "\n const { FileCardList } = this;\n <FileCardList\n size=\"small\"\n deleteable\n items={[\n {key: 'a', name: 'a.pdf', status: 'loading', percent: 10, loadingText: '\u4E0A\u4F20\u4E2D'},\n ]}\n ev-delete={this.onDelete}\n />\n ";
|
|
1057
|
+
_mount28 = mount(Demo), element = _mount28[1];
|
|
1058
|
+
card = element.querySelector('.k-file-card');
|
|
1059
|
+
button = element.querySelector('.k-file-card-delete');
|
|
1060
|
+
expect(card.className).to.contain('k-file-card-small');
|
|
1061
|
+
expect((_element$querySelecto12 = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto12.textContent).to.contain('上传中... 10%');
|
|
1062
|
+
button.click();
|
|
1063
|
+
_context56.next = 11;
|
|
1064
|
+
return wait();
|
|
1065
|
+
case 11:
|
|
1066
|
+
expect(calls).to.eql(['a']);
|
|
1067
|
+
case 12:
|
|
1068
|
+
case "end":
|
|
1069
|
+
return _context56.stop();
|
|
1070
|
+
}
|
|
1071
|
+
}, _callee28);
|
|
1072
|
+
})));
|
|
1073
|
+
// FileCardList 的 prefix/suffix 插槽为空时,不保留额外 flex item。
|
|
1074
|
+
it('should not render prefix or suffix wrapper when slots are empty', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
|
|
1075
|
+
var Demo, _mount29, element;
|
|
1076
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context58) {
|
|
1077
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
1078
|
+
case 0:
|
|
1079
|
+
Demo = /*#__PURE__*/function (_Component29) {
|
|
1080
|
+
_inheritsLoose(Demo, _Component29);
|
|
1081
|
+
function Demo() {
|
|
1082
|
+
var _context57;
|
|
1083
|
+
var _this29;
|
|
1084
|
+
for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
|
|
1085
|
+
args[_key29] = arguments[_key29];
|
|
1086
|
+
}
|
|
1087
|
+
_this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context57 = [this]).call(_context57, args)) || this;
|
|
1088
|
+
_this29.FileCardList = FileCardList;
|
|
1089
|
+
return _this29;
|
|
1090
|
+
}
|
|
1091
|
+
return Demo;
|
|
1092
|
+
}(Component);
|
|
1093
|
+
Demo.template = "\n const { FileCardList } = this;\n <FileCardList\n items={[{key: 'a', name: 'a.pdf'}]}\n >\n <b:prefix>\n <button v-if={false} class=\"empty-prefix\" type=\"button\">add</button>\n </b:prefix>\n <b:suffix>\n <button v-if={false} class=\"empty-suffix\" type=\"button\">more</button>\n </b:suffix>\n </FileCardList>\n ";
|
|
1094
|
+
_mount29 = mount(Demo), element = _mount29[1];
|
|
1095
|
+
expect(element.querySelector('.k-file-card-list-prefix')).to.eql(null);
|
|
1096
|
+
expect(element.querySelector('.k-file-card-list-suffix')).to.eql(null);
|
|
1097
|
+
case 5:
|
|
1098
|
+
case "end":
|
|
1099
|
+
return _context58.stop();
|
|
1100
|
+
}
|
|
1101
|
+
}, _callee29);
|
|
1102
|
+
})));
|
|
1103
|
+
it('should render prefix before items and suffix after items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
|
|
1104
|
+
var Demo, _mount30, element, list;
|
|
1105
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context60) {
|
|
1106
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
1107
|
+
case 0:
|
|
1108
|
+
Demo = /*#__PURE__*/function (_Component30) {
|
|
1109
|
+
_inheritsLoose(Demo, _Component30);
|
|
1110
|
+
function Demo() {
|
|
1111
|
+
var _context59;
|
|
1112
|
+
var _this30;
|
|
1113
|
+
for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
|
|
1114
|
+
args[_key30] = arguments[_key30];
|
|
1115
|
+
}
|
|
1116
|
+
_this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context59 = [this]).call(_context59, args)) || this;
|
|
1117
|
+
_this30.FileCardList = FileCardList;
|
|
1118
|
+
return _this30;
|
|
1119
|
+
}
|
|
1120
|
+
return Demo;
|
|
1121
|
+
}(Component);
|
|
1122
|
+
Demo.template = "\n const { FileCardList } = this;\n <FileCardList\n items={[{key: 'a', name: 'a.pdf'}]}\n >\n <b:prefix>\n <button class=\"prefix-action\" type=\"button\">add</button>\n </b:prefix>\n <b:suffix>\n <button class=\"suffix-action\" type=\"button\">more</button>\n </b:suffix>\n </FileCardList>\n ";
|
|
1123
|
+
_mount30 = mount(Demo), element = _mount30[1];
|
|
1124
|
+
list = element.classList.contains('k-file-card-list') ? element : element.querySelector('.k-file-card-list');
|
|
1125
|
+
expect(list.children[0].className).to.contain('k-file-card-list-prefix');
|
|
1126
|
+
expect(list.children[1].className).to.contain('k-file-card');
|
|
1127
|
+
expect(list.children[2].className).to.contain('k-file-card-list-suffix');
|
|
1128
|
+
case 7:
|
|
1129
|
+
case "end":
|
|
1130
|
+
return _context60.stop();
|
|
1131
|
+
}
|
|
1132
|
+
}, _callee30);
|
|
1133
|
+
})));
|
|
1134
|
+
// 删除角标回到卡片内后,列表容器不再需要额外顶部留白。
|
|
1135
|
+
it('should not add top padding for delete icon in lists', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
1136
|
+
var Demo, _mount31, element, listWrap, listX, listY;
|
|
1137
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context62) {
|
|
1138
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
1139
|
+
case 0:
|
|
1140
|
+
Demo = /*#__PURE__*/function (_Component31) {
|
|
1141
|
+
_inheritsLoose(Demo, _Component31);
|
|
1142
|
+
function Demo() {
|
|
1143
|
+
var _context61;
|
|
1144
|
+
var _this31;
|
|
1145
|
+
for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
|
|
1146
|
+
args[_key31] = arguments[_key31];
|
|
1147
|
+
}
|
|
1148
|
+
_this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context61 = [this]).call(_context61, args)) || this;
|
|
1149
|
+
_this31.FileCardList = FileCardList;
|
|
1150
|
+
return _this31;
|
|
1151
|
+
}
|
|
1152
|
+
return Demo;
|
|
1153
|
+
}(Component);
|
|
1154
|
+
Demo.template = "\n const { FileCardList } = this;\n <div>\n <FileCardList\n className=\"wrap-list\"\n overflow=\"wrap\"\n deleteable\n items={[\n {key: 'c', name: 'c.pdf', type: 'file'},\n ]}\n />\n <FileCardList\n className=\"scroll-x-list\"\n overflow=\"scrollX\"\n deleteable\n items={[\n {key: 'a', name: 'a.pdf', type: 'file'},\n ]}\n />\n <FileCardList\n className=\"scroll-y-list\"\n overflow=\"scrollY\"\n deleteable\n items={[\n {key: 'b', name: 'b.pdf', type: 'file'},\n ]}\n />\n </div>\n ";
|
|
1155
|
+
_mount31 = mount(Demo), element = _mount31[1];
|
|
1156
|
+
listWrap = element.querySelector('.wrap-list');
|
|
1157
|
+
listX = element.querySelector('.scroll-x-list');
|
|
1158
|
+
listY = element.querySelector('.scroll-y-list');
|
|
1159
|
+
expect(getComputedStyle(listWrap).paddingTop).to.eql('0px');
|
|
1160
|
+
expect(getComputedStyle(listX).paddingTop).to.eql('0px');
|
|
1161
|
+
expect(getComputedStyle(listY).paddingTop).to.eql('0px');
|
|
1162
|
+
case 9:
|
|
1163
|
+
case "end":
|
|
1164
|
+
return _context62.stop();
|
|
1165
|
+
}
|
|
1166
|
+
}, _callee31);
|
|
1167
|
+
})));
|
|
1168
|
+
});
|