@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,2201 @@
|
|
|
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 _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
5
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
6
|
+
import _URL from "@babel/runtime-corejs3/core-js/url";
|
|
7
|
+
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
8
|
+
import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
|
|
9
|
+
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
10
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
11
|
+
import { Component } from 'intact-vue-next';
|
|
12
|
+
import { dispatchEvent, getElement, mount, unmount, wait } from '../../test/utils';
|
|
13
|
+
import { Sender } from '.';
|
|
14
|
+
function getDataTransfer(files) {
|
|
15
|
+
var dataTransfer = new DataTransfer();
|
|
16
|
+
files.forEach(function (file) {
|
|
17
|
+
return dataTransfer.items.add(file);
|
|
18
|
+
});
|
|
19
|
+
return dataTransfer;
|
|
20
|
+
}
|
|
21
|
+
function getClipboardData(files) {
|
|
22
|
+
return {
|
|
23
|
+
items: _mapInstanceProperty(files).call(files, function (file) {
|
|
24
|
+
return {
|
|
25
|
+
kind: 'file',
|
|
26
|
+
getAsFile: function getAsFile() {
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}),
|
|
31
|
+
files: files
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function createDragFileEntry(_file, name) {
|
|
35
|
+
if (name === void 0) {
|
|
36
|
+
name = _file.name;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
isFile: true,
|
|
40
|
+
isDirectory: false,
|
|
41
|
+
name: name,
|
|
42
|
+
file: function file(success) {
|
|
43
|
+
success(_file);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function createDragDirectoryEntry(name, entries) {
|
|
48
|
+
return {
|
|
49
|
+
isFile: false,
|
|
50
|
+
isDirectory: true,
|
|
51
|
+
name: name,
|
|
52
|
+
createReader: function createReader() {
|
|
53
|
+
var called = false;
|
|
54
|
+
return {
|
|
55
|
+
readEntries: function readEntries(success) {
|
|
56
|
+
if (called) {
|
|
57
|
+
success([]);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
called = true;
|
|
61
|
+
success(entries);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function getDataTransferWithEntries(entries, files) {
|
|
68
|
+
if (files === void 0) {
|
|
69
|
+
files = [];
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
types: ['Files'],
|
|
73
|
+
items: _mapInstanceProperty(entries).call(entries, function (entry) {
|
|
74
|
+
return {
|
|
75
|
+
kind: 'file',
|
|
76
|
+
webkitGetAsEntry: function webkitGetAsEntry() {
|
|
77
|
+
return entry;
|
|
78
|
+
},
|
|
79
|
+
getAsFile: function getAsFile() {
|
|
80
|
+
return entry.isFile ? null : null;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}),
|
|
84
|
+
files: files
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
describe('Sender', function () {
|
|
88
|
+
afterEach(function () {
|
|
89
|
+
unmount();
|
|
90
|
+
});
|
|
91
|
+
it('should render textarea, attachment button and send button by default', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
92
|
+
var Demo, _mount, element, sendBtn;
|
|
93
|
+
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
94
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
97
|
+
_inheritsLoose(Demo, _Component);
|
|
98
|
+
function Demo() {
|
|
99
|
+
var _context;
|
|
100
|
+
var _this;
|
|
101
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
102
|
+
args[_key] = arguments[_key];
|
|
103
|
+
}
|
|
104
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
105
|
+
_this.Sender = Sender;
|
|
106
|
+
return _this;
|
|
107
|
+
}
|
|
108
|
+
return Demo;
|
|
109
|
+
}(Component);
|
|
110
|
+
Demo.template = "const { Sender } = this; <div><Sender /></div>";
|
|
111
|
+
_mount = mount(Demo), element = _mount[1];
|
|
112
|
+
expect(element.querySelector('.k-sender')).not.to.eql(null);
|
|
113
|
+
expect(element.querySelector('.k-sender-input')).not.to.eql(null);
|
|
114
|
+
expect(element.querySelector('.k-sender-attach-btn')).not.to.eql(null);
|
|
115
|
+
expect(element.querySelector('.k-sender-input').getAttribute('placeholder')).to.eql('输入对话内容(Enter发送, Shift + Enter 换行)');
|
|
116
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
117
|
+
expect(sendBtn).not.to.eql(null);
|
|
118
|
+
// 空内容应当自动禁用发送
|
|
119
|
+
expect(sendBtn.disabled).to.eql(true);
|
|
120
|
+
case 10:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context2.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee);
|
|
125
|
+
})));
|
|
126
|
+
it('should enable send button when value is non-empty', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
127
|
+
var Demo, _mount2, instance, element, sendBtn;
|
|
128
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context4) {
|
|
129
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
Demo = /*#__PURE__*/function (_Component2) {
|
|
132
|
+
_inheritsLoose(Demo, _Component2);
|
|
133
|
+
function Demo() {
|
|
134
|
+
var _context3;
|
|
135
|
+
var _this2;
|
|
136
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
137
|
+
args[_key2] = arguments[_key2];
|
|
138
|
+
}
|
|
139
|
+
_this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
|
|
140
|
+
_this2.Sender = Sender;
|
|
141
|
+
return _this2;
|
|
142
|
+
}
|
|
143
|
+
Demo.defaults = function defaults() {
|
|
144
|
+
return {
|
|
145
|
+
value: ''
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
return Demo;
|
|
149
|
+
}(Component);
|
|
150
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender value={this.get('value')} />\n </div>\n ";
|
|
151
|
+
_mount2 = mount(Demo), instance = _mount2[0], element = _mount2[1];
|
|
152
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
153
|
+
expect(sendBtn.disabled).to.eql(true);
|
|
154
|
+
instance.set('value', '你好');
|
|
155
|
+
_context4.next = 8;
|
|
156
|
+
return wait();
|
|
157
|
+
case 8:
|
|
158
|
+
expect(sendBtn.disabled).to.eql(false);
|
|
159
|
+
case 9:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context4.stop();
|
|
162
|
+
}
|
|
163
|
+
}, _callee2);
|
|
164
|
+
})));
|
|
165
|
+
it('should trigger messageSend on Enter and clear value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
166
|
+
var sent, Demo, _mount3, instance, element, textarea;
|
|
167
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context6) {
|
|
168
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
sent = '';
|
|
171
|
+
Demo = /*#__PURE__*/function (_Component3) {
|
|
172
|
+
_inheritsLoose(Demo, _Component3);
|
|
173
|
+
function Demo() {
|
|
174
|
+
var _context5;
|
|
175
|
+
var _this3;
|
|
176
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
177
|
+
args[_key3] = arguments[_key3];
|
|
178
|
+
}
|
|
179
|
+
_this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context5 = [this]).call(_context5, args)) || this;
|
|
180
|
+
_this3.Sender = Sender;
|
|
181
|
+
_this3.onSend = function (payload) {
|
|
182
|
+
sent = payload.value;
|
|
183
|
+
};
|
|
184
|
+
return _this3;
|
|
185
|
+
}
|
|
186
|
+
Demo.defaults = function defaults() {
|
|
187
|
+
return {
|
|
188
|
+
value: 'hi'
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
return Demo;
|
|
192
|
+
}(Component);
|
|
193
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n value={this.get('value')}\n ev-$change:value={(v) => this.set('value', v)}\n ev-messageSend={this.onSend}\n />\n ";
|
|
194
|
+
_mount3 = mount(Demo), instance = _mount3[0], element = _mount3[1];
|
|
195
|
+
textarea = element.querySelector('.k-sender-input');
|
|
196
|
+
textarea.focus();
|
|
197
|
+
dispatchEvent(textarea, 'keydown', {
|
|
198
|
+
key: 'Enter',
|
|
199
|
+
keyCode: 13
|
|
200
|
+
});
|
|
201
|
+
_context6.next = 9;
|
|
202
|
+
return wait();
|
|
203
|
+
case 9:
|
|
204
|
+
expect(sent).to.eql('hi');
|
|
205
|
+
expect(instance.get('value')).to.eql('');
|
|
206
|
+
case 11:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context6.stop();
|
|
209
|
+
}
|
|
210
|
+
}, _callee3);
|
|
211
|
+
})));
|
|
212
|
+
it('should expose focus and blur methods', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
213
|
+
var Demo, _mount4, instance, element, textarea, shell;
|
|
214
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context8) {
|
|
215
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
Demo = /*#__PURE__*/function (_Component4) {
|
|
218
|
+
_inheritsLoose(Demo, _Component4);
|
|
219
|
+
function Demo() {
|
|
220
|
+
var _context7;
|
|
221
|
+
var _this4;
|
|
222
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
223
|
+
args[_key4] = arguments[_key4];
|
|
224
|
+
}
|
|
225
|
+
_this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context7 = [this]).call(_context7, args)) || this;
|
|
226
|
+
_this4.Sender = Sender;
|
|
227
|
+
_this4.senderRef = null;
|
|
228
|
+
return _this4;
|
|
229
|
+
}
|
|
230
|
+
return Demo;
|
|
231
|
+
}(Component);
|
|
232
|
+
Demo.template = "\n const { Sender } = this;\n <Sender ref={(i) => this.senderRef = i} />\n ";
|
|
233
|
+
_mount4 = mount(Demo), instance = _mount4[0], element = _mount4[1];
|
|
234
|
+
textarea = element.querySelector('.k-sender-input');
|
|
235
|
+
shell = element.querySelector('.k-sender-shell');
|
|
236
|
+
instance.senderRef.focus();
|
|
237
|
+
_context8.next = 8;
|
|
238
|
+
return wait();
|
|
239
|
+
case 8:
|
|
240
|
+
expect(document.activeElement).to.eql(textarea);
|
|
241
|
+
expect(shell.classList.contains('k-sender-active')).to.be.true;
|
|
242
|
+
// active 态叠加 backdrop-filter 与多层负 spread 阴影;Headless Chrome 下
|
|
243
|
+
// getComputedStyle(boxShadow) 会归一化为全零,无法可靠断言具体色值。
|
|
244
|
+
expect(getComputedStyle(shell).backdropFilter).to.contain('blur(4px)');
|
|
245
|
+
instance.senderRef.blur();
|
|
246
|
+
_context8.next = 14;
|
|
247
|
+
return wait();
|
|
248
|
+
case 14:
|
|
249
|
+
expect(document.activeElement).not.to.eql(textarea);
|
|
250
|
+
expect(shell.classList.contains('k-sender-active')).to.be.false;
|
|
251
|
+
expect(getComputedStyle(shell).backdropFilter).to.eql('none');
|
|
252
|
+
case 17:
|
|
253
|
+
case "end":
|
|
254
|
+
return _context8.stop();
|
|
255
|
+
}
|
|
256
|
+
}, _callee4);
|
|
257
|
+
})));
|
|
258
|
+
it('should expose submit method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
259
|
+
var sent, Demo, _mount5, instance;
|
|
260
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context10) {
|
|
261
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
262
|
+
case 0:
|
|
263
|
+
sent = '';
|
|
264
|
+
Demo = /*#__PURE__*/function (_Component5) {
|
|
265
|
+
_inheritsLoose(Demo, _Component5);
|
|
266
|
+
function Demo() {
|
|
267
|
+
var _context9;
|
|
268
|
+
var _this5;
|
|
269
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
270
|
+
args[_key5] = arguments[_key5];
|
|
271
|
+
}
|
|
272
|
+
_this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
|
|
273
|
+
_this5.Sender = Sender;
|
|
274
|
+
_this5.senderRef = null;
|
|
275
|
+
_this5.onSend = function (payload) {
|
|
276
|
+
sent = payload.value;
|
|
277
|
+
};
|
|
278
|
+
return _this5;
|
|
279
|
+
}
|
|
280
|
+
Demo.defaults = function defaults() {
|
|
281
|
+
return {
|
|
282
|
+
value: 'hello'
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
return Demo;
|
|
286
|
+
}(Component);
|
|
287
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n value={this.get('value')}\n ev-$change:value={(v) => this.set('value', v)}\n ev-messageSend={this.onSend}\n />\n ";
|
|
288
|
+
_mount5 = mount(Demo), instance = _mount5[0];
|
|
289
|
+
instance.senderRef.submit();
|
|
290
|
+
_context10.next = 7;
|
|
291
|
+
return wait();
|
|
292
|
+
case 7:
|
|
293
|
+
expect(sent).to.eql('hello');
|
|
294
|
+
expect(instance.get('value')).to.eql('');
|
|
295
|
+
case 9:
|
|
296
|
+
case "end":
|
|
297
|
+
return _context10.stop();
|
|
298
|
+
}
|
|
299
|
+
}, _callee5);
|
|
300
|
+
})));
|
|
301
|
+
it('should expose clear method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
302
|
+
var Demo, _mount6, instance;
|
|
303
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context12) {
|
|
304
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
305
|
+
case 0:
|
|
306
|
+
Demo = /*#__PURE__*/function (_Component6) {
|
|
307
|
+
_inheritsLoose(Demo, _Component6);
|
|
308
|
+
function Demo() {
|
|
309
|
+
var _context11;
|
|
310
|
+
var _this6;
|
|
311
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
312
|
+
args[_key6] = arguments[_key6];
|
|
313
|
+
}
|
|
314
|
+
_this6 = _Component6.call.apply(_Component6, _concatInstanceProperty(_context11 = [this]).call(_context11, args)) || this;
|
|
315
|
+
_this6.Sender = Sender;
|
|
316
|
+
_this6.senderRef = null;
|
|
317
|
+
return _this6;
|
|
318
|
+
}
|
|
319
|
+
Demo.defaults = function defaults() {
|
|
320
|
+
return {
|
|
321
|
+
value: 'hello',
|
|
322
|
+
attachments: [{
|
|
323
|
+
key: 'a',
|
|
324
|
+
uid: 'a',
|
|
325
|
+
name: 'note.txt',
|
|
326
|
+
status: 'done'
|
|
327
|
+
}]
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
return Demo;
|
|
331
|
+
}(Component);
|
|
332
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n value={this.get('value')}\n attachments={this.get('attachments')}\n ev-$change:value={(v) => this.set('value', v)}\n ev-$change:attachments={(attachments) => this.set('attachments', attachments)}\n />\n ";
|
|
333
|
+
_mount6 = mount(Demo), instance = _mount6[0];
|
|
334
|
+
instance.senderRef.clear();
|
|
335
|
+
_context12.next = 6;
|
|
336
|
+
return wait();
|
|
337
|
+
case 6:
|
|
338
|
+
expect(instance.get('value')).to.eql('');
|
|
339
|
+
expect(instance.get('attachments')).to.eql([]);
|
|
340
|
+
case 8:
|
|
341
|
+
case "end":
|
|
342
|
+
return _context12.stop();
|
|
343
|
+
}
|
|
344
|
+
}, _callee6);
|
|
345
|
+
})));
|
|
346
|
+
it('should abort uploading attachments when clear method is called', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
347
|
+
var aborted, Demo, revokeObjectURL, revoked, _mount7, instance;
|
|
348
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context14) {
|
|
349
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
350
|
+
case 0:
|
|
351
|
+
aborted = 0;
|
|
352
|
+
Demo = /*#__PURE__*/function (_Component7) {
|
|
353
|
+
_inheritsLoose(Demo, _Component7);
|
|
354
|
+
function Demo() {
|
|
355
|
+
var _context13;
|
|
356
|
+
var _this7;
|
|
357
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
358
|
+
args[_key7] = arguments[_key7];
|
|
359
|
+
}
|
|
360
|
+
_this7 = _Component7.call.apply(_Component7, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
|
|
361
|
+
_this7.Sender = Sender;
|
|
362
|
+
_this7.senderRef = null;
|
|
363
|
+
return _this7;
|
|
364
|
+
}
|
|
365
|
+
Demo.defaults = function defaults() {
|
|
366
|
+
return {
|
|
367
|
+
value: 'hello',
|
|
368
|
+
attachments: [{
|
|
369
|
+
key: 'a',
|
|
370
|
+
uid: 'a',
|
|
371
|
+
name: 'note.txt',
|
|
372
|
+
status: 'loading',
|
|
373
|
+
src: 'blob:test',
|
|
374
|
+
request: {
|
|
375
|
+
abort: function abort() {
|
|
376
|
+
aborted++;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}]
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
return Demo;
|
|
383
|
+
}(Component);
|
|
384
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n value={this.get('value')}\n attachments={this.get('attachments')}\n ev-$change:value={(v) => this.set('value', v)}\n ev-$change:attachments={(attachments) => this.set('attachments', attachments)}\n />\n ";
|
|
385
|
+
revokeObjectURL = _URL.revokeObjectURL;
|
|
386
|
+
revoked = '';
|
|
387
|
+
_URL.revokeObjectURL = function (url) {
|
|
388
|
+
revoked = url;
|
|
389
|
+
};
|
|
390
|
+
_mount7 = mount(Demo), instance = _mount7[0];
|
|
391
|
+
instance.senderRef.clear();
|
|
392
|
+
_context14.next = 10;
|
|
393
|
+
return wait();
|
|
394
|
+
case 10:
|
|
395
|
+
expect(aborted).to.eql(1);
|
|
396
|
+
expect(revoked).to.eql('blob:test');
|
|
397
|
+
expect(instance.get('value')).to.eql('');
|
|
398
|
+
expect(instance.get('attachments')).to.eql([]);
|
|
399
|
+
_URL.revokeObjectURL = revokeObjectURL;
|
|
400
|
+
case 15:
|
|
401
|
+
case "end":
|
|
402
|
+
return _context14.stop();
|
|
403
|
+
}
|
|
404
|
+
}, _callee7);
|
|
405
|
+
})));
|
|
406
|
+
it('should expose stopGenerate method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
407
|
+
var stopped, Demo, _mount8, instance;
|
|
408
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context16) {
|
|
409
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
410
|
+
case 0:
|
|
411
|
+
stopped = 0;
|
|
412
|
+
Demo = /*#__PURE__*/function (_Component8) {
|
|
413
|
+
_inheritsLoose(Demo, _Component8);
|
|
414
|
+
function Demo() {
|
|
415
|
+
var _context15;
|
|
416
|
+
var _this8;
|
|
417
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
418
|
+
args[_key8] = arguments[_key8];
|
|
419
|
+
}
|
|
420
|
+
_this8 = _Component8.call.apply(_Component8, _concatInstanceProperty(_context15 = [this]).call(_context15, args)) || this;
|
|
421
|
+
_this8.Sender = Sender;
|
|
422
|
+
_this8.senderRef = null;
|
|
423
|
+
_this8.onStop = function () {
|
|
424
|
+
stopped++;
|
|
425
|
+
};
|
|
426
|
+
return _this8;
|
|
427
|
+
}
|
|
428
|
+
Demo.defaults = function defaults() {
|
|
429
|
+
return {
|
|
430
|
+
generating: true
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
return Demo;
|
|
434
|
+
}(Component);
|
|
435
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n generating={this.get('generating')}\n ev-stopGenerate={this.onStop}\n />\n ";
|
|
436
|
+
_mount8 = mount(Demo), instance = _mount8[0];
|
|
437
|
+
instance.senderRef.stopGenerate();
|
|
438
|
+
_context16.next = 7;
|
|
439
|
+
return wait();
|
|
440
|
+
case 7:
|
|
441
|
+
expect(stopped).to.eql(1);
|
|
442
|
+
instance.set('generating', false);
|
|
443
|
+
_context16.next = 11;
|
|
444
|
+
return wait();
|
|
445
|
+
case 11:
|
|
446
|
+
instance.senderRef.stopGenerate();
|
|
447
|
+
_context16.next = 14;
|
|
448
|
+
return wait();
|
|
449
|
+
case 14:
|
|
450
|
+
expect(stopped).to.eql(1);
|
|
451
|
+
case 15:
|
|
452
|
+
case "end":
|
|
453
|
+
return _context16.stop();
|
|
454
|
+
}
|
|
455
|
+
}, _callee8);
|
|
456
|
+
})));
|
|
457
|
+
it('should NOT submit on Shift+Enter', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
458
|
+
var sentCount, Demo, _mount9, element, textarea;
|
|
459
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context18) {
|
|
460
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
461
|
+
case 0:
|
|
462
|
+
sentCount = 0;
|
|
463
|
+
Demo = /*#__PURE__*/function (_Component9) {
|
|
464
|
+
_inheritsLoose(Demo, _Component9);
|
|
465
|
+
function Demo() {
|
|
466
|
+
var _context17;
|
|
467
|
+
var _this9;
|
|
468
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
469
|
+
args[_key9] = arguments[_key9];
|
|
470
|
+
}
|
|
471
|
+
_this9 = _Component9.call.apply(_Component9, _concatInstanceProperty(_context17 = [this]).call(_context17, args)) || this;
|
|
472
|
+
_this9.Sender = Sender;
|
|
473
|
+
_this9.onSend = function () {
|
|
474
|
+
sentCount++;
|
|
475
|
+
};
|
|
476
|
+
return _this9;
|
|
477
|
+
}
|
|
478
|
+
Demo.defaults = function defaults() {
|
|
479
|
+
return {
|
|
480
|
+
value: 'hi'
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
return Demo;
|
|
484
|
+
}(Component);
|
|
485
|
+
Demo.template = "\n const { Sender } = this;\n <Sender value={this.get('value')} ev-messageSend={this.onSend} />\n ";
|
|
486
|
+
_mount9 = mount(Demo), element = _mount9[1];
|
|
487
|
+
textarea = element.querySelector('.k-sender-input');
|
|
488
|
+
dispatchEvent(textarea, 'keydown', {
|
|
489
|
+
key: 'Enter',
|
|
490
|
+
keyCode: 13,
|
|
491
|
+
shiftKey: true
|
|
492
|
+
});
|
|
493
|
+
_context18.next = 8;
|
|
494
|
+
return wait();
|
|
495
|
+
case 8:
|
|
496
|
+
expect(sentCount).to.eql(0);
|
|
497
|
+
case 9:
|
|
498
|
+
case "end":
|
|
499
|
+
return _context18.stop();
|
|
500
|
+
}
|
|
501
|
+
}, _callee9);
|
|
502
|
+
})));
|
|
503
|
+
it('should switch to stop button when generating and trigger stopGenerate on click', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
504
|
+
var stopped, Demo, _mount10, element, sendBtn;
|
|
505
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context20) {
|
|
506
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
507
|
+
case 0:
|
|
508
|
+
stopped = 0;
|
|
509
|
+
Demo = /*#__PURE__*/function (_Component10) {
|
|
510
|
+
_inheritsLoose(Demo, _Component10);
|
|
511
|
+
function Demo() {
|
|
512
|
+
var _context19;
|
|
513
|
+
var _this10;
|
|
514
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
515
|
+
args[_key10] = arguments[_key10];
|
|
516
|
+
}
|
|
517
|
+
_this10 = _Component10.call.apply(_Component10, _concatInstanceProperty(_context19 = [this]).call(_context19, args)) || this;
|
|
518
|
+
_this10.Sender = Sender;
|
|
519
|
+
_this10.onStop = function () {
|
|
520
|
+
stopped++;
|
|
521
|
+
};
|
|
522
|
+
return _this10;
|
|
523
|
+
}
|
|
524
|
+
Demo.defaults = function defaults() {
|
|
525
|
+
return {
|
|
526
|
+
generating: true
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
return Demo;
|
|
530
|
+
}(Component);
|
|
531
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n generating={this.get('generating')}\n ev-stopGenerate={this.onStop}\n />\n ";
|
|
532
|
+
_mount10 = mount(Demo), element = _mount10[1];
|
|
533
|
+
sendBtn = element.querySelector('.k-sender-send-btn'); // 生成中按钮 title 应该为「停止生成」
|
|
534
|
+
expect(sendBtn.title).to.contain('停止');
|
|
535
|
+
// 生成中即使内容为空也是可点的
|
|
536
|
+
expect(sendBtn.disabled).to.eql(false);
|
|
537
|
+
sendBtn.click();
|
|
538
|
+
_context20.next = 10;
|
|
539
|
+
return wait();
|
|
540
|
+
case 10:
|
|
541
|
+
expect(stopped).to.eql(1);
|
|
542
|
+
case 11:
|
|
543
|
+
case "end":
|
|
544
|
+
return _context20.stop();
|
|
545
|
+
}
|
|
546
|
+
}, _callee10);
|
|
547
|
+
})));
|
|
548
|
+
it('should respect stopDisabled prop when generating', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
549
|
+
var stopped, Demo, _mount11, instance, element, sendBtn;
|
|
550
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context22) {
|
|
551
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
552
|
+
case 0:
|
|
553
|
+
stopped = 0;
|
|
554
|
+
Demo = /*#__PURE__*/function (_Component11) {
|
|
555
|
+
_inheritsLoose(Demo, _Component11);
|
|
556
|
+
function Demo() {
|
|
557
|
+
var _context21;
|
|
558
|
+
var _this11;
|
|
559
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
560
|
+
args[_key11] = arguments[_key11];
|
|
561
|
+
}
|
|
562
|
+
_this11 = _Component11.call.apply(_Component11, _concatInstanceProperty(_context21 = [this]).call(_context21, args)) || this;
|
|
563
|
+
_this11.Sender = Sender;
|
|
564
|
+
_this11.senderRef = null;
|
|
565
|
+
_this11.onStop = function () {
|
|
566
|
+
stopped++;
|
|
567
|
+
};
|
|
568
|
+
return _this11;
|
|
569
|
+
}
|
|
570
|
+
Demo.defaults = function defaults() {
|
|
571
|
+
return {
|
|
572
|
+
stopDisabled: true
|
|
573
|
+
};
|
|
574
|
+
};
|
|
575
|
+
return Demo;
|
|
576
|
+
}(Component);
|
|
577
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n generating={true}\n stopDisabled={this.get('stopDisabled')}\n ev-stopGenerate={this.onStop}\n />\n ";
|
|
578
|
+
_mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
|
|
579
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
580
|
+
expect(sendBtn.title).to.contain('停止');
|
|
581
|
+
expect(sendBtn.disabled).to.eql(true);
|
|
582
|
+
sendBtn.click();
|
|
583
|
+
_context22.next = 10;
|
|
584
|
+
return wait();
|
|
585
|
+
case 10:
|
|
586
|
+
expect(stopped).to.eql(0);
|
|
587
|
+
instance.senderRef.stopGenerate();
|
|
588
|
+
_context22.next = 14;
|
|
589
|
+
return wait();
|
|
590
|
+
case 14:
|
|
591
|
+
expect(stopped).to.eql(0);
|
|
592
|
+
instance.set('stopDisabled', false);
|
|
593
|
+
_context22.next = 18;
|
|
594
|
+
return wait();
|
|
595
|
+
case 18:
|
|
596
|
+
expect(sendBtn.disabled).to.eql(false);
|
|
597
|
+
instance.senderRef.stopGenerate();
|
|
598
|
+
_context22.next = 22;
|
|
599
|
+
return wait();
|
|
600
|
+
case 22:
|
|
601
|
+
expect(stopped).to.eql(1);
|
|
602
|
+
case 23:
|
|
603
|
+
case "end":
|
|
604
|
+
return _context22.stop();
|
|
605
|
+
}
|
|
606
|
+
}, _callee11);
|
|
607
|
+
})));
|
|
608
|
+
it('should respect disabled prop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
609
|
+
var Demo, _mount12, element, textarea, sendBtn;
|
|
610
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context24) {
|
|
611
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
612
|
+
case 0:
|
|
613
|
+
Demo = /*#__PURE__*/function (_Component12) {
|
|
614
|
+
_inheritsLoose(Demo, _Component12);
|
|
615
|
+
function Demo() {
|
|
616
|
+
var _context23;
|
|
617
|
+
var _this12;
|
|
618
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
619
|
+
args[_key12] = arguments[_key12];
|
|
620
|
+
}
|
|
621
|
+
_this12 = _Component12.call.apply(_Component12, _concatInstanceProperty(_context23 = [this]).call(_context23, args)) || this;
|
|
622
|
+
_this12.Sender = Sender;
|
|
623
|
+
return _this12;
|
|
624
|
+
}
|
|
625
|
+
return Demo;
|
|
626
|
+
}(Component);
|
|
627
|
+
Demo.template = "const { Sender } = this; <div><Sender disabled={true} value=\"hi\" /></div>";
|
|
628
|
+
_mount12 = mount(Demo), element = _mount12[1];
|
|
629
|
+
expect(element.querySelector('.k-sender').classList.contains('k-sender-disabled')).to.eql(true);
|
|
630
|
+
textarea = element.querySelector('.k-sender-input');
|
|
631
|
+
expect(textarea.disabled).to.eql(true);
|
|
632
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
633
|
+
expect(sendBtn.disabled).to.eql(true);
|
|
634
|
+
case 8:
|
|
635
|
+
case "end":
|
|
636
|
+
return _context24.stop();
|
|
637
|
+
}
|
|
638
|
+
}, _callee12);
|
|
639
|
+
})));
|
|
640
|
+
it('should respect sendDisabled prop without disabling input and upload', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
641
|
+
var sentCount, Demo, _mount13, instance, element, root, textarea, attachBtn, sendBtn;
|
|
642
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context26) {
|
|
643
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
644
|
+
case 0:
|
|
645
|
+
sentCount = 0;
|
|
646
|
+
Demo = /*#__PURE__*/function (_Component13) {
|
|
647
|
+
_inheritsLoose(Demo, _Component13);
|
|
648
|
+
function Demo() {
|
|
649
|
+
var _context25;
|
|
650
|
+
var _this13;
|
|
651
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
652
|
+
args[_key13] = arguments[_key13];
|
|
653
|
+
}
|
|
654
|
+
_this13 = _Component13.call.apply(_Component13, _concatInstanceProperty(_context25 = [this]).call(_context25, args)) || this;
|
|
655
|
+
_this13.Sender = Sender;
|
|
656
|
+
_this13.senderRef = null;
|
|
657
|
+
_this13.onSend = function () {
|
|
658
|
+
sentCount++;
|
|
659
|
+
};
|
|
660
|
+
return _this13;
|
|
661
|
+
}
|
|
662
|
+
return Demo;
|
|
663
|
+
}(Component);
|
|
664
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender\n ref={(i) => this.senderRef = i}\n sendDisabled={true}\n value=\"hi\"\n clearOnSend={false}\n ev-messageSend={this.onSend}\n />\n </div>\n ";
|
|
665
|
+
_mount13 = mount(Demo), instance = _mount13[0], element = _mount13[1];
|
|
666
|
+
root = element.querySelector('.k-sender');
|
|
667
|
+
expect(root.classList.contains('k-sender-disabled')).to.eql(false);
|
|
668
|
+
textarea = element.querySelector('.k-sender-input');
|
|
669
|
+
expect(textarea.disabled).to.eql(false);
|
|
670
|
+
attachBtn = element.querySelector('.k-sender-attach-btn');
|
|
671
|
+
expect(attachBtn.disabled).to.eql(false);
|
|
672
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
673
|
+
expect(sendBtn.disabled).to.eql(true);
|
|
674
|
+
sendBtn.click();
|
|
675
|
+
_context26.next = 15;
|
|
676
|
+
return wait();
|
|
677
|
+
case 15:
|
|
678
|
+
expect(sentCount).to.eql(0);
|
|
679
|
+
instance.senderRef.submit();
|
|
680
|
+
_context26.next = 19;
|
|
681
|
+
return wait();
|
|
682
|
+
case 19:
|
|
683
|
+
expect(sentCount).to.eql(0);
|
|
684
|
+
dispatchEvent(textarea, 'keydown', {
|
|
685
|
+
key: 'Enter',
|
|
686
|
+
keyCode: 13
|
|
687
|
+
});
|
|
688
|
+
_context26.next = 23;
|
|
689
|
+
return wait();
|
|
690
|
+
case 23:
|
|
691
|
+
expect(sentCount).to.eql(0);
|
|
692
|
+
case 24:
|
|
693
|
+
case "end":
|
|
694
|
+
return _context26.stop();
|
|
695
|
+
}
|
|
696
|
+
}, _callee13);
|
|
697
|
+
})));
|
|
698
|
+
it('should disable input interactions without disabling stop generation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
699
|
+
var sentCount, stopped, inputChanged, Demo, _mount14, instance, element, root, shell, textarea, attachBtn, sendBtn;
|
|
700
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context28) {
|
|
701
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
702
|
+
case 0:
|
|
703
|
+
sentCount = 0;
|
|
704
|
+
stopped = 0;
|
|
705
|
+
inputChanged = 0;
|
|
706
|
+
Demo = /*#__PURE__*/function (_Component14) {
|
|
707
|
+
_inheritsLoose(Demo, _Component14);
|
|
708
|
+
function Demo() {
|
|
709
|
+
var _context27;
|
|
710
|
+
var _this14;
|
|
711
|
+
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
712
|
+
args[_key14] = arguments[_key14];
|
|
713
|
+
}
|
|
714
|
+
_this14 = _Component14.call.apply(_Component14, _concatInstanceProperty(_context27 = [this]).call(_context27, args)) || this;
|
|
715
|
+
_this14.Sender = Sender;
|
|
716
|
+
_this14.senderRef = null;
|
|
717
|
+
_this14.onSend = function () {
|
|
718
|
+
sentCount++;
|
|
719
|
+
};
|
|
720
|
+
_this14.onStop = function () {
|
|
721
|
+
stopped++;
|
|
722
|
+
};
|
|
723
|
+
_this14.onInputChange = function () {
|
|
724
|
+
inputChanged++;
|
|
725
|
+
};
|
|
726
|
+
return _this14;
|
|
727
|
+
}
|
|
728
|
+
return Demo;
|
|
729
|
+
}(Component);
|
|
730
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender\n ref={(i) => this.senderRef = i}\n value=\"hi\"\n generating={true}\n inputDisabled={true}\n dragFile={true}\n pasteFile={true}\n clearOnSend={false}\n ev-messageSend={this.onSend}\n ev-stopGenerate={this.onStop}\n ev-$change:value={this.onInputChange}\n />\n </div>\n ";
|
|
731
|
+
_mount14 = mount(Demo), instance = _mount14[0], element = _mount14[1];
|
|
732
|
+
root = element.querySelector('.k-sender');
|
|
733
|
+
shell = element.querySelector('.k-sender-shell');
|
|
734
|
+
textarea = element.querySelector('.k-sender-input');
|
|
735
|
+
attachBtn = element.querySelector('.k-sender-attach-btn');
|
|
736
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
737
|
+
expect(root.classList.contains('k-sender-disabled')).to.eql(false);
|
|
738
|
+
expect(root.classList.contains('k-sender-input-disabled')).to.eql(true);
|
|
739
|
+
expect(textarea.disabled).to.eql(true);
|
|
740
|
+
expect(attachBtn.disabled).to.eql(true);
|
|
741
|
+
expect(sendBtn.title).to.contain('停止');
|
|
742
|
+
expect(sendBtn.disabled).to.eql(false);
|
|
743
|
+
expect(getComputedStyle(shell).backgroundColor).not.to.eql('rgb(255, 255, 255)');
|
|
744
|
+
dispatchEvent(textarea, 'keydown', {
|
|
745
|
+
key: 'Enter',
|
|
746
|
+
keyCode: 13
|
|
747
|
+
});
|
|
748
|
+
dispatchEvent(textarea, 'input');
|
|
749
|
+
dispatchEvent(textarea, 'paste', {
|
|
750
|
+
clipboardData: getClipboardData([new File(['a'], 'a.txt', {
|
|
751
|
+
type: 'text/plain'
|
|
752
|
+
})])
|
|
753
|
+
});
|
|
754
|
+
_context28.next = 23;
|
|
755
|
+
return wait();
|
|
756
|
+
case 23:
|
|
757
|
+
expect(sentCount).to.eql(0);
|
|
758
|
+
expect(inputChanged).to.eql(0);
|
|
759
|
+
instance.senderRef.addFiles([new File(['b'], 'b.txt', {
|
|
760
|
+
type: 'text/plain'
|
|
761
|
+
})]);
|
|
762
|
+
_context28.next = 28;
|
|
763
|
+
return wait();
|
|
764
|
+
case 28:
|
|
765
|
+
expect(instance.senderRef.get('attachments') || []).to.eql([]);
|
|
766
|
+
sendBtn.click();
|
|
767
|
+
_context28.next = 32;
|
|
768
|
+
return wait();
|
|
769
|
+
case 32:
|
|
770
|
+
expect(stopped).to.eql(1);
|
|
771
|
+
instance.senderRef.stopGenerate();
|
|
772
|
+
_context28.next = 36;
|
|
773
|
+
return wait();
|
|
774
|
+
case 36:
|
|
775
|
+
expect(stopped).to.eql(2);
|
|
776
|
+
case 37:
|
|
777
|
+
case "end":
|
|
778
|
+
return _context28.stop();
|
|
779
|
+
}
|
|
780
|
+
}, _callee14);
|
|
781
|
+
})));
|
|
782
|
+
it('should render attachments via FileCardList and emit change on delete', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
783
|
+
var lastAttachments, Demo, _mount15, element, deleteBtn;
|
|
784
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context30) {
|
|
785
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
786
|
+
case 0:
|
|
787
|
+
lastAttachments = null;
|
|
788
|
+
Demo = /*#__PURE__*/function (_Component15) {
|
|
789
|
+
_inheritsLoose(Demo, _Component15);
|
|
790
|
+
function Demo() {
|
|
791
|
+
var _context29;
|
|
792
|
+
var _this15;
|
|
793
|
+
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
|
794
|
+
args[_key15] = arguments[_key15];
|
|
795
|
+
}
|
|
796
|
+
_this15 = _Component15.call.apply(_Component15, _concatInstanceProperty(_context29 = [this]).call(_context29, args)) || this;
|
|
797
|
+
_this15.Sender = Sender;
|
|
798
|
+
_this15.onChange = function (items) {
|
|
799
|
+
lastAttachments = items;
|
|
800
|
+
};
|
|
801
|
+
return _this15;
|
|
802
|
+
}
|
|
803
|
+
Demo.defaults = function defaults() {
|
|
804
|
+
return {
|
|
805
|
+
attachments: [{
|
|
806
|
+
key: 'a',
|
|
807
|
+
uid: 'a',
|
|
808
|
+
name: 'note.txt',
|
|
809
|
+
byte: 1024,
|
|
810
|
+
status: 'done'
|
|
811
|
+
}]
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
return Demo;
|
|
815
|
+
}(Component);
|
|
816
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
817
|
+
_mount15 = mount(Demo), element = _mount15[1];
|
|
818
|
+
expect(element.querySelector('.k-sender-attachments')).not.to.eql(null);
|
|
819
|
+
expect(element.querySelectorAll('.k-file-card').length).to.eql(1);
|
|
820
|
+
deleteBtn = element.querySelector('.k-file-card-delete');
|
|
821
|
+
deleteBtn.click();
|
|
822
|
+
_context30.next = 10;
|
|
823
|
+
return wait();
|
|
824
|
+
case 10:
|
|
825
|
+
expect(lastAttachments).not.to.eql(null);
|
|
826
|
+
expect(lastAttachments.length).to.eql(0);
|
|
827
|
+
case 12:
|
|
828
|
+
case "end":
|
|
829
|
+
return _context30.stop();
|
|
830
|
+
}
|
|
831
|
+
}, _callee15);
|
|
832
|
+
})));
|
|
833
|
+
it('should expose attachment click and delete events', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
834
|
+
var _lastDeleted;
|
|
835
|
+
var clickCount, deleteCount, lastDeleted, Demo, _mount16, element, card, deleteBtn;
|
|
836
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context32) {
|
|
837
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
838
|
+
case 0:
|
|
839
|
+
clickCount = 0;
|
|
840
|
+
deleteCount = 0;
|
|
841
|
+
lastDeleted = null;
|
|
842
|
+
Demo = /*#__PURE__*/function (_Component16) {
|
|
843
|
+
_inheritsLoose(Demo, _Component16);
|
|
844
|
+
function Demo() {
|
|
845
|
+
var _context31;
|
|
846
|
+
var _this16;
|
|
847
|
+
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
|
848
|
+
args[_key16] = arguments[_key16];
|
|
849
|
+
}
|
|
850
|
+
_this16 = _Component16.call.apply(_Component16, _concatInstanceProperty(_context31 = [this]).call(_context31, args)) || this;
|
|
851
|
+
_this16.Sender = Sender;
|
|
852
|
+
_this16.onAttachmentClick = function () {
|
|
853
|
+
clickCount += 1;
|
|
854
|
+
};
|
|
855
|
+
_this16.onAttachmentDelete = function (item) {
|
|
856
|
+
deleteCount += 1;
|
|
857
|
+
lastDeleted = item;
|
|
858
|
+
};
|
|
859
|
+
return _this16;
|
|
860
|
+
}
|
|
861
|
+
Demo.defaults = function defaults() {
|
|
862
|
+
return {
|
|
863
|
+
attachments: [{
|
|
864
|
+
key: 'a',
|
|
865
|
+
uid: 'a',
|
|
866
|
+
name: 'note.txt',
|
|
867
|
+
byte: 1024,
|
|
868
|
+
status: 'done'
|
|
869
|
+
}]
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
return Demo;
|
|
873
|
+
}(Component);
|
|
874
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n ev-attachmentClick={this.onAttachmentClick}\n ev-attachmentDelete={this.onAttachmentDelete}\n />\n ";
|
|
875
|
+
_mount16 = mount(Demo), element = _mount16[1];
|
|
876
|
+
card = element.querySelector('.k-file-card');
|
|
877
|
+
card.click();
|
|
878
|
+
_context32.next = 10;
|
|
879
|
+
return wait();
|
|
880
|
+
case 10:
|
|
881
|
+
expect(clickCount).to.eql(1);
|
|
882
|
+
deleteBtn = element.querySelector('.k-file-card-delete');
|
|
883
|
+
deleteBtn.click();
|
|
884
|
+
_context32.next = 15;
|
|
885
|
+
return wait();
|
|
886
|
+
case 15:
|
|
887
|
+
expect(deleteCount).to.eql(1);
|
|
888
|
+
expect((_lastDeleted = lastDeleted) == null ? void 0 : _lastDeleted.name).to.eql('note.txt');
|
|
889
|
+
case 17:
|
|
890
|
+
case "end":
|
|
891
|
+
return _context32.stop();
|
|
892
|
+
}
|
|
893
|
+
}, _callee16);
|
|
894
|
+
})));
|
|
895
|
+
it('should expose send button slot params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
|
896
|
+
var _context34, _context35;
|
|
897
|
+
var captured, Demo, _mount17, instance, element, btn, stopBtn;
|
|
898
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context36) {
|
|
899
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
900
|
+
case 0:
|
|
901
|
+
captured = null;
|
|
902
|
+
Demo = /*#__PURE__*/function (_Component17) {
|
|
903
|
+
_inheritsLoose(Demo, _Component17);
|
|
904
|
+
function Demo() {
|
|
905
|
+
var _context33;
|
|
906
|
+
var _this17;
|
|
907
|
+
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
|
908
|
+
args[_key17] = arguments[_key17];
|
|
909
|
+
}
|
|
910
|
+
_this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context33 = [this]).call(_context33, args)) || this;
|
|
911
|
+
_this17.Sender = Sender;
|
|
912
|
+
_this17.capture = function (p) {
|
|
913
|
+
captured = p;
|
|
914
|
+
};
|
|
915
|
+
return _this17;
|
|
916
|
+
}
|
|
917
|
+
Demo.defaults = function defaults() {
|
|
918
|
+
return {
|
|
919
|
+
value: 'hi',
|
|
920
|
+
generating: false,
|
|
921
|
+
stopDisabled: false
|
|
922
|
+
};
|
|
923
|
+
};
|
|
924
|
+
return Demo;
|
|
925
|
+
}(Component);
|
|
926
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n value={this.get('value')}\n generating={this.get('generating')}\n stopDisabled={this.get('stopDisabled')}\n >\n <b:sendButton args=\"scope\">\n <button class=\"custom-send\" disabled={scope.generating ? scope.stopDisabled : scope.disabled}>\n {scope.generating ? 'STOP' : 'SEND'}\n </button>\n </b:sendButton>\n </Sender>\n ";
|
|
927
|
+
_mount17 = mount(Demo), instance = _mount17[0], element = _mount17[1];
|
|
928
|
+
btn = element.querySelector('.custom-send');
|
|
929
|
+
expect(btn).not.to.eql(null);
|
|
930
|
+
expect(_trimInstanceProperty(_context34 = btn.textContent).call(_context34)).to.eql('SEND');
|
|
931
|
+
instance.set('generating', true);
|
|
932
|
+
_context36.next = 10;
|
|
933
|
+
return wait();
|
|
934
|
+
case 10:
|
|
935
|
+
stopBtn = element.querySelector('.custom-send');
|
|
936
|
+
expect(_trimInstanceProperty(_context35 = stopBtn.textContent).call(_context35)).to.eql('STOP');
|
|
937
|
+
expect(stopBtn.disabled).to.eql(false);
|
|
938
|
+
instance.set('stopDisabled', true);
|
|
939
|
+
_context36.next = 16;
|
|
940
|
+
return wait();
|
|
941
|
+
case 16:
|
|
942
|
+
expect(stopBtn.disabled).to.eql(true);
|
|
943
|
+
case 17:
|
|
944
|
+
case "end":
|
|
945
|
+
return _context36.stop();
|
|
946
|
+
}
|
|
947
|
+
}, _callee17);
|
|
948
|
+
})));
|
|
949
|
+
it('should render tooltip for default buttons by buttonTooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
950
|
+
var Demo, _mount18, instance, element, sendBtn, stopBtn, listUpload;
|
|
951
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context38) {
|
|
952
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
953
|
+
case 0:
|
|
954
|
+
Demo = /*#__PURE__*/function (_Component18) {
|
|
955
|
+
_inheritsLoose(Demo, _Component18);
|
|
956
|
+
function Demo() {
|
|
957
|
+
var _context37;
|
|
958
|
+
var _this18;
|
|
959
|
+
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
|
960
|
+
args[_key18] = arguments[_key18];
|
|
961
|
+
}
|
|
962
|
+
_this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context37 = [this]).call(_context37, args)) || this;
|
|
963
|
+
_this18.Sender = Sender;
|
|
964
|
+
return _this18;
|
|
965
|
+
}
|
|
966
|
+
Demo.defaults = function defaults() {
|
|
967
|
+
return {
|
|
968
|
+
generating: false
|
|
969
|
+
};
|
|
970
|
+
};
|
|
971
|
+
return Demo;
|
|
972
|
+
}(Component);
|
|
973
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n value=\"hello\"\n generating={this.get('generating')}\n uploadButton=\"list\"\n buttonTooltip={{\n send: '\u53D1\u9001\u63D0\u793A',\n stop: '\u505C\u6B62\u63D0\u793A',\n upload: '\u4E0A\u4F20\u63D0\u793A',\n listUpload: '\u53C2\u8003\u63D0\u793A',\n }}\n />\n ";
|
|
974
|
+
_mount18 = mount(Demo), instance = _mount18[0], element = _mount18[1];
|
|
975
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
976
|
+
expect(sendBtn.getAttribute('title')).to.eql(null);
|
|
977
|
+
dispatchEvent(sendBtn, 'mouseenter');
|
|
978
|
+
_context38.next = 8;
|
|
979
|
+
return wait(0);
|
|
980
|
+
case 8:
|
|
981
|
+
expect(getElement('.k-tooltip-content').textContent).to.contain('发送提示');
|
|
982
|
+
dispatchEvent(sendBtn, 'mouseleave');
|
|
983
|
+
_context38.next = 12;
|
|
984
|
+
return wait(600);
|
|
985
|
+
case 12:
|
|
986
|
+
instance.set('generating', true);
|
|
987
|
+
_context38.next = 15;
|
|
988
|
+
return wait();
|
|
989
|
+
case 15:
|
|
990
|
+
stopBtn = element.querySelector('.k-sender-send-btn');
|
|
991
|
+
dispatchEvent(stopBtn, 'mouseenter');
|
|
992
|
+
_context38.next = 19;
|
|
993
|
+
return wait(0);
|
|
994
|
+
case 19:
|
|
995
|
+
expect(getElement('.k-tooltip-content').textContent).to.contain('停止提示');
|
|
996
|
+
dispatchEvent(stopBtn, 'mouseleave');
|
|
997
|
+
_context38.next = 23;
|
|
998
|
+
return wait(600);
|
|
999
|
+
case 23:
|
|
1000
|
+
listUpload = element.querySelector('.k-sender-list-upload');
|
|
1001
|
+
expect(listUpload.getAttribute('title')).to.eql(null);
|
|
1002
|
+
dispatchEvent(listUpload, 'mouseenter');
|
|
1003
|
+
_context38.next = 28;
|
|
1004
|
+
return wait(0);
|
|
1005
|
+
case 28:
|
|
1006
|
+
expect(getElement('.k-tooltip-content').textContent).to.contain('参考提示');
|
|
1007
|
+
case 29:
|
|
1008
|
+
case "end":
|
|
1009
|
+
return _context38.stop();
|
|
1010
|
+
}
|
|
1011
|
+
}, _callee18);
|
|
1012
|
+
})));
|
|
1013
|
+
it('should disable default button tooltip by false value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
1014
|
+
var Demo, _mount19, element, sendBtn, uploadBtn;
|
|
1015
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context40) {
|
|
1016
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
1017
|
+
case 0:
|
|
1018
|
+
Demo = /*#__PURE__*/function (_Component19) {
|
|
1019
|
+
_inheritsLoose(Demo, _Component19);
|
|
1020
|
+
function Demo() {
|
|
1021
|
+
var _context39;
|
|
1022
|
+
var _this19;
|
|
1023
|
+
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
|
1024
|
+
args[_key19] = arguments[_key19];
|
|
1025
|
+
}
|
|
1026
|
+
_this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context39 = [this]).call(_context39, args)) || this;
|
|
1027
|
+
_this19.Sender = Sender;
|
|
1028
|
+
return _this19;
|
|
1029
|
+
}
|
|
1030
|
+
return Demo;
|
|
1031
|
+
}(Component);
|
|
1032
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n value=\"hello\"\n buttonTooltip={{send: false, upload: false}}\n />\n ";
|
|
1033
|
+
_mount19 = mount(Demo), element = _mount19[1];
|
|
1034
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
1035
|
+
uploadBtn = element.querySelector('.k-sender-attach-btn');
|
|
1036
|
+
expect(sendBtn.getAttribute('title')).to.eql(null);
|
|
1037
|
+
expect(uploadBtn.getAttribute('title')).to.eql(null);
|
|
1038
|
+
expect(element.querySelector('.k-sender-send-tooltip')).to.eql(null);
|
|
1039
|
+
expect(element.querySelector('.k-sender-upload-tooltip')).to.eql(null);
|
|
1040
|
+
expect(sendBtn.getAttribute('aria-label')).to.eql('发送');
|
|
1041
|
+
expect(uploadBtn.getAttribute('aria-label')).to.eql('上传附件');
|
|
1042
|
+
case 11:
|
|
1043
|
+
case "end":
|
|
1044
|
+
return _context40.stop();
|
|
1045
|
+
}
|
|
1046
|
+
}, _callee19);
|
|
1047
|
+
})));
|
|
1048
|
+
it('should render beforeInput inside shell and configure inside toolbar middle', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
|
|
1049
|
+
var Demo, _mount20, element, top, tools, shell, middle, left, right, toolbar, children;
|
|
1050
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context42) {
|
|
1051
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
1052
|
+
case 0:
|
|
1053
|
+
Demo = /*#__PURE__*/function (_Component20) {
|
|
1054
|
+
_inheritsLoose(Demo, _Component20);
|
|
1055
|
+
function Demo() {
|
|
1056
|
+
var _context41;
|
|
1057
|
+
var _this20;
|
|
1058
|
+
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
|
1059
|
+
args[_key20] = arguments[_key20];
|
|
1060
|
+
}
|
|
1061
|
+
_this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context41 = [this]).call(_context41, args)) || this;
|
|
1062
|
+
_this20.Sender = Sender;
|
|
1063
|
+
return _this20;
|
|
1064
|
+
}
|
|
1065
|
+
return Demo;
|
|
1066
|
+
}(Component);
|
|
1067
|
+
Demo.template = "\n const { Sender } = this;\n <Sender>\n <b:beforeInput>\n <div class=\"top-suggest\">\u63A8\u8350</div>\n </b:beforeInput>\n <b:configure>\n <div class=\"bottom-tools\">\u5DE5\u5177</div>\n </b:configure>\n </Sender>\n ";
|
|
1068
|
+
_mount20 = mount(Demo), element = _mount20[1];
|
|
1069
|
+
top = element.querySelector('.top-suggest');
|
|
1070
|
+
tools = element.querySelector('.bottom-tools');
|
|
1071
|
+
expect(top).not.to.eql(null);
|
|
1072
|
+
expect(tools).not.to.eql(null);
|
|
1073
|
+
// beforeInput 包装容器在 shell 内
|
|
1074
|
+
shell = element.querySelector('.k-sender-shell');
|
|
1075
|
+
expect(shell.contains(top)).to.eql(true);
|
|
1076
|
+
// configure 落在 toolbar 中间
|
|
1077
|
+
middle = element.querySelector('.k-sender-toolbar-middle');
|
|
1078
|
+
expect(middle).not.to.eql(null);
|
|
1079
|
+
expect(middle.contains(tools)).to.eql(true);
|
|
1080
|
+
// configure 处于附件按钮和发送按钮之间
|
|
1081
|
+
left = element.querySelector('.k-sender-toolbar-left');
|
|
1082
|
+
right = element.querySelector('.k-sender-toolbar-right');
|
|
1083
|
+
toolbar = element.querySelector('.k-sender-toolbar');
|
|
1084
|
+
children = _Array$from(toolbar.children);
|
|
1085
|
+
expect(children.indexOf(left)).to.be.lessThan(children.indexOf(middle));
|
|
1086
|
+
expect(children.indexOf(middle)).to.be.lessThan(children.indexOf(right));
|
|
1087
|
+
case 18:
|
|
1088
|
+
case "end":
|
|
1089
|
+
return _context42.stop();
|
|
1090
|
+
}
|
|
1091
|
+
}, _callee20);
|
|
1092
|
+
})));
|
|
1093
|
+
it('should render prefix inside input area before textarea', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
|
|
1094
|
+
var Demo, _mount21, element, inputArea, prefix, customPrefix, textarea, children;
|
|
1095
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context44) {
|
|
1096
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
1097
|
+
case 0:
|
|
1098
|
+
Demo = /*#__PURE__*/function (_Component21) {
|
|
1099
|
+
_inheritsLoose(Demo, _Component21);
|
|
1100
|
+
function Demo() {
|
|
1101
|
+
var _context43;
|
|
1102
|
+
var _this21;
|
|
1103
|
+
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
|
1104
|
+
args[_key21] = arguments[_key21];
|
|
1105
|
+
}
|
|
1106
|
+
_this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
|
|
1107
|
+
_this21.Sender = Sender;
|
|
1108
|
+
return _this21;
|
|
1109
|
+
}
|
|
1110
|
+
return Demo;
|
|
1111
|
+
}(Component);
|
|
1112
|
+
Demo.template = "\n const { Sender } = this;\n <Sender>\n <b:prefix>\n <span class=\"custom-prefix\">AI</span>\n </b:prefix>\n </Sender>\n ";
|
|
1113
|
+
_mount21 = mount(Demo), element = _mount21[1];
|
|
1114
|
+
inputArea = element.querySelector('.k-sender-input-area');
|
|
1115
|
+
prefix = element.querySelector('.k-sender-prefix');
|
|
1116
|
+
customPrefix = element.querySelector('.custom-prefix');
|
|
1117
|
+
textarea = element.querySelector('.k-sender-input');
|
|
1118
|
+
children = _Array$from(inputArea.children);
|
|
1119
|
+
expect(prefix).not.to.eql(null);
|
|
1120
|
+
expect(prefix.contains(customPrefix)).to.eql(true);
|
|
1121
|
+
expect(children.indexOf(prefix)).to.be.lessThan(children.indexOf(textarea));
|
|
1122
|
+
case 11:
|
|
1123
|
+
case "end":
|
|
1124
|
+
return _context44.stop();
|
|
1125
|
+
}
|
|
1126
|
+
}, _callee21);
|
|
1127
|
+
})));
|
|
1128
|
+
it('should render header above shell and footer below shell', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
|
|
1129
|
+
var _context46;
|
|
1130
|
+
var Demo, _mount22, element, header, footer, shell;
|
|
1131
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context47) {
|
|
1132
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
1133
|
+
case 0:
|
|
1134
|
+
Demo = /*#__PURE__*/function (_Component22) {
|
|
1135
|
+
_inheritsLoose(Demo, _Component22);
|
|
1136
|
+
function Demo() {
|
|
1137
|
+
var _context45;
|
|
1138
|
+
var _this22;
|
|
1139
|
+
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
|
1140
|
+
args[_key22] = arguments[_key22];
|
|
1141
|
+
}
|
|
1142
|
+
_this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
|
|
1143
|
+
_this22.Sender = Sender;
|
|
1144
|
+
return _this22;
|
|
1145
|
+
}
|
|
1146
|
+
return Demo;
|
|
1147
|
+
}(Component);
|
|
1148
|
+
Demo.template = "\n const { Sender } = this;\n <Sender>\n <b:header>\n <button class=\"new-chat-btn\">\u5F00\u542F\u65B0\u5BF9\u8BDD</button>\n </b:header>\n <b:footer>\n <div class=\"sender-disclaimer\">AI\u751F\u6210\uFF0C\u4EC5\u4F9B\u53C2\u8003\u3002</div>\n </b:footer>\n </Sender>\n ";
|
|
1149
|
+
_mount22 = mount(Demo), element = _mount22[1];
|
|
1150
|
+
header = element.querySelector('.k-sender-header');
|
|
1151
|
+
footer = element.querySelector('.k-sender-footer');
|
|
1152
|
+
shell = element.querySelector('.k-sender-shell');
|
|
1153
|
+
expect(header).not.to.eql(null);
|
|
1154
|
+
expect(footer).not.to.eql(null);
|
|
1155
|
+
expect(header.querySelector('.new-chat-btn')).not.to.eql(null);
|
|
1156
|
+
expect(_trimInstanceProperty(_context46 = footer.querySelector('.sender-disclaimer').textContent).call(_context46)).to.eql('AI生成,仅供参考。');
|
|
1157
|
+
expect(shell.contains(header)).to.eql(false);
|
|
1158
|
+
expect(shell.contains(footer)).to.eql(false);
|
|
1159
|
+
expect(_Array$from(element.children)).to.eql([header, shell, footer]);
|
|
1160
|
+
case 13:
|
|
1161
|
+
case "end":
|
|
1162
|
+
return _context47.stop();
|
|
1163
|
+
}
|
|
1164
|
+
}, _callee22);
|
|
1165
|
+
})));
|
|
1166
|
+
// 布局插槽为空时,不保留 header/footer/beforeInput/configure/uploadButton 的空壳。
|
|
1167
|
+
it('should not render wrappers for empty layout slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
|
|
1168
|
+
var Demo, _mount23, element;
|
|
1169
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context49) {
|
|
1170
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
1171
|
+
case 0:
|
|
1172
|
+
Demo = /*#__PURE__*/function (_Component23) {
|
|
1173
|
+
_inheritsLoose(Demo, _Component23);
|
|
1174
|
+
function Demo() {
|
|
1175
|
+
var _context48;
|
|
1176
|
+
var _this23;
|
|
1177
|
+
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
|
1178
|
+
args[_key23] = arguments[_key23];
|
|
1179
|
+
}
|
|
1180
|
+
_this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context48 = [this]).call(_context48, args)) || this;
|
|
1181
|
+
_this23.Sender = Sender;
|
|
1182
|
+
return _this23;
|
|
1183
|
+
}
|
|
1184
|
+
return Demo;
|
|
1185
|
+
}(Component);
|
|
1186
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"none\">\n <b:header>\n <span v-if={false} class=\"empty-header\">header</span>\n </b:header>\n <b:beforeInput>\n <span v-if={false} class=\"empty-before-input\">before</span>\n </b:beforeInput>\n <b:prefix>\n <span v-if={false} class=\"empty-prefix\">prefix</span>\n </b:prefix>\n <b:uploadButton args=\"scope\">\n <button v-if={false} class=\"empty-upload-button\" type=\"button\">upload</button>\n </b:uploadButton>\n <b:configure>\n <span v-if={false} class=\"empty-configure\">configure</span>\n </b:configure>\n <b:footer>\n <span v-if={false} class=\"empty-footer\">footer</span>\n </b:footer>\n </Sender>\n </div>\n ";
|
|
1187
|
+
_mount23 = mount(Demo), element = _mount23[1];
|
|
1188
|
+
expect(element.querySelector('.k-sender-header')).to.eql(null);
|
|
1189
|
+
expect(element.querySelector('.k-sender-before-input')).to.eql(null);
|
|
1190
|
+
expect(element.querySelector('.k-sender-prefix')).to.eql(null);
|
|
1191
|
+
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
1192
|
+
expect(element.querySelector('.k-sender-toolbar-middle')).to.eql(null);
|
|
1193
|
+
expect(element.querySelector('.k-sender-footer')).to.eql(null);
|
|
1194
|
+
expect(element.querySelector('.k-sender-toolbar-right')).not.to.eql(null);
|
|
1195
|
+
case 10:
|
|
1196
|
+
case "end":
|
|
1197
|
+
return _context49.stop();
|
|
1198
|
+
}
|
|
1199
|
+
}, _callee23);
|
|
1200
|
+
})));
|
|
1201
|
+
it('should render default upload button in toolbar by default', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
|
|
1202
|
+
var Demo, _mount24, element;
|
|
1203
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context51) {
|
|
1204
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
1205
|
+
case 0:
|
|
1206
|
+
Demo = /*#__PURE__*/function (_Component24) {
|
|
1207
|
+
_inheritsLoose(Demo, _Component24);
|
|
1208
|
+
function Demo() {
|
|
1209
|
+
var _context50;
|
|
1210
|
+
var _this24;
|
|
1211
|
+
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
|
1212
|
+
args[_key24] = arguments[_key24];
|
|
1213
|
+
}
|
|
1214
|
+
_this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context50 = [this]).call(_context50, args)) || this;
|
|
1215
|
+
_this24.Sender = Sender;
|
|
1216
|
+
return _this24;
|
|
1217
|
+
}
|
|
1218
|
+
return Demo;
|
|
1219
|
+
}(Component);
|
|
1220
|
+
Demo.template = "const { Sender } = this; <div><Sender /></div>";
|
|
1221
|
+
_mount24 = mount(Demo), element = _mount24[1];
|
|
1222
|
+
expect(element.querySelector('.k-sender-toolbar-left')).not.to.eql(null);
|
|
1223
|
+
expect(element.querySelector('.k-sender-attach-btn')).not.to.eql(null);
|
|
1224
|
+
expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
|
|
1225
|
+
case 6:
|
|
1226
|
+
case "end":
|
|
1227
|
+
return _context51.stop();
|
|
1228
|
+
}
|
|
1229
|
+
}, _callee24);
|
|
1230
|
+
})));
|
|
1231
|
+
it('should show dashed upload button in attachment list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
|
|
1232
|
+
var _context53;
|
|
1233
|
+
var Demo, _mount25, element, addBox, clicked, fileInput;
|
|
1234
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context54) {
|
|
1235
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
1236
|
+
case 0:
|
|
1237
|
+
Demo = /*#__PURE__*/function (_Component25) {
|
|
1238
|
+
_inheritsLoose(Demo, _Component25);
|
|
1239
|
+
function Demo() {
|
|
1240
|
+
var _context52;
|
|
1241
|
+
var _this25;
|
|
1242
|
+
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
|
|
1243
|
+
args[_key25] = arguments[_key25];
|
|
1244
|
+
}
|
|
1245
|
+
_this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context52 = [this]).call(_context52, args)) || this;
|
|
1246
|
+
_this25.Sender = Sender;
|
|
1247
|
+
return _this25;
|
|
1248
|
+
}
|
|
1249
|
+
return Demo;
|
|
1250
|
+
}(Component);
|
|
1251
|
+
Demo.template = "const { Sender } = this; <div><Sender uploadButton=\"list\" /></div>";
|
|
1252
|
+
_mount25 = mount(Demo), element = _mount25[1];
|
|
1253
|
+
expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
|
|
1254
|
+
// 列表入口即使没有附件也要展示 FileCardList,用来承载前置 + 框
|
|
1255
|
+
expect(element.querySelector('.k-sender-attachments')).not.to.eql(null);
|
|
1256
|
+
addBox = element.querySelector('.k-sender-list-upload');
|
|
1257
|
+
expect(addBox).not.to.eql(null);
|
|
1258
|
+
expect(addBox.getAttribute('title')).to.eql('参考内容');
|
|
1259
|
+
expect(addBox.getAttribute('aria-label')).to.eql('参考内容');
|
|
1260
|
+
expect(_trimInstanceProperty(_context53 = addBox.querySelector('.k-sender-list-upload-text').textContent).call(_context53)).to.eql('参考内容');
|
|
1261
|
+
expect(addBox.querySelector('.k-icon-add-bold')).not.to.eql(null);
|
|
1262
|
+
// 点击 + 框会触发 file input click
|
|
1263
|
+
clicked = 0;
|
|
1264
|
+
fileInput = element.querySelector('.k-sender-file-input');
|
|
1265
|
+
fileInput.addEventListener('click', function (e) {
|
|
1266
|
+
clicked++;
|
|
1267
|
+
e.preventDefault();
|
|
1268
|
+
});
|
|
1269
|
+
addBox.click();
|
|
1270
|
+
_context54.next = 17;
|
|
1271
|
+
return wait();
|
|
1272
|
+
case 17:
|
|
1273
|
+
expect(clicked).to.eql(1);
|
|
1274
|
+
case 18:
|
|
1275
|
+
case "end":
|
|
1276
|
+
return _context54.stop();
|
|
1277
|
+
}
|
|
1278
|
+
}, _callee25);
|
|
1279
|
+
})));
|
|
1280
|
+
it('should let configure start from the left edge when upload button is not in toolbar', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
|
|
1281
|
+
var _context56;
|
|
1282
|
+
var Demo, _mount26, element, toolbar, middle;
|
|
1283
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context57) {
|
|
1284
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
1285
|
+
case 0:
|
|
1286
|
+
Demo = /*#__PURE__*/function (_Component26) {
|
|
1287
|
+
_inheritsLoose(Demo, _Component26);
|
|
1288
|
+
function Demo() {
|
|
1289
|
+
var _context55;
|
|
1290
|
+
var _this26;
|
|
1291
|
+
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
|
|
1292
|
+
args[_key26] = arguments[_key26];
|
|
1293
|
+
}
|
|
1294
|
+
_this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
|
|
1295
|
+
_this26.Sender = Sender;
|
|
1296
|
+
return _this26;
|
|
1297
|
+
}
|
|
1298
|
+
return Demo;
|
|
1299
|
+
}(Component);
|
|
1300
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"list\">\n <b:configure>\n <div class=\"sender-tools\">\u914D\u7F6E\u9879</div>\n </b:configure>\n </Sender>\n </div>\n ";
|
|
1301
|
+
_mount26 = mount(Demo), element = _mount26[1];
|
|
1302
|
+
toolbar = element.querySelector('.k-sender-toolbar');
|
|
1303
|
+
middle = element.querySelector('.k-sender-toolbar-middle');
|
|
1304
|
+
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
1305
|
+
expect(toolbar.firstElementChild).to.eql(middle);
|
|
1306
|
+
expect(_trimInstanceProperty(_context56 = middle.querySelector('.sender-tools').textContent).call(_context56)).to.eql('配置项');
|
|
1307
|
+
case 8:
|
|
1308
|
+
case "end":
|
|
1309
|
+
return _context57.stop();
|
|
1310
|
+
}
|
|
1311
|
+
}, _callee26);
|
|
1312
|
+
})));
|
|
1313
|
+
it('should hide list upload button when reaching uploadProps.limit', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
|
|
1314
|
+
var Demo, _mount27, element;
|
|
1315
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context59) {
|
|
1316
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
1317
|
+
case 0:
|
|
1318
|
+
Demo = /*#__PURE__*/function (_Component27) {
|
|
1319
|
+
_inheritsLoose(Demo, _Component27);
|
|
1320
|
+
function Demo() {
|
|
1321
|
+
var _context58;
|
|
1322
|
+
var _this27;
|
|
1323
|
+
for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
|
|
1324
|
+
args[_key27] = arguments[_key27];
|
|
1325
|
+
}
|
|
1326
|
+
_this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context58 = [this]).call(_context58, args)) || this;
|
|
1327
|
+
_this27.Sender = Sender;
|
|
1328
|
+
return _this27;
|
|
1329
|
+
}
|
|
1330
|
+
return Demo;
|
|
1331
|
+
}(Component);
|
|
1332
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"list\"\n uploadProps={{limit: 1}}\n attachments={[{key: 'a', uid: 'a', name: 'p.png', type: 'image/png', src: ''}]}\n />\n </div>\n ";
|
|
1333
|
+
_mount27 = mount(Demo), element = _mount27[1];
|
|
1334
|
+
expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
|
|
1335
|
+
// 文件卡片仍然渲染
|
|
1336
|
+
expect(element.querySelector('.k-file-card')).not.to.eql(null);
|
|
1337
|
+
case 5:
|
|
1338
|
+
case "end":
|
|
1339
|
+
return _context59.stop();
|
|
1340
|
+
}
|
|
1341
|
+
}, _callee27);
|
|
1342
|
+
})));
|
|
1343
|
+
it('should pass uploadButton slot params and render it in toolbar', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
|
|
1344
|
+
var _context61;
|
|
1345
|
+
var Demo, _mount28, element, button;
|
|
1346
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context62) {
|
|
1347
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
1348
|
+
case 0:
|
|
1349
|
+
Demo = /*#__PURE__*/function (_Component28) {
|
|
1350
|
+
_inheritsLoose(Demo, _Component28);
|
|
1351
|
+
function Demo() {
|
|
1352
|
+
var _context60;
|
|
1353
|
+
var _this28;
|
|
1354
|
+
for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
|
|
1355
|
+
args[_key28] = arguments[_key28];
|
|
1356
|
+
}
|
|
1357
|
+
_this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context60 = [this]).call(_context60, args)) || this;
|
|
1358
|
+
_this28.Sender = Sender;
|
|
1359
|
+
return _this28;
|
|
1360
|
+
}
|
|
1361
|
+
return Demo;
|
|
1362
|
+
}(Component);
|
|
1363
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadProps={{limit: 1}} attachments={[\n {key: 'a', uid: 'a', name: 'note.txt'},\n ]}>\n <b:uploadButton args=\"scope\">\n <button\n class=\"custom-upload\"\n disabled={scope.disabled || scope.reachLimit}\n ev-click={scope.pickFiles}\n >{scope.position}</button>\n </b:uploadButton>\n </Sender>\n </div>\n ";
|
|
1364
|
+
_mount28 = mount(Demo), element = _mount28[1];
|
|
1365
|
+
button = element.querySelector('.custom-upload');
|
|
1366
|
+
expect(button).not.to.eql(null);
|
|
1367
|
+
expect(_trimInstanceProperty(_context61 = button.textContent).call(_context61)).to.eql('toolbar');
|
|
1368
|
+
expect(button.disabled).to.eql(true);
|
|
1369
|
+
expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
|
|
1370
|
+
case 8:
|
|
1371
|
+
case "end":
|
|
1372
|
+
return _context62.stop();
|
|
1373
|
+
}
|
|
1374
|
+
}, _callee28);
|
|
1375
|
+
})));
|
|
1376
|
+
it('should add local files through uploadButton slot params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
|
|
1377
|
+
var lastAttachments, Demo, _mount29, element, button;
|
|
1378
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context64) {
|
|
1379
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
1380
|
+
case 0:
|
|
1381
|
+
lastAttachments = [];
|
|
1382
|
+
Demo = /*#__PURE__*/function (_Component29) {
|
|
1383
|
+
_inheritsLoose(Demo, _Component29);
|
|
1384
|
+
function Demo() {
|
|
1385
|
+
var _context63;
|
|
1386
|
+
var _this29;
|
|
1387
|
+
for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
|
|
1388
|
+
args[_key29] = arguments[_key29];
|
|
1389
|
+
}
|
|
1390
|
+
_this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context63 = [this]).call(_context63, args)) || this;
|
|
1391
|
+
_this29.Sender = Sender;
|
|
1392
|
+
_this29.file = new File(['hello'], 'hello.txt', {
|
|
1393
|
+
type: 'text/plain'
|
|
1394
|
+
});
|
|
1395
|
+
_this29.onChange = function (items) {
|
|
1396
|
+
lastAttachments = items;
|
|
1397
|
+
};
|
|
1398
|
+
return _this29;
|
|
1399
|
+
}
|
|
1400
|
+
Demo.defaults = function defaults() {
|
|
1401
|
+
return {
|
|
1402
|
+
attachments: []
|
|
1403
|
+
};
|
|
1404
|
+
};
|
|
1405
|
+
return Demo;
|
|
1406
|
+
}(Component);
|
|
1407
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n uploadProps={{accept: '.txt', autoUpload: false}}\n ev-$change:attachments={this.onChange}\n >\n <b:uploadButton args=\"scope\">\n <button\n class=\"custom-add-files\"\n ev-click={() => scope.addFiles([this.file])}\n >add</button>\n </b:uploadButton>\n </Sender>\n ";
|
|
1408
|
+
_mount29 = mount(Demo), element = _mount29[1];
|
|
1409
|
+
button = element.querySelector('.custom-add-files');
|
|
1410
|
+
button.click();
|
|
1411
|
+
_context64.next = 8;
|
|
1412
|
+
return wait();
|
|
1413
|
+
case 8:
|
|
1414
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1415
|
+
expect(lastAttachments[0].name).to.eql('hello.txt');
|
|
1416
|
+
expect(lastAttachments[0].status).to.eql('default');
|
|
1417
|
+
case 11:
|
|
1418
|
+
case "end":
|
|
1419
|
+
return _context64.stop();
|
|
1420
|
+
}
|
|
1421
|
+
}, _callee29);
|
|
1422
|
+
})));
|
|
1423
|
+
it('should render uploadButton slot in attachment list when uploadButton is list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
|
|
1424
|
+
var _context66;
|
|
1425
|
+
var Demo, _mount30, element;
|
|
1426
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context67) {
|
|
1427
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
1428
|
+
case 0:
|
|
1429
|
+
Demo = /*#__PURE__*/function (_Component30) {
|
|
1430
|
+
_inheritsLoose(Demo, _Component30);
|
|
1431
|
+
function Demo() {
|
|
1432
|
+
var _context65;
|
|
1433
|
+
var _this30;
|
|
1434
|
+
for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
|
|
1435
|
+
args[_key30] = arguments[_key30];
|
|
1436
|
+
}
|
|
1437
|
+
_this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context65 = [this]).call(_context65, args)) || this;
|
|
1438
|
+
_this30.Sender = Sender;
|
|
1439
|
+
return _this30;
|
|
1440
|
+
}
|
|
1441
|
+
return Demo;
|
|
1442
|
+
}(Component);
|
|
1443
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"list\">\n <b:uploadButton args=\"scope\">\n <button class=\"custom-list-upload\" ev-click={scope.pickFiles}>{scope.position}</button>\n </b:uploadButton>\n </Sender>\n </div>\n ";
|
|
1444
|
+
_mount30 = mount(Demo), element = _mount30[1];
|
|
1445
|
+
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
1446
|
+
expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
|
|
1447
|
+
expect(_trimInstanceProperty(_context66 = element.querySelector('.k-file-card-list-prefix .custom-list-upload').textContent).call(_context66)).to.eql('list');
|
|
1448
|
+
case 6:
|
|
1449
|
+
case "end":
|
|
1450
|
+
return _context67.stop();
|
|
1451
|
+
}
|
|
1452
|
+
}, _callee30);
|
|
1453
|
+
})));
|
|
1454
|
+
it('should expose addFiles method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
1455
|
+
var lastAttachments, Demo, _mount31, instance, file;
|
|
1456
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context69) {
|
|
1457
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
1458
|
+
case 0:
|
|
1459
|
+
lastAttachments = [];
|
|
1460
|
+
Demo = /*#__PURE__*/function (_Component31) {
|
|
1461
|
+
_inheritsLoose(Demo, _Component31);
|
|
1462
|
+
function Demo() {
|
|
1463
|
+
var _context68;
|
|
1464
|
+
var _this31;
|
|
1465
|
+
for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
|
|
1466
|
+
args[_key31] = arguments[_key31];
|
|
1467
|
+
}
|
|
1468
|
+
_this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context68 = [this]).call(_context68, args)) || this;
|
|
1469
|
+
_this31.Sender = Sender;
|
|
1470
|
+
_this31.senderRef = null;
|
|
1471
|
+
_this31.onChange = function (items) {
|
|
1472
|
+
lastAttachments = items;
|
|
1473
|
+
};
|
|
1474
|
+
return _this31;
|
|
1475
|
+
}
|
|
1476
|
+
Demo.defaults = function defaults() {
|
|
1477
|
+
return {
|
|
1478
|
+
attachments: []
|
|
1479
|
+
};
|
|
1480
|
+
};
|
|
1481
|
+
return Demo;
|
|
1482
|
+
}(Component);
|
|
1483
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n attachments={this.get('attachments')}\n uploadProps={{autoUpload: false}}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1484
|
+
_mount31 = mount(Demo), instance = _mount31[0];
|
|
1485
|
+
file = new File(['hello'], 'dialog.txt', {
|
|
1486
|
+
type: 'text/plain'
|
|
1487
|
+
});
|
|
1488
|
+
instance.senderRef.addFiles([file]);
|
|
1489
|
+
_context69.next = 8;
|
|
1490
|
+
return wait();
|
|
1491
|
+
case 8:
|
|
1492
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1493
|
+
expect(lastAttachments[0].name).to.eql('dialog.txt');
|
|
1494
|
+
expect(lastAttachments[0].status).to.eql('default');
|
|
1495
|
+
case 11:
|
|
1496
|
+
case "end":
|
|
1497
|
+
return _context69.stop();
|
|
1498
|
+
}
|
|
1499
|
+
}, _callee31);
|
|
1500
|
+
})));
|
|
1501
|
+
it('should render card-view attachments uniformly as file cards', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
|
|
1502
|
+
var Demo, _mount32, element;
|
|
1503
|
+
return _regeneratorRuntime.wrap(function _callee32$(_context71) {
|
|
1504
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
1505
|
+
case 0:
|
|
1506
|
+
Demo = /*#__PURE__*/function (_Component32) {
|
|
1507
|
+
_inheritsLoose(Demo, _Component32);
|
|
1508
|
+
function Demo() {
|
|
1509
|
+
var _context70;
|
|
1510
|
+
var _this32;
|
|
1511
|
+
for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
|
|
1512
|
+
args[_key32] = arguments[_key32];
|
|
1513
|
+
}
|
|
1514
|
+
_this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context70 = [this]).call(_context70, args)) || this;
|
|
1515
|
+
_this32.Sender = Sender;
|
|
1516
|
+
return _this32;
|
|
1517
|
+
}
|
|
1518
|
+
return Demo;
|
|
1519
|
+
}(Component);
|
|
1520
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n {key: 'b', uid: 'b', name: 'note.txt', type: 'text/plain'},\n ]} />\n </div>\n ";
|
|
1521
|
+
_mount32 = mount(Demo), element = _mount32[1]; // card 视图下,图片附件也应当以「文件卡」形式呈现,而不是图片缩略图
|
|
1522
|
+
expect(element.querySelectorAll('.k-file-card-file').length).to.eql(2);
|
|
1523
|
+
expect(element.querySelectorAll('.k-file-card-media').length).to.eql(0);
|
|
1524
|
+
case 5:
|
|
1525
|
+
case "end":
|
|
1526
|
+
return _context71.stop();
|
|
1527
|
+
}
|
|
1528
|
+
}, _callee32);
|
|
1529
|
+
})));
|
|
1530
|
+
it('should keep image media cards (square) in media view', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
|
|
1531
|
+
var Demo, _mount33, element;
|
|
1532
|
+
return _regeneratorRuntime.wrap(function _callee33$(_context73) {
|
|
1533
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
1534
|
+
case 0:
|
|
1535
|
+
Demo = /*#__PURE__*/function (_Component33) {
|
|
1536
|
+
_inheritsLoose(Demo, _Component33);
|
|
1537
|
+
function Demo() {
|
|
1538
|
+
var _context72;
|
|
1539
|
+
var _this33;
|
|
1540
|
+
for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
|
|
1541
|
+
args[_key33] = arguments[_key33];
|
|
1542
|
+
}
|
|
1543
|
+
_this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context72 = [this]).call(_context72, args)) || this;
|
|
1544
|
+
_this33.Sender = Sender;
|
|
1545
|
+
return _this33;
|
|
1546
|
+
}
|
|
1547
|
+
return Demo;
|
|
1548
|
+
}(Component);
|
|
1549
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n ]} />\n </div>\n ";
|
|
1550
|
+
_mount33 = mount(Demo), element = _mount33[1]; // media 视图下保留 FileCard 的图片渲染(自带 1:1 裁剪),不强制转成 file 卡片
|
|
1551
|
+
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1552
|
+
case 4:
|
|
1553
|
+
case "end":
|
|
1554
|
+
return _context73.stop();
|
|
1555
|
+
}
|
|
1556
|
+
}, _callee33);
|
|
1557
|
+
})));
|
|
1558
|
+
it('should enable name tooltip for Sender media attachments', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
|
|
1559
|
+
var Demo, _mount34, element, mediaView;
|
|
1560
|
+
return _regeneratorRuntime.wrap(function _callee34$(_context75) {
|
|
1561
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
1562
|
+
case 0:
|
|
1563
|
+
Demo = /*#__PURE__*/function (_Component34) {
|
|
1564
|
+
_inheritsLoose(Demo, _Component34);
|
|
1565
|
+
function Demo() {
|
|
1566
|
+
var _context74;
|
|
1567
|
+
var _this34;
|
|
1568
|
+
for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) {
|
|
1569
|
+
args[_key34] = arguments[_key34];
|
|
1570
|
+
}
|
|
1571
|
+
_this34 = _Component34.call.apply(_Component34, _concatInstanceProperty(_context74 = [this]).call(_context74, args)) || this;
|
|
1572
|
+
_this34.Sender = Sender;
|
|
1573
|
+
return _this34;
|
|
1574
|
+
}
|
|
1575
|
+
return Demo;
|
|
1576
|
+
}(Component);
|
|
1577
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'very-long-image-name.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n ]} />\n </div>\n ";
|
|
1578
|
+
_mount34 = mount(Demo), element = _mount34[1];
|
|
1579
|
+
mediaView = element.querySelector('.k-file-card-media-view');
|
|
1580
|
+
expect(mediaView.querySelector('.k-media-name-tooltip-trigger')).not.to.eql(null);
|
|
1581
|
+
expect(mediaView.getAttribute('title')).to.eql(null);
|
|
1582
|
+
case 6:
|
|
1583
|
+
case "end":
|
|
1584
|
+
return _context75.stop();
|
|
1585
|
+
}
|
|
1586
|
+
}, _callee34);
|
|
1587
|
+
})));
|
|
1588
|
+
it('should infer media type from name in media view when attachment type is generic mime', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {
|
|
1589
|
+
var Demo, _mount35, element;
|
|
1590
|
+
return _regeneratorRuntime.wrap(function _callee35$(_context77) {
|
|
1591
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
1592
|
+
case 0:
|
|
1593
|
+
Demo = /*#__PURE__*/function (_Component35) {
|
|
1594
|
+
_inheritsLoose(Demo, _Component35);
|
|
1595
|
+
function Demo() {
|
|
1596
|
+
var _context76;
|
|
1597
|
+
var _this35;
|
|
1598
|
+
for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) {
|
|
1599
|
+
args[_key35] = arguments[_key35];
|
|
1600
|
+
}
|
|
1601
|
+
_this35 = _Component35.call.apply(_Component35, _concatInstanceProperty(_context76 = [this]).call(_context76, args)) || this;
|
|
1602
|
+
_this35.Sender = Sender;
|
|
1603
|
+
return _this35;
|
|
1604
|
+
}
|
|
1605
|
+
return Demo;
|
|
1606
|
+
}(Component);
|
|
1607
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'application/octet-stream', src: 'blob:mock'},\n ]} />\n </div>\n ";
|
|
1608
|
+
_mount35 = mount(Demo), element = _mount35[1];
|
|
1609
|
+
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1610
|
+
expect(element.querySelector('.k-file-card-file')).to.eql(null);
|
|
1611
|
+
case 5:
|
|
1612
|
+
case "end":
|
|
1613
|
+
return _context77.stop();
|
|
1614
|
+
}
|
|
1615
|
+
}, _callee35);
|
|
1616
|
+
})));
|
|
1617
|
+
it('should keep explicit image type in media view even when src has no extension', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {
|
|
1618
|
+
var Demo, _mount36, element;
|
|
1619
|
+
return _regeneratorRuntime.wrap(function _callee36$(_context79) {
|
|
1620
|
+
while (1) switch (_context79.prev = _context79.next) {
|
|
1621
|
+
case 0:
|
|
1622
|
+
Demo = /*#__PURE__*/function (_Component36) {
|
|
1623
|
+
_inheritsLoose(Demo, _Component36);
|
|
1624
|
+
function Demo() {
|
|
1625
|
+
var _context78;
|
|
1626
|
+
var _this36;
|
|
1627
|
+
for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) {
|
|
1628
|
+
args[_key36] = arguments[_key36];
|
|
1629
|
+
}
|
|
1630
|
+
_this36 = _Component36.call.apply(_Component36, _concatInstanceProperty(_context78 = [this]).call(_context78, args)) || this;
|
|
1631
|
+
_this36.Sender = Sender;
|
|
1632
|
+
return _this36;
|
|
1633
|
+
}
|
|
1634
|
+
return Demo;
|
|
1635
|
+
}(Component);
|
|
1636
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'unsplash.jpg', type: 'image', src: 'https://images.unsplash.com/photo-1492691527719-9d1e07e534b4?auto=format&fit=crop&w=1200&q=80'},\n ]} />\n </div>\n ";
|
|
1637
|
+
_mount36 = mount(Demo), element = _mount36[1];
|
|
1638
|
+
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1639
|
+
expect(element.querySelector('.k-media-image')).not.to.eql(null);
|
|
1640
|
+
case 5:
|
|
1641
|
+
case "end":
|
|
1642
|
+
return _context79.stop();
|
|
1643
|
+
}
|
|
1644
|
+
}, _callee36);
|
|
1645
|
+
})));
|
|
1646
|
+
it('should support directory selection and preserve relative path metadata', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {
|
|
1647
|
+
var lastAttachments, Demo, _mount37, element, input, file;
|
|
1648
|
+
return _regeneratorRuntime.wrap(function _callee37$(_context81) {
|
|
1649
|
+
while (1) switch (_context81.prev = _context81.next) {
|
|
1650
|
+
case 0:
|
|
1651
|
+
lastAttachments = [];
|
|
1652
|
+
Demo = /*#__PURE__*/function (_Component37) {
|
|
1653
|
+
_inheritsLoose(Demo, _Component37);
|
|
1654
|
+
function Demo() {
|
|
1655
|
+
var _context80;
|
|
1656
|
+
var _this37;
|
|
1657
|
+
for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) {
|
|
1658
|
+
args[_key37] = arguments[_key37];
|
|
1659
|
+
}
|
|
1660
|
+
_this37 = _Component37.call.apply(_Component37, _concatInstanceProperty(_context80 = [this]).call(_context80, args)) || this;
|
|
1661
|
+
_this37.Sender = Sender;
|
|
1662
|
+
_this37.onChange = function (items) {
|
|
1663
|
+
lastAttachments = items;
|
|
1664
|
+
};
|
|
1665
|
+
return _this37;
|
|
1666
|
+
}
|
|
1667
|
+
Demo.defaults = function defaults() {
|
|
1668
|
+
return {
|
|
1669
|
+
attachments: []
|
|
1670
|
+
};
|
|
1671
|
+
};
|
|
1672
|
+
return Demo;
|
|
1673
|
+
}(Component);
|
|
1674
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n uploadProps={{directory: true}}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1675
|
+
_mount37 = mount(Demo), element = _mount37[1];
|
|
1676
|
+
input = element.querySelector('.k-sender-file-input');
|
|
1677
|
+
expect(input.getAttribute('directory')).to.eql('');
|
|
1678
|
+
expect(input.getAttribute('webkitdirectory')).to.eql('');
|
|
1679
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1680
|
+
type: 'text/plain'
|
|
1681
|
+
});
|
|
1682
|
+
Object.defineProperty(file, 'webkitRelativePath', {
|
|
1683
|
+
value: 'docs/hello.txt',
|
|
1684
|
+
configurable: true
|
|
1685
|
+
});
|
|
1686
|
+
Object.defineProperty(input, 'files', {
|
|
1687
|
+
value: [file],
|
|
1688
|
+
configurable: true
|
|
1689
|
+
});
|
|
1690
|
+
dispatchEvent(input, 'change');
|
|
1691
|
+
_context81.next = 13;
|
|
1692
|
+
return wait();
|
|
1693
|
+
case 13:
|
|
1694
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1695
|
+
expect(lastAttachments[0].name).to.eql('docs/hello.txt');
|
|
1696
|
+
expect(lastAttachments[0].relativePath).to.eql('docs/hello.txt');
|
|
1697
|
+
case 16:
|
|
1698
|
+
case "end":
|
|
1699
|
+
return _context81.stop();
|
|
1700
|
+
}
|
|
1701
|
+
}, _callee37);
|
|
1702
|
+
})));
|
|
1703
|
+
it('should support mapAttachment for runtime uploading items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {
|
|
1704
|
+
var _element$querySelecto;
|
|
1705
|
+
var lastAttachments, resolveBeforeUpload, Demo, _mount38, element, input, file;
|
|
1706
|
+
return _regeneratorRuntime.wrap(function _callee38$(_context83) {
|
|
1707
|
+
while (1) switch (_context83.prev = _context83.next) {
|
|
1708
|
+
case 0:
|
|
1709
|
+
lastAttachments = [];
|
|
1710
|
+
Demo = /*#__PURE__*/function (_Component38) {
|
|
1711
|
+
_inheritsLoose(Demo, _Component38);
|
|
1712
|
+
function Demo() {
|
|
1713
|
+
var _context82;
|
|
1714
|
+
var _this38;
|
|
1715
|
+
for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) {
|
|
1716
|
+
args[_key38] = arguments[_key38];
|
|
1717
|
+
}
|
|
1718
|
+
_this38 = _Component38.call.apply(_Component38, _concatInstanceProperty(_context82 = [this]).call(_context82, args)) || this;
|
|
1719
|
+
_this38.Sender = Sender;
|
|
1720
|
+
_this38.onChange = function (items) {
|
|
1721
|
+
lastAttachments = items;
|
|
1722
|
+
};
|
|
1723
|
+
return _this38;
|
|
1724
|
+
}
|
|
1725
|
+
Demo.defaults = function defaults() {
|
|
1726
|
+
return {
|
|
1727
|
+
attachments: []
|
|
1728
|
+
};
|
|
1729
|
+
};
|
|
1730
|
+
var _proto = Demo.prototype;
|
|
1731
|
+
_proto.getUploadProps = function getUploadProps() {
|
|
1732
|
+
return {
|
|
1733
|
+
autoUpload: false,
|
|
1734
|
+
beforeUpload: function beforeUpload() {
|
|
1735
|
+
return new _Promise(function (resolve) {
|
|
1736
|
+
resolveBeforeUpload = resolve;
|
|
1737
|
+
});
|
|
1738
|
+
},
|
|
1739
|
+
mapAttachment: function mapAttachment(file) {
|
|
1740
|
+
return {
|
|
1741
|
+
loadingText: "\u4E0A\u4F20\u4E2D " + file.name,
|
|
1742
|
+
errorText: "\u4E0A\u4F20\u5931\u8D25 " + file.name
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
};
|
|
1747
|
+
return Demo;
|
|
1748
|
+
}(Component);
|
|
1749
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n uploadProps={this.getUploadProps()}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1750
|
+
_mount38 = mount(Demo), element = _mount38[1];
|
|
1751
|
+
input = element.querySelector('.k-sender-file-input');
|
|
1752
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1753
|
+
type: 'text/plain'
|
|
1754
|
+
});
|
|
1755
|
+
Object.defineProperty(input, 'files', {
|
|
1756
|
+
value: [file],
|
|
1757
|
+
configurable: true
|
|
1758
|
+
});
|
|
1759
|
+
dispatchEvent(input, 'change');
|
|
1760
|
+
_context83.next = 10;
|
|
1761
|
+
return wait();
|
|
1762
|
+
case 10:
|
|
1763
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1764
|
+
expect(lastAttachments[0].loadingText).to.eql('上传中 hello.txt');
|
|
1765
|
+
expect(lastAttachments[0].errorText).to.eql('上传失败 hello.txt');
|
|
1766
|
+
expect((_element$querySelecto = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto.textContent).to.contain('上传中 hello.txt');
|
|
1767
|
+
if (resolveBeforeUpload) {
|
|
1768
|
+
resolveBeforeUpload(true);
|
|
1769
|
+
}
|
|
1770
|
+
case 15:
|
|
1771
|
+
case "end":
|
|
1772
|
+
return _context83.stop();
|
|
1773
|
+
}
|
|
1774
|
+
}, _callee38);
|
|
1775
|
+
})));
|
|
1776
|
+
it('should show fullscreen drag mask and add dropped files when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {
|
|
1777
|
+
var lastAttachments, Demo, _mount39, element, file, mask, card, icon, text;
|
|
1778
|
+
return _regeneratorRuntime.wrap(function _callee39$(_context85) {
|
|
1779
|
+
while (1) switch (_context85.prev = _context85.next) {
|
|
1780
|
+
case 0:
|
|
1781
|
+
lastAttachments = [];
|
|
1782
|
+
Demo = /*#__PURE__*/function (_Component39) {
|
|
1783
|
+
_inheritsLoose(Demo, _Component39);
|
|
1784
|
+
function Demo() {
|
|
1785
|
+
var _context84;
|
|
1786
|
+
var _this39;
|
|
1787
|
+
for (var _len39 = arguments.length, args = new Array(_len39), _key39 = 0; _key39 < _len39; _key39++) {
|
|
1788
|
+
args[_key39] = arguments[_key39];
|
|
1789
|
+
}
|
|
1790
|
+
_this39 = _Component39.call.apply(_Component39, _concatInstanceProperty(_context84 = [this]).call(_context84, args)) || this;
|
|
1791
|
+
_this39.Sender = Sender;
|
|
1792
|
+
_this39.onChange = function (items) {
|
|
1793
|
+
lastAttachments = items;
|
|
1794
|
+
};
|
|
1795
|
+
return _this39;
|
|
1796
|
+
}
|
|
1797
|
+
Demo.defaults = function defaults() {
|
|
1798
|
+
return {
|
|
1799
|
+
attachments: []
|
|
1800
|
+
};
|
|
1801
|
+
};
|
|
1802
|
+
return Demo;
|
|
1803
|
+
}(Component);
|
|
1804
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1805
|
+
_mount39 = mount(Demo), element = _mount39[1];
|
|
1806
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1807
|
+
type: 'text/plain'
|
|
1808
|
+
});
|
|
1809
|
+
dispatchEvent(document, 'dragenter', {
|
|
1810
|
+
dataTransfer: getDataTransfer([file])
|
|
1811
|
+
});
|
|
1812
|
+
_context85.next = 8;
|
|
1813
|
+
return wait();
|
|
1814
|
+
case 8:
|
|
1815
|
+
mask = element.querySelector('.k-sender-drag-mask');
|
|
1816
|
+
card = element.querySelector('.k-sender-drag-card');
|
|
1817
|
+
icon = element.querySelector('.k-sender-drag-card .k-icon');
|
|
1818
|
+
text = element.querySelector('.k-sender-drag-text');
|
|
1819
|
+
expect(mask).not.to.eql(null);
|
|
1820
|
+
expect(text.textContent).to.eql('文件拖动到此处即可上传');
|
|
1821
|
+
expect(getComputedStyle(mask).backgroundColor).to.eql('rgba(255, 255, 255, 0.72)');
|
|
1822
|
+
expect(getComputedStyle(card).flexDirection).to.eql('column');
|
|
1823
|
+
expect(getComputedStyle(icon).color).to.eql('rgb(83, 112, 255)');
|
|
1824
|
+
expect(getComputedStyle(card).boxShadow).to.eql('none');
|
|
1825
|
+
expect(getComputedStyle(card).borderTopWidth).to.eql('0px');
|
|
1826
|
+
dispatchEvent(document, 'drop', {
|
|
1827
|
+
dataTransfer: getDataTransfer([file])
|
|
1828
|
+
});
|
|
1829
|
+
_context85.next = 22;
|
|
1830
|
+
return wait();
|
|
1831
|
+
case 22:
|
|
1832
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1833
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1834
|
+
expect(lastAttachments[0].name).to.eql('hello.txt');
|
|
1835
|
+
case 25:
|
|
1836
|
+
case "end":
|
|
1837
|
+
return _context85.stop();
|
|
1838
|
+
}
|
|
1839
|
+
}, _callee39);
|
|
1840
|
+
})));
|
|
1841
|
+
it('should ignore non-file drags when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40() {
|
|
1842
|
+
var Demo, _mount40, element;
|
|
1843
|
+
return _regeneratorRuntime.wrap(function _callee40$(_context87) {
|
|
1844
|
+
while (1) switch (_context87.prev = _context87.next) {
|
|
1845
|
+
case 0:
|
|
1846
|
+
Demo = /*#__PURE__*/function (_Component40) {
|
|
1847
|
+
_inheritsLoose(Demo, _Component40);
|
|
1848
|
+
function Demo() {
|
|
1849
|
+
var _context86;
|
|
1850
|
+
var _this40;
|
|
1851
|
+
for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) {
|
|
1852
|
+
args[_key40] = arguments[_key40];
|
|
1853
|
+
}
|
|
1854
|
+
_this40 = _Component40.call.apply(_Component40, _concatInstanceProperty(_context86 = [this]).call(_context86, args)) || this;
|
|
1855
|
+
_this40.Sender = Sender;
|
|
1856
|
+
return _this40;
|
|
1857
|
+
}
|
|
1858
|
+
return Demo;
|
|
1859
|
+
}(Component);
|
|
1860
|
+
Demo.template = "\n const { Sender } = this;\n <Sender dragFile={true} />\n ";
|
|
1861
|
+
_mount40 = mount(Demo), element = _mount40[1];
|
|
1862
|
+
dispatchEvent(document, 'dragenter', {
|
|
1863
|
+
dataTransfer: {
|
|
1864
|
+
types: ['text/plain']
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
_context87.next = 6;
|
|
1868
|
+
return wait();
|
|
1869
|
+
case 6:
|
|
1870
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1871
|
+
case 7:
|
|
1872
|
+
case "end":
|
|
1873
|
+
return _context87.stop();
|
|
1874
|
+
}
|
|
1875
|
+
}, _callee40);
|
|
1876
|
+
})));
|
|
1877
|
+
it('should trigger uploadError for invalid file type on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {
|
|
1878
|
+
var errorMessage, lastAttachments, Demo, _mount41, element, file;
|
|
1879
|
+
return _regeneratorRuntime.wrap(function _callee41$(_context89) {
|
|
1880
|
+
while (1) switch (_context89.prev = _context89.next) {
|
|
1881
|
+
case 0:
|
|
1882
|
+
errorMessage = '';
|
|
1883
|
+
lastAttachments = [];
|
|
1884
|
+
Demo = /*#__PURE__*/function (_Component41) {
|
|
1885
|
+
_inheritsLoose(Demo, _Component41);
|
|
1886
|
+
function Demo() {
|
|
1887
|
+
var _context88;
|
|
1888
|
+
var _this41;
|
|
1889
|
+
for (var _len41 = arguments.length, args = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) {
|
|
1890
|
+
args[_key41] = arguments[_key41];
|
|
1891
|
+
}
|
|
1892
|
+
_this41 = _Component41.call.apply(_Component41, _concatInstanceProperty(_context88 = [this]).call(_context88, args)) || this;
|
|
1893
|
+
_this41.Sender = Sender;
|
|
1894
|
+
_this41.onChange = function (items) {
|
|
1895
|
+
lastAttachments = items;
|
|
1896
|
+
};
|
|
1897
|
+
_this41.onUploadError = function (error) {
|
|
1898
|
+
errorMessage = error.message;
|
|
1899
|
+
};
|
|
1900
|
+
return _this41;
|
|
1901
|
+
}
|
|
1902
|
+
Demo.defaults = function defaults() {
|
|
1903
|
+
return {
|
|
1904
|
+
attachments: []
|
|
1905
|
+
};
|
|
1906
|
+
};
|
|
1907
|
+
return Demo;
|
|
1908
|
+
}(Component);
|
|
1909
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n uploadProps={{accept: 'image/*'}}\n ev-$change:attachments={this.onChange}\n ev-uploadError={this.onUploadError}\n />\n ";
|
|
1910
|
+
_mount41 = mount(Demo), element = _mount41[1];
|
|
1911
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1912
|
+
type: 'text/plain'
|
|
1913
|
+
});
|
|
1914
|
+
dispatchEvent(document, 'dragenter', {
|
|
1915
|
+
dataTransfer: getDataTransfer([file])
|
|
1916
|
+
});
|
|
1917
|
+
_context89.next = 9;
|
|
1918
|
+
return wait();
|
|
1919
|
+
case 9:
|
|
1920
|
+
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1921
|
+
dispatchEvent(document, 'drop', {
|
|
1922
|
+
dataTransfer: getDataTransfer([file])
|
|
1923
|
+
});
|
|
1924
|
+
_context89.next = 13;
|
|
1925
|
+
return wait();
|
|
1926
|
+
case 13:
|
|
1927
|
+
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
1928
|
+
expect(lastAttachments.length).to.eql(0);
|
|
1929
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1930
|
+
case 16:
|
|
1931
|
+
case "end":
|
|
1932
|
+
return _context89.stop();
|
|
1933
|
+
}
|
|
1934
|
+
}, _callee41);
|
|
1935
|
+
})));
|
|
1936
|
+
it('should flatten dragged directory files when uploadProps.directory is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42() {
|
|
1937
|
+
var lastAttachments, Demo, _mount42, element, noteFile, imageFile, docsDir;
|
|
1938
|
+
return _regeneratorRuntime.wrap(function _callee42$(_context91) {
|
|
1939
|
+
while (1) switch (_context91.prev = _context91.next) {
|
|
1940
|
+
case 0:
|
|
1941
|
+
lastAttachments = [];
|
|
1942
|
+
Demo = /*#__PURE__*/function (_Component42) {
|
|
1943
|
+
_inheritsLoose(Demo, _Component42);
|
|
1944
|
+
function Demo() {
|
|
1945
|
+
var _context90;
|
|
1946
|
+
var _this42;
|
|
1947
|
+
for (var _len42 = arguments.length, args = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) {
|
|
1948
|
+
args[_key42] = arguments[_key42];
|
|
1949
|
+
}
|
|
1950
|
+
_this42 = _Component42.call.apply(_Component42, _concatInstanceProperty(_context90 = [this]).call(_context90, args)) || this;
|
|
1951
|
+
_this42.Sender = Sender;
|
|
1952
|
+
_this42.onChange = function (items) {
|
|
1953
|
+
lastAttachments = items;
|
|
1954
|
+
};
|
|
1955
|
+
return _this42;
|
|
1956
|
+
}
|
|
1957
|
+
Demo.defaults = function defaults() {
|
|
1958
|
+
return {
|
|
1959
|
+
attachments: []
|
|
1960
|
+
};
|
|
1961
|
+
};
|
|
1962
|
+
return Demo;
|
|
1963
|
+
}(Component);
|
|
1964
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n uploadProps={{directory: true}}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1965
|
+
_mount42 = mount(Demo), element = _mount42[1];
|
|
1966
|
+
noteFile = new File(['note'], 'note.txt', {
|
|
1967
|
+
type: 'text/plain'
|
|
1968
|
+
});
|
|
1969
|
+
imageFile = new File(['image'], 'cover.png', {
|
|
1970
|
+
type: 'image/png'
|
|
1971
|
+
});
|
|
1972
|
+
docsDir = createDragDirectoryEntry('docs', [createDragFileEntry(noteFile), createDragDirectoryEntry('assets', [createDragFileEntry(imageFile)])]);
|
|
1973
|
+
dispatchEvent(document, 'dragenter', {
|
|
1974
|
+
dataTransfer: getDataTransfer([noteFile])
|
|
1975
|
+
});
|
|
1976
|
+
_context91.next = 10;
|
|
1977
|
+
return wait();
|
|
1978
|
+
case 10:
|
|
1979
|
+
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1980
|
+
dispatchEvent(document, 'drop', {
|
|
1981
|
+
dataTransfer: getDataTransferWithEntries([docsDir])
|
|
1982
|
+
});
|
|
1983
|
+
_context91.next = 14;
|
|
1984
|
+
return wait(20);
|
|
1985
|
+
case 14:
|
|
1986
|
+
expect(lastAttachments.length).to.eql(2);
|
|
1987
|
+
expect(_mapInstanceProperty(lastAttachments).call(lastAttachments, function (item) {
|
|
1988
|
+
return item.name;
|
|
1989
|
+
})).to.eql(['docs/note.txt', 'docs/assets/cover.png']);
|
|
1990
|
+
expect(_mapInstanceProperty(lastAttachments).call(lastAttachments, function (item) {
|
|
1991
|
+
return item.relativePath;
|
|
1992
|
+
})).to.eql(['docs/note.txt', 'docs/assets/cover.png']);
|
|
1993
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1994
|
+
case 18:
|
|
1995
|
+
case "end":
|
|
1996
|
+
return _context91.stop();
|
|
1997
|
+
}
|
|
1998
|
+
}, _callee42);
|
|
1999
|
+
})));
|
|
2000
|
+
it('should still validate flattened directory files on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43() {
|
|
2001
|
+
var errorMessage, lastAttachments, Demo, _mount43, element, file, docsDir;
|
|
2002
|
+
return _regeneratorRuntime.wrap(function _callee43$(_context93) {
|
|
2003
|
+
while (1) switch (_context93.prev = _context93.next) {
|
|
2004
|
+
case 0:
|
|
2005
|
+
errorMessage = '';
|
|
2006
|
+
lastAttachments = [];
|
|
2007
|
+
Demo = /*#__PURE__*/function (_Component43) {
|
|
2008
|
+
_inheritsLoose(Demo, _Component43);
|
|
2009
|
+
function Demo() {
|
|
2010
|
+
var _context92;
|
|
2011
|
+
var _this43;
|
|
2012
|
+
for (var _len43 = arguments.length, args = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) {
|
|
2013
|
+
args[_key43] = arguments[_key43];
|
|
2014
|
+
}
|
|
2015
|
+
_this43 = _Component43.call.apply(_Component43, _concatInstanceProperty(_context92 = [this]).call(_context92, args)) || this;
|
|
2016
|
+
_this43.Sender = Sender;
|
|
2017
|
+
_this43.onChange = function (items) {
|
|
2018
|
+
lastAttachments = items;
|
|
2019
|
+
};
|
|
2020
|
+
_this43.onUploadError = function (error) {
|
|
2021
|
+
errorMessage = error.message;
|
|
2022
|
+
};
|
|
2023
|
+
return _this43;
|
|
2024
|
+
}
|
|
2025
|
+
Demo.defaults = function defaults() {
|
|
2026
|
+
return {
|
|
2027
|
+
attachments: []
|
|
2028
|
+
};
|
|
2029
|
+
};
|
|
2030
|
+
return Demo;
|
|
2031
|
+
}(Component);
|
|
2032
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n uploadProps={{directory: true, accept: 'image/*'}}\n ev-$change:attachments={this.onChange}\n ev-uploadError={this.onUploadError}\n />\n ";
|
|
2033
|
+
_mount43 = mount(Demo), element = _mount43[1];
|
|
2034
|
+
file = new File(['hello'], 'hello.txt', {
|
|
2035
|
+
type: 'text/plain'
|
|
2036
|
+
});
|
|
2037
|
+
docsDir = createDragDirectoryEntry('docs', [createDragFileEntry(file)]);
|
|
2038
|
+
dispatchEvent(document, 'dragenter', {
|
|
2039
|
+
dataTransfer: getDataTransfer([file])
|
|
2040
|
+
});
|
|
2041
|
+
_context93.next = 10;
|
|
2042
|
+
return wait();
|
|
2043
|
+
case 10:
|
|
2044
|
+
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
2045
|
+
dispatchEvent(document, 'drop', {
|
|
2046
|
+
dataTransfer: getDataTransferWithEntries([docsDir])
|
|
2047
|
+
});
|
|
2048
|
+
_context93.next = 14;
|
|
2049
|
+
return wait(20);
|
|
2050
|
+
case 14:
|
|
2051
|
+
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
2052
|
+
expect(lastAttachments.length).to.eql(0);
|
|
2053
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
2054
|
+
case 17:
|
|
2055
|
+
case "end":
|
|
2056
|
+
return _context93.stop();
|
|
2057
|
+
}
|
|
2058
|
+
}, _callee43);
|
|
2059
|
+
})));
|
|
2060
|
+
it('should add pasted files when pasteFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44() {
|
|
2061
|
+
var lastAttachments, Demo, _mount44, element, textarea, file;
|
|
2062
|
+
return _regeneratorRuntime.wrap(function _callee44$(_context95) {
|
|
2063
|
+
while (1) switch (_context95.prev = _context95.next) {
|
|
2064
|
+
case 0:
|
|
2065
|
+
lastAttachments = [];
|
|
2066
|
+
Demo = /*#__PURE__*/function (_Component44) {
|
|
2067
|
+
_inheritsLoose(Demo, _Component44);
|
|
2068
|
+
function Demo() {
|
|
2069
|
+
var _context94;
|
|
2070
|
+
var _this44;
|
|
2071
|
+
for (var _len44 = arguments.length, args = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) {
|
|
2072
|
+
args[_key44] = arguments[_key44];
|
|
2073
|
+
}
|
|
2074
|
+
_this44 = _Component44.call.apply(_Component44, _concatInstanceProperty(_context94 = [this]).call(_context94, args)) || this;
|
|
2075
|
+
_this44.Sender = Sender;
|
|
2076
|
+
_this44.onChange = function (items) {
|
|
2077
|
+
lastAttachments = items;
|
|
2078
|
+
};
|
|
2079
|
+
return _this44;
|
|
2080
|
+
}
|
|
2081
|
+
Demo.defaults = function defaults() {
|
|
2082
|
+
return {
|
|
2083
|
+
attachments: []
|
|
2084
|
+
};
|
|
2085
|
+
};
|
|
2086
|
+
return Demo;
|
|
2087
|
+
}(Component);
|
|
2088
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n pasteFile={true}\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
2089
|
+
_mount44 = mount(Demo), element = _mount44[1];
|
|
2090
|
+
textarea = element.querySelector('.k-sender-input');
|
|
2091
|
+
file = new File(['image'], 'cover.png', {
|
|
2092
|
+
type: 'image/png'
|
|
2093
|
+
});
|
|
2094
|
+
dispatchEvent(textarea, 'paste', {
|
|
2095
|
+
clipboardData: getClipboardData([file])
|
|
2096
|
+
});
|
|
2097
|
+
_context95.next = 9;
|
|
2098
|
+
return wait();
|
|
2099
|
+
case 9:
|
|
2100
|
+
expect(lastAttachments.length).to.eql(1);
|
|
2101
|
+
expect(lastAttachments[0].name).to.eql('cover.png');
|
|
2102
|
+
case 11:
|
|
2103
|
+
case "end":
|
|
2104
|
+
return _context95.stop();
|
|
2105
|
+
}
|
|
2106
|
+
}, _callee44);
|
|
2107
|
+
})));
|
|
2108
|
+
it('should trigger uploadError for invalid file type on paste', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45() {
|
|
2109
|
+
var errorMessage, lastAttachments, Demo, _mount45, element, textarea, file;
|
|
2110
|
+
return _regeneratorRuntime.wrap(function _callee45$(_context97) {
|
|
2111
|
+
while (1) switch (_context97.prev = _context97.next) {
|
|
2112
|
+
case 0:
|
|
2113
|
+
errorMessage = '';
|
|
2114
|
+
lastAttachments = [];
|
|
2115
|
+
Demo = /*#__PURE__*/function (_Component45) {
|
|
2116
|
+
_inheritsLoose(Demo, _Component45);
|
|
2117
|
+
function Demo() {
|
|
2118
|
+
var _context96;
|
|
2119
|
+
var _this45;
|
|
2120
|
+
for (var _len45 = arguments.length, args = new Array(_len45), _key45 = 0; _key45 < _len45; _key45++) {
|
|
2121
|
+
args[_key45] = arguments[_key45];
|
|
2122
|
+
}
|
|
2123
|
+
_this45 = _Component45.call.apply(_Component45, _concatInstanceProperty(_context96 = [this]).call(_context96, args)) || this;
|
|
2124
|
+
_this45.Sender = Sender;
|
|
2125
|
+
_this45.onChange = function (items) {
|
|
2126
|
+
lastAttachments = items;
|
|
2127
|
+
};
|
|
2128
|
+
_this45.onUploadError = function (error) {
|
|
2129
|
+
errorMessage = error.message;
|
|
2130
|
+
};
|
|
2131
|
+
return _this45;
|
|
2132
|
+
}
|
|
2133
|
+
Demo.defaults = function defaults() {
|
|
2134
|
+
return {
|
|
2135
|
+
attachments: []
|
|
2136
|
+
};
|
|
2137
|
+
};
|
|
2138
|
+
return Demo;
|
|
2139
|
+
}(Component);
|
|
2140
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n pasteFile={true}\n attachments={this.get('attachments')}\n uploadProps={{accept: 'image/*'}}\n ev-$change:attachments={this.onChange}\n ev-uploadError={this.onUploadError}\n />\n ";
|
|
2141
|
+
_mount45 = mount(Demo), element = _mount45[1];
|
|
2142
|
+
textarea = element.querySelector('.k-sender-input');
|
|
2143
|
+
file = new File(['hello'], 'hello.txt', {
|
|
2144
|
+
type: 'text/plain'
|
|
2145
|
+
});
|
|
2146
|
+
dispatchEvent(textarea, 'paste', {
|
|
2147
|
+
clipboardData: getClipboardData([file])
|
|
2148
|
+
});
|
|
2149
|
+
_context97.next = 10;
|
|
2150
|
+
return wait();
|
|
2151
|
+
case 10:
|
|
2152
|
+
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
2153
|
+
expect(lastAttachments.length).to.eql(0);
|
|
2154
|
+
case 12:
|
|
2155
|
+
case "end":
|
|
2156
|
+
return _context97.stop();
|
|
2157
|
+
}
|
|
2158
|
+
}, _callee45);
|
|
2159
|
+
})));
|
|
2160
|
+
it('should keep native text paste when pasteFile is disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46() {
|
|
2161
|
+
var Demo, _mount46, element, textarea, file, event;
|
|
2162
|
+
return _regeneratorRuntime.wrap(function _callee46$(_context99) {
|
|
2163
|
+
while (1) switch (_context99.prev = _context99.next) {
|
|
2164
|
+
case 0:
|
|
2165
|
+
Demo = /*#__PURE__*/function (_Component46) {
|
|
2166
|
+
_inheritsLoose(Demo, _Component46);
|
|
2167
|
+
function Demo() {
|
|
2168
|
+
var _context98;
|
|
2169
|
+
var _this46;
|
|
2170
|
+
for (var _len46 = arguments.length, args = new Array(_len46), _key46 = 0; _key46 < _len46; _key46++) {
|
|
2171
|
+
args[_key46] = arguments[_key46];
|
|
2172
|
+
}
|
|
2173
|
+
_this46 = _Component46.call.apply(_Component46, _concatInstanceProperty(_context98 = [this]).call(_context98, args)) || this;
|
|
2174
|
+
_this46.Sender = Sender;
|
|
2175
|
+
return _this46;
|
|
2176
|
+
}
|
|
2177
|
+
return Demo;
|
|
2178
|
+
}(Component);
|
|
2179
|
+
Demo.template = "\n const { Sender } = this;\n <Sender />\n ";
|
|
2180
|
+
_mount46 = mount(Demo), element = _mount46[1];
|
|
2181
|
+
textarea = element.querySelector('.k-sender-input');
|
|
2182
|
+
file = new File(['image'], 'cover.png', {
|
|
2183
|
+
type: 'image/png'
|
|
2184
|
+
});
|
|
2185
|
+
event = document.createEvent('Event');
|
|
2186
|
+
event.initEvent('paste', true, true);
|
|
2187
|
+
_Object$assign(event, {
|
|
2188
|
+
clipboardData: getClipboardData([file])
|
|
2189
|
+
});
|
|
2190
|
+
textarea.dispatchEvent(event);
|
|
2191
|
+
_context99.next = 11;
|
|
2192
|
+
return wait();
|
|
2193
|
+
case 11:
|
|
2194
|
+
expect(event.defaultPrevented).to.eql(false);
|
|
2195
|
+
case 12:
|
|
2196
|
+
case "end":
|
|
2197
|
+
return _context99.stop();
|
|
2198
|
+
}
|
|
2199
|
+
}, _callee46);
|
|
2200
|
+
})));
|
|
2201
|
+
});
|