@king-design/vue 3.7.0 → 3.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/__snapshots__/Vue Next Demos.md +399 -0
- package/components/bubble/bubble.d.ts +61 -0
- package/components/bubble/bubble.js +81 -0
- package/components/bubble/bubble.vdt.js +85 -0
- package/components/bubble/index.d.ts +1 -0
- package/components/bubble/index.js +1 -0
- package/components/bubble/index.spec.d.ts +1 -0
- package/components/bubble/index.spec.js +771 -0
- package/components/bubble/styles.d.ts +5 -0
- package/components/bubble/styles.js +53 -0
- package/components/bubble/useBubbleDisplay.d.ts +18 -0
- package/components/bubble/useBubbleDisplay.js +300 -0
- package/components/bubbleList/bubbleList.d.ts +87 -0
- package/components/bubbleList/bubbleList.js +75 -0
- package/components/bubbleList/bubbleList.vdt.js +143 -0
- package/components/bubbleList/index.d.ts +1 -0
- package/components/bubbleList/index.js +1 -0
- package/components/bubbleList/index.spec.d.ts +1 -0
- package/components/bubbleList/index.spec.js +1268 -0
- package/components/bubbleList/item.d.ts +16 -0
- package/components/bubbleList/item.js +27 -0
- package/components/bubbleList/item.vdt.js +36 -0
- package/components/bubbleList/styles.d.ts +5 -0
- package/components/bubbleList/styles.js +33 -0
- package/components/bubbleList/useBubbleList.d.ts +28 -0
- package/components/bubbleList/useBubbleList.js +455 -0
- package/components/checkbox/index.d.ts +3 -3
- package/components/fileCard/fileCard.d.ts +65 -0
- package/components/fileCard/fileCard.js +72 -0
- package/components/fileCard/fileCard.vdt.js +161 -0
- package/components/fileCard/fileCardAssets.d.ts +1 -0
- package/components/fileCard/fileCardAssets.js +54 -0
- package/components/fileCard/fileCardUtils.d.ts +14 -0
- package/components/fileCard/fileCardUtils.js +94 -0
- package/components/fileCard/index.d.ts +2 -0
- package/components/fileCard/index.js +2 -0
- package/components/fileCard/index.spec.d.ts +1 -0
- package/components/fileCard/index.spec.js +1096 -0
- package/components/fileCard/list.d.ts +29 -0
- package/components/fileCard/list.js +46 -0
- package/components/fileCard/list.vdt.js +71 -0
- package/components/fileCard/styles.d.ts +5 -0
- package/components/fileCard/styles.js +83 -0
- package/components/fileCard/useFileCard.d.ts +45 -0
- package/components/fileCard/useFileCard.js +330 -0
- package/components/fileCard/useFileCardList.d.ts +14 -0
- package/components/fileCard/useFileCardList.js +49 -0
- package/components/form/form.js +2 -1
- package/components/media/context.d.ts +6 -0
- package/components/media/context.js +2 -0
- package/components/media/group.d.ts +12 -0
- package/components/media/group.js +32 -0
- package/components/media/group.vdt.js +50 -0
- package/components/media/index.d.ts +2 -0
- package/components/media/index.js +2 -0
- package/components/media/index.spec.d.ts +1 -0
- package/components/media/index.spec.js +1691 -0
- package/components/media/media.d.ts +37 -0
- package/components/media/media.js +67 -0
- package/components/media/media.vdt.js +202 -0
- package/components/media/mediaAssets.d.ts +4 -0
- package/components/media/mediaAssets.js +9 -0
- package/components/media/mediaUtils.d.ts +6 -0
- package/components/media/mediaUtils.js +66 -0
- package/components/media/styles.d.ts +13 -0
- package/components/media/styles.js +52 -0
- package/components/media/types.d.ts +37 -0
- package/components/media/types.js +1 -0
- package/components/media/useMedia.d.ts +70 -0
- package/components/media/useMedia.js +471 -0
- package/components/media/useMediaGroup.d.ts +15 -0
- package/components/media/useMediaGroup.js +136 -0
- package/components/media/useMediaViewer.d.ts +14 -0
- package/components/media/useMediaViewer.js +129 -0
- package/components/media/viewer.d.ts +24 -0
- package/components/media/viewer.js +54 -0
- package/components/media/viewer.vdt.js +100 -0
- package/components/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 +1597 -0
- package/components/sender/sender.d.ts +104 -0
- package/components/sender/sender.js +111 -0
- package/components/sender/sender.vdt.js +230 -0
- package/components/sender/styles.d.ts +5 -0
- package/components/sender/styles.js +56 -0
- package/components/sender/useAutoResize.d.ts +4 -0
- package/components/sender/useAutoResize.js +99 -0
- package/components/sender/useSenderDrag.d.ts +6 -0
- package/components/sender/useSenderDrag.js +320 -0
- package/components/sender/useSenderInput.d.ts +16 -0
- package/components/sender/useSenderInput.js +101 -0
- package/components/sender/useSenderPaste.d.ts +5 -0
- package/components/sender/useSenderPaste.js +36 -0
- package/components/sender/useSenderUpload.d.ts +11 -0
- package/components/sender/useSenderUpload.js +395 -0
- package/components/skeleton/skeleton.d.ts +2 -1
- package/components/skeleton/skeleton.js +1 -1
- package/components/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 +1666 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.d.ts +8 -0
- package/components/xmarkdown/markdown/codeBlockRenderer.js +52 -0
- package/components/xmarkdown/markdown/codeblock.d.ts +8 -0
- package/components/xmarkdown/markdown/codeblock.js +74 -0
- package/components/xmarkdown/markdown/highlight.d.ts +17 -0
- package/components/xmarkdown/markdown/highlight.js +83 -0
- package/components/xmarkdown/markdown/index.d.ts +14 -0
- package/components/xmarkdown/markdown/index.js +14 -0
- package/components/xmarkdown/markdown/mermaid.d.ts +8 -0
- package/components/xmarkdown/markdown/mermaid.js +104 -0
- package/components/xmarkdown/markdown/renderTree.d.ts +54 -0
- package/components/xmarkdown/markdown/renderTree.js +386 -0
- package/components/xmarkdown/markdown/renderer.d.ts +18 -0
- package/components/xmarkdown/markdown/renderer.js +461 -0
- package/components/xmarkdown/markdown/streaming.d.ts +24 -0
- package/components/xmarkdown/markdown/streaming.js +513 -0
- package/components/xmarkdown/markdown/types.d.ts +124 -0
- package/components/xmarkdown/markdown/types.js +6 -0
- package/components/xmarkdown/markdown/utils.d.ts +7 -0
- package/components/xmarkdown/markdown/utils.js +9 -0
- package/components/xmarkdown/markdown.d.ts +1 -0
- package/components/xmarkdown/markdown.js +1 -0
- package/components/xmarkdown/styles.d.ts +5 -0
- package/components/xmarkdown/styles.js +50 -0
- package/components/xmarkdown/useMermaid.d.ts +27 -0
- package/components/xmarkdown/useMermaid.js +745 -0
- package/components/xmarkdown/useXMarkdownContent.d.ts +14 -0
- package/components/xmarkdown/useXMarkdownContent.js +218 -0
- package/components/xmarkdown/useXMarkdownDisplay.d.ts +26 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +569 -0
- package/components/xmarkdown/xmarkdown.d.ts +61 -0
- package/components/xmarkdown/xmarkdown.js +109 -0
- package/components/xmarkdown/xmarkdown.vdt.js +43 -0
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/i18n/en-US.js +29 -1
- package/dist/i18n/en-US.js.map +1 -1
- package/dist/i18n/en-US.min.js +1 -1
- package/dist/index.js +100506 -37457
- 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 +27 -0
- package/i18n/en-US.js +29 -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,1597 @@
|
|
|
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, 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;
|
|
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
|
+
instance.senderRef.focus();
|
|
236
|
+
_context8.next = 7;
|
|
237
|
+
return wait();
|
|
238
|
+
case 7:
|
|
239
|
+
expect(document.activeElement).to.eql(textarea);
|
|
240
|
+
instance.senderRef.blur();
|
|
241
|
+
_context8.next = 11;
|
|
242
|
+
return wait();
|
|
243
|
+
case 11:
|
|
244
|
+
expect(document.activeElement).not.to.eql(textarea);
|
|
245
|
+
case 12:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context8.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee4);
|
|
250
|
+
})));
|
|
251
|
+
it('should expose submit method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
252
|
+
var sent, Demo, _mount5, instance;
|
|
253
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context10) {
|
|
254
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
255
|
+
case 0:
|
|
256
|
+
sent = '';
|
|
257
|
+
Demo = /*#__PURE__*/function (_Component5) {
|
|
258
|
+
_inheritsLoose(Demo, _Component5);
|
|
259
|
+
function Demo() {
|
|
260
|
+
var _context9;
|
|
261
|
+
var _this5;
|
|
262
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
263
|
+
args[_key5] = arguments[_key5];
|
|
264
|
+
}
|
|
265
|
+
_this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
|
|
266
|
+
_this5.Sender = Sender;
|
|
267
|
+
_this5.senderRef = null;
|
|
268
|
+
_this5.onSend = function (payload) {
|
|
269
|
+
sent = payload.value;
|
|
270
|
+
};
|
|
271
|
+
return _this5;
|
|
272
|
+
}
|
|
273
|
+
Demo.defaults = function defaults() {
|
|
274
|
+
return {
|
|
275
|
+
value: 'hello'
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
return Demo;
|
|
279
|
+
}(Component);
|
|
280
|
+
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 ";
|
|
281
|
+
_mount5 = mount(Demo), instance = _mount5[0];
|
|
282
|
+
instance.senderRef.submit();
|
|
283
|
+
_context10.next = 7;
|
|
284
|
+
return wait();
|
|
285
|
+
case 7:
|
|
286
|
+
expect(sent).to.eql('hello');
|
|
287
|
+
expect(instance.get('value')).to.eql('');
|
|
288
|
+
case 9:
|
|
289
|
+
case "end":
|
|
290
|
+
return _context10.stop();
|
|
291
|
+
}
|
|
292
|
+
}, _callee5);
|
|
293
|
+
})));
|
|
294
|
+
it('should expose clear method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
295
|
+
var Demo, _mount6, instance;
|
|
296
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context12) {
|
|
297
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
Demo = /*#__PURE__*/function (_Component6) {
|
|
300
|
+
_inheritsLoose(Demo, _Component6);
|
|
301
|
+
function Demo() {
|
|
302
|
+
var _context11;
|
|
303
|
+
var _this6;
|
|
304
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
305
|
+
args[_key6] = arguments[_key6];
|
|
306
|
+
}
|
|
307
|
+
_this6 = _Component6.call.apply(_Component6, _concatInstanceProperty(_context11 = [this]).call(_context11, args)) || this;
|
|
308
|
+
_this6.Sender = Sender;
|
|
309
|
+
_this6.senderRef = null;
|
|
310
|
+
return _this6;
|
|
311
|
+
}
|
|
312
|
+
Demo.defaults = function defaults() {
|
|
313
|
+
return {
|
|
314
|
+
value: 'hello',
|
|
315
|
+
attachments: [{
|
|
316
|
+
key: 'a',
|
|
317
|
+
uid: 'a',
|
|
318
|
+
name: 'note.txt',
|
|
319
|
+
status: 'done'
|
|
320
|
+
}]
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
return Demo;
|
|
324
|
+
}(Component);
|
|
325
|
+
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 ";
|
|
326
|
+
_mount6 = mount(Demo), instance = _mount6[0];
|
|
327
|
+
instance.senderRef.clear();
|
|
328
|
+
_context12.next = 6;
|
|
329
|
+
return wait();
|
|
330
|
+
case 6:
|
|
331
|
+
expect(instance.get('value')).to.eql('');
|
|
332
|
+
expect(instance.get('attachments')).to.eql([]);
|
|
333
|
+
case 8:
|
|
334
|
+
case "end":
|
|
335
|
+
return _context12.stop();
|
|
336
|
+
}
|
|
337
|
+
}, _callee6);
|
|
338
|
+
})));
|
|
339
|
+
it('should abort uploading attachments when clear method is called', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
340
|
+
var aborted, Demo, revokeObjectURL, revoked, _mount7, instance;
|
|
341
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context14) {
|
|
342
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
343
|
+
case 0:
|
|
344
|
+
aborted = 0;
|
|
345
|
+
Demo = /*#__PURE__*/function (_Component7) {
|
|
346
|
+
_inheritsLoose(Demo, _Component7);
|
|
347
|
+
function Demo() {
|
|
348
|
+
var _context13;
|
|
349
|
+
var _this7;
|
|
350
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
351
|
+
args[_key7] = arguments[_key7];
|
|
352
|
+
}
|
|
353
|
+
_this7 = _Component7.call.apply(_Component7, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
|
|
354
|
+
_this7.Sender = Sender;
|
|
355
|
+
_this7.senderRef = null;
|
|
356
|
+
return _this7;
|
|
357
|
+
}
|
|
358
|
+
Demo.defaults = function defaults() {
|
|
359
|
+
return {
|
|
360
|
+
value: 'hello',
|
|
361
|
+
attachments: [{
|
|
362
|
+
key: 'a',
|
|
363
|
+
uid: 'a',
|
|
364
|
+
name: 'note.txt',
|
|
365
|
+
status: 'loading',
|
|
366
|
+
src: 'blob:test',
|
|
367
|
+
request: {
|
|
368
|
+
abort: function abort() {
|
|
369
|
+
aborted++;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}]
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
return Demo;
|
|
376
|
+
}(Component);
|
|
377
|
+
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 ";
|
|
378
|
+
revokeObjectURL = _URL.revokeObjectURL;
|
|
379
|
+
revoked = '';
|
|
380
|
+
_URL.revokeObjectURL = function (url) {
|
|
381
|
+
revoked = url;
|
|
382
|
+
};
|
|
383
|
+
_mount7 = mount(Demo), instance = _mount7[0];
|
|
384
|
+
instance.senderRef.clear();
|
|
385
|
+
_context14.next = 10;
|
|
386
|
+
return wait();
|
|
387
|
+
case 10:
|
|
388
|
+
expect(aborted).to.eql(1);
|
|
389
|
+
expect(revoked).to.eql('blob:test');
|
|
390
|
+
expect(instance.get('value')).to.eql('');
|
|
391
|
+
expect(instance.get('attachments')).to.eql([]);
|
|
392
|
+
_URL.revokeObjectURL = revokeObjectURL;
|
|
393
|
+
case 15:
|
|
394
|
+
case "end":
|
|
395
|
+
return _context14.stop();
|
|
396
|
+
}
|
|
397
|
+
}, _callee7);
|
|
398
|
+
})));
|
|
399
|
+
it('should expose stopGenerate method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
400
|
+
var stopped, Demo, _mount8, instance;
|
|
401
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context16) {
|
|
402
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
403
|
+
case 0:
|
|
404
|
+
stopped = 0;
|
|
405
|
+
Demo = /*#__PURE__*/function (_Component8) {
|
|
406
|
+
_inheritsLoose(Demo, _Component8);
|
|
407
|
+
function Demo() {
|
|
408
|
+
var _context15;
|
|
409
|
+
var _this8;
|
|
410
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
411
|
+
args[_key8] = arguments[_key8];
|
|
412
|
+
}
|
|
413
|
+
_this8 = _Component8.call.apply(_Component8, _concatInstanceProperty(_context15 = [this]).call(_context15, args)) || this;
|
|
414
|
+
_this8.Sender = Sender;
|
|
415
|
+
_this8.senderRef = null;
|
|
416
|
+
_this8.onStop = function () {
|
|
417
|
+
stopped++;
|
|
418
|
+
};
|
|
419
|
+
return _this8;
|
|
420
|
+
}
|
|
421
|
+
Demo.defaults = function defaults() {
|
|
422
|
+
return {
|
|
423
|
+
generating: true
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
return Demo;
|
|
427
|
+
}(Component);
|
|
428
|
+
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 ";
|
|
429
|
+
_mount8 = mount(Demo), instance = _mount8[0];
|
|
430
|
+
instance.senderRef.stopGenerate();
|
|
431
|
+
_context16.next = 7;
|
|
432
|
+
return wait();
|
|
433
|
+
case 7:
|
|
434
|
+
expect(stopped).to.eql(1);
|
|
435
|
+
instance.set('generating', false);
|
|
436
|
+
_context16.next = 11;
|
|
437
|
+
return wait();
|
|
438
|
+
case 11:
|
|
439
|
+
instance.senderRef.stopGenerate();
|
|
440
|
+
_context16.next = 14;
|
|
441
|
+
return wait();
|
|
442
|
+
case 14:
|
|
443
|
+
expect(stopped).to.eql(1);
|
|
444
|
+
case 15:
|
|
445
|
+
case "end":
|
|
446
|
+
return _context16.stop();
|
|
447
|
+
}
|
|
448
|
+
}, _callee8);
|
|
449
|
+
})));
|
|
450
|
+
it('should NOT submit on Shift+Enter', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
451
|
+
var sentCount, Demo, _mount9, element, textarea;
|
|
452
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context18) {
|
|
453
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
454
|
+
case 0:
|
|
455
|
+
sentCount = 0;
|
|
456
|
+
Demo = /*#__PURE__*/function (_Component9) {
|
|
457
|
+
_inheritsLoose(Demo, _Component9);
|
|
458
|
+
function Demo() {
|
|
459
|
+
var _context17;
|
|
460
|
+
var _this9;
|
|
461
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
462
|
+
args[_key9] = arguments[_key9];
|
|
463
|
+
}
|
|
464
|
+
_this9 = _Component9.call.apply(_Component9, _concatInstanceProperty(_context17 = [this]).call(_context17, args)) || this;
|
|
465
|
+
_this9.Sender = Sender;
|
|
466
|
+
_this9.onSend = function () {
|
|
467
|
+
sentCount++;
|
|
468
|
+
};
|
|
469
|
+
return _this9;
|
|
470
|
+
}
|
|
471
|
+
Demo.defaults = function defaults() {
|
|
472
|
+
return {
|
|
473
|
+
value: 'hi'
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
return Demo;
|
|
477
|
+
}(Component);
|
|
478
|
+
Demo.template = "\n const { Sender } = this;\n <Sender value={this.get('value')} ev-messageSend={this.onSend} />\n ";
|
|
479
|
+
_mount9 = mount(Demo), element = _mount9[1];
|
|
480
|
+
textarea = element.querySelector('.k-sender-input');
|
|
481
|
+
dispatchEvent(textarea, 'keydown', {
|
|
482
|
+
key: 'Enter',
|
|
483
|
+
keyCode: 13,
|
|
484
|
+
shiftKey: true
|
|
485
|
+
});
|
|
486
|
+
_context18.next = 8;
|
|
487
|
+
return wait();
|
|
488
|
+
case 8:
|
|
489
|
+
expect(sentCount).to.eql(0);
|
|
490
|
+
case 9:
|
|
491
|
+
case "end":
|
|
492
|
+
return _context18.stop();
|
|
493
|
+
}
|
|
494
|
+
}, _callee9);
|
|
495
|
+
})));
|
|
496
|
+
it('should switch to stop button when generating and trigger stopGenerate on click', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
497
|
+
var stopped, Demo, _mount10, element, sendBtn;
|
|
498
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context20) {
|
|
499
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
500
|
+
case 0:
|
|
501
|
+
stopped = 0;
|
|
502
|
+
Demo = /*#__PURE__*/function (_Component10) {
|
|
503
|
+
_inheritsLoose(Demo, _Component10);
|
|
504
|
+
function Demo() {
|
|
505
|
+
var _context19;
|
|
506
|
+
var _this10;
|
|
507
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
|
508
|
+
args[_key10] = arguments[_key10];
|
|
509
|
+
}
|
|
510
|
+
_this10 = _Component10.call.apply(_Component10, _concatInstanceProperty(_context19 = [this]).call(_context19, args)) || this;
|
|
511
|
+
_this10.Sender = Sender;
|
|
512
|
+
_this10.onStop = function () {
|
|
513
|
+
stopped++;
|
|
514
|
+
};
|
|
515
|
+
return _this10;
|
|
516
|
+
}
|
|
517
|
+
Demo.defaults = function defaults() {
|
|
518
|
+
return {
|
|
519
|
+
generating: true
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
return Demo;
|
|
523
|
+
}(Component);
|
|
524
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n generating={this.get('generating')}\n ev-stopGenerate={this.onStop}\n />\n ";
|
|
525
|
+
_mount10 = mount(Demo), element = _mount10[1];
|
|
526
|
+
sendBtn = element.querySelector('.k-sender-send-btn'); // 生成中按钮 title 应该为「停止生成」
|
|
527
|
+
expect(sendBtn.title).to.contain('停止');
|
|
528
|
+
// 生成中即使内容为空也是可点的
|
|
529
|
+
expect(sendBtn.disabled).to.eql(false);
|
|
530
|
+
sendBtn.click();
|
|
531
|
+
_context20.next = 10;
|
|
532
|
+
return wait();
|
|
533
|
+
case 10:
|
|
534
|
+
expect(stopped).to.eql(1);
|
|
535
|
+
case 11:
|
|
536
|
+
case "end":
|
|
537
|
+
return _context20.stop();
|
|
538
|
+
}
|
|
539
|
+
}, _callee10);
|
|
540
|
+
})));
|
|
541
|
+
it('should respect disabled prop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
542
|
+
var Demo, _mount11, element, textarea, sendBtn;
|
|
543
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context22) {
|
|
544
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
545
|
+
case 0:
|
|
546
|
+
Demo = /*#__PURE__*/function (_Component11) {
|
|
547
|
+
_inheritsLoose(Demo, _Component11);
|
|
548
|
+
function Demo() {
|
|
549
|
+
var _context21;
|
|
550
|
+
var _this11;
|
|
551
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
|
552
|
+
args[_key11] = arguments[_key11];
|
|
553
|
+
}
|
|
554
|
+
_this11 = _Component11.call.apply(_Component11, _concatInstanceProperty(_context21 = [this]).call(_context21, args)) || this;
|
|
555
|
+
_this11.Sender = Sender;
|
|
556
|
+
return _this11;
|
|
557
|
+
}
|
|
558
|
+
return Demo;
|
|
559
|
+
}(Component);
|
|
560
|
+
Demo.template = "const { Sender } = this; <div><Sender disabled={true} value=\"hi\" /></div>";
|
|
561
|
+
_mount11 = mount(Demo), element = _mount11[1];
|
|
562
|
+
expect(element.querySelector('.k-sender').classList.contains('k-sender-disabled')).to.eql(true);
|
|
563
|
+
textarea = element.querySelector('.k-sender-input');
|
|
564
|
+
expect(textarea.disabled).to.eql(true);
|
|
565
|
+
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
566
|
+
expect(sendBtn.disabled).to.eql(true);
|
|
567
|
+
case 8:
|
|
568
|
+
case "end":
|
|
569
|
+
return _context22.stop();
|
|
570
|
+
}
|
|
571
|
+
}, _callee11);
|
|
572
|
+
})));
|
|
573
|
+
it('should render attachments via FileCardList and emit change on delete', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
574
|
+
var lastAttachments, Demo, _mount12, element, deleteBtn;
|
|
575
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context24) {
|
|
576
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
577
|
+
case 0:
|
|
578
|
+
lastAttachments = null;
|
|
579
|
+
Demo = /*#__PURE__*/function (_Component12) {
|
|
580
|
+
_inheritsLoose(Demo, _Component12);
|
|
581
|
+
function Demo() {
|
|
582
|
+
var _context23;
|
|
583
|
+
var _this12;
|
|
584
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
|
585
|
+
args[_key12] = arguments[_key12];
|
|
586
|
+
}
|
|
587
|
+
_this12 = _Component12.call.apply(_Component12, _concatInstanceProperty(_context23 = [this]).call(_context23, args)) || this;
|
|
588
|
+
_this12.Sender = Sender;
|
|
589
|
+
_this12.onChange = function (items) {
|
|
590
|
+
lastAttachments = items;
|
|
591
|
+
};
|
|
592
|
+
return _this12;
|
|
593
|
+
}
|
|
594
|
+
Demo.defaults = function defaults() {
|
|
595
|
+
return {
|
|
596
|
+
attachments: [{
|
|
597
|
+
key: 'a',
|
|
598
|
+
uid: 'a',
|
|
599
|
+
name: 'note.txt',
|
|
600
|
+
byte: 1024,
|
|
601
|
+
status: 'done'
|
|
602
|
+
}]
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
return Demo;
|
|
606
|
+
}(Component);
|
|
607
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
608
|
+
_mount12 = mount(Demo), element = _mount12[1];
|
|
609
|
+
expect(element.querySelector('.k-sender-attachments')).not.to.eql(null);
|
|
610
|
+
expect(element.querySelectorAll('.k-file-card').length).to.eql(1);
|
|
611
|
+
deleteBtn = element.querySelector('.k-file-card-delete');
|
|
612
|
+
deleteBtn.click();
|
|
613
|
+
_context24.next = 10;
|
|
614
|
+
return wait();
|
|
615
|
+
case 10:
|
|
616
|
+
expect(lastAttachments).not.to.eql(null);
|
|
617
|
+
expect(lastAttachments.length).to.eql(0);
|
|
618
|
+
case 12:
|
|
619
|
+
case "end":
|
|
620
|
+
return _context24.stop();
|
|
621
|
+
}
|
|
622
|
+
}, _callee12);
|
|
623
|
+
})));
|
|
624
|
+
it('should expose attachment click and delete events', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
625
|
+
var _lastDeleted;
|
|
626
|
+
var clickCount, deleteCount, lastDeleted, Demo, _mount13, element, card, deleteBtn;
|
|
627
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context26) {
|
|
628
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
629
|
+
case 0:
|
|
630
|
+
clickCount = 0;
|
|
631
|
+
deleteCount = 0;
|
|
632
|
+
lastDeleted = null;
|
|
633
|
+
Demo = /*#__PURE__*/function (_Component13) {
|
|
634
|
+
_inheritsLoose(Demo, _Component13);
|
|
635
|
+
function Demo() {
|
|
636
|
+
var _context25;
|
|
637
|
+
var _this13;
|
|
638
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
|
639
|
+
args[_key13] = arguments[_key13];
|
|
640
|
+
}
|
|
641
|
+
_this13 = _Component13.call.apply(_Component13, _concatInstanceProperty(_context25 = [this]).call(_context25, args)) || this;
|
|
642
|
+
_this13.Sender = Sender;
|
|
643
|
+
_this13.onAttachmentClick = function () {
|
|
644
|
+
clickCount += 1;
|
|
645
|
+
};
|
|
646
|
+
_this13.onAttachmentDelete = function (item) {
|
|
647
|
+
deleteCount += 1;
|
|
648
|
+
lastDeleted = item;
|
|
649
|
+
};
|
|
650
|
+
return _this13;
|
|
651
|
+
}
|
|
652
|
+
Demo.defaults = function defaults() {
|
|
653
|
+
return {
|
|
654
|
+
attachments: [{
|
|
655
|
+
key: 'a',
|
|
656
|
+
uid: 'a',
|
|
657
|
+
name: 'note.txt',
|
|
658
|
+
byte: 1024,
|
|
659
|
+
status: 'done'
|
|
660
|
+
}]
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
return Demo;
|
|
664
|
+
}(Component);
|
|
665
|
+
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 ";
|
|
666
|
+
_mount13 = mount(Demo), element = _mount13[1];
|
|
667
|
+
card = element.querySelector('.k-file-card');
|
|
668
|
+
card.click();
|
|
669
|
+
_context26.next = 10;
|
|
670
|
+
return wait();
|
|
671
|
+
case 10:
|
|
672
|
+
expect(clickCount).to.eql(1);
|
|
673
|
+
deleteBtn = element.querySelector('.k-file-card-delete');
|
|
674
|
+
deleteBtn.click();
|
|
675
|
+
_context26.next = 15;
|
|
676
|
+
return wait();
|
|
677
|
+
case 15:
|
|
678
|
+
expect(deleteCount).to.eql(1);
|
|
679
|
+
expect((_lastDeleted = lastDeleted) == null ? void 0 : _lastDeleted.name).to.eql('note.txt');
|
|
680
|
+
case 17:
|
|
681
|
+
case "end":
|
|
682
|
+
return _context26.stop();
|
|
683
|
+
}
|
|
684
|
+
}, _callee13);
|
|
685
|
+
})));
|
|
686
|
+
it('should expose send button slot params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
687
|
+
var _context28, _context29;
|
|
688
|
+
var captured, Demo, _mount14, instance, element, btn;
|
|
689
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context30) {
|
|
690
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
691
|
+
case 0:
|
|
692
|
+
captured = null;
|
|
693
|
+
Demo = /*#__PURE__*/function (_Component14) {
|
|
694
|
+
_inheritsLoose(Demo, _Component14);
|
|
695
|
+
function Demo() {
|
|
696
|
+
var _context27;
|
|
697
|
+
var _this14;
|
|
698
|
+
for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
|
|
699
|
+
args[_key14] = arguments[_key14];
|
|
700
|
+
}
|
|
701
|
+
_this14 = _Component14.call.apply(_Component14, _concatInstanceProperty(_context27 = [this]).call(_context27, args)) || this;
|
|
702
|
+
_this14.Sender = Sender;
|
|
703
|
+
_this14.capture = function (p) {
|
|
704
|
+
captured = p;
|
|
705
|
+
};
|
|
706
|
+
return _this14;
|
|
707
|
+
}
|
|
708
|
+
Demo.defaults = function defaults() {
|
|
709
|
+
return {
|
|
710
|
+
value: 'hi',
|
|
711
|
+
generating: false
|
|
712
|
+
};
|
|
713
|
+
};
|
|
714
|
+
return Demo;
|
|
715
|
+
}(Component);
|
|
716
|
+
Demo.template = "\n const { Sender } = this;\n <Sender value={this.get('value')} generating={this.get('generating')}>\n <b:sendButton args=\"scope\">\n <button class=\"custom-send\" disabled={scope.disabled}>\n {scope.generating ? 'STOP' : 'SEND'}\n </button>\n </b:sendButton>\n </Sender>\n ";
|
|
717
|
+
_mount14 = mount(Demo), instance = _mount14[0], element = _mount14[1];
|
|
718
|
+
btn = element.querySelector('.custom-send');
|
|
719
|
+
expect(btn).not.to.eql(null);
|
|
720
|
+
expect(_trimInstanceProperty(_context28 = btn.textContent).call(_context28)).to.eql('SEND');
|
|
721
|
+
instance.set('generating', true);
|
|
722
|
+
_context30.next = 10;
|
|
723
|
+
return wait();
|
|
724
|
+
case 10:
|
|
725
|
+
expect(_trimInstanceProperty(_context29 = element.querySelector('.custom-send').textContent).call(_context29)).to.eql('STOP');
|
|
726
|
+
case 11:
|
|
727
|
+
case "end":
|
|
728
|
+
return _context30.stop();
|
|
729
|
+
}
|
|
730
|
+
}, _callee14);
|
|
731
|
+
})));
|
|
732
|
+
it('should render beforeInput inside shell and configure inside toolbar middle', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
733
|
+
var Demo, _mount15, element, top, tools, shell, middle, left, right, toolbar, children;
|
|
734
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context32) {
|
|
735
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
736
|
+
case 0:
|
|
737
|
+
Demo = /*#__PURE__*/function (_Component15) {
|
|
738
|
+
_inheritsLoose(Demo, _Component15);
|
|
739
|
+
function Demo() {
|
|
740
|
+
var _context31;
|
|
741
|
+
var _this15;
|
|
742
|
+
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
|
743
|
+
args[_key15] = arguments[_key15];
|
|
744
|
+
}
|
|
745
|
+
_this15 = _Component15.call.apply(_Component15, _concatInstanceProperty(_context31 = [this]).call(_context31, args)) || this;
|
|
746
|
+
_this15.Sender = Sender;
|
|
747
|
+
return _this15;
|
|
748
|
+
}
|
|
749
|
+
return Demo;
|
|
750
|
+
}(Component);
|
|
751
|
+
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 ";
|
|
752
|
+
_mount15 = mount(Demo), element = _mount15[1];
|
|
753
|
+
top = element.querySelector('.top-suggest');
|
|
754
|
+
tools = element.querySelector('.bottom-tools');
|
|
755
|
+
expect(top).not.to.eql(null);
|
|
756
|
+
expect(tools).not.to.eql(null);
|
|
757
|
+
// beforeInput 包装容器在 shell 内
|
|
758
|
+
shell = element.querySelector('.k-sender-shell');
|
|
759
|
+
expect(shell.contains(top)).to.eql(true);
|
|
760
|
+
// configure 落在 toolbar 中间
|
|
761
|
+
middle = element.querySelector('.k-sender-toolbar-middle');
|
|
762
|
+
expect(middle).not.to.eql(null);
|
|
763
|
+
expect(middle.contains(tools)).to.eql(true);
|
|
764
|
+
// configure 处于附件按钮和发送按钮之间
|
|
765
|
+
left = element.querySelector('.k-sender-toolbar-left');
|
|
766
|
+
right = element.querySelector('.k-sender-toolbar-right');
|
|
767
|
+
toolbar = element.querySelector('.k-sender-toolbar');
|
|
768
|
+
children = _Array$from(toolbar.children);
|
|
769
|
+
expect(children.indexOf(left)).to.be.lessThan(children.indexOf(middle));
|
|
770
|
+
expect(children.indexOf(middle)).to.be.lessThan(children.indexOf(right));
|
|
771
|
+
case 18:
|
|
772
|
+
case "end":
|
|
773
|
+
return _context32.stop();
|
|
774
|
+
}
|
|
775
|
+
}, _callee15);
|
|
776
|
+
})));
|
|
777
|
+
it('should render header above shell and footer below shell', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
778
|
+
var _context34;
|
|
779
|
+
var Demo, _mount16, element, header, footer, shell;
|
|
780
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context35) {
|
|
781
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
782
|
+
case 0:
|
|
783
|
+
Demo = /*#__PURE__*/function (_Component16) {
|
|
784
|
+
_inheritsLoose(Demo, _Component16);
|
|
785
|
+
function Demo() {
|
|
786
|
+
var _context33;
|
|
787
|
+
var _this16;
|
|
788
|
+
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
|
789
|
+
args[_key16] = arguments[_key16];
|
|
790
|
+
}
|
|
791
|
+
_this16 = _Component16.call.apply(_Component16, _concatInstanceProperty(_context33 = [this]).call(_context33, args)) || this;
|
|
792
|
+
_this16.Sender = Sender;
|
|
793
|
+
return _this16;
|
|
794
|
+
}
|
|
795
|
+
return Demo;
|
|
796
|
+
}(Component);
|
|
797
|
+
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 ";
|
|
798
|
+
_mount16 = mount(Demo), element = _mount16[1];
|
|
799
|
+
header = element.querySelector('.k-sender-header');
|
|
800
|
+
footer = element.querySelector('.k-sender-footer');
|
|
801
|
+
shell = element.querySelector('.k-sender-shell');
|
|
802
|
+
expect(header).not.to.eql(null);
|
|
803
|
+
expect(footer).not.to.eql(null);
|
|
804
|
+
expect(header.querySelector('.new-chat-btn')).not.to.eql(null);
|
|
805
|
+
expect(_trimInstanceProperty(_context34 = footer.querySelector('.sender-disclaimer').textContent).call(_context34)).to.eql('AI生成,仅供参考。');
|
|
806
|
+
expect(shell.contains(header)).to.eql(false);
|
|
807
|
+
expect(shell.contains(footer)).to.eql(false);
|
|
808
|
+
expect(_Array$from(element.children)).to.eql([header, shell, footer]);
|
|
809
|
+
case 13:
|
|
810
|
+
case "end":
|
|
811
|
+
return _context35.stop();
|
|
812
|
+
}
|
|
813
|
+
}, _callee16);
|
|
814
|
+
})));
|
|
815
|
+
// 布局插槽为空时,不保留 header/footer/beforeInput/configure/attachmentsButton 的空壳。
|
|
816
|
+
it('should not render wrappers for empty layout slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
|
817
|
+
var Demo, _mount17, element;
|
|
818
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context37) {
|
|
819
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
820
|
+
case 0:
|
|
821
|
+
Demo = /*#__PURE__*/function (_Component17) {
|
|
822
|
+
_inheritsLoose(Demo, _Component17);
|
|
823
|
+
function Demo() {
|
|
824
|
+
var _context36;
|
|
825
|
+
var _this17;
|
|
826
|
+
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
|
827
|
+
args[_key17] = arguments[_key17];
|
|
828
|
+
}
|
|
829
|
+
_this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context36 = [this]).call(_context36, args)) || this;
|
|
830
|
+
_this17.Sender = Sender;
|
|
831
|
+
return _this17;
|
|
832
|
+
}
|
|
833
|
+
return Demo;
|
|
834
|
+
}(Component);
|
|
835
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender showAttachmentsButton={false}>\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:attachmentsButton>\n <button v-if={false} class=\"empty-attachments-button\" type=\"button\">upload</button>\n </b:attachmentsButton>\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 ";
|
|
836
|
+
_mount17 = mount(Demo), element = _mount17[1];
|
|
837
|
+
expect(element.querySelector('.k-sender-header')).to.eql(null);
|
|
838
|
+
expect(element.querySelector('.k-sender-before-input')).to.eql(null);
|
|
839
|
+
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
840
|
+
expect(element.querySelector('.k-sender-toolbar-middle')).to.eql(null);
|
|
841
|
+
expect(element.querySelector('.k-sender-footer')).to.eql(null);
|
|
842
|
+
expect(element.querySelector('.k-sender-toolbar-right')).not.to.eql(null);
|
|
843
|
+
case 9:
|
|
844
|
+
case "end":
|
|
845
|
+
return _context37.stop();
|
|
846
|
+
}
|
|
847
|
+
}, _callee17);
|
|
848
|
+
})));
|
|
849
|
+
it('should hide attach button and show dashed + box in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
850
|
+
var Demo, _mount18, element, addBox, clicked, fileInput;
|
|
851
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context39) {
|
|
852
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
853
|
+
case 0:
|
|
854
|
+
Demo = /*#__PURE__*/function (_Component18) {
|
|
855
|
+
_inheritsLoose(Demo, _Component18);
|
|
856
|
+
function Demo() {
|
|
857
|
+
var _context38;
|
|
858
|
+
var _this18;
|
|
859
|
+
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
|
|
860
|
+
args[_key18] = arguments[_key18];
|
|
861
|
+
}
|
|
862
|
+
_this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context38 = [this]).call(_context38, args)) || this;
|
|
863
|
+
_this18.Sender = Sender;
|
|
864
|
+
return _this18;
|
|
865
|
+
}
|
|
866
|
+
return Demo;
|
|
867
|
+
}(Component);
|
|
868
|
+
Demo.template = "const { Sender } = this; <div><Sender type=\"image\" /></div>";
|
|
869
|
+
_mount18 = mount(Demo), element = _mount18[1]; // 默认附件按钮隐藏
|
|
870
|
+
expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
|
|
871
|
+
// 图片模式即使没有附件也要展示 FileCardList,用来承载末尾 + 框
|
|
872
|
+
expect(element.querySelector('.k-sender-attachments')).not.to.eql(null);
|
|
873
|
+
addBox = element.querySelector('.k-sender-image-add');
|
|
874
|
+
expect(addBox).not.to.eql(null);
|
|
875
|
+
// 点击 + 框会触发 file input click
|
|
876
|
+
clicked = 0;
|
|
877
|
+
fileInput = element.querySelector('.k-sender-file-input');
|
|
878
|
+
fileInput.addEventListener('click', function (e) {
|
|
879
|
+
clicked++;
|
|
880
|
+
e.preventDefault();
|
|
881
|
+
});
|
|
882
|
+
addBox.click();
|
|
883
|
+
_context39.next = 13;
|
|
884
|
+
return wait();
|
|
885
|
+
case 13:
|
|
886
|
+
expect(clicked).to.eql(1);
|
|
887
|
+
case 14:
|
|
888
|
+
case "end":
|
|
889
|
+
return _context39.stop();
|
|
890
|
+
}
|
|
891
|
+
}, _callee18);
|
|
892
|
+
})));
|
|
893
|
+
it('should let configure start from the left edge in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
894
|
+
var _context41;
|
|
895
|
+
var Demo, _mount19, element, toolbar, middle;
|
|
896
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context42) {
|
|
897
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
898
|
+
case 0:
|
|
899
|
+
Demo = /*#__PURE__*/function (_Component19) {
|
|
900
|
+
_inheritsLoose(Demo, _Component19);
|
|
901
|
+
function Demo() {
|
|
902
|
+
var _context40;
|
|
903
|
+
var _this19;
|
|
904
|
+
for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
|
|
905
|
+
args[_key19] = arguments[_key19];
|
|
906
|
+
}
|
|
907
|
+
_this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context40 = [this]).call(_context40, args)) || this;
|
|
908
|
+
_this19.Sender = Sender;
|
|
909
|
+
return _this19;
|
|
910
|
+
}
|
|
911
|
+
return Demo;
|
|
912
|
+
}(Component);
|
|
913
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\">\n <b:configure>\n <div class=\"image-tools\">\u914D\u7F6E\u9879</div>\n </b:configure>\n </Sender>\n </div>\n ";
|
|
914
|
+
_mount19 = mount(Demo), element = _mount19[1];
|
|
915
|
+
toolbar = element.querySelector('.k-sender-toolbar');
|
|
916
|
+
middle = element.querySelector('.k-sender-toolbar-middle');
|
|
917
|
+
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
918
|
+
expect(toolbar.firstElementChild).to.eql(middle);
|
|
919
|
+
expect(_trimInstanceProperty(_context41 = middle.querySelector('.image-tools').textContent).call(_context41)).to.eql('配置项');
|
|
920
|
+
case 8:
|
|
921
|
+
case "end":
|
|
922
|
+
return _context42.stop();
|
|
923
|
+
}
|
|
924
|
+
}, _callee19);
|
|
925
|
+
})));
|
|
926
|
+
it('should hide + box when reaching uploadProps.limit in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
|
|
927
|
+
var Demo, _mount20, element;
|
|
928
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context44) {
|
|
929
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
930
|
+
case 0:
|
|
931
|
+
Demo = /*#__PURE__*/function (_Component20) {
|
|
932
|
+
_inheritsLoose(Demo, _Component20);
|
|
933
|
+
function Demo() {
|
|
934
|
+
var _context43;
|
|
935
|
+
var _this20;
|
|
936
|
+
for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
|
|
937
|
+
args[_key20] = arguments[_key20];
|
|
938
|
+
}
|
|
939
|
+
_this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
|
|
940
|
+
_this20.Sender = Sender;
|
|
941
|
+
return _this20;
|
|
942
|
+
}
|
|
943
|
+
return Demo;
|
|
944
|
+
}(Component);
|
|
945
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\"\n uploadProps={{limit: 1}}\n attachments={[{key: 'a', uid: 'a', name: 'p.png', type: 'image/png', src: ''}]}\n />\n </div>\n ";
|
|
946
|
+
_mount20 = mount(Demo), element = _mount20[1];
|
|
947
|
+
expect(element.querySelector('.k-sender-image-add')).to.eql(null);
|
|
948
|
+
// 文件卡片仍然渲染
|
|
949
|
+
expect(element.querySelector('.k-file-card')).not.to.eql(null);
|
|
950
|
+
case 5:
|
|
951
|
+
case "end":
|
|
952
|
+
return _context44.stop();
|
|
953
|
+
}
|
|
954
|
+
}, _callee20);
|
|
955
|
+
})));
|
|
956
|
+
it('should render text-mode attachments uniformly as file cards', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
|
|
957
|
+
var Demo, _mount21, element;
|
|
958
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context46) {
|
|
959
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
960
|
+
case 0:
|
|
961
|
+
Demo = /*#__PURE__*/function (_Component21) {
|
|
962
|
+
_inheritsLoose(Demo, _Component21);
|
|
963
|
+
function Demo() {
|
|
964
|
+
var _context45;
|
|
965
|
+
var _this21;
|
|
966
|
+
for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
|
|
967
|
+
args[_key21] = arguments[_key21];
|
|
968
|
+
}
|
|
969
|
+
_this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
|
|
970
|
+
_this21.Sender = Sender;
|
|
971
|
+
return _this21;
|
|
972
|
+
}
|
|
973
|
+
return Demo;
|
|
974
|
+
}(Component);
|
|
975
|
+
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 ";
|
|
976
|
+
_mount21 = mount(Demo), element = _mount21[1]; // 在 text 模式下,图片附件也应当以「文件卡」形式呈现,而不是图片缩略图
|
|
977
|
+
expect(element.querySelectorAll('.k-file-card-file').length).to.eql(2);
|
|
978
|
+
expect(element.querySelectorAll('.k-file-card-media').length).to.eql(0);
|
|
979
|
+
case 5:
|
|
980
|
+
case "end":
|
|
981
|
+
return _context46.stop();
|
|
982
|
+
}
|
|
983
|
+
}, _callee21);
|
|
984
|
+
})));
|
|
985
|
+
it('should keep image media cards (square) in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
|
|
986
|
+
var Demo, _mount22, element;
|
|
987
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context48) {
|
|
988
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
989
|
+
case 0:
|
|
990
|
+
Demo = /*#__PURE__*/function (_Component22) {
|
|
991
|
+
_inheritsLoose(Demo, _Component22);
|
|
992
|
+
function Demo() {
|
|
993
|
+
var _context47;
|
|
994
|
+
var _this22;
|
|
995
|
+
for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
|
|
996
|
+
args[_key22] = arguments[_key22];
|
|
997
|
+
}
|
|
998
|
+
_this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context47 = [this]).call(_context47, args)) || this;
|
|
999
|
+
_this22.Sender = Sender;
|
|
1000
|
+
return _this22;
|
|
1001
|
+
}
|
|
1002
|
+
return Demo;
|
|
1003
|
+
}(Component);
|
|
1004
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n ]} />\n </div>\n ";
|
|
1005
|
+
_mount22 = mount(Demo), element = _mount22[1]; // 图片模式下保留 FileCard 的图片渲染(自带 1:1 裁剪),不强制转成 file 卡片
|
|
1006
|
+
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1007
|
+
case 4:
|
|
1008
|
+
case "end":
|
|
1009
|
+
return _context48.stop();
|
|
1010
|
+
}
|
|
1011
|
+
}, _callee22);
|
|
1012
|
+
})));
|
|
1013
|
+
it('should infer media type from name in image mode when attachment type is generic mime', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
|
|
1014
|
+
var Demo, _mount23, element;
|
|
1015
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context50) {
|
|
1016
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
1017
|
+
case 0:
|
|
1018
|
+
Demo = /*#__PURE__*/function (_Component23) {
|
|
1019
|
+
_inheritsLoose(Demo, _Component23);
|
|
1020
|
+
function Demo() {
|
|
1021
|
+
var _context49;
|
|
1022
|
+
var _this23;
|
|
1023
|
+
for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
|
|
1024
|
+
args[_key23] = arguments[_key23];
|
|
1025
|
+
}
|
|
1026
|
+
_this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context49 = [this]).call(_context49, args)) || this;
|
|
1027
|
+
_this23.Sender = Sender;
|
|
1028
|
+
return _this23;
|
|
1029
|
+
}
|
|
1030
|
+
return Demo;
|
|
1031
|
+
}(Component);
|
|
1032
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'application/octet-stream', src: 'blob:mock'},\n ]} />\n </div>\n ";
|
|
1033
|
+
_mount23 = mount(Demo), element = _mount23[1];
|
|
1034
|
+
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1035
|
+
expect(element.querySelector('.k-file-card-file')).to.eql(null);
|
|
1036
|
+
case 5:
|
|
1037
|
+
case "end":
|
|
1038
|
+
return _context50.stop();
|
|
1039
|
+
}
|
|
1040
|
+
}, _callee23);
|
|
1041
|
+
})));
|
|
1042
|
+
it('should support directory selection and preserve relative path metadata', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
|
|
1043
|
+
var lastAttachments, Demo, _mount24, element, input, file;
|
|
1044
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context52) {
|
|
1045
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
1046
|
+
case 0:
|
|
1047
|
+
lastAttachments = [];
|
|
1048
|
+
Demo = /*#__PURE__*/function (_Component24) {
|
|
1049
|
+
_inheritsLoose(Demo, _Component24);
|
|
1050
|
+
function Demo() {
|
|
1051
|
+
var _context51;
|
|
1052
|
+
var _this24;
|
|
1053
|
+
for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
|
|
1054
|
+
args[_key24] = arguments[_key24];
|
|
1055
|
+
}
|
|
1056
|
+
_this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context51 = [this]).call(_context51, args)) || this;
|
|
1057
|
+
_this24.Sender = Sender;
|
|
1058
|
+
_this24.onChange = function (items) {
|
|
1059
|
+
lastAttachments = items;
|
|
1060
|
+
};
|
|
1061
|
+
return _this24;
|
|
1062
|
+
}
|
|
1063
|
+
Demo.defaults = function defaults() {
|
|
1064
|
+
return {
|
|
1065
|
+
attachments: []
|
|
1066
|
+
};
|
|
1067
|
+
};
|
|
1068
|
+
return Demo;
|
|
1069
|
+
}(Component);
|
|
1070
|
+
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 ";
|
|
1071
|
+
_mount24 = mount(Demo), element = _mount24[1];
|
|
1072
|
+
input = element.querySelector('.k-sender-file-input');
|
|
1073
|
+
expect(input.getAttribute('directory')).to.eql('');
|
|
1074
|
+
expect(input.getAttribute('webkitdirectory')).to.eql('');
|
|
1075
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1076
|
+
type: 'text/plain'
|
|
1077
|
+
});
|
|
1078
|
+
Object.defineProperty(file, 'webkitRelativePath', {
|
|
1079
|
+
value: 'docs/hello.txt',
|
|
1080
|
+
configurable: true
|
|
1081
|
+
});
|
|
1082
|
+
Object.defineProperty(input, 'files', {
|
|
1083
|
+
value: [file],
|
|
1084
|
+
configurable: true
|
|
1085
|
+
});
|
|
1086
|
+
dispatchEvent(input, 'change');
|
|
1087
|
+
_context52.next = 13;
|
|
1088
|
+
return wait();
|
|
1089
|
+
case 13:
|
|
1090
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1091
|
+
expect(lastAttachments[0].name).to.eql('docs/hello.txt');
|
|
1092
|
+
expect(lastAttachments[0].relativePath).to.eql('docs/hello.txt');
|
|
1093
|
+
case 16:
|
|
1094
|
+
case "end":
|
|
1095
|
+
return _context52.stop();
|
|
1096
|
+
}
|
|
1097
|
+
}, _callee24);
|
|
1098
|
+
})));
|
|
1099
|
+
it('should support mapAttachment for runtime uploading items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
|
|
1100
|
+
var _element$querySelecto;
|
|
1101
|
+
var lastAttachments, resolveBeforeUpload, Demo, _mount25, element, input, file;
|
|
1102
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context54) {
|
|
1103
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
1104
|
+
case 0:
|
|
1105
|
+
lastAttachments = [];
|
|
1106
|
+
Demo = /*#__PURE__*/function (_Component25) {
|
|
1107
|
+
_inheritsLoose(Demo, _Component25);
|
|
1108
|
+
function Demo() {
|
|
1109
|
+
var _context53;
|
|
1110
|
+
var _this25;
|
|
1111
|
+
for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
|
|
1112
|
+
args[_key25] = arguments[_key25];
|
|
1113
|
+
}
|
|
1114
|
+
_this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context53 = [this]).call(_context53, args)) || this;
|
|
1115
|
+
_this25.Sender = Sender;
|
|
1116
|
+
_this25.onChange = function (items) {
|
|
1117
|
+
lastAttachments = items;
|
|
1118
|
+
};
|
|
1119
|
+
return _this25;
|
|
1120
|
+
}
|
|
1121
|
+
Demo.defaults = function defaults() {
|
|
1122
|
+
return {
|
|
1123
|
+
attachments: []
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
var _proto = Demo.prototype;
|
|
1127
|
+
_proto.getUploadProps = function getUploadProps() {
|
|
1128
|
+
return {
|
|
1129
|
+
autoUpload: false,
|
|
1130
|
+
beforeUpload: function beforeUpload() {
|
|
1131
|
+
return new _Promise(function (resolve) {
|
|
1132
|
+
resolveBeforeUpload = resolve;
|
|
1133
|
+
});
|
|
1134
|
+
},
|
|
1135
|
+
mapAttachment: function mapAttachment(file) {
|
|
1136
|
+
return {
|
|
1137
|
+
loadingText: "\u4E0A\u4F20\u4E2D " + file.name,
|
|
1138
|
+
errorText: "\u4E0A\u4F20\u5931\u8D25 " + file.name
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
};
|
|
1143
|
+
return Demo;
|
|
1144
|
+
}(Component);
|
|
1145
|
+
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 ";
|
|
1146
|
+
_mount25 = mount(Demo), element = _mount25[1];
|
|
1147
|
+
input = element.querySelector('.k-sender-file-input');
|
|
1148
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1149
|
+
type: 'text/plain'
|
|
1150
|
+
});
|
|
1151
|
+
Object.defineProperty(input, 'files', {
|
|
1152
|
+
value: [file],
|
|
1153
|
+
configurable: true
|
|
1154
|
+
});
|
|
1155
|
+
dispatchEvent(input, 'change');
|
|
1156
|
+
_context54.next = 10;
|
|
1157
|
+
return wait();
|
|
1158
|
+
case 10:
|
|
1159
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1160
|
+
expect(lastAttachments[0].loadingText).to.eql('上传中 hello.txt');
|
|
1161
|
+
expect(lastAttachments[0].errorText).to.eql('上传失败 hello.txt');
|
|
1162
|
+
expect((_element$querySelecto = element.querySelector('.k-file-card-description')) == null ? void 0 : _element$querySelecto.textContent).to.contain('上传中 hello.txt');
|
|
1163
|
+
if (resolveBeforeUpload) {
|
|
1164
|
+
resolveBeforeUpload(true);
|
|
1165
|
+
}
|
|
1166
|
+
case 15:
|
|
1167
|
+
case "end":
|
|
1168
|
+
return _context54.stop();
|
|
1169
|
+
}
|
|
1170
|
+
}, _callee25);
|
|
1171
|
+
})));
|
|
1172
|
+
it('should show fullscreen drag mask and add dropped files when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
|
|
1173
|
+
var lastAttachments, Demo, _mount26, element, file, mask, card, icon, text;
|
|
1174
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context56) {
|
|
1175
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
1176
|
+
case 0:
|
|
1177
|
+
lastAttachments = [];
|
|
1178
|
+
Demo = /*#__PURE__*/function (_Component26) {
|
|
1179
|
+
_inheritsLoose(Demo, _Component26);
|
|
1180
|
+
function Demo() {
|
|
1181
|
+
var _context55;
|
|
1182
|
+
var _this26;
|
|
1183
|
+
for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
|
|
1184
|
+
args[_key26] = arguments[_key26];
|
|
1185
|
+
}
|
|
1186
|
+
_this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
|
|
1187
|
+
_this26.Sender = Sender;
|
|
1188
|
+
_this26.onChange = function (items) {
|
|
1189
|
+
lastAttachments = items;
|
|
1190
|
+
};
|
|
1191
|
+
return _this26;
|
|
1192
|
+
}
|
|
1193
|
+
Demo.defaults = function defaults() {
|
|
1194
|
+
return {
|
|
1195
|
+
attachments: []
|
|
1196
|
+
};
|
|
1197
|
+
};
|
|
1198
|
+
return Demo;
|
|
1199
|
+
}(Component);
|
|
1200
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1201
|
+
_mount26 = mount(Demo), element = _mount26[1];
|
|
1202
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1203
|
+
type: 'text/plain'
|
|
1204
|
+
});
|
|
1205
|
+
dispatchEvent(document, 'dragenter', {
|
|
1206
|
+
dataTransfer: getDataTransfer([file])
|
|
1207
|
+
});
|
|
1208
|
+
_context56.next = 8;
|
|
1209
|
+
return wait();
|
|
1210
|
+
case 8:
|
|
1211
|
+
mask = element.querySelector('.k-sender-drag-mask');
|
|
1212
|
+
card = element.querySelector('.k-sender-drag-card');
|
|
1213
|
+
icon = element.querySelector('.k-sender-drag-card .k-icon');
|
|
1214
|
+
text = element.querySelector('.k-sender-drag-text');
|
|
1215
|
+
expect(mask).not.to.eql(null);
|
|
1216
|
+
expect(text.textContent).to.eql('文件拖动到此处即可上传');
|
|
1217
|
+
expect(getComputedStyle(mask).backgroundColor).to.eql('rgba(255, 255, 255, 0.72)');
|
|
1218
|
+
expect(getComputedStyle(card).flexDirection).to.eql('column');
|
|
1219
|
+
expect(getComputedStyle(icon).color).to.eql('rgb(83, 112, 255)');
|
|
1220
|
+
expect(getComputedStyle(card).boxShadow).to.eql('none');
|
|
1221
|
+
expect(getComputedStyle(card).borderTopWidth).to.eql('0px');
|
|
1222
|
+
dispatchEvent(document, 'drop', {
|
|
1223
|
+
dataTransfer: getDataTransfer([file])
|
|
1224
|
+
});
|
|
1225
|
+
_context56.next = 22;
|
|
1226
|
+
return wait();
|
|
1227
|
+
case 22:
|
|
1228
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1229
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1230
|
+
expect(lastAttachments[0].name).to.eql('hello.txt');
|
|
1231
|
+
case 25:
|
|
1232
|
+
case "end":
|
|
1233
|
+
return _context56.stop();
|
|
1234
|
+
}
|
|
1235
|
+
}, _callee26);
|
|
1236
|
+
})));
|
|
1237
|
+
it('should ignore non-file drags when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
|
|
1238
|
+
var Demo, _mount27, element;
|
|
1239
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context58) {
|
|
1240
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
1241
|
+
case 0:
|
|
1242
|
+
Demo = /*#__PURE__*/function (_Component27) {
|
|
1243
|
+
_inheritsLoose(Demo, _Component27);
|
|
1244
|
+
function Demo() {
|
|
1245
|
+
var _context57;
|
|
1246
|
+
var _this27;
|
|
1247
|
+
for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
|
|
1248
|
+
args[_key27] = arguments[_key27];
|
|
1249
|
+
}
|
|
1250
|
+
_this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context57 = [this]).call(_context57, args)) || this;
|
|
1251
|
+
_this27.Sender = Sender;
|
|
1252
|
+
return _this27;
|
|
1253
|
+
}
|
|
1254
|
+
return Demo;
|
|
1255
|
+
}(Component);
|
|
1256
|
+
Demo.template = "\n const { Sender } = this;\n <Sender dragFile={true} />\n ";
|
|
1257
|
+
_mount27 = mount(Demo), element = _mount27[1];
|
|
1258
|
+
dispatchEvent(document, 'dragenter', {
|
|
1259
|
+
dataTransfer: {
|
|
1260
|
+
types: ['text/plain']
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
_context58.next = 6;
|
|
1264
|
+
return wait();
|
|
1265
|
+
case 6:
|
|
1266
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1267
|
+
case 7:
|
|
1268
|
+
case "end":
|
|
1269
|
+
return _context58.stop();
|
|
1270
|
+
}
|
|
1271
|
+
}, _callee27);
|
|
1272
|
+
})));
|
|
1273
|
+
it('should trigger uploadError for invalid file type on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
|
|
1274
|
+
var errorMessage, lastAttachments, Demo, _mount28, element, file;
|
|
1275
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context60) {
|
|
1276
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
1277
|
+
case 0:
|
|
1278
|
+
errorMessage = '';
|
|
1279
|
+
lastAttachments = [];
|
|
1280
|
+
Demo = /*#__PURE__*/function (_Component28) {
|
|
1281
|
+
_inheritsLoose(Demo, _Component28);
|
|
1282
|
+
function Demo() {
|
|
1283
|
+
var _context59;
|
|
1284
|
+
var _this28;
|
|
1285
|
+
for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
|
|
1286
|
+
args[_key28] = arguments[_key28];
|
|
1287
|
+
}
|
|
1288
|
+
_this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context59 = [this]).call(_context59, args)) || this;
|
|
1289
|
+
_this28.Sender = Sender;
|
|
1290
|
+
_this28.onChange = function (items) {
|
|
1291
|
+
lastAttachments = items;
|
|
1292
|
+
};
|
|
1293
|
+
_this28.onUploadError = function (error) {
|
|
1294
|
+
errorMessage = error.message;
|
|
1295
|
+
};
|
|
1296
|
+
return _this28;
|
|
1297
|
+
}
|
|
1298
|
+
Demo.defaults = function defaults() {
|
|
1299
|
+
return {
|
|
1300
|
+
attachments: []
|
|
1301
|
+
};
|
|
1302
|
+
};
|
|
1303
|
+
return Demo;
|
|
1304
|
+
}(Component);
|
|
1305
|
+
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 ";
|
|
1306
|
+
_mount28 = mount(Demo), element = _mount28[1];
|
|
1307
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1308
|
+
type: 'text/plain'
|
|
1309
|
+
});
|
|
1310
|
+
dispatchEvent(document, 'dragenter', {
|
|
1311
|
+
dataTransfer: getDataTransfer([file])
|
|
1312
|
+
});
|
|
1313
|
+
_context60.next = 9;
|
|
1314
|
+
return wait();
|
|
1315
|
+
case 9:
|
|
1316
|
+
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1317
|
+
dispatchEvent(document, 'drop', {
|
|
1318
|
+
dataTransfer: getDataTransfer([file])
|
|
1319
|
+
});
|
|
1320
|
+
_context60.next = 13;
|
|
1321
|
+
return wait();
|
|
1322
|
+
case 13:
|
|
1323
|
+
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
1324
|
+
expect(lastAttachments.length).to.eql(0);
|
|
1325
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1326
|
+
case 16:
|
|
1327
|
+
case "end":
|
|
1328
|
+
return _context60.stop();
|
|
1329
|
+
}
|
|
1330
|
+
}, _callee28);
|
|
1331
|
+
})));
|
|
1332
|
+
it('should flatten dragged directory files when uploadProps.directory is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
|
|
1333
|
+
var lastAttachments, Demo, _mount29, element, noteFile, imageFile, docsDir;
|
|
1334
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context62) {
|
|
1335
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
1336
|
+
case 0:
|
|
1337
|
+
lastAttachments = [];
|
|
1338
|
+
Demo = /*#__PURE__*/function (_Component29) {
|
|
1339
|
+
_inheritsLoose(Demo, _Component29);
|
|
1340
|
+
function Demo() {
|
|
1341
|
+
var _context61;
|
|
1342
|
+
var _this29;
|
|
1343
|
+
for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
|
|
1344
|
+
args[_key29] = arguments[_key29];
|
|
1345
|
+
}
|
|
1346
|
+
_this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context61 = [this]).call(_context61, args)) || this;
|
|
1347
|
+
_this29.Sender = Sender;
|
|
1348
|
+
_this29.onChange = function (items) {
|
|
1349
|
+
lastAttachments = items;
|
|
1350
|
+
};
|
|
1351
|
+
return _this29;
|
|
1352
|
+
}
|
|
1353
|
+
Demo.defaults = function defaults() {
|
|
1354
|
+
return {
|
|
1355
|
+
attachments: []
|
|
1356
|
+
};
|
|
1357
|
+
};
|
|
1358
|
+
return Demo;
|
|
1359
|
+
}(Component);
|
|
1360
|
+
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 ";
|
|
1361
|
+
_mount29 = mount(Demo), element = _mount29[1];
|
|
1362
|
+
noteFile = new File(['note'], 'note.txt', {
|
|
1363
|
+
type: 'text/plain'
|
|
1364
|
+
});
|
|
1365
|
+
imageFile = new File(['image'], 'cover.png', {
|
|
1366
|
+
type: 'image/png'
|
|
1367
|
+
});
|
|
1368
|
+
docsDir = createDragDirectoryEntry('docs', [createDragFileEntry(noteFile), createDragDirectoryEntry('assets', [createDragFileEntry(imageFile)])]);
|
|
1369
|
+
dispatchEvent(document, 'dragenter', {
|
|
1370
|
+
dataTransfer: getDataTransfer([noteFile])
|
|
1371
|
+
});
|
|
1372
|
+
_context62.next = 10;
|
|
1373
|
+
return wait();
|
|
1374
|
+
case 10:
|
|
1375
|
+
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1376
|
+
dispatchEvent(document, 'drop', {
|
|
1377
|
+
dataTransfer: getDataTransferWithEntries([docsDir])
|
|
1378
|
+
});
|
|
1379
|
+
_context62.next = 14;
|
|
1380
|
+
return wait(20);
|
|
1381
|
+
case 14:
|
|
1382
|
+
expect(lastAttachments.length).to.eql(2);
|
|
1383
|
+
expect(_mapInstanceProperty(lastAttachments).call(lastAttachments, function (item) {
|
|
1384
|
+
return item.name;
|
|
1385
|
+
})).to.eql(['docs/note.txt', 'docs/assets/cover.png']);
|
|
1386
|
+
expect(_mapInstanceProperty(lastAttachments).call(lastAttachments, function (item) {
|
|
1387
|
+
return item.relativePath;
|
|
1388
|
+
})).to.eql(['docs/note.txt', 'docs/assets/cover.png']);
|
|
1389
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1390
|
+
case 18:
|
|
1391
|
+
case "end":
|
|
1392
|
+
return _context62.stop();
|
|
1393
|
+
}
|
|
1394
|
+
}, _callee29);
|
|
1395
|
+
})));
|
|
1396
|
+
it('should still validate flattened directory files on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
|
|
1397
|
+
var errorMessage, lastAttachments, Demo, _mount30, element, file, docsDir;
|
|
1398
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context64) {
|
|
1399
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
1400
|
+
case 0:
|
|
1401
|
+
errorMessage = '';
|
|
1402
|
+
lastAttachments = [];
|
|
1403
|
+
Demo = /*#__PURE__*/function (_Component30) {
|
|
1404
|
+
_inheritsLoose(Demo, _Component30);
|
|
1405
|
+
function Demo() {
|
|
1406
|
+
var _context63;
|
|
1407
|
+
var _this30;
|
|
1408
|
+
for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
|
|
1409
|
+
args[_key30] = arguments[_key30];
|
|
1410
|
+
}
|
|
1411
|
+
_this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context63 = [this]).call(_context63, args)) || this;
|
|
1412
|
+
_this30.Sender = Sender;
|
|
1413
|
+
_this30.onChange = function (items) {
|
|
1414
|
+
lastAttachments = items;
|
|
1415
|
+
};
|
|
1416
|
+
_this30.onUploadError = function (error) {
|
|
1417
|
+
errorMessage = error.message;
|
|
1418
|
+
};
|
|
1419
|
+
return _this30;
|
|
1420
|
+
}
|
|
1421
|
+
Demo.defaults = function defaults() {
|
|
1422
|
+
return {
|
|
1423
|
+
attachments: []
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1426
|
+
return Demo;
|
|
1427
|
+
}(Component);
|
|
1428
|
+
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 ";
|
|
1429
|
+
_mount30 = mount(Demo), element = _mount30[1];
|
|
1430
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1431
|
+
type: 'text/plain'
|
|
1432
|
+
});
|
|
1433
|
+
docsDir = createDragDirectoryEntry('docs', [createDragFileEntry(file)]);
|
|
1434
|
+
dispatchEvent(document, 'dragenter', {
|
|
1435
|
+
dataTransfer: getDataTransfer([file])
|
|
1436
|
+
});
|
|
1437
|
+
_context64.next = 10;
|
|
1438
|
+
return wait();
|
|
1439
|
+
case 10:
|
|
1440
|
+
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1441
|
+
dispatchEvent(document, 'drop', {
|
|
1442
|
+
dataTransfer: getDataTransferWithEntries([docsDir])
|
|
1443
|
+
});
|
|
1444
|
+
_context64.next = 14;
|
|
1445
|
+
return wait(20);
|
|
1446
|
+
case 14:
|
|
1447
|
+
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
1448
|
+
expect(lastAttachments.length).to.eql(0);
|
|
1449
|
+
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1450
|
+
case 17:
|
|
1451
|
+
case "end":
|
|
1452
|
+
return _context64.stop();
|
|
1453
|
+
}
|
|
1454
|
+
}, _callee30);
|
|
1455
|
+
})));
|
|
1456
|
+
it('should add pasted files when pasteFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
1457
|
+
var lastAttachments, Demo, _mount31, element, textarea, file;
|
|
1458
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context66) {
|
|
1459
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
1460
|
+
case 0:
|
|
1461
|
+
lastAttachments = [];
|
|
1462
|
+
Demo = /*#__PURE__*/function (_Component31) {
|
|
1463
|
+
_inheritsLoose(Demo, _Component31);
|
|
1464
|
+
function Demo() {
|
|
1465
|
+
var _context65;
|
|
1466
|
+
var _this31;
|
|
1467
|
+
for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
|
|
1468
|
+
args[_key31] = arguments[_key31];
|
|
1469
|
+
}
|
|
1470
|
+
_this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context65 = [this]).call(_context65, args)) || this;
|
|
1471
|
+
_this31.Sender = Sender;
|
|
1472
|
+
_this31.onChange = function (items) {
|
|
1473
|
+
lastAttachments = items;
|
|
1474
|
+
};
|
|
1475
|
+
return _this31;
|
|
1476
|
+
}
|
|
1477
|
+
Demo.defaults = function defaults() {
|
|
1478
|
+
return {
|
|
1479
|
+
attachments: []
|
|
1480
|
+
};
|
|
1481
|
+
};
|
|
1482
|
+
return Demo;
|
|
1483
|
+
}(Component);
|
|
1484
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n pasteFile={true}\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
1485
|
+
_mount31 = mount(Demo), element = _mount31[1];
|
|
1486
|
+
textarea = element.querySelector('.k-sender-input');
|
|
1487
|
+
file = new File(['image'], 'cover.png', {
|
|
1488
|
+
type: 'image/png'
|
|
1489
|
+
});
|
|
1490
|
+
dispatchEvent(textarea, 'paste', {
|
|
1491
|
+
clipboardData: getClipboardData([file])
|
|
1492
|
+
});
|
|
1493
|
+
_context66.next = 9;
|
|
1494
|
+
return wait();
|
|
1495
|
+
case 9:
|
|
1496
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1497
|
+
expect(lastAttachments[0].name).to.eql('cover.png');
|
|
1498
|
+
case 11:
|
|
1499
|
+
case "end":
|
|
1500
|
+
return _context66.stop();
|
|
1501
|
+
}
|
|
1502
|
+
}, _callee31);
|
|
1503
|
+
})));
|
|
1504
|
+
it('should trigger uploadError for invalid file type on paste', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
|
|
1505
|
+
var errorMessage, lastAttachments, Demo, _mount32, element, textarea, file;
|
|
1506
|
+
return _regeneratorRuntime.wrap(function _callee32$(_context68) {
|
|
1507
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
1508
|
+
case 0:
|
|
1509
|
+
errorMessage = '';
|
|
1510
|
+
lastAttachments = [];
|
|
1511
|
+
Demo = /*#__PURE__*/function (_Component32) {
|
|
1512
|
+
_inheritsLoose(Demo, _Component32);
|
|
1513
|
+
function Demo() {
|
|
1514
|
+
var _context67;
|
|
1515
|
+
var _this32;
|
|
1516
|
+
for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
|
|
1517
|
+
args[_key32] = arguments[_key32];
|
|
1518
|
+
}
|
|
1519
|
+
_this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context67 = [this]).call(_context67, args)) || this;
|
|
1520
|
+
_this32.Sender = Sender;
|
|
1521
|
+
_this32.onChange = function (items) {
|
|
1522
|
+
lastAttachments = items;
|
|
1523
|
+
};
|
|
1524
|
+
_this32.onUploadError = function (error) {
|
|
1525
|
+
errorMessage = error.message;
|
|
1526
|
+
};
|
|
1527
|
+
return _this32;
|
|
1528
|
+
}
|
|
1529
|
+
Demo.defaults = function defaults() {
|
|
1530
|
+
return {
|
|
1531
|
+
attachments: []
|
|
1532
|
+
};
|
|
1533
|
+
};
|
|
1534
|
+
return Demo;
|
|
1535
|
+
}(Component);
|
|
1536
|
+
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 ";
|
|
1537
|
+
_mount32 = mount(Demo), element = _mount32[1];
|
|
1538
|
+
textarea = element.querySelector('.k-sender-input');
|
|
1539
|
+
file = new File(['hello'], 'hello.txt', {
|
|
1540
|
+
type: 'text/plain'
|
|
1541
|
+
});
|
|
1542
|
+
dispatchEvent(textarea, 'paste', {
|
|
1543
|
+
clipboardData: getClipboardData([file])
|
|
1544
|
+
});
|
|
1545
|
+
_context68.next = 10;
|
|
1546
|
+
return wait();
|
|
1547
|
+
case 10:
|
|
1548
|
+
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
1549
|
+
expect(lastAttachments.length).to.eql(0);
|
|
1550
|
+
case 12:
|
|
1551
|
+
case "end":
|
|
1552
|
+
return _context68.stop();
|
|
1553
|
+
}
|
|
1554
|
+
}, _callee32);
|
|
1555
|
+
})));
|
|
1556
|
+
it('should keep native text paste when pasteFile is disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
|
|
1557
|
+
var Demo, _mount33, element, textarea, file, event;
|
|
1558
|
+
return _regeneratorRuntime.wrap(function _callee33$(_context70) {
|
|
1559
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
1560
|
+
case 0:
|
|
1561
|
+
Demo = /*#__PURE__*/function (_Component33) {
|
|
1562
|
+
_inheritsLoose(Demo, _Component33);
|
|
1563
|
+
function Demo() {
|
|
1564
|
+
var _context69;
|
|
1565
|
+
var _this33;
|
|
1566
|
+
for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
|
|
1567
|
+
args[_key33] = arguments[_key33];
|
|
1568
|
+
}
|
|
1569
|
+
_this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context69 = [this]).call(_context69, args)) || this;
|
|
1570
|
+
_this33.Sender = Sender;
|
|
1571
|
+
return _this33;
|
|
1572
|
+
}
|
|
1573
|
+
return Demo;
|
|
1574
|
+
}(Component);
|
|
1575
|
+
Demo.template = "\n const { Sender } = this;\n <Sender />\n ";
|
|
1576
|
+
_mount33 = mount(Demo), element = _mount33[1];
|
|
1577
|
+
textarea = element.querySelector('.k-sender-input');
|
|
1578
|
+
file = new File(['image'], 'cover.png', {
|
|
1579
|
+
type: 'image/png'
|
|
1580
|
+
});
|
|
1581
|
+
event = document.createEvent('Event');
|
|
1582
|
+
event.initEvent('paste', true, true);
|
|
1583
|
+
_Object$assign(event, {
|
|
1584
|
+
clipboardData: getClipboardData([file])
|
|
1585
|
+
});
|
|
1586
|
+
textarea.dispatchEvent(event);
|
|
1587
|
+
_context70.next = 11;
|
|
1588
|
+
return wait();
|
|
1589
|
+
case 11:
|
|
1590
|
+
expect(event.defaultPrevented).to.eql(false);
|
|
1591
|
+
case 12:
|
|
1592
|
+
case "end":
|
|
1593
|
+
return _context70.stop();
|
|
1594
|
+
}
|
|
1595
|
+
}, _callee33);
|
|
1596
|
+
})));
|
|
1597
|
+
});
|