@king-design/vue 3.8.0-beta.0 → 3.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +74 -74
  2. package/components/bubble/bubble.d.ts +1 -0
  3. package/components/bubble/bubble.vdt.js +6 -2
  4. package/components/bubble/index.spec.js +58 -5
  5. package/components/bubble/styles.js +1 -1
  6. package/components/bubble/useBubbleDisplay.d.ts +1 -0
  7. package/components/bubble/useBubbleDisplay.js +8 -0
  8. package/components/bubbleList/bubbleList.vdt.js +3 -1
  9. package/components/bubbleList/index.spec.js +301 -237
  10. package/components/bubbleList/styles.js +2 -2
  11. package/components/bubbleList/useBubbleList.js +7 -0
  12. package/components/fileCard/fileCard.vdt.js +4 -4
  13. package/components/fileCard/index.spec.js +179 -107
  14. package/components/fileCard/list.d.ts +2 -1
  15. package/components/fileCard/list.vdt.js +7 -5
  16. package/components/fileCard/styles.js +10 -8
  17. package/components/fileCard/useFileCard.d.ts +1 -1
  18. package/components/fileCard/useFileCard.js +6 -35
  19. package/components/media/index.spec.js +774 -585
  20. package/components/media/media.vdt.js +17 -6
  21. package/components/media/mediaAssets.d.ts +2 -0
  22. package/components/media/mediaAssets.js +4 -0
  23. package/components/media/styles.js +5 -3
  24. package/components/media/useMedia.d.ts +6 -2
  25. package/components/media/useMedia.js +28 -6
  26. package/components/sender/index.spec.js +1039 -435
  27. package/components/sender/sender.d.ts +27 -4
  28. package/components/sender/sender.js +16 -5
  29. package/components/sender/sender.vdt.js +121 -49
  30. package/components/sender/styles.js +18 -9
  31. package/components/sender/useAutoResize.js +6 -6
  32. package/components/sender/useSenderDrag.js +12 -3
  33. package/components/sender/useSenderInput.d.ts +3 -0
  34. package/components/sender/useSenderInput.js +20 -3
  35. package/components/sender/useSenderPaste.js +1 -1
  36. package/components/sender/useSenderUpload.js +38 -29
  37. package/components/xmarkdown/index.spec.js +370 -239
  38. package/components/xmarkdown/markdown/streaming.js +41 -8
  39. package/components/xmarkdown/styles.js +2 -2
  40. package/components/xmarkdown/useXMarkdownDisplay.d.ts +1 -0
  41. package/components/xmarkdown/useXMarkdownDisplay.js +9 -1
  42. package/components/xmarkdown/xmarkdown.d.ts +1 -0
  43. package/components/xmarkdown/xmarkdown.vdt.js +6 -2
  44. package/dist/i18n/en-US.js +1 -0
  45. package/dist/i18n/en-US.js.map +1 -1
  46. package/dist/i18n/en-US.min.js +1 -1
  47. package/dist/index.js +400 -193
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.min.js +2 -2
  50. package/i18n/en-US.d.ts +1 -0
  51. package/i18n/en-US.js +1 -0
  52. package/index.d.ts +2 -2
  53. package/index.js +2 -2
  54. 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 = 7;
237
+ _context8.next = 8;
237
238
  return wait();
238
- case 7:
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 = 11;
246
+ _context8.next = 14;
242
247
  return wait();
243
- case 11:
248
+ case 14:
244
249
  expect(document.activeElement).not.to.eql(textarea);
245
- case 12:
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 disabled prop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
542
- var Demo, _mount11, element, textarea, sendBtn;
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; <div><Sender disabled={true} value=\"hi\" /></div>";
561
- _mount11 = mount(Demo), element = _mount11[1];
562
- expect(element.querySelector('.k-sender').classList.contains('k-sender-disabled')).to.eql(true);
563
- textarea = element.querySelector('.k-sender-input');
564
- expect(textarea.disabled).to.eql(true);
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
- case 8:
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 render attachments via FileCardList and emit change on delete', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
574
- var lastAttachments, Demo, _mount12, element, deleteBtn;
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 = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
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-attachments')).not.to.eql(null);
610
- expect(element.querySelectorAll('.k-file-card').length).to.eql(1);
611
- deleteBtn = element.querySelector('.k-file-card-delete');
612
- deleteBtn.click();
613
- _context24.next = 10;
614
- return wait();
615
- case 10:
616
- expect(lastAttachments).not.to.eql(null);
617
- expect(lastAttachments.length).to.eql(0);
618
- case 12:
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 expose attachment click and delete events', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
625
- var _lastDeleted;
626
- var clickCount, deleteCount, lastDeleted, Demo, _mount13, element, card, deleteBtn;
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
- clickCount = 0;
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.onAttachmentClick = function () {
644
- clickCount += 1;
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 attachments={this.get('attachments')}\n ev-attachmentClick={this.onAttachmentClick}\n ev-attachmentDelete={this.onAttachmentDelete}\n />\n ";
666
- _mount13 = mount(Demo), element = _mount13[1];
667
- card = element.querySelector('.k-file-card');
668
- card.click();
669
- _context26.next = 10;
670
- return wait();
671
- case 10:
672
- expect(clickCount).to.eql(1);
673
- deleteBtn = element.querySelector('.k-file-card-delete');
674
- deleteBtn.click();
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(deleteCount).to.eql(1);
679
- expect((_lastDeleted = lastDeleted) == null ? void 0 : _lastDeleted.name).to.eql('note.txt');
680
- case 17:
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 expose send button slot params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
687
- var _context28, _context29;
688
- var captured, Demo, _mount14, instance, element, btn;
689
- return _regeneratorRuntime.wrap(function _callee14$(_context30) {
690
- while (1) switch (_context30.prev = _context30.next) {
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
- captured = null;
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,956 @@ 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.capture = function (p) {
704
- captured = p;
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 value={this.get('value')} generating={this.get('generating')}>\n <b:sendButton args=\"scope\">\n <button class=\"custom-send\" disabled={scope.disabled}>\n {scope.generating ? 'STOP' : 'SEND'}\n </button>\n </b:sendButton>\n </Sender>\n ";
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
- btn = element.querySelector('.custom-send');
719
- expect(btn).not.to.eql(null);
720
- expect(_trimInstanceProperty(_context28 = btn.textContent).call(_context28)).to.eql('SEND');
721
- instance.set('generating', true);
722
- _context30.next = 10;
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 10:
725
- expect(_trimInstanceProperty(_context29 = element.querySelector('.custom-send').textContent).call(_context29)).to.eql('STOP');
726
- case 11:
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 _context30.stop();
778
+ return _context28.stop();
729
779
  }
730
780
  }, _callee14);
731
781
  })));
732
- it('should render beforeInput inside shell and configure inside toolbar middle', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
733
- var Demo, _mount15, element, top, tools, shell, middle, left, right, toolbar, children;
734
- return _regeneratorRuntime.wrap(function _callee15$(_context32) {
735
- while (1) switch (_context32.prev = _context32.next) {
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 _context31;
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(_context31 = [this]).call(_context31, args)) || this;
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>\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 ";
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
- top = element.querySelector('.top-suggest');
754
- tools = element.querySelector('.bottom-tools');
755
- expect(top).not.to.eql(null);
756
- expect(tools).not.to.eql(null);
757
- // beforeInput 包装容器在 shell 内
758
- shell = element.querySelector('.k-sender-shell');
759
- expect(shell.contains(top)).to.eql(true);
760
- // configure 落在 toolbar 中间
761
- middle = element.querySelector('.k-sender-toolbar-middle');
762
- expect(middle).not.to.eql(null);
763
- expect(middle.contains(tools)).to.eql(true);
764
- // configure 处于附件按钮和发送按钮之间
765
- left = element.querySelector('.k-sender-toolbar-left');
766
- right = element.querySelector('.k-sender-toolbar-right');
767
- toolbar = element.querySelector('.k-sender-toolbar');
768
- children = _Array$from(toolbar.children);
769
- expect(children.indexOf(left)).to.be.lessThan(children.indexOf(middle));
770
- expect(children.indexOf(middle)).to.be.lessThan(children.indexOf(right));
771
- case 18:
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 _context32.stop();
829
+ return _context30.stop();
774
830
  }
775
831
  }, _callee15);
776
832
  })));
777
- it('should render header above shell and footer below shell', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
778
- var _context34;
779
- var Demo, _mount16, element, header, footer, shell;
780
- return _regeneratorRuntime.wrap(function _callee16$(_context35) {
781
- while (1) switch (_context35.prev = _context35.next) {
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 _context33;
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(_context33 = [this]).call(_context33, args)) || this;
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>\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 ";
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
- header = element.querySelector('.k-sender-header');
800
- footer = element.querySelector('.k-sender-footer');
801
- shell = element.querySelector('.k-sender-shell');
802
- expect(header).not.to.eql(null);
803
- expect(footer).not.to.eql(null);
804
- expect(header.querySelector('.new-chat-btn')).not.to.eql(null);
805
- expect(_trimInstanceProperty(_context34 = footer.querySelector('.sender-disclaimer').textContent).call(_context34)).to.eql('AI生成,仅供参考。');
806
- expect(shell.contains(header)).to.eql(false);
807
- expect(shell.contains(footer)).to.eql(false);
808
- expect(_Array$from(element.children)).to.eql([header, shell, footer]);
809
- case 13:
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 _context35.stop();
891
+ return _context32.stop();
812
892
  }
813
893
  }, _callee16);
814
894
  })));
815
- // 布局插槽为空时,不保留 header/footer/beforeInput/configure/attachmentsButton 的空壳。
816
- it('should not render wrappers for empty layout slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
817
- var Demo, _mount17, element;
818
- return _regeneratorRuntime.wrap(function _callee17$(_context37) {
819
- while (1) switch (_context37.prev = _context37.next) {
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 _context36;
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(_context36 = [this]).call(_context36, args)) || this;
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
- return Demo;
834
- }(Component);
835
- Demo.template = "\n const { Sender } = this;\n <div>\n <Sender showAttachmentsButton={false}>\n <b:header>\n <span v-if={false} class=\"empty-header\">header</span>\n </b:header>\n <b:beforeInput>\n <span v-if={false} class=\"empty-before-input\">before</span>\n </b:beforeInput>\n <b:attachmentsButton>\n <button v-if={false} class=\"empty-attachments-button\" type=\"button\">upload</button>\n </b:attachmentsButton>\n <b:configure>\n <span v-if={false} class=\"empty-configure\">configure</span>\n </b:configure>\n <b:footer>\n <span v-if={false} class=\"empty-footer\">footer</span>\n </b:footer>\n </Sender>\n </div>\n ";
836
- _mount17 = mount(Demo), element = _mount17[1];
837
- expect(element.querySelector('.k-sender-header')).to.eql(null);
838
- expect(element.querySelector('.k-sender-before-input')).to.eql(null);
839
- expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
840
- expect(element.querySelector('.k-sender-toolbar-middle')).to.eql(null);
841
- expect(element.querySelector('.k-sender-footer')).to.eql(null);
842
- expect(element.querySelector('.k-sender-toolbar-right')).not.to.eql(null);
843
- case 9:
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:
844
944
  case "end":
845
- return _context37.stop();
945
+ return _context36.stop();
846
946
  }
847
947
  }, _callee17);
848
948
  })));
849
- it('should hide attach button and show dashed + box in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
850
- var Demo, _mount18, element, addBox, clicked, fileInput;
851
- return _regeneratorRuntime.wrap(function _callee18$(_context39) {
852
- while (1) switch (_context39.prev = _context39.next) {
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) {
853
953
  case 0:
854
954
  Demo = /*#__PURE__*/function (_Component18) {
855
955
  _inheritsLoose(Demo, _Component18);
856
956
  function Demo() {
857
- var _context38;
957
+ var _context37;
858
958
  var _this18;
859
959
  for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
860
960
  args[_key18] = arguments[_key18];
861
961
  }
862
- _this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context38 = [this]).call(_context38, args)) || this;
962
+ _this18 = _Component18.call.apply(_Component18, _concatInstanceProperty(_context37 = [this]).call(_context37, args)) || this;
863
963
  _this18.Sender = Sender;
864
964
  return _this18;
865
965
  }
966
+ Demo.defaults = function defaults() {
967
+ return {
968
+ generating: false
969
+ };
970
+ };
866
971
  return Demo;
867
972
  }(Component);
868
- Demo.template = "const { Sender } = this; <div><Sender type=\"image\" /></div>";
869
- _mount18 = mount(Demo), element = _mount18[1]; // 默认附件按钮隐藏
870
- expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
871
- // 图片模式即使没有附件也要展示 FileCardList,用来承载末尾 + 框
872
- expect(element.querySelector('.k-sender-attachments')).not.to.eql(null);
873
- addBox = element.querySelector('.k-sender-image-add');
874
- expect(addBox).not.to.eql(null);
875
- // 点击 + 框会触发 file input click
876
- clicked = 0;
877
- fileInput = element.querySelector('.k-sender-file-input');
878
- fileInput.addEventListener('click', function (e) {
879
- clicked++;
880
- e.preventDefault();
881
- });
882
- addBox.click();
883
- _context39.next = 13;
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;
884
988
  return wait();
885
- case 13:
886
- expect(clicked).to.eql(1);
887
- case 14:
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:
888
1008
  case "end":
889
- return _context39.stop();
1009
+ return _context38.stop();
890
1010
  }
891
1011
  }, _callee18);
892
1012
  })));
893
- it('should let configure start from the left edge in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
894
- var _context41;
895
- var Demo, _mount19, element, toolbar, middle;
896
- return _regeneratorRuntime.wrap(function _callee19$(_context42) {
897
- while (1) switch (_context42.prev = _context42.next) {
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) {
898
1017
  case 0:
899
1018
  Demo = /*#__PURE__*/function (_Component19) {
900
1019
  _inheritsLoose(Demo, _Component19);
901
1020
  function Demo() {
902
- var _context40;
1021
+ var _context39;
903
1022
  var _this19;
904
1023
  for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
905
1024
  args[_key19] = arguments[_key19];
906
1025
  }
907
- _this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context40 = [this]).call(_context40, args)) || this;
1026
+ _this19 = _Component19.call.apply(_Component19, _concatInstanceProperty(_context39 = [this]).call(_context39, args)) || this;
908
1027
  _this19.Sender = Sender;
909
1028
  return _this19;
910
1029
  }
911
1030
  return Demo;
912
1031
  }(Component);
913
- Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\">\n <b:configure>\n <div class=\"image-tools\">\u914D\u7F6E\u9879</div>\n </b:configure>\n </Sender>\n </div>\n ";
1032
+ Demo.template = "\n const { Sender } = this;\n <Sender\n value=\"hello\"\n buttonTooltip={{send: false, upload: false}}\n />\n ";
914
1033
  _mount19 = mount(Demo), element = _mount19[1];
915
- toolbar = element.querySelector('.k-sender-toolbar');
916
- middle = element.querySelector('.k-sender-toolbar-middle');
917
- expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
918
- expect(toolbar.firstElementChild).to.eql(middle);
919
- expect(_trimInstanceProperty(_context41 = middle.querySelector('.image-tools').textContent).call(_context41)).to.eql('配置项');
920
- case 8:
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:
921
1043
  case "end":
922
- return _context42.stop();
1044
+ return _context40.stop();
923
1045
  }
924
1046
  }, _callee19);
925
1047
  })));
926
- it('should hide + box when reaching uploadProps.limit in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
927
- var Demo, _mount20, element;
928
- return _regeneratorRuntime.wrap(function _callee20$(_context44) {
929
- while (1) switch (_context44.prev = _context44.next) {
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) {
930
1052
  case 0:
931
1053
  Demo = /*#__PURE__*/function (_Component20) {
932
1054
  _inheritsLoose(Demo, _Component20);
933
1055
  function Demo() {
934
- var _context43;
1056
+ var _context41;
935
1057
  var _this20;
936
1058
  for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
937
1059
  args[_key20] = arguments[_key20];
938
1060
  }
939
- _this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
1061
+ _this20 = _Component20.call.apply(_Component20, _concatInstanceProperty(_context41 = [this]).call(_context41, args)) || this;
940
1062
  _this20.Sender = Sender;
941
1063
  return _this20;
942
1064
  }
943
1065
  return Demo;
944
1066
  }(Component);
945
- Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\"\n uploadProps={{limit: 1}}\n attachments={[{key: 'a', uid: 'a', name: 'p.png', type: 'image/png', src: ''}]}\n />\n </div>\n ";
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 ";
946
1068
  _mount20 = mount(Demo), element = _mount20[1];
947
- expect(element.querySelector('.k-sender-image-add')).to.eql(null);
948
- // 文件卡片仍然渲染
949
- expect(element.querySelector('.k-file-card')).not.to.eql(null);
950
- case 5:
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:
951
1088
  case "end":
952
- return _context44.stop();
1089
+ return _context42.stop();
953
1090
  }
954
1091
  }, _callee20);
955
1092
  })));
956
- it('should render text-mode attachments uniformly as file cards', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
957
- var Demo, _mount21, element;
958
- return _regeneratorRuntime.wrap(function _callee21$(_context46) {
959
- while (1) switch (_context46.prev = _context46.next) {
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) {
960
1097
  case 0:
961
1098
  Demo = /*#__PURE__*/function (_Component21) {
962
1099
  _inheritsLoose(Demo, _Component21);
963
1100
  function Demo() {
964
- var _context45;
1101
+ var _context43;
965
1102
  var _this21;
966
1103
  for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
967
1104
  args[_key21] = arguments[_key21];
968
1105
  }
969
- _this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
1106
+ _this21 = _Component21.call.apply(_Component21, _concatInstanceProperty(_context43 = [this]).call(_context43, args)) || this;
970
1107
  _this21.Sender = Sender;
971
1108
  return _this21;
972
1109
  }
973
1110
  return Demo;
974
1111
  }(Component);
975
- Demo.template = "\n const { Sender } = this;\n <div>\n <Sender attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n {key: 'b', uid: 'b', name: 'note.txt', type: 'text/plain'},\n ]} />\n </div>\n ";
976
- _mount21 = mount(Demo), element = _mount21[1]; // 在 text 模式下,图片附件也应当以「文件卡」形式呈现,而不是图片缩略图
977
- expect(element.querySelectorAll('.k-file-card-file').length).to.eql(2);
978
- expect(element.querySelectorAll('.k-file-card-media').length).to.eql(0);
979
- case 5:
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:
980
1123
  case "end":
981
- return _context46.stop();
1124
+ return _context44.stop();
982
1125
  }
983
1126
  }, _callee21);
984
1127
  })));
985
- it('should keep image media cards (square) in image mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
986
- var Demo, _mount22, element;
987
- return _regeneratorRuntime.wrap(function _callee22$(_context48) {
988
- while (1) switch (_context48.prev = _context48.next) {
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) {
989
1133
  case 0:
990
1134
  Demo = /*#__PURE__*/function (_Component22) {
991
1135
  _inheritsLoose(Demo, _Component22);
992
1136
  function Demo() {
993
- var _context47;
1137
+ var _context45;
994
1138
  var _this22;
995
1139
  for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
996
1140
  args[_key22] = arguments[_key22];
997
1141
  }
998
- _this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context47 = [this]).call(_context47, args)) || this;
1142
+ _this22 = _Component22.call.apply(_Component22, _concatInstanceProperty(_context45 = [this]).call(_context45, args)) || this;
999
1143
  _this22.Sender = Sender;
1000
1144
  return _this22;
1001
1145
  }
1002
1146
  return Demo;
1003
1147
  }(Component);
1004
- Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n ]} />\n </div>\n ";
1005
- _mount22 = mount(Demo), element = _mount22[1]; // 图片模式下保留 FileCard 的图片渲染(自带 1:1 裁剪),不强制转成 file 卡片
1006
- expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
1007
- case 4:
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:
1008
1161
  case "end":
1009
- return _context48.stop();
1162
+ return _context47.stop();
1010
1163
  }
1011
1164
  }, _callee22);
1012
1165
  })));
1013
- it('should infer media type from name in image mode when attachment type is generic mime', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1166
+ // 布局插槽为空时,不保留 header/footer/beforeInput/configure/uploadButton 的空壳。
1167
+ it('should not render wrappers for empty layout slots', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
1014
1168
  var Demo, _mount23, element;
1015
- return _regeneratorRuntime.wrap(function _callee23$(_context50) {
1016
- while (1) switch (_context50.prev = _context50.next) {
1169
+ return _regeneratorRuntime.wrap(function _callee23$(_context49) {
1170
+ while (1) switch (_context49.prev = _context49.next) {
1017
1171
  case 0:
1018
1172
  Demo = /*#__PURE__*/function (_Component23) {
1019
1173
  _inheritsLoose(Demo, _Component23);
1020
1174
  function Demo() {
1021
- var _context49;
1175
+ var _context48;
1022
1176
  var _this23;
1023
1177
  for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
1024
1178
  args[_key23] = arguments[_key23];
1025
1179
  }
1026
- _this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context49 = [this]).call(_context49, args)) || this;
1180
+ _this23 = _Component23.call.apply(_Component23, _concatInstanceProperty(_context48 = [this]).call(_context48, args)) || this;
1027
1181
  _this23.Sender = Sender;
1028
1182
  return _this23;
1029
1183
  }
1030
1184
  return Demo;
1031
1185
  }(Component);
1032
- Demo.template = "\n const { Sender } = this;\n <div>\n <Sender type=\"image\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'application/octet-stream', src: 'blob:mock'},\n ]} />\n </div>\n ";
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 ";
1033
1187
  _mount23 = mount(Demo), element = _mount23[1];
1034
- expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
1035
- expect(element.querySelector('.k-file-card-file')).to.eql(null);
1036
- case 5:
1188
+ expect(element.querySelector('.k-sender-header')).to.eql(null);
1189
+ expect(element.querySelector('.k-sender-before-input')).to.eql(null);
1190
+ expect(element.querySelector('.k-sender-prefix')).to.eql(null);
1191
+ expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
1192
+ expect(element.querySelector('.k-sender-toolbar-middle')).to.eql(null);
1193
+ expect(element.querySelector('.k-sender-footer')).to.eql(null);
1194
+ expect(element.querySelector('.k-sender-toolbar-right')).not.to.eql(null);
1195
+ case 10:
1037
1196
  case "end":
1038
- return _context50.stop();
1197
+ return _context49.stop();
1039
1198
  }
1040
1199
  }, _callee23);
1041
1200
  })));
1042
- it('should support directory selection and preserve relative path metadata', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
1043
- var lastAttachments, Demo, _mount24, element, input, file;
1044
- return _regeneratorRuntime.wrap(function _callee24$(_context52) {
1045
- while (1) switch (_context52.prev = _context52.next) {
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) {
1046
1205
  case 0:
1047
- lastAttachments = [];
1048
1206
  Demo = /*#__PURE__*/function (_Component24) {
1049
1207
  _inheritsLoose(Demo, _Component24);
1050
1208
  function Demo() {
1051
- var _context51;
1209
+ var _context50;
1052
1210
  var _this24;
1053
1211
  for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
1054
1212
  args[_key24] = arguments[_key24];
1055
1213
  }
1056
- _this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context51 = [this]).call(_context51, args)) || this;
1214
+ _this24 = _Component24.call.apply(_Component24, _concatInstanceProperty(_context50 = [this]).call(_context50, args)) || this;
1057
1215
  _this24.Sender = Sender;
1058
- _this24.onChange = function (items) {
1216
+ return _this24;
1217
+ }
1218
+ return Demo;
1219
+ }(Component);
1220
+ Demo.template = "const { Sender } = this; <div><Sender /></div>";
1221
+ _mount24 = mount(Demo), element = _mount24[1];
1222
+ expect(element.querySelector('.k-sender-toolbar-left')).not.to.eql(null);
1223
+ expect(element.querySelector('.k-sender-attach-btn')).not.to.eql(null);
1224
+ expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
1225
+ case 6:
1226
+ case "end":
1227
+ return _context51.stop();
1228
+ }
1229
+ }, _callee24);
1230
+ })));
1231
+ it('should show dashed upload button in attachment list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1232
+ var _context53;
1233
+ var Demo, _mount25, element, addBox, clicked, fileInput;
1234
+ return _regeneratorRuntime.wrap(function _callee25$(_context54) {
1235
+ while (1) switch (_context54.prev = _context54.next) {
1236
+ case 0:
1237
+ Demo = /*#__PURE__*/function (_Component25) {
1238
+ _inheritsLoose(Demo, _Component25);
1239
+ function Demo() {
1240
+ var _context52;
1241
+ var _this25;
1242
+ for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
1243
+ args[_key25] = arguments[_key25];
1244
+ }
1245
+ _this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context52 = [this]).call(_context52, args)) || this;
1246
+ _this25.Sender = Sender;
1247
+ return _this25;
1248
+ }
1249
+ return Demo;
1250
+ }(Component);
1251
+ Demo.template = "const { Sender } = this; <div><Sender uploadButton=\"list\" /></div>";
1252
+ _mount25 = mount(Demo), element = _mount25[1];
1253
+ expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
1254
+ // 列表入口即使没有附件也要展示 FileCardList,用来承载前置 + 框
1255
+ expect(element.querySelector('.k-sender-attachments')).not.to.eql(null);
1256
+ addBox = element.querySelector('.k-sender-list-upload');
1257
+ expect(addBox).not.to.eql(null);
1258
+ expect(addBox.getAttribute('title')).to.eql('参考内容');
1259
+ expect(addBox.getAttribute('aria-label')).to.eql('参考内容');
1260
+ expect(_trimInstanceProperty(_context53 = addBox.querySelector('.k-sender-list-upload-text').textContent).call(_context53)).to.eql('参考内容');
1261
+ expect(addBox.querySelector('.k-icon-add-bold')).not.to.eql(null);
1262
+ // 点击 + 框会触发 file input click
1263
+ clicked = 0;
1264
+ fileInput = element.querySelector('.k-sender-file-input');
1265
+ fileInput.addEventListener('click', function (e) {
1266
+ clicked++;
1267
+ e.preventDefault();
1268
+ });
1269
+ addBox.click();
1270
+ _context54.next = 17;
1271
+ return wait();
1272
+ case 17:
1273
+ expect(clicked).to.eql(1);
1274
+ case 18:
1275
+ case "end":
1276
+ return _context54.stop();
1277
+ }
1278
+ }, _callee25);
1279
+ })));
1280
+ it('should let configure start from the left edge when upload button is not in toolbar', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
1281
+ var _context56;
1282
+ var Demo, _mount26, element, toolbar, middle;
1283
+ return _regeneratorRuntime.wrap(function _callee26$(_context57) {
1284
+ while (1) switch (_context57.prev = _context57.next) {
1285
+ case 0:
1286
+ Demo = /*#__PURE__*/function (_Component26) {
1287
+ _inheritsLoose(Demo, _Component26);
1288
+ function Demo() {
1289
+ var _context55;
1290
+ var _this26;
1291
+ for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
1292
+ args[_key26] = arguments[_key26];
1293
+ }
1294
+ _this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
1295
+ _this26.Sender = Sender;
1296
+ return _this26;
1297
+ }
1298
+ return Demo;
1299
+ }(Component);
1300
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"list\">\n <b:configure>\n <div class=\"sender-tools\">\u914D\u7F6E\u9879</div>\n </b:configure>\n </Sender>\n </div>\n ";
1301
+ _mount26 = mount(Demo), element = _mount26[1];
1302
+ toolbar = element.querySelector('.k-sender-toolbar');
1303
+ middle = element.querySelector('.k-sender-toolbar-middle');
1304
+ expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
1305
+ expect(toolbar.firstElementChild).to.eql(middle);
1306
+ expect(_trimInstanceProperty(_context56 = middle.querySelector('.sender-tools').textContent).call(_context56)).to.eql('配置项');
1307
+ case 8:
1308
+ case "end":
1309
+ return _context57.stop();
1310
+ }
1311
+ }, _callee26);
1312
+ })));
1313
+ it('should hide list upload button when reaching uploadProps.limit', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
1314
+ var Demo, _mount27, element;
1315
+ return _regeneratorRuntime.wrap(function _callee27$(_context59) {
1316
+ while (1) switch (_context59.prev = _context59.next) {
1317
+ case 0:
1318
+ Demo = /*#__PURE__*/function (_Component27) {
1319
+ _inheritsLoose(Demo, _Component27);
1320
+ function Demo() {
1321
+ var _context58;
1322
+ var _this27;
1323
+ for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
1324
+ args[_key27] = arguments[_key27];
1325
+ }
1326
+ _this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context58 = [this]).call(_context58, args)) || this;
1327
+ _this27.Sender = Sender;
1328
+ return _this27;
1329
+ }
1330
+ return Demo;
1331
+ }(Component);
1332
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"list\"\n uploadProps={{limit: 1}}\n attachments={[{key: 'a', uid: 'a', name: 'p.png', type: 'image/png', src: ''}]}\n />\n </div>\n ";
1333
+ _mount27 = mount(Demo), element = _mount27[1];
1334
+ expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
1335
+ // 文件卡片仍然渲染
1336
+ expect(element.querySelector('.k-file-card')).not.to.eql(null);
1337
+ case 5:
1338
+ case "end":
1339
+ return _context59.stop();
1340
+ }
1341
+ }, _callee27);
1342
+ })));
1343
+ it('should pass uploadButton slot params and render it in toolbar', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
1344
+ var _context61;
1345
+ var Demo, _mount28, element, button;
1346
+ return _regeneratorRuntime.wrap(function _callee28$(_context62) {
1347
+ while (1) switch (_context62.prev = _context62.next) {
1348
+ case 0:
1349
+ Demo = /*#__PURE__*/function (_Component28) {
1350
+ _inheritsLoose(Demo, _Component28);
1351
+ function Demo() {
1352
+ var _context60;
1353
+ var _this28;
1354
+ for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
1355
+ args[_key28] = arguments[_key28];
1356
+ }
1357
+ _this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context60 = [this]).call(_context60, args)) || this;
1358
+ _this28.Sender = Sender;
1359
+ return _this28;
1360
+ }
1361
+ return Demo;
1362
+ }(Component);
1363
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadProps={{limit: 1}} attachments={[\n {key: 'a', uid: 'a', name: 'note.txt'},\n ]}>\n <b:uploadButton args=\"scope\">\n <button\n class=\"custom-upload\"\n disabled={scope.disabled || scope.reachLimit}\n ev-click={scope.pickFiles}\n >{scope.position}</button>\n </b:uploadButton>\n </Sender>\n </div>\n ";
1364
+ _mount28 = mount(Demo), element = _mount28[1];
1365
+ button = element.querySelector('.custom-upload');
1366
+ expect(button).not.to.eql(null);
1367
+ expect(_trimInstanceProperty(_context61 = button.textContent).call(_context61)).to.eql('toolbar');
1368
+ expect(button.disabled).to.eql(true);
1369
+ expect(element.querySelector('.k-sender-attach-btn')).to.eql(null);
1370
+ case 8:
1371
+ case "end":
1372
+ return _context62.stop();
1373
+ }
1374
+ }, _callee28);
1375
+ })));
1376
+ it('should add local files through uploadButton slot params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
1377
+ var lastAttachments, Demo, _mount29, element, button;
1378
+ return _regeneratorRuntime.wrap(function _callee29$(_context64) {
1379
+ while (1) switch (_context64.prev = _context64.next) {
1380
+ case 0:
1381
+ lastAttachments = [];
1382
+ Demo = /*#__PURE__*/function (_Component29) {
1383
+ _inheritsLoose(Demo, _Component29);
1384
+ function Demo() {
1385
+ var _context63;
1386
+ var _this29;
1387
+ for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
1388
+ args[_key29] = arguments[_key29];
1389
+ }
1390
+ _this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context63 = [this]).call(_context63, args)) || this;
1391
+ _this29.Sender = Sender;
1392
+ _this29.file = new File(['hello'], 'hello.txt', {
1393
+ type: 'text/plain'
1394
+ });
1395
+ _this29.onChange = function (items) {
1059
1396
  lastAttachments = items;
1060
1397
  };
1061
- return _this24;
1398
+ return _this29;
1399
+ }
1400
+ Demo.defaults = function defaults() {
1401
+ return {
1402
+ attachments: []
1403
+ };
1404
+ };
1405
+ return Demo;
1406
+ }(Component);
1407
+ Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n uploadProps={{accept: '.txt', autoUpload: false}}\n ev-$change:attachments={this.onChange}\n >\n <b:uploadButton args=\"scope\">\n <button\n class=\"custom-add-files\"\n ev-click={() => scope.addFiles([this.file])}\n >add</button>\n </b:uploadButton>\n </Sender>\n ";
1408
+ _mount29 = mount(Demo), element = _mount29[1];
1409
+ button = element.querySelector('.custom-add-files');
1410
+ button.click();
1411
+ _context64.next = 8;
1412
+ return wait();
1413
+ case 8:
1414
+ expect(lastAttachments.length).to.eql(1);
1415
+ expect(lastAttachments[0].name).to.eql('hello.txt');
1416
+ expect(lastAttachments[0].status).to.eql('default');
1417
+ case 11:
1418
+ case "end":
1419
+ return _context64.stop();
1420
+ }
1421
+ }, _callee29);
1422
+ })));
1423
+ it('should render uploadButton slot in attachment list when uploadButton is list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
1424
+ var _context66;
1425
+ var Demo, _mount30, element;
1426
+ return _regeneratorRuntime.wrap(function _callee30$(_context67) {
1427
+ while (1) switch (_context67.prev = _context67.next) {
1428
+ case 0:
1429
+ Demo = /*#__PURE__*/function (_Component30) {
1430
+ _inheritsLoose(Demo, _Component30);
1431
+ function Demo() {
1432
+ var _context65;
1433
+ var _this30;
1434
+ for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
1435
+ args[_key30] = arguments[_key30];
1436
+ }
1437
+ _this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context65 = [this]).call(_context65, args)) || this;
1438
+ _this30.Sender = Sender;
1439
+ return _this30;
1440
+ }
1441
+ return Demo;
1442
+ }(Component);
1443
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender uploadButton=\"list\">\n <b:uploadButton args=\"scope\">\n <button class=\"custom-list-upload\" ev-click={scope.pickFiles}>{scope.position}</button>\n </b:uploadButton>\n </Sender>\n </div>\n ";
1444
+ _mount30 = mount(Demo), element = _mount30[1];
1445
+ expect(element.querySelector('.k-sender-toolbar-left')).to.eql(null);
1446
+ expect(element.querySelector('.k-sender-list-upload')).to.eql(null);
1447
+ expect(_trimInstanceProperty(_context66 = element.querySelector('.k-file-card-list-prefix .custom-list-upload').textContent).call(_context66)).to.eql('list');
1448
+ case 6:
1449
+ case "end":
1450
+ return _context67.stop();
1451
+ }
1452
+ }, _callee30);
1453
+ })));
1454
+ it('should expose addFiles method', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
1455
+ var lastAttachments, Demo, _mount31, instance, file;
1456
+ return _regeneratorRuntime.wrap(function _callee31$(_context69) {
1457
+ while (1) switch (_context69.prev = _context69.next) {
1458
+ case 0:
1459
+ lastAttachments = [];
1460
+ Demo = /*#__PURE__*/function (_Component31) {
1461
+ _inheritsLoose(Demo, _Component31);
1462
+ function Demo() {
1463
+ var _context68;
1464
+ var _this31;
1465
+ for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
1466
+ args[_key31] = arguments[_key31];
1467
+ }
1468
+ _this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context68 = [this]).call(_context68, args)) || this;
1469
+ _this31.Sender = Sender;
1470
+ _this31.senderRef = null;
1471
+ _this31.onChange = function (items) {
1472
+ lastAttachments = items;
1473
+ };
1474
+ return _this31;
1475
+ }
1476
+ Demo.defaults = function defaults() {
1477
+ return {
1478
+ attachments: []
1479
+ };
1480
+ };
1481
+ return Demo;
1482
+ }(Component);
1483
+ Demo.template = "\n const { Sender } = this;\n <Sender\n ref={(i) => this.senderRef = i}\n attachments={this.get('attachments')}\n uploadProps={{autoUpload: false}}\n ev-$change:attachments={this.onChange}\n />\n ";
1484
+ _mount31 = mount(Demo), instance = _mount31[0];
1485
+ file = new File(['hello'], 'dialog.txt', {
1486
+ type: 'text/plain'
1487
+ });
1488
+ instance.senderRef.addFiles([file]);
1489
+ _context69.next = 8;
1490
+ return wait();
1491
+ case 8:
1492
+ expect(lastAttachments.length).to.eql(1);
1493
+ expect(lastAttachments[0].name).to.eql('dialog.txt');
1494
+ expect(lastAttachments[0].status).to.eql('default');
1495
+ case 11:
1496
+ case "end":
1497
+ return _context69.stop();
1498
+ }
1499
+ }, _callee31);
1500
+ })));
1501
+ it('should render card-view attachments uniformly as file cards', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
1502
+ var Demo, _mount32, element;
1503
+ return _regeneratorRuntime.wrap(function _callee32$(_context71) {
1504
+ while (1) switch (_context71.prev = _context71.next) {
1505
+ case 0:
1506
+ Demo = /*#__PURE__*/function (_Component32) {
1507
+ _inheritsLoose(Demo, _Component32);
1508
+ function Demo() {
1509
+ var _context70;
1510
+ var _this32;
1511
+ for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
1512
+ args[_key32] = arguments[_key32];
1513
+ }
1514
+ _this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context70 = [this]).call(_context70, args)) || this;
1515
+ _this32.Sender = Sender;
1516
+ return _this32;
1517
+ }
1518
+ return Demo;
1519
+ }(Component);
1520
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n {key: 'b', uid: 'b', name: 'note.txt', type: 'text/plain'},\n ]} />\n </div>\n ";
1521
+ _mount32 = mount(Demo), element = _mount32[1]; // card 视图下,图片附件也应当以「文件卡」形式呈现,而不是图片缩略图
1522
+ expect(element.querySelectorAll('.k-file-card-file').length).to.eql(2);
1523
+ expect(element.querySelectorAll('.k-file-card-media').length).to.eql(0);
1524
+ case 5:
1525
+ case "end":
1526
+ return _context71.stop();
1527
+ }
1528
+ }, _callee32);
1529
+ })));
1530
+ it('should keep image media cards (square) in media view', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
1531
+ var Demo, _mount33, element;
1532
+ return _regeneratorRuntime.wrap(function _callee33$(_context73) {
1533
+ while (1) switch (_context73.prev = _context73.next) {
1534
+ case 0:
1535
+ Demo = /*#__PURE__*/function (_Component33) {
1536
+ _inheritsLoose(Demo, _Component33);
1537
+ function Demo() {
1538
+ var _context72;
1539
+ var _this33;
1540
+ for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
1541
+ args[_key33] = arguments[_key33];
1542
+ }
1543
+ _this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context72 = [this]).call(_context72, args)) || this;
1544
+ _this33.Sender = Sender;
1545
+ return _this33;
1546
+ }
1547
+ return Demo;
1548
+ }(Component);
1549
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n ]} />\n </div>\n ";
1550
+ _mount33 = mount(Demo), element = _mount33[1]; // media 视图下保留 FileCard 的图片渲染(自带 1:1 裁剪),不强制转成 file 卡片
1551
+ expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
1552
+ case 4:
1553
+ case "end":
1554
+ return _context73.stop();
1555
+ }
1556
+ }, _callee33);
1557
+ })));
1558
+ it('should enable name tooltip for Sender media attachments', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
1559
+ var Demo, _mount34, element, mediaView;
1560
+ return _regeneratorRuntime.wrap(function _callee34$(_context75) {
1561
+ while (1) switch (_context75.prev = _context75.next) {
1562
+ case 0:
1563
+ Demo = /*#__PURE__*/function (_Component34) {
1564
+ _inheritsLoose(Demo, _Component34);
1565
+ function Demo() {
1566
+ var _context74;
1567
+ var _this34;
1568
+ for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) {
1569
+ args[_key34] = arguments[_key34];
1570
+ }
1571
+ _this34 = _Component34.call.apply(_Component34, _concatInstanceProperty(_context74 = [this]).call(_context74, args)) || this;
1572
+ _this34.Sender = Sender;
1573
+ return _this34;
1574
+ }
1575
+ return Demo;
1576
+ }(Component);
1577
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'very-long-image-name.png', type: 'image/png', src: 'data:image/png;base64,AAAA'},\n ]} />\n </div>\n ";
1578
+ _mount34 = mount(Demo), element = _mount34[1];
1579
+ mediaView = element.querySelector('.k-file-card-media-view');
1580
+ expect(mediaView.querySelector('.k-media-name-tooltip-trigger')).not.to.eql(null);
1581
+ expect(mediaView.getAttribute('title')).to.eql(null);
1582
+ case 6:
1583
+ case "end":
1584
+ return _context75.stop();
1585
+ }
1586
+ }, _callee34);
1587
+ })));
1588
+ it('should infer media type from name in media view when attachment type is generic mime', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {
1589
+ var Demo, _mount35, element;
1590
+ return _regeneratorRuntime.wrap(function _callee35$(_context77) {
1591
+ while (1) switch (_context77.prev = _context77.next) {
1592
+ case 0:
1593
+ Demo = /*#__PURE__*/function (_Component35) {
1594
+ _inheritsLoose(Demo, _Component35);
1595
+ function Demo() {
1596
+ var _context76;
1597
+ var _this35;
1598
+ for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) {
1599
+ args[_key35] = arguments[_key35];
1600
+ }
1601
+ _this35 = _Component35.call.apply(_Component35, _concatInstanceProperty(_context76 = [this]).call(_context76, args)) || this;
1602
+ _this35.Sender = Sender;
1603
+ return _this35;
1604
+ }
1605
+ return Demo;
1606
+ }(Component);
1607
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'pic.png', type: 'application/octet-stream', src: 'blob:mock'},\n ]} />\n </div>\n ";
1608
+ _mount35 = mount(Demo), element = _mount35[1];
1609
+ expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
1610
+ expect(element.querySelector('.k-file-card-file')).to.eql(null);
1611
+ case 5:
1612
+ case "end":
1613
+ return _context77.stop();
1614
+ }
1615
+ }, _callee35);
1616
+ })));
1617
+ it('should keep explicit image type in media view even when src has no extension', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {
1618
+ var Demo, _mount36, element;
1619
+ return _regeneratorRuntime.wrap(function _callee36$(_context79) {
1620
+ while (1) switch (_context79.prev = _context79.next) {
1621
+ case 0:
1622
+ Demo = /*#__PURE__*/function (_Component36) {
1623
+ _inheritsLoose(Demo, _Component36);
1624
+ function Demo() {
1625
+ var _context78;
1626
+ var _this36;
1627
+ for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) {
1628
+ args[_key36] = arguments[_key36];
1629
+ }
1630
+ _this36 = _Component36.call.apply(_Component36, _concatInstanceProperty(_context78 = [this]).call(_context78, args)) || this;
1631
+ _this36.Sender = Sender;
1632
+ return _this36;
1633
+ }
1634
+ return Demo;
1635
+ }(Component);
1636
+ Demo.template = "\n const { Sender } = this;\n <div>\n <Sender fileView=\"media\" attachments={[\n {key: 'a', uid: 'a', name: 'unsplash.jpg', type: 'image', src: 'https://images.unsplash.com/photo-1492691527719-9d1e07e534b4?auto=format&fit=crop&w=1200&q=80'},\n ]} />\n </div>\n ";
1637
+ _mount36 = mount(Demo), element = _mount36[1];
1638
+ expect(element.querySelector('.k-file-card-media.k-file-card-type-image')).not.to.eql(null);
1639
+ expect(element.querySelector('.k-media-image')).not.to.eql(null);
1640
+ case 5:
1641
+ case "end":
1642
+ return _context79.stop();
1643
+ }
1644
+ }, _callee36);
1645
+ })));
1646
+ it('should support directory selection and preserve relative path metadata', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {
1647
+ var lastAttachments, Demo, _mount37, element, input, file;
1648
+ return _regeneratorRuntime.wrap(function _callee37$(_context81) {
1649
+ while (1) switch (_context81.prev = _context81.next) {
1650
+ case 0:
1651
+ lastAttachments = [];
1652
+ Demo = /*#__PURE__*/function (_Component37) {
1653
+ _inheritsLoose(Demo, _Component37);
1654
+ function Demo() {
1655
+ var _context80;
1656
+ var _this37;
1657
+ for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) {
1658
+ args[_key37] = arguments[_key37];
1659
+ }
1660
+ _this37 = _Component37.call.apply(_Component37, _concatInstanceProperty(_context80 = [this]).call(_context80, args)) || this;
1661
+ _this37.Sender = Sender;
1662
+ _this37.onChange = function (items) {
1663
+ lastAttachments = items;
1664
+ };
1665
+ return _this37;
1062
1666
  }
1063
1667
  Demo.defaults = function defaults() {
1064
1668
  return {
@@ -1068,7 +1672,7 @@ describe('Sender', function () {
1068
1672
  return Demo;
1069
1673
  }(Component);
1070
1674
  Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n uploadProps={{directory: true}}\n ev-$change:attachments={this.onChange}\n />\n ";
1071
- _mount24 = mount(Demo), element = _mount24[1];
1675
+ _mount37 = mount(Demo), element = _mount37[1];
1072
1676
  input = element.querySelector('.k-sender-file-input');
1073
1677
  expect(input.getAttribute('directory')).to.eql('');
1074
1678
  expect(input.getAttribute('webkitdirectory')).to.eql('');
@@ -1084,7 +1688,7 @@ describe('Sender', function () {
1084
1688
  configurable: true
1085
1689
  });
1086
1690
  dispatchEvent(input, 'change');
1087
- _context52.next = 13;
1691
+ _context81.next = 13;
1088
1692
  return wait();
1089
1693
  case 13:
1090
1694
  expect(lastAttachments.length).to.eql(1);
@@ -1092,31 +1696,31 @@ describe('Sender', function () {
1092
1696
  expect(lastAttachments[0].relativePath).to.eql('docs/hello.txt');
1093
1697
  case 16:
1094
1698
  case "end":
1095
- return _context52.stop();
1699
+ return _context81.stop();
1096
1700
  }
1097
- }, _callee24);
1701
+ }, _callee37);
1098
1702
  })));
1099
- it('should support mapAttachment for runtime uploading items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1703
+ it('should support mapAttachment for runtime uploading items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {
1100
1704
  var _element$querySelecto;
1101
- var lastAttachments, resolveBeforeUpload, Demo, _mount25, element, input, file;
1102
- return _regeneratorRuntime.wrap(function _callee25$(_context54) {
1103
- while (1) switch (_context54.prev = _context54.next) {
1705
+ var lastAttachments, resolveBeforeUpload, Demo, _mount38, element, input, file;
1706
+ return _regeneratorRuntime.wrap(function _callee38$(_context83) {
1707
+ while (1) switch (_context83.prev = _context83.next) {
1104
1708
  case 0:
1105
1709
  lastAttachments = [];
1106
- Demo = /*#__PURE__*/function (_Component25) {
1107
- _inheritsLoose(Demo, _Component25);
1710
+ Demo = /*#__PURE__*/function (_Component38) {
1711
+ _inheritsLoose(Demo, _Component38);
1108
1712
  function Demo() {
1109
- var _context53;
1110
- var _this25;
1111
- for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
1112
- args[_key25] = arguments[_key25];
1713
+ var _context82;
1714
+ var _this38;
1715
+ for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) {
1716
+ args[_key38] = arguments[_key38];
1113
1717
  }
1114
- _this25 = _Component25.call.apply(_Component25, _concatInstanceProperty(_context53 = [this]).call(_context53, args)) || this;
1115
- _this25.Sender = Sender;
1116
- _this25.onChange = function (items) {
1718
+ _this38 = _Component38.call.apply(_Component38, _concatInstanceProperty(_context82 = [this]).call(_context82, args)) || this;
1719
+ _this38.Sender = Sender;
1720
+ _this38.onChange = function (items) {
1117
1721
  lastAttachments = items;
1118
1722
  };
1119
- return _this25;
1723
+ return _this38;
1120
1724
  }
1121
1725
  Demo.defaults = function defaults() {
1122
1726
  return {
@@ -1143,7 +1747,7 @@ describe('Sender', function () {
1143
1747
  return Demo;
1144
1748
  }(Component);
1145
1749
  Demo.template = "\n const { Sender } = this;\n <Sender\n attachments={this.get('attachments')}\n uploadProps={this.getUploadProps()}\n ev-$change:attachments={this.onChange}\n />\n ";
1146
- _mount25 = mount(Demo), element = _mount25[1];
1750
+ _mount38 = mount(Demo), element = _mount38[1];
1147
1751
  input = element.querySelector('.k-sender-file-input');
1148
1752
  file = new File(['hello'], 'hello.txt', {
1149
1753
  type: 'text/plain'
@@ -1153,7 +1757,7 @@ describe('Sender', function () {
1153
1757
  configurable: true
1154
1758
  });
1155
1759
  dispatchEvent(input, 'change');
1156
- _context54.next = 10;
1760
+ _context83.next = 10;
1157
1761
  return wait();
1158
1762
  case 10:
1159
1763
  expect(lastAttachments.length).to.eql(1);
@@ -1165,30 +1769,30 @@ describe('Sender', function () {
1165
1769
  }
1166
1770
  case 15:
1167
1771
  case "end":
1168
- return _context54.stop();
1772
+ return _context83.stop();
1169
1773
  }
1170
- }, _callee25);
1774
+ }, _callee38);
1171
1775
  })));
1172
- it('should show fullscreen drag mask and add dropped files when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
1173
- var lastAttachments, Demo, _mount26, element, file, mask, card, icon, text;
1174
- return _regeneratorRuntime.wrap(function _callee26$(_context56) {
1175
- while (1) switch (_context56.prev = _context56.next) {
1776
+ it('should show fullscreen drag mask and add dropped files when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {
1777
+ var lastAttachments, Demo, _mount39, element, file, mask, card, icon, text;
1778
+ return _regeneratorRuntime.wrap(function _callee39$(_context85) {
1779
+ while (1) switch (_context85.prev = _context85.next) {
1176
1780
  case 0:
1177
1781
  lastAttachments = [];
1178
- Demo = /*#__PURE__*/function (_Component26) {
1179
- _inheritsLoose(Demo, _Component26);
1782
+ Demo = /*#__PURE__*/function (_Component39) {
1783
+ _inheritsLoose(Demo, _Component39);
1180
1784
  function Demo() {
1181
- var _context55;
1182
- var _this26;
1183
- for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
1184
- args[_key26] = arguments[_key26];
1785
+ var _context84;
1786
+ var _this39;
1787
+ for (var _len39 = arguments.length, args = new Array(_len39), _key39 = 0; _key39 < _len39; _key39++) {
1788
+ args[_key39] = arguments[_key39];
1185
1789
  }
1186
- _this26 = _Component26.call.apply(_Component26, _concatInstanceProperty(_context55 = [this]).call(_context55, args)) || this;
1187
- _this26.Sender = Sender;
1188
- _this26.onChange = function (items) {
1790
+ _this39 = _Component39.call.apply(_Component39, _concatInstanceProperty(_context84 = [this]).call(_context84, args)) || this;
1791
+ _this39.Sender = Sender;
1792
+ _this39.onChange = function (items) {
1189
1793
  lastAttachments = items;
1190
1794
  };
1191
- return _this26;
1795
+ return _this39;
1192
1796
  }
1193
1797
  Demo.defaults = function defaults() {
1194
1798
  return {
@@ -1198,14 +1802,14 @@ describe('Sender', function () {
1198
1802
  return Demo;
1199
1803
  }(Component);
1200
1804
  Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
1201
- _mount26 = mount(Demo), element = _mount26[1];
1805
+ _mount39 = mount(Demo), element = _mount39[1];
1202
1806
  file = new File(['hello'], 'hello.txt', {
1203
1807
  type: 'text/plain'
1204
1808
  });
1205
1809
  dispatchEvent(document, 'dragenter', {
1206
1810
  dataTransfer: getDataTransfer([file])
1207
1811
  });
1208
- _context56.next = 8;
1812
+ _context85.next = 8;
1209
1813
  return wait();
1210
1814
  case 8:
1211
1815
  mask = element.querySelector('.k-sender-drag-mask');
@@ -1222,7 +1826,7 @@ describe('Sender', function () {
1222
1826
  dispatchEvent(document, 'drop', {
1223
1827
  dataTransfer: getDataTransfer([file])
1224
1828
  });
1225
- _context56.next = 22;
1829
+ _context85.next = 22;
1226
1830
  return wait();
1227
1831
  case 22:
1228
1832
  expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
@@ -1230,70 +1834,70 @@ describe('Sender', function () {
1230
1834
  expect(lastAttachments[0].name).to.eql('hello.txt');
1231
1835
  case 25:
1232
1836
  case "end":
1233
- return _context56.stop();
1837
+ return _context85.stop();
1234
1838
  }
1235
- }, _callee26);
1839
+ }, _callee39);
1236
1840
  })));
1237
- it('should ignore non-file drags when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
1238
- var Demo, _mount27, element;
1239
- return _regeneratorRuntime.wrap(function _callee27$(_context58) {
1240
- while (1) switch (_context58.prev = _context58.next) {
1841
+ it('should ignore non-file drags when dragFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40() {
1842
+ var Demo, _mount40, element;
1843
+ return _regeneratorRuntime.wrap(function _callee40$(_context87) {
1844
+ while (1) switch (_context87.prev = _context87.next) {
1241
1845
  case 0:
1242
- Demo = /*#__PURE__*/function (_Component27) {
1243
- _inheritsLoose(Demo, _Component27);
1846
+ Demo = /*#__PURE__*/function (_Component40) {
1847
+ _inheritsLoose(Demo, _Component40);
1244
1848
  function Demo() {
1245
- var _context57;
1246
- var _this27;
1247
- for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
1248
- args[_key27] = arguments[_key27];
1849
+ var _context86;
1850
+ var _this40;
1851
+ for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) {
1852
+ args[_key40] = arguments[_key40];
1249
1853
  }
1250
- _this27 = _Component27.call.apply(_Component27, _concatInstanceProperty(_context57 = [this]).call(_context57, args)) || this;
1251
- _this27.Sender = Sender;
1252
- return _this27;
1854
+ _this40 = _Component40.call.apply(_Component40, _concatInstanceProperty(_context86 = [this]).call(_context86, args)) || this;
1855
+ _this40.Sender = Sender;
1856
+ return _this40;
1253
1857
  }
1254
1858
  return Demo;
1255
1859
  }(Component);
1256
1860
  Demo.template = "\n const { Sender } = this;\n <Sender dragFile={true} />\n ";
1257
- _mount27 = mount(Demo), element = _mount27[1];
1861
+ _mount40 = mount(Demo), element = _mount40[1];
1258
1862
  dispatchEvent(document, 'dragenter', {
1259
1863
  dataTransfer: {
1260
1864
  types: ['text/plain']
1261
1865
  }
1262
1866
  });
1263
- _context58.next = 6;
1867
+ _context87.next = 6;
1264
1868
  return wait();
1265
1869
  case 6:
1266
1870
  expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
1267
1871
  case 7:
1268
1872
  case "end":
1269
- return _context58.stop();
1873
+ return _context87.stop();
1270
1874
  }
1271
- }, _callee27);
1875
+ }, _callee40);
1272
1876
  })));
1273
- it('should trigger uploadError for invalid file type on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
1274
- var errorMessage, lastAttachments, Demo, _mount28, element, file;
1275
- return _regeneratorRuntime.wrap(function _callee28$(_context60) {
1276
- while (1) switch (_context60.prev = _context60.next) {
1877
+ it('should trigger uploadError for invalid file type on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {
1878
+ var errorMessage, lastAttachments, Demo, _mount41, element, file;
1879
+ return _regeneratorRuntime.wrap(function _callee41$(_context89) {
1880
+ while (1) switch (_context89.prev = _context89.next) {
1277
1881
  case 0:
1278
1882
  errorMessage = '';
1279
1883
  lastAttachments = [];
1280
- Demo = /*#__PURE__*/function (_Component28) {
1281
- _inheritsLoose(Demo, _Component28);
1884
+ Demo = /*#__PURE__*/function (_Component41) {
1885
+ _inheritsLoose(Demo, _Component41);
1282
1886
  function Demo() {
1283
- var _context59;
1284
- var _this28;
1285
- for (var _len28 = arguments.length, args = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) {
1286
- args[_key28] = arguments[_key28];
1887
+ var _context88;
1888
+ var _this41;
1889
+ for (var _len41 = arguments.length, args = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) {
1890
+ args[_key41] = arguments[_key41];
1287
1891
  }
1288
- _this28 = _Component28.call.apply(_Component28, _concatInstanceProperty(_context59 = [this]).call(_context59, args)) || this;
1289
- _this28.Sender = Sender;
1290
- _this28.onChange = function (items) {
1892
+ _this41 = _Component41.call.apply(_Component41, _concatInstanceProperty(_context88 = [this]).call(_context88, args)) || this;
1893
+ _this41.Sender = Sender;
1894
+ _this41.onChange = function (items) {
1291
1895
  lastAttachments = items;
1292
1896
  };
1293
- _this28.onUploadError = function (error) {
1897
+ _this41.onUploadError = function (error) {
1294
1898
  errorMessage = error.message;
1295
1899
  };
1296
- return _this28;
1900
+ return _this41;
1297
1901
  }
1298
1902
  Demo.defaults = function defaults() {
1299
1903
  return {
@@ -1303,21 +1907,21 @@ describe('Sender', function () {
1303
1907
  return Demo;
1304
1908
  }(Component);
1305
1909
  Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n uploadProps={{accept: 'image/*'}}\n ev-$change:attachments={this.onChange}\n ev-uploadError={this.onUploadError}\n />\n ";
1306
- _mount28 = mount(Demo), element = _mount28[1];
1910
+ _mount41 = mount(Demo), element = _mount41[1];
1307
1911
  file = new File(['hello'], 'hello.txt', {
1308
1912
  type: 'text/plain'
1309
1913
  });
1310
1914
  dispatchEvent(document, 'dragenter', {
1311
1915
  dataTransfer: getDataTransfer([file])
1312
1916
  });
1313
- _context60.next = 9;
1917
+ _context89.next = 9;
1314
1918
  return wait();
1315
1919
  case 9:
1316
1920
  expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
1317
1921
  dispatchEvent(document, 'drop', {
1318
1922
  dataTransfer: getDataTransfer([file])
1319
1923
  });
1320
- _context60.next = 13;
1924
+ _context89.next = 13;
1321
1925
  return wait();
1322
1926
  case 13:
1323
1927
  expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
@@ -1325,30 +1929,30 @@ describe('Sender', function () {
1325
1929
  expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
1326
1930
  case 16:
1327
1931
  case "end":
1328
- return _context60.stop();
1932
+ return _context89.stop();
1329
1933
  }
1330
- }, _callee28);
1934
+ }, _callee41);
1331
1935
  })));
1332
- it('should flatten dragged directory files when uploadProps.directory is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
1333
- var lastAttachments, Demo, _mount29, element, noteFile, imageFile, docsDir;
1334
- return _regeneratorRuntime.wrap(function _callee29$(_context62) {
1335
- while (1) switch (_context62.prev = _context62.next) {
1936
+ it('should flatten dragged directory files when uploadProps.directory is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42() {
1937
+ var lastAttachments, Demo, _mount42, element, noteFile, imageFile, docsDir;
1938
+ return _regeneratorRuntime.wrap(function _callee42$(_context91) {
1939
+ while (1) switch (_context91.prev = _context91.next) {
1336
1940
  case 0:
1337
1941
  lastAttachments = [];
1338
- Demo = /*#__PURE__*/function (_Component29) {
1339
- _inheritsLoose(Demo, _Component29);
1942
+ Demo = /*#__PURE__*/function (_Component42) {
1943
+ _inheritsLoose(Demo, _Component42);
1340
1944
  function Demo() {
1341
- var _context61;
1342
- var _this29;
1343
- for (var _len29 = arguments.length, args = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
1344
- args[_key29] = arguments[_key29];
1945
+ var _context90;
1946
+ var _this42;
1947
+ for (var _len42 = arguments.length, args = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) {
1948
+ args[_key42] = arguments[_key42];
1345
1949
  }
1346
- _this29 = _Component29.call.apply(_Component29, _concatInstanceProperty(_context61 = [this]).call(_context61, args)) || this;
1347
- _this29.Sender = Sender;
1348
- _this29.onChange = function (items) {
1950
+ _this42 = _Component42.call.apply(_Component42, _concatInstanceProperty(_context90 = [this]).call(_context90, args)) || this;
1951
+ _this42.Sender = Sender;
1952
+ _this42.onChange = function (items) {
1349
1953
  lastAttachments = items;
1350
1954
  };
1351
- return _this29;
1955
+ return _this42;
1352
1956
  }
1353
1957
  Demo.defaults = function defaults() {
1354
1958
  return {
@@ -1358,7 +1962,7 @@ describe('Sender', function () {
1358
1962
  return Demo;
1359
1963
  }(Component);
1360
1964
  Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n uploadProps={{directory: true}}\n ev-$change:attachments={this.onChange}\n />\n ";
1361
- _mount29 = mount(Demo), element = _mount29[1];
1965
+ _mount42 = mount(Demo), element = _mount42[1];
1362
1966
  noteFile = new File(['note'], 'note.txt', {
1363
1967
  type: 'text/plain'
1364
1968
  });
@@ -1369,14 +1973,14 @@ describe('Sender', function () {
1369
1973
  dispatchEvent(document, 'dragenter', {
1370
1974
  dataTransfer: getDataTransfer([noteFile])
1371
1975
  });
1372
- _context62.next = 10;
1976
+ _context91.next = 10;
1373
1977
  return wait();
1374
1978
  case 10:
1375
1979
  expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
1376
1980
  dispatchEvent(document, 'drop', {
1377
1981
  dataTransfer: getDataTransferWithEntries([docsDir])
1378
1982
  });
1379
- _context62.next = 14;
1983
+ _context91.next = 14;
1380
1984
  return wait(20);
1381
1985
  case 14:
1382
1986
  expect(lastAttachments.length).to.eql(2);
@@ -1389,34 +1993,34 @@ describe('Sender', function () {
1389
1993
  expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
1390
1994
  case 18:
1391
1995
  case "end":
1392
- return _context62.stop();
1996
+ return _context91.stop();
1393
1997
  }
1394
- }, _callee29);
1998
+ }, _callee42);
1395
1999
  })));
1396
- it('should still validate flattened directory files on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
1397
- var errorMessage, lastAttachments, Demo, _mount30, element, file, docsDir;
1398
- return _regeneratorRuntime.wrap(function _callee30$(_context64) {
1399
- while (1) switch (_context64.prev = _context64.next) {
2000
+ it('should still validate flattened directory files on drag drop', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43() {
2001
+ var errorMessage, lastAttachments, Demo, _mount43, element, file, docsDir;
2002
+ return _regeneratorRuntime.wrap(function _callee43$(_context93) {
2003
+ while (1) switch (_context93.prev = _context93.next) {
1400
2004
  case 0:
1401
2005
  errorMessage = '';
1402
2006
  lastAttachments = [];
1403
- Demo = /*#__PURE__*/function (_Component30) {
1404
- _inheritsLoose(Demo, _Component30);
2007
+ Demo = /*#__PURE__*/function (_Component43) {
2008
+ _inheritsLoose(Demo, _Component43);
1405
2009
  function Demo() {
1406
- var _context63;
1407
- var _this30;
1408
- for (var _len30 = arguments.length, args = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
1409
- args[_key30] = arguments[_key30];
2010
+ var _context92;
2011
+ var _this43;
2012
+ for (var _len43 = arguments.length, args = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) {
2013
+ args[_key43] = arguments[_key43];
1410
2014
  }
1411
- _this30 = _Component30.call.apply(_Component30, _concatInstanceProperty(_context63 = [this]).call(_context63, args)) || this;
1412
- _this30.Sender = Sender;
1413
- _this30.onChange = function (items) {
2015
+ _this43 = _Component43.call.apply(_Component43, _concatInstanceProperty(_context92 = [this]).call(_context92, args)) || this;
2016
+ _this43.Sender = Sender;
2017
+ _this43.onChange = function (items) {
1414
2018
  lastAttachments = items;
1415
2019
  };
1416
- _this30.onUploadError = function (error) {
2020
+ _this43.onUploadError = function (error) {
1417
2021
  errorMessage = error.message;
1418
2022
  };
1419
- return _this30;
2023
+ return _this43;
1420
2024
  }
1421
2025
  Demo.defaults = function defaults() {
1422
2026
  return {
@@ -1426,7 +2030,7 @@ describe('Sender', function () {
1426
2030
  return Demo;
1427
2031
  }(Component);
1428
2032
  Demo.template = "\n const { Sender } = this;\n <Sender\n dragFile={true}\n attachments={this.get('attachments')}\n uploadProps={{directory: true, accept: 'image/*'}}\n ev-$change:attachments={this.onChange}\n ev-uploadError={this.onUploadError}\n />\n ";
1429
- _mount30 = mount(Demo), element = _mount30[1];
2033
+ _mount43 = mount(Demo), element = _mount43[1];
1430
2034
  file = new File(['hello'], 'hello.txt', {
1431
2035
  type: 'text/plain'
1432
2036
  });
@@ -1434,14 +2038,14 @@ describe('Sender', function () {
1434
2038
  dispatchEvent(document, 'dragenter', {
1435
2039
  dataTransfer: getDataTransfer([file])
1436
2040
  });
1437
- _context64.next = 10;
2041
+ _context93.next = 10;
1438
2042
  return wait();
1439
2043
  case 10:
1440
2044
  expect(element.querySelector('.k-sender-drag-mask')).not.to.eql(null);
1441
2045
  dispatchEvent(document, 'drop', {
1442
2046
  dataTransfer: getDataTransferWithEntries([docsDir])
1443
2047
  });
1444
- _context64.next = 14;
2048
+ _context93.next = 14;
1445
2049
  return wait(20);
1446
2050
  case 14:
1447
2051
  expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
@@ -1449,30 +2053,30 @@ describe('Sender', function () {
1449
2053
  expect(element.querySelector('.k-sender-drag-mask')).to.eql(null);
1450
2054
  case 17:
1451
2055
  case "end":
1452
- return _context64.stop();
2056
+ return _context93.stop();
1453
2057
  }
1454
- }, _callee30);
2058
+ }, _callee43);
1455
2059
  })));
1456
- it('should add pasted files when pasteFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
1457
- var lastAttachments, Demo, _mount31, element, textarea, file;
1458
- return _regeneratorRuntime.wrap(function _callee31$(_context66) {
1459
- while (1) switch (_context66.prev = _context66.next) {
2060
+ it('should add pasted files when pasteFile is enabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44() {
2061
+ var lastAttachments, Demo, _mount44, element, textarea, file;
2062
+ return _regeneratorRuntime.wrap(function _callee44$(_context95) {
2063
+ while (1) switch (_context95.prev = _context95.next) {
1460
2064
  case 0:
1461
2065
  lastAttachments = [];
1462
- Demo = /*#__PURE__*/function (_Component31) {
1463
- _inheritsLoose(Demo, _Component31);
2066
+ Demo = /*#__PURE__*/function (_Component44) {
2067
+ _inheritsLoose(Demo, _Component44);
1464
2068
  function Demo() {
1465
- var _context65;
1466
- var _this31;
1467
- for (var _len31 = arguments.length, args = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
1468
- args[_key31] = arguments[_key31];
2069
+ var _context94;
2070
+ var _this44;
2071
+ for (var _len44 = arguments.length, args = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) {
2072
+ args[_key44] = arguments[_key44];
1469
2073
  }
1470
- _this31 = _Component31.call.apply(_Component31, _concatInstanceProperty(_context65 = [this]).call(_context65, args)) || this;
1471
- _this31.Sender = Sender;
1472
- _this31.onChange = function (items) {
2074
+ _this44 = _Component44.call.apply(_Component44, _concatInstanceProperty(_context94 = [this]).call(_context94, args)) || this;
2075
+ _this44.Sender = Sender;
2076
+ _this44.onChange = function (items) {
1473
2077
  lastAttachments = items;
1474
2078
  };
1475
- return _this31;
2079
+ return _this44;
1476
2080
  }
1477
2081
  Demo.defaults = function defaults() {
1478
2082
  return {
@@ -1482,7 +2086,7 @@ describe('Sender', function () {
1482
2086
  return Demo;
1483
2087
  }(Component);
1484
2088
  Demo.template = "\n const { Sender } = this;\n <Sender\n pasteFile={true}\n attachments={this.get('attachments')}\n ev-$change:attachments={this.onChange}\n />\n ";
1485
- _mount31 = mount(Demo), element = _mount31[1];
2089
+ _mount44 = mount(Demo), element = _mount44[1];
1486
2090
  textarea = element.querySelector('.k-sender-input');
1487
2091
  file = new File(['image'], 'cover.png', {
1488
2092
  type: 'image/png'
@@ -1490,41 +2094,41 @@ describe('Sender', function () {
1490
2094
  dispatchEvent(textarea, 'paste', {
1491
2095
  clipboardData: getClipboardData([file])
1492
2096
  });
1493
- _context66.next = 9;
2097
+ _context95.next = 9;
1494
2098
  return wait();
1495
2099
  case 9:
1496
2100
  expect(lastAttachments.length).to.eql(1);
1497
2101
  expect(lastAttachments[0].name).to.eql('cover.png');
1498
2102
  case 11:
1499
2103
  case "end":
1500
- return _context66.stop();
2104
+ return _context95.stop();
1501
2105
  }
1502
- }, _callee31);
2106
+ }, _callee44);
1503
2107
  })));
1504
- it('should trigger uploadError for invalid file type on paste', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
1505
- var errorMessage, lastAttachments, Demo, _mount32, element, textarea, file;
1506
- return _regeneratorRuntime.wrap(function _callee32$(_context68) {
1507
- while (1) switch (_context68.prev = _context68.next) {
2108
+ it('should trigger uploadError for invalid file type on paste', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45() {
2109
+ var errorMessage, lastAttachments, Demo, _mount45, element, textarea, file;
2110
+ return _regeneratorRuntime.wrap(function _callee45$(_context97) {
2111
+ while (1) switch (_context97.prev = _context97.next) {
1508
2112
  case 0:
1509
2113
  errorMessage = '';
1510
2114
  lastAttachments = [];
1511
- Demo = /*#__PURE__*/function (_Component32) {
1512
- _inheritsLoose(Demo, _Component32);
2115
+ Demo = /*#__PURE__*/function (_Component45) {
2116
+ _inheritsLoose(Demo, _Component45);
1513
2117
  function Demo() {
1514
- var _context67;
1515
- var _this32;
1516
- for (var _len32 = arguments.length, args = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
1517
- args[_key32] = arguments[_key32];
2118
+ var _context96;
2119
+ var _this45;
2120
+ for (var _len45 = arguments.length, args = new Array(_len45), _key45 = 0; _key45 < _len45; _key45++) {
2121
+ args[_key45] = arguments[_key45];
1518
2122
  }
1519
- _this32 = _Component32.call.apply(_Component32, _concatInstanceProperty(_context67 = [this]).call(_context67, args)) || this;
1520
- _this32.Sender = Sender;
1521
- _this32.onChange = function (items) {
2123
+ _this45 = _Component45.call.apply(_Component45, _concatInstanceProperty(_context96 = [this]).call(_context96, args)) || this;
2124
+ _this45.Sender = Sender;
2125
+ _this45.onChange = function (items) {
1522
2126
  lastAttachments = items;
1523
2127
  };
1524
- _this32.onUploadError = function (error) {
2128
+ _this45.onUploadError = function (error) {
1525
2129
  errorMessage = error.message;
1526
2130
  };
1527
- return _this32;
2131
+ return _this45;
1528
2132
  }
1529
2133
  Demo.defaults = function defaults() {
1530
2134
  return {
@@ -1534,7 +2138,7 @@ describe('Sender', function () {
1534
2138
  return Demo;
1535
2139
  }(Component);
1536
2140
  Demo.template = "\n const { Sender } = this;\n <Sender\n pasteFile={true}\n attachments={this.get('attachments')}\n uploadProps={{accept: 'image/*'}}\n ev-$change:attachments={this.onChange}\n ev-uploadError={this.onUploadError}\n />\n ";
1537
- _mount32 = mount(Demo), element = _mount32[1];
2141
+ _mount45 = mount(Demo), element = _mount45[1];
1538
2142
  textarea = element.querySelector('.k-sender-input');
1539
2143
  file = new File(['hello'], 'hello.txt', {
1540
2144
  type: 'text/plain'
@@ -1542,38 +2146,38 @@ describe('Sender', function () {
1542
2146
  dispatchEvent(textarea, 'paste', {
1543
2147
  clipboardData: getClipboardData([file])
1544
2148
  });
1545
- _context68.next = 10;
2149
+ _context97.next = 10;
1546
2150
  return wait();
1547
2151
  case 10:
1548
2152
  expect(errorMessage).to.eql('"hello.txt" 文件类型不合法');
1549
2153
  expect(lastAttachments.length).to.eql(0);
1550
2154
  case 12:
1551
2155
  case "end":
1552
- return _context68.stop();
2156
+ return _context97.stop();
1553
2157
  }
1554
- }, _callee32);
2158
+ }, _callee45);
1555
2159
  })));
1556
- it('should keep native text paste when pasteFile is disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
1557
- var Demo, _mount33, element, textarea, file, event;
1558
- return _regeneratorRuntime.wrap(function _callee33$(_context70) {
1559
- while (1) switch (_context70.prev = _context70.next) {
2160
+ it('should keep native text paste when pasteFile is disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46() {
2161
+ var Demo, _mount46, element, textarea, file, event;
2162
+ return _regeneratorRuntime.wrap(function _callee46$(_context99) {
2163
+ while (1) switch (_context99.prev = _context99.next) {
1560
2164
  case 0:
1561
- Demo = /*#__PURE__*/function (_Component33) {
1562
- _inheritsLoose(Demo, _Component33);
2165
+ Demo = /*#__PURE__*/function (_Component46) {
2166
+ _inheritsLoose(Demo, _Component46);
1563
2167
  function Demo() {
1564
- var _context69;
1565
- var _this33;
1566
- for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
1567
- args[_key33] = arguments[_key33];
2168
+ var _context98;
2169
+ var _this46;
2170
+ for (var _len46 = arguments.length, args = new Array(_len46), _key46 = 0; _key46 < _len46; _key46++) {
2171
+ args[_key46] = arguments[_key46];
1568
2172
  }
1569
- _this33 = _Component33.call.apply(_Component33, _concatInstanceProperty(_context69 = [this]).call(_context69, args)) || this;
1570
- _this33.Sender = Sender;
1571
- return _this33;
2173
+ _this46 = _Component46.call.apply(_Component46, _concatInstanceProperty(_context98 = [this]).call(_context98, args)) || this;
2174
+ _this46.Sender = Sender;
2175
+ return _this46;
1572
2176
  }
1573
2177
  return Demo;
1574
2178
  }(Component);
1575
2179
  Demo.template = "\n const { Sender } = this;\n <Sender />\n ";
1576
- _mount33 = mount(Demo), element = _mount33[1];
2180
+ _mount46 = mount(Demo), element = _mount46[1];
1577
2181
  textarea = element.querySelector('.k-sender-input');
1578
2182
  file = new File(['image'], 'cover.png', {
1579
2183
  type: 'image/png'
@@ -1584,14 +2188,14 @@ describe('Sender', function () {
1584
2188
  clipboardData: getClipboardData([file])
1585
2189
  });
1586
2190
  textarea.dispatchEvent(event);
1587
- _context70.next = 11;
2191
+ _context99.next = 11;
1588
2192
  return wait();
1589
2193
  case 11:
1590
2194
  expect(event.defaultPrevented).to.eql(false);
1591
2195
  case 12:
1592
2196
  case "end":
1593
- return _context70.stop();
2197
+ return _context99.stop();
1594
2198
  }
1595
- }, _callee33);
2199
+ }, _callee46);
1596
2200
  })));
1597
2201
  });