@king-design/intact 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/components/dropdown/dropdown.ts +34 -70
  2. package/components/dropdown/index.spec.ts +53 -4
  3. package/components/dropdown/item.ts +15 -5
  4. package/components/dropdown/menu.ts +3 -3
  5. package/components/dropdown/usePosition.ts +3 -0
  6. package/components/menu/demos/collapse.md +1 -1
  7. package/components/menu/index.spec.ts +9 -1
  8. package/components/menu/item.ts +7 -0
  9. package/components/pagination/index.spec.ts +23 -0
  10. package/components/pagination/index.ts +3 -1
  11. package/components/tooltip/content.ts +15 -1
  12. package/components/tooltip/content.vdt +6 -1
  13. package/components/tooltip/index.spec.ts +57 -1
  14. package/components/tooltip/styles.ts +1 -1
  15. package/components/tooltip/tooltip.ts +8 -0
  16. package/components/virtual.ts +98 -0
  17. package/es/components/dropdown/dropdown.d.ts +6 -5
  18. package/es/components/dropdown/dropdown.js +40 -68
  19. package/es/components/dropdown/index.spec.js +96 -17
  20. package/es/components/dropdown/item.d.ts +1 -1
  21. package/es/components/dropdown/item.js +16 -4
  22. package/es/components/dropdown/usePosition.js +4 -2
  23. package/es/components/menu/index.spec.js +26 -15
  24. package/es/components/menu/item.d.ts +2 -0
  25. package/es/components/menu/item.js +5 -0
  26. package/es/components/pagination/index.js +4 -1
  27. package/es/components/pagination/index.spec.js +49 -0
  28. package/es/components/tooltip/content.d.ts +1 -0
  29. package/es/components/tooltip/content.js +18 -1
  30. package/es/components/tooltip/content.vdt.js +3 -1
  31. package/es/components/tooltip/index.spec.js +108 -0
  32. package/es/components/tooltip/styles.d.ts +22 -0
  33. package/es/components/tooltip/styles.js +1 -1
  34. package/es/components/tooltip/tooltip.d.ts +1 -0
  35. package/es/components/tooltip/tooltip.js +11 -0
  36. package/es/components/virtual.d.ts +8 -0
  37. package/es/components/virtual.js +126 -0
  38. package/es/index.d.ts +2 -2
  39. package/es/index.js +2 -2
  40. package/es/site/data/components/dialog/demos/basic/react.js +1 -4
  41. package/es/site/data/components/menu/demos/collapse/index.js +1 -1
  42. package/es/site/data/components/menu/demos/collapse/react.js +1 -1
  43. package/index.ts +2 -2
  44. package/package.json +4 -3
@@ -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';
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(CollapseDemo), instance = _mount[0], element = _mount[1];
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 = 5;
31
+ _context.next = 7;
26
32
  return wait(500);
27
33
 
28
- case 5:
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 = 10;
38
+ _context.next = 12;
33
39
  return wait(500);
34
40
 
35
- case 10:
41
+ case 12:
36
42
  expect(element.outerHTML).to.matchSnapshot();
37
43
  expect(instance.get('expandedKeys')).to.eql(['3']);
38
44
 
39
- case 12:
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 = 6;
68
+ _context2.next = 9;
58
69
  return wait();
59
70
 
60
- case 6:
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 = 11;
75
+ _context2.next = 14;
65
76
  return wait();
66
77
 
67
- case 11:
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 = 17;
83
+ _context2.next = 20;
73
84
  return wait();
74
85
 
75
- case 17:
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 = 22;
91
+ _context2.next = 25;
81
92
  return wait();
82
93
 
83
- case 22:
94
+ case 25:
84
95
  expect(element.querySelector('.k-highlighted')).to.be.null;
85
96
 
86
- case 23:
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';
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;
@@ -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);
@@ -105,7 +105,10 @@ export var Pagination = /*#__PURE__*/function (_Component) {
105
105
 
106
106
  if (page > totalPages) {
107
107
  page = totalPages;
108
- } else if (page < 1) {
108
+ } // perhaps totalPages is 0
109
+
110
+
111
+ if (page < 1) {
109
112
  page = 1;
110
113
  }
111
114
 
@@ -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';
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
  });
@@ -12,6 +12,7 @@ export declare class TooltipContent extends DropdownMenu<TooltipContentProps, To
12
12
  private arrow;
13
13
  init(): void;
14
14
  private onEnter;
15
+ private onAfterLeave;
15
16
  protected onMouseEnter(e: MouseEvent): void;
16
17
  private ok;
17
18
  private cancel;
@@ -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) {
@@ -12,7 +12,9 @@ import ContentDemo from '~/components/tooltip/demos/content';
12
12
  import ConfirmDemo from '~/components/tooltip/demos/confirm';
13
13
  import AlwaysDemo from '~/components/tooltip/demos/always';
14
14
  import { Tooltip } from './';
15
+ import { Dialog } from '../dialog';
15
16
  import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
17
+ import { tooltip as tooltipTheme } from './styles';
16
18
  describe('Tooltip', function () {
17
19
  afterEach(function (done) {
18
20
  unmount();
@@ -577,4 +579,110 @@ describe('Tooltip', function () {
577
579
  }
578
580
  }, _callee9);
579
581
  })));
582
+ it('should add className', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
583
+ var Demo, _mount10, instance, element, trigger, dropdown;
584
+
585
+ return _regeneratorRuntime.wrap(function _callee10$(_context13) {
586
+ while (1) {
587
+ switch (_context13.prev = _context13.next) {
588
+ case 0:
589
+ Demo = /*#__PURE__*/function (_Component3) {
590
+ _inheritsLoose(Demo, _Component3);
591
+
592
+ function Demo() {
593
+ var _context12;
594
+
595
+ var _this3;
596
+
597
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
598
+ args[_key3] = arguments[_key3];
599
+ }
600
+
601
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
602
+ _this3.Tooltip = Tooltip;
603
+ return _this3;
604
+ }
605
+
606
+ return Demo;
607
+ }(Component);
608
+
609
+ Demo.template = "\n const Tooltip = this.Tooltip;\n <div>\n <Tooltip content=\"hello\" class=\"a\">\n <div ref=\"test\" class=\"b\">test</div>\n </Tooltip>\n </div>\n ";
610
+ _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
611
+ trigger = instance.refs.test;
612
+ expect(trigger.className).to.eql('b a');
613
+ dispatchEvent(trigger, 'mouseenter');
614
+ _context13.next = 8;
615
+ return wait();
616
+
617
+ case 8:
618
+ dropdown = getElement('.k-tooltip-content');
619
+ expect(dropdown.classList.contains('a')).to.be.true;
620
+
621
+ case 10:
622
+ case "end":
623
+ return _context13.stop();
624
+ }
625
+ }
626
+ }, _callee10);
627
+ })));
628
+ it('should fix the width in small container', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
629
+ var Demo, _mount11, instance, element, trigger, expecedWidth, content, width, newWidth;
630
+
631
+ return _regeneratorRuntime.wrap(function _callee11$(_context15) {
632
+ while (1) {
633
+ switch (_context15.prev = _context15.next) {
634
+ case 0:
635
+ Demo = /*#__PURE__*/function (_Component4) {
636
+ _inheritsLoose(Demo, _Component4);
637
+
638
+ function Demo() {
639
+ var _context14;
640
+
641
+ var _this4;
642
+
643
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
644
+ args[_key4] = arguments[_key4];
645
+ }
646
+
647
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context14 = [this]).call(_context14, args)) || this;
648
+ _this4.Tooltip = Tooltip;
649
+ _this4.Dialog = Dialog;
650
+ return _this4;
651
+ }
652
+
653
+ return Demo;
654
+ }(Component);
655
+
656
+ Demo.template = "\n const {Tooltip, Dialog} = this;\n <div style=\"text-align: right; position: relative; width: 300px;\">\n <Tooltip content=\"\u8FD9\u662F\u4E00\u6BB5\u5F88\u957F\u7684\u63CF\u8FF0\u6587\u5B57\uFF0C\u8FD9\u662F\u4E00\u6BB5\u5F88\u957F\u7684\u63CF\u8FF0\u6587\u5B57\" container={dom => dom}>\n <span class=\"trigger\">test</span>\n </Tooltip>\n </div>\n ";
657
+ _mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
658
+ trigger = element.querySelector('.trigger');
659
+ expecedWidth = parseInt(tooltipTheme.maxWidth);
660
+ dispatchEvent(trigger, 'mouseenter');
661
+ _context15.next = 8;
662
+ return wait();
663
+
664
+ case 8:
665
+ content = getElement('.k-tooltip-content');
666
+ width = content.offsetWidth;
667
+ expect(width).to.eql(expecedWidth);
668
+ dispatchEvent(trigger, 'mouseleave');
669
+ _context15.next = 14;
670
+ return wait();
671
+
672
+ case 14:
673
+ dispatchEvent(trigger, 'mouseenter');
674
+ _context15.next = 17;
675
+ return wait();
676
+
677
+ case 17:
678
+ newWidth = content.offsetWidth;
679
+ expect(newWidth).to.eql(width);
680
+
681
+ case 19:
682
+ case "end":
683
+ return _context15.stop();
684
+ }
685
+ }
686
+ }, _callee11);
687
+ })));
580
688
  });
@@ -1,4 +1,26 @@
1
1
  import '../../styles/global';
2
+ declare const defaults: {
3
+ padding: string;
4
+ readonly color: string;
5
+ bgColor: string;
6
+ lineHeight: number;
7
+ maxWidth: string;
8
+ arrow: {
9
+ borderColor: string;
10
+ width: string;
11
+ };
12
+ confirm: {
13
+ gaps: string;
14
+ };
15
+ dark: {
16
+ readonly bgColor: string;
17
+ color: string;
18
+ readonly arrowBorderColor: string;
19
+ };
20
+ smallPadding: string;
21
+ };
22
+ export declare let tooltip: typeof defaults;
2
23
  export declare type Theme = 'dark' | 'light';
3
24
  export declare const themes: Theme[];
4
25
  export default function makeStyles(): string;
26
+ export {};
@@ -38,7 +38,7 @@ var defaults = {
38
38
  },
39
39
  smallPadding: '4px'
40
40
  };
41
- var tooltip;
41
+ export var tooltip;
42
42
  setDefault(function () {
43
43
  tooltip = deepDefaults(theme, {
44
44
  tooltip: defaults
@@ -23,5 +23,6 @@ export declare class Tooltip<T extends TooltipProps = TooltipProps, E extends To
23
23
  static typeDefs: Required<TypeDefs<TooltipProps>>;
24
24
  static defaults: () => Partial<TooltipProps>;
25
25
  static events: Events<TooltipEvents>;
26
+ show(shouldFocus?: boolean): void;
26
27
  hide(immediately: boolean): void;
27
28
  }
@@ -25,6 +25,7 @@ var defaults = function defaults() {
25
25
  at: 'center top',
26
26
  collision: 'flipfit'
27
27
  },
28
+ collison: 'flipfit',
28
29
  hoverable: false,
29
30
  always: false,
30
31
  confirm: false,
@@ -48,6 +49,16 @@ export var Tooltip = /*#__PURE__*/function (_Dropdown) {
48
49
 
49
50
  var _proto = Tooltip.prototype;
50
51
 
52
+ _proto.show = function show(shouldFocus) {
53
+ if (shouldFocus === void 0) {
54
+ shouldFocus = false;
55
+ }
56
+
57
+ if (this.get('disabled')) return;
58
+ clearTimeout(this.timer);
59
+ this.set('value', true);
60
+ };
61
+
51
62
  _proto.hide = function hide(immediately) {
52
63
  if (this.get('always')) return;
53
64
 
@@ -0,0 +1,8 @@
1
+ import { Component, VNode } from 'intact';
2
+ export declare class Virtual extends Component<any> {
3
+ static template(this: Virtual): VNode<import("intact").VNodeTag>;
4
+ private vNodeProps;
5
+ private getVNodeProps;
6
+ private getEventProps;
7
+ private callEvent;
8
+ }
@@ -0,0 +1,126 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime-corejs3/helpers/objectWithoutPropertiesLoose";
3
+ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
4
+ var _excluded = ["children"];
5
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
6
+ import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js/instance/starts-with";
7
+ import { Component, directClone, createVNode } from 'intact';
8
+ import { isTextChildren } from './utils';
9
+ import { EMPTY_OBJ, isFunction, hasOwn } from 'intact-shared';
10
+ import { cx } from '@emotion/css';
11
+ var reactEventReg = /on[A-Z]/;
12
+ export var Virtual = /*#__PURE__*/function (_Component) {
13
+ _inheritsLoose(Virtual, _Component);
14
+
15
+ function Virtual() {
16
+ var _context;
17
+
18
+ var _this;
19
+
20
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
+ args[_key] = arguments[_key];
22
+ }
23
+
24
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
25
+ _this.vNodeProps = null;
26
+ return _this;
27
+ }
28
+
29
+ Virtual.template = function template() {
30
+ var _cx;
31
+
32
+ var _this$get = this.get(),
33
+ children = _this$get.children,
34
+ props = _objectWithoutPropertiesLoose(_this$get, _excluded);
35
+
36
+ if (process.env.NODE_ENV !== 'production') {
37
+ if (!children || Array.isArray(children) && children.length !== 1) {
38
+ throw new Error('Component must receive one children');
39
+ }
40
+ }
41
+
42
+ var vNode = Array.isArray(children) ? children[0] : children;
43
+ var clonedVNode = isTextChildren(vNode) ? createVNode('span', null, vNode) : directClone(vNode);
44
+ var vNodeProps = this.vNodeProps = this.getVNodeProps(clonedVNode.props || EMPTY_OBJ);
45
+ var eventProps = this.getEventProps(); // merge className
46
+
47
+ var className = clonedVNode.className || vNodeProps.className;
48
+ className = cx((_cx = {}, _cx[className] = !!className, _cx[props.className] = !!props.className, _cx));
49
+ clonedVNode.props = _extends({}, props, vNodeProps, eventProps, {
50
+ className: className
51
+ });
52
+ clonedVNode.className = className;
53
+ return clonedVNode;
54
+ };
55
+
56
+ var _proto = Virtual.prototype;
57
+
58
+ _proto.getVNodeProps = function getVNodeProps(props) {
59
+ var vnode = props.vnode;
60
+ if (!vnode) return props; // maybe we render the intact component in react slot property, in this case
61
+ // the $isReact is false. so use the vnode $$typeof field as gauge
62
+
63
+ if (vnode.$$typeof || vnode.__v_isVNode
64
+ /* vue3 vnode */
65
+ ) {
66
+ var _props = vnode.props;
67
+ if (!_props) return props;
68
+ var events = {};
69
+
70
+ for (var key in _props) {
71
+ if (reactEventReg.test(key)) {
72
+ events["ev-" + key.substring(2).toLowerCase()] = _props[key];
73
+ }
74
+ }
75
+
76
+ return _extends({}, props, events, {
77
+ className: _props.className || _props.class
78
+ /* vue-next */
79
+
80
+ });
81
+ } else if (hasOwn.call(vnode, 'componentOptions')
82
+ /* vue2 vnode */
83
+ ) {
84
+ var data = vnode.data;
85
+ var on = data && data.on || EMPTY_OBJ;
86
+ var _events = {};
87
+
88
+ for (var _key2 in on) {
89
+ _events["ev-" + _key2] = on[_key2];
90
+ }
91
+
92
+ return _extends({}, props, _events);
93
+ }
94
+
95
+ return props;
96
+ };
97
+
98
+ _proto.getEventProps = function getEventProps() {
99
+ var _this2 = this;
100
+
101
+ var props = {};
102
+
103
+ var _loop = function _loop(prop) {
104
+ if (_startsWithInstanceProperty(prop).call(prop, 'ev-')) {
105
+ props[prop] = function (e) {
106
+ return _this2.callEvent(prop, e);
107
+ };
108
+ }
109
+ };
110
+
111
+ for (var prop in this.get()) {
112
+ _loop(prop);
113
+ }
114
+
115
+ return props;
116
+ };
117
+
118
+ _proto.callEvent = function callEvent(name, e) {
119
+ var callback = this.vNodeProps[name];
120
+ var callbackOnVirtual = this.get(name);
121
+ if (isFunction(callback)) callback(e);
122
+ if (isFunction(callbackOnVirtual)) callbackOnVirtual(e);
123
+ };
124
+
125
+ return Virtual;
126
+ }(Component);
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.1.0
2
+ * @king-design v2.1.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -57,4 +57,4 @@ export * from './components/tree';
57
57
  export * from './components/treeSelect';
58
58
  export * from './components/upload';
59
59
  export * from './components/wave';
60
- export declare const version = "2.1.0";
60
+ export declare const version = "2.1.1";
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.1.0
2
+ * @king-design v2.1.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -59,5 +59,5 @@ export * from './components/tree';
59
59
  export * from './components/treeSelect';
60
60
  export * from './components/upload';
61
61
  export * from './components/wave';
62
- export var version = '2.1.0';
62
+ export var version = '2.1.1';
63
63
  /* generate end */
@@ -50,10 +50,7 @@ var Demo = /*#__PURE__*/function (_React$Component) {
50
50
  ref: function ref(i) {
51
51
  return _this2.__demo = i;
52
52
  }
53
- }, "Dialog Body", this.state.show ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, {
54
- filterable: true,
55
- multiple: true
56
- })) : undefined));
53
+ }, "Dialog Body", /*#__PURE__*/React.createElement(Select, null)));
57
54
  };
58
55
 
59
56
  return Demo;
@@ -16,7 +16,7 @@ var default_1 = /*#__PURE__*/function (_Component) {
16
16
  return {
17
17
  expandedKeys: ['3'],
18
18
  selectedKey: '3-2',
19
- collapse: false,
19
+ collapse: true,
20
20
  theme: 'dark'
21
21
  };
22
22
  };
@@ -21,7 +21,7 @@ var Demo = /*#__PURE__*/function (_React$Component) {
21
21
  _this.state = {
22
22
  expandedKeys: ['3'],
23
23
  selectedKey: '3-2',
24
- collapse: false,
24
+ collapse: true,
25
25
  theme: 'dark'
26
26
  };
27
27
  _this.__test = void 0;
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.1.0
2
+ * @king-design v2.1.1
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -62,6 +62,6 @@ export * from './components/treeSelect';
62
62
  export * from './components/upload';
63
63
  export * from './components/wave';
64
64
 
65
- export const version = '2.1.0';
65
+ export const version = '2.1.1';
66
66
 
67
67
  /* generate end */