@king-design/vue 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.
- package/__tests__/__snapshots__/Vue Next Demos.md +111 -47
- package/__tests__/components/misc.spec.ts +93 -0
- package/components/cascader/index.spec.js +18 -19
- package/components/datepicker/basepicker.d.ts +6 -27
- package/components/datepicker/basepicker.js +23 -268
- package/components/datepicker/calendar.d.ts +4 -2
- package/components/datepicker/dayjs.d.ts +2 -13
- package/components/datepicker/helpers.d.ts +3 -2
- package/components/datepicker/helpers.js +2 -3
- package/components/datepicker/index.d.ts +21 -29
- package/components/datepicker/index.js +22 -32
- package/components/datepicker/index.spec.js +1333 -578
- package/components/datepicker/index.vdt.js +39 -38
- package/components/datepicker/shortcuts.d.ts +1 -1
- package/components/datepicker/styles.d.ts +7 -2
- package/components/datepicker/styles.js +10 -15
- package/components/datepicker/useConfirm.d.ts +6 -0
- package/components/datepicker/useConfirm.js +65 -0
- package/components/datepicker/useDisabled.d.ts +5 -3
- package/components/datepicker/useDisabled.js +22 -27
- package/components/datepicker/useFormats.d.ts +2 -2
- package/components/datepicker/useFormats.js +6 -2
- package/components/datepicker/useHighlight.d.ts +14 -0
- package/components/datepicker/useHighlight.js +60 -0
- package/components/datepicker/useKeyboards.js +2 -1
- package/components/datepicker/useMergeRange.d.ts +1 -1
- package/components/datepicker/useMergeRange.js +11 -16
- package/components/datepicker/useMonths.js +5 -3
- package/components/datepicker/usePanel.d.ts +1 -10
- package/components/datepicker/usePanel.js +19 -32
- package/components/datepicker/useShowDate.d.ts +1 -1
- package/components/datepicker/useShowDate.js +15 -40
- package/components/datepicker/useStatus.js +33 -16
- package/components/datepicker/useValue.d.ts +11 -6
- package/components/datepicker/useValue.js +49 -69
- package/components/datepicker/useValueBase.d.ts +28 -0
- package/components/datepicker/useValueBase.js +277 -0
- package/components/datepicker/useYears.js +6 -3
- package/components/dropdown/dropdown.d.ts +1 -0
- package/components/dropdown/dropdown.js +7 -4
- package/components/input/index.d.ts +2 -0
- package/components/input/index.js +6 -0
- package/components/input/index.spec.js +45 -0
- package/components/input/index.vdt.js +4 -3
- package/components/input/useAutoWidth.d.ts +2 -0
- package/components/input/useAutoWidth.js +19 -1
- package/components/scrollSelect/useMouseEvents.js +5 -4
- package/components/select/base.d.ts +1 -1
- package/components/select/base.js +3 -2
- package/components/select/base.vdt.js +4 -3
- package/components/select/index.spec.js +158 -84
- package/components/select/option.js +2 -1
- package/components/select/select.js +2 -1
- package/components/select/styles.d.ts +79 -0
- package/components/select/styles.js +1 -0
- package/components/select/useInput.d.ts +1 -1
- package/components/select/useInput.js +4 -4
- package/components/table/index.spec.js +84 -6
- package/components/table/useStickyHeader.js +1 -1
- package/components/timepicker/index.spec.js +298 -128
- package/components/timepicker/panelPicker.d.ts +21 -16
- package/components/timepicker/panelPicker.js +7 -4
- package/components/timepicker/panelPicker.vdt.js +5 -9
- package/components/timepicker/selectPicker.d.ts +4 -3
- package/components/timepicker/styles.js +1 -1
- package/components/timepicker/useConfirm.d.ts +6 -0
- package/components/timepicker/useConfirm.js +19 -0
- package/components/timepicker/useDefaultValue.d.ts +4 -0
- package/components/timepicker/useDefaultValue.js +27 -0
- package/components/timepicker/useDisabled.d.ts +6 -3
- package/components/timepicker/useDisabled.js +13 -4
- package/components/timepicker/useFormats.d.ts +1 -1
- package/components/timepicker/useValue.d.ts +13 -8
- package/components/timepicker/useValue.js +14 -15
- package/components/tour/index.spec.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- package/components/datepicker/usePosition.d.ts +0 -10
- package/components/datepicker/usePosition.js +0 -166
|
@@ -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 =
|
|
328
|
+
_context9.next = 6;
|
|
328
329
|
return wait();
|
|
329
|
-
case
|
|
330
|
+
case 6:
|
|
330
331
|
input.value = 'xxx';
|
|
331
332
|
dispatchEvent(input, 'input');
|
|
332
|
-
_context9.next =
|
|
333
|
+
_context9.next = 10;
|
|
333
334
|
return wait();
|
|
334
|
-
case
|
|
335
|
+
case 10:
|
|
335
336
|
dropdown = getElement('.k-select-menu');
|
|
336
337
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
337
|
-
//
|
|
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 =
|
|
346
|
+
_context9.next = 18;
|
|
342
347
|
return wait();
|
|
343
|
-
case
|
|
348
|
+
case 18:
|
|
344
349
|
expect(instance.get('day')).to.eql('xxx');
|
|
345
|
-
|
|
350
|
+
expect(input.value).to.eql('xxx');
|
|
351
|
+
// reopen dropdown
|
|
346
352
|
input.click();
|
|
347
|
-
_context9.next =
|
|
353
|
+
_context9.next = 23;
|
|
348
354
|
return wait();
|
|
349
|
-
case
|
|
355
|
+
case 23:
|
|
350
356
|
expect(element.innerHTML).to.matchSnapshot();
|
|
351
357
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
352
|
-
// input
|
|
358
|
+
// input another custom option
|
|
353
359
|
input.value = 'yyy';
|
|
354
360
|
dispatchEvent(input, 'input');
|
|
355
|
-
_context9.next =
|
|
361
|
+
_context9.next = 29;
|
|
356
362
|
return wait();
|
|
357
|
-
case
|
|
363
|
+
case 29:
|
|
358
364
|
expect(element.innerHTML).to.matchSnapshot();
|
|
359
365
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
360
|
-
|
|
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 =
|
|
371
|
+
_context9.next = 37;
|
|
363
372
|
return wait();
|
|
364
|
-
case
|
|
373
|
+
case 37:
|
|
365
374
|
expect(element.innerHTML).to.matchSnapshot();
|
|
366
|
-
expect(instance.get('day')).to.eql('xxx');
|
|
367
|
-
|
|
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'); //
|
|
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
|
-
//
|
|
464
|
+
// check the created option appears in dropdown
|
|
412
465
|
dropdown = getElement('.k-select-menu');
|
|
413
466
|
expect(dropdown.innerHTML).to.contain('custom1');
|
|
414
|
-
//
|
|
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('');
|
|
424
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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$
|
|
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$
|
|
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,
|
|
578
|
-
return _regeneratorRuntime.wrap(function _callee12$(
|
|
579
|
-
while (1) switch (
|
|
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
|
-
|
|
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
|
-
//
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
_context15.next = 6;
|
|
658
|
+
// first open dropdown, check initial state
|
|
659
|
+
element.click();
|
|
660
|
+
_context16.next = 7;
|
|
587
661
|
return wait();
|
|
588
|
-
case
|
|
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'); //
|
|
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
|
-
//
|
|
675
|
+
// check the checkbox of Tuesday should be checked
|
|
602
676
|
expect(tuesdayCheckbox).to.exist;
|
|
603
677
|
expect(tuesdayCheckbox.checked).to.be.true;
|
|
604
|
-
//
|
|
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
|
-
//
|
|
681
|
+
// close dropdown
|
|
608
682
|
_dropdown$querySelect4 = dropdown.querySelectorAll('.k-select-footer .k-btn'), cancel = _dropdown$querySelect4[0];
|
|
609
683
|
cancel.click();
|
|
610
|
-
|
|
684
|
+
_context16.next = 21;
|
|
611
685
|
return wait();
|
|
612
|
-
case
|
|
613
|
-
//
|
|
614
|
-
|
|
615
|
-
|
|
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
|
|
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
|
|
707
|
+
case 32:
|
|
634
708
|
case "end":
|
|
635
|
-
return
|
|
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$(
|
|
642
|
-
while (1) switch (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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$(
|
|
688
|
-
while (1) switch (
|
|
761
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context19) {
|
|
762
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
689
763
|
case 0:
|
|
690
|
-
Demo = /*#__PURE__*/function (
|
|
691
|
-
_inheritsLoose(Demo,
|
|
764
|
+
Demo = /*#__PURE__*/function (_Component5) {
|
|
765
|
+
_inheritsLoose(Demo, _Component5);
|
|
692
766
|
function Demo() {
|
|
693
|
-
var
|
|
694
|
-
var
|
|
695
|
-
for (var
|
|
696
|
-
args[
|
|
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
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
795
|
+
_context19.next = 8;
|
|
722
796
|
return wait(100);
|
|
723
797
|
case 8:
|
|
724
798
|
element.click();
|
|
725
|
-
|
|
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
|
|
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: (
|
|
3
|
+
export declare function useInput(resetKeywords: () => void): {
|
|
4
4
|
onInput: (value: string) => void;
|
|
5
5
|
keywords: State<string>;
|
|
6
6
|
inputRef: import('intact-vue-next').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(
|
|
32
|
+
resetKeywords();
|
|
33
33
|
} else if (component.get('multiple')) {
|
|
34
|
-
resetKeywords(
|
|
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(
|
|
48
|
+
if (!keepKeywords) {
|
|
49
|
+
resetKeywords();
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
});
|