@king-design/vue 3.5.2 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +111 -47
  2. package/__tests__/components/misc.spec.ts +93 -0
  3. package/components/cascader/index.spec.js +18 -19
  4. package/components/datepicker/basepicker.d.ts +6 -25
  5. package/components/datepicker/basepicker.js +22 -234
  6. package/components/datepicker/calendar.d.ts +36 -6
  7. package/components/datepicker/calendar.js +4 -0
  8. package/components/datepicker/calendar.vdt.js +21 -5
  9. package/components/datepicker/dayjs.d.ts +2 -2
  10. package/components/datepicker/dayjs.js +6 -0
  11. package/components/datepicker/helpers.d.ts +8 -7
  12. package/components/datepicker/helpers.js +2 -3
  13. package/components/datepicker/index.d.ts +26 -19
  14. package/components/datepicker/index.js +21 -13
  15. package/components/datepicker/index.spec.js +1389 -633
  16. package/components/datepicker/index.vdt.js +43 -46
  17. package/components/datepicker/shortcuts.d.ts +1 -1
  18. package/components/datepicker/styles.d.ts +22 -0
  19. package/components/datepicker/styles.js +26 -4
  20. package/components/datepicker/useConfirm.d.ts +6 -0
  21. package/components/datepicker/useConfirm.js +65 -0
  22. package/components/datepicker/useDisabled.d.ts +7 -5
  23. package/components/datepicker/useDisabled.js +22 -27
  24. package/components/datepicker/useFormats.d.ts +2 -2
  25. package/components/datepicker/useFormats.js +9 -3
  26. package/components/datepicker/useHighlight.d.ts +14 -0
  27. package/components/datepicker/useHighlight.js +60 -0
  28. package/components/datepicker/useKeyboards.js +2 -1
  29. package/components/datepicker/useMergeRange.d.ts +5 -0
  30. package/components/datepicker/useMergeRange.js +45 -0
  31. package/components/datepicker/useMonths.js +5 -3
  32. package/components/datepicker/usePanel.d.ts +1 -10
  33. package/components/datepicker/usePanel.js +19 -32
  34. package/components/datepicker/useQuarters.d.ts +15 -0
  35. package/components/datepicker/useQuarters.js +36 -0
  36. package/components/datepicker/useShowDate.js +10 -2
  37. package/components/datepicker/useStatus.d.ts +1 -1
  38. package/components/datepicker/useStatus.js +33 -16
  39. package/components/datepicker/useValue.d.ts +12 -6
  40. package/components/datepicker/useValue.js +49 -45
  41. package/components/datepicker/useValueBase.d.ts +28 -0
  42. package/components/datepicker/useValueBase.js +277 -0
  43. package/components/datepicker/useWeeks.d.ts +19 -0
  44. package/components/datepicker/useWeeks.js +48 -0
  45. package/components/datepicker/useYears.js +6 -3
  46. package/components/dialog/useFixBody.js +6 -58
  47. package/components/dropdown/dropdown.d.ts +1 -0
  48. package/components/dropdown/dropdown.js +7 -4
  49. package/components/ellipsis/styles.js +1 -1
  50. package/components/form/styles.js +1 -1
  51. package/components/input/index.d.ts +2 -0
  52. package/components/input/index.js +6 -0
  53. package/components/input/index.spec.js +45 -0
  54. package/components/input/index.vdt.js +4 -3
  55. package/components/input/useAutoWidth.d.ts +2 -0
  56. package/components/input/useAutoWidth.js +19 -1
  57. package/components/scrollSelect/index.spec.js +4 -6
  58. package/components/scrollSelect/useMouseEvents.js +22 -9
  59. package/components/select/base.d.ts +1 -1
  60. package/components/select/base.js +3 -2
  61. package/components/select/base.vdt.js +5 -2
  62. package/components/select/index.spec.js +329 -82
  63. package/components/select/option.d.ts +1 -0
  64. package/components/select/option.js +10 -2
  65. package/components/select/select.d.ts +1 -0
  66. package/components/select/select.js +4 -2
  67. package/components/select/styles.d.ts +79 -0
  68. package/components/select/styles.js +1 -0
  69. package/components/select/useFilterable.js +2 -1
  70. package/components/select/useInput.d.ts +1 -1
  71. package/components/select/useInput.js +7 -4
  72. package/components/select/useSearchable.js +1 -0
  73. package/components/table/index.spec.js +84 -6
  74. package/components/table/useStickyHeader.js +1 -1
  75. package/components/timepicker/index.spec.js +298 -128
  76. package/components/timepicker/panelPicker.d.ts +23 -17
  77. package/components/timepicker/panelPicker.js +7 -4
  78. package/components/timepicker/panelPicker.vdt.js +8 -4
  79. package/components/timepicker/selectPicker.d.ts +5 -4
  80. package/components/timepicker/useConfirm.d.ts +6 -0
  81. package/components/timepicker/useConfirm.js +19 -0
  82. package/components/timepicker/useDefaultValue.d.ts +4 -0
  83. package/components/timepicker/useDefaultValue.js +27 -0
  84. package/components/timepicker/useDisabled.d.ts +7 -4
  85. package/components/timepicker/useDisabled.js +13 -4
  86. package/components/timepicker/useFormats.d.ts +1 -1
  87. package/components/timepicker/useValue.d.ts +14 -8
  88. package/components/timepicker/useValue.js +14 -15
  89. package/components/tour/index.d.ts +2 -0
  90. package/components/tour/index.js +2 -0
  91. package/components/tour/index.spec.d.ts +1 -0
  92. package/components/tour/index.spec.js +356 -0
  93. package/components/tour/step.d.ts +23 -0
  94. package/components/tour/step.js +46 -0
  95. package/components/tour/step.vdt.js +74 -0
  96. package/components/tour/styles.d.ts +7 -0
  97. package/components/tour/styles.js +84 -0
  98. package/components/tour/tour.d.ts +73 -0
  99. package/components/tour/tour.js +70 -0
  100. package/components/tour/tour.vdt.js +66 -0
  101. package/components/tour/useArrow.d.ts +4 -0
  102. package/components/tour/useArrow.js +40 -0
  103. package/components/tour/useFixBody.d.ts +4 -0
  104. package/components/tour/useFixBody.js +17 -0
  105. package/components/tour/useHighlight.d.ts +4 -0
  106. package/components/tour/useHighlight.js +31 -0
  107. package/components/tour/useMaskClosable.d.ts +1 -0
  108. package/components/tour/useMaskClosable.js +25 -0
  109. package/components/tour/useNavigation.d.ts +5 -0
  110. package/components/tour/useNavigation.js +103 -0
  111. package/components/tour/usePosition.d.ts +6 -0
  112. package/components/tour/usePosition.js +93 -0
  113. package/components/tour/useSteps.d.ts +6 -0
  114. package/components/tour/useSteps.js +68 -0
  115. package/hooks/useFixBody.d.ts +11 -0
  116. package/hooks/useFixBody.js +72 -0
  117. package/index.d.ts +3 -2
  118. package/index.js +3 -2
  119. package/package.json +2 -2
@@ -1,6 +1,7 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
2
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
3
3
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
4
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
4
5
  import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
5
6
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
6
7
  import BasicDemo from '~/components/select/demos/basic';
@@ -316,103 +317,265 @@ describe('Select', function () {
316
317
  }, _callee7);
317
318
  })));
318
319
  it('creatable', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
319
- var _mount9, instance, element, input, dropdown;
320
+ var _mount9, instance, element, input, dropdown, createOption, newCreateOption, _element$querySelecto6, multipleInput, multipleDropdown, mondayOption;
320
321
  return _regeneratorRuntime.wrap(function _callee8$(_context9) {
321
322
  while (1) switch (_context9.prev = _context9.next) {
322
323
  case 0:
323
324
  _mount9 = mount(CreatableDemo), instance = _mount9[0], element = _mount9[1];
324
325
  input = element.querySelector('.k-input-inner');
326
+ expect(instance.get('day')).to.be.null;
325
327
  input.click();
326
- _context9.next = 5;
328
+ _context9.next = 6;
327
329
  return wait();
328
- case 5:
330
+ case 6:
329
331
  input.value = 'xxx';
330
332
  dispatchEvent(input, 'input');
331
- _context9.next = 9;
333
+ _context9.next = 10;
332
334
  return wait();
333
- case 9:
335
+ case 10:
334
336
  dropdown = getElement('.k-select-menu');
335
337
  expect(dropdown.innerHTML).to.matchSnapshot();
336
- // select
338
+ // check the created option appears in dropdown
339
+ createOption = dropdown.querySelector('.k-select-option');
340
+ expect(createOption).to.exist;
341
+ expect(createOption.textContent).to.contain('xxx');
342
+ // press enter to select the custom option
337
343
  dispatchEvent(document, 'keydown', {
338
344
  keyCode: 13
339
345
  });
340
- _context9.next = 14;
346
+ _context9.next = 18;
341
347
  return wait();
342
- case 14:
348
+ case 18:
343
349
  expect(instance.get('day')).to.eql('xxx');
344
- // open again
350
+ expect(input.value).to.eql('xxx');
351
+ // reopen dropdown
345
352
  input.click();
346
- _context9.next = 18;
353
+ _context9.next = 23;
347
354
  return wait();
348
- case 18:
355
+ case 23:
349
356
  expect(element.innerHTML).to.matchSnapshot();
350
357
  expect(dropdown.innerHTML).to.matchSnapshot();
351
- // input again
358
+ // input another custom option
352
359
  input.value = 'yyy';
353
360
  dispatchEvent(input, 'input');
354
- _context9.next = 24;
361
+ _context9.next = 29;
355
362
  return wait();
356
- case 24:
363
+ case 29:
357
364
  expect(element.innerHTML).to.matchSnapshot();
358
365
  expect(dropdown.innerHTML).to.matchSnapshot();
359
- // discard
366
+ newCreateOption = dropdown.querySelector('.k-select-option');
367
+ expect(newCreateOption).to.exist;
368
+ expect(newCreateOption.textContent).to.contain('yyy');
369
+ // click outside to cancel selection
360
370
  dispatchEvent(document, 'click');
361
- _context9.next = 29;
371
+ _context9.next = 37;
362
372
  return wait();
363
- case 29:
373
+ case 37:
364
374
  expect(element.innerHTML).to.matchSnapshot();
365
- expect(instance.get('day')).to.eql('xxx');
366
- case 31:
375
+ expect(instance.get('day')).to.eql('xxx'); // should keep the original value
376
+ expect(input.value).to.eql('xxx'); // should restore the original value
377
+ // test multiple creatable
378
+ _element$querySelecto6 = element.querySelectorAll('.k-input-inner'), multipleInput = _element$querySelecto6[1];
379
+ expect(instance.get('days')).to.eql([]);
380
+ multipleInput.click();
381
+ _context9.next = 45;
382
+ return wait();
383
+ case 45:
384
+ multipleInput.value = 'custom1';
385
+ dispatchEvent(multipleInput, 'input');
386
+ _context9.next = 49;
387
+ return wait();
388
+ case 49:
389
+ // press enter to create and select the first custom option
390
+ dispatchEvent(document, 'keydown', {
391
+ keyCode: 13
392
+ });
393
+ _context9.next = 52;
394
+ return wait();
395
+ case 52:
396
+ expect(instance.get('days')).to.include('custom1');
397
+ expect(multipleInput.value).to.eql('custom1');
398
+ // input the same option again
399
+ dispatchEvent(document, 'keydown', {
400
+ keyCode: 13
401
+ });
402
+ _context9.next = 57;
403
+ return wait();
404
+ case 57:
405
+ expect(instance.get('days')).to.eql([]);
406
+ expect(multipleInput.value).to.eql('custom1');
407
+ // test select original options
408
+ multipleInput.value = 'Monday';
409
+ dispatchEvent(multipleInput, 'input');
410
+ _context9.next = 63;
411
+ return wait();
412
+ case 63:
413
+ multipleDropdown = getElement('.k-select-menu');
414
+ mondayOption = multipleDropdown.querySelector('.k-select-option');
415
+ expect(mondayOption.textContent).to.eql('星期一');
416
+ mondayOption.click();
417
+ _context9.next = 69;
418
+ return wait();
419
+ case 69:
420
+ expect(instance.get('days')).to.include('Monday');
421
+ case 70:
367
422
  case "end":
368
423
  return _context9.stop();
369
424
  }
370
425
  }, _callee8);
371
426
  })));
372
- it('Tooltip with Select', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
373
- var Demo, _mount10, instance, element;
427
+ it('keepKeywords', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
428
+ var KeepKeywordsDemo, _mount10, instance, element, input, dropdown, mondayOption;
374
429
  return _regeneratorRuntime.wrap(function _callee9$(_context11) {
375
430
  while (1) switch (_context11.prev = _context11.next) {
376
431
  case 0:
377
- Demo = /*#__PURE__*/function (_Component2) {
378
- _inheritsLoose(Demo, _Component2);
379
- function Demo() {
432
+ KeepKeywordsDemo = /*#__PURE__*/function (_Component2) {
433
+ _inheritsLoose(KeepKeywordsDemo, _Component2);
434
+ function KeepKeywordsDemo() {
380
435
  var _context10;
381
436
  var _this2;
382
437
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
383
438
  args[_key2] = arguments[_key2];
384
439
  }
385
440
  _this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context10 = [this]).call(_context10, args)) || this;
386
- _this2.Tooltip = Tooltip;
387
441
  _this2.Select = Select;
388
442
  _this2.Option = Option;
389
443
  return _this2;
390
444
  }
445
+ KeepKeywordsDemo.defaults = function defaults() {
446
+ return {
447
+ days: []
448
+ };
449
+ };
450
+ return KeepKeywordsDemo;
451
+ }(Component);
452
+ KeepKeywordsDemo.template = "\n const {Select, Option} = this;\n <div>\n <Select v-model=\"days\" filterable multiple creatable keepKeywords={false}>\n <Option value=\"Monday\">\u661F\u671F\u4E00</Option>\n <Option value=\"Tuesday\">\u661F\u671F\u4E8C</Option>\n <Option value=\"Wednesday\">\u661F\u671F\u4E09</Option>\n </Select>\n </div>\n ";
453
+ _mount10 = mount(KeepKeywordsDemo), instance = _mount10[0], element = _mount10[1];
454
+ input = element.querySelector('.k-input-inner'); // input custom option "custom1"
455
+ input.click();
456
+ _context11.next = 7;
457
+ return wait();
458
+ case 7:
459
+ input.value = 'custom1';
460
+ dispatchEvent(input, 'input');
461
+ _context11.next = 11;
462
+ return wait();
463
+ case 11:
464
+ // check the created option appears in dropdown
465
+ dropdown = getElement('.k-select-menu');
466
+ expect(dropdown.innerHTML).to.contain('custom1');
467
+ // press enter to create and select
468
+ dispatchEvent(document, 'keydown', {
469
+ keyCode: 13
470
+ });
471
+ _context11.next = 16;
472
+ return wait();
473
+ case 16:
474
+ // check the option is selected, and the input is cleared
475
+ expect(instance.get('days')).to.eql(['custom1']);
476
+ expect(input.value).to.eql('');
477
+ // input the same option "custom1" again
478
+ input.value = 'custom1';
479
+ dispatchEvent(input, 'input');
480
+ _context11.next = 22;
481
+ return wait();
482
+ case 22:
483
+ // press enter again
484
+ dispatchEvent(document, 'keydown', {
485
+ keyCode: 13
486
+ });
487
+ _context11.next = 25;
488
+ return wait();
489
+ case 25:
490
+ // check the option is still selected (not be unselected), and the input is cleared
491
+ expect(instance.get('days')).to.eql(['custom1']); // should be selected
492
+ expect(input.value).to.eql(''); // should be cleared
493
+ // input another custom option "custom2"
494
+ input.value = 'custom2';
495
+ dispatchEvent(input, 'input');
496
+ _context11.next = 31;
497
+ return wait();
498
+ case 31:
499
+ dispatchEvent(document, 'keydown', {
500
+ keyCode: 13
501
+ });
502
+ _context11.next = 34;
503
+ return wait();
504
+ case 34:
505
+ // check two options are selected
506
+ expect(instance.get('days')).to.eql(['custom1', 'custom2']);
507
+ expect(input.value).to.eql('');
508
+ // test the normal behavior of original options
509
+ input.click();
510
+ _context11.next = 39;
511
+ return wait();
512
+ case 39:
513
+ mondayOption = dropdown.querySelector('[data-value="Monday"]');
514
+ if (!mondayOption) {
515
+ _context11.next = 49;
516
+ break;
517
+ }
518
+ mondayOption.click();
519
+ _context11.next = 44;
520
+ return wait();
521
+ case 44:
522
+ expect(instance.get('days')).to.include('Monday');
523
+ // click again should be unselected (original options are not affected by keepKeywords)
524
+ mondayOption.click();
525
+ _context11.next = 48;
526
+ return wait();
527
+ case 48:
528
+ expect(instance.get('days')).to.not.include('Monday');
529
+ case 49:
530
+ case "end":
531
+ return _context11.stop();
532
+ }
533
+ }, _callee9);
534
+ })));
535
+ it('Tooltip with Select', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
536
+ var Demo, _mount11, instance, element;
537
+ return _regeneratorRuntime.wrap(function _callee10$(_context13) {
538
+ while (1) switch (_context13.prev = _context13.next) {
539
+ case 0:
540
+ Demo = /*#__PURE__*/function (_Component3) {
541
+ _inheritsLoose(Demo, _Component3);
542
+ function Demo() {
543
+ var _context12;
544
+ var _this3;
545
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
546
+ args[_key3] = arguments[_key3];
547
+ }
548
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
549
+ _this3.Tooltip = Tooltip;
550
+ _this3.Select = Select;
551
+ _this3.Option = Option;
552
+ return _this3;
553
+ }
391
554
  return Demo;
392
555
  }(Component);
393
556
  Demo.template = "\n const {Tooltip, Select, Option} = this;\n <Tooltip content=\"hello\">\n <Select><Option value=\"1\">option 1</Option></Select>\n </Tooltip>\n ";
394
- _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
557
+ _mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
395
558
  element.click();
396
- _context11.next = 6;
559
+ _context13.next = 6;
397
560
  return wait();
398
561
  case 6:
399
562
  expect(getElement('.k-select-menu')).to.be.exist;
400
563
  expect(getElement('.k-tooltip-content')).to.be.exist;
401
564
  case 8:
402
565
  case "end":
403
- return _context11.stop();
566
+ return _context13.stop();
404
567
  }
405
- }, _callee9);
568
+ }, _callee10);
406
569
  })));
407
- it('Searchable with multiple', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
408
- var _mount11, instance, element, _element$querySelecto6, select, dropdown, _dropdown$querySelect2, selectAll, toggleSelect, unselectAll, _dropdown$querySelect3, cancel, confirm, input;
409
- return _regeneratorRuntime.wrap(function _callee10$(_context12) {
410
- while (1) switch (_context12.prev = _context12.next) {
570
+ it('Searchable with multiple', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
571
+ var _mount12, instance, element, _element$querySelecto7, select, dropdown, _dropdown$querySelect2, selectAll, toggleSelect, unselectAll, _dropdown$querySelect3, cancel, confirm, input;
572
+ return _regeneratorRuntime.wrap(function _callee11$(_context14) {
573
+ while (1) switch (_context14.prev = _context14.next) {
411
574
  case 0:
412
- _mount11 = mount(SearchableDemo), instance = _mount11[0], element = _mount11[1];
413
- _element$querySelecto6 = element.querySelectorAll('.k-select'), select = _element$querySelecto6[1];
575
+ _mount12 = mount(SearchableDemo), instance = _mount12[0], element = _mount12[1];
576
+ _element$querySelecto7 = element.querySelectorAll('.k-select'), select = _element$querySelecto7[1];
414
577
  select.click();
415
- _context12.next = 5;
578
+ _context14.next = 5;
416
579
  return wait();
417
580
  case 5:
418
581
  dropdown = getElement('.k-select-menu');
@@ -420,112 +583,196 @@ describe('Select', function () {
420
583
  _dropdown$querySelect3 = dropdown.querySelectorAll('.k-select-footer .k-btn'), cancel = _dropdown$querySelect3[0], confirm = _dropdown$querySelect3[1]; // select all
421
584
  selectAll.click();
422
585
  confirm.click();
423
- _context12.next = 12;
586
+ _context14.next = 12;
424
587
  return wait();
425
588
  case 12:
426
589
  expect(instance.get('days')).have.length(6);
427
590
  // unselect all
428
591
  select.click();
429
- _context12.next = 16;
592
+ _context14.next = 16;
430
593
  return wait();
431
594
  case 16:
432
595
  unselectAll.click();
433
596
  confirm.click();
434
- _context12.next = 20;
597
+ _context14.next = 20;
435
598
  return wait();
436
599
  case 20:
437
600
  expect(instance.get('days')).have.length(0);
438
601
  // toggle select
439
602
  select.click();
440
- _context12.next = 24;
603
+ _context14.next = 24;
441
604
  return wait();
442
605
  case 24:
443
606
  instance.set('days', ['Monday', 'Tuesday']);
444
- _context12.next = 27;
607
+ _context14.next = 27;
445
608
  return wait();
446
609
  case 27:
447
610
  input = dropdown.querySelector('.k-input-inner');
448
611
  input.value = 's';
449
612
  dispatchEvent(input, 'input');
450
- _context12.next = 32;
613
+ _context14.next = 32;
451
614
  return wait();
452
615
  case 32:
453
616
  toggleSelect.click();
454
617
  confirm.click();
455
- _context12.next = 36;
618
+ _context14.next = 36;
456
619
  return wait();
457
620
  case 36:
458
621
  expect(instance.get('days')).have.length(5);
459
622
  expect(instance.get('days')).include('Monday');
460
623
  case 38:
461
624
  case "end":
462
- return _context12.stop();
625
+ return _context14.stop();
463
626
  }
464
- }, _callee10);
627
+ }, _callee11);
465
628
  })));
466
- it('disabled option does not allow clearable and close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
467
- var _mount12, instance, element, _element$querySelecto7, clear1, _element$querySelecto8, tag1, _element$querySelecto9, clear2, _element$querySelecto10, clear3;
468
- return _regeneratorRuntime.wrap(function _callee11$(_context13) {
469
- while (1) switch (_context13.prev = _context13.next) {
629
+ it('Searchable with multiple should show correct initial checkbox state', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
630
+ var Demo, _mount13, instance, element, dropdown, checkboxes, options, tuesdayCheckbox, tuesdayOption, _dropdown$querySelect4, cancel, dropdown2, checkboxes2, options2, tuesdayCheckbox2, tuesdayOption2;
631
+ return _regeneratorRuntime.wrap(function _callee12$(_context16) {
632
+ while (1) switch (_context16.prev = _context16.next) {
633
+ case 0:
634
+ Demo = /*#__PURE__*/function (_Component4) {
635
+ _inheritsLoose(Demo, _Component4);
636
+ function Demo() {
637
+ var _context15;
638
+ var _this4;
639
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
640
+ args[_key4] = arguments[_key4];
641
+ }
642
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context15 = [this]).call(_context15, args)) || this;
643
+ _this4.Tooltip = Tooltip;
644
+ _this4.Select = Select;
645
+ _this4.Option = Option;
646
+ return _this4;
647
+ }
648
+ Demo.defaults = function defaults() {
649
+ return {
650
+ days: ['Tuesday']
651
+ };
652
+ };
653
+ return Demo;
654
+ }(Component);
655
+ Demo.template = "\n const {Select, Option} = this;\n <Select v-model=\"days\" searchable multiple>\n <Option value=\"Monday\" disabled>\u661F\u671F\u4E00</Option>\n <Option value=\"Tuesday\">\u661F\u671F\u4E8C</Option>\n <Option value=\"Wednesday\">\u661F\u671F\u4E09</Option>\n <Option value=\"Thursday\">\u661F\u671F\u56DB</Option>\n <Option value=\"Friday\">\u661F\u671F\u4E94</Option>\n <Option value=\"Saturday\">\u661F\u671F\u516D</Option>\n <Option value=\"Sunday\">\u661F\u671F\u5929</Option>\n <b:values args=\"[value]\">\n <div class=\"k-value\">\n \u5DF2\u9009\u62E9{value.length}\u9879 / \u51717\u9879\n </div>\n </b:values>\n </Select>\n ";
656
+ _mount13 = mount(Demo), instance = _mount13[0], element = _mount13[1];
657
+ expect(instance.get('days')).to.eql(['Tuesday']);
658
+ // first open dropdown, check initial state
659
+ element.click();
660
+ _context16.next = 7;
661
+ return wait();
662
+ case 7:
663
+ dropdown = getElement('.k-select-menu');
664
+ checkboxes = dropdown.querySelectorAll('.k-checkbox input[type="checkbox"]');
665
+ options = dropdown.querySelectorAll('.k-select-option'); // find the checkbox of Tuesday option
666
+ tuesdayCheckbox = null;
667
+ tuesdayOption = null;
668
+ options.forEach(function (option, index) {
669
+ var _option$textContent;
670
+ if ((_option$textContent = option.textContent) != null && _includesInstanceProperty(_option$textContent).call(_option$textContent, '星期二')) {
671
+ tuesdayCheckbox = checkboxes[index];
672
+ tuesdayOption = option;
673
+ }
674
+ });
675
+ // check the checkbox of Tuesday should be checked
676
+ expect(tuesdayCheckbox).to.exist;
677
+ expect(tuesdayCheckbox.checked).to.be.true;
678
+ // check the Tuesday option should have active style
679
+ expect(tuesdayOption).to.exist;
680
+ expect(tuesdayOption.className).to.include('k-active');
681
+ // close dropdown
682
+ _dropdown$querySelect4 = dropdown.querySelectorAll('.k-select-footer .k-btn'), cancel = _dropdown$querySelect4[0];
683
+ cancel.click();
684
+ _context16.next = 21;
685
+ return wait();
686
+ case 21:
687
+ // reopen dropdown, check the state is still correct
688
+ element.click();
689
+ _context16.next = 24;
690
+ return wait();
691
+ case 24:
692
+ dropdown2 = getElement('.k-select-menu');
693
+ checkboxes2 = dropdown2.querySelectorAll('.k-checkbox input[type="checkbox"]');
694
+ options2 = dropdown2.querySelectorAll('.k-select-option');
695
+ tuesdayCheckbox2 = null;
696
+ tuesdayOption2 = null;
697
+ options2.forEach(function (option, index) {
698
+ var _option$textContent2;
699
+ if ((_option$textContent2 = option.textContent) != null && _includesInstanceProperty(_option$textContent2).call(_option$textContent2, '星期二')) {
700
+ tuesdayCheckbox2 = checkboxes2[index];
701
+ tuesdayOption2 = option;
702
+ }
703
+ });
704
+ // check the state is still correct when reopen
705
+ expect(tuesdayCheckbox2.checked).to.be.true;
706
+ expect(tuesdayOption2.className).to.include('k-active');
707
+ case 32:
708
+ case "end":
709
+ return _context16.stop();
710
+ }
711
+ }, _callee12);
712
+ })));
713
+ it('disabled option does not allow clearable and close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
714
+ var _mount14, instance, element, _element$querySelecto8, clear1, _element$querySelecto9, tag1, _element$querySelecto10, clear2, _element$querySelecto11, clear3;
715
+ return _regeneratorRuntime.wrap(function _callee13$(_context17) {
716
+ while (1) switch (_context17.prev = _context17.next) {
470
717
  case 0:
471
- _mount12 = mount(ImmutableDemo), instance = _mount12[0], element = _mount12[1];
718
+ _mount14 = mount(ImmutableDemo), instance = _mount14[0], element = _mount14[1];
472
719
  instance.set('days', ['Tuesday', 'Friday']);
473
- _context13.next = 4;
720
+ _context17.next = 4;
474
721
  return wait();
475
722
  case 4:
476
723
  expect(element.outerHTML).to.matchSnapshot();
477
- _element$querySelecto7 = element.querySelectorAll('.k-select-clear'), clear1 = _element$querySelecto7[0];
724
+ _element$querySelecto8 = element.querySelectorAll('.k-select-clear'), clear1 = _element$querySelecto8[0];
478
725
  clear1.click();
479
- _context13.next = 9;
726
+ _context17.next = 9;
480
727
  return wait();
481
728
  case 9:
482
- _element$querySelecto8 = element.querySelectorAll('.k-tag'), tag1 = _element$querySelecto8[0];
729
+ _element$querySelecto9 = element.querySelectorAll('.k-tag'), tag1 = _element$querySelecto9[0];
483
730
  expect(tag1.className).not.contain("k-closable");
484
731
  expect(instance.get('days')).to.eql(['Tuesday', 'Friday']);
485
732
  instance.set('days', ['Monday', 'Tuesday']);
486
- _context13.next = 15;
733
+ _context17.next = 15;
487
734
  return wait();
488
735
  case 15:
489
- _element$querySelecto9 = element.querySelectorAll('.k-select-clear'), clear2 = _element$querySelecto9[0];
736
+ _element$querySelecto10 = element.querySelectorAll('.k-select-clear'), clear2 = _element$querySelecto10[0];
490
737
  clear2.click();
491
- _context13.next = 19;
738
+ _context17.next = 19;
492
739
  return wait();
493
740
  case 19:
494
741
  expect(instance.get('days')).to.eql(['Tuesday']);
495
742
  instance.set('days', ['Monday', 'Wednesday']);
496
- _context13.next = 23;
743
+ _context17.next = 23;
497
744
  return wait();
498
745
  case 23:
499
- _element$querySelecto10 = element.querySelectorAll('.k-select-clear'), clear3 = _element$querySelecto10[0];
746
+ _element$querySelecto11 = element.querySelectorAll('.k-select-clear'), clear3 = _element$querySelecto11[0];
500
747
  clear3.click();
501
- _context13.next = 27;
748
+ _context17.next = 27;
502
749
  return wait();
503
750
  case 27:
504
751
  expect(instance.get('days')).to.eql([]);
505
752
  // expect(clear).to.be.null;
506
753
  case 28:
507
754
  case "end":
508
- return _context13.stop();
755
+ return _context17.stop();
509
756
  }
510
- }, _callee11);
757
+ }, _callee13);
511
758
  })));
512
- it('should handle async data correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
513
- var Demo, _mount13, instance, element, wrapper, phantom;
514
- return _regeneratorRuntime.wrap(function _callee12$(_context15) {
515
- while (1) switch (_context15.prev = _context15.next) {
759
+ it('should handle async data correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
760
+ var Demo, _mount15, instance, element, wrapper, phantom;
761
+ return _regeneratorRuntime.wrap(function _callee14$(_context19) {
762
+ while (1) switch (_context19.prev = _context19.next) {
516
763
  case 0:
517
- Demo = /*#__PURE__*/function (_Component3) {
518
- _inheritsLoose(Demo, _Component3);
764
+ Demo = /*#__PURE__*/function (_Component5) {
765
+ _inheritsLoose(Demo, _Component5);
519
766
  function Demo() {
520
- var _context14;
521
- var _this3;
522
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
523
- args[_key3] = arguments[_key3];
767
+ var _context18;
768
+ var _this5;
769
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
770
+ args[_key5] = arguments[_key5];
524
771
  }
525
- _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context14 = [this]).call(_context14, args)) || this;
526
- _this3.Select = Select;
527
- _this3.Option = Option;
528
- return _this3;
772
+ _this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context18 = [this]).call(_context18, args)) || this;
773
+ _this5.Select = Select;
774
+ _this5.Option = Option;
775
+ return _this5;
529
776
  }
530
777
  Demo.defaults = function defaults() {
531
778
  return {
@@ -535,8 +782,8 @@ describe('Select', function () {
535
782
  return Demo;
536
783
  }(Component);
537
784
  Demo.template = "\n const {Select, Option} = this;\n <Select v-model=\"day\" virtual>\n <Option v-for={this.get('list')} value={$value}>\n {$value}\n </Option>\n </Select>\n ";
538
- _mount13 = mount(Demo), instance = _mount13[0], element = _mount13[1];
539
- _context15.next = 5;
785
+ _mount15 = mount(Demo), instance = _mount15[0], element = _mount15[1];
786
+ _context19.next = 5;
540
787
  return wait();
541
788
  case 5:
542
789
  // simulate async data loading
@@ -545,11 +792,11 @@ describe('Select', function () {
545
792
  }, function (_, i) {
546
793
  return i;
547
794
  }));
548
- _context15.next = 8;
795
+ _context19.next = 8;
549
796
  return wait(100);
550
797
  case 8:
551
798
  element.click();
552
- _context15.next = 11;
799
+ _context19.next = 11;
553
800
  return wait();
554
801
  case 11:
555
802
  wrapper = getElement('.k-virtual-wrapper');
@@ -558,9 +805,9 @@ describe('Select', function () {
558
805
  expect(phantom.style.height).to.be.equal('3000px');
559
806
  case 15:
560
807
  case "end":
561
- return _context15.stop();
808
+ return _context19.stop();
562
809
  }
563
- }, _callee12);
810
+ }, _callee14);
564
811
  })));
565
812
  // it('should trigger change event correctly', async () => {
566
813
  // const spy = sinon.spy();
@@ -3,6 +3,7 @@ export interface OptionProps {
3
3
  value: any;
4
4
  label?: string;
5
5
  disabled?: boolean;
6
+ isCreated?: boolean;
6
7
  }
7
8
  export declare class Option extends Component<OptionProps> {
8
9
  static template: string | import('intact-vue-next').Template<any>;
@@ -12,7 +12,8 @@ var typeDefs = {
12
12
  required: true
13
13
  },
14
14
  label: String,
15
- disabled: Boolean
15
+ disabled: Boolean,
16
+ isCreated: Boolean
16
17
  };
17
18
  export var Option = /*#__PURE__*/function (_Component) {
18
19
  _inheritsLoose(Option, _Component);
@@ -30,12 +31,19 @@ export var Option = /*#__PURE__*/function (_Component) {
30
31
  var _proto = Option.prototype;
31
32
  _proto.onSelect = function onSelect() {
32
33
  var select = this.select;
33
- var multiple = select.get('multiple');
34
+ var _select$get = select.get(),
35
+ multiple = _select$get.multiple,
36
+ keepKeywords = _select$get.keepKeywords;
34
37
  var value = this.get('value');
38
+ var isCreated = this.get('isCreated');
35
39
  if (!multiple) {
36
40
  select.set('value', this.get('value'));
37
41
  } else {
38
42
  var values = select.get('value');
43
+ if (!keepKeywords && isCreated && Array.isArray(values) && _includesInstanceProperty(values).call(values, value)) {
44
+ select.resetKeywords();
45
+ return;
46
+ }
39
47
  values = toggleArray(values, value);
40
48
  select.set('value', values);
41
49
  }
@@ -8,6 +8,7 @@ export interface SelectProps<T = string, Multipe extends boolean = boolean> exte
8
8
  labelMap?: Map<any, Children>;
9
9
  card?: boolean;
10
10
  autoDisableArrow?: boolean;
11
+ keepKeywords?: boolean;
11
12
  }
12
13
  export interface SelectEvents extends BaseSelectEvents {
13
14
  }
@@ -18,11 +18,13 @@ var typeDefs = _extends({}, BaseSelect.typeDefs, {
18
18
  creatable: Boolean,
19
19
  labelMap: _Map,
20
20
  card: Boolean,
21
- autoDisableArrow: Boolean
21
+ autoDisableArrow: Boolean,
22
+ keepKeywords: Boolean
22
23
  });
23
24
  var defaults = function defaults() {
24
25
  return _extends({}, BaseSelect.defaults(), {
25
- labelMap: new _Map()
26
+ labelMap: new _Map(),
27
+ keepKeywords: true
26
28
  });
27
29
  };
28
30
  export var Select = /*#__PURE__*/function (_BaseSelect) {