@king-design/react 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.
- package/components/cascader/index.spec.js +18 -19
- package/components/datepicker/basepicker.d.ts +6 -25
- package/components/datepicker/basepicker.js +22 -234
- package/components/datepicker/calendar.d.ts +36 -6
- package/components/datepicker/calendar.js +4 -0
- package/components/datepicker/calendar.vdt.js +21 -5
- package/components/datepicker/dayjs.d.ts +2 -2
- package/components/datepicker/dayjs.js +6 -0
- package/components/datepicker/helpers.d.ts +8 -7
- package/components/datepicker/helpers.js +2 -3
- package/components/datepicker/index.d.ts +26 -19
- package/components/datepicker/index.js +21 -13
- package/components/datepicker/index.spec.js +1389 -633
- package/components/datepicker/index.vdt.js +43 -46
- package/components/datepicker/shortcuts.d.ts +1 -1
- package/components/datepicker/styles.d.ts +22 -0
- package/components/datepicker/styles.js +26 -4
- package/components/datepicker/useConfirm.d.ts +6 -0
- package/components/datepicker/useConfirm.js +65 -0
- package/components/datepicker/useDisabled.d.ts +7 -5
- package/components/datepicker/useDisabled.js +22 -27
- package/components/datepicker/useFormats.d.ts +2 -2
- package/components/datepicker/useFormats.js +9 -3
- 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 +5 -0
- package/components/datepicker/useMergeRange.js +45 -0
- 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/useQuarters.d.ts +15 -0
- package/components/datepicker/useQuarters.js +36 -0
- package/components/datepicker/useShowDate.js +10 -2
- package/components/datepicker/useStatus.d.ts +1 -1
- package/components/datepicker/useStatus.js +33 -16
- package/components/datepicker/useValue.d.ts +12 -6
- package/components/datepicker/useValue.js +49 -45
- package/components/datepicker/useValueBase.d.ts +28 -0
- package/components/datepicker/useValueBase.js +277 -0
- package/components/datepicker/useWeeks.d.ts +19 -0
- package/components/datepicker/useWeeks.js +48 -0
- package/components/datepicker/useYears.js +6 -3
- package/components/dialog/useFixBody.js +6 -58
- package/components/dropdown/dropdown.d.ts +1 -0
- package/components/dropdown/dropdown.js +7 -4
- package/components/ellipsis/styles.js +1 -1
- package/components/form/styles.js +1 -1
- 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/index.spec.js +4 -6
- package/components/scrollSelect/useMouseEvents.js +22 -9
- package/components/select/base.d.ts +1 -1
- package/components/select/base.js +3 -2
- package/components/select/base.vdt.js +5 -2
- package/components/select/index.spec.js +329 -82
- package/components/select/option.d.ts +1 -0
- package/components/select/option.js +10 -2
- package/components/select/select.d.ts +1 -0
- package/components/select/select.js +4 -2
- package/components/select/styles.d.ts +79 -0
- package/components/select/styles.js +1 -0
- package/components/select/useFilterable.js +2 -1
- package/components/select/useInput.d.ts +1 -1
- package/components/select/useInput.js +7 -4
- package/components/select/useSearchable.js +1 -0
- 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 +23 -17
- package/components/timepicker/panelPicker.js +7 -4
- package/components/timepicker/panelPicker.vdt.js +8 -4
- package/components/timepicker/selectPicker.d.ts +5 -4
- 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 +7 -4
- package/components/timepicker/useDisabled.js +13 -4
- package/components/timepicker/useFormats.d.ts +1 -1
- package/components/timepicker/useValue.d.ts +14 -8
- package/components/timepicker/useValue.js +14 -15
- package/components/tour/index.d.ts +2 -0
- package/components/tour/index.js +2 -0
- package/components/tour/index.spec.d.ts +1 -0
- package/components/tour/index.spec.js +356 -0
- package/components/tour/step.d.ts +23 -0
- package/components/tour/step.js +46 -0
- package/components/tour/step.vdt.js +74 -0
- package/components/tour/styles.d.ts +7 -0
- package/components/tour/styles.js +84 -0
- package/components/tour/tour.d.ts +73 -0
- package/components/tour/tour.js +70 -0
- package/components/tour/tour.vdt.js +66 -0
- package/components/tour/useArrow.d.ts +4 -0
- package/components/tour/useArrow.js +40 -0
- package/components/tour/useFixBody.d.ts +4 -0
- package/components/tour/useFixBody.js +17 -0
- package/components/tour/useHighlight.d.ts +4 -0
- package/components/tour/useHighlight.js +31 -0
- package/components/tour/useMaskClosable.d.ts +1 -0
- package/components/tour/useMaskClosable.js +25 -0
- package/components/tour/useNavigation.d.ts +5 -0
- package/components/tour/useNavigation.js +103 -0
- package/components/tour/usePosition.d.ts +6 -0
- package/components/tour/usePosition.js +93 -0
- package/components/tour/useSteps.d.ts +6 -0
- package/components/tour/useSteps.js +68 -0
- package/hooks/useFixBody.d.ts +11 -0
- package/hooks/useFixBody.js +72 -0
- package/index.d.ts +3 -2
- package/index.js +3 -2
- 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 =
|
|
328
|
+
_context9.next = 6;
|
|
327
329
|
return wait();
|
|
328
|
-
case
|
|
330
|
+
case 6:
|
|
329
331
|
input.value = 'xxx';
|
|
330
332
|
dispatchEvent(input, 'input');
|
|
331
|
-
_context9.next =
|
|
333
|
+
_context9.next = 10;
|
|
332
334
|
return wait();
|
|
333
|
-
case
|
|
335
|
+
case 10:
|
|
334
336
|
dropdown = getElement('.k-select-menu');
|
|
335
337
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
336
|
-
//
|
|
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 =
|
|
346
|
+
_context9.next = 18;
|
|
341
347
|
return wait();
|
|
342
|
-
case
|
|
348
|
+
case 18:
|
|
343
349
|
expect(instance.get('day')).to.eql('xxx');
|
|
344
|
-
|
|
350
|
+
expect(input.value).to.eql('xxx');
|
|
351
|
+
// reopen dropdown
|
|
345
352
|
input.click();
|
|
346
|
-
_context9.next =
|
|
353
|
+
_context9.next = 23;
|
|
347
354
|
return wait();
|
|
348
|
-
case
|
|
355
|
+
case 23:
|
|
349
356
|
expect(element.innerHTML).to.matchSnapshot();
|
|
350
357
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
351
|
-
// input
|
|
358
|
+
// input another custom option
|
|
352
359
|
input.value = 'yyy';
|
|
353
360
|
dispatchEvent(input, 'input');
|
|
354
|
-
_context9.next =
|
|
361
|
+
_context9.next = 29;
|
|
355
362
|
return wait();
|
|
356
|
-
case
|
|
363
|
+
case 29:
|
|
357
364
|
expect(element.innerHTML).to.matchSnapshot();
|
|
358
365
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
359
|
-
|
|
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 =
|
|
371
|
+
_context9.next = 37;
|
|
362
372
|
return wait();
|
|
363
|
-
case
|
|
373
|
+
case 37:
|
|
364
374
|
expect(element.innerHTML).to.matchSnapshot();
|
|
365
|
-
expect(instance.get('day')).to.eql('xxx');
|
|
366
|
-
|
|
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('
|
|
373
|
-
var
|
|
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
|
-
|
|
378
|
-
_inheritsLoose(
|
|
379
|
-
function
|
|
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
|
-
|
|
557
|
+
_mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
|
|
395
558
|
element.click();
|
|
396
|
-
|
|
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
|
|
566
|
+
return _context13.stop();
|
|
404
567
|
}
|
|
405
|
-
},
|
|
568
|
+
}, _callee10);
|
|
406
569
|
})));
|
|
407
|
-
it('Searchable with multiple', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
408
|
-
var
|
|
409
|
-
return _regeneratorRuntime.wrap(function
|
|
410
|
-
while (1) switch (
|
|
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
|
-
|
|
413
|
-
_element$
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
592
|
+
_context14.next = 16;
|
|
430
593
|
return wait();
|
|
431
594
|
case 16:
|
|
432
595
|
unselectAll.click();
|
|
433
596
|
confirm.click();
|
|
434
|
-
|
|
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
|
-
|
|
603
|
+
_context14.next = 24;
|
|
441
604
|
return wait();
|
|
442
605
|
case 24:
|
|
443
606
|
instance.set('days', ['Monday', 'Tuesday']);
|
|
444
|
-
|
|
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
|
-
|
|
613
|
+
_context14.next = 32;
|
|
451
614
|
return wait();
|
|
452
615
|
case 32:
|
|
453
616
|
toggleSelect.click();
|
|
454
617
|
confirm.click();
|
|
455
|
-
|
|
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
|
|
625
|
+
return _context14.stop();
|
|
463
626
|
}
|
|
464
|
-
},
|
|
627
|
+
}, _callee11);
|
|
465
628
|
})));
|
|
466
|
-
it('
|
|
467
|
-
var
|
|
468
|
-
return _regeneratorRuntime.wrap(function
|
|
469
|
-
while (1) switch (
|
|
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
|
-
|
|
718
|
+
_mount14 = mount(ImmutableDemo), instance = _mount14[0], element = _mount14[1];
|
|
472
719
|
instance.set('days', ['Tuesday', 'Friday']);
|
|
473
|
-
|
|
720
|
+
_context17.next = 4;
|
|
474
721
|
return wait();
|
|
475
722
|
case 4:
|
|
476
723
|
expect(element.outerHTML).to.matchSnapshot();
|
|
477
|
-
_element$
|
|
724
|
+
_element$querySelecto8 = element.querySelectorAll('.k-select-clear'), clear1 = _element$querySelecto8[0];
|
|
478
725
|
clear1.click();
|
|
479
|
-
|
|
726
|
+
_context17.next = 9;
|
|
480
727
|
return wait();
|
|
481
728
|
case 9:
|
|
482
|
-
_element$
|
|
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
|
-
|
|
733
|
+
_context17.next = 15;
|
|
487
734
|
return wait();
|
|
488
735
|
case 15:
|
|
489
|
-
_element$
|
|
736
|
+
_element$querySelecto10 = element.querySelectorAll('.k-select-clear'), clear2 = _element$querySelecto10[0];
|
|
490
737
|
clear2.click();
|
|
491
|
-
|
|
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
|
-
|
|
743
|
+
_context17.next = 23;
|
|
497
744
|
return wait();
|
|
498
745
|
case 23:
|
|
499
|
-
_element$
|
|
746
|
+
_element$querySelecto11 = element.querySelectorAll('.k-select-clear'), clear3 = _element$querySelecto11[0];
|
|
500
747
|
clear3.click();
|
|
501
|
-
|
|
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
|
|
755
|
+
return _context17.stop();
|
|
509
756
|
}
|
|
510
|
-
},
|
|
757
|
+
}, _callee13);
|
|
511
758
|
})));
|
|
512
|
-
it('should handle async data correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
513
|
-
var Demo,
|
|
514
|
-
return _regeneratorRuntime.wrap(function
|
|
515
|
-
while (1) switch (
|
|
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 (
|
|
518
|
-
_inheritsLoose(Demo,
|
|
764
|
+
Demo = /*#__PURE__*/function (_Component5) {
|
|
765
|
+
_inheritsLoose(Demo, _Component5);
|
|
519
766
|
function Demo() {
|
|
520
|
-
var
|
|
521
|
-
var
|
|
522
|
-
for (var
|
|
523
|
-
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];
|
|
524
771
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
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;
|
|
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
|
-
|
|
539
|
-
|
|
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
|
-
|
|
795
|
+
_context19.next = 8;
|
|
549
796
|
return wait(100);
|
|
550
797
|
case 8:
|
|
551
798
|
element.click();
|
|
552
|
-
|
|
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
|
|
808
|
+
return _context19.stop();
|
|
562
809
|
}
|
|
563
|
-
},
|
|
810
|
+
}, _callee14);
|
|
564
811
|
})));
|
|
565
812
|
// it('should trigger change event correctly', async () => {
|
|
566
813
|
// const spy = sinon.spy();
|
|
@@ -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
|
|
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
|
}
|
|
@@ -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) {
|