@king-design/intact 3.6.0-beta.0 → 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 (171) hide show
  1. package/components/.DS_Store +0 -0
  2. package/components/cascader/index.spec.ts +7 -6
  3. package/components/datepicker/basepicker.ts +26 -314
  4. package/components/datepicker/calendar.ts +3 -1
  5. package/components/datepicker/calendar.vdt +5 -2
  6. package/components/datepicker/dayjs.ts +2 -16
  7. package/components/datepicker/demos/multiple.md +5 -0
  8. package/components/datepicker/demos/yearMonth.md +2 -8
  9. package/components/datepicker/helpers.ts +5 -7
  10. package/components/datepicker/index.md +1 -2
  11. package/components/datepicker/index.spec.ts +551 -139
  12. package/components/datepicker/index.ts +16 -33
  13. package/components/datepicker/index.vdt +41 -35
  14. package/components/datepicker/shortcuts.ts +1 -1
  15. package/components/datepicker/styles.ts +27 -18
  16. package/components/datepicker/useConfirm.ts +82 -0
  17. package/components/datepicker/useDisabled.ts +29 -31
  18. package/components/datepicker/useFormats.ts +8 -4
  19. package/components/datepicker/useHighlight.ts +81 -0
  20. package/components/datepicker/useKeyboards.ts +2 -1
  21. package/components/datepicker/useMergeRange.ts +12 -12
  22. package/components/datepicker/useMonths.ts +6 -3
  23. package/components/datepicker/usePanel.ts +19 -19
  24. package/components/datepicker/useShowDate.ts +21 -41
  25. package/components/datepicker/useStatus.ts +34 -15
  26. package/components/datepicker/useValue.ts +43 -72
  27. package/components/datepicker/useValueBase.ts +309 -0
  28. package/components/datepicker/useWeeks.ts +1 -1
  29. package/components/datepicker/useYears.ts +7 -3
  30. package/components/descriptions/.DS_Store +0 -0
  31. package/components/dropdown/dropdown.ts +5 -4
  32. package/components/dropdown/index.md +1 -0
  33. package/components/dropdown/item.ts +1 -1
  34. package/components/dropdown/useKeyboard.ts +0 -1
  35. package/components/input/index.spec.ts +42 -0
  36. package/components/input/index.ts +8 -0
  37. package/components/input/index.vdt +3 -4
  38. package/components/input/useAutoWidth.ts +19 -1
  39. package/components/menu/.DS_Store +0 -0
  40. package/components/menu/demos/.DS_Store +0 -0
  41. package/components/scrollSelect/useMouseEvents.ts +5 -4
  42. package/components/select/base.ts +3 -2
  43. package/components/select/base.vdt +2 -1
  44. package/components/select/demos/creatable.md +2 -2
  45. package/components/select/index.md +1 -1
  46. package/components/select/index.spec.ts +107 -34
  47. package/components/select/option.ts +2 -1
  48. package/components/select/select.ts +1 -0
  49. package/components/select/styles.ts +3 -1
  50. package/components/select/useInput.ts +5 -9
  51. package/components/table/.DS_Store +0 -0
  52. package/components/table/index.spec.ts +69 -1
  53. package/components/table/useStickyHeader.ts +1 -1
  54. package/components/timepicker/index.spec.ts +145 -27
  55. package/components/timepicker/panelPicker.ts +10 -4
  56. package/components/timepicker/panelPicker.vdt +3 -5
  57. package/components/timepicker/styles.ts +1 -0
  58. package/components/timepicker/useConfirm.ts +33 -0
  59. package/components/timepicker/useDefaultValue.ts +30 -0
  60. package/components/timepicker/useDisabled.ts +17 -4
  61. package/components/timepicker/useFormats.ts +1 -1
  62. package/components/timepicker/useValue.ts +22 -19
  63. package/components/tour/.DS_Store +0 -0
  64. package/components/tour/index.spec.ts +1 -1
  65. package/components/virtualList/.DS_Store +0 -0
  66. package/components/virtualList/demos/.DS_Store +0 -0
  67. package/es/components/cascader/index.spec.js +18 -19
  68. package/es/components/datepicker/basepicker.d.ts +6 -27
  69. package/es/components/datepicker/basepicker.js +23 -268
  70. package/es/components/datepicker/calendar.d.ts +4 -2
  71. package/es/components/datepicker/dayjs.d.ts +2 -13
  72. package/es/components/datepicker/helpers.d.ts +3 -2
  73. package/es/components/datepicker/helpers.js +2 -3
  74. package/es/components/datepicker/index.d.ts +21 -29
  75. package/es/components/datepicker/index.js +22 -32
  76. package/es/components/datepicker/index.spec.js +1333 -578
  77. package/es/components/datepicker/index.vdt.js +39 -38
  78. package/es/components/datepicker/shortcuts.d.ts +1 -1
  79. package/es/components/datepicker/styles.d.ts +7 -2
  80. package/es/components/datepicker/styles.js +10 -15
  81. package/es/components/datepicker/useConfirm.d.ts +6 -0
  82. package/es/components/datepicker/useConfirm.js +65 -0
  83. package/es/components/datepicker/useDisabled.d.ts +5 -3
  84. package/es/components/datepicker/useDisabled.js +22 -27
  85. package/es/components/datepicker/useFormats.d.ts +2 -2
  86. package/es/components/datepicker/useFormats.js +6 -2
  87. package/es/components/datepicker/useHighlight.d.ts +14 -0
  88. package/es/components/datepicker/useHighlight.js +60 -0
  89. package/es/components/datepicker/useKeyboards.js +2 -1
  90. package/es/components/datepicker/useMergeRange.d.ts +1 -1
  91. package/es/components/datepicker/useMergeRange.js +11 -16
  92. package/es/components/datepicker/useMonths.js +5 -3
  93. package/es/components/datepicker/usePanel.d.ts +1 -10
  94. package/es/components/datepicker/usePanel.js +19 -32
  95. package/es/components/datepicker/useShowDate.d.ts +1 -1
  96. package/es/components/datepicker/useShowDate.js +15 -40
  97. package/es/components/datepicker/useStatus.js +33 -16
  98. package/es/components/datepicker/useValue.d.ts +11 -6
  99. package/es/components/datepicker/useValue.js +49 -69
  100. package/es/components/datepicker/useValueBase.d.ts +28 -0
  101. package/es/components/datepicker/useValueBase.js +277 -0
  102. package/es/components/datepicker/useYears.js +6 -3
  103. package/es/components/dropdown/dropdown.d.ts +1 -0
  104. package/es/components/dropdown/dropdown.js +7 -4
  105. package/es/components/input/index.d.ts +2 -0
  106. package/es/components/input/index.js +6 -0
  107. package/es/components/input/index.spec.js +45 -0
  108. package/es/components/input/index.vdt.js +4 -3
  109. package/es/components/input/useAutoWidth.d.ts +2 -0
  110. package/es/components/input/useAutoWidth.js +19 -1
  111. package/es/components/scrollSelect/useMouseEvents.js +5 -4
  112. package/es/components/select/base.d.ts +1 -1
  113. package/es/components/select/base.js +3 -2
  114. package/es/components/select/base.vdt.js +4 -3
  115. package/es/components/select/index.spec.js +158 -84
  116. package/es/components/select/option.js +2 -1
  117. package/es/components/select/select.js +2 -1
  118. package/es/components/select/styles.d.ts +79 -0
  119. package/es/components/select/styles.js +1 -0
  120. package/es/components/select/useInput.d.ts +1 -1
  121. package/es/components/select/useInput.js +4 -4
  122. package/es/components/table/index.spec.js +84 -6
  123. package/es/components/table/useStickyHeader.js +1 -1
  124. package/es/components/timepicker/index.spec.js +298 -128
  125. package/es/components/timepicker/panelPicker.d.ts +21 -16
  126. package/es/components/timepicker/panelPicker.js +7 -4
  127. package/es/components/timepicker/panelPicker.vdt.js +5 -9
  128. package/es/components/timepicker/selectPicker.d.ts +4 -3
  129. package/es/components/timepicker/styles.js +1 -1
  130. package/es/components/timepicker/useConfirm.d.ts +6 -0
  131. package/es/components/timepicker/useConfirm.js +19 -0
  132. package/es/components/timepicker/useDefaultValue.d.ts +4 -0
  133. package/es/components/timepicker/useDefaultValue.js +27 -0
  134. package/es/components/timepicker/useDisabled.d.ts +6 -3
  135. package/es/components/timepicker/useDisabled.js +13 -4
  136. package/es/components/timepicker/useFormats.d.ts +1 -1
  137. package/es/components/timepicker/useValue.d.ts +13 -8
  138. package/es/components/timepicker/useValue.js +14 -15
  139. package/es/components/tour/index.spec.js +1 -1
  140. package/es/index.d.ts +2 -2
  141. package/es/index.js +2 -2
  142. package/es/site/data/components/datepicker/demos/multiple/index.d.ts +1 -0
  143. package/es/site/data/components/datepicker/demos/multiple/index.js +2 -1
  144. package/es/site/data/components/datepicker/demos/multiple/react.d.ts +1 -0
  145. package/es/site/data/components/datepicker/demos/multiple/react.js +13 -2
  146. package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +0 -2
  147. package/es/site/data/components/datepicker/demos/yearMonth/index.js +1 -3
  148. package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +0 -2
  149. package/es/site/data/components/datepicker/demos/yearMonth/react.js +1 -21
  150. package/es/site/data/components/select/demos/creatable/react.js +2 -2
  151. package/es/site/data/components/select/demos/searchable/index.js +1 -1
  152. package/es/site/data/components/select/demos/searchable/react.js +1 -1
  153. package/es/site/data/components/tour/demos/customText/index.d.ts +19 -6
  154. package/es/site/data/components/tour/demos/customText/index.js +18 -17
  155. package/es/site/data/components/tour/demos/customText/react.d.ts +20 -6
  156. package/es/site/data/components/tour/demos/customText/react.js +31 -27
  157. package/index.ts +2 -2
  158. package/package.json +2 -2
  159. package/styles/.DS_Store +0 -0
  160. package/components/datepicker/demos/nowrap.md +0 -35
  161. package/components/datepicker/usePosition.ts +0 -169
  162. package/es/components/datepicker/usePosition.d.ts +0 -10
  163. package/es/components/datepicker/usePosition.js +0 -166
  164. package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +0 -10
  165. package/es/site/data/components/datepicker/demos/nowrap/index.js +0 -19
  166. package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +0 -10
  167. package/es/site/data/components/datepicker/demos/nowrap/react.js +0 -49
  168. package/es/site/data/components/tour/demos/customButtons/index.d.ts +0 -33
  169. package/es/site/data/components/tour/demos/customButtons/index.js +0 -55
  170. package/es/site/data/components/tour/demos/customButtons/react.d.ts +0 -33
  171. package/es/site/data/components/tour/demos/customButtons/react.js +0 -99
@@ -317,54 +317,108 @@ describe('Select', function () {
317
317
  }, _callee7);
318
318
  })));
319
319
  it('creatable', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
320
- var _mount9, instance, element, input, dropdown;
320
+ var _mount9, instance, element, input, dropdown, createOption, newCreateOption, _element$querySelecto6, multipleInput, multipleDropdown, mondayOption;
321
321
  return _regeneratorRuntime.wrap(function _callee8$(_context9) {
322
322
  while (1) switch (_context9.prev = _context9.next) {
323
323
  case 0:
324
324
  _mount9 = mount(CreatableDemo), instance = _mount9[0], element = _mount9[1];
325
325
  input = element.querySelector('.k-input-inner');
326
+ expect(instance.get('day')).to.be.null;
326
327
  input.click();
327
- _context9.next = 5;
328
+ _context9.next = 6;
328
329
  return wait();
329
- case 5:
330
+ case 6:
330
331
  input.value = 'xxx';
331
332
  dispatchEvent(input, 'input');
332
- _context9.next = 9;
333
+ _context9.next = 10;
333
334
  return wait();
334
- case 9:
335
+ case 10:
335
336
  dropdown = getElement('.k-select-menu');
336
337
  expect(dropdown.innerHTML).to.matchSnapshot();
337
- // 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
338
343
  dispatchEvent(document, 'keydown', {
339
344
  keyCode: 13
340
345
  });
341
- _context9.next = 14;
346
+ _context9.next = 18;
342
347
  return wait();
343
- case 14:
348
+ case 18:
344
349
  expect(instance.get('day')).to.eql('xxx');
345
- // open again
350
+ expect(input.value).to.eql('xxx');
351
+ // reopen dropdown
346
352
  input.click();
347
- _context9.next = 18;
353
+ _context9.next = 23;
348
354
  return wait();
349
- case 18:
355
+ case 23:
350
356
  expect(element.innerHTML).to.matchSnapshot();
351
357
  expect(dropdown.innerHTML).to.matchSnapshot();
352
- // input again
358
+ // input another custom option
353
359
  input.value = 'yyy';
354
360
  dispatchEvent(input, 'input');
355
- _context9.next = 24;
361
+ _context9.next = 29;
356
362
  return wait();
357
- case 24:
363
+ case 29:
358
364
  expect(element.innerHTML).to.matchSnapshot();
359
365
  expect(dropdown.innerHTML).to.matchSnapshot();
360
- // 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
361
370
  dispatchEvent(document, 'click');
362
- _context9.next = 29;
371
+ _context9.next = 37;
363
372
  return wait();
364
- case 29:
373
+ case 37:
365
374
  expect(element.innerHTML).to.matchSnapshot();
366
- expect(instance.get('day')).to.eql('xxx');
367
- 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:
368
422
  case "end":
369
423
  return _context9.stop();
370
424
  }
@@ -375,7 +429,6 @@ describe('Select', function () {
375
429
  return _regeneratorRuntime.wrap(function _callee9$(_context11) {
376
430
  while (1) switch (_context11.prev = _context11.next) {
377
431
  case 0:
378
- // 创建一个测试组件,包含keepKeywords功能
379
432
  KeepKeywordsDemo = /*#__PURE__*/function (_Component2) {
380
433
  _inheritsLoose(KeepKeywordsDemo, _Component2);
381
434
  function KeepKeywordsDemo() {
@@ -396,9 +449,9 @@ describe('Select', function () {
396
449
  };
397
450
  return KeepKeywordsDemo;
398
451
  }(Component);
399
- KeepKeywordsDemo.template = "\n const {Select, Option} = this;\n <div>\n <Select v-model=\"days\" filterable multiple creatable keepKeywords>\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 ";
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 ";
400
453
  _mount10 = mount(KeepKeywordsDemo), instance = _mount10[0], element = _mount10[1];
401
- input = element.querySelector('.k-input-inner'); // 1. 输入自定义选项 "custom1"
454
+ input = element.querySelector('.k-input-inner'); // input custom option "custom1"
402
455
  input.click();
403
456
  _context11.next = 7;
404
457
  return wait();
@@ -408,36 +461,36 @@ describe('Select', function () {
408
461
  _context11.next = 11;
409
462
  return wait();
410
463
  case 11:
411
- // 验证创建的选项出现在dropdown
464
+ // check the created option appears in dropdown
412
465
  dropdown = getElement('.k-select-menu');
413
466
  expect(dropdown.innerHTML).to.contain('custom1');
414
- // 2. 按回车创建并选中
467
+ // press enter to create and select
415
468
  dispatchEvent(document, 'keydown', {
416
469
  keyCode: 13
417
470
  });
418
471
  _context11.next = 16;
419
472
  return wait();
420
473
  case 16:
421
- // 验证选项被选中,且输入框被清空
474
+ // check the option is selected, and the input is cleared
422
475
  expect(instance.get('days')).to.eql(['custom1']);
423
- expect(input.value).to.eql(''); // keepKeywords=true时应该清空输入框
424
- // 3. 再次输入相同的选项 "custom1"
476
+ expect(input.value).to.eql('');
477
+ // input the same option "custom1" again
425
478
  input.value = 'custom1';
426
479
  dispatchEvent(input, 'input');
427
480
  _context11.next = 22;
428
481
  return wait();
429
482
  case 22:
430
- // 4. 再次按回车
483
+ // press enter again
431
484
  dispatchEvent(document, 'keydown', {
432
485
  keyCode: 13
433
486
  });
434
487
  _context11.next = 25;
435
488
  return wait();
436
489
  case 25:
437
- // 验证选项仍然被选中(不会被取消选中),且输入框被清空
438
- expect(instance.get('days')).to.eql(['custom1']); // 应该保持选中状态
439
- expect(input.value).to.eql(''); // 输入框应该被清空
440
- // 5. 输入另一个自定义选项 "custom2"
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"
441
494
  input.value = 'custom2';
442
495
  dispatchEvent(input, 'input');
443
496
  _context11.next = 31;
@@ -449,10 +502,10 @@ describe('Select', function () {
449
502
  _context11.next = 34;
450
503
  return wait();
451
504
  case 34:
452
- // 验证两个选项都被选中
505
+ // check two options are selected
453
506
  expect(instance.get('days')).to.eql(['custom1', 'custom2']);
454
507
  expect(input.value).to.eql('');
455
- // 6. 测试原有选项的正常行为
508
+ // test the normal behavior of original options
456
509
  input.click();
457
510
  _context11.next = 39;
458
511
  return wait();
@@ -467,7 +520,7 @@ describe('Select', function () {
467
520
  return wait();
468
521
  case 44:
469
522
  expect(instance.get('days')).to.include('Monday');
470
- // 再次点击应该能取消选中(原有选项不受keepKeywords影响)
523
+ // click again should be unselected (original options are not affected by keepKeywords)
471
524
  mondayOption.click();
472
525
  _context11.next = 48;
473
526
  return wait();
@@ -515,12 +568,12 @@ describe('Select', function () {
515
568
  }, _callee10);
516
569
  })));
517
570
  it('Searchable with multiple', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
518
- var _mount12, instance, element, _element$querySelecto6, select, dropdown, _dropdown$querySelect2, selectAll, toggleSelect, unselectAll, _dropdown$querySelect3, cancel, confirm, input;
571
+ var _mount12, instance, element, _element$querySelecto7, select, dropdown, _dropdown$querySelect2, selectAll, toggleSelect, unselectAll, _dropdown$querySelect3, cancel, confirm, input;
519
572
  return _regeneratorRuntime.wrap(function _callee11$(_context14) {
520
573
  while (1) switch (_context14.prev = _context14.next) {
521
574
  case 0:
522
575
  _mount12 = mount(SearchableDemo), instance = _mount12[0], element = _mount12[1];
523
- _element$querySelecto6 = element.querySelectorAll('.k-select'), select = _element$querySelecto6[1];
576
+ _element$querySelecto7 = element.querySelectorAll('.k-select'), select = _element$querySelecto7[1];
524
577
  select.click();
525
578
  _context14.next = 5;
526
579
  return wait();
@@ -574,21 +627,42 @@ describe('Select', function () {
574
627
  }, _callee11);
575
628
  })));
576
629
  it('Searchable with multiple should show correct initial checkbox state', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
577
- var _mount13, instance, element, _element$querySelecto7, select, dropdown, checkboxes, options, tuesdayCheckbox, tuesdayOption, _dropdown$querySelect4, cancel, dropdown2, checkboxes2, options2, tuesdayCheckbox2, tuesdayOption2;
578
- return _regeneratorRuntime.wrap(function _callee12$(_context15) {
579
- while (1) switch (_context15.prev = _context15.next) {
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) {
580
633
  case 0:
581
- _mount13 = mount(SearchableDemo), instance = _mount13[0], element = _mount13[1]; // 验证初始值
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];
582
657
  expect(instance.get('days')).to.eql(['Tuesday']);
583
- // 第一次打开dropdown,检查初始状态
584
- _element$querySelecto7 = element.querySelectorAll('.k-select'), select = _element$querySelecto7[1];
585
- select.click();
586
- _context15.next = 6;
658
+ // first open dropdown, check initial state
659
+ element.click();
660
+ _context16.next = 7;
587
661
  return wait();
588
- case 6:
662
+ case 7:
589
663
  dropdown = getElement('.k-select-menu');
590
664
  checkboxes = dropdown.querySelectorAll('.k-checkbox input[type="checkbox"]');
591
- options = dropdown.querySelectorAll('.k-select-option'); // 找到Tuesday选项对应的checkbox
665
+ options = dropdown.querySelectorAll('.k-select-option'); // find the checkbox of Tuesday option
592
666
  tuesdayCheckbox = null;
593
667
  tuesdayOption = null;
594
668
  options.forEach(function (option, index) {
@@ -598,23 +672,23 @@ describe('Select', function () {
598
672
  tuesdayOption = option;
599
673
  }
600
674
  });
601
- // 验证Tuesday的checkbox应该被选中
675
+ // check the checkbox of Tuesday should be checked
602
676
  expect(tuesdayCheckbox).to.exist;
603
677
  expect(tuesdayCheckbox.checked).to.be.true;
604
- // 验证Tuesday选项应该有active样式
678
+ // check the Tuesday option should have active style
605
679
  expect(tuesdayOption).to.exist;
606
680
  expect(tuesdayOption.className).to.include('k-active');
607
- // 关闭dropdown
681
+ // close dropdown
608
682
  _dropdown$querySelect4 = dropdown.querySelectorAll('.k-select-footer .k-btn'), cancel = _dropdown$querySelect4[0];
609
683
  cancel.click();
610
- _context15.next = 20;
684
+ _context16.next = 21;
611
685
  return wait();
612
- case 20:
613
- // 再次打开dropdown,验证状态仍然正确
614
- select.click();
615
- _context15.next = 23;
686
+ case 21:
687
+ // reopen dropdown, check the state is still correct
688
+ element.click();
689
+ _context16.next = 24;
616
690
  return wait();
617
- case 23:
691
+ case 24:
618
692
  dropdown2 = getElement('.k-select-menu');
619
693
  checkboxes2 = dropdown2.querySelectorAll('.k-checkbox input[type="checkbox"]');
620
694
  options2 = dropdown2.querySelectorAll('.k-select-option');
@@ -627,78 +701,78 @@ describe('Select', function () {
627
701
  tuesdayOption2 = option;
628
702
  }
629
703
  });
630
- // 验证第二次打开时状态依然正确
704
+ // check the state is still correct when reopen
631
705
  expect(tuesdayCheckbox2.checked).to.be.true;
632
706
  expect(tuesdayOption2.className).to.include('k-active');
633
- case 31:
707
+ case 32:
634
708
  case "end":
635
- return _context15.stop();
709
+ return _context16.stop();
636
710
  }
637
711
  }, _callee12);
638
712
  })));
639
713
  it('disabled option does not allow clearable and close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
640
714
  var _mount14, instance, element, _element$querySelecto8, clear1, _element$querySelecto9, tag1, _element$querySelecto10, clear2, _element$querySelecto11, clear3;
641
- return _regeneratorRuntime.wrap(function _callee13$(_context16) {
642
- while (1) switch (_context16.prev = _context16.next) {
715
+ return _regeneratorRuntime.wrap(function _callee13$(_context17) {
716
+ while (1) switch (_context17.prev = _context17.next) {
643
717
  case 0:
644
718
  _mount14 = mount(ImmutableDemo), instance = _mount14[0], element = _mount14[1];
645
719
  instance.set('days', ['Tuesday', 'Friday']);
646
- _context16.next = 4;
720
+ _context17.next = 4;
647
721
  return wait();
648
722
  case 4:
649
723
  expect(element.outerHTML).to.matchSnapshot();
650
724
  _element$querySelecto8 = element.querySelectorAll('.k-select-clear'), clear1 = _element$querySelecto8[0];
651
725
  clear1.click();
652
- _context16.next = 9;
726
+ _context17.next = 9;
653
727
  return wait();
654
728
  case 9:
655
729
  _element$querySelecto9 = element.querySelectorAll('.k-tag'), tag1 = _element$querySelecto9[0];
656
730
  expect(tag1.className).not.contain("k-closable");
657
731
  expect(instance.get('days')).to.eql(['Tuesday', 'Friday']);
658
732
  instance.set('days', ['Monday', 'Tuesday']);
659
- _context16.next = 15;
733
+ _context17.next = 15;
660
734
  return wait();
661
735
  case 15:
662
736
  _element$querySelecto10 = element.querySelectorAll('.k-select-clear'), clear2 = _element$querySelecto10[0];
663
737
  clear2.click();
664
- _context16.next = 19;
738
+ _context17.next = 19;
665
739
  return wait();
666
740
  case 19:
667
741
  expect(instance.get('days')).to.eql(['Tuesday']);
668
742
  instance.set('days', ['Monday', 'Wednesday']);
669
- _context16.next = 23;
743
+ _context17.next = 23;
670
744
  return wait();
671
745
  case 23:
672
746
  _element$querySelecto11 = element.querySelectorAll('.k-select-clear'), clear3 = _element$querySelecto11[0];
673
747
  clear3.click();
674
- _context16.next = 27;
748
+ _context17.next = 27;
675
749
  return wait();
676
750
  case 27:
677
751
  expect(instance.get('days')).to.eql([]);
678
752
  // expect(clear).to.be.null;
679
753
  case 28:
680
754
  case "end":
681
- return _context16.stop();
755
+ return _context17.stop();
682
756
  }
683
757
  }, _callee13);
684
758
  })));
685
759
  it('should handle async data correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
686
760
  var Demo, _mount15, instance, element, wrapper, phantom;
687
- return _regeneratorRuntime.wrap(function _callee14$(_context18) {
688
- while (1) switch (_context18.prev = _context18.next) {
761
+ return _regeneratorRuntime.wrap(function _callee14$(_context19) {
762
+ while (1) switch (_context19.prev = _context19.next) {
689
763
  case 0:
690
- Demo = /*#__PURE__*/function (_Component4) {
691
- _inheritsLoose(Demo, _Component4);
764
+ Demo = /*#__PURE__*/function (_Component5) {
765
+ _inheritsLoose(Demo, _Component5);
692
766
  function Demo() {
693
- var _context17;
694
- var _this4;
695
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
696
- args[_key4] = arguments[_key4];
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];
697
771
  }
698
- _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context17 = [this]).call(_context17, args)) || this;
699
- _this4.Select = Select;
700
- _this4.Option = Option;
701
- return _this4;
772
+ _this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context18 = [this]).call(_context18, args)) || this;
773
+ _this5.Select = Select;
774
+ _this5.Option = Option;
775
+ return _this5;
702
776
  }
703
777
  Demo.defaults = function defaults() {
704
778
  return {
@@ -709,7 +783,7 @@ describe('Select', function () {
709
783
  }(Component);
710
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 ";
711
785
  _mount15 = mount(Demo), instance = _mount15[0], element = _mount15[1];
712
- _context18.next = 5;
786
+ _context19.next = 5;
713
787
  return wait();
714
788
  case 5:
715
789
  // simulate async data loading
@@ -718,11 +792,11 @@ describe('Select', function () {
718
792
  }, function (_, i) {
719
793
  return i;
720
794
  }));
721
- _context18.next = 8;
795
+ _context19.next = 8;
722
796
  return wait(100);
723
797
  case 8:
724
798
  element.click();
725
- _context18.next = 11;
799
+ _context19.next = 11;
726
800
  return wait();
727
801
  case 11:
728
802
  wrapper = getElement('.k-virtual-wrapper');
@@ -731,7 +805,7 @@ describe('Select', function () {
731
805
  expect(phantom.style.height).to.be.equal('3000px');
732
806
  case 15:
733
807
  case "end":
734
- return _context18.stop();
808
+ return _context19.stop();
735
809
  }
736
810
  }, _callee14);
737
811
  })));
@@ -40,7 +40,8 @@ export var Option = /*#__PURE__*/function (_Component) {
40
40
  select.set('value', this.get('value'));
41
41
  } else {
42
42
  var values = select.get('value');
43
- if (keepKeywords && isCreated && Array.isArray(values) && _includesInstanceProperty(values).call(values, value)) {
43
+ if (!keepKeywords && isCreated && Array.isArray(values) && _includesInstanceProperty(values).call(values, value)) {
44
+ select.resetKeywords();
44
45
  return;
45
46
  }
46
47
  values = toggleArray(values, value);
@@ -23,7 +23,8 @@ var typeDefs = _extends({}, BaseSelect.typeDefs, {
23
23
  });
24
24
  var defaults = function defaults() {
25
25
  return _extends({}, BaseSelect.defaults(), {
26
- labelMap: new _Map()
26
+ labelMap: new _Map(),
27
+ keepKeywords: true
27
28
  });
28
29
  };
29
30
  export var Select = /*#__PURE__*/function (_BaseSelect) {
@@ -1,4 +1,83 @@
1
+ import { Sizes } from '../../styles/utils';
1
2
  import '../../styles/global';
3
+ type SizeStyles = {
4
+ padding: string;
5
+ height: string;
6
+ fontSize: string;
7
+ };
8
+ declare const defaults: {
9
+ readonly transition: string;
10
+ width: string;
11
+ readonly height: string;
12
+ bgColor: string;
13
+ readonly fontSize: string;
14
+ readonly border: string;
15
+ readonly focusBorder: string;
16
+ readonly hoverBorder: string;
17
+ readonly activeColor: string;
18
+ readonly borderRadius: string;
19
+ suffixGap: string;
20
+ clearGap: string;
21
+ readonly placeholderColor: string;
22
+ disabled: {
23
+ readonly color: string;
24
+ readonly bgColor: string;
25
+ readonly borderColor: string;
26
+ };
27
+ group: {
28
+ readonly labelColor: string;
29
+ labelPadding: string;
30
+ };
31
+ card: {
32
+ height: string;
33
+ readonly itemHoverColor: string;
34
+ itemHoverBgColor: string;
35
+ };
36
+ multiple: {
37
+ checkmark: {
38
+ fontSize: string;
39
+ };
40
+ };
41
+ tag: {
42
+ margin: string;
43
+ padding: string;
44
+ readonly borderRadius: string;
45
+ readonly bgColor: string;
46
+ disabledBgColor: string;
47
+ delete: {
48
+ gap: string;
49
+ fontSize: string;
50
+ readonly color: string;
51
+ };
52
+ };
53
+ menuMaxHeight: string;
54
+ empty: {
55
+ padding: string;
56
+ readonly color: string;
57
+ };
58
+ searchable: {
59
+ padding: string;
60
+ headerGap: string;
61
+ readonly border: string;
62
+ header: {
63
+ padding: string;
64
+ gap: string;
65
+ btnPadding: string;
66
+ btnGap: string;
67
+ };
68
+ optionPadding: string;
69
+ footer: {
70
+ padding: string;
71
+ gap: string;
72
+ btnGap: string;
73
+ };
74
+ };
75
+ flat: {
76
+ readonly color: string;
77
+ };
78
+ } & Record<Sizes, SizeStyles>;
79
+ declare let select: typeof defaults;
80
+ export { select };
2
81
  export declare const makeStyles: {
3
82
  (k: string): string;
4
83
  clearCache(): {};
@@ -146,6 +146,7 @@ setDefault(function () {
146
146
  makeMenuStyles == null || makeMenuStyles.clearCache();
147
147
  makeGroupStyles == null || makeGroupStyles.clearCache();
148
148
  });
149
+ export { select };
149
150
  export var makeStyles = cache(function makeStyles(k) {
150
151
  return /*#__PURE__*/css("display:inline-flex;align-items:center;vertical-align:middle;position:relative;width:", select.width, ";cursor:pointer;outline:none;border:", select.border, ";background:", select.bgColor, ";transition:border ", select.transition, ",background ", select.transition, ",box-shadow ", select.transition, ";border-radius:", select.borderRadius, ";.", k, "-select-main{flex:1;min-width:0;}.", k, "-select-prefix,.", k, "-select-suffix{display:flex;align-items:center;position:relative;}.", k, "-select-suffix{margin-left:", select.suffixGap, ";}.", k, "-select-placeholder{color:", select.placeholderColor, ";user-select:none;}.", k, "-input .", k, "-input-inner{background:transparent;}&.", k, "-fluid{width:100%;}.", k, "-select-clear{opacity:0;transition:opacity ", select.transition, ",color ", select.transition, "!important;pointer-events:none;position:absolute;z-index:1;top:50%;left:50%;transform:translate(-50%, -50%);}&:hover{border:", select.hoverBorder, ";.", k, "-select-clear.", k, "-show{opacity:1;pointer-events:all;+.", k, "-select-suffix-icon{opacity:0;}}}.", k, "-select-suffix-icon{display:inline-flex;align-items:center;transition:opacity ", select.transition, ";}.", k, "-select-arrow{display:inline-block;transition:transform ", select.transition, ";}&.", k, "-dropdown-open{border:", select.focusBorder, ";.", k, "-select-arrow{transform:rotateX(180deg);}}&:focus{outline:none;border:", select.focusBorder, ";}.", k, "-tags{padding:3px 0;}.", k, "-tag{word-break:break-word;height:auto;max-width:calc(100% - ", getRight(select.tag.margin), " - 1px);}", _mapInstanceProperty(sizes).call(sizes, function (size) {
151
152
  var styles = select[size];
@@ -1,6 +1,6 @@
1
1
  import { State } from '../../hooks/useState';
2
2
  import type { Input } from '../input';
3
- export declare function useInput(resetKeywords: (keywords: State<string>) => void): {
3
+ export declare function useInput(resetKeywords: () => void): {
4
4
  onInput: (value: string) => void;
5
5
  keywords: State<string>;
6
6
  inputRef: import("intact").RefObject<Input<string | number>>;
@@ -29,9 +29,9 @@ export function useInput(resetKeywords) {
29
29
  component.on('$changed:show', function (show) {
30
30
  if (show) {
31
31
  focusInput();
32
- resetKeywords(keywords);
32
+ resetKeywords();
33
33
  } else if (component.get('multiple')) {
34
- resetKeywords(keywords);
34
+ resetKeywords();
35
35
  }
36
36
  });
37
37
  component.on('$changed:value', function () {
@@ -45,8 +45,8 @@ export function useInput(resetKeywords) {
45
45
  * don't reset keywords on multiple mode for continue selection
46
46
  * https://github.com/ksc-fe/kpc/issues/983
47
47
  */
48
- if (keepKeywords) {
49
- resetKeywords(keywords);
48
+ if (!keepKeywords) {
49
+ resetKeywords();
50
50
  }
51
51
  }
52
52
  });