@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.
@@ -12,7 +12,10 @@ 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';
18
+ import { Select, Option } from '../select';
16
19
  describe('Tooltip', function () {
17
20
  afterEach(function (done) {
18
21
  unmount();
@@ -577,4 +580,166 @@ describe('Tooltip', function () {
577
580
  }
578
581
  }, _callee9);
579
582
  })));
583
+ it('should add className', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
584
+ var Demo, _mount10, instance, element, trigger, dropdown;
585
+
586
+ return _regeneratorRuntime.wrap(function _callee10$(_context13) {
587
+ while (1) {
588
+ switch (_context13.prev = _context13.next) {
589
+ case 0:
590
+ Demo = /*#__PURE__*/function (_Component3) {
591
+ _inheritsLoose(Demo, _Component3);
592
+
593
+ function Demo() {
594
+ var _context12;
595
+
596
+ var _this3;
597
+
598
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
599
+ args[_key3] = arguments[_key3];
600
+ }
601
+
602
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
603
+ _this3.Tooltip = Tooltip;
604
+ return _this3;
605
+ }
606
+
607
+ return Demo;
608
+ }(Component);
609
+
610
+ 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 ";
611
+ _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
612
+ trigger = instance.refs.test;
613
+ expect(trigger.className).to.eql('b a');
614
+ dispatchEvent(trigger, 'mouseenter');
615
+ _context13.next = 8;
616
+ return wait();
617
+
618
+ case 8:
619
+ dropdown = getElement('.k-tooltip-content');
620
+ expect(dropdown.classList.contains('a')).to.be.true;
621
+
622
+ case 10:
623
+ case "end":
624
+ return _context13.stop();
625
+ }
626
+ }
627
+ }, _callee10);
628
+ })));
629
+ it('should fix the width in small container', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
630
+ var Demo, _mount11, instance, element, trigger, expecedWidth, content, width, newWidth;
631
+
632
+ return _regeneratorRuntime.wrap(function _callee11$(_context15) {
633
+ while (1) {
634
+ switch (_context15.prev = _context15.next) {
635
+ case 0:
636
+ Demo = /*#__PURE__*/function (_Component4) {
637
+ _inheritsLoose(Demo, _Component4);
638
+
639
+ function Demo() {
640
+ var _context14;
641
+
642
+ var _this4;
643
+
644
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
645
+ args[_key4] = arguments[_key4];
646
+ }
647
+
648
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context14 = [this]).call(_context14, args)) || this;
649
+ _this4.Tooltip = Tooltip;
650
+ _this4.Dialog = Dialog;
651
+ return _this4;
652
+ }
653
+
654
+ return Demo;
655
+ }(Component);
656
+
657
+ 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 ";
658
+ _mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
659
+ trigger = element.querySelector('.trigger');
660
+ expecedWidth = parseInt(tooltipTheme.maxWidth);
661
+ dispatchEvent(trigger, 'mouseenter');
662
+ _context15.next = 8;
663
+ return wait();
664
+
665
+ case 8:
666
+ content = getElement('.k-tooltip-content');
667
+ width = content.offsetWidth;
668
+ expect(width).to.eql(expecedWidth);
669
+ dispatchEvent(trigger, 'mouseleave');
670
+ _context15.next = 14;
671
+ return wait();
672
+
673
+ case 14:
674
+ dispatchEvent(trigger, 'mouseenter');
675
+ _context15.next = 17;
676
+ return wait();
677
+
678
+ case 17:
679
+ newWidth = content.offsetWidth;
680
+ expect(newWidth).to.eql(width);
681
+
682
+ case 19:
683
+ case "end":
684
+ return _context15.stop();
685
+ }
686
+ }
687
+ }, _callee11);
688
+ })));
689
+ it('should not impact select when wrap select with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
690
+ var Demo, _mount12, instance, element, menu;
691
+
692
+ return _regeneratorRuntime.wrap(function _callee12$(_context17) {
693
+ while (1) {
694
+ switch (_context17.prev = _context17.next) {
695
+ case 0:
696
+ Demo = /*#__PURE__*/function (_Component5) {
697
+ _inheritsLoose(Demo, _Component5);
698
+
699
+ function Demo() {
700
+ var _context16;
701
+
702
+ var _this5;
703
+
704
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
705
+ args[_key5] = arguments[_key5];
706
+ }
707
+
708
+ _this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context16 = [this]).call(_context16, args)) || this;
709
+ _this5.Tooltip = Tooltip;
710
+ _this5.Select = Select;
711
+ _this5.Option = Option;
712
+ return _this5;
713
+ }
714
+
715
+ return Demo;
716
+ }(Component);
717
+
718
+ Demo.template = "\n const {Tooltip, Select, Option} = this;\n <Tooltip>\n <Select>\n <Option value=\"1\">Option 1</Option>\n <Option value=\"2\">Option 2</Option>\n </Select>\n </Tooltip>\n ";
719
+ _mount12 = mount(Demo), instance = _mount12[0], element = _mount12[1];
720
+ dispatchEvent(element, 'mouseenter');
721
+ _context17.next = 6;
722
+ return wait();
723
+
724
+ case 6:
725
+ dispatchEvent(element, 'click');
726
+ _context17.next = 9;
727
+ return wait();
728
+
729
+ case 9:
730
+ menu = getElement(".k-select-menu");
731
+ dispatchEvent(element, 'mouseleave');
732
+ _context17.next = 13;
733
+ return wait(500);
734
+
735
+ case 13:
736
+ expect(menu.style.display).to.eql('');
737
+
738
+ case 14:
739
+ case "end":
740
+ return _context17.stop();
741
+ }
742
+ }
743
+ }, _callee12);
744
+ })));
580
745
  });
@@ -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,12 +49,26 @@ 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
 
54
65
  if (this.get('hoverable')) {
55
66
  return _Dropdown.prototype.hide.call(this, immediately);
56
- }
67
+ } // tooltip can show any number sub-tooltips, we should not close the showed tooltip
68
+ // #885
69
+
70
+
71
+ this.showedDropdown = null;
57
72
 
58
73
  _Dropdown.prototype.hide.call(this, true);
59
74
  };
@@ -0,0 +1,8 @@
1
+ import { Component, VNode } from 'intact-vue-next';
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-vue-next';
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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.1.0
2
+ * @king-design v2.1.2
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -57,7 +57,7 @@ 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.2";
61
61
 
62
62
 
63
63
  export {normalize} from 'intact-vue-next';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.1.0
2
+ * @king-design v2.1.2
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -59,7 +59,7 @@ 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.2';
63
63
  /* generate end */
64
64
 
65
65
  export {normalize} from 'intact-vue-next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/vue",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "King-Design UI components for Vue3.0.",
5
5
  "keywords": [
6
6
  "component",
@@ -38,7 +38,7 @@
38
38
  "dayjs": "^1.10.7",
39
39
  "downloadjs": "^1.4.7",
40
40
  "enquire.js": "^2.1.6",
41
- "intact-vue-next": "^3.0.18",
41
+ "intact-vue-next": "3.0.19",
42
42
  "monaco-editor": "^0.26.1",
43
43
  "mxgraphx": "^4.0.7",
44
44
  "resize-observer-polyfill": "^1.5.1",