@king-design/vue 3.6.2-beta.1 → 3.7.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__/components/upload.spec.ts +1 -1
- package/components/anchor/constants.d.ts +2 -0
- package/components/anchor/constants.js +2 -0
- package/components/anchor/index.d.ts +41 -0
- package/components/anchor/index.js +141 -0
- package/components/anchor/index.spec.d.ts +1 -0
- package/components/anchor/index.spec.js +230 -0
- package/components/anchor/index.vdt.js +31 -0
- package/components/anchor/link.d.ts +16 -0
- package/components/anchor/link.js +52 -0
- package/components/anchor/link.vdt.js +49 -0
- package/components/anchor/styles.d.ts +5 -0
- package/components/anchor/styles.js +30 -0
- package/components/anchor/useScroll.d.ts +7 -0
- package/components/anchor/useScroll.js +218 -0
- package/components/dialog/base.vdt.js +1 -1
- package/components/drawer/index.d.ts +3 -0
- package/components/drawer/index.js +22 -3
- package/components/drawer/index.spec.js +83 -0
- package/components/drawer/index.vdt.js +23 -3
- package/components/drawer/styles.js +1 -1
- package/components/drawer/useDrawerResizable.d.ts +10 -0
- package/components/drawer/useDrawerResizable.js +162 -0
- package/components/menu/styles.d.ts +1 -0
- package/components/menu/styles.js +4 -1
- package/components/notification/index.d.ts +1 -0
- package/components/notification/index.js +1 -0
- package/components/notification/index.spec.d.ts +1 -0
- package/components/notification/index.spec.js +317 -0
- package/components/notification/notification.d.ts +39 -0
- package/components/notification/notification.js +183 -0
- package/components/notification/notification.vdt.js +56 -0
- package/components/notification/notifications.d.ts +16 -0
- package/components/notification/notifications.js +51 -0
- package/components/notification/notifications.vdt.js +24 -0
- package/components/notification/styles.d.ts +9 -0
- package/components/notification/styles.js +110 -0
- package/components/select/styles.js +1 -1
- package/components/table/styles.js +1 -1
- package/components/tabs/useActiveBar.js +7 -3
- package/components/tag/base.d.ts +2 -0
- package/components/tag/base.js +3 -0
- package/components/tag/index.spec.js +17 -0
- package/components/tag/index.vdt.js +12 -5
- package/components/tag/styles.d.ts +9 -0
- package/components/tag/styles.js +14 -1
- package/components/tag/useColor.d.ts +7 -0
- package/components/tag/useColor.js +71 -0
- package/components/timepicker/index.spec.js +70 -42
- package/components/timepicker/useDefaultValue.js +12 -7
- package/components/timepicker/useStep.js +4 -2
- package/components/transfer/index.d.ts +13 -0
- package/components/transfer/index.js +6 -2
- package/components/transfer/index.spec.js +197 -0
- package/components/transfer/index.vdt.js +28 -5
- package/components/transfer/styles.js +4 -1
- package/components/transfer/useCheck.js +2 -1
- package/components/transfer/usePagination.d.ts +12 -0
- package/components/transfer/usePagination.js +79 -0
- package/dist/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.svg +235 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/fonts/ionicons.woff2 +0 -0
- package/dist/i18n/en-US.js +1411 -0
- package/dist/i18n/en-US.js.map +1 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/i18n/index.js +283 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.min.js +1 -0
- package/dist/index.js +58128 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1 -0
- package/index.d.ts +4 -2
- package/index.js +4 -2
- package/install.js +2 -0
- package/package.json +4 -2
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.svg +38 -0
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/theme.d.ts +8 -0
- package/styles/theme.js +5 -1
- package/yarn-error.log +43 -44
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
4
|
+
import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
|
|
5
|
+
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
3
6
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
4
7
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
5
8
|
import BasicDemo from '~/components/timepicker/demos/basic';
|
|
@@ -41,7 +44,7 @@ describe('Timepicker', function () {
|
|
|
41
44
|
expect(inputInner.value).eql('');
|
|
42
45
|
dropdown = getElement('.k-time-content');
|
|
43
46
|
ok = dropdown.querySelector('.k-btn');
|
|
44
|
-
expect(ok.classList.contains('k-disabled')).eql(
|
|
47
|
+
expect(ok.classList.contains('k-disabled')).eql(false);
|
|
45
48
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
46
49
|
next = dropdown.querySelector('.k-scroll-select-item:nth-child(11)');
|
|
47
50
|
next.click();
|
|
@@ -60,7 +63,7 @@ describe('Timepicker', function () {
|
|
|
60
63
|
_context2.next = 27;
|
|
61
64
|
return wait(500);
|
|
62
65
|
case 27:
|
|
63
|
-
expect(instance.get('time')).to.eql('
|
|
66
|
+
expect(instance.get('time')).to.eql('03:34:56');
|
|
64
67
|
expect(dropdown.style.display).to.eql('none');
|
|
65
68
|
// set time
|
|
66
69
|
instance.set('time', '03:03:03');
|
|
@@ -368,51 +371,76 @@ describe('Timepicker', function () {
|
|
|
368
371
|
case 15:
|
|
369
372
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
370
373
|
dropdown.querySelector('.k-btn').click();
|
|
371
|
-
expect(instance.get('time')).to.eql(['00:30:00', '23:
|
|
374
|
+
expect(instance.get('time')).to.eql(['00:30:00', '23:00:00']);
|
|
372
375
|
case 18:
|
|
373
376
|
case "end":
|
|
374
377
|
return _context9.stop();
|
|
375
378
|
}
|
|
376
379
|
}, _callee9);
|
|
377
380
|
})));
|
|
378
|
-
it('
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
|
|
381
|
+
it('should not have 23:59:59 in step mode without max', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
382
|
+
var _context10;
|
|
383
|
+
var _mount9, instance, element, picker, dropdown, options, texts;
|
|
384
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context12) {
|
|
385
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
382
386
|
case 0:
|
|
383
|
-
_mount9 = mount(
|
|
387
|
+
_mount9 = mount(StepRangeDemo), instance = _mount9[0], element = _mount9[1];
|
|
388
|
+
picker = element.querySelector('.k-select');
|
|
389
|
+
picker.click();
|
|
390
|
+
_context12.next = 5;
|
|
391
|
+
return wait();
|
|
392
|
+
case 5:
|
|
393
|
+
dropdown = getElement('.k-time-content');
|
|
394
|
+
options = dropdown.querySelectorAll('k-scroll-select-item');
|
|
395
|
+
texts = _mapInstanceProperty(_context10 = _Array$from(options)).call(_context10, function (el) {
|
|
396
|
+
var _context11;
|
|
397
|
+
return _trimInstanceProperty(_context11 = el.innerText).call(_context11);
|
|
398
|
+
});
|
|
399
|
+
expect(texts).to.not.include('23:59:59');
|
|
400
|
+
case 9:
|
|
401
|
+
case "end":
|
|
402
|
+
return _context12.stop();
|
|
403
|
+
}
|
|
404
|
+
}, _callee10);
|
|
405
|
+
})));
|
|
406
|
+
it('format', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
407
|
+
var _mount10, instance, element, _element$querySelecto5, input1, input2, input3, content, _content$querySelecto, scroll1, scroll2;
|
|
408
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context13) {
|
|
409
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
410
|
+
case 0:
|
|
411
|
+
_mount10 = mount(FormatDemo), instance = _mount10[0], element = _mount10[1];
|
|
384
412
|
_element$querySelecto5 = element.querySelectorAll('.k-select'), input1 = _element$querySelecto5[0], input2 = _element$querySelecto5[1], input3 = _element$querySelecto5[2];
|
|
385
413
|
input1.click();
|
|
386
|
-
|
|
414
|
+
_context13.next = 5;
|
|
387
415
|
return wait();
|
|
388
416
|
case 5:
|
|
389
417
|
content = getElement('.k-time-content');
|
|
390
418
|
expect(content.innerHTML).to.matchSnapshot();
|
|
391
419
|
// is '02'
|
|
392
420
|
content.querySelector('.k-scroll-select-item:nth-child(12)').click();
|
|
393
|
-
|
|
421
|
+
_context13.next = 10;
|
|
394
422
|
return wait();
|
|
395
423
|
case 10:
|
|
396
424
|
content.querySelector('.k-btn').click();
|
|
397
|
-
|
|
425
|
+
_context13.next = 13;
|
|
398
426
|
return wait();
|
|
399
427
|
case 13:
|
|
400
|
-
expect(instance.get('time1')).to.eql('
|
|
428
|
+
expect(instance.get('time1')).to.eql('03:34 am');
|
|
401
429
|
expect(input1.innerHTML).to.matchSnapshot();
|
|
402
430
|
input2.click();
|
|
403
|
-
|
|
431
|
+
_context13.next = 18;
|
|
404
432
|
return wait();
|
|
405
433
|
case 18:
|
|
406
434
|
content = getElement('.k-select-menu');
|
|
407
435
|
expect(content.innerHTML).to.matchSnapshot();
|
|
408
436
|
content.querySelector('.k-select-option').click();
|
|
409
|
-
|
|
437
|
+
_context13.next = 23;
|
|
410
438
|
return wait();
|
|
411
439
|
case 23:
|
|
412
440
|
expect(instance.get('time2')).to.eql('00:00:00');
|
|
413
441
|
expect(input2.innerHTML).to.matchSnapshot();
|
|
414
442
|
input3.click();
|
|
415
|
-
|
|
443
|
+
_context13.next = 28;
|
|
416
444
|
return wait();
|
|
417
445
|
case 28:
|
|
418
446
|
content = getElement('.k-time-content');
|
|
@@ -420,100 +448,100 @@ describe('Timepicker', function () {
|
|
|
420
448
|
_content$querySelecto = content.querySelectorAll('.k-scroll-select'), scroll1 = _content$querySelecto[0], scroll2 = _content$querySelecto[1];
|
|
421
449
|
scroll1.querySelector('.k-scroll-select-item:nth-child(11)').click();
|
|
422
450
|
scroll2.querySelector('.k-scroll-select-item:nth-child(12)').click();
|
|
423
|
-
|
|
451
|
+
_context13.next = 35;
|
|
424
452
|
return wait();
|
|
425
453
|
case 35:
|
|
426
454
|
expect(content.innerHTML).to.matchSnapshot();
|
|
427
455
|
content.querySelector('.k-btn').click();
|
|
428
|
-
|
|
456
|
+
_context13.next = 39;
|
|
429
457
|
return wait();
|
|
430
458
|
case 39:
|
|
431
459
|
expect(instance.get('time3')).eql(['00:30:00.000', '00:30:00.000']);
|
|
432
460
|
expect(input3.innerHTML).to.matchSnapshot();
|
|
433
461
|
case 41:
|
|
434
462
|
case "end":
|
|
435
|
-
return
|
|
463
|
+
return _context13.stop();
|
|
436
464
|
}
|
|
437
|
-
},
|
|
465
|
+
}, _callee11);
|
|
438
466
|
})));
|
|
439
|
-
it('can input', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
440
|
-
var Demo,
|
|
441
|
-
return _regeneratorRuntime.wrap(function
|
|
442
|
-
while (1) switch (
|
|
467
|
+
it('can input', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
468
|
+
var Demo, _mount11, instance, element, _element$querySelecto6, basicInput, multipleInput, rangeInput, formatInput, input;
|
|
469
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context16) {
|
|
470
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
443
471
|
case 0:
|
|
444
472
|
Demo = /*#__PURE__*/function (_Component) {
|
|
445
473
|
_inheritsLoose(Demo, _Component);
|
|
446
474
|
function Demo() {
|
|
447
|
-
var
|
|
475
|
+
var _context14;
|
|
448
476
|
var _this;
|
|
449
477
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
450
478
|
args[_key] = arguments[_key];
|
|
451
479
|
}
|
|
452
|
-
_this = _Component.call.apply(_Component, _concatInstanceProperty(
|
|
480
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context14 = [this]).call(_context14, args)) || this;
|
|
453
481
|
_this.Timepicker = Timepicker;
|
|
454
482
|
return _this;
|
|
455
483
|
}
|
|
456
484
|
return Demo;
|
|
457
485
|
}(Component);
|
|
458
486
|
Demo.template = "\n const {Timepicker} = this;\n <div>\n <Timepicker v-model=\"basic\" min=\"01:34:56\" max=\"15:02:59\" />\n <Timepicker v-model=\"multiple\" multiple />\n <Timepicker v-model=\"range\" range min=\"01:34:56\" max=\"15:02:59\" />\n <Timepicker v-model=\"format\" range step=\"00:30:00\" valueFormat=\"HH:mm:ss.SSS\" showFormat=\"HH:mm\"/>\n </div>\n ";
|
|
459
|
-
|
|
487
|
+
_mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
|
|
460
488
|
_element$querySelecto6 = element.querySelectorAll('.k-input-inner'), basicInput = _element$querySelecto6[0], multipleInput = _element$querySelecto6[1], rangeInput = _element$querySelecto6[2], formatInput = _element$querySelecto6[3];
|
|
461
489
|
input = /*#__PURE__*/function () {
|
|
462
|
-
var
|
|
463
|
-
return _regeneratorRuntime.wrap(function
|
|
464
|
-
while (1) switch (
|
|
490
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_input, value) {
|
|
491
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context15) {
|
|
492
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
465
493
|
case 0:
|
|
466
494
|
_input.value = value;
|
|
467
495
|
dispatchEvent(_input, 'input');
|
|
468
|
-
|
|
496
|
+
_context15.next = 4;
|
|
469
497
|
return wait();
|
|
470
498
|
case 4:
|
|
471
499
|
case "end":
|
|
472
|
-
return
|
|
500
|
+
return _context15.stop();
|
|
473
501
|
}
|
|
474
|
-
},
|
|
502
|
+
}, _callee12);
|
|
475
503
|
}));
|
|
476
504
|
return function input(_x, _x2) {
|
|
477
|
-
return
|
|
505
|
+
return _ref13.apply(this, arguments);
|
|
478
506
|
};
|
|
479
507
|
}(); // input disabled value
|
|
480
|
-
|
|
508
|
+
_context16.next = 7;
|
|
481
509
|
return input(basicInput, '01:01:01');
|
|
482
510
|
case 7:
|
|
483
511
|
expect(instance.get('basic')).to.eql(undefined);
|
|
484
512
|
// input correct value
|
|
485
|
-
|
|
513
|
+
_context16.next = 10;
|
|
486
514
|
return input(basicInput, '03:03:03');
|
|
487
515
|
case 10:
|
|
488
516
|
expect(instance.get('basic')).to.eql('03:03:03');
|
|
489
517
|
// input multple values
|
|
490
|
-
|
|
518
|
+
_context16.next = 13;
|
|
491
519
|
return input(multipleInput, '01:01:01');
|
|
492
520
|
case 13:
|
|
493
521
|
expect(instance.get('multiple')).to.eql(['01:01:01']);
|
|
494
|
-
|
|
522
|
+
_context16.next = 16;
|
|
495
523
|
return input(multipleInput, '02:02:02');
|
|
496
524
|
case 16:
|
|
497
525
|
expect(instance.get('multiple')).to.eql(['01:01:01', '02:02:02']);
|
|
498
526
|
// input disabled range value
|
|
499
|
-
|
|
527
|
+
_context16.next = 19;
|
|
500
528
|
return input(rangeInput, '01:01:01~05:05:05');
|
|
501
529
|
case 19:
|
|
502
530
|
expect(instance.get('range')).to.eql(undefined);
|
|
503
531
|
// input correct range value
|
|
504
|
-
|
|
532
|
+
_context16.next = 22;
|
|
505
533
|
return input(rangeInput, '03:03:03~05:05:05');
|
|
506
534
|
case 22:
|
|
507
535
|
expect(instance.get('range')).to.eql(['03:03:03', '05:05:05']);
|
|
508
536
|
// input correct formated value
|
|
509
|
-
|
|
537
|
+
_context16.next = 25;
|
|
510
538
|
return input(formatInput, '01:00~02:00');
|
|
511
539
|
case 25:
|
|
512
540
|
expect(instance.get('format')).to.eql(['01:00:00.000', '02:00:00.000']);
|
|
513
541
|
case 26:
|
|
514
542
|
case "end":
|
|
515
|
-
return
|
|
543
|
+
return _context16.stop();
|
|
516
544
|
}
|
|
517
|
-
},
|
|
545
|
+
}, _callee13);
|
|
518
546
|
})));
|
|
519
547
|
});
|
|
@@ -6,16 +6,21 @@ import { isArray } from 'intact-shared';
|
|
|
6
6
|
export function useDefaultValue() {
|
|
7
7
|
var instance = useInstance();
|
|
8
8
|
function get() {
|
|
9
|
-
var
|
|
10
|
-
var lastValue = last(_value);
|
|
9
|
+
var _instance$value, _instance$step;
|
|
11
10
|
var _instance$get = instance.get(),
|
|
12
|
-
range = _instance$get.range
|
|
11
|
+
range = _instance$get.range,
|
|
12
|
+
min = _instance$get.min,
|
|
13
|
+
max = _instance$get.max;
|
|
14
|
+
var _value = ((_instance$value = instance.value) == null ? void 0 : _instance$value.value.value) || [];
|
|
15
|
+
var options = (_instance$step = instance.step) == null ? void 0 : _instance$step.options.value;
|
|
16
|
+
// 优先级:用户选择值 > step 选项首尾 > min/max 属性 > 全局默认值
|
|
17
|
+
var hasOptions = options && options.length;
|
|
18
|
+
var start = hasOptions ? instance.formats.createDateByValueFormat(options[0].value) : min ? instance.formats.createDateByValueFormat(min) : NOW_START;
|
|
19
|
+
var end = hasOptions ? instance.formats.createDateByValueFormat(options[options.length - 1].value) : max ? instance.formats.createDateByValueFormat(max) : NOW_END;
|
|
13
20
|
if (range) {
|
|
14
|
-
|
|
15
|
-
var penulimate = getPenulimate(_value);
|
|
16
|
-
return _Object$assign([NOW_START, NOW_END], penulimate, lastValue);
|
|
21
|
+
return _Object$assign([start, end], getPenulimate(_value), last(_value));
|
|
17
22
|
}
|
|
18
|
-
return
|
|
23
|
+
return last(_value) || start;
|
|
19
24
|
}
|
|
20
25
|
return {
|
|
21
26
|
get: get
|
|
@@ -13,7 +13,8 @@ export function useStep(_ref, _ref2) {
|
|
|
13
13
|
useReceive(['step', 'min', 'max'], generateOptions);
|
|
14
14
|
function generateOptions() {
|
|
15
15
|
var _instance$get = instance.get(),
|
|
16
|
-
step = _instance$get.step
|
|
16
|
+
step = _instance$get.step,
|
|
17
|
+
max = _instance$get.max;
|
|
17
18
|
if (step) {
|
|
18
19
|
var data = [];
|
|
19
20
|
var maxValue = maxDate.value || NOW_END;
|
|
@@ -29,7 +30,8 @@ export function useStep(_ref, _ref2) {
|
|
|
29
30
|
if (value <= maxValue) {
|
|
30
31
|
push(value);
|
|
31
32
|
if (+value === +maxValue) break;
|
|
32
|
-
} else if (data.length) {
|
|
33
|
+
} else if (data.length && max !== undefined) {
|
|
34
|
+
// unless max is undefined, it means the max is not set, so we don't need to add the maxValue to the last
|
|
33
35
|
// it the last value is less than maxValue,
|
|
34
36
|
// add the maxValue to the last
|
|
35
37
|
push(maxValue);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, TypeDefs, VNode, Key, Children } from 'intact-vue-next';
|
|
2
2
|
import { Model } from './useFilter';
|
|
3
3
|
import type { Events } from '../types';
|
|
4
|
+
import type { PaginationProps, PaginationChangeData } from '../pagination';
|
|
4
5
|
export interface TransferProps<K extends string = 'key', L extends string = 'label', T extends TransferDataItem<K, L> = TransferDataItem<K, L>, V extends T[K] = T[K]> {
|
|
5
6
|
data?: T[];
|
|
6
7
|
keyName?: K;
|
|
@@ -17,6 +18,7 @@ export interface TransferProps<K extends string = 'key', L extends string = 'lab
|
|
|
17
18
|
rightTitle?: string | VNode;
|
|
18
19
|
enableAdd?: () => boolean;
|
|
19
20
|
enableRemove?: () => boolean;
|
|
21
|
+
pagination?: boolean | PaginationProps;
|
|
20
22
|
}
|
|
21
23
|
export type TransferDataItem<A extends string = 'key', B extends string = 'label'> = {
|
|
22
24
|
[K in A]: Key;
|
|
@@ -28,6 +30,7 @@ export type TransferDataItem<A extends string = 'key', B extends string = 'label
|
|
|
28
30
|
export interface TransferEvents {
|
|
29
31
|
add: [];
|
|
30
32
|
remove: [];
|
|
33
|
+
page: [Model, PaginationChangeData];
|
|
31
34
|
}
|
|
32
35
|
export interface TransferBlocks<T, V> {
|
|
33
36
|
header: Model;
|
|
@@ -42,6 +45,16 @@ export declare class Transfer<K extends string = 'key', L extends string = 'labe
|
|
|
42
45
|
static events: Events<TransferEvents>;
|
|
43
46
|
private transfer;
|
|
44
47
|
private filter;
|
|
48
|
+
paginationState: {
|
|
49
|
+
getPagedData: (model: Model, allData: any[]) => any[];
|
|
50
|
+
leftValue: import("../../hooks/useState").State<number>;
|
|
51
|
+
leftLimit: import("../../hooks/useState").State<number>;
|
|
52
|
+
rightValue: import("../../hooks/useState").State<number>;
|
|
53
|
+
rightLimit: import("../../hooks/useState").State<number>;
|
|
54
|
+
onChange: (model: Model, data: PaginationChangeData) => void;
|
|
55
|
+
leftPaginationRef: import('intact-vue-next').RefObject<import("../pagination").Pagination>;
|
|
56
|
+
rightPaginationRef: import('intact-vue-next').RefObject<import("../pagination").Pagination>;
|
|
57
|
+
};
|
|
45
58
|
private check;
|
|
46
59
|
private config;
|
|
47
60
|
getData(): any[];
|
|
@@ -7,6 +7,7 @@ import { _$ } from '../../i18n';
|
|
|
7
7
|
import { useTransfer } from './useTransfer';
|
|
8
8
|
import { useFilter } from './useFilter';
|
|
9
9
|
import { useCheck } from './useCheck';
|
|
10
|
+
import { usePagination } from './usePagination';
|
|
10
11
|
import { useConfigContext } from '../config';
|
|
11
12
|
var typeDefs = {
|
|
12
13
|
data: Array,
|
|
@@ -23,7 +24,8 @@ var typeDefs = {
|
|
|
23
24
|
leftTitle: [String, VNode],
|
|
24
25
|
rightTitle: [String, VNode],
|
|
25
26
|
enableAdd: Function,
|
|
26
|
-
enableRemove: Function
|
|
27
|
+
enableRemove: Function,
|
|
28
|
+
pagination: [Boolean, Object]
|
|
27
29
|
};
|
|
28
30
|
var defaults = function defaults() {
|
|
29
31
|
return {
|
|
@@ -40,7 +42,8 @@ var defaults = function defaults() {
|
|
|
40
42
|
};
|
|
41
43
|
var events = {
|
|
42
44
|
add: true,
|
|
43
|
-
remove: true
|
|
45
|
+
remove: true,
|
|
46
|
+
page: true
|
|
44
47
|
};
|
|
45
48
|
export var Transfer = /*#__PURE__*/function (_Component) {
|
|
46
49
|
_inheritsLoose(Transfer, _Component);
|
|
@@ -53,6 +56,7 @@ export var Transfer = /*#__PURE__*/function (_Component) {
|
|
|
53
56
|
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
54
57
|
_this.transfer = useTransfer();
|
|
55
58
|
_this.filter = useFilter(_this.transfer.rightData);
|
|
59
|
+
_this.paginationState = usePagination();
|
|
56
60
|
_this.check = useCheck(_filterInstanceProperty(_this));
|
|
57
61
|
_this.config = useConfigContext();
|
|
58
62
|
return _this;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _atInstanceProperty from "@babel/runtime-corejs3/core-js/instance/at";
|
|
2
3
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
4
|
import BasicDemo from '~/components/transfer/demos/basic';
|
|
4
5
|
import LabelDemo from '~/components/transfer/demos/label';
|
|
6
|
+
import PaginationDemo from '~/components/transfer/demos/pagination';
|
|
5
7
|
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
6
8
|
describe('Transfer', function () {
|
|
7
9
|
afterEach(function () {
|
|
@@ -203,4 +205,199 @@ describe('Transfer', function () {
|
|
|
203
205
|
}
|
|
204
206
|
}, _callee4, this);
|
|
205
207
|
})));
|
|
208
|
+
it('pagination', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
209
|
+
var _mount6, instance, element, transfer, pagination, leftItems, firstItem, nextButton, leftItemsPage2, firstItemPage2, nextButton2, filteredItems, restoredItems;
|
|
210
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
211
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
this.timeout(0);
|
|
214
|
+
_mount6 = mount(PaginationDemo), instance = _mount6[0], element = _mount6[1];
|
|
215
|
+
_context5.next = 4;
|
|
216
|
+
return wait();
|
|
217
|
+
case 4:
|
|
218
|
+
transfer = instance.refs.__test; // 快照:初始状态(第1页)
|
|
219
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
220
|
+
// 测试1: 分页器存在
|
|
221
|
+
pagination = element.querySelector('.k-transfer-pagination-wrapper .k-pagination');
|
|
222
|
+
expect(pagination).to.be.ok;
|
|
223
|
+
// 测试2: 第一页显示的数据(默认 limit=10,显示前10条)
|
|
224
|
+
leftItems = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item');
|
|
225
|
+
expect(leftItems.length).to.eql(10);
|
|
226
|
+
// 验证显示的是前10条数据
|
|
227
|
+
firstItem = leftItems[0].querySelector('.k-checkbox');
|
|
228
|
+
expect(firstItem.textContent).to.include('主机名1');
|
|
229
|
+
// 测试3: 点击下一页
|
|
230
|
+
nextButton = element.querySelector('.k-transfer-pagination-wrapper .k-pagination .k-pagination-next');
|
|
231
|
+
if (!(nextButton && !nextButton.classList.contains('k-disabled'))) {
|
|
232
|
+
_context5.next = 22;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
nextButton.click();
|
|
236
|
+
_context5.next = 17;
|
|
237
|
+
return wait(500);
|
|
238
|
+
case 17:
|
|
239
|
+
// 快照:第2页
|
|
240
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
241
|
+
// 验证显示的是第11-20条数据
|
|
242
|
+
leftItemsPage2 = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item');
|
|
243
|
+
expect(leftItemsPage2.length).to.eql(10);
|
|
244
|
+
firstItemPage2 = leftItemsPage2[0].querySelector('.k-checkbox');
|
|
245
|
+
expect(firstItemPage2.textContent).to.include('主机名11');
|
|
246
|
+
case 22:
|
|
247
|
+
// 测试4: 设置关键词进行筛选,验证页码重置为1
|
|
248
|
+
// 先翻到第2页
|
|
249
|
+
nextButton2 = element.querySelector('.k-transfer-pagination-wrapper .k-pagination .k-pagination-next');
|
|
250
|
+
if (!(nextButton2 && !nextButton2.classList.contains('k-disabled'))) {
|
|
251
|
+
_context5.next = 27;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
nextButton2.click();
|
|
255
|
+
_context5.next = 27;
|
|
256
|
+
return wait(500);
|
|
257
|
+
case 27:
|
|
258
|
+
// 设置关键词,应该重置到第1页
|
|
259
|
+
transfer.set('leftKeywords', '1');
|
|
260
|
+
_context5.next = 30;
|
|
261
|
+
return wait(500);
|
|
262
|
+
case 30:
|
|
263
|
+
// 快照:筛选后(第1页)
|
|
264
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
265
|
+
// 验证筛选后的数据(应该显示第1页的筛选结果)
|
|
266
|
+
filteredItems = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item'); // 筛选包含'1'的数据,应该少于或等于10条
|
|
267
|
+
_atInstanceProperty(expect(filteredItems.length).to.be).most(10);
|
|
268
|
+
// 验证所有显示的数据都包含'1'
|
|
269
|
+
filteredItems.forEach(function (item) {
|
|
270
|
+
var text = item.textContent || '';
|
|
271
|
+
expect(text).to.match(/主机名\d*1\d*/);
|
|
272
|
+
});
|
|
273
|
+
// 测试5: 清除筛选后恢复分页
|
|
274
|
+
transfer.set('leftKeywords', '');
|
|
275
|
+
_context5.next = 37;
|
|
276
|
+
return wait(500);
|
|
277
|
+
case 37:
|
|
278
|
+
// 快照:清除筛选后(恢复第1页)
|
|
279
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
280
|
+
restoredItems = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item');
|
|
281
|
+
expect(restoredItems.length).to.eql(10);
|
|
282
|
+
case 40:
|
|
283
|
+
case "end":
|
|
284
|
+
return _context5.stop();
|
|
285
|
+
}
|
|
286
|
+
}, _callee5, this);
|
|
287
|
+
})));
|
|
288
|
+
it('pagination with filter', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
289
|
+
var _mount7, instance, element, transfer, filteredItems, nextButton, page2Items, restoredItems;
|
|
290
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
291
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
292
|
+
case 0:
|
|
293
|
+
this.timeout(0);
|
|
294
|
+
_mount7 = mount(PaginationDemo), instance = _mount7[0], element = _mount7[1];
|
|
295
|
+
_context6.next = 4;
|
|
296
|
+
return wait();
|
|
297
|
+
case 4:
|
|
298
|
+
transfer = instance.refs.__test; // 测试筛选后分页数据立即更新
|
|
299
|
+
transfer.set('leftKeywords', '2');
|
|
300
|
+
_context6.next = 8;
|
|
301
|
+
return wait(500);
|
|
302
|
+
case 8:
|
|
303
|
+
// 快照:筛选后(第1页)
|
|
304
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
305
|
+
// 验证筛选后的数据立即显示
|
|
306
|
+
filteredItems = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item'); // 所有显示的数据应该包含'2'
|
|
307
|
+
filteredItems.forEach(function (item) {
|
|
308
|
+
var text = item.textContent || '';
|
|
309
|
+
expect(text).to.match(/主机名\d*2\d*/);
|
|
310
|
+
});
|
|
311
|
+
// 测试筛选后切换页面
|
|
312
|
+
nextButton = element.querySelector('.k-transfer-pagination-wrapper .k-pagination .k-pagination-next');
|
|
313
|
+
if (!(nextButton && !nextButton.classList.contains('k-disabled'))) {
|
|
314
|
+
_context6.next = 19;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
nextButton.click();
|
|
318
|
+
_context6.next = 16;
|
|
319
|
+
return wait(500);
|
|
320
|
+
case 16:
|
|
321
|
+
// 快照:筛选后第2页
|
|
322
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
323
|
+
// 验证第二页的数据也包含'2'
|
|
324
|
+
page2Items = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item');
|
|
325
|
+
page2Items.forEach(function (item) {
|
|
326
|
+
var text = item.textContent || '';
|
|
327
|
+
expect(text).to.match(/主机名\d*2\d*/);
|
|
328
|
+
});
|
|
329
|
+
case 19:
|
|
330
|
+
// 清除筛选
|
|
331
|
+
transfer.set('leftKeywords', '');
|
|
332
|
+
_context6.next = 22;
|
|
333
|
+
return wait(500);
|
|
334
|
+
case 22:
|
|
335
|
+
// 快照:清除筛选后(恢复第1页)
|
|
336
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
337
|
+
// 验证清除筛选后显示所有数据的第一页
|
|
338
|
+
restoredItems = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item');
|
|
339
|
+
expect(restoredItems.length).to.eql(10);
|
|
340
|
+
case 25:
|
|
341
|
+
case "end":
|
|
342
|
+
return _context6.stop();
|
|
343
|
+
}
|
|
344
|
+
}, _callee6, this);
|
|
345
|
+
})));
|
|
346
|
+
it('pagination with checkbox selection', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
347
|
+
var _mount8, instance, element, transfer, checkAll, leftCheckedKeys, nextButton, leftCheckedKeysAfterPageChange, page2Items, leftCheckedKeysAfterUncheck;
|
|
348
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
349
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
350
|
+
case 0:
|
|
351
|
+
this.timeout(0);
|
|
352
|
+
_mount8 = mount(PaginationDemo), instance = _mount8[0], element = _mount8[1];
|
|
353
|
+
_context7.next = 4;
|
|
354
|
+
return wait();
|
|
355
|
+
case 4:
|
|
356
|
+
transfer = instance.refs.__test; // 测试1: 全选基于全部数据
|
|
357
|
+
checkAll = element.querySelector('.k-transfer-title .k-checkbox');
|
|
358
|
+
checkAll.click();
|
|
359
|
+
_context7.next = 9;
|
|
360
|
+
return wait();
|
|
361
|
+
case 9:
|
|
362
|
+
// 快照:全选后(第1页)
|
|
363
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
364
|
+
leftCheckedKeys = transfer.get('leftCheckedKeys');
|
|
365
|
+
expect(leftCheckedKeys.length).to.eql(100);
|
|
366
|
+
// 测试2: 切换页面时保持选中状态
|
|
367
|
+
nextButton = element.querySelector('.k-transfer-pagination-wrapper .k-pagination .k-pagination-next');
|
|
368
|
+
if (!(nextButton && !nextButton.classList.contains('k-disabled'))) {
|
|
369
|
+
_context7.next = 22;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
nextButton.click();
|
|
373
|
+
_context7.next = 17;
|
|
374
|
+
return wait(500);
|
|
375
|
+
case 17:
|
|
376
|
+
// 快照:全选后切换到第2页(选中状态保持)
|
|
377
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
378
|
+
// 切换到第2页后,选中状态应该保持
|
|
379
|
+
leftCheckedKeysAfterPageChange = transfer.get('leftCheckedKeys');
|
|
380
|
+
expect(leftCheckedKeysAfterPageChange.length).to.eql(100);
|
|
381
|
+
// 验证第2页的checkbox状态(应该都是选中的)
|
|
382
|
+
page2Items = element.querySelectorAll('.k-transfer-panel:first-child .k-transfer-item');
|
|
383
|
+
page2Items.forEach(function (item) {
|
|
384
|
+
var checkbox = item.querySelector('input[type="checkbox"]');
|
|
385
|
+
expect(checkbox.checked).to.be.true;
|
|
386
|
+
});
|
|
387
|
+
case 22:
|
|
388
|
+
// 测试3: 取消全选
|
|
389
|
+
checkAll.click();
|
|
390
|
+
_context7.next = 25;
|
|
391
|
+
return wait();
|
|
392
|
+
case 25:
|
|
393
|
+
// 快照:取消全选后
|
|
394
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
395
|
+
leftCheckedKeysAfterUncheck = transfer.get('leftCheckedKeys');
|
|
396
|
+
expect(leftCheckedKeysAfterUncheck.length).to.eql(0);
|
|
397
|
+
case 28:
|
|
398
|
+
case "end":
|
|
399
|
+
return _context7.stop();
|
|
400
|
+
}
|
|
401
|
+
}, _callee7, this);
|
|
402
|
+
})));
|
|
206
403
|
});
|
|
@@ -9,6 +9,8 @@ import { Checkbox } from '../checkbox';
|
|
|
9
9
|
import { Button } from '../button';
|
|
10
10
|
import { Tree } from '../tree';
|
|
11
11
|
import { Icon } from '../icon';
|
|
12
|
+
import { Pagination } from '../pagination';
|
|
13
|
+
import { isObject, EMPTY_OBJ } from 'intact-shared';
|
|
12
14
|
export default function ($props, $blocks, $__proto__) {
|
|
13
15
|
var _classNameObj,
|
|
14
16
|
_this = this;
|
|
@@ -24,7 +26,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
24
26
|
labelName = _this$get.labelName,
|
|
25
27
|
filterable = _this$get.filterable,
|
|
26
28
|
filter = _filterInstanceProperty(_this$get),
|
|
27
|
-
placeholder = _this$get.placeholder
|
|
29
|
+
placeholder = _this$get.placeholder,
|
|
30
|
+
pagination = _this$get.pagination;
|
|
28
31
|
var getShowedData = _filterInstanceProperty(this).getShowedData;
|
|
29
32
|
var _this$transfer = this.transfer,
|
|
30
33
|
enableAdd = _this$transfer.enableAdd,
|
|
@@ -36,13 +39,22 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
36
39
|
toggleCheckAll = _this$check.toggleCheckAll,
|
|
37
40
|
onCheckboxChange = _this$check.onCheckboxChange,
|
|
38
41
|
isIndeterminate = _this$check.isIndeterminate;
|
|
42
|
+
var _this$paginationState = this.paginationState,
|
|
43
|
+
getPagedData = _this$paginationState.getPagedData,
|
|
44
|
+
leftValue = _this$paginationState.leftValue,
|
|
45
|
+
leftLimit = _this$paginationState.leftLimit,
|
|
46
|
+
rightValue = _this$paginationState.rightValue,
|
|
47
|
+
rightLimit = _this$paginationState.rightLimit,
|
|
48
|
+
onPageChange = _this$paginationState.onChange;
|
|
39
49
|
var k = this.config.k;
|
|
40
50
|
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-transfer"] = true, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
41
51
|
var Panel = function Panel(model) {
|
|
42
52
|
var title = _this.get(model + "Title");
|
|
43
|
-
var
|
|
53
|
+
var allData = getShowedData(model) || [];
|
|
54
|
+
var hasPagination = !!pagination;
|
|
55
|
+
var displayData = hasPagination ? getPagedData(model, allData) : allData;
|
|
44
56
|
return _$ce(2, 'div', [_$ce(2, 'div', (_$blocks['header'] = function ($super) {
|
|
45
|
-
return [_$ce(2, 'div', [this.get(model + "CheckedKeys.length"), _$ct(' /\n '),
|
|
57
|
+
return [_$ce(2, 'div', [this.get(model + "CheckedKeys.length"), _$ct(' /\n '), allData.length], 0, _$cn(k + "-transfer-count")), _$cc(Checkbox, {
|
|
46
58
|
'className': 'c-ellipsis',
|
|
47
59
|
'value': isCheckAll(model),
|
|
48
60
|
'indeterminate': isIndeterminate(model),
|
|
@@ -90,7 +102,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
90
102
|
}, _filterInstanceProperty(__$blocks).call(__$blocks, _$no, model)) : undefined, _$ce(2, 'div', (_$blocks['list'] = function ($super) {
|
|
91
103
|
return _$cc(TransitionGroup, {
|
|
92
104
|
'name': 'k-fade',
|
|
93
|
-
'children': _$ma(
|
|
105
|
+
'children': _$ma(displayData, function ($value, $key) {
|
|
94
106
|
var _$cn2;
|
|
95
107
|
return _$ce(2, 'div', _$cc(Checkbox, {
|
|
96
108
|
'name': model,
|
|
@@ -119,7 +131,18 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
119
131
|
return _$blocks['list'].call($this, $super, data);
|
|
120
132
|
};
|
|
121
133
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
122
|
-
}, __$blocks['list'](_$no, model)), 0, _$cn(k + "-transfer-list"))
|
|
134
|
+
}, __$blocks['list'](_$no, model)), 0, _$cn(k + "-transfer-list")), hasPagination ? _$ce(2, 'div', _$cc(Pagination, _extends({
|
|
135
|
+
'ref': model === 'left' ? _this.paginationState.leftPaginationRef : _this.paginationState.rightPaginationRef,
|
|
136
|
+
'total': allData.length,
|
|
137
|
+
'size': 'mini',
|
|
138
|
+
'flat': true,
|
|
139
|
+
'showTotal': false,
|
|
140
|
+
'showLimits': false
|
|
141
|
+
}, isObject(pagination) ? pagination : EMPTY_OBJ, {
|
|
142
|
+
'value': model === 'left' ? leftValue.value : rightValue.value,
|
|
143
|
+
'limit': model === 'left' ? leftLimit.value : rightLimit.value,
|
|
144
|
+
'ev-change': onPageChange.bind(null, model)
|
|
145
|
+
}), null, model === 'left' ? _this.paginationState.leftPaginationRef : _this.paginationState.rightPaginationRef), 2, _$cn(k + "-transfer-pagination-wrapper")) : undefined], 0, _$cn(k + "-transfer-panel"));
|
|
123
146
|
};
|
|
124
147
|
return _$cv('div', _extends({
|
|
125
148
|
'className': _$cn(classNameObj)
|