@king-design/vue 3.1.0-beta.2 → 3.1.0-beta.3

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.
@@ -7,6 +7,7 @@ export interface CopyProps {
7
7
  export interface CopyEvents {
8
8
  success: [string];
9
9
  error: [];
10
+ click: [MouseEvent];
10
11
  }
11
12
  export declare class Copy extends Component<CopyProps, CopyEvents> {
12
13
  static template: string | import("intact").Template<any>;
@@ -17,7 +17,8 @@ var defaults = function defaults() {
17
17
 
18
18
  var events = {
19
19
  success: true,
20
- error: true
20
+ error: true,
21
+ click: true
21
22
  };
22
23
  export var Copy = /*#__PURE__*/function (_Component) {
23
24
  _inheritsLoose(Copy, _Component);
@@ -1,7 +1,12 @@
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/copy/demos/basic';
4
- import { mount, unmount } from '../../test/utils';
6
+ import { mount, unmount, wait } from '../../test/utils';
7
+ import { Tooltip } from '../tooltip';
8
+ import { Component } from 'intact-vue-next';
9
+ import { Copy } from '.';
5
10
  describe('Copy', function () {
6
11
  afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
7
12
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -49,4 +54,62 @@ describe('Copy', function () {
49
54
  }
50
55
  }, _callee2, null, [[2, 9]]);
51
56
  })));
57
+ it('wrap copy with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
58
+ var Demo, _mount2, instance, element, text;
59
+
60
+ return _regeneratorRuntime.wrap(function _callee3$(_context4) {
61
+ while (1) {
62
+ switch (_context4.prev = _context4.next) {
63
+ case 0:
64
+ Demo = /*#__PURE__*/function (_Component) {
65
+ _inheritsLoose(Demo, _Component);
66
+
67
+ function Demo() {
68
+ var _context3;
69
+
70
+ var _this;
71
+
72
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
+ args[_key] = arguments[_key];
74
+ }
75
+
76
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
77
+ _this.Tooltip = Tooltip;
78
+ _this.Copy = Copy;
79
+ return _this;
80
+ }
81
+
82
+ return Demo;
83
+ }(Component);
84
+
85
+ Demo.template = "\n const { Tooltip, Copy } = this;\n <Tooltip content=\"test\">\n <Copy text=\"test\" />\n </Tooltip>\n ";
86
+ _mount2 = mount(Demo), instance = _mount2[0], element = _mount2[1];
87
+ element.click();
88
+ _context4.next = 6;
89
+ return wait();
90
+
91
+ case 6:
92
+ _context4.prev = 6;
93
+ _context4.next = 9;
94
+ return navigator.clipboard.readText();
95
+
96
+ case 9:
97
+ text = _context4.sent;
98
+ expect(text).to.eql('test');
99
+ _context4.next = 16;
100
+ break;
101
+
102
+ case 13:
103
+ _context4.prev = 13;
104
+ _context4.t0 = _context4["catch"](6);
105
+ // Read permisson denied
106
+ console.log(_context4.t0);
107
+
108
+ case 16:
109
+ case "end":
110
+ return _context4.stop();
111
+ }
112
+ }
113
+ }, _callee3, null, [[6, 13]]);
114
+ })));
52
115
  });
@@ -1,4 +1,4 @@
1
1
  export declare function useCopy(): {
2
- startCopy: () => void;
2
+ startCopy: (e: MouseEvent) => void;
3
3
  success: import("../../hooks/useState").State<boolean>;
4
4
  };
@@ -8,7 +8,7 @@ export function useCopy() {
8
8
  var success = useState(false);
9
9
  var timer;
10
10
  return {
11
- startCopy: function startCopy() {
11
+ startCopy: function startCopy(e) {
12
12
  var _instance$get = instance.get(),
13
13
  text = _instance$get.text,
14
14
  showMessage = _instance$get.showMessage;
@@ -30,6 +30,8 @@ export function useCopy() {
30
30
  success.set(false);
31
31
  instance.trigger('error');
32
32
  }
33
+
34
+ instance.trigger('click', e);
33
35
  },
34
36
  success: success
35
37
  };
@@ -142,7 +142,7 @@ export var BaseDialog = /*#__PURE__*/function (_Component) {
142
142
  };
143
143
 
144
144
  _proto.onClickWrapper = function onClickWrapper(e) {
145
- if (this.get('closable')) {
145
+ if (this.get('closable') && e.target === this.overlayRef.value) {
146
146
  this.terminate();
147
147
  }
148
148
  };
@@ -123,15 +123,15 @@ export default function ($props, $blocks, $__proto__) {
123
123
 
124
124
  return _$cc(Portal, {
125
125
  'container': container,
126
- 'children': _$ce(2, 'div', [overlay ? _$cc(Transition, {
126
+ 'children': _$ce(2, 'div', overlay ? _$cc(Transition, {
127
127
  'key': 'overlay',
128
128
  'show': overlay ? value : false,
129
129
  'appear': value,
130
130
  'name': 'k-fade',
131
- 'children': _$ce(2, 'div', null, 1, _$cn(k + "-dialog-overlay"), {
131
+ 'children': _$ce(2, 'div', dialog, 0, _$cn(k + "-dialog-overlay"), {
132
132
  'ev-click': this.onClickWrapper
133
133
  }, null, this.overlayRef)
134
- }, 'overlay') : undefined, dialog], 0, _$cn((_$cn2 = {}, _$cn2[k + "-dialog-wrapper"] = true, _$cn2[k + "-open"] = value, _$cn2[makeWrapperStyles(k)] = true, _$cn2)))
134
+ }, 'overlay') : dialog, 0, _$cn((_$cn2 = {}, _$cn2[k + "-dialog-wrapper"] = true, _$cn2[k + "-open"] = value, _$cn2[makeWrapperStyles(k)] = true, _$cn2)))
135
135
  });
136
136
  }
137
137
  ;
@@ -92,7 +92,7 @@ export function makeDialogStyles(k) {
92
92
  export function makeWrapperStyles(k) {
93
93
  //.${k}-fade-leave-active will add position absolute to the styles
94
94
  // so we must set fixed with important to .${k}-dialog-overlay
95
- return /*#__PURE__*/css("position:absolute;z-index:", theme.maxZIndex, ";top:0;left:0;width:100%;.", k, "-dialog-overlay{position:fixed!important;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, .5);}");
95
+ return /*#__PURE__*/css("position:absolute;z-index:", theme.maxZIndex, ";top:0;left:0;width:100%;.", k, "-dialog-overlay{position:fixed!important;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, .5);overflow:auto;}");
96
96
  }
97
97
  export function makeAlertStyles(k) {
98
98
  var _context2;
@@ -7,7 +7,7 @@ import { Icon } from '../icon';
7
7
  import { Menu } from './menu';
8
8
  import { getRestProps, expandAnimationCallbacks } from '../utils';
9
9
  import { isNullOrUndefined } from 'intact-shared';
10
- import { makeItemStyles, makeTitleStyles } from './styles';
10
+ import { makeItemStyles, makeTitleStyles, makeNestedMenuStyles } from './styles';
11
11
  export default function ($props, $blocks, $__proto__) {
12
12
  var _classNameObj,
13
13
  _this = this;
@@ -67,7 +67,27 @@ export default function ($props, $blocks, $__proto__) {
67
67
  'show': isExpanded,
68
68
  'key': 'subMenu'
69
69
  }, expandAnimationCallbacks, {
70
- 'children': subMenuVNode
70
+ 'children': function () {
71
+ if (subMenuVNode) {
72
+ var _$cn3;
73
+
74
+ var paddingLeft = _this.parentMenu.get('_paddingLeft');
75
+
76
+ var _makeNestedMenuStyles = makeNestedMenuStyles(k, showDot || !!iconVNode, paddingLeft),
77
+ _classname = _makeNestedMenuStyles[0],
78
+ _paddingLeft = _makeNestedMenuStyles[1];
79
+
80
+ var _className = _$cn((_$cn3 = {}, _$cn3[_classname] = true, _$cn3[subMenuVNode.className] = subMenuVNode.className, _$cn3));
81
+
82
+ var clonedVNode = directClone(subMenuVNode);
83
+ clonedVNode.props = _extends({}, clonedVNode.props, {
84
+ className: _className,
85
+ _paddingLeft: _paddingLeft
86
+ });
87
+ clonedVNode.className = _className;
88
+ return clonedVNode;
89
+ }
90
+ }()
71
91
  }), 'subMenu')] : !subMenuVNode ? isTopItem && isCollapse ? _$cc(Tooltip, {
72
92
  'position': rootMenu.get('type') !== 'horizontal' ? 'right' : 'bottom',
73
93
  'theme': rootMenu.get('theme') === 'dark' ? 'dark' : 'light',
@@ -9,6 +9,7 @@ export interface MenuProps<K extends Key = Key> {
9
9
  size?: 'large' | 'default' | 'small';
10
10
  accordion?: boolean;
11
11
  dot?: boolean;
12
+ _paddingLeft?: string;
12
13
  }
13
14
  export interface MenuEvents {
14
15
  }
@@ -12,7 +12,8 @@ var typeDefs = {
12
12
  type: ['vertical', 'horizontal'],
13
13
  size: ['large', 'default', 'small'],
14
14
  accordion: Boolean,
15
- dot: Boolean
15
+ dot: Boolean,
16
+ _paddingLeft: String
16
17
  };
17
18
 
18
19
  var defaults = function defaults() {
@@ -44,7 +44,7 @@ export default function ($props, $blocks, $__proto__) {
44
44
  }), 0, _$cn((_$cn2 = {}, _$cn2[k + "-menu-header"] = true, _$cn2[makeTitleStyles(k)] = true, _$cn2))) : undefined, children];
45
45
  return !isDropdownMenu ? _$cv('div', _extends({}, getRestProps(this), {
46
46
  'className': _$cn(classNameObj)
47
- }), [content, null]) : _$cc(DropdownMenu, _extends({}, getRestProps(this), {
47
+ }), content) : _$cc(DropdownMenu, _extends({}, getRestProps(this), {
48
48
  'className': _$cn(classNameObj),
49
49
  'children': content
50
50
  }));
@@ -65,3 +65,4 @@ export { menu };
65
65
  export declare function makeMenuStyles(k: string): string;
66
66
  export declare function makeTitleStyles(k: string): string;
67
67
  export declare function makeItemStyles(k: string): string;
68
+ export declare function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingLeft?: string): string[];
@@ -122,7 +122,7 @@ export function makeMenuStyles(k) {
122
122
 
123
123
  // we must increase the priority by adding &.${k}-menu
124
124
  // to override the css of dropdownMenu
125
- return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";}&:not(.", k, "-dropdown-menu) &:not(.", k, "-dropdown-menu){width:auto;background:", menu.subBgColor, ";.", k, "-menu-title{padding-left:calc(", getLeft(menu.item.padding), " + ", menu.icon.width, " + ", menu.icon.gap, ");}}&:not(.", k, "-dropdown-menu) &:not(.", k, "-dropdown-menu) &:not(.", k, "-dropdown-menu){.", k, "-menu-title{padding-left:calc(", getLeft(menu.item.padding), " + ", menu.icon.width, " * 2 + ", menu.icon.gap, ");}}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";font-size:", menu.header.fontSize, ";font-weight:bold;border-bottom:", menu.header.borderBottom, ";}", _mapInstanceProperty(_context = ['light', 'white']).call(_context, function (theme) {
125
+ return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";font-size:", menu.header.fontSize, ";font-weight:bold;border-bottom:", menu.header.borderBottom, ";}", _mapInstanceProperty(_context = ['light', 'white']).call(_context, function (theme) {
126
126
  var styles = menu[theme];
127
127
  return /*#__PURE__*/css("&.", k, "-", theme, "{background:", styles.bgColor, ";.", k, "-menu-header{color:", styles.item.color, ";border-bottom:", styles.border, ";}.", k, "-menu-item{.", k, "-menu-title{color:", styles.item.color, ";&:hover{color:", styles.item.hoverColor, ";}}&.", k, "-highlighted{>.", k, "-menu-title{color:", styles.item.hoverColor, ";}}&.", k, "-disabled{>.", k, "-menu-title{color:", styles.item.disabledColor, "!important;}}}.", k, "-menu:not(.", k, "-dropdown-menu){background:", styles.subBgColor, ";}&.", k, "-horizontal{.", k, "-menu-header{border-right:", styles.border, ";}}}");
128
128
  }), " &.", k, "-white{.", k, "-menu-item.", k, "-active{>.", k, "-menu-title{color:", menu.white.active.color, "!important;background:", menu.white.active.bgColor, ";}}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
@@ -136,5 +136,13 @@ export function makeTitleStyles(k) {
136
136
  }
137
137
  export function makeItemStyles(k) {
138
138
  var item = menu.item;
139
- return /*#__PURE__*/css(".", k, "-menu-title{cursor:pointer;height:", menu.item.height, ";transition:all ", menu.transition, ";&:hover{color:", menu.item.hoverColor, ";}}.", k, "-menu-name{flex:1;display:flex;align-items:center;min-width:0;span{overflow:hidden;text-overflow:ellipsis;min-width:0;}}.", k, "-menu-arrow{transition:transform ", menu.transition, ";margin:0 0 0 ", menu.icon.gap, ";}&.", k, "-expanded{>.", k, "-menu-title{color:", menu.item.hoverColor, ";.", k, "-menu-arrow{transform:rotateX(180deg);}}}&.", k, "-highlighted{>.", k, "-menu-title{color:", menu.item.hoverColor, ";}}&.", k, "-active{>.", k, "-menu-title{color:", menu.item.hoverColor, "!important;background:", menu.item.activeBgColor, ";}}&.", k, "-disabled{>.", k, "-menu-title{color:", menu.item.disabledColor, "!important;cursor:not-allowed;}}.", k, "-menu-dot{font-size:", menu.item.dotFontSize, ";transform:scale(.4);}");
139
+ return /*#__PURE__*/css(".", k, "-menu-title{cursor:pointer;height:", menu.item.height, ";&:hover{color:", menu.item.hoverColor, ";}}.", k, "-menu-name{flex:1;display:flex;align-items:center;min-width:0;span{overflow:hidden;text-overflow:ellipsis;min-width:0;}.", k, "-icon{color:inherit;}}.", k, "-menu-arrow{transition:transform ", menu.transition, ";margin:0 0 0 ", menu.icon.gap, ";}&.", k, "-expanded{>.", k, "-menu-title{color:", menu.item.hoverColor, ";.", k, "-menu-arrow{transform:rotateX(180deg);}}}&.", k, "-highlighted{>.", k, "-menu-title{color:", menu.item.hoverColor, ";}}&.", k, "-active{>.", k, "-menu-title{color:", menu.item.hoverColor, "!important;background:", menu.item.activeBgColor, ";}}&.", k, "-disabled{>.", k, "-menu-title{color:", menu.item.disabledColor, "!important;cursor:not-allowed;}}.", k, "-menu-dot{font-size:", menu.item.dotFontSize, ";transform:scale(.4);}");
140
+ }
141
+ export function makeNestedMenuStyles(k, hasIcon, parentPaddingLeft) {
142
+ if (parentPaddingLeft === void 0) {
143
+ parentPaddingLeft = getLeft(menu.item.padding);
144
+ }
145
+
146
+ var paddingLeft = "" + parentPaddingLeft + (hasIcon ? ' + ' + menu.icon.width : '') + " + " + menu.icon.gap;
147
+ return [/*#__PURE__*/css("&.", k, "-menu{width:auto;background:", menu.subBgColor, ";.", k, "-menu-title{padding-left:calc(", paddingLeft, ");}}"), paddingLeft];
140
148
  }
@@ -31,16 +31,13 @@ export function useDropdown(rootMenu, parentMenu) {
31
31
  eachChildren(children, function (vNode) {
32
32
  if (isComponentVNode(vNode, Menu)) {
33
33
  subMenuVNode = vNode;
34
- } else if (isTopItem && isCollapse) {
35
- if (isStringOrNumberNotEmpty(vNode) || isTextVNode(vNode)) {
36
- tooltipContents.push(vNode);
37
- } else if (!iconVNode && isComponentVNode(vNode, Icon)) {
38
- iconVNode = vNode;
39
- }
40
34
  } else {
41
35
  if (isStringOrNumberNotEmpty(vNode) || isTextVNode(vNode)) {
42
36
  // wrap with span for showing text ellipsis
43
37
  vNode = createVNode('span', null, vNode);
38
+ tooltipContents.push(vNode);
39
+ } else if (!iconVNode && isComponentVNode(vNode, Icon)) {
40
+ iconVNode = vNode;
44
41
  }
45
42
 
46
43
  titleVNodes.push(vNode);
@@ -62,7 +62,7 @@ export default function ($props, $blocks, $__proto__) {
62
62
  }, getClassAndStyleForFixed({
63
63
  fixed: hasFixedLeft ? 'left' : false,
64
64
  className: [k + "-table-check"]
65
- }, 0), spans), children));
65
+ }, 0, k), spans), children));
66
66
  };
67
67
 
68
68
  if (checkType === 'checkbox') {
@@ -131,7 +131,7 @@ export default function ($props, $blocks, $__proto__) {
131
131
  return _$ce(2, 'tr', function () {
132
132
  var ths = [$key === 0 && checkType !== 'none' ? _$cv('th', _extends({}, getClassAndStyleForFixed({
133
133
  fixed: hasFixedLeft ? 'left' : false
134
- }, 0), {
134
+ }, 0, k), {
135
135
  'rowspan': maxRows,
136
136
  'key': '$checktype'
137
137
  }), checkType === 'checkbox' ? _$cc(Checkbox, {
@@ -2,7 +2,8 @@ import { Component, Key, TypeDefs } from 'intact-vue-next';
2
2
  import { DataItem, Node } from './useNodes';
3
3
  import { Mode } from './useDraggable';
4
4
  import type { Events } from '../types';
5
- export type { Node as TreeNode, DataItem as TreeDataItem, Mode as TreeMode, };
5
+ export type { Node as TreeNode, DataItem as TreeDataItem, };
6
+ export { Mode as TreeMode };
6
7
  export interface TreeProps<K extends Key = Key> {
7
8
  data?: DataItem<K>[];
8
9
  filter?: Filter<K>;
@@ -18,11 +19,11 @@ export interface TreeProps<K extends Key = Key> {
18
19
  showLine?: boolean;
19
20
  draggable?: boolean;
20
21
  allowDrag?: (node: Node<K>) => boolean;
21
- allowDrop?: (node: Node<K>) => boolean;
22
+ allowDrop?: (node: Node<K>, srcNode: Node<K>, mode: Mode) => boolean;
22
23
  }
23
24
  export interface TreeEvents<K extends Key> {
24
25
  denydrag: [Node<K>];
25
- denydrop: [Node<K>];
26
+ denydrop: [Node<K>, Node<K>, Mode];
26
27
  dragend: [DragEndData<K>];
27
28
  transitionEnd: [];
28
29
  }
@@ -54,5 +55,6 @@ export declare class Tree<K extends Key = Key> extends Component<TreeProps<K>, T
54
55
  expand(key: K): void;
55
56
  shrink(key: K): void;
56
57
  getNodes(): Node<K>[];
58
+ expandAll(): void;
57
59
  private onClick;
58
60
  }
@@ -13,6 +13,7 @@ import { useFilter } from './useFilter';
13
13
  import { useDraggable, Mode } from './useDraggable';
14
14
  import { useTransitionEvent } from './useTransitionEvent';
15
15
  import { useConfigContext } from '../config';
16
+ export { Mode as TreeMode };
16
17
  var typeDefs = {
17
18
  data: Array,
18
19
  filter: Function,
@@ -98,6 +99,10 @@ export var Tree = /*#__PURE__*/function (_Component) {
98
99
  return this.nodes.getNodes();
99
100
  };
100
101
 
102
+ _proto.expandAll = function expandAll() {
103
+ this.expanded.expandAll();
104
+ };
105
+
101
106
  _proto.onClick = function onClick(node) {
102
107
  if (node.data.disabled) return;
103
108
 
@@ -306,7 +306,7 @@ describe('Tree', function () {
306
306
  }, _callee6);
307
307
  })));
308
308
  it('draggable', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
309
- var onDenyDrag, onDenyDrop, onDragEnd, _mount7, instance, element, disabled, nodes, notAllowed;
309
+ var onDenyDrag, onDenyDrop, onDragEnd, _mount7, instance, element, _element$querySelecto13, notAllowed, file1, file2, dir1, file3, dir2, disabled;
310
310
 
311
311
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
312
312
  while (1) {
@@ -320,53 +320,74 @@ describe('Tree', function () {
320
320
  DraggableDemo.prototype.onDenyDrop = onDenyDrop;
321
321
  DraggableDemo.prototype.onDragEnd = onDragEnd;
322
322
  _mount7 = mount(DraggableDemo), instance = _mount7[0], element = _mount7[1];
323
- instance.set('expandedKeys', ['2', '2-1', '1', '1-1']);
323
+ instance.set('expandedKeys', ['guide']);
324
324
  _context7.next = 11;
325
325
  return wait(500);
326
326
 
327
327
  case 11:
328
- // can not drag disabled item
329
- disabled = element.querySelector('.k-disabled'); // dispatchEvent(disabled, 'mousedown');
328
+ _element$querySelecto13 = element.querySelectorAll('.k-tree-label'), notAllowed = _element$querySelecto13[0], file1 = _element$querySelecto13[1], file2 = _element$querySelecto13[2], dir1 = _element$querySelecto13[3], file3 = _element$querySelecto13[4], dir2 = _element$querySelecto13[5], disabled = _element$querySelecto13[6]; // can not drag disabled item
330
329
 
331
330
  dispatchEvent(disabled, 'dragstart');
332
- expect(onDenyDrag.callCount).to.eql(1);
333
- nodes = element.querySelectorAll('.k-tree-label'); // can not drag not-allowed item
334
-
335
- notAllowed = nodes[2]; // dispatchEvent(notAllowed, 'mousedown');
331
+ expect(onDenyDrag.callCount).to.eql(1); // can not drag not-allowed item
336
332
 
337
333
  dispatchEvent(notAllowed, 'dragstart');
338
- expect(onDenyDrag.callCount).to.eql(2); // drag insert
339
-
340
- return _context7.abrupt("return", dragInsert(nodes[6], nodes[6]).then(function () {
341
- // drag to self will do nothing
342
- expect(element.innerHTML).to.matchSnapshot();
343
- expect(onDragEnd.callCount).to.eql(0);
344
- return dragInsert(nodes[6], notAllowed);
345
- }).then(function () {
346
- // drag to not-allowed item will do nothing
347
- expect(element.innerHTML).to.matchSnapshot();
348
- expect(onDragEnd.callCount).to.eql(0);
349
- return dragInsert(nodes[6], disabled);
350
- }).then(function () {
351
- // drag to disabled item will do nothing
352
- expect(element.innerHTML).to.matchSnapshot();
353
- expect(onDragEnd.callCount).to.eql(0);
354
- return dragInsert(nodes[6], nodes[5], 'before');
355
- }).then(function () {
356
- expect(element.innerHTML).to.matchSnapshot();
357
- expect(onDragEnd.callCount).to.eql(1);
358
- expect(instance.get('data')).to.matchSnapshot();
359
- return dragInsert(nodes[6], nodes[5], 'after');
360
- }).then(function () {
361
- expect(element.innerHTML).to.matchSnapshot();
362
- expect(instance.get('data')).to.matchSnapshot();
363
- return dragInsert(nodes[6], nodes[5]);
364
- }).then(function () {
365
- expect(element.innerHTML).to.matchSnapshot();
366
- expect(instance.get('data')).to.matchSnapshot();
367
- }));
334
+ expect(onDenyDrag.callCount).to.eql(2);
335
+ _context7.next = 18;
336
+ return dragInsert(dir1, dir1);
337
+
338
+ case 18:
339
+ // drag to self will do nothing
340
+ expect(element.innerHTML).to.matchSnapshot();
341
+ expect(onDragEnd.callCount).to.eql(0);
342
+ _context7.next = 22;
343
+ return dragInsert(file1, notAllowed);
344
+
345
+ case 22:
346
+ // drag to not-allowed item will do nothing
347
+ expect(element.innerHTML).to.matchSnapshot();
348
+ expect(onDragEnd.callCount).to.eql(0);
349
+ _context7.next = 26;
350
+ return dragInsert(file1, disabled);
368
351
 
369
- case 19:
352
+ case 26:
353
+ // drag to disabled item will do nothing
354
+ expect(element.innerHTML).to.matchSnapshot();
355
+ expect(onDragEnd.callCount).to.eql(0);
356
+ _context7.next = 30;
357
+ return dragInsert(file2, file1, 'before');
358
+
359
+ case 30:
360
+ expect(element.innerHTML).to.matchSnapshot();
361
+ expect(onDragEnd.callCount).to.eql(1);
362
+ expect(instance.get('data')).to.matchSnapshot();
363
+ _context7.next = 35;
364
+ return dragInsert(file2, file1, 'after');
365
+
366
+ case 35:
367
+ expect(element.innerHTML).to.matchSnapshot();
368
+ expect(onDragEnd.callCount).to.eql(2);
369
+ expect(instance.get('data')).to.matchSnapshot();
370
+ _context7.next = 40;
371
+ return dragInsert(file1, dir1);
372
+
373
+ case 40:
374
+ expect(onDragEnd.callCount).to.eql(3);
375
+ expect(element.innerHTML).to.matchSnapshot();
376
+ expect(instance.get('data')).to.matchSnapshot();
377
+ _context7.next = 45;
378
+ return dragInsert(dir2, dir1);
379
+
380
+ case 45:
381
+ expect(onDragEnd.callCount).to.eql(3);
382
+ expect(onDenyDrag.callCount).to.eql(2);
383
+ _context7.next = 49;
384
+ return dragInsert(dir2, file3, 'before');
385
+
386
+ case 49:
387
+ expect(onDragEnd.callCount).to.eql(3);
388
+ expect(onDenyDrag.callCount).to.eql(2);
389
+
390
+ case 51:
370
391
  case "end":
371
392
  return _context7.stop();
372
393
  }
@@ -69,5 +69,5 @@ setDefault(function () {
69
69
  }).tree;
70
70
  });
71
71
  export function makeStyles(k) {
72
- return /*#__PURE__*/css("font-size:", tree.fontSize, ";line-height:", tree.lineHeight, ";position:relative;.", k, "-tree-label{position:relative;display:flex;align-items:center;&.", k, "-before,&.", k, "-after{&:before{position:absolute;content:'';display:block;border-top:", tree.dragging.border, ";width:100%;left:0;}}&.", k, "-before:before{top:0;}&.", k, "-after:before{bottom:0;}&.", k, "-inner{background:", tree.selected.bgColor, ";}}.", k, "-tree-icon,.", k, "-tree-text{cursor:pointer;}.", k, "-tree-text{padding:", tree.textPadding, ";border-radius:", tree.borderRadius, ";flex:1;}.", k, "-tree-leaf{padding-left:", tree.leafIndent, ";}.", k, "-tree-icon{width:", tree.iconWidth, ";text-align:center;color:", tree.iconColor, ";&:before{transform:rotate(-90deg);transition:transform ", tree.transition, ";}}.", k, "-tree-checkbox{margin-right:", tree.checkboxGap, ";}&.", k, "-selectable{.", k, "-tree-node{&.", k, "-selected{>.", k, "-tree-label .", k, "-tree-text{background:", tree.selected.bgColor, "!important;}}}}.", k, "-tree-node{background:#fff;&:not(.", k, "-disabled){>.", k, "-tree-label .", k, "-tree-text:hover{background:", theme.color.bg, ";}}&.", k, "-expanded{>.", k, "-tree-label .", k, "-tree-icon:before{transform:rotate(0);}}&.", k, "-disabled{>.", k, "-tree-label{color:", tree.disabledColor, ";.", k, "-tree-text{cursor:not-allowed;}}}&.", k, "-dragging{background:", tree.dragging.bgColor, ";.", k, "-tree-node{background:", tree.dragging.bgColor, ";}}}.", k, "-tree{margin-left:", tree.marginLeft, ";padding-left:", tree.paddingLeft, ";}&.", k, "-line .", k, "-tree{border-left:", tree.line, ";}");
72
+ return /*#__PURE__*/css("font-size:", tree.fontSize, ";line-height:", tree.lineHeight, ";position:relative;.", k, "-tree-label{position:relative;display:flex;align-items:center;&.", k, "-before,&.", k, "-after{&:before{position:absolute;content:'';display:block;border-top:", tree.dragging.border, ";width:100%;left:0;}}&.", k, "-before:before{top:0;}&.", k, "-after:before{bottom:0;}&.", k, "-inner{background:", tree.selected.bgColor, ";}}.", k, "-tree-icon,.", k, "-tree-text{cursor:pointer;}.", k, "-tree-text{padding:", tree.textPadding, ";border-radius:", tree.borderRadius, ";flex:1;display:flex;align-items:center;}.", k, "-tree-leaf{padding-left:", tree.leafIndent, ";}.", k, "-tree-icon{width:", tree.iconWidth, ";text-align:center;color:", tree.iconColor, ";&:before{transform:rotate(-90deg);transition:transform ", tree.transition, ";}}.", k, "-tree-checkbox{margin-right:", tree.checkboxGap, ";}&.", k, "-selectable{.", k, "-tree-node{&.", k, "-selected{>.", k, "-tree-label .", k, "-tree-text{background:", tree.selected.bgColor, "!important;}}}}.", k, "-tree-node{background:#fff;&:not(.", k, "-disabled){>.", k, "-tree-label .", k, "-tree-text:hover{background:", theme.color.bg, ";}}&.", k, "-expanded{>.", k, "-tree-label .", k, "-tree-icon:before{transform:rotate(0);}}&.", k, "-disabled{>.", k, "-tree-label{color:", tree.disabledColor, ";.", k, "-tree-text{cursor:not-allowed;}}}&.", k, "-dragging{background:", tree.dragging.bgColor, ";.", k, "-tree-node{background:", tree.dragging.bgColor, ";}}}.", k, "-tree{margin-left:", tree.marginLeft, ";padding-left:", tree.paddingLeft, ";}&.", k, "-line .", k, "-tree{border-left:", tree.line, ";}");
73
73
  }
@@ -57,18 +57,18 @@ export function useDraggable() {
57
57
  if (node !== overNode || newMode !== mode.value) {
58
58
  overNode = node;
59
59
  mode.set(newMode);
60
- overKey.set(node.key); // if the node does not allow drop, prevent the dragging ndoe from inserting to it
61
-
62
- if (mode.value === Mode.Inner) {
63
- var _instance$get2 = instance.get(),
64
- allowDrop = _instance$get2.allowDrop;
65
-
66
- if (node.data.disabled || allowDrop && !allowDrop(node)) {
67
- instance.trigger('denydrop', node);
68
- valid = false;
69
- return;
70
- }
71
- }
60
+ overKey.set(node.key); // if the node does not allow drop, prevent the dragging node from inserting to it
61
+ // if (mode.value === Mode.Inner) {
62
+
63
+ var _instance$get2 = instance.get(),
64
+ allowDrop = _instance$get2.allowDrop;
65
+
66
+ if (node.data.disabled || allowDrop && !allowDrop(node, draggingNode, newMode)) {
67
+ instance.trigger('denydrop', node, draggingNode, newMode);
68
+ valid = false;
69
+ return;
70
+ } // }
71
+
72
72
 
73
73
  valid = true;
74
74
  }
@@ -3,4 +3,5 @@ import type { Node } from './useNodes';
3
3
  export declare function useExpanded(getNodes: () => Node<Key>[]): {
4
4
  get: () => Set<Key>;
5
5
  toggle: (node: Node<Key>) => Promise<void>;
6
+ expandAll: () => void;
6
7
  };
@@ -89,6 +89,7 @@ export function useExpanded(getNodes) {
89
89
  get: function get() {
90
90
  return expandedKeys;
91
91
  },
92
- toggle: toggle
92
+ toggle: toggle,
93
+ expandAll: expandAll
93
94
  };
94
95
  }
@@ -5,6 +5,7 @@ export declare type DataItem<K extends Key> = {
5
5
  disabled?: boolean;
6
6
  loaded?: boolean;
7
7
  children?: DataItem<K>[];
8
+ [key: string]: any;
8
9
  };
9
10
  export declare function useNodes(): {
10
11
  getNodes: () => Node<Key>[];
@@ -21,6 +21,7 @@ export declare class TreeSelect<K extends Key = Key, Checkbox extends boolean =
21
21
  static defaults: () => Partial<TreeSelectProps<Key, boolean, boolean>>;
22
22
  private value;
23
23
  init(): void;
24
+ expandAll(): void;
24
25
  protected getPlaceholder(): string | number | boolean | import("misstime/dist/utils/types").VNode<any> | Children[];
25
26
  protected getLabel(): Children;
26
27
  private filter;
@@ -66,6 +66,10 @@ export var TreeSelect = /*#__PURE__*/function (_BaseSelect) {
66
66
  });
67
67
  };
68
68
 
69
+ _proto.expandAll = function expandAll() {
70
+ this.value.treeRef.value.expandAll();
71
+ };
72
+
69
73
  _proto.getPlaceholder = function getPlaceholder() {
70
74
  var _this$get = this.get(),
71
75
  placeholder = _this$get.placeholder;
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.0-beta.2
2
+ * @king-design v3.1.0-beta.3
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -60,7 +60,7 @@ export * from './components/tree';
60
60
  export * from './components/treeSelect';
61
61
  export * from './components/upload';
62
62
  export * from './components/wave';
63
- export declare const version = "3.1.0-beta.2";
63
+ export declare const version = "3.1.0-beta.3";
64
64
 
65
65
 
66
66
  export {normalize} from 'intact-vue-next';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.0-beta.2
2
+ * @king-design v3.1.0-beta.3
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -62,7 +62,7 @@ export * from './components/tree';
62
62
  export * from './components/treeSelect';
63
63
  export * from './components/upload';
64
64
  export * from './components/wave';
65
- export var version = '3.1.0-beta.2';
65
+ export var version = '3.1.0-beta.3';
66
66
  /* generate end */
67
67
 
68
68
  export {normalize} from 'intact-vue-next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/vue",
3
- "version": "3.1.0-beta.2",
3
+ "version": "3.1.0-beta.3",
4
4
  "description": "King-Design UI components for Vue3.0.",
5
5
  "keywords": [
6
6
  "component",