@king-design/vue 3.8.0-beta.0 → 3.8.0-beta.2
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 +74 -74
- package/components/bubble/bubble.d.ts +3 -0
- package/components/bubble/bubble.vdt.js +6 -2
- package/components/bubble/index.spec.js +231 -5
- package/components/bubble/styles.js +1 -1
- package/components/bubble/useBubbleDisplay.d.ts +1 -0
- package/components/bubble/useBubbleDisplay.js +68 -22
- package/components/bubbleList/bubbleList.vdt.js +3 -1
- package/components/bubbleList/index.spec.js +378 -237
- package/components/bubbleList/styles.js +2 -2
- package/components/bubbleList/useBubbleList.js +7 -0
- package/components/fileCard/fileCard.vdt.js +4 -4
- package/components/fileCard/index.spec.js +179 -107
- package/components/fileCard/list.d.ts +2 -1
- package/components/fileCard/list.vdt.js +7 -5
- package/components/fileCard/styles.js +10 -8
- package/components/fileCard/useFileCard.d.ts +1 -1
- package/components/fileCard/useFileCard.js +6 -35
- package/components/media/index.spec.js +774 -585
- package/components/media/media.vdt.js +17 -6
- package/components/media/mediaAssets.d.ts +2 -0
- package/components/media/mediaAssets.js +4 -0
- package/components/media/styles.js +5 -3
- package/components/media/useMedia.d.ts +6 -2
- package/components/media/useMedia.js +28 -6
- package/components/sender/index.spec.js +1146 -476
- package/components/sender/sender.d.ts +28 -5
- package/components/sender/sender.js +17 -6
- package/components/sender/sender.vdt.js +121 -49
- package/components/sender/styles.js +18 -9
- package/components/sender/useAutoResize.js +7 -6
- package/components/sender/useSenderDrag.js +12 -3
- package/components/sender/useSenderInput.d.ts +3 -0
- package/components/sender/useSenderInput.js +20 -3
- package/components/sender/useSenderPaste.js +1 -1
- package/components/sender/useSenderUpload.js +38 -29
- package/components/xmarkdown/index.spec.js +492 -263
- package/components/xmarkdown/markdown/streaming.js +41 -8
- package/components/xmarkdown/styles.js +2 -2
- package/components/xmarkdown/useXMarkdownDisplay.d.ts +1 -0
- package/components/xmarkdown/useXMarkdownDisplay.js +69 -24
- package/components/xmarkdown/xmarkdown.d.ts +3 -0
- package/components/xmarkdown/xmarkdown.vdt.js +6 -2
- package/dist/i18n/en-US.js +1 -0
- package/dist/i18n/en-US.js.map +1 -1
- package/dist/i18n/en-US.min.js +1 -1
- package/dist/index.js +795 -512
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/i18n/en-US.d.ts +1 -0
- package/i18n/en-US.js +1 -0
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
|
|
|
9
9
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
10
10
|
import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
11
11
|
import { Component } from 'intact-vue-next';
|
|
12
|
-
import { dispatchEvent, mount, unmount, wait } from '../../test/utils';
|
|
12
|
+
import { dispatchEvent, getElement, mount, unmount, wait } from '../../test/utils';
|
|
13
13
|
import { Sender } from '.';
|
|
14
14
|
function getDataTransfer(files) {
|
|
15
15
|
var dataTransfer = new DataTransfer();
|
|
@@ -210,7 +210,7 @@ describe('Sender', function () {
|
|
|
210
210
|
}, _callee3);
|
|
211
211
|
})));
|
|
212
212
|
it('should expose focus and blur methods', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
213
|
-
var Demo, _mount4, instance, element, textarea;
|
|
213
|
+
var Demo, _mount4, instance, element, textarea, shell;
|
|
214
214
|
return _regeneratorRuntime.wrap(function _callee4$(_context8) {
|
|
215
215
|
while (1) switch (_context8.prev = _context8.next) {
|
|
216
216
|
case 0:
|
|
@@ -232,17 +232,24 @@ describe('Sender', function () {
|
|
|
232
232
|
Demo.template = "\n const { Sender } = this;\n <Sender ref={(i) => this.senderRef = i} />\n ";
|
|
233
233
|
_mount4 = mount(Demo), instance = _mount4[0], element = _mount4[1];
|
|
234
234
|
textarea = element.querySelector('.k-sender-input');
|
|
235
|
+
shell = element.querySelector('.k-sender-shell');
|
|
235
236
|
instance.senderRef.focus();
|
|
236
|
-
_context8.next =
|
|
237
|
+
_context8.next = 8;
|
|
237
238
|
return wait();
|
|
238
|
-
case
|
|
239
|
+
case 8:
|
|
239
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)');
|
|
240
245
|
instance.senderRef.blur();
|
|
241
|
-
_context8.next =
|
|
246
|
+
_context8.next = 14;
|
|
242
247
|
return wait();
|
|
243
|
-
case
|
|
248
|
+
case 14:
|
|
244
249
|
expect(document.activeElement).not.to.eql(textarea);
|
|
245
|
-
|
|
250
|
+
expect(shell.classList.contains('k-sender-active')).to.be.false;
|
|
251
|
+
expect(getComputedStyle(shell).backdropFilter).to.eql('none');
|
|
252
|
+
case 17:
|
|
246
253
|
case "end":
|
|
247
254
|
return _context8.stop();
|
|
248
255
|
}
|
|
@@ -538,11 +545,12 @@ describe('Sender', function () {
|
|
|
538
545
|
}
|
|
539
546
|
}, _callee10);
|
|
540
547
|
})));
|
|
541
|
-
it('should respect
|
|
542
|
-
var Demo, _mount11,
|
|
548
|
+
it('should respect stopDisabled prop when generating', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
549
|
+
var stopped, Demo, _mount11, instance, element, sendBtn;
|
|
543
550
|
return _regeneratorRuntime.wrap(function _callee11$(_context22) {
|
|
544
551
|
while (1) switch (_context22.prev = _context22.next) {
|
|
545
552
|
case 0:
|
|
553
|
+
stopped = 0;
|
|
546
554
|
Demo = /*#__PURE__*/function (_Component11) {
|
|
547
555
|
_inheritsLoose(Demo, _Component11);
|
|
548
556
|
function Demo() {
|
|
@@ -553,29 +561,55 @@ describe('Sender', function () {
|
|
|
553
561
|
}
|
|
554
562
|
_this11 = _Component11.call.apply(_Component11, _concatInstanceProperty(_context21 = [this]).call(_context21, args)) || this;
|
|
555
563
|
_this11.Sender = Sender;
|
|
564
|
+
_this11.senderRef = null;
|
|
565
|
+
_this11.onStop = function () {
|
|
566
|
+
stopped++;
|
|
567
|
+
};
|
|
556
568
|
return _this11;
|
|
557
569
|
}
|
|
570
|
+
Demo.defaults = function defaults() {
|
|
571
|
+
return {
|
|
572
|
+
stopDisabled: true
|
|
573
|
+
};
|
|
574
|
+
};
|
|
558
575
|
return Demo;
|
|
559
576
|
}(Component);
|
|
560
|
-
Demo.template = "const { Sender } = this
|
|
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);
|
|
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];
|
|
565
579
|
sendBtn = element.querySelector('.k-sender-send-btn');
|
|
580
|
+
expect(sendBtn.title).to.contain('停止');
|
|
566
581
|
expect(sendBtn.disabled).to.eql(true);
|
|
567
|
-
|
|
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:
|
|
568
603
|
case "end":
|
|
569
604
|
return _context22.stop();
|
|
570
605
|
}
|
|
571
606
|
}, _callee11);
|
|
572
607
|
})));
|
|
573
|
-
it('should
|
|
574
|
-
var
|
|
608
|
+
it('should respect disabled prop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
609
|
+
var Demo, _mount12, element, textarea, sendBtn;
|
|
575
610
|
return _regeneratorRuntime.wrap(function _callee12$(_context24) {
|
|
576
611
|
while (1) switch (_context24.prev = _context24.next) {
|
|
577
612
|
case 0:
|
|
578
|
-
lastAttachments = null;
|
|
579
613
|
Demo = /*#__PURE__*/function (_Component12) {
|
|
580
614
|
_inheritsLoose(Demo, _Component12);
|
|
581
615
|
function Demo() {
|
|
@@ -586,50 +620,29 @@ describe('Sender', function () {
|
|
|
586
620
|
}
|
|
587
621
|
_this12 = _Component12.call.apply(_Component12, _concatInstanceProperty(_context23 = [this]).call(_context23, args)) || this;
|
|
588
622
|
_this12.Sender = Sender;
|
|
589
|
-
_this12.onChange = function (items) {
|
|
590
|
-
lastAttachments = items;
|
|
591
|
-
};
|
|
592
623
|
return _this12;
|
|
593
624
|
}
|
|
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
625
|
return Demo;
|
|
606
626
|
}(Component);
|
|
607
|
-
Demo.template = "
|
|
627
|
+
Demo.template = "const { Sender } = this; <div><Sender disabled={true} value=\"hi\" /></div>";
|
|
608
628
|
_mount12 = mount(Demo), element = _mount12[1];
|
|
609
|
-
expect(element.querySelector('.k-sender-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
case 10:
|
|
616
|
-
expect(lastAttachments).not.to.eql(null);
|
|
617
|
-
expect(lastAttachments.length).to.eql(0);
|
|
618
|
-
case 12:
|
|
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:
|
|
619
635
|
case "end":
|
|
620
636
|
return _context24.stop();
|
|
621
637
|
}
|
|
622
638
|
}, _callee12);
|
|
623
639
|
})));
|
|
624
|
-
it('should
|
|
625
|
-
var
|
|
626
|
-
var clickCount, deleteCount, lastDeleted, Demo, _mount13, element, card, deleteBtn;
|
|
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;
|
|
627
642
|
return _regeneratorRuntime.wrap(function _callee13$(_context26) {
|
|
628
643
|
while (1) switch (_context26.prev = _context26.next) {
|
|
629
644
|
case 0:
|
|
630
|
-
|
|
631
|
-
deleteCount = 0;
|
|
632
|
-
lastDeleted = null;
|
|
645
|
+
sentCount = 0;
|
|
633
646
|
Demo = /*#__PURE__*/function (_Component13) {
|
|
634
647
|
_inheritsLoose(Demo, _Component13);
|
|
635
648
|
function Demo() {
|
|
@@ -640,56 +653,56 @@ describe('Sender', function () {
|
|
|
640
653
|
}
|
|
641
654
|
_this13 = _Component13.call.apply(_Component13, _concatInstanceProperty(_context25 = [this]).call(_context25, args)) || this;
|
|
642
655
|
_this13.Sender = Sender;
|
|
643
|
-
_this13.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
_this13.onAttachmentDelete = function (item) {
|
|
647
|
-
deleteCount += 1;
|
|
648
|
-
lastDeleted = item;
|
|
656
|
+
_this13.senderRef = null;
|
|
657
|
+
_this13.onSend = function () {
|
|
658
|
+
sentCount++;
|
|
649
659
|
};
|
|
650
660
|
return _this13;
|
|
651
661
|
}
|
|
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
662
|
return Demo;
|
|
664
663
|
}(Component);
|
|
665
|
-
Demo.template = "\n const { Sender } = this;\n <Sender\n
|
|
666
|
-
_mount13 = mount(Demo), element = _mount13[1];
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
expect(
|
|
673
|
-
|
|
674
|
-
|
|
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
675
|
_context26.next = 15;
|
|
676
676
|
return wait();
|
|
677
677
|
case 15:
|
|
678
|
-
expect(
|
|
679
|
-
|
|
680
|
-
|
|
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:
|
|
681
693
|
case "end":
|
|
682
694
|
return _context26.stop();
|
|
683
695
|
}
|
|
684
696
|
}, _callee13);
|
|
685
697
|
})));
|
|
686
|
-
it('should
|
|
687
|
-
var
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
while (1) switch (_context30.prev = _context30.next) {
|
|
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) {
|
|
691
702
|
case 0:
|
|
692
|
-
|
|
703
|
+
sentCount = 0;
|
|
704
|
+
stopped = 0;
|
|
705
|
+
inputChanged = 0;
|
|
693
706
|
Demo = /*#__PURE__*/function (_Component14) {
|
|
694
707
|
_inheritsLoose(Demo, _Component14);
|
|
695
708
|
function Demo() {
|
|
@@ -700,365 +713,1022 @@ describe('Sender', function () {
|
|
|
700
713
|
}
|
|
701
714
|
_this14 = _Component14.call.apply(_Component14, _concatInstanceProperty(_context27 = [this]).call(_context27, args)) || this;
|
|
702
715
|
_this14.Sender = Sender;
|
|
703
|
-
_this14.
|
|
704
|
-
|
|
716
|
+
_this14.senderRef = null;
|
|
717
|
+
_this14.onSend = function () {
|
|
718
|
+
sentCount++;
|
|
719
|
+
};
|
|
720
|
+
_this14.onStop = function () {
|
|
721
|
+
stopped++;
|
|
722
|
+
};
|
|
723
|
+
_this14.onInputChange = function () {
|
|
724
|
+
inputChanged++;
|
|
705
725
|
};
|
|
706
726
|
return _this14;
|
|
707
727
|
}
|
|
708
|
-
Demo.defaults = function defaults() {
|
|
709
|
-
return {
|
|
710
|
-
value: 'hi',
|
|
711
|
-
generating: false
|
|
712
|
-
};
|
|
713
|
-
};
|
|
714
728
|
return Demo;
|
|
715
729
|
}(Component);
|
|
716
|
-
Demo.template = "\n const { Sender } = this;\n <Sender
|
|
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 ";
|
|
717
731
|
_mount14 = mount(Demo), instance = _mount14[0], element = _mount14[1];
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
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;
|
|
723
755
|
return wait();
|
|
724
|
-
case
|
|
725
|
-
expect(
|
|
726
|
-
|
|
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:
|
|
727
777
|
case "end":
|
|
728
|
-
return
|
|
778
|
+
return _context28.stop();
|
|
729
779
|
}
|
|
730
780
|
}, _callee14);
|
|
731
781
|
})));
|
|
732
|
-
it('should render
|
|
733
|
-
var Demo, _mount15, element,
|
|
734
|
-
return _regeneratorRuntime.wrap(function _callee15$(
|
|
735
|
-
while (1) switch (
|
|
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) {
|
|
736
786
|
case 0:
|
|
787
|
+
lastAttachments = null;
|
|
737
788
|
Demo = /*#__PURE__*/function (_Component15) {
|
|
738
789
|
_inheritsLoose(Demo, _Component15);
|
|
739
790
|
function Demo() {
|
|
740
|
-
var
|
|
791
|
+
var _context29;
|
|
741
792
|
var _this15;
|
|
742
793
|
for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
|
|
743
794
|
args[_key15] = arguments[_key15];
|
|
744
795
|
}
|
|
745
|
-
_this15 = _Component15.call.apply(_Component15, _concatInstanceProperty(
|
|
796
|
+
_this15 = _Component15.call.apply(_Component15, _concatInstanceProperty(_context29 = [this]).call(_context29, args)) || this;
|
|
746
797
|
_this15.Sender = Sender;
|
|
798
|
+
_this15.onChange = function (items) {
|
|
799
|
+
lastAttachments = items;
|
|
800
|
+
};
|
|
747
801
|
return _this15;
|
|
748
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
|
+
};
|
|
749
814
|
return Demo;
|
|
750
815
|
}(Component);
|
|
751
|
-
Demo.template = "\n const { Sender } = this;\n <Sender
|
|
816
|
+
Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
|
|
752
817
|
_mount15 = mount(Demo), element = _mount15[1];
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
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:
|
|
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:
|
|
772
828
|
case "end":
|
|
773
|
-
return
|
|
829
|
+
return _context30.stop();
|
|
774
830
|
}
|
|
775
831
|
}, _callee15);
|
|
776
832
|
})));
|
|
777
|
-
it('should
|
|
778
|
-
var
|
|
779
|
-
var Demo, _mount16, element,
|
|
780
|
-
return _regeneratorRuntime.wrap(function _callee16$(
|
|
781
|
-
while (1) switch (
|
|
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) {
|
|
782
838
|
case 0:
|
|
839
|
+
clickCount = 0;
|
|
840
|
+
deleteCount = 0;
|
|
841
|
+
lastDeleted = null;
|
|
783
842
|
Demo = /*#__PURE__*/function (_Component16) {
|
|
784
843
|
_inheritsLoose(Demo, _Component16);
|
|
785
844
|
function Demo() {
|
|
786
|
-
var
|
|
845
|
+
var _context31;
|
|
787
846
|
var _this16;
|
|
788
847
|
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
|
|
789
848
|
args[_key16] = arguments[_key16];
|
|
790
849
|
}
|
|
791
|
-
_this16 = _Component16.call.apply(_Component16, _concatInstanceProperty(
|
|
850
|
+
_this16 = _Component16.call.apply(_Component16, _concatInstanceProperty(_context31 = [this]).call(_context31, args)) || this;
|
|
792
851
|
_this16.Sender = Sender;
|
|
852
|
+
_this16.onAttachmentClick = function () {
|
|
853
|
+
clickCount += 1;
|
|
854
|
+
};
|
|
855
|
+
_this16.onAttachmentDelete = function (item) {
|
|
856
|
+
deleteCount += 1;
|
|
857
|
+
lastDeleted = item;
|
|
858
|
+
};
|
|
793
859
|
return _this16;
|
|
794
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
|
+
};
|
|
795
872
|
return Demo;
|
|
796
873
|
}(Component);
|
|
797
|
-
Demo.template = "\n const { Sender } = this;\n <Sender
|
|
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 ";
|
|
798
875
|
_mount16 = mount(Demo), element = _mount16[1];
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
expect(
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
case
|
|
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:
|
|
810
890
|
case "end":
|
|
811
|
-
return
|
|
891
|
+
return _context32.stop();
|
|
812
892
|
}
|
|
813
893
|
}, _callee16);
|
|
814
894
|
})));
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
var Demo, _mount17, element;
|
|
818
|
-
return _regeneratorRuntime.wrap(function _callee17$(
|
|
819
|
-
while (1) switch (
|
|
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) {
|
|
820
900
|
case 0:
|
|
901
|
+
captured = null;
|
|
821
902
|
Demo = /*#__PURE__*/function (_Component17) {
|
|
822
903
|
_inheritsLoose(Demo, _Component17);
|
|
823
904
|
function Demo() {
|
|
824
|
-
var
|
|
905
|
+
var _context33;
|
|
825
906
|
var _this17;
|
|
826
907
|
for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
|
|
827
908
|
args[_key17] = arguments[_key17];
|
|
828
909
|
}
|
|
829
|
-
_this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(
|
|
910
|
+
_this17 = _Component17.call.apply(_Component17, _concatInstanceProperty(_context33 = [this]).call(_context33, args)) || this;
|
|
830
911
|
_this17.Sender = Sender;
|
|
912
|
+
_this17.capture = function (p) {
|
|
913
|
+
captured = p;
|
|
914
|
+
};
|
|
831
915
|
return _this17;
|
|
832
916
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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];
|
|
837
1188
|
expect(element.querySelector('.k-sender-header')).to.eql(null);
|
|
838
1189
|
expect(element.querySelector('.k-sender-before-input')).to.eql(null);
|
|
1190
|
+
expect(element.querySelector('.k-sender-prefix')).to.eql(null);
|
|
839
1191
|
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
840
1192
|
expect(element.querySelector('.k-sender-toolbar-middle')).to.eql(null);
|
|
841
1193
|
expect(element.querySelector('.k-sender-footer')).to.eql(null);
|
|
842
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 shrink textarea min height only when uploadButton is list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
|
|
1344
|
+
var Demo, _mount28, element, toolbarTextarea, listTextarea;
|
|
1345
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context61) {
|
|
1346
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
1347
|
+
case 0:
|
|
1348
|
+
Demo = /*#__PURE__*/function (_Component28) {
|
|
1349
|
+
_inheritsLoose(Demo, _Component28);
|
|
1350
|
+
function Demo() {
|
|
1351
|
+
var _context60;
|
|
1352
|
+
var _this28;
|
|
1353
|
+
for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
|
|
1354
|
+
args[_key28] = arguments[_key28];
|
|
1355
|
+
}
|
|
1356
|
+
_this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context60 = [this]).call(_context60, args)) || this;
|
|
1357
|
+
_this28.Sender = Sender;
|
|
1358
|
+
return _this28;
|
|
1359
|
+
}
|
|
1360
|
+
return Demo;
|
|
1361
|
+
}(Component);
|
|
1362
|
+
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender className=\"sender-toolbar-media\" fileView=\"media\" />\n <Sender className=\"sender-list-card\" uploadButton=\"list\" />\n </div>\n ";
|
|
1363
|
+
_mount28 = mount(Demo), element = _mount28[1];
|
|
1364
|
+
_context61.next = 5;
|
|
1365
|
+
return wait();
|
|
1366
|
+
case 5:
|
|
1367
|
+
toolbarTextarea = element.querySelector('.sender-toolbar-media .k-sender-input');
|
|
1368
|
+
listTextarea = element.querySelector('.sender-list-card .k-sender-input');
|
|
1369
|
+
expect(toolbarTextarea.style.height).to.eql('64px');
|
|
1370
|
+
expect(listTextarea.style.height).to.eql('20px');
|
|
843
1371
|
case 9:
|
|
844
1372
|
case "end":
|
|
845
|
-
return
|
|
1373
|
+
return _context61.stop();
|
|
846
1374
|
}
|
|
847
|
-
},
|
|
1375
|
+
}, _callee28);
|
|
848
1376
|
})));
|
|
849
|
-
it('should
|
|
850
|
-
var Demo,
|
|
851
|
-
return _regeneratorRuntime.wrap(function
|
|
852
|
-
while (1) switch (
|
|
1377
|
+
it('should use 300px as the default shell maxHeight', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
|
|
1378
|
+
var Demo, _mount29, element, shell;
|
|
1379
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context63) {
|
|
1380
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
853
1381
|
case 0:
|
|
854
|
-
Demo = /*#__PURE__*/function (
|
|
855
|
-
_inheritsLoose(Demo,
|
|
1382
|
+
Demo = /*#__PURE__*/function (_Component29) {
|
|
1383
|
+
_inheritsLoose(Demo, _Component29);
|
|
1384
|
+
function Demo() {
|
|
1385
|
+
var _context62;
|
|
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(_context62 = [this]).call(_context62, args)) || this;
|
|
1391
|
+
_this29.Sender = Sender;
|
|
1392
|
+
return _this29;
|
|
1393
|
+
}
|
|
1394
|
+
return Demo;
|
|
1395
|
+
}(Component);
|
|
1396
|
+
Demo.template = "const { Sender } = this; <div><Sender /></div>";
|
|
1397
|
+
_mount29 = mount(Demo), element = _mount29[1];
|
|
1398
|
+
_context63.next = 5;
|
|
1399
|
+
return wait();
|
|
1400
|
+
case 5:
|
|
1401
|
+
shell = element.querySelector('.k-sender-shell');
|
|
1402
|
+
expect(shell.style.maxHeight).to.eql('300px');
|
|
1403
|
+
case 7:
|
|
1404
|
+
case "end":
|
|
1405
|
+
return _context63.stop();
|
|
1406
|
+
}
|
|
1407
|
+
}, _callee29);
|
|
1408
|
+
})));
|
|
1409
|
+
it('should pass uploadButton slot params and render it in toolbar', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
|
|
1410
|
+
var _context65;
|
|
1411
|
+
var Demo, _mount30, element, button;
|
|
1412
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context66) {
|
|
1413
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
1414
|
+
case 0:
|
|
1415
|
+
Demo = /*#__PURE__*/function (_Component30) {
|
|
1416
|
+
_inheritsLoose(Demo, _Component30);
|
|
1417
|
+
function Demo() {
|
|
1418
|
+
var _context64;
|
|
1419
|
+
var _this30;
|
|
1420
|
+
for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
|
|
1421
|
+
args[_key30] = arguments[_key30];
|
|
1422
|
+
}
|
|
1423
|
+
_this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context64 = [this]).call(_context64, args)) || this;
|
|
1424
|
+
_this30.Sender = Sender;
|
|
1425
|
+
return _this30;
|
|
1426
|
+
}
|
|
1427
|
+
return Demo;
|
|
1428
|
+
}(Component);
|
|
1429
|
+
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 ";
|
|
1430
|
+
_mount30 = mount(Demo), element = _mount30[1];
|
|
1431
|
+
button = element.querySelector('.custom-upload');
|
|
1432
|
+
expect(button).not.to.eql(null);
|
|
1433
|
+
expect(_trimInstanceProperty(_context65 = button.textContent).call(_context65)).to.eql('toolbar');
|
|
1434
|
+
expect(button.disabled).to.eql(true);
|
|
1435
|
+
expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
|
|
1436
|
+
case 8:
|
|
1437
|
+
case "end":
|
|
1438
|
+
return _context66.stop();
|
|
1439
|
+
}
|
|
1440
|
+
}, _callee30);
|
|
1441
|
+
})));
|
|
1442
|
+
it('should add local files through uploadButton slot params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
1443
|
+
var lastAttachments, Demo, _mount31, element, button;
|
|
1444
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context68) {
|
|
1445
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
1446
|
+
case 0:
|
|
1447
|
+
lastAttachments = [];
|
|
1448
|
+
Demo = /*#__PURE__*/function (_Component31) {
|
|
1449
|
+
_inheritsLoose(Demo, _Component31);
|
|
856
1450
|
function Demo() {
|
|
857
|
-
var
|
|
858
|
-
var
|
|
859
|
-
for (var
|
|
860
|
-
args[
|
|
1451
|
+
var _context67;
|
|
1452
|
+
var _this31;
|
|
1453
|
+
for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
|
|
1454
|
+
args[_key31] = arguments[_key31];
|
|
861
1455
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
1456
|
+
_this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context67 = [this]).call(_context67, args)) || this;
|
|
1457
|
+
_this31.Sender = Sender;
|
|
1458
|
+
_this31.file = new File(['hello'], 'hello.txt', {
|
|
1459
|
+
type: 'text/plain'
|
|
1460
|
+
});
|
|
1461
|
+
_this31.onChange = function (items) {
|
|
1462
|
+
lastAttachments = items;
|
|
1463
|
+
};
|
|
1464
|
+
return _this31;
|
|
865
1465
|
}
|
|
1466
|
+
Demo.defaults = function defaults() {
|
|
1467
|
+
return {
|
|
1468
|
+
attachments: []
|
|
1469
|
+
};
|
|
1470
|
+
};
|
|
866
1471
|
return Demo;
|
|
867
1472
|
}(Component);
|
|
868
|
-
Demo.template = "const { Sender } = this
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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;
|
|
1473
|
+
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 ";
|
|
1474
|
+
_mount31 = mount(Demo), element = _mount31[1];
|
|
1475
|
+
button = element.querySelector('.custom-add-files');
|
|
1476
|
+
button.click();
|
|
1477
|
+
_context68.next = 8;
|
|
884
1478
|
return wait();
|
|
885
|
-
case
|
|
886
|
-
expect(
|
|
887
|
-
|
|
1479
|
+
case 8:
|
|
1480
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1481
|
+
expect(lastAttachments[0].name).to.eql('hello.txt');
|
|
1482
|
+
expect(lastAttachments[0].status).to.eql('default');
|
|
1483
|
+
case 11:
|
|
888
1484
|
case "end":
|
|
889
|
-
return
|
|
1485
|
+
return _context68.stop();
|
|
890
1486
|
}
|
|
891
|
-
},
|
|
1487
|
+
}, _callee31);
|
|
892
1488
|
})));
|
|
893
|
-
it('should
|
|
894
|
-
var
|
|
895
|
-
var Demo,
|
|
896
|
-
return _regeneratorRuntime.wrap(function
|
|
897
|
-
while (1) switch (
|
|
1489
|
+
it('should render uploadButton slot in attachment list when uploadButton is list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
|
|
1490
|
+
var _context70;
|
|
1491
|
+
var Demo, _mount32, element;
|
|
1492
|
+
return _regeneratorRuntime.wrap(function _callee32$(_context71) {
|
|
1493
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
898
1494
|
case 0:
|
|
899
|
-
Demo = /*#__PURE__*/function (
|
|
900
|
-
_inheritsLoose(Demo,
|
|
1495
|
+
Demo = /*#__PURE__*/function (_Component32) {
|
|
1496
|
+
_inheritsLoose(Demo, _Component32);
|
|
901
1497
|
function Demo() {
|
|
902
|
-
var
|
|
903
|
-
var
|
|
904
|
-
for (var
|
|
905
|
-
args[
|
|
1498
|
+
var _context69;
|
|
1499
|
+
var _this32;
|
|
1500
|
+
for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
|
|
1501
|
+
args[_key32] = arguments[_key32];
|
|
906
1502
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
return
|
|
1503
|
+
_this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context69 = [this]).call(_context69, args)) || this;
|
|
1504
|
+
_this32.Sender = Sender;
|
|
1505
|
+
return _this32;
|
|
910
1506
|
}
|
|
911
1507
|
return Demo;
|
|
912
1508
|
}(Component);
|
|
913
|
-
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender
|
|
914
|
-
|
|
915
|
-
toolbar = element.querySelector('.k-sender-toolbar');
|
|
916
|
-
middle = element.querySelector('.k-sender-toolbar-middle');
|
|
1509
|
+
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 ";
|
|
1510
|
+
_mount32 = mount(Demo), element = _mount32[1];
|
|
917
1511
|
expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
|
|
918
|
-
expect(
|
|
919
|
-
expect(_trimInstanceProperty(
|
|
920
|
-
case
|
|
1512
|
+
expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
|
|
1513
|
+
expect(_trimInstanceProperty(_context70 = element.querySelector('.k-file-card-list-prefix .custom-list-upload').textContent).call(_context70)).to.eql('list');
|
|
1514
|
+
case 6:
|
|
921
1515
|
case "end":
|
|
922
|
-
return
|
|
1516
|
+
return _context71.stop();
|
|
923
1517
|
}
|
|
924
|
-
},
|
|
1518
|
+
}, _callee32);
|
|
925
1519
|
})));
|
|
926
|
-
it('should
|
|
927
|
-
var Demo,
|
|
928
|
-
return _regeneratorRuntime.wrap(function
|
|
929
|
-
while (1) switch (
|
|
1520
|
+
it('should expose addFiles method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
|
|
1521
|
+
var lastAttachments, Demo, _mount33, instance, file;
|
|
1522
|
+
return _regeneratorRuntime.wrap(function _callee33$(_context73) {
|
|
1523
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
930
1524
|
case 0:
|
|
931
|
-
|
|
932
|
-
|
|
1525
|
+
lastAttachments = [];
|
|
1526
|
+
Demo = /*#__PURE__*/function (_Component33) {
|
|
1527
|
+
_inheritsLoose(Demo, _Component33);
|
|
933
1528
|
function Demo() {
|
|
934
|
-
var
|
|
935
|
-
var
|
|
936
|
-
for (var
|
|
937
|
-
args[
|
|
1529
|
+
var _context72;
|
|
1530
|
+
var _this33;
|
|
1531
|
+
for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
|
|
1532
|
+
args[_key33] = arguments[_key33];
|
|
938
1533
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1534
|
+
_this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context72 = [this]).call(_context72, args)) || this;
|
|
1535
|
+
_this33.Sender = Sender;
|
|
1536
|
+
_this33.senderRef = null;
|
|
1537
|
+
_this33.onChange = function (items) {
|
|
1538
|
+
lastAttachments = items;
|
|
1539
|
+
};
|
|
1540
|
+
return _this33;
|
|
942
1541
|
}
|
|
1542
|
+
Demo.defaults = function defaults() {
|
|
1543
|
+
return {
|
|
1544
|
+
attachments: []
|
|
1545
|
+
};
|
|
1546
|
+
};
|
|
943
1547
|
return Demo;
|
|
944
1548
|
}(Component);
|
|
945
|
-
Demo.template = "\n const { Sender } = this;\n <
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1549
|
+
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 ";
|
|
1550
|
+
_mount33 = mount(Demo), instance = _mount33[0];
|
|
1551
|
+
file = new File(['hello'], 'dialog.txt', {
|
|
1552
|
+
type: 'text/plain'
|
|
1553
|
+
});
|
|
1554
|
+
instance.senderRef.addFiles([file]);
|
|
1555
|
+
_context73.next = 8;
|
|
1556
|
+
return wait();
|
|
1557
|
+
case 8:
|
|
1558
|
+
expect(lastAttachments.length).to.eql(1);
|
|
1559
|
+
expect(lastAttachments[0].name).to.eql('dialog.txt');
|
|
1560
|
+
expect(lastAttachments[0].status).to.eql('default');
|
|
1561
|
+
case 11:
|
|
951
1562
|
case "end":
|
|
952
|
-
return
|
|
1563
|
+
return _context73.stop();
|
|
953
1564
|
}
|
|
954
|
-
},
|
|
1565
|
+
}, _callee33);
|
|
955
1566
|
})));
|
|
956
|
-
it('should render
|
|
957
|
-
var Demo,
|
|
958
|
-
return _regeneratorRuntime.wrap(function
|
|
959
|
-
while (1) switch (
|
|
1567
|
+
it('should render card-view attachments uniformly as file cards', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
|
|
1568
|
+
var Demo, _mount34, element;
|
|
1569
|
+
return _regeneratorRuntime.wrap(function _callee34$(_context75) {
|
|
1570
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
960
1571
|
case 0:
|
|
961
|
-
Demo = /*#__PURE__*/function (
|
|
962
|
-
_inheritsLoose(Demo,
|
|
1572
|
+
Demo = /*#__PURE__*/function (_Component34) {
|
|
1573
|
+
_inheritsLoose(Demo, _Component34);
|
|
963
1574
|
function Demo() {
|
|
964
|
-
var
|
|
965
|
-
var
|
|
966
|
-
for (var
|
|
967
|
-
args[
|
|
1575
|
+
var _context74;
|
|
1576
|
+
var _this34;
|
|
1577
|
+
for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) {
|
|
1578
|
+
args[_key34] = arguments[_key34];
|
|
968
1579
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
return
|
|
1580
|
+
_this34 = _Component34.call.apply(_Component34, _concatInstanceProperty(_context74 = [this]).call(_context74, args)) || this;
|
|
1581
|
+
_this34.Sender = Sender;
|
|
1582
|
+
return _this34;
|
|
972
1583
|
}
|
|
973
1584
|
return Demo;
|
|
974
1585
|
}(Component);
|
|
975
1586
|
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
|
-
|
|
1587
|
+
_mount34 = mount(Demo), element = _mount34[1]; // card 视图下,图片附件也应当以「文件卡」形式呈现,而不是图片缩略图
|
|
977
1588
|
expect(element.querySelectorAll('.k-file-card-file').length).to.eql(2);
|
|
978
1589
|
expect(element.querySelectorAll('.k-file-card-media').length).to.eql(0);
|
|
979
1590
|
case 5:
|
|
980
1591
|
case "end":
|
|
981
|
-
return
|
|
1592
|
+
return _context75.stop();
|
|
982
1593
|
}
|
|
983
|
-
},
|
|
1594
|
+
}, _callee34);
|
|
984
1595
|
})));
|
|
985
|
-
it('should keep image media cards (square) in
|
|
986
|
-
var Demo,
|
|
987
|
-
return _regeneratorRuntime.wrap(function
|
|
988
|
-
while (1) switch (
|
|
1596
|
+
it('should keep image media cards (square) in media view', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {
|
|
1597
|
+
var Demo, _mount35, element;
|
|
1598
|
+
return _regeneratorRuntime.wrap(function _callee35$(_context77) {
|
|
1599
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
989
1600
|
case 0:
|
|
990
|
-
Demo = /*#__PURE__*/function (
|
|
991
|
-
_inheritsLoose(Demo,
|
|
1601
|
+
Demo = /*#__PURE__*/function (_Component35) {
|
|
1602
|
+
_inheritsLoose(Demo, _Component35);
|
|
992
1603
|
function Demo() {
|
|
993
|
-
var
|
|
994
|
-
var
|
|
995
|
-
for (var
|
|
996
|
-
args[
|
|
1604
|
+
var _context76;
|
|
1605
|
+
var _this35;
|
|
1606
|
+
for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) {
|
|
1607
|
+
args[_key35] = arguments[_key35];
|
|
997
1608
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
return
|
|
1609
|
+
_this35 = _Component35.call.apply(_Component35, _concatInstanceProperty(_context76 = [this]).call(_context76, args)) || this;
|
|
1610
|
+
_this35.Sender = Sender;
|
|
1611
|
+
return _this35;
|
|
1001
1612
|
}
|
|
1002
1613
|
return Demo;
|
|
1003
1614
|
}(Component);
|
|
1004
|
-
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender
|
|
1005
|
-
|
|
1615
|
+
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 ";
|
|
1616
|
+
_mount35 = mount(Demo), element = _mount35[1]; // media 视图下保留 FileCard 的图片渲染(自带 1:1 裁剪),不强制转成 file 卡片
|
|
1006
1617
|
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1007
1618
|
case 4:
|
|
1008
1619
|
case "end":
|
|
1009
|
-
return
|
|
1620
|
+
return _context77.stop();
|
|
1010
1621
|
}
|
|
1011
|
-
},
|
|
1622
|
+
}, _callee35);
|
|
1012
1623
|
})));
|
|
1013
|
-
it('should
|
|
1014
|
-
var Demo,
|
|
1015
|
-
return _regeneratorRuntime.wrap(function
|
|
1016
|
-
while (1) switch (
|
|
1624
|
+
it('should enable name tooltip for Sender media attachments', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {
|
|
1625
|
+
var Demo, _mount36, element, mediaView;
|
|
1626
|
+
return _regeneratorRuntime.wrap(function _callee36$(_context79) {
|
|
1627
|
+
while (1) switch (_context79.prev = _context79.next) {
|
|
1017
1628
|
case 0:
|
|
1018
|
-
Demo = /*#__PURE__*/function (
|
|
1019
|
-
_inheritsLoose(Demo,
|
|
1629
|
+
Demo = /*#__PURE__*/function (_Component36) {
|
|
1630
|
+
_inheritsLoose(Demo, _Component36);
|
|
1020
1631
|
function Demo() {
|
|
1021
|
-
var
|
|
1022
|
-
var
|
|
1023
|
-
for (var
|
|
1024
|
-
args[
|
|
1632
|
+
var _context78;
|
|
1633
|
+
var _this36;
|
|
1634
|
+
for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) {
|
|
1635
|
+
args[_key36] = arguments[_key36];
|
|
1025
1636
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
return
|
|
1637
|
+
_this36 = _Component36.call.apply(_Component36, _concatInstanceProperty(_context78 = [this]).call(_context78, args)) || this;
|
|
1638
|
+
_this36.Sender = Sender;
|
|
1639
|
+
return _this36;
|
|
1029
1640
|
}
|
|
1030
1641
|
return Demo;
|
|
1031
1642
|
}(Component);
|
|
1032
|
-
Demo.template = "\n const { Sender } = this;\n <div>\n <Sender
|
|
1033
|
-
|
|
1643
|
+
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 ";
|
|
1644
|
+
_mount36 = mount(Demo), element = _mount36[1];
|
|
1645
|
+
mediaView = element.querySelector('.k-file-card-media-view');
|
|
1646
|
+
expect(mediaView.querySelector('.k-media-name-tooltip-trigger')).not.to.eql(null);
|
|
1647
|
+
expect(mediaView.getAttribute('title')).to.eql(null);
|
|
1648
|
+
case 6:
|
|
1649
|
+
case "end":
|
|
1650
|
+
return _context79.stop();
|
|
1651
|
+
}
|
|
1652
|
+
}, _callee36);
|
|
1653
|
+
})));
|
|
1654
|
+
it('should infer media type from name in media view when attachment type is generic mime', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {
|
|
1655
|
+
var Demo, _mount37, element;
|
|
1656
|
+
return _regeneratorRuntime.wrap(function _callee37$(_context81) {
|
|
1657
|
+
while (1) switch (_context81.prev = _context81.next) {
|
|
1658
|
+
case 0:
|
|
1659
|
+
Demo = /*#__PURE__*/function (_Component37) {
|
|
1660
|
+
_inheritsLoose(Demo, _Component37);
|
|
1661
|
+
function Demo() {
|
|
1662
|
+
var _context80;
|
|
1663
|
+
var _this37;
|
|
1664
|
+
for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) {
|
|
1665
|
+
args[_key37] = arguments[_key37];
|
|
1666
|
+
}
|
|
1667
|
+
_this37 = _Component37.call.apply(_Component37, _concatInstanceProperty(_context80 = [this]).call(_context80, args)) || this;
|
|
1668
|
+
_this37.Sender = Sender;
|
|
1669
|
+
return _this37;
|
|
1670
|
+
}
|
|
1671
|
+
return Demo;
|
|
1672
|
+
}(Component);
|
|
1673
|
+
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 ";
|
|
1674
|
+
_mount37 = mount(Demo), element = _mount37[1];
|
|
1034
1675
|
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1035
1676
|
expect(element.querySelector('.k-file-card-file')).to.eql(null);
|
|
1036
1677
|
case 5:
|
|
1037
1678
|
case "end":
|
|
1038
|
-
return
|
|
1679
|
+
return _context81.stop();
|
|
1039
1680
|
}
|
|
1040
|
-
},
|
|
1681
|
+
}, _callee37);
|
|
1682
|
+
})));
|
|
1683
|
+
it('should keep explicit image type in media view even when src has no extension', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {
|
|
1684
|
+
var Demo, _mount38, element;
|
|
1685
|
+
return _regeneratorRuntime.wrap(function _callee38$(_context83) {
|
|
1686
|
+
while (1) switch (_context83.prev = _context83.next) {
|
|
1687
|
+
case 0:
|
|
1688
|
+
Demo = /*#__PURE__*/function (_Component38) {
|
|
1689
|
+
_inheritsLoose(Demo, _Component38);
|
|
1690
|
+
function Demo() {
|
|
1691
|
+
var _context82;
|
|
1692
|
+
var _this38;
|
|
1693
|
+
for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) {
|
|
1694
|
+
args[_key38] = arguments[_key38];
|
|
1695
|
+
}
|
|
1696
|
+
_this38 = _Component38.call.apply(_Component38, _concatInstanceProperty(_context82 = [this]).call(_context82, args)) || this;
|
|
1697
|
+
_this38.Sender = Sender;
|
|
1698
|
+
return _this38;
|
|
1699
|
+
}
|
|
1700
|
+
return Demo;
|
|
1701
|
+
}(Component);
|
|
1702
|
+
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 ";
|
|
1703
|
+
_mount38 = mount(Demo), element = _mount38[1];
|
|
1704
|
+
expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
|
|
1705
|
+
expect(element.querySelector('.k-media-image')).not.to.eql(null);
|
|
1706
|
+
case 5:
|
|
1707
|
+
case "end":
|
|
1708
|
+
return _context83.stop();
|
|
1709
|
+
}
|
|
1710
|
+
}, _callee38);
|
|
1041
1711
|
})));
|
|
1042
|
-
it('should support directory selection and preserve relative path metadata', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1043
|
-
var lastAttachments, Demo,
|
|
1044
|
-
return _regeneratorRuntime.wrap(function
|
|
1045
|
-
while (1) switch (
|
|
1712
|
+
it('should support directory selection and preserve relative path metadata', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {
|
|
1713
|
+
var lastAttachments, Demo, _mount39, element, input, file;
|
|
1714
|
+
return _regeneratorRuntime.wrap(function _callee39$(_context85) {
|
|
1715
|
+
while (1) switch (_context85.prev = _context85.next) {
|
|
1046
1716
|
case 0:
|
|
1047
1717
|
lastAttachments = [];
|
|
1048
|
-
Demo = /*#__PURE__*/function (
|
|
1049
|
-
_inheritsLoose(Demo,
|
|
1718
|
+
Demo = /*#__PURE__*/function (_Component39) {
|
|
1719
|
+
_inheritsLoose(Demo, _Component39);
|
|
1050
1720
|
function Demo() {
|
|
1051
|
-
var
|
|
1052
|
-
var
|
|
1053
|
-
for (var
|
|
1054
|
-
args[
|
|
1721
|
+
var _context84;
|
|
1722
|
+
var _this39;
|
|
1723
|
+
for (var _len39 = arguments.length, args = new Array(_len39), _key39 = 0; _key39 < _len39; _key39++) {
|
|
1724
|
+
args[_key39] = arguments[_key39];
|
|
1055
1725
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1726
|
+
_this39 = _Component39.call.apply(_Component39, _concatInstanceProperty(_context84 = [this]).call(_context84, args)) || this;
|
|
1727
|
+
_this39.Sender = Sender;
|
|
1728
|
+
_this39.onChange = function (items) {
|
|
1059
1729
|
lastAttachments = items;
|
|
1060
1730
|
};
|
|
1061
|
-
return
|
|
1731
|
+
return _this39;
|
|
1062
1732
|
}
|
|
1063
1733
|
Demo.defaults = function defaults() {
|
|
1064
1734
|
return {
|
|
@@ -1068,7 +1738,7 @@ describe('Sender', function () {
|
|
|
1068
1738
|
return Demo;
|
|
1069
1739
|
}(Component);
|
|
1070
1740
|
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
|
-
|
|
1741
|
+
_mount39 = mount(Demo), element = _mount39[1];
|
|
1072
1742
|
input = element.querySelector('.k-sender-file-input');
|
|
1073
1743
|
expect(input.getAttribute('directory')).to.eql('');
|
|
1074
1744
|
expect(input.getAttribute('webkitdirectory')).to.eql('');
|
|
@@ -1084,7 +1754,7 @@ describe('Sender', function () {
|
|
|
1084
1754
|
configurable: true
|
|
1085
1755
|
});
|
|
1086
1756
|
dispatchEvent(input, 'change');
|
|
1087
|
-
|
|
1757
|
+
_context85.next = 13;
|
|
1088
1758
|
return wait();
|
|
1089
1759
|
case 13:
|
|
1090
1760
|
expect(lastAttachments.length).to.eql(1);
|
|
@@ -1092,31 +1762,31 @@ describe('Sender', function () {
|
|
|
1092
1762
|
expect(lastAttachments[0].relativePath).to.eql('docs/hello.txt');
|
|
1093
1763
|
case 16:
|
|
1094
1764
|
case "end":
|
|
1095
|
-
return
|
|
1765
|
+
return _context85.stop();
|
|
1096
1766
|
}
|
|
1097
|
-
},
|
|
1767
|
+
}, _callee39);
|
|
1098
1768
|
})));
|
|
1099
|
-
it('should support mapAttachment for runtime uploading items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1769
|
+
it('should support mapAttachment for runtime uploading items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40() {
|
|
1100
1770
|
var _element$querySelecto;
|
|
1101
|
-
var lastAttachments, resolveBeforeUpload, Demo,
|
|
1102
|
-
return _regeneratorRuntime.wrap(function
|
|
1103
|
-
while (1) switch (
|
|
1771
|
+
var lastAttachments, resolveBeforeUpload, Demo, _mount40, element, input, file;
|
|
1772
|
+
return _regeneratorRuntime.wrap(function _callee40$(_context87) {
|
|
1773
|
+
while (1) switch (_context87.prev = _context87.next) {
|
|
1104
1774
|
case 0:
|
|
1105
1775
|
lastAttachments = [];
|
|
1106
|
-
Demo = /*#__PURE__*/function (
|
|
1107
|
-
_inheritsLoose(Demo,
|
|
1776
|
+
Demo = /*#__PURE__*/function (_Component40) {
|
|
1777
|
+
_inheritsLoose(Demo, _Component40);
|
|
1108
1778
|
function Demo() {
|
|
1109
|
-
var
|
|
1110
|
-
var
|
|
1111
|
-
for (var
|
|
1112
|
-
args[
|
|
1779
|
+
var _context86;
|
|
1780
|
+
var _this40;
|
|
1781
|
+
for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) {
|
|
1782
|
+
args[_key40] = arguments[_key40];
|
|
1113
1783
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1784
|
+
_this40 = _Component40.call.apply(_Component40, _concatInstanceProperty(_context86 = [this]).call(_context86, args)) || this;
|
|
1785
|
+
_this40.Sender = Sender;
|
|
1786
|
+
_this40.onChange = function (items) {
|
|
1117
1787
|
lastAttachments = items;
|
|
1118
1788
|
};
|
|
1119
|
-
return
|
|
1789
|
+
return _this40;
|
|
1120
1790
|
}
|
|
1121
1791
|
Demo.defaults = function defaults() {
|
|
1122
1792
|
return {
|
|
@@ -1143,7 +1813,7 @@ describe('Sender', function () {
|
|
|
1143
1813
|
return Demo;
|
|
1144
1814
|
}(Component);
|
|
1145
1815
|
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
|
-
|
|
1816
|
+
_mount40 = mount(Demo), element = _mount40[1];
|
|
1147
1817
|
input = element.querySelector('.k-sender-file-input');
|
|
1148
1818
|
file = new File(['hello'], 'hello.txt', {
|
|
1149
1819
|
type: 'text/plain'
|
|
@@ -1153,7 +1823,7 @@ describe('Sender', function () {
|
|
|
1153
1823
|
configurable: true
|
|
1154
1824
|
});
|
|
1155
1825
|
dispatchEvent(input, 'change');
|
|
1156
|
-
|
|
1826
|
+
_context87.next = 10;
|
|
1157
1827
|
return wait();
|
|
1158
1828
|
case 10:
|
|
1159
1829
|
expect(lastAttachments.length).to.eql(1);
|
|
@@ -1165,30 +1835,30 @@ describe('Sender', function () {
|
|
|
1165
1835
|
}
|
|
1166
1836
|
case 15:
|
|
1167
1837
|
case "end":
|
|
1168
|
-
return
|
|
1838
|
+
return _context87.stop();
|
|
1169
1839
|
}
|
|
1170
|
-
},
|
|
1840
|
+
}, _callee40);
|
|
1171
1841
|
})));
|
|
1172
|
-
it('should show fullscreen drag mask and add dropped files when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1173
|
-
var lastAttachments, Demo,
|
|
1174
|
-
return _regeneratorRuntime.wrap(function
|
|
1175
|
-
while (1) switch (
|
|
1842
|
+
it('should show fullscreen drag mask and add dropped files when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {
|
|
1843
|
+
var lastAttachments, Demo, _mount41, element, file, mask, card, icon, text;
|
|
1844
|
+
return _regeneratorRuntime.wrap(function _callee41$(_context89) {
|
|
1845
|
+
while (1) switch (_context89.prev = _context89.next) {
|
|
1176
1846
|
case 0:
|
|
1177
1847
|
lastAttachments = [];
|
|
1178
|
-
Demo = /*#__PURE__*/function (
|
|
1179
|
-
_inheritsLoose(Demo,
|
|
1848
|
+
Demo = /*#__PURE__*/function (_Component41) {
|
|
1849
|
+
_inheritsLoose(Demo, _Component41);
|
|
1180
1850
|
function Demo() {
|
|
1181
|
-
var
|
|
1182
|
-
var
|
|
1183
|
-
for (var
|
|
1184
|
-
args[
|
|
1851
|
+
var _context88;
|
|
1852
|
+
var _this41;
|
|
1853
|
+
for (var _len41 = arguments.length, args = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) {
|
|
1854
|
+
args[_key41] = arguments[_key41];
|
|
1185
1855
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1856
|
+
_this41 = _Component41.call.apply(_Component41, _concatInstanceProperty(_context88 = [this]).call(_context88, args)) || this;
|
|
1857
|
+
_this41.Sender = Sender;
|
|
1858
|
+
_this41.onChange = function (items) {
|
|
1189
1859
|
lastAttachments = items;
|
|
1190
1860
|
};
|
|
1191
|
-
return
|
|
1861
|
+
return _this41;
|
|
1192
1862
|
}
|
|
1193
1863
|
Demo.defaults = function defaults() {
|
|
1194
1864
|
return {
|
|
@@ -1198,14 +1868,14 @@ describe('Sender', function () {
|
|
|
1198
1868
|
return Demo;
|
|
1199
1869
|
}(Component);
|
|
1200
1870
|
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
|
-
|
|
1871
|
+
_mount41 = mount(Demo), element = _mount41[1];
|
|
1202
1872
|
file = new File(['hello'], 'hello.txt', {
|
|
1203
1873
|
type: 'text/plain'
|
|
1204
1874
|
});
|
|
1205
1875
|
dispatchEvent(document, 'dragenter', {
|
|
1206
1876
|
dataTransfer: getDataTransfer([file])
|
|
1207
1877
|
});
|
|
1208
|
-
|
|
1878
|
+
_context89.next = 8;
|
|
1209
1879
|
return wait();
|
|
1210
1880
|
case 8:
|
|
1211
1881
|
mask = element.querySelector('.k-sender-drag-mask');
|
|
@@ -1222,7 +1892,7 @@ describe('Sender', function () {
|
|
|
1222
1892
|
dispatchEvent(document, 'drop', {
|
|
1223
1893
|
dataTransfer: getDataTransfer([file])
|
|
1224
1894
|
});
|
|
1225
|
-
|
|
1895
|
+
_context89.next = 22;
|
|
1226
1896
|
return wait();
|
|
1227
1897
|
case 22:
|
|
1228
1898
|
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
@@ -1230,70 +1900,70 @@ describe('Sender', function () {
|
|
|
1230
1900
|
expect(lastAttachments[0].name).to.eql('hello.txt');
|
|
1231
1901
|
case 25:
|
|
1232
1902
|
case "end":
|
|
1233
|
-
return
|
|
1903
|
+
return _context89.stop();
|
|
1234
1904
|
}
|
|
1235
|
-
},
|
|
1905
|
+
}, _callee41);
|
|
1236
1906
|
})));
|
|
1237
|
-
it('should ignore non-file drags when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1238
|
-
var Demo,
|
|
1239
|
-
return _regeneratorRuntime.wrap(function
|
|
1240
|
-
while (1) switch (
|
|
1907
|
+
it('should ignore non-file drags when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42() {
|
|
1908
|
+
var Demo, _mount42, element;
|
|
1909
|
+
return _regeneratorRuntime.wrap(function _callee42$(_context91) {
|
|
1910
|
+
while (1) switch (_context91.prev = _context91.next) {
|
|
1241
1911
|
case 0:
|
|
1242
|
-
Demo = /*#__PURE__*/function (
|
|
1243
|
-
_inheritsLoose(Demo,
|
|
1912
|
+
Demo = /*#__PURE__*/function (_Component42) {
|
|
1913
|
+
_inheritsLoose(Demo, _Component42);
|
|
1244
1914
|
function Demo() {
|
|
1245
|
-
var
|
|
1246
|
-
var
|
|
1247
|
-
for (var
|
|
1248
|
-
args[
|
|
1915
|
+
var _context90;
|
|
1916
|
+
var _this42;
|
|
1917
|
+
for (var _len42 = arguments.length, args = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) {
|
|
1918
|
+
args[_key42] = arguments[_key42];
|
|
1249
1919
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
return
|
|
1920
|
+
_this42 = _Component42.call.apply(_Component42, _concatInstanceProperty(_context90 = [this]).call(_context90, args)) || this;
|
|
1921
|
+
_this42.Sender = Sender;
|
|
1922
|
+
return _this42;
|
|
1253
1923
|
}
|
|
1254
1924
|
return Demo;
|
|
1255
1925
|
}(Component);
|
|
1256
1926
|
Demo.template = "\n const { Sender } = this;\n <Sender dragFile={true} />\n ";
|
|
1257
|
-
|
|
1927
|
+
_mount42 = mount(Demo), element = _mount42[1];
|
|
1258
1928
|
dispatchEvent(document, 'dragenter', {
|
|
1259
1929
|
dataTransfer: {
|
|
1260
1930
|
types: ['text/plain']
|
|
1261
1931
|
}
|
|
1262
1932
|
});
|
|
1263
|
-
|
|
1933
|
+
_context91.next = 6;
|
|
1264
1934
|
return wait();
|
|
1265
1935
|
case 6:
|
|
1266
1936
|
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1267
1937
|
case 7:
|
|
1268
1938
|
case "end":
|
|
1269
|
-
return
|
|
1939
|
+
return _context91.stop();
|
|
1270
1940
|
}
|
|
1271
|
-
},
|
|
1941
|
+
}, _callee42);
|
|
1272
1942
|
})));
|
|
1273
|
-
it('should trigger uploadError for invalid file type on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1274
|
-
var errorMessage, lastAttachments, Demo,
|
|
1275
|
-
return _regeneratorRuntime.wrap(function
|
|
1276
|
-
while (1) switch (
|
|
1943
|
+
it('should trigger uploadError for invalid file type on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43() {
|
|
1944
|
+
var errorMessage, lastAttachments, Demo, _mount43, element, file;
|
|
1945
|
+
return _regeneratorRuntime.wrap(function _callee43$(_context93) {
|
|
1946
|
+
while (1) switch (_context93.prev = _context93.next) {
|
|
1277
1947
|
case 0:
|
|
1278
1948
|
errorMessage = '';
|
|
1279
1949
|
lastAttachments = [];
|
|
1280
|
-
Demo = /*#__PURE__*/function (
|
|
1281
|
-
_inheritsLoose(Demo,
|
|
1950
|
+
Demo = /*#__PURE__*/function (_Component43) {
|
|
1951
|
+
_inheritsLoose(Demo, _Component43);
|
|
1282
1952
|
function Demo() {
|
|
1283
|
-
var
|
|
1284
|
-
var
|
|
1285
|
-
for (var
|
|
1286
|
-
args[
|
|
1953
|
+
var _context92;
|
|
1954
|
+
var _this43;
|
|
1955
|
+
for (var _len43 = arguments.length, args = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) {
|
|
1956
|
+
args[_key43] = arguments[_key43];
|
|
1287
1957
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1958
|
+
_this43 = _Component43.call.apply(_Component43, _concatInstanceProperty(_context92 = [this]).call(_context92, args)) || this;
|
|
1959
|
+
_this43.Sender = Sender;
|
|
1960
|
+
_this43.onChange = function (items) {
|
|
1291
1961
|
lastAttachments = items;
|
|
1292
1962
|
};
|
|
1293
|
-
|
|
1963
|
+
_this43.onUploadError = function (error) {
|
|
1294
1964
|
errorMessage = error.message;
|
|
1295
1965
|
};
|
|
1296
|
-
return
|
|
1966
|
+
return _this43;
|
|
1297
1967
|
}
|
|
1298
1968
|
Demo.defaults = function defaults() {
|
|
1299
1969
|
return {
|
|
@@ -1303,21 +1973,21 @@ describe('Sender', function () {
|
|
|
1303
1973
|
return Demo;
|
|
1304
1974
|
}(Component);
|
|
1305
1975
|
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
|
-
|
|
1976
|
+
_mount43 = mount(Demo), element = _mount43[1];
|
|
1307
1977
|
file = new File(['hello'], 'hello.txt', {
|
|
1308
1978
|
type: 'text/plain'
|
|
1309
1979
|
});
|
|
1310
1980
|
dispatchEvent(document, 'dragenter', {
|
|
1311
1981
|
dataTransfer: getDataTransfer([file])
|
|
1312
1982
|
});
|
|
1313
|
-
|
|
1983
|
+
_context93.next = 9;
|
|
1314
1984
|
return wait();
|
|
1315
1985
|
case 9:
|
|
1316
1986
|
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1317
1987
|
dispatchEvent(document, 'drop', {
|
|
1318
1988
|
dataTransfer: getDataTransfer([file])
|
|
1319
1989
|
});
|
|
1320
|
-
|
|
1990
|
+
_context93.next = 13;
|
|
1321
1991
|
return wait();
|
|
1322
1992
|
case 13:
|
|
1323
1993
|
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
@@ -1325,30 +1995,30 @@ describe('Sender', function () {
|
|
|
1325
1995
|
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1326
1996
|
case 16:
|
|
1327
1997
|
case "end":
|
|
1328
|
-
return
|
|
1998
|
+
return _context93.stop();
|
|
1329
1999
|
}
|
|
1330
|
-
},
|
|
2000
|
+
}, _callee43);
|
|
1331
2001
|
})));
|
|
1332
|
-
it('should flatten dragged directory files when uploadProps.directory is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1333
|
-
var lastAttachments, Demo,
|
|
1334
|
-
return _regeneratorRuntime.wrap(function
|
|
1335
|
-
while (1) switch (
|
|
2002
|
+
it('should flatten dragged directory files when uploadProps.directory is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44() {
|
|
2003
|
+
var lastAttachments, Demo, _mount44, element, noteFile, imageFile, docsDir;
|
|
2004
|
+
return _regeneratorRuntime.wrap(function _callee44$(_context95) {
|
|
2005
|
+
while (1) switch (_context95.prev = _context95.next) {
|
|
1336
2006
|
case 0:
|
|
1337
2007
|
lastAttachments = [];
|
|
1338
|
-
Demo = /*#__PURE__*/function (
|
|
1339
|
-
_inheritsLoose(Demo,
|
|
2008
|
+
Demo = /*#__PURE__*/function (_Component44) {
|
|
2009
|
+
_inheritsLoose(Demo, _Component44);
|
|
1340
2010
|
function Demo() {
|
|
1341
|
-
var
|
|
1342
|
-
var
|
|
1343
|
-
for (var
|
|
1344
|
-
args[
|
|
2011
|
+
var _context94;
|
|
2012
|
+
var _this44;
|
|
2013
|
+
for (var _len44 = arguments.length, args = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) {
|
|
2014
|
+
args[_key44] = arguments[_key44];
|
|
1345
2015
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
2016
|
+
_this44 = _Component44.call.apply(_Component44, _concatInstanceProperty(_context94 = [this]).call(_context94, args)) || this;
|
|
2017
|
+
_this44.Sender = Sender;
|
|
2018
|
+
_this44.onChange = function (items) {
|
|
1349
2019
|
lastAttachments = items;
|
|
1350
2020
|
};
|
|
1351
|
-
return
|
|
2021
|
+
return _this44;
|
|
1352
2022
|
}
|
|
1353
2023
|
Demo.defaults = function defaults() {
|
|
1354
2024
|
return {
|
|
@@ -1358,7 +2028,7 @@ describe('Sender', function () {
|
|
|
1358
2028
|
return Demo;
|
|
1359
2029
|
}(Component);
|
|
1360
2030
|
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
|
-
|
|
2031
|
+
_mount44 = mount(Demo), element = _mount44[1];
|
|
1362
2032
|
noteFile = new File(['note'], 'note.txt', {
|
|
1363
2033
|
type: 'text/plain'
|
|
1364
2034
|
});
|
|
@@ -1369,14 +2039,14 @@ describe('Sender', function () {
|
|
|
1369
2039
|
dispatchEvent(document, 'dragenter', {
|
|
1370
2040
|
dataTransfer: getDataTransfer([noteFile])
|
|
1371
2041
|
});
|
|
1372
|
-
|
|
2042
|
+
_context95.next = 10;
|
|
1373
2043
|
return wait();
|
|
1374
2044
|
case 10:
|
|
1375
2045
|
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1376
2046
|
dispatchEvent(document, 'drop', {
|
|
1377
2047
|
dataTransfer: getDataTransferWithEntries([docsDir])
|
|
1378
2048
|
});
|
|
1379
|
-
|
|
2049
|
+
_context95.next = 14;
|
|
1380
2050
|
return wait(20);
|
|
1381
2051
|
case 14:
|
|
1382
2052
|
expect(lastAttachments.length).to.eql(2);
|
|
@@ -1389,34 +2059,34 @@ describe('Sender', function () {
|
|
|
1389
2059
|
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1390
2060
|
case 18:
|
|
1391
2061
|
case "end":
|
|
1392
|
-
return
|
|
2062
|
+
return _context95.stop();
|
|
1393
2063
|
}
|
|
1394
|
-
},
|
|
2064
|
+
}, _callee44);
|
|
1395
2065
|
})));
|
|
1396
|
-
it('should still validate flattened directory files on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1397
|
-
var errorMessage, lastAttachments, Demo,
|
|
1398
|
-
return _regeneratorRuntime.wrap(function
|
|
1399
|
-
while (1) switch (
|
|
2066
|
+
it('should still validate flattened directory files on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45() {
|
|
2067
|
+
var errorMessage, lastAttachments, Demo, _mount45, element, file, docsDir;
|
|
2068
|
+
return _regeneratorRuntime.wrap(function _callee45$(_context97) {
|
|
2069
|
+
while (1) switch (_context97.prev = _context97.next) {
|
|
1400
2070
|
case 0:
|
|
1401
2071
|
errorMessage = '';
|
|
1402
2072
|
lastAttachments = [];
|
|
1403
|
-
Demo = /*#__PURE__*/function (
|
|
1404
|
-
_inheritsLoose(Demo,
|
|
2073
|
+
Demo = /*#__PURE__*/function (_Component45) {
|
|
2074
|
+
_inheritsLoose(Demo, _Component45);
|
|
1405
2075
|
function Demo() {
|
|
1406
|
-
var
|
|
1407
|
-
var
|
|
1408
|
-
for (var
|
|
1409
|
-
args[
|
|
2076
|
+
var _context96;
|
|
2077
|
+
var _this45;
|
|
2078
|
+
for (var _len45 = arguments.length, args = new Array(_len45), _key45 = 0; _key45 < _len45; _key45++) {
|
|
2079
|
+
args[_key45] = arguments[_key45];
|
|
1410
2080
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
2081
|
+
_this45 = _Component45.call.apply(_Component45, _concatInstanceProperty(_context96 = [this]).call(_context96, args)) || this;
|
|
2082
|
+
_this45.Sender = Sender;
|
|
2083
|
+
_this45.onChange = function (items) {
|
|
1414
2084
|
lastAttachments = items;
|
|
1415
2085
|
};
|
|
1416
|
-
|
|
2086
|
+
_this45.onUploadError = function (error) {
|
|
1417
2087
|
errorMessage = error.message;
|
|
1418
2088
|
};
|
|
1419
|
-
return
|
|
2089
|
+
return _this45;
|
|
1420
2090
|
}
|
|
1421
2091
|
Demo.defaults = function defaults() {
|
|
1422
2092
|
return {
|
|
@@ -1426,7 +2096,7 @@ describe('Sender', function () {
|
|
|
1426
2096
|
return Demo;
|
|
1427
2097
|
}(Component);
|
|
1428
2098
|
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
|
-
|
|
2099
|
+
_mount45 = mount(Demo), element = _mount45[1];
|
|
1430
2100
|
file = new File(['hello'], 'hello.txt', {
|
|
1431
2101
|
type: 'text/plain'
|
|
1432
2102
|
});
|
|
@@ -1434,14 +2104,14 @@ describe('Sender', function () {
|
|
|
1434
2104
|
dispatchEvent(document, 'dragenter', {
|
|
1435
2105
|
dataTransfer: getDataTransfer([file])
|
|
1436
2106
|
});
|
|
1437
|
-
|
|
2107
|
+
_context97.next = 10;
|
|
1438
2108
|
return wait();
|
|
1439
2109
|
case 10:
|
|
1440
2110
|
expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
|
|
1441
2111
|
dispatchEvent(document, 'drop', {
|
|
1442
2112
|
dataTransfer: getDataTransferWithEntries([docsDir])
|
|
1443
2113
|
});
|
|
1444
|
-
|
|
2114
|
+
_context97.next = 14;
|
|
1445
2115
|
return wait(20);
|
|
1446
2116
|
case 14:
|
|
1447
2117
|
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
@@ -1449,30 +2119,30 @@ describe('Sender', function () {
|
|
|
1449
2119
|
expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
|
|
1450
2120
|
case 17:
|
|
1451
2121
|
case "end":
|
|
1452
|
-
return
|
|
2122
|
+
return _context97.stop();
|
|
1453
2123
|
}
|
|
1454
|
-
},
|
|
2124
|
+
}, _callee45);
|
|
1455
2125
|
})));
|
|
1456
|
-
it('should add pasted files when pasteFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1457
|
-
var lastAttachments, Demo,
|
|
1458
|
-
return _regeneratorRuntime.wrap(function
|
|
1459
|
-
while (1) switch (
|
|
2126
|
+
it('should add pasted files when pasteFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46() {
|
|
2127
|
+
var lastAttachments, Demo, _mount46, element, textarea, file;
|
|
2128
|
+
return _regeneratorRuntime.wrap(function _callee46$(_context99) {
|
|
2129
|
+
while (1) switch (_context99.prev = _context99.next) {
|
|
1460
2130
|
case 0:
|
|
1461
2131
|
lastAttachments = [];
|
|
1462
|
-
Demo = /*#__PURE__*/function (
|
|
1463
|
-
_inheritsLoose(Demo,
|
|
2132
|
+
Demo = /*#__PURE__*/function (_Component46) {
|
|
2133
|
+
_inheritsLoose(Demo, _Component46);
|
|
1464
2134
|
function Demo() {
|
|
1465
|
-
var
|
|
1466
|
-
var
|
|
1467
|
-
for (var
|
|
1468
|
-
args[
|
|
2135
|
+
var _context98;
|
|
2136
|
+
var _this46;
|
|
2137
|
+
for (var _len46 = arguments.length, args = new Array(_len46), _key46 = 0; _key46 < _len46; _key46++) {
|
|
2138
|
+
args[_key46] = arguments[_key46];
|
|
1469
2139
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
2140
|
+
_this46 = _Component46.call.apply(_Component46, _concatInstanceProperty(_context98 = [this]).call(_context98, args)) || this;
|
|
2141
|
+
_this46.Sender = Sender;
|
|
2142
|
+
_this46.onChange = function (items) {
|
|
1473
2143
|
lastAttachments = items;
|
|
1474
2144
|
};
|
|
1475
|
-
return
|
|
2145
|
+
return _this46;
|
|
1476
2146
|
}
|
|
1477
2147
|
Demo.defaults = function defaults() {
|
|
1478
2148
|
return {
|
|
@@ -1482,7 +2152,7 @@ describe('Sender', function () {
|
|
|
1482
2152
|
return Demo;
|
|
1483
2153
|
}(Component);
|
|
1484
2154
|
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
|
-
|
|
2155
|
+
_mount46 = mount(Demo), element = _mount46[1];
|
|
1486
2156
|
textarea = element.querySelector('.k-sender-input');
|
|
1487
2157
|
file = new File(['image'], 'cover.png', {
|
|
1488
2158
|
type: 'image/png'
|
|
@@ -1490,41 +2160,41 @@ describe('Sender', function () {
|
|
|
1490
2160
|
dispatchEvent(textarea, 'paste', {
|
|
1491
2161
|
clipboardData: getClipboardData([file])
|
|
1492
2162
|
});
|
|
1493
|
-
|
|
2163
|
+
_context99.next = 9;
|
|
1494
2164
|
return wait();
|
|
1495
2165
|
case 9:
|
|
1496
2166
|
expect(lastAttachments.length).to.eql(1);
|
|
1497
2167
|
expect(lastAttachments[0].name).to.eql('cover.png');
|
|
1498
2168
|
case 11:
|
|
1499
2169
|
case "end":
|
|
1500
|
-
return
|
|
2170
|
+
return _context99.stop();
|
|
1501
2171
|
}
|
|
1502
|
-
},
|
|
2172
|
+
}, _callee46);
|
|
1503
2173
|
})));
|
|
1504
|
-
it('should trigger uploadError for invalid file type on paste', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1505
|
-
var errorMessage, lastAttachments, Demo,
|
|
1506
|
-
return _regeneratorRuntime.wrap(function
|
|
1507
|
-
while (1) switch (
|
|
2174
|
+
it('should trigger uploadError for invalid file type on paste', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee47() {
|
|
2175
|
+
var errorMessage, lastAttachments, Demo, _mount47, element, textarea, file;
|
|
2176
|
+
return _regeneratorRuntime.wrap(function _callee47$(_context101) {
|
|
2177
|
+
while (1) switch (_context101.prev = _context101.next) {
|
|
1508
2178
|
case 0:
|
|
1509
2179
|
errorMessage = '';
|
|
1510
2180
|
lastAttachments = [];
|
|
1511
|
-
Demo = /*#__PURE__*/function (
|
|
1512
|
-
_inheritsLoose(Demo,
|
|
2181
|
+
Demo = /*#__PURE__*/function (_Component47) {
|
|
2182
|
+
_inheritsLoose(Demo, _Component47);
|
|
1513
2183
|
function Demo() {
|
|
1514
|
-
var
|
|
1515
|
-
var
|
|
1516
|
-
for (var
|
|
1517
|
-
args[
|
|
2184
|
+
var _context100;
|
|
2185
|
+
var _this47;
|
|
2186
|
+
for (var _len47 = arguments.length, args = new Array(_len47), _key47 = 0; _key47 < _len47; _key47++) {
|
|
2187
|
+
args[_key47] = arguments[_key47];
|
|
1518
2188
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
2189
|
+
_this47 = _Component47.call.apply(_Component47, _concatInstanceProperty(_context100 = [this]).call(_context100, args)) || this;
|
|
2190
|
+
_this47.Sender = Sender;
|
|
2191
|
+
_this47.onChange = function (items) {
|
|
1522
2192
|
lastAttachments = items;
|
|
1523
2193
|
};
|
|
1524
|
-
|
|
2194
|
+
_this47.onUploadError = function (error) {
|
|
1525
2195
|
errorMessage = error.message;
|
|
1526
2196
|
};
|
|
1527
|
-
return
|
|
2197
|
+
return _this47;
|
|
1528
2198
|
}
|
|
1529
2199
|
Demo.defaults = function defaults() {
|
|
1530
2200
|
return {
|
|
@@ -1534,7 +2204,7 @@ describe('Sender', function () {
|
|
|
1534
2204
|
return Demo;
|
|
1535
2205
|
}(Component);
|
|
1536
2206
|
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
|
-
|
|
2207
|
+
_mount47 = mount(Demo), element = _mount47[1];
|
|
1538
2208
|
textarea = element.querySelector('.k-sender-input');
|
|
1539
2209
|
file = new File(['hello'], 'hello.txt', {
|
|
1540
2210
|
type: 'text/plain'
|
|
@@ -1542,38 +2212,38 @@ describe('Sender', function () {
|
|
|
1542
2212
|
dispatchEvent(textarea, 'paste', {
|
|
1543
2213
|
clipboardData: getClipboardData([file])
|
|
1544
2214
|
});
|
|
1545
|
-
|
|
2215
|
+
_context101.next = 10;
|
|
1546
2216
|
return wait();
|
|
1547
2217
|
case 10:
|
|
1548
2218
|
expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
|
|
1549
2219
|
expect(lastAttachments.length).to.eql(0);
|
|
1550
2220
|
case 12:
|
|
1551
2221
|
case "end":
|
|
1552
|
-
return
|
|
2222
|
+
return _context101.stop();
|
|
1553
2223
|
}
|
|
1554
|
-
},
|
|
2224
|
+
}, _callee47);
|
|
1555
2225
|
})));
|
|
1556
|
-
it('should keep native text paste when pasteFile is disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1557
|
-
var Demo,
|
|
1558
|
-
return _regeneratorRuntime.wrap(function
|
|
1559
|
-
while (1) switch (
|
|
2226
|
+
it('should keep native text paste when pasteFile is disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee48() {
|
|
2227
|
+
var Demo, _mount48, element, textarea, file, event;
|
|
2228
|
+
return _regeneratorRuntime.wrap(function _callee48$(_context103) {
|
|
2229
|
+
while (1) switch (_context103.prev = _context103.next) {
|
|
1560
2230
|
case 0:
|
|
1561
|
-
Demo = /*#__PURE__*/function (
|
|
1562
|
-
_inheritsLoose(Demo,
|
|
2231
|
+
Demo = /*#__PURE__*/function (_Component48) {
|
|
2232
|
+
_inheritsLoose(Demo, _Component48);
|
|
1563
2233
|
function Demo() {
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1566
|
-
for (var
|
|
1567
|
-
args[
|
|
2234
|
+
var _context102;
|
|
2235
|
+
var _this48;
|
|
2236
|
+
for (var _len48 = arguments.length, args = new Array(_len48), _key48 = 0; _key48 < _len48; _key48++) {
|
|
2237
|
+
args[_key48] = arguments[_key48];
|
|
1568
2238
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
return
|
|
2239
|
+
_this48 = _Component48.call.apply(_Component48, _concatInstanceProperty(_context102 = [this]).call(_context102, args)) || this;
|
|
2240
|
+
_this48.Sender = Sender;
|
|
2241
|
+
return _this48;
|
|
1572
2242
|
}
|
|
1573
2243
|
return Demo;
|
|
1574
2244
|
}(Component);
|
|
1575
2245
|
Demo.template = "\n const { Sender } = this;\n <Sender />\n ";
|
|
1576
|
-
|
|
2246
|
+
_mount48 = mount(Demo), element = _mount48[1];
|
|
1577
2247
|
textarea = element.querySelector('.k-sender-input');
|
|
1578
2248
|
file = new File(['image'], 'cover.png', {
|
|
1579
2249
|
type: 'image/png'
|
|
@@ -1584,14 +2254,14 @@ describe('Sender', function () {
|
|
|
1584
2254
|
clipboardData: getClipboardData([file])
|
|
1585
2255
|
});
|
|
1586
2256
|
textarea.dispatchEvent(event);
|
|
1587
|
-
|
|
2257
|
+
_context103.next = 11;
|
|
1588
2258
|
return wait();
|
|
1589
2259
|
case 11:
|
|
1590
2260
|
expect(event.defaultPrevented).to.eql(false);
|
|
1591
2261
|
case 12:
|
|
1592
2262
|
case "end":
|
|
1593
|
-
return
|
|
2263
|
+
return _context103.stop();
|
|
1594
2264
|
}
|
|
1595
|
-
},
|
|
2265
|
+
}, _callee48);
|
|
1596
2266
|
})));
|
|
1597
2267
|
});
|