@king-design/vue 2.1.0 → 2.1.2
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 +11 -11
- package/components/dropdown/dropdown.d.ts +6 -5
- package/components/dropdown/dropdown.js +42 -69
- package/components/dropdown/index.spec.js +96 -17
- package/components/dropdown/item.d.ts +1 -1
- package/components/dropdown/item.js +16 -4
- package/components/dropdown/usePosition.js +4 -2
- package/components/form/index.spec.js +49 -2
- package/components/menu/index.spec.js +26 -15
- package/components/menu/item.d.ts +2 -0
- package/components/menu/item.js +5 -0
- package/components/pagination/index.js +4 -1
- package/components/pagination/index.spec.js +49 -0
- package/components/tooltip/content.d.ts +1 -0
- package/components/tooltip/content.js +18 -1
- package/components/tooltip/content.vdt.js +3 -1
- package/components/tooltip/index.spec.js +165 -0
- package/components/tooltip/styles.d.ts +22 -0
- package/components/tooltip/styles.js +1 -1
- package/components/tooltip/tooltip.d.ts +1 -0
- package/components/tooltip/tooltip.js +16 -1
- package/components/virtual.d.ts +8 -0
- package/components/virtual.js +126 -0
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@ import { Dropdown, DropdownMenu, DropdownItem } from '../dropdown';
|
|
|
8
8
|
import BasicDemo from '~/components/dropdown/demos/basic';
|
|
9
9
|
import NestedDemo from '~/components/dropdown/demos/nested';
|
|
10
10
|
import ContextMenuDemo from '~/components/dropdown/demos/contextmenu';
|
|
11
|
+
import TooltipDemo from '~/components/dropdown/demos/tooltip';
|
|
11
12
|
describe('Dropdown', function () {
|
|
12
13
|
afterEach(function (done) {
|
|
13
14
|
unmount();
|
|
@@ -113,42 +114,61 @@ describe('Dropdown', function () {
|
|
|
113
114
|
}, _callee2);
|
|
114
115
|
})));
|
|
115
116
|
it('nested dropdown', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
116
|
-
var _mount3, instance, element, dropdown, _dropdown$querySelect, hoverItem, clickItem, clickSubDropdown, hoverSubDropdown;
|
|
117
|
+
var _mount3, instance, element, dropdown, _dropdown$querySelect, hoverItem, clickItem, clickSubDropdown, hoverSubDropdown, _hoverSubDropdown$que, hoverItem1, hoverSubDropdown1, _hoverSubDropdown1$qu, hoverItem2, hoverSubDropdown2;
|
|
117
118
|
|
|
118
119
|
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
119
120
|
while (1) {
|
|
120
121
|
switch (_context4.prev = _context4.next) {
|
|
121
122
|
case 0:
|
|
123
|
+
this.timeout(0);
|
|
122
124
|
_mount3 = mount(NestedDemo), instance = _mount3[0], element = _mount3[1];
|
|
123
125
|
element.firstElementChild.click();
|
|
124
|
-
_context4.next =
|
|
126
|
+
_context4.next = 5;
|
|
125
127
|
return wait();
|
|
126
128
|
|
|
127
|
-
case
|
|
129
|
+
case 5:
|
|
128
130
|
dropdown = getElement('.k-dropdown-menu');
|
|
129
131
|
_dropdown$querySelect = dropdown.querySelectorAll(':scope > .k-dropdown-item'), hoverItem = _dropdown$querySelect[3], clickItem = _dropdown$querySelect[4];
|
|
130
132
|
clickItem.click();
|
|
131
|
-
_context4.next =
|
|
133
|
+
_context4.next = 10;
|
|
132
134
|
return wait(500);
|
|
133
135
|
|
|
134
|
-
case
|
|
136
|
+
case 10:
|
|
135
137
|
clickSubDropdown = getElement('.k-dropdown-menu');
|
|
136
138
|
expect(clickSubDropdown.innerHTML).to.matchSnapshot(); // should hide last sub-dropdown and show next
|
|
137
139
|
|
|
138
140
|
dispatchEvent(hoverItem, 'mouseenter');
|
|
139
|
-
_context4.next =
|
|
141
|
+
_context4.next = 15;
|
|
140
142
|
return wait(500);
|
|
141
143
|
|
|
142
|
-
case
|
|
144
|
+
case 15:
|
|
143
145
|
hoverSubDropdown = getElement('.k-dropdown-menu');
|
|
144
146
|
expect(hoverSubDropdown.innerHTML).to.matchSnapshot();
|
|
147
|
+
_hoverSubDropdown$que = hoverSubDropdown.querySelectorAll('.k-dropdown-item'), hoverItem1 = _hoverSubDropdown$que[0];
|
|
148
|
+
dispatchEvent(hoverItem, 'mouseleave');
|
|
149
|
+
dispatchEvent(hoverItem1, 'mouseenter');
|
|
150
|
+
_context4.next = 22;
|
|
151
|
+
return wait(500);
|
|
145
152
|
|
|
146
|
-
case
|
|
153
|
+
case 22:
|
|
154
|
+
hoverSubDropdown1 = getElement('.k-dropdown-menu');
|
|
155
|
+
expect(hoverSubDropdown1.textContent).to.eql('item 1item 2');
|
|
156
|
+
_hoverSubDropdown1$qu = hoverSubDropdown1.querySelectorAll('.k-dropdown-item'), hoverItem2 = _hoverSubDropdown1$qu[0];
|
|
157
|
+
dispatchEvent(hoverItem1, 'mouseleave');
|
|
158
|
+
dispatchEvent(hoverItem2, 'mouseenter');
|
|
159
|
+
_context4.next = 29;
|
|
160
|
+
return wait(1000);
|
|
161
|
+
|
|
162
|
+
case 29:
|
|
163
|
+
hoverSubDropdown2 = getElement('.k-dropdown-menu');
|
|
164
|
+
expect(hoverSubDropdown2 === hoverSubDropdown1).to.be.true;
|
|
165
|
+
|
|
166
|
+
case 31:
|
|
147
167
|
case "end":
|
|
148
168
|
return _context4.stop();
|
|
149
169
|
}
|
|
150
170
|
}
|
|
151
|
-
}, _callee3);
|
|
171
|
+
}, _callee3, this);
|
|
152
172
|
})));
|
|
153
173
|
it('hide on click document', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
154
174
|
var _mount4, instance, element;
|
|
@@ -483,7 +503,7 @@ describe('Dropdown', function () {
|
|
|
483
503
|
}
|
|
484
504
|
}, _callee9);
|
|
485
505
|
})));
|
|
486
|
-
it('trigger
|
|
506
|
+
it('focus trigger type', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
487
507
|
var Demo, _mount9, instance;
|
|
488
508
|
|
|
489
509
|
return _regeneratorRuntime.wrap(function _callee10$(_context14) {
|
|
@@ -506,39 +526,98 @@ describe('Dropdown', function () {
|
|
|
506
526
|
_this4.Dropdown = Dropdown;
|
|
507
527
|
_this4.DropdownItem = DropdownItem;
|
|
508
528
|
_this4.DropdownMenu = DropdownMenu;
|
|
529
|
+
_this4.onFocus = sinon.spy(function (e) {
|
|
530
|
+
return console.log(e);
|
|
531
|
+
});
|
|
509
532
|
return _this4;
|
|
510
533
|
}
|
|
511
534
|
|
|
512
535
|
return Demo;
|
|
513
536
|
}(Component);
|
|
514
537
|
|
|
515
|
-
Demo.template = "\n const {Dropdown, DropdownMenu, DropdownItem} = this;\n <div>\n <Dropdown trigger=\"focus\">\n <input ref=\"trigger\" />\n <DropdownMenu>\n <DropdownItem>test1</DropdownItem>\n <DropdownItem>test2</DropdownItem>\n </DropdownMenu>\n </Dropdown>\n </div>\n ";
|
|
538
|
+
Demo.template = "\n const {Dropdown, DropdownMenu, DropdownItem} = this;\n <div>\n <Dropdown trigger=\"focus\">\n <input ref=\"trigger\" ev-focusin={this.onFocus} />\n <DropdownMenu>\n <DropdownItem>test1</DropdownItem>\n <DropdownItem>test2</DropdownItem>\n </DropdownMenu>\n </Dropdown>\n </div>\n ";
|
|
516
539
|
_mount9 = mount(Demo), instance = _mount9[0];
|
|
517
540
|
dispatchEvent(instance.refs.trigger, 'focusin');
|
|
518
541
|
_context14.next = 6;
|
|
519
542
|
return wait(500);
|
|
520
543
|
|
|
521
544
|
case 6:
|
|
522
|
-
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
545
|
+
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
546
|
+
expect(instance.onFocus.callCount).to.eql(1); // clicking anywhere should not hide menu
|
|
523
547
|
|
|
524
548
|
dispatchEvent(document, 'click');
|
|
525
|
-
_context14.next =
|
|
549
|
+
_context14.next = 11;
|
|
526
550
|
return wait(500);
|
|
527
551
|
|
|
528
|
-
case
|
|
552
|
+
case 11:
|
|
529
553
|
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
530
554
|
dispatchEvent(instance.refs.trigger, 'focusout');
|
|
531
|
-
_context14.next =
|
|
555
|
+
_context14.next = 15;
|
|
532
556
|
return wait(700);
|
|
533
557
|
|
|
534
|
-
case
|
|
558
|
+
case 15:
|
|
535
559
|
expect(getElement('.k-dropdown-menu')).to.not.be.exist;
|
|
536
560
|
|
|
537
|
-
case
|
|
561
|
+
case 16:
|
|
538
562
|
case "end":
|
|
539
563
|
return _context14.stop();
|
|
540
564
|
}
|
|
541
565
|
}
|
|
542
566
|
}, _callee10);
|
|
543
567
|
})));
|
|
568
|
+
it('wrap by tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
569
|
+
var _mount10, instance, element, dropdown, _dropdown$querySelect4, item1, item2, item3, item4;
|
|
570
|
+
|
|
571
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context15) {
|
|
572
|
+
while (1) {
|
|
573
|
+
switch (_context15.prev = _context15.next) {
|
|
574
|
+
case 0:
|
|
575
|
+
_mount10 = mount(TooltipDemo), instance = _mount10[0], element = _mount10[1];
|
|
576
|
+
dispatchEvent(element.firstChild, 'mouseenter');
|
|
577
|
+
_context15.next = 4;
|
|
578
|
+
return wait();
|
|
579
|
+
|
|
580
|
+
case 4:
|
|
581
|
+
dropdown = getElement('.k-dropdown-menu');
|
|
582
|
+
_dropdown$querySelect4 = dropdown.querySelectorAll('.k-dropdown-item'), item1 = _dropdown$querySelect4[0], item2 = _dropdown$querySelect4[1], item3 = _dropdown$querySelect4[2], item4 = _dropdown$querySelect4[3];
|
|
583
|
+
dispatchEvent(item1, 'mouseenter');
|
|
584
|
+
_context15.next = 9;
|
|
585
|
+
return wait();
|
|
586
|
+
|
|
587
|
+
case 9:
|
|
588
|
+
expect(getElement('.k-tooltip-content').textContent).to.eql('item 1');
|
|
589
|
+
dispatchEvent(item1, 'mouseleave');
|
|
590
|
+
dispatchEvent(item3, 'mouseenter');
|
|
591
|
+
_context15.next = 14;
|
|
592
|
+
return wait();
|
|
593
|
+
|
|
594
|
+
case 14:
|
|
595
|
+
expect(getElement('.k-tooltip-content').textContent).to.eql('disabled');
|
|
596
|
+
dispatchEvent(item3, 'mouseleave');
|
|
597
|
+
dispatchEvent(item4, 'mouseenter');
|
|
598
|
+
_context15.next = 19;
|
|
599
|
+
return wait();
|
|
600
|
+
|
|
601
|
+
case 19:
|
|
602
|
+
expect(getElement('.k-tooltip-content').textContent).to.eql('This is a nested Dropdown.');
|
|
603
|
+
dispatchEvent(item4, 'click');
|
|
604
|
+
_context15.next = 23;
|
|
605
|
+
return wait();
|
|
606
|
+
|
|
607
|
+
case 23:
|
|
608
|
+
expect(getElement('.k-dropdown-menu').textContent).to.eql('item 1item 2');
|
|
609
|
+
dispatchEvent(item4, 'mouseleave');
|
|
610
|
+
_context15.next = 27;
|
|
611
|
+
return wait(800);
|
|
612
|
+
|
|
613
|
+
case 27:
|
|
614
|
+
expect(getElement('.k-dropdown-menu')).to.not.be.exist;
|
|
615
|
+
|
|
616
|
+
case 28:
|
|
617
|
+
case "end":
|
|
618
|
+
return _context15.stop();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}, _callee11);
|
|
622
|
+
})));
|
|
544
623
|
});
|
|
@@ -5,8 +5,9 @@ import { Component, inject } from 'intact-vue-next';
|
|
|
5
5
|
import template from './item.vdt';
|
|
6
6
|
import { bind } from '../utils';
|
|
7
7
|
import { useItemKeyboard } from './useKeyboard';
|
|
8
|
-
import {
|
|
8
|
+
import { DROPDOWN } from './dropdown';
|
|
9
9
|
import { DROPDOWN_MENU } from './menu';
|
|
10
|
+
import { Dropdown as ExportDropdown, DropdownMenu as ExportDropdownMenu } from '.';
|
|
10
11
|
var typeDefs = {
|
|
11
12
|
disabled: Boolean,
|
|
12
13
|
hideOnSelect: Boolean,
|
|
@@ -64,11 +65,22 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
_proto.hasSubMenu = function hasSubMenu() {
|
|
67
|
-
//
|
|
68
|
+
// wrapped by Dropdown rather than DropdownMenu
|
|
68
69
|
var parent = this.$senior;
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
while (parent) {
|
|
72
|
+
// Tooltip extends Dropdown, it's also a instance of Dropdown
|
|
73
|
+
// so use constructor to detect
|
|
74
|
+
// if (parent instanceof DropdownMenu) {
|
|
75
|
+
if (parent.constructor === ExportDropdownMenu) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (parent.constructor === ExportDropdown) {
|
|
80
|
+
return parent;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
parent = parent.$senior;
|
|
72
84
|
}
|
|
73
85
|
};
|
|
74
86
|
|
|
@@ -17,7 +17,8 @@ export function usePosition() {
|
|
|
17
17
|
['of', 'position'].forEach(function (item) {
|
|
18
18
|
instance.watch(item, function (newValue, oldValue) {
|
|
19
19
|
// return if object is the same
|
|
20
|
-
if (isObject(newValue) && isObject(oldValue) &&
|
|
20
|
+
if (isObject(newValue) && isObject(oldValue) && // is not event object
|
|
21
|
+
!(newValue instanceof Event) && _JSON$stringify(newValue) === _JSON$stringify(oldValue)) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -67,7 +68,8 @@ export function usePosition() {
|
|
|
67
68
|
|
|
68
69
|
position(findDomFromVNode(instance.menuVNode, true), _extends({
|
|
69
70
|
my: 'left top+8',
|
|
70
|
-
at: 'left bottom'
|
|
71
|
+
at: 'left bottom',
|
|
72
|
+
collision: instance.get('collison')
|
|
71
73
|
}, pos, {
|
|
72
74
|
of: ofElement,
|
|
73
75
|
using: function using(_feedback) {
|
|
@@ -8,10 +8,11 @@ import BasicDemo, { data as basicDemoData } from '~/components/form/demos/basic'
|
|
|
8
8
|
import CustomDemo from '~/components/form/demos/custom';
|
|
9
9
|
import VariableDemo from '~/components/form/demos/variable';
|
|
10
10
|
import RemoteDemo from '~/components/form/demos/remote';
|
|
11
|
-
import { mount, dispatchEvent, wait } from '../../test/utils';
|
|
11
|
+
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
12
12
|
import { Component } from 'intact-vue-next';
|
|
13
13
|
import { Form, FormItem } from './';
|
|
14
14
|
import { Input } from '../input';
|
|
15
|
+
import { Select } from '../select';
|
|
15
16
|
|
|
16
17
|
RemoteDemo.prototype.validateUserName = function (value) {
|
|
17
18
|
// mock api
|
|
@@ -29,7 +30,9 @@ RemoteDemo.prototype.validateUserName = function (value) {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
describe('Form', function () {
|
|
32
|
-
|
|
33
|
+
afterEach(function () {
|
|
34
|
+
return unmount();
|
|
35
|
+
});
|
|
33
36
|
it('validate', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
34
37
|
var _mount, instance, element, form, item, input;
|
|
35
38
|
|
|
@@ -1315,4 +1318,48 @@ describe('Form', function () {
|
|
|
1315
1318
|
}
|
|
1316
1319
|
}, _callee7);
|
|
1317
1320
|
})));
|
|
1321
|
+
it('should not validate when select is disabled on init', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
1322
|
+
var Demo, _mount8, instance, element;
|
|
1323
|
+
|
|
1324
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context11) {
|
|
1325
|
+
while (1) {
|
|
1326
|
+
switch (_context11.prev = _context11.next) {
|
|
1327
|
+
case 0:
|
|
1328
|
+
Demo = /*#__PURE__*/function (_Component3) {
|
|
1329
|
+
_inheritsLoose(Demo, _Component3);
|
|
1330
|
+
|
|
1331
|
+
function Demo() {
|
|
1332
|
+
var _context10;
|
|
1333
|
+
|
|
1334
|
+
var _this3;
|
|
1335
|
+
|
|
1336
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1337
|
+
args[_key3] = arguments[_key3];
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
_this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context10 = [this]).call(_context10, args)) || this;
|
|
1341
|
+
_this3.Form = Form;
|
|
1342
|
+
_this3.FormItem = FormItem;
|
|
1343
|
+
_this3.Select = Select;
|
|
1344
|
+
return _this3;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
return Demo;
|
|
1348
|
+
}(Component);
|
|
1349
|
+
|
|
1350
|
+
Demo.template = "\n const {Form, FormItem, Select} = this;\n <Form ref=\"form\">\n <FormItem rules={{required: true}}>\n <Select disabled />\n </FormItem>\n </Form>\n ";
|
|
1351
|
+
_mount8 = mount(Demo), instance = _mount8[0], element = _mount8[1];
|
|
1352
|
+
_context11.next = 5;
|
|
1353
|
+
return wait(500);
|
|
1354
|
+
|
|
1355
|
+
case 5:
|
|
1356
|
+
expect(element.querySelector('.k-form-error')).to.be.null;
|
|
1357
|
+
|
|
1358
|
+
case 6:
|
|
1359
|
+
case "end":
|
|
1360
|
+
return _context11.stop();
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}, _callee8);
|
|
1364
|
+
})));
|
|
1318
1365
|
});
|
|
@@ -4,6 +4,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
4
4
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
6
6
|
import { Component } from 'intact-vue-next';
|
|
7
|
+
import BasicDemo from '~/components/menu/demos/basic';
|
|
7
8
|
import CollapseDemo from '~/components/menu/demos/collapse';
|
|
8
9
|
import AccordionDemo from '~/components/menu/demos/accordion';
|
|
9
10
|
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
@@ -19,24 +20,29 @@ describe('Menu', function () {
|
|
|
19
20
|
while (1) {
|
|
20
21
|
switch (_context.prev = _context.next) {
|
|
21
22
|
case 0:
|
|
22
|
-
_mount = mount(
|
|
23
|
+
_mount = mount(BasicDemo), instance = _mount[0], element = _mount[1];
|
|
24
|
+
_context.next = 3;
|
|
25
|
+
return wait();
|
|
26
|
+
|
|
27
|
+
case 3:
|
|
28
|
+
// shrink
|
|
23
29
|
title = element.querySelector('.k-expanded .k-menu-title');
|
|
24
30
|
title.click();
|
|
25
|
-
_context.next =
|
|
31
|
+
_context.next = 7;
|
|
26
32
|
return wait(500);
|
|
27
33
|
|
|
28
|
-
case
|
|
34
|
+
case 7:
|
|
29
35
|
expect(element.outerHTML).to.matchSnapshot();
|
|
30
36
|
expect(instance.get('expandedKeys')).to.eql([]);
|
|
31
37
|
title.click();
|
|
32
|
-
_context.next =
|
|
38
|
+
_context.next = 12;
|
|
33
39
|
return wait(500);
|
|
34
40
|
|
|
35
|
-
case
|
|
41
|
+
case 12:
|
|
36
42
|
expect(element.outerHTML).to.matchSnapshot();
|
|
37
43
|
expect(instance.get('expandedKeys')).to.eql(['3']);
|
|
38
44
|
|
|
39
|
-
case
|
|
45
|
+
case 14:
|
|
40
46
|
case "end":
|
|
41
47
|
return _context.stop();
|
|
42
48
|
}
|
|
@@ -51,39 +57,44 @@ describe('Menu', function () {
|
|
|
51
57
|
switch (_context2.prev = _context2.next) {
|
|
52
58
|
case 0:
|
|
53
59
|
_mount2 = mount(CollapseDemo), instance = _mount2[0], element = _mount2[1];
|
|
60
|
+
instance.set('collapse', false);
|
|
61
|
+
_context2.next = 4;
|
|
62
|
+
return wait();
|
|
63
|
+
|
|
64
|
+
case 4:
|
|
54
65
|
expect(element.innerHTML).to.matchSnapshot();
|
|
55
66
|
_element$querySelecto = element.querySelectorAll('.k-menu-title'), title = _element$querySelecto[0], disabledTitle = _element$querySelecto[1];
|
|
56
67
|
title.click();
|
|
57
|
-
_context2.next =
|
|
68
|
+
_context2.next = 9;
|
|
58
69
|
return wait();
|
|
59
70
|
|
|
60
|
-
case
|
|
71
|
+
case 9:
|
|
61
72
|
expect(element.outerHTML).to.matchSnapshot();
|
|
62
73
|
expect(instance.get('selectedKey')).to.eql('1');
|
|
63
74
|
disabledTitle.click();
|
|
64
|
-
_context2.next =
|
|
75
|
+
_context2.next = 14;
|
|
65
76
|
return wait();
|
|
66
77
|
|
|
67
|
-
case
|
|
78
|
+
case 14:
|
|
68
79
|
expect(element.outerHTML).to.matchSnapshot();
|
|
69
80
|
expect(instance.get('selectedKey')).to.eql('1');
|
|
70
81
|
subTitle = element.querySelector('.k-expanded .k-menu .k-menu-title');
|
|
71
82
|
subTitle.click();
|
|
72
|
-
_context2.next =
|
|
83
|
+
_context2.next = 20;
|
|
73
84
|
return wait();
|
|
74
85
|
|
|
75
|
-
case
|
|
86
|
+
case 20:
|
|
76
87
|
expect(element.outerHTML).to.matchSnapshot();
|
|
77
88
|
expect(instance.get('selectedKey')).to.eql('3-1'); // clear
|
|
78
89
|
|
|
79
90
|
instance.set('selectedKey', '');
|
|
80
|
-
_context2.next =
|
|
91
|
+
_context2.next = 25;
|
|
81
92
|
return wait();
|
|
82
93
|
|
|
83
|
-
case
|
|
94
|
+
case 25:
|
|
84
95
|
expect(element.querySelector('.k-highlighted')).to.be.null;
|
|
85
96
|
|
|
86
|
-
case
|
|
97
|
+
case 26:
|
|
87
98
|
case "end":
|
|
88
99
|
return _context2.stop();
|
|
89
100
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component, TypeDefs, Key } from 'intact-vue-next';
|
|
2
2
|
import { Menu } from './menu';
|
|
3
|
+
import { Events } from '../types';
|
|
3
4
|
export interface MenuItemProps {
|
|
4
5
|
key: Key;
|
|
5
6
|
to?: string | object;
|
|
@@ -14,6 +15,7 @@ export declare const MENU_ITEM = "MenuItem";
|
|
|
14
15
|
export declare class MenuItem extends Component<MenuItemProps, MenuItemEvents> {
|
|
15
16
|
static template: string | import("intact").Template<any>;
|
|
16
17
|
static typeDefs: Required<TypeDefs<MenuItemProps>>;
|
|
18
|
+
static events: Events<MenuItemEvents>;
|
|
17
19
|
rootMenu: Menu<Key>;
|
|
18
20
|
parentMenu: Menu<Key>;
|
|
19
21
|
parentMenuItem: MenuItem | null;
|
package/components/menu/item.js
CHANGED
|
@@ -19,6 +19,10 @@ var typeDefs = {
|
|
|
19
19
|
dot: Boolean,
|
|
20
20
|
disabled: Boolean
|
|
21
21
|
};
|
|
22
|
+
var events = {
|
|
23
|
+
click: true,
|
|
24
|
+
select: true
|
|
25
|
+
};
|
|
22
26
|
export var MENU_ITEM = 'MenuItem';
|
|
23
27
|
export var MenuItem = /*#__PURE__*/function (_Component) {
|
|
24
28
|
_inheritsLoose(MenuItem, _Component);
|
|
@@ -76,5 +80,6 @@ export var MenuItem = /*#__PURE__*/function (_Component) {
|
|
|
76
80
|
}(Component);
|
|
77
81
|
MenuItem.template = template;
|
|
78
82
|
MenuItem.typeDefs = typeDefs;
|
|
83
|
+
MenuItem.events = events;
|
|
79
84
|
|
|
80
85
|
__decorate([bind], MenuItem.prototype, "onClick", null);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import BasicDemo from '~/components/pagination/demos/basic';
|
|
4
6
|
import GotoDemo from '~/components/pagination/demos/goto';
|
|
5
7
|
import CurrentDemo from '~/components/pagination/demos/current';
|
|
6
8
|
import DisableDemo from '~/components/pagination/demos/disable';
|
|
7
9
|
import { mount, dispatchEvent, wait } from '../../test/utils';
|
|
10
|
+
import { Component } from 'intact-vue-next';
|
|
11
|
+
import { Pagination } from '.';
|
|
8
12
|
describe('Pagination', function () {
|
|
9
13
|
// afterEach(() => unmount());
|
|
10
14
|
it('basic test', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -167,4 +171,49 @@ describe('Pagination', function () {
|
|
|
167
171
|
}
|
|
168
172
|
}, _callee4);
|
|
169
173
|
})));
|
|
174
|
+
it('should not set value to 0 when total is 0 on intialization', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
175
|
+
var Demo, _mount5, instance;
|
|
176
|
+
|
|
177
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
178
|
+
while (1) {
|
|
179
|
+
switch (_context6.prev = _context6.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
182
|
+
_inheritsLoose(Demo, _Component);
|
|
183
|
+
|
|
184
|
+
function Demo() {
|
|
185
|
+
var _context5;
|
|
186
|
+
|
|
187
|
+
var _this;
|
|
188
|
+
|
|
189
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
190
|
+
args[_key] = arguments[_key];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context5 = [this]).call(_context5, args)) || this;
|
|
194
|
+
_this.Pagination = Pagination;
|
|
195
|
+
return _this;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
Demo.defaults = function defaults() {
|
|
199
|
+
return {
|
|
200
|
+
page: 1
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return Demo;
|
|
205
|
+
}(Component);
|
|
206
|
+
|
|
207
|
+
Demo.template = "\n const { Pagination } = this;\n <Pagination total={0} v-model=\"page\" />\n ";
|
|
208
|
+
_mount5 = mount(Demo), instance = _mount5[0]; // await wait();
|
|
209
|
+
|
|
210
|
+
expect(instance.get('page')).to.eql(1);
|
|
211
|
+
|
|
212
|
+
case 4:
|
|
213
|
+
case "end":
|
|
214
|
+
return _context6.stop();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, _callee5);
|
|
218
|
+
})));
|
|
170
219
|
});
|
|
@@ -5,6 +5,7 @@ import { DropdownMenu } from '../dropdown/menu';
|
|
|
5
5
|
import template from './content.vdt';
|
|
6
6
|
import { bind } from '../utils';
|
|
7
7
|
import { useArrow } from './useArrow';
|
|
8
|
+
import { tooltip as tooltipTheme } from './styles';
|
|
8
9
|
export var TooltipContent = /*#__PURE__*/function (_DropdownMenu) {
|
|
9
10
|
_inheritsLoose(TooltipContent, _DropdownMenu);
|
|
10
11
|
|
|
@@ -35,10 +36,24 @@ export var TooltipContent = /*#__PURE__*/function (_DropdownMenu) {
|
|
|
35
36
|
});
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
_proto.onEnter = function onEnter() {
|
|
39
|
+
_proto.onEnter = function onEnter(elem) {
|
|
40
|
+
// fix the width, https://github.com/ksc-fe/kpc/issues/873
|
|
41
|
+
var maxWidth = parseInt(tooltipTheme.maxWidth);
|
|
42
|
+
var width = elem.offsetWidth;
|
|
43
|
+
|
|
44
|
+
if (width === maxWidth) {
|
|
45
|
+
elem.style.width = width + "px";
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
this.dropdown.position();
|
|
40
49
|
};
|
|
41
50
|
|
|
51
|
+
_proto.onAfterLeave = function onAfterLeave(elem) {
|
|
52
|
+
// remove the position after leave, https://github.com/ksc-fe/kpc/issues/873
|
|
53
|
+
var style = elem.style;
|
|
54
|
+
style.left = style.top = style.width = '';
|
|
55
|
+
};
|
|
56
|
+
|
|
42
57
|
_proto.onMouseEnter = function onMouseEnter(e) {
|
|
43
58
|
var dropdown = this.dropdown;
|
|
44
59
|
|
|
@@ -67,6 +82,8 @@ TooltipContent.template = template;
|
|
|
67
82
|
|
|
68
83
|
__decorate([bind], TooltipContent.prototype, "onEnter", null);
|
|
69
84
|
|
|
85
|
+
__decorate([bind], TooltipContent.prototype, "onAfterLeave", null);
|
|
86
|
+
|
|
70
87
|
__decorate([bind], TooltipContent.prototype, "onMouseEnter", null);
|
|
71
88
|
|
|
72
89
|
__decorate([bind], TooltipContent.prototype, "ok", null);
|
|
@@ -38,7 +38,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
38
38
|
'value': !!value && !this.isEmptyChildren,
|
|
39
39
|
'transition': {
|
|
40
40
|
name: 'k-fade',
|
|
41
|
-
onEnter: this.onEnter
|
|
41
|
+
onEnter: this.onEnter,
|
|
42
|
+
onAfterLeave: this.onAfterLeave,
|
|
43
|
+
onLeaveCancelled: this.onAfterLeave
|
|
42
44
|
},
|
|
43
45
|
'className': _$cn(classNameObj)
|
|
44
46
|
}, function ($blocks) {
|