@king-design/vue 3.4.3-beta.2 → 3.4.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.
Files changed (50) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +279 -217
  2. package/__tests__/components/editable.spec.ts +1 -1
  3. package/__tests__/components/table.spec.ts +54 -0
  4. package/components/button/index.vdt.js +1 -1
  5. package/components/button/styles.js +3 -3
  6. package/components/diagram/shapes/callout.d.ts +1 -1
  7. package/components/diagram/shapes/circle.d.ts +1 -1
  8. package/components/diagram/shapes/document.d.ts +1 -1
  9. package/components/diagram/shapes/ellipse.d.ts +1 -1
  10. package/components/diagram/shapes/hexagon.d.ts +1 -1
  11. package/components/diagram/shapes/image.d.ts +1 -1
  12. package/components/diagram/shapes/parallelogram.d.ts +1 -1
  13. package/components/diagram/shapes/rectangle.d.ts +1 -1
  14. package/components/diagram/shapes/square.d.ts +1 -1
  15. package/components/diagram/shapes/text.d.ts +1 -1
  16. package/components/dialog/styles.js +3 -3
  17. package/components/dropdown/item.js +5 -2
  18. package/components/editable/index.d.ts +2 -0
  19. package/components/editable/index.js +4 -2
  20. package/components/editable/index.spec.js +39 -0
  21. package/components/editable/index.vdt.js +17 -6
  22. package/components/editable/styles.d.ts +1 -0
  23. package/components/editable/styles.js +3 -0
  24. package/components/ellipsis/index.d.ts +1 -0
  25. package/components/ellipsis/index.js +4 -2
  26. package/components/ellipsis/index.vdt.js +3 -1
  27. package/components/input/styles.js +11 -1
  28. package/components/menu/styles.js +1 -1
  29. package/components/select/index.spec.js +47 -0
  30. package/components/switch/styles.js +1 -1
  31. package/components/table/cell.d.ts +1 -0
  32. package/components/table/cell.vdt.js +14 -3
  33. package/components/table/column.d.ts +1 -0
  34. package/components/table/column.js +1 -0
  35. package/components/table/row.d.ts +2 -1
  36. package/components/table/row.js +24 -15
  37. package/components/table/row.vdt.js +3 -1
  38. package/components/table/styles.js +2 -2
  39. package/components/table/table.d.ts +3 -0
  40. package/components/table/table.js +3 -1
  41. package/components/table/table.vdt.js +19 -3
  42. package/components/table/useTree.d.ts +1 -1
  43. package/components/table/useTree.js +30 -2
  44. package/components/tooltip/index.spec.js +99 -67
  45. package/components/tooltip/tooltip.d.ts +1 -0
  46. package/components/tooltip/tooltip.js +9 -1
  47. package/components/treeSelect/index.vdt.js +1 -0
  48. package/index.d.ts +2 -2
  49. package/index.js +2 -2
  50. package/package.json +2 -2
@@ -14,6 +14,7 @@ export interface TableColumnProps {
14
14
  exportCell?: (data: any, index: number) => string;
15
15
  minWidth?: number;
16
16
  hidden?: boolean;
17
+ ellipsis?: boolean;
17
18
  cols?: number;
18
19
  rows?: number;
19
20
  prevVNode?: VNodeComponentClass<TableColumn> | null;
@@ -22,6 +22,7 @@ var typeDefs = {
22
22
  exportCell: Function,
23
23
  minWidth: Number,
24
24
  hidden: Boolean,
25
+ ellipsis: Boolean,
25
26
  // offset: null,
26
27
  cols: null,
27
28
  rows: null,
@@ -20,10 +20,11 @@ export interface TableRowProps {
20
20
  spreaded: boolean;
21
21
  hasChildren: boolean;
22
22
  indent: number;
23
- onToggleSpreadRow: (key: TableRowKey) => void;
23
+ onToggleSpreadRow: (key: TableRowKey, rowData?: any) => void;
24
24
  onBeforeUnmount: (key: TableRowKey) => void;
25
25
  offsetMap: Record<Key, number>;
26
26
  animation: boolean;
27
+ loaded: boolean;
27
28
  draggable: boolean;
28
29
  draggingKey: TableRowKey | null;
29
30
  onRowDragStart: DragCallback;
@@ -6,6 +6,7 @@ import template from './row.vdt';
6
6
  import { bind } from '../utils';
7
7
  import { isEqualObject } from '../utils';
8
8
  import { useConfigContext } from '../config';
9
+ import { hasOwn } from 'intact-shared';
9
10
  export var TableRow = /*#__PURE__*/function (_Component) {
10
11
  _inheritsLoose(TableRow, _Component);
11
12
  function TableRow() {
@@ -23,19 +24,26 @@ export var TableRow = /*#__PURE__*/function (_Component) {
23
24
  var lastProps = lastVNode.props;
24
25
  var nextProps = nextVNode.props;
25
26
  var isSame = true;
26
- var key;
27
- for (key in lastProps) {
28
- // ignore index
29
- if (key === 'index') continue;
30
- var lastValue = lastProps[key];
31
- var nextValue = nextProps[key];
32
- // deeply compare for offsetMap
33
- if (key === 'offsetMap' && isEqualObject(lastValue, nextValue)) {
34
- continue;
35
- }
36
- if (lastValue !== nextValue) {
37
- isSame = false;
38
- break;
27
+ if (hasOwn.call(this, 'vueInstance')) {
28
+ // In Vue, we may change value by modifing the same reference,
29
+ // and the new row may be expanded by click tree arrow
30
+ // so we can not compare in this case, #1030
31
+ isSame = false;
32
+ } else {
33
+ var key;
34
+ for (key in lastProps) {
35
+ // ignore index
36
+ if (key === 'index') continue;
37
+ var lastValue = lastProps[key];
38
+ var nextValue = nextProps[key];
39
+ // deeply compare for offsetMap
40
+ if (key === 'offsetMap' && isEqualObject(lastValue, nextValue)) {
41
+ continue;
42
+ }
43
+ if (lastValue !== nextValue) {
44
+ isSame = false;
45
+ break;
46
+ }
39
47
  }
40
48
  }
41
49
  if (!isSame) {
@@ -70,8 +78,9 @@ export var TableRow = /*#__PURE__*/function (_Component) {
70
78
  e.stopPropagation();
71
79
  var _this$get3 = this.get(),
72
80
  onToggleSpreadRow = _this$get3.onToggleSpreadRow,
73
- key = _this$get3.key;
74
- onToggleSpreadRow(key);
81
+ key = _this$get3.key,
82
+ data = _this$get3.data;
83
+ onToggleSpreadRow(key, data);
75
84
  };
76
85
  _proto.onMouseEnter = function onMouseEnter(e) {
77
86
  // for tooltip
@@ -33,7 +33,8 @@ export default function ($props, $blocks, $__proto__) {
33
33
  offsetMap = _this$get.offsetMap,
34
34
  draggable = _this$get.draggable,
35
35
  draggingKey = _this$get.draggingKey,
36
- animation = _this$get.animation;
36
+ animation = _this$get.animation,
37
+ loaded = _this$get.loaded;
37
38
  var k = this.config.k;
38
39
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-disabled"] = disabled, _classNameObj[k + "-checked"] = checked, _classNameObj[k + "-selected"] = selected, _classNameObj[k + "-spreaded"] = spreaded, _classNameObj[k + "-dragging"] = draggingKey === key, _classNameObj[className] = className, _classNameObj);
39
40
  var getGridItem = function getGridItem(columnIndex) {
@@ -82,6 +83,7 @@ export default function ($props, $blocks, $__proto__) {
82
83
  'columnIndex': columnIndex,
83
84
  'rowIndex': rowIndex,
84
85
  'data': data,
86
+ 'loaded': loaded,
85
87
  'offset': offsetMap[columnKey],
86
88
  'checkType': checkType,
87
89
  'indent': indent,
@@ -90,9 +90,9 @@ setDefault(function () {
90
90
  makeGroupMenuStyles == null || makeGroupMenuStyles.clearCache();
91
91
  });
92
92
  export var makeStyles = cache(function makeStyles(k) {
93
- return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";position:relative;z-index:0;.", k, "-table-wrapper{border-bottom:", table.border, ";overflow:auto;border-radius:", table.borderRadius, ";}table{width:100%;border-spacing:0;table-layout:fixed;}thead{text-align:", table.thead.textAlign, ";font-size:", table.thead.fontSize, ";font-weight:", table.thead.fontWeight, ";position:sticky;top:0;z-index:2;tr{height:", table.thead.height, ";&:not(:last-of-type) th{border-bottom:", table.border, ";}}}th{padding:", table.thead.padding, ";position:relative;background:", table.thead.bgColor, ";line-height:normal;&:before{content:'';height:", table.thead.delimiterHeight, ";position:absolute;background-color:", table.thead.delimiterColor, ";width:1px;left:1px;top:50%;transform:translateY(-50%);}&.", k, "-fixed-right:before{left:-2px;}&:first-of-type:before{display:none;}}.", k, "-table-title{display:inline-flex;align-items:center;max-width:100%;color:", table.thead.color, ";}.", k, "-table-title-text{flex:1;display:inline-flex;line-height:1.4;}tbody{tr{&:hover td{background:", table.tbody.hoverBgcolor, ";}&:last-of-type td{border-bottom-color:transparent;}}}td{padding:", table.tbody.padding, ";border-bottom:", table.border, ";background:", table.bgColor, ";word-wrap:break-word;}.", k, "-fixed-left,.", k, "-fixed-right{position:sticky;z-index:1;&:after{content:'';display:block;transition:box-shadow ", table.transition, ";position:absolute;top:0;bottom:0px;width:10px;pointer-events:none;}}.", k, "-fixed-left:after{right:-11px;}.", k, "-fixed-right:after{left:-11px;}&.", k, "-scroll-left .", k, "-fixed-right:after{box-shadow:", table.fixRightShadow, ";}&.", k, "-scroll-right .", k, "-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}&.", k, "-scroll-middle{.", k, "-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}.", k, "-fixed-right:after{box-shadow:", table.fixRightShadow, ";}}.", k, "-fixed-right+.", k, "-fixed-right:after{display:none;}.", k, "-table-affix-header{position:sticky;top:0;left:0;.", k, "-affix-wrapper{overflow:hidden;}&.", k, "-fixed{position:relative;}}&.", k, "-border,&.", k, "-grid{.", k, "-table-wrapper{border-top:", table.border, ";border-left:", table.border, ";border-right:", table.border, ";}}&.", k, "-grid{td:not(:last-of-type),th:not(:last-of-type){border-right:", table.border, ";}th:before{display:none;}}&.", k, "-stripe{tr:nth-child(even):not(:hover) td{background:", table.stripeBgColor, ";}}.", k, "-table-group{margin-left:", table.group.gap, ";}.", k, "-table-check{.", k, "-checkbox,.", k, "-radio{position:relative;top:-1px;}}.", k, "-column-sortable{cursor:pointer;}.", k, "-column-sort{.", k, "-icon{display:block;height:", _sortInstanceProperty(table).iconHeight, ";line-height:", _sortInstanceProperty(table).iconHeight, ";margin:0 0 1px ", _sortInstanceProperty(table).gap, ";}&.", k, "-desc .", k, "-icon.", k, "-desc,&.", k, "-asc .", k, "-icon.", k, "-asc{color:", _sortInstanceProperty(table).enabledColor, ";}}.", k, "-table-spin.", k, "-overlay{z-index:2;}.", k, "-table-empty{text-align:center;}tr.", k, "-expand{td{padding:0;background:#fdfcff;}}&.", k, "-with-expand{tr:not(.", k, "-expand){td{border-bottom:none;}}}.", k, "-table-expand{border-top:", table.border, ";box-sizing:content-box;}tbody tr.", k, "-selected td{background:", table.selectedBgColor, ";}.", k, "-hidden{display:none;}.", k, "-table-arrow{width:", table.arrow.width, "!important;margin-right:", table.arrow.gap, ";transition:transform ", table.transition, ";position:relative;top:-1px;}tr.", k, "-spreaded{.", k, "-table-arrow{transform:rotate(90deg);}}.", k, "-table-resize{height:100%;width:", table.resizeWidth, ";position:absolute;top:0;left:-1px;cursor:ew-resize;}tr.", k, "-dragging{opacity:", table.draggingOpacity, ";}.", k, "-table-scrollbar{overflow-x:auto;overflow-y:hidden;}.", k, "-table-scrollbar-inner{height:1px;}", _mapInstanceProperty(aligns).call(aligns, function (type) {
93
+ return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";position:relative;z-index:0;.", k, "-table-wrapper{border-bottom:", table.border, ";overflow:auto;border-radius:", table.borderRadius, ";}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed;}thead{text-align:", table.thead.textAlign, ";font-size:", table.thead.fontSize, ";font-weight:", table.thead.fontWeight, ";z-index:2;tr{height:", table.thead.height, ";&:not(:last-of-type) th{border-bottom:", table.border, ";}}}tfoot{z-index:2;tr{td{border-top:", table.border, ";}}}th{padding:", table.thead.padding, ";position:relative;background:", table.thead.bgColor, ";line-height:normal;&:before{content:'';height:", table.thead.delimiterHeight, ";position:absolute;background-color:", table.thead.delimiterColor, ";width:1px;left:1px;top:50%;transform:translateY(-50%);}&.", k, "-fixed-right:before{left:-2px;}&:first-of-type:before{display:none;}}.", k, "-table-title{display:inline-flex;align-items:center;max-width:100%;color:", table.thead.color, ";}.", k, "-table-title-text{flex:1;display:inline-flex;line-height:1.4;}tbody{tr{&:hover td{background:", table.tbody.hoverBgcolor, ";}&:last-of-type td{border-bottom-color:transparent;}}}td{padding:", table.tbody.padding, ";border-bottom:", table.border, ";background:", table.bgColor, ";word-wrap:break-word;}.", k, "-fixed-left,.", k, "-fixed-right{position:sticky;z-index:1;&:after{content:'';display:block;transition:box-shadow ", table.transition, ";position:absolute;top:0;bottom:0px;width:10px;pointer-events:none;}}.", k, "-fixed-left:after{right:-11px;}.", k, "-fixed-right:after{left:-11px;}&.", k, "-scroll-left .", k, "-fixed-right:after{box-shadow:", table.fixRightShadow, ";}&.", k, "-scroll-right .", k, "-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}&.", k, "-scroll-middle{.", k, "-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}.", k, "-fixed-right:after{box-shadow:", table.fixRightShadow, ";}}.", k, "-fixed-right+.", k, "-fixed-right:after{display:none;}.", k, "-table-affix-header{position:sticky;top:0;left:0;.", k, "-affix-wrapper{overflow:hidden;}&.", k, "-fixed{position:relative;}}&.", k, "-border,&.", k, "-grid{.", k, "-table-wrapper{border-top:", table.border, ";border-left:", table.border, ";border-right:", table.border, ";}}&.", k, "-grid{td:not(:last-of-type),th:not(:last-of-type){border-right:", table.border, ";}th:before{display:none;}}&.", k, "-stripe{tr:nth-child(even):not(:hover) td{background:", table.stripeBgColor, ";}}.", k, "-table-group{margin-left:", table.group.gap, ";}.", k, "-table-check{.", k, "-checkbox,.", k, "-radio{position:relative;top:-1px;}}.", k, "-column-sortable{cursor:pointer;}.", k, "-column-sort{.", k, "-icon{display:block;height:", _sortInstanceProperty(table).iconHeight, ";line-height:", _sortInstanceProperty(table).iconHeight, ";margin:0 0 1px ", _sortInstanceProperty(table).gap, ";}&.", k, "-desc .", k, "-icon.", k, "-desc,&.", k, "-asc .", k, "-icon.", k, "-asc{color:", _sortInstanceProperty(table).enabledColor, ";}}.", k, "-table-spin.", k, "-overlay{z-index:2;}.", k, "-table-empty{text-align:center;}tr.", k, "-expand{td{padding:0;background:#fdfcff;}}&.", k, "-with-expand{tr:not(.", k, "-expand){td{border-bottom:none;}}}.", k, "-table-expand{border-top:", table.border, ";box-sizing:content-box;}tbody tr.", k, "-selected td{background:", table.selectedBgColor, ";}.", k, "-hidden{display:none;}.", k, "-table-arrow{width:", table.arrow.width, "!important;margin-right:", table.arrow.gap, ";transition:transform ", table.transition, ";position:relative;top:-1px;}tr.", k, "-spreaded{.", k, "-table-arrow{transform:rotate(90deg);}}.", k, "-table-resize{height:100%;width:", table.resizeWidth, ";position:absolute;top:0;left:-1px;cursor:ew-resize;}tr.", k, "-dragging{opacity:", table.draggingOpacity, ";}.", k, "-table-scrollbar{overflow-x:auto;overflow-y:hidden;}.", k, "-table-scrollbar-inner{height:1px;}", _mapInstanceProperty(aligns).call(aligns, function (type) {
94
94
  return /*#__PURE__*/css(".", k, "-align-", type, "{text-align:", type, ";}");
95
- }), ">.", k, "-pagination{margin:16px 0;}&.", k, "-fix-header{min-height:0;.", k, "-table-wrapper{height:100%;}}");
95
+ }), ">.", k, "-pagination{margin:16px 0;}&.", k, "-fix-header{min-height:0;.", k, "-table-wrapper{height:100%;}thead{position:sticky;top:0;}}&.", k, "-fix-footer{min-height:0;.", k, "-table-wrapper{height:100%;}tfoot{position:sticky;bottom:0;}}");
96
96
  });
97
97
  export var makeGroupMenuStyles = cache(function makeGroupMenuStyles(k) {
98
98
  return /*#__PURE__*/css("min-width:", table.group.menuMinWidth, "!important;.", k, "-dropdown-item.", k, "-active{color:", table.group.activeColor, ";}.", k, "-table-group-header{padding:", table.group.headerPadding, ";border-bottom:", table.group.headerBorder, ";}.", k, "-table-group-body{max-height:", table.group.menuMaxHeight, ";overflow:auto;}.", k, "-table-group-footer{text-align:right;border-top:", table.group.headerBorder, ";padding:8px;.", k, "-btn{margin-left:8px;}}");
@@ -38,6 +38,8 @@ export interface TableProps<T = any, K extends TableRowKey = TableRowKey, C exte
38
38
  animation?: boolean | [boolean, boolean];
39
39
  hideHeader?: boolean;
40
40
  pagination?: boolean | PaginationProps;
41
+ fixFooter?: boolean;
42
+ load?: (value: T) => Promise<void> | void;
41
43
  }
42
44
  export interface TableEvents<T = any, K extends TableRowKey = number> {
43
45
  clickRow: [T, number, K];
@@ -60,6 +62,7 @@ export interface TableBlocks<T = unknown> {
60
62
  empty: null;
61
63
  tooltip: [T, number];
62
64
  expand: [T, number];
65
+ footer: null;
63
66
  }
64
67
  type CheckType = 'checkbox' | 'radio' | 'none';
65
68
  export type TableCheckType = CheckType;
@@ -61,7 +61,9 @@ var typeDefs = {
61
61
  draggable: Boolean,
62
62
  animation: [Boolean, Array],
63
63
  hideHeader: Boolean,
64
- pagination: [Boolean, Object]
64
+ pagination: [Boolean, Object],
65
+ fixFooter: Boolean,
66
+ load: Function
65
67
  };
66
68
  var defaults = function defaults() {
67
69
  return {
@@ -54,7 +54,8 @@ export default function ($props, $blocks, $__proto__) {
54
54
  draggable = _this$get.draggable,
55
55
  _animation = _this$get.animation,
56
56
  hideHeader = _this$get.hideHeader,
57
- pagination = _this$get.pagination;
57
+ pagination = _this$get.pagination,
58
+ fixFooter = _this$get.fixFooter;
58
59
  var animation = !Array.isArray(_animation) ? [_animation, _animation] : _animation;
59
60
  var _this$columns$getData = this.columns.getData(),
60
61
  columns = _this$columns$getData.columns,
@@ -73,7 +74,7 @@ export default function ($props, $blocks, $__proto__) {
73
74
  elementRef = _this$stickyHeader.elementRef,
74
75
  headRef = _this$stickyHeader.headRef;
75
76
  var k = this.config.k;
76
- var classNameObj = (_classNameObj = {}, _classNameObj[k + "-table"] = true, _classNameObj[k + "-fix-header"] = fixHeader, _classNameObj[k + "-scroll-" + scrollPosition.value] = scrollPosition.value, _classNameObj[k + "-fix-columns"] = hasFixed.value, _classNameObj[k + "-" + type] = type && type !== 'default', _classNameObj[k + "-stripe"] = stripe, _classNameObj[k + "-with-expand"] = $blocks.expand, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
77
+ var classNameObj = (_classNameObj = {}, _classNameObj[k + "-table"] = true, _classNameObj[k + "-fix-header"] = fixHeader, _classNameObj[k + "-fix-footer"] = fixFooter, _classNameObj[k + "-scroll-" + scrollPosition.value] = scrollPosition.value, _classNameObj[k + "-fix-columns"] = hasFixed.value, _classNameObj[k + "-" + type] = type && type !== 'default', _classNameObj[k + "-stripe"] = stripe, _classNameObj[k + "-with-expand"] = $blocks.expand, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
77
78
  var style = isStringOrNumber(fixHeader) ? {
78
79
  maxHeight: fixHeader + "px"
79
80
  } : null;
@@ -183,6 +184,7 @@ export default function ($props, $blocks, $__proto__) {
183
184
  'key': key,
184
185
  'cols': cols,
185
186
  'data': value,
187
+ 'loaded': value.loaded,
186
188
  'checkType': checkType,
187
189
  'hasFixedLeft': hasFixedLeft,
188
190
  'onClick': _this.clickRow,
@@ -265,6 +267,20 @@ export default function ($props, $blocks, $__proto__) {
265
267
  'children': rows
266
268
  }) : rows;
267
269
  }(), 0);
270
+ var tfooter = null;
271
+ if ($blocks.footer) {
272
+ tfooter = _$ce(2, 'tfoot', _$ce(2, 'tr', _$ce(2, 'td', (_$blocks['footer'] = function ($super) {
273
+ return null;
274
+ }, __$blocks['footer'] = function ($super, data) {
275
+ var block = $blocks['footer'];
276
+ var callBlock = function callBlock() {
277
+ return _$blocks['footer'].call($this, $super, data);
278
+ };
279
+ return block ? block.call($this, callBlock, data) : callBlock();
280
+ }, __$blocks['footer'](_$no)), 0, _$cn(k + "-table-footer"), {
281
+ 'colspan': colCount
282
+ }), 2, null, null, 'table-footer'), 2);
283
+ }
268
284
  var tableWidthPx = tableWidth.value ? tableWidth.value + "px" : null;
269
285
  var _this$stickyScrollbar = this.stickyScrollbar,
270
286
  shouldStickScrollbar = _this$stickyScrollbar.shouldStickScrollbar,
@@ -287,7 +303,7 @@ export default function ($props, $blocks, $__proto__) {
287
303
  width: tableWidthPx
288
304
  }
289
305
  }, null, headRef)
290
- }) : undefined, _$ce(2, 'table', [colgroup, isNull(stickHeader.value) ? thead : undefined, tbody], 0, null, {
306
+ }) : undefined, _$ce(2, 'table', [colgroup, isNull(stickHeader.value) ? thead : undefined, tbody, $blocks.footer ? tfooter : undefined], 0, null, {
291
307
  'style': {
292
308
  width: tableWidthPx
293
309
  }
@@ -2,7 +2,7 @@ import type { TableRowKey } from './table';
2
2
  import { State } from '../../hooks/useState';
3
3
  export declare function useTree(data: State<any[] | undefined>): {
4
4
  isSpreaded: (key: TableRowKey) => boolean;
5
- toggleSpreadRow: (key: TableRowKey) => void;
5
+ toggleSpreadRow: (key: TableRowKey, rowData?: any) => Promise<void>;
6
6
  loopData: <T>(cb: (value: any, index: number, level: number, meta: T | null) => T, shouldBreak?: boolean) => void;
7
7
  };
8
8
  export declare function loopDataWithChildrenKey<T>(data: any[] | undefined, childrenKey: string | undefined, cb: (value: any, index: number, level: number, meta: T | null) => T, shouldBreak: boolean): void;
@@ -1,3 +1,5 @@
1
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
1
3
  import { useInstance } from 'intact-vue-next';
2
4
  import { inArray } from './useChecked';
3
5
  import { toggleArray } from '../utils';
@@ -6,8 +8,34 @@ export function useTree(data) {
6
8
  function isSpreaded(key) {
7
9
  return inArray(instance.get('spreadKeys'), key);
8
10
  }
9
- function toggleSpreadRow(key) {
10
- instance.set('spreadKeys', toggleArray(instance.get('spreadKeys'), key));
11
+ function toggleSpreadRow(_x, _x2) {
12
+ return _toggleSpreadRow.apply(this, arguments);
13
+ }
14
+ function _toggleSpreadRow() {
15
+ _toggleSpreadRow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, rowData) {
16
+ var _instance$get2, spreadKeys, load;
17
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ _instance$get2 = instance.get(), spreadKeys = _instance$get2.spreadKeys, load = _instance$get2.load;
21
+ instance.set('spreadKeys', toggleArray(spreadKeys, key));
22
+ if (!(load && data.value && !rowData.loaded)) {
23
+ _context.next = 8;
24
+ break;
25
+ }
26
+ rowData.loaded = false;
27
+ _context.next = 6;
28
+ return load(rowData);
29
+ case 6:
30
+ rowData.loaded = true;
31
+ instance.forceUpdate();
32
+ case 8:
33
+ case "end":
34
+ return _context.stop();
35
+ }
36
+ }, _callee);
37
+ }));
38
+ return _toggleSpreadRow.apply(this, arguments);
11
39
  }
12
40
  function loopData(cb, shouldBreak) {
13
41
  if (shouldBreak === void 0) {
@@ -223,13 +223,13 @@ describe('Tooltip', function () {
223
223
  }, _callee4, this);
224
224
  })));
225
225
  it('should custom content correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
226
- var _mount5, element, _Array$from4, btn, content;
226
+ var _mount5, element, _Array$from4, btn1, content;
227
227
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
228
228
  while (1) switch (_context5.prev = _context5.next) {
229
229
  case 0:
230
230
  _mount5 = mount(ContentDemo), element = _mount5[1];
231
- _Array$from4 = _Array$from2(element.querySelectorAll('.k-btn')), btn = _Array$from4[0];
232
- btn.click();
231
+ _Array$from4 = _Array$from2(element.querySelectorAll('.k-btn')), btn1 = _Array$from4[0];
232
+ btn1.click();
233
233
  _context5.next = 5;
234
234
  return wait(500);
235
235
  case 5:
@@ -241,34 +241,66 @@ describe('Tooltip', function () {
241
241
  }
242
242
  }, _callee5);
243
243
  })));
244
- it('should always show tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
245
- var _mount6, element, content;
244
+ it('Internal dropdown closing should not affect tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
245
+ var _mount6, element, _Array$from5, btn2, content, trigger, dropdown, item;
246
246
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
247
247
  while (1) switch (_context6.prev = _context6.next) {
248
248
  case 0:
249
- _mount6 = mount(AlwaysDemo), element = _mount6[1];
249
+ _mount6 = mount(ContentDemo), element = _mount6[1];
250
+ _Array$from5 = _Array$from2(element.querySelectorAll('.k-btn')), btn2 = _Array$from5[1];
251
+ btn2.click();
252
+ _context6.next = 5;
253
+ return wait(500);
254
+ case 5:
255
+ content = getElement('.k-tooltip-content');
256
+ trigger = content.querySelector('.k-select');
257
+ trigger.click();
258
+ _context6.next = 10;
259
+ return wait();
260
+ case 10:
261
+ expect(element.outerHTML).to.matchSnapshot();
262
+ dropdown = getElement('.k-select-menu');
263
+ expect(dropdown.innerHTML).to.matchSnapshot();
264
+ item = dropdown.querySelector('.k-dropdown-item');
265
+ item.click();
266
+ _context6.next = 17;
267
+ return wait(500);
268
+ case 17:
269
+ expect(content.style.display).to.eql('');
270
+ case 18:
271
+ case "end":
272
+ return _context6.stop();
273
+ }
274
+ }, _callee6);
275
+ })));
276
+ it('should always show tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
277
+ var _mount7, element, content;
278
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
279
+ while (1) switch (_context7.prev = _context7.next) {
280
+ case 0:
281
+ _mount7 = mount(AlwaysDemo), element = _mount7[1];
250
282
  content = getElement('.k-tooltip-content');
251
283
  expect(content.textContent).eql('hello');
252
284
  document.body.click();
253
- _context6.next = 6;
285
+ _context7.next = 6;
254
286
  return wait(500);
255
287
  case 6:
256
288
  expect(getElement('.k-tooltip-content')).eql(content);
257
289
  element.querySelector('span').click();
258
- _context6.next = 10;
290
+ _context7.next = 10;
259
291
  return wait(500);
260
292
  case 10:
261
293
  expect(getElement('.k-tooltip-content')).eql(content);
262
294
  dispatchEvent(content, 'mouseleave');
263
- _context6.next = 14;
295
+ _context7.next = 14;
264
296
  return wait(600);
265
297
  case 14:
266
298
  expect(getElement('.k-tooltip-content')).eql(content);
267
299
  case 15:
268
300
  case "end":
269
- return _context6.stop();
301
+ return _context7.stop();
270
302
  }
271
- }, _callee6);
303
+ }, _callee7);
272
304
  })));
273
305
  // it('should hide tooltip when v-show is false in Vue', async () => {
274
306
  // interface IData {
@@ -338,20 +370,20 @@ describe('Tooltip', function () {
338
370
  // app.$destroy();
339
371
  // document.body.removeChild(app.$el);
340
372
  // });
341
- it('should hide layer when we have disabled Tooltip and also hide on next updating', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
342
- var Demo, _mount7, i, content;
343
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
344
- while (1) switch (_context8.prev = _context8.next) {
373
+ it('should hide layer when we have disabled Tooltip and also hide on next updating', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
374
+ var Demo, _mount8, i, content;
375
+ return _regeneratorRuntime.wrap(function _callee8$(_context9) {
376
+ while (1) switch (_context9.prev = _context9.next) {
345
377
  case 0:
346
378
  Demo = /*#__PURE__*/function (_Component) {
347
379
  _inheritsLoose(Demo, _Component);
348
380
  function Demo() {
349
- var _context7;
381
+ var _context8;
350
382
  var _this;
351
383
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
352
384
  args[_key] = arguments[_key];
353
385
  }
354
- _this = _Component.call.apply(_Component, _concatInstanceProperty(_context7 = [this]).call(_context7, args)) || this;
386
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context8 = [this]).call(_context8, args)) || this;
355
387
  _this.Tooltip = Tooltip;
356
388
  return _this;
357
389
  }
@@ -363,45 +395,45 @@ describe('Tooltip', function () {
363
395
  disabled: false
364
396
  };
365
397
  };
366
- _mount7 = mount(Demo), i = _mount7[0];
398
+ _mount8 = mount(Demo), i = _mount8[0];
367
399
  dispatchEvent(i.refs.test, 'mouseenter');
368
- _context8.next = 7;
400
+ _context9.next = 7;
369
401
  return wait();
370
402
  case 7:
371
403
  content = getElement('.k-tooltip-content');
372
404
  expect(content.textContent).eql('hello');
373
405
  i.set('disabled', true);
374
- _context8.next = 12;
406
+ _context9.next = 12;
375
407
  return wait(500);
376
408
  case 12:
377
409
  content = getElement('.k-tooltip-content');
378
410
  expect(content).eql(undefined);
379
411
  i.set('disabled', false);
380
- _context8.next = 17;
412
+ _context9.next = 17;
381
413
  return wait();
382
414
  case 17:
383
415
  content = getElement('.k-tooltip-content');
384
416
  expect(content).eql(undefined);
385
417
  case 19:
386
418
  case "end":
387
- return _context8.stop();
419
+ return _context9.stop();
388
420
  }
389
- }, _callee7);
421
+ }, _callee8);
390
422
  })));
391
- it('should not detect collison when target is not in viewport', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
392
- var Demo, _mount8, i, content;
393
- return _regeneratorRuntime.wrap(function _callee8$(_context10) {
394
- while (1) switch (_context10.prev = _context10.next) {
423
+ it('should not detect collison when target is not in viewport', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
424
+ var Demo, _mount9, i, content;
425
+ return _regeneratorRuntime.wrap(function _callee9$(_context11) {
426
+ while (1) switch (_context11.prev = _context11.next) {
395
427
  case 0:
396
428
  Demo = /*#__PURE__*/function (_Component2) {
397
429
  _inheritsLoose(Demo, _Component2);
398
430
  function Demo() {
399
- var _context9;
431
+ var _context10;
400
432
  var _this2;
401
433
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
402
434
  args[_key2] = arguments[_key2];
403
435
  }
404
- _this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
436
+ _this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context10 = [this]).call(_context10, args)) || this;
405
437
  _this2.Tooltip = Tooltip;
406
438
  return _this2;
407
439
  }
@@ -422,10 +454,10 @@ describe('Tooltip', function () {
422
454
  show: false
423
455
  };
424
456
  };
425
- _mount8 = mount(Demo), i = _mount8[0]; // await wait(500);
457
+ _mount9 = mount(Demo), i = _mount9[0]; // await wait(500);
426
458
  // window.scrollTo(0, 10000);
427
459
  i.set('show', true);
428
- _context10.next = 7;
460
+ _context11.next = 7;
429
461
  return wait(500);
430
462
  case 7:
431
463
  content = getElement('.k-tooltip-content');
@@ -434,59 +466,59 @@ describe('Tooltip', function () {
434
466
  expect(content.getBoundingClientRect().top < 0).to.be.true;
435
467
  case 11:
436
468
  case "end":
437
- return _context10.stop();
469
+ return _context11.stop();
438
470
  }
439
- }, _callee8);
471
+ }, _callee9);
440
472
  })));
441
- it('should add className', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
442
- var Demo, _mount9, instance, element, trigger, dropdown;
443
- return _regeneratorRuntime.wrap(function _callee9$(_context12) {
444
- while (1) switch (_context12.prev = _context12.next) {
473
+ it('should add className', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
474
+ var Demo, _mount10, instance, element, trigger, dropdown;
475
+ return _regeneratorRuntime.wrap(function _callee10$(_context13) {
476
+ while (1) switch (_context13.prev = _context13.next) {
445
477
  case 0:
446
478
  Demo = /*#__PURE__*/function (_Component3) {
447
479
  _inheritsLoose(Demo, _Component3);
448
480
  function Demo() {
449
- var _context11;
481
+ var _context12;
450
482
  var _this3;
451
483
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
452
484
  args[_key3] = arguments[_key3];
453
485
  }
454
- _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context11 = [this]).call(_context11, args)) || this;
486
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
455
487
  _this3.Tooltip = Tooltip;
456
488
  return _this3;
457
489
  }
458
490
  return Demo;
459
491
  }(Component);
460
492
  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 ";
461
- _mount9 = mount(Demo), instance = _mount9[0], element = _mount9[1];
493
+ _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
462
494
  trigger = instance.refs.test;
463
495
  expect(trigger.className).to.eql('b a');
464
496
  dispatchEvent(trigger, 'mouseenter');
465
- _context12.next = 8;
497
+ _context13.next = 8;
466
498
  return wait();
467
499
  case 8:
468
500
  dropdown = getElement('.k-tooltip-content');
469
501
  expect(dropdown.classList.contains('a')).to.be.true;
470
502
  case 10:
471
503
  case "end":
472
- return _context12.stop();
504
+ return _context13.stop();
473
505
  }
474
- }, _callee9);
506
+ }, _callee10);
475
507
  })));
476
- it('should fix the width in small container', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
477
- var Demo, _mount10, instance, element, trigger, expecedWidth, content, width, newWidth;
478
- return _regeneratorRuntime.wrap(function _callee10$(_context14) {
479
- while (1) switch (_context14.prev = _context14.next) {
508
+ it('should fix the width in small container', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
509
+ var Demo, _mount11, instance, element, trigger, expecedWidth, content, width, newWidth;
510
+ return _regeneratorRuntime.wrap(function _callee11$(_context15) {
511
+ while (1) switch (_context15.prev = _context15.next) {
480
512
  case 0:
481
513
  Demo = /*#__PURE__*/function (_Component4) {
482
514
  _inheritsLoose(Demo, _Component4);
483
515
  function Demo() {
484
- var _context13;
516
+ var _context14;
485
517
  var _this4;
486
518
  for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
487
519
  args[_key4] = arguments[_key4];
488
520
  }
489
- _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
521
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context14 = [this]).call(_context14, args)) || this;
490
522
  _this4.Tooltip = Tooltip;
491
523
  _this4.Dialog = Dialog;
492
524
  return _this4;
@@ -494,46 +526,46 @@ describe('Tooltip', function () {
494
526
  return Demo;
495
527
  }(Component);
496
528
  Demo.template = "\n const {Tooltip, Dialog} = this;\n <div style=\"text-align: right; position: relative; width: 350px;\">\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\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 ";
497
- _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
529
+ _mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
498
530
  trigger = element.querySelector('.trigger');
499
531
  expecedWidth = parseInt(tooltipTheme.maxWidth);
500
532
  dispatchEvent(trigger, 'mouseenter');
501
- _context14.next = 8;
533
+ _context15.next = 8;
502
534
  return wait();
503
535
  case 8:
504
536
  content = getElement('.k-tooltip-content');
505
537
  width = content.offsetWidth;
506
538
  expect(width).to.eql(expecedWidth);
507
539
  dispatchEvent(trigger, 'mouseleave');
508
- _context14.next = 14;
540
+ _context15.next = 14;
509
541
  return wait();
510
542
  case 14:
511
543
  dispatchEvent(trigger, 'mouseenter');
512
- _context14.next = 17;
544
+ _context15.next = 17;
513
545
  return wait();
514
546
  case 17:
515
547
  newWidth = content.offsetWidth;
516
548
  expect(newWidth).to.eql(width);
517
549
  case 19:
518
550
  case "end":
519
- return _context14.stop();
551
+ return _context15.stop();
520
552
  }
521
- }, _callee10);
553
+ }, _callee11);
522
554
  })));
523
- it('should not impact select when wrap select with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
524
- var Demo, _mount11, instance, element, menu;
525
- return _regeneratorRuntime.wrap(function _callee11$(_context16) {
526
- while (1) switch (_context16.prev = _context16.next) {
555
+ it('should not impact select when wrap select with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
556
+ var Demo, _mount12, instance, element, menu;
557
+ return _regeneratorRuntime.wrap(function _callee12$(_context17) {
558
+ while (1) switch (_context17.prev = _context17.next) {
527
559
  case 0:
528
560
  Demo = /*#__PURE__*/function (_Component5) {
529
561
  _inheritsLoose(Demo, _Component5);
530
562
  function Demo() {
531
- var _context15;
563
+ var _context16;
532
564
  var _this5;
533
565
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
534
566
  args[_key5] = arguments[_key5];
535
567
  }
536
- _this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context15 = [this]).call(_context15, args)) || this;
568
+ _this5 = _Component5.call.apply(_Component5, _concatInstanceProperty(_context16 = [this]).call(_context16, args)) || this;
537
569
  _this5.Tooltip = Tooltip;
538
570
  _this5.Select = Select;
539
571
  _this5.Option = Option;
@@ -542,25 +574,25 @@ describe('Tooltip', function () {
542
574
  return Demo;
543
575
  }(Component);
544
576
  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 ";
545
- _mount11 = mount(Demo), instance = _mount11[0], element = _mount11[1];
577
+ _mount12 = mount(Demo), instance = _mount12[0], element = _mount12[1];
546
578
  dispatchEvent(element, 'mouseenter');
547
- _context16.next = 6;
579
+ _context17.next = 6;
548
580
  return wait();
549
581
  case 6:
550
582
  dispatchEvent(element, 'click');
551
- _context16.next = 9;
583
+ _context17.next = 9;
552
584
  return wait();
553
585
  case 9:
554
586
  menu = getElement(".k-select-menu");
555
587
  dispatchEvent(element, 'mouseleave');
556
- _context16.next = 13;
588
+ _context17.next = 13;
557
589
  return wait(500);
558
590
  case 13:
559
591
  expect(menu.style.display).to.eql('');
560
592
  case 14:
561
593
  case "end":
562
- return _context16.stop();
594
+ return _context17.stop();
563
595
  }
564
- }, _callee11);
596
+ }, _callee12);
565
597
  })));
566
598
  });