ebaoferc 0.0.1 → 0.0.2-beta.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 (141) hide show
  1. package/dist/{FlexRowCol → components/FlexRowCol}/index.js +1 -1
  2. package/dist/components/MindGraph/core/default.d.ts +6 -0
  3. package/dist/components/MindGraph/core/default.js +81 -0
  4. package/dist/components/MindGraph/core/graphic/drag.d.ts +42 -0
  5. package/dist/components/MindGraph/core/graphic/drag.js +120 -0
  6. package/dist/components/MindGraph/core/graphic/index.d.ts +181 -0
  7. package/dist/components/MindGraph/core/graphic/index.js +423 -0
  8. package/dist/components/MindGraph/core/graphic/node-translate-to.d.ts +11 -0
  9. package/dist/components/MindGraph/core/graphic/node-translate-to.js +55 -0
  10. package/dist/components/MindGraph/core/graphic/zoom.d.ts +17 -0
  11. package/dist/components/MindGraph/core/graphic/zoom.js +90 -0
  12. package/dist/components/MindGraph/core/helper/breadth-first-walk-tree.d.ts +5 -0
  13. package/dist/components/MindGraph/core/helper/breadth-first-walk-tree.js +21 -0
  14. package/dist/components/MindGraph/core/helper/depth-first-walk-tree.d.ts +10 -0
  15. package/dist/components/MindGraph/core/helper/depth-first-walk-tree.js +17 -0
  16. package/dist/components/MindGraph/core/helper/descendant.d.ts +6 -0
  17. package/dist/components/MindGraph/core/helper/descendant.js +28 -0
  18. package/dist/components/MindGraph/core/helper/error.d.ts +1 -0
  19. package/dist/components/MindGraph/core/helper/error.js +3 -0
  20. package/dist/components/MindGraph/core/helper/get-layout-calc-children.d.ts +10 -0
  21. package/dist/components/MindGraph/core/helper/get-layout-calc-children.js +37 -0
  22. package/dist/components/MindGraph/core/helper/get-svg-path-id.d.ts +1 -0
  23. package/dist/components/MindGraph/core/helper/get-svg-path-id.js +4 -0
  24. package/dist/components/MindGraph/core/helper/index.d.ts +23 -0
  25. package/dist/components/MindGraph/core/helper/index.js +26 -0
  26. package/dist/components/MindGraph/core/helper/judge-if-all-child-fold.d.ts +7 -0
  27. package/dist/components/MindGraph/core/helper/judge-if-all-child-fold.js +14 -0
  28. package/dist/components/MindGraph/core/helper/judge-if-heir-and-fold.d.ts +10 -0
  29. package/dist/components/MindGraph/core/helper/judge-if-heir-and-fold.js +26 -0
  30. package/dist/components/MindGraph/core/helper/judge-if-visual-leaf.d.ts +6 -0
  31. package/dist/components/MindGraph/core/helper/judge-if-visual-leaf.js +7 -0
  32. package/dist/components/MindGraph/core/helper/root-to-node-array.d.ts +2 -0
  33. package/dist/components/MindGraph/core/helper/root-to-node-array.js +27 -0
  34. package/dist/components/MindGraph/core/helper/transform-root-to-walkable.d.ts +5 -0
  35. package/dist/components/MindGraph/core/helper/transform-root-to-walkable.js +32 -0
  36. package/dist/components/MindGraph/core/helper/with-prefix.d.ts +1 -0
  37. package/dist/components/MindGraph/core/helper/with-prefix.js +3 -0
  38. package/dist/components/MindGraph/core/index.d.ts +394 -0
  39. package/dist/components/MindGraph/core/index.js +86 -0
  40. package/dist/components/MindGraph/core/process/anchor.d.ts +12 -0
  41. package/dist/components/MindGraph/core/process/anchor.js +63 -0
  42. package/dist/components/MindGraph/core/process/index.d.ts +91 -0
  43. package/dist/components/MindGraph/core/process/index.js +30 -0
  44. package/dist/components/MindGraph/core/process/layout/dagre.d.ts +2 -0
  45. package/dist/components/MindGraph/core/process/layout/dagre.js +20 -0
  46. package/dist/components/MindGraph/core/process/layout/descendant-center.d.ts +10 -0
  47. package/dist/components/MindGraph/core/process/layout/descendant-center.js +146 -0
  48. package/dist/components/MindGraph/core/process/layout/heir-center.d.ts +10 -0
  49. package/dist/components/MindGraph/core/process/layout/heir-center.js +52 -0
  50. package/dist/components/MindGraph/core/process/layout/index.d.ts +3 -0
  51. package/dist/components/MindGraph/core/process/layout/index.js +3 -0
  52. package/dist/components/MindGraph/core/process/layout/structured/calc-drag-attach.d.ts +2 -0
  53. package/dist/components/MindGraph/core/process/layout/structured/calc-drag-attach.js +172 -0
  54. package/dist/components/MindGraph/core/process/layout/structured/calc-drop-index.d.ts +2 -0
  55. package/dist/components/MindGraph/core/process/layout/structured/calc-drop-index.js +38 -0
  56. package/dist/components/MindGraph/core/process/layout/structured/get-node-cross-boundary.d.ts +10 -0
  57. package/dist/components/MindGraph/core/process/layout/structured/get-node-cross-boundary.js +35 -0
  58. package/dist/components/MindGraph/core/process/layout/structured/index.d.ts +13 -0
  59. package/dist/components/MindGraph/core/process/layout/structured/index.js +321 -0
  60. package/dist/components/MindGraph/core/process/layout/type.d.ts +44 -0
  61. package/dist/components/MindGraph/core/process/layout/type.js +51 -0
  62. package/dist/components/MindGraph/core/process/line.d.ts +9 -0
  63. package/dist/components/MindGraph/core/process/line.js +69 -0
  64. package/dist/components/MindGraph/core/process/node-valid.d.ts +6 -0
  65. package/dist/components/MindGraph/core/process/node-valid.js +35 -0
  66. package/dist/components/MindGraph/core/process/orientation.d.ts +8 -0
  67. package/dist/components/MindGraph/core/process/orientation.js +40 -0
  68. package/dist/components/MindGraph/core/process/size.d.ts +4 -0
  69. package/dist/components/MindGraph/core/process/size.js +16 -0
  70. package/dist/components/MindGraph/core/process/visible.d.ts +16 -0
  71. package/dist/components/MindGraph/core/process/visible.js +99 -0
  72. package/dist/components/MindGraph/core/render/calc-visible.d.ts +11 -0
  73. package/dist/components/MindGraph/core/render/calc-visible.js +25 -0
  74. package/dist/components/MindGraph/core/render/connect/bezier.d.ts +2 -0
  75. package/dist/components/MindGraph/core/render/connect/bezier.js +12 -0
  76. package/dist/components/MindGraph/core/render/connect/get-path-render.d.ts +2 -0
  77. package/dist/components/MindGraph/core/render/connect/get-path-render.js +17 -0
  78. package/dist/components/MindGraph/core/render/connect/index.d.ts +10 -0
  79. package/dist/components/MindGraph/core/render/connect/index.js +45 -0
  80. package/dist/components/MindGraph/core/render/connect/line.d.ts +2 -0
  81. package/dist/components/MindGraph/core/render/connect/line.js +71 -0
  82. package/dist/components/MindGraph/core/render/connect/temporary-line.d.ts +15 -0
  83. package/dist/components/MindGraph/core/render/connect/temporary-line.js +44 -0
  84. package/dist/components/MindGraph/core/render/index.d.ts +27 -0
  85. package/dist/components/MindGraph/core/render/index.js +8 -0
  86. package/dist/components/MindGraph/core/render/layout.d.ts +12 -0
  87. package/dist/components/MindGraph/core/render/layout.js +85 -0
  88. package/dist/components/MindGraph/demo.js +54 -0
  89. package/dist/components/MindGraph/index.d.ts +3 -0
  90. package/dist/components/MindGraph/index.js +3 -0
  91. package/dist/components/MindGraph/react/component/index.d.ts +3 -0
  92. package/dist/components/MindGraph/react/component/index.js +227 -0
  93. package/dist/components/MindGraph/react/component/index.module.less +72 -0
  94. package/dist/components/MindGraph/react/component/nodes.d.ts +13 -0
  95. package/dist/components/MindGraph/react/component/nodes.js +153 -0
  96. package/dist/components/MindGraph/react/hook/use-drag.d.ts +20 -0
  97. package/dist/components/MindGraph/react/hook/use-drag.js +191 -0
  98. package/dist/components/MindGraph/react/hook/use-shadow-state.d.ts +2 -0
  99. package/dist/components/MindGraph/react/hook/use-shadow-state.js +24 -0
  100. package/dist/components/MindGraph/react/index.d.ts +154 -0
  101. package/dist/components/MindGraph/react/index.js +9 -0
  102. package/dist/components/MindGraph/react/scrollbar/axis/index.d.ts +25 -0
  103. package/dist/components/MindGraph/react/scrollbar/axis/index.js +143 -0
  104. package/dist/components/MindGraph/react/scrollbar/axis/index.module.less +48 -0
  105. package/dist/components/MindGraph/react/scrollbar/index.d.ts +8 -0
  106. package/dist/components/MindGraph/react/scrollbar/index.js +134 -0
  107. package/dist/components/MindGraph/react/tools/class-name-wrapper.d.ts +1 -0
  108. package/dist/components/MindGraph/react/tools/class-name-wrapper.js +5 -0
  109. package/dist/{SliderVerify → components/SliderVerify}/icons/close.js +0 -1
  110. package/dist/{SliderVerify → components/SliderVerify}/icons/refresh.js +0 -1
  111. package/dist/components/SliderVerify/icons/slider.d.ts +1 -0
  112. package/dist/{SliderVerify → components/SliderVerify}/icons/slider.js +0 -1
  113. package/dist/{SliderVerify → components/SliderVerify}/style.module.less +119 -121
  114. package/dist/{StyledQueryFilter → components/StyledQueryFilter}/index.less +22 -22
  115. package/dist/{StyledTable → components/StyledTable}/index.less +11 -11
  116. package/dist/{TabSearchTools → components/TabSearchTools}/index.d.ts +2 -2
  117. package/dist/{TabSearchTools → components/TabSearchTools}/index.js +1 -1
  118. package/dist/components/index.d.ts +6 -0
  119. package/dist/components/index.js +6 -0
  120. package/dist/hooks/index.d.ts +1 -0
  121. package/dist/hooks/index.js +1 -0
  122. package/dist/hooks/useBIHooks/index.d.ts +10 -0
  123. package/dist/hooks/useBIHooks/index.js +64 -0
  124. package/dist/index.d.ts +3 -5
  125. package/dist/index.js +3 -5
  126. package/dist/utils/bi/index.d.ts +2 -0
  127. package/dist/utils/bi/index.js +35 -0
  128. package/dist/utils/format/index.js +8 -8
  129. package/dist/utils/index.d.ts +1 -0
  130. package/dist/utils/index.js +1 -0
  131. package/package.json +33 -20
  132. /package/dist/{FlexRowCol → components/FlexRowCol}/index.d.ts +0 -0
  133. /package/dist/{SliderVerify/icons/close.d.ts → components/MindGraph/demo.d.ts} +0 -0
  134. /package/dist/{SliderVerify/icons/refresh.d.ts → components/SliderVerify/icons/close.d.ts} +0 -0
  135. /package/dist/{SliderVerify/icons/slider.d.ts → components/SliderVerify/icons/refresh.d.ts} +0 -0
  136. /package/dist/{SliderVerify → components/SliderVerify}/index.d.ts +0 -0
  137. /package/dist/{SliderVerify → components/SliderVerify}/index.js +0 -0
  138. /package/dist/{StyledQueryFilter → components/StyledQueryFilter}/index.d.ts +0 -0
  139. /package/dist/{StyledQueryFilter → components/StyledQueryFilter}/index.js +0 -0
  140. /package/dist/{StyledTable → components/StyledTable}/index.d.ts +0 -0
  141. /package/dist/{StyledTable → components/StyledTable}/index.js +0 -0
@@ -0,0 +1,20 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ import * as dagre from 'dagre';
6
+ import { Mind } from "../../index";
7
+ export var generateDagreGraphic = function generateDagreGraphic(options) {
8
+ var DirectionToRankdir = _defineProperty(_defineProperty({}, Mind.Direction.x, 'LR'), Mind.Direction.y, 'BT');
9
+ var graphic = new dagre.graphlib.Graph();
10
+ graphic.setGraph({
11
+ nodesep: options.nodeSeparate,
12
+ rankdir: DirectionToRankdir[options.direction],
13
+ ranker: 'tight-tree',
14
+ ranksep: options.rankSeparate
15
+ });
16
+ graphic.setDefaultEdgeLabel(function () {
17
+ return {};
18
+ });
19
+ return graphic;
20
+ };
@@ -0,0 +1,10 @@
1
+ import { Process } from '../index';
2
+ export declare class DescendantCenterLayout implements Process.Lifecycle {
3
+ private options;
4
+ private cacheMap;
5
+ private root;
6
+ private getRootHeirOrientation;
7
+ start: (context: Process.StartContext) => void;
8
+ afterEvery: (context: Process.EveryContext) => void;
9
+ end: () => void;
10
+ }
@@ -0,0 +1,146 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ // 子代整体居中对齐布局
9
+ // 算法默认会将同一rank(层级)的直系子代,在垂直于布局的方向上中心对齐
10
+ // 故而通过递归,将所有后代统一视作一个整体计算尺寸,得出偏移
11
+ // 即可实现后代居中功能
12
+ import * as dagre from 'dagre';
13
+ import { Helper } from "../../helper";
14
+ import { Mind } from "../../index";
15
+ import { generateDagreGraphic } from "./dagre";
16
+ export var DescendantCenterLayout = /*#__PURE__*/_createClass(function DescendantCenterLayout() {
17
+ var _this = this;
18
+ _classCallCheck(this, DescendantCenterLayout);
19
+ _defineProperty(this, "options", void 0);
20
+ _defineProperty(this, "cacheMap", void 0);
21
+ _defineProperty(this, "root", void 0);
22
+ _defineProperty(this, "getRootHeirOrientation", void 0);
23
+ _defineProperty(this, "start", function (context) {
24
+ var options = context.options,
25
+ cacheMap = context.cacheMap,
26
+ root = context.root,
27
+ getRootHeirOrientation = context.getRootHeirOrientation;
28
+ _this.root = root;
29
+ _this.options = options;
30
+ _this.cacheMap = cacheMap;
31
+ _this.getRootHeirOrientation = getRootHeirOrientation;
32
+ });
33
+ // 递归返回,子节点处理完成
34
+ _defineProperty(this, "afterEvery", function (context) {
35
+ var cache = context.cache;
36
+ var node = cache.node;
37
+ // 区域矩形初始化为本身尺寸,用作计算
38
+ var localityRect = {
39
+ height: cache.rect.height,
40
+ width: cache.rect.width,
41
+ x: 0,
42
+ y: 0
43
+ };
44
+ cache.processCache.descendantCenterLayout = {
45
+ localityRect: localityRect
46
+ };
47
+ // 设置子代节点
48
+ // 由于是深度优先遍历,并且 afterEvery 在子代遍历完成之后触发
49
+ // 故而,子代本身得局部矩形信息已经计算完成
50
+ var children = Helper.getLayoutCalcChildren(node, _this.root.node.id, _this.getRootHeirOrientation);
51
+ // 子代为空,或者子代需要折叠,则,本身尺寸作为区域尺寸,x y 直接居中即可
52
+ if (children.length === 0) {
53
+ localityRect.x = cache.rect.width / 2;
54
+ localityRect.y = cache.rect.height / 2;
55
+ return;
56
+ }
57
+
58
+ // 创建一个局部的计算图
59
+ var graphic = generateDagreGraphic(_this.options);
60
+ // 设置区域根节点
61
+ graphic.setNode(node.id, localityRect);
62
+ children.forEach(function (child) {
63
+ var cache = _this.cacheMap.get(child.id);
64
+ // 子节点区域矩形信息
65
+ var localityRect = cache.processCache.descendantCenterLayout.localityRect;
66
+ // 子节点区域在父级区域矩形信息中的位置信息
67
+ var localityRectInParent = {
68
+ height: localityRect.height,
69
+ width: localityRect.width,
70
+ x: 0,
71
+ y: 0
72
+ };
73
+ cache.processCache.descendantCenterLayout.localityRectInParent = localityRectInParent;
74
+ graphic.setNode(child.id, localityRectInParent);
75
+ if (cache.orientation === Mind.Orientation.positive) {
76
+ graphic.setEdge(node.id, child.id);
77
+ } else {
78
+ graphic.setEdge(child.id, node.id);
79
+ }
80
+ });
81
+ dagre.layout(graphic);
82
+ var graph = graphic.graph();
83
+ // 回填区域尺寸数据
84
+ localityRect.width = graph.width;
85
+ localityRect.height = graph.height;
86
+ });
87
+ _defineProperty(this, "end", function () {
88
+ var rootCache = _this.cacheMap.get(_this.root.node.id);
89
+ var rootNode = rootCache.node;
90
+ // 保存整体布局尺寸
91
+ rootCache.layoutSize = {
92
+ height: rootCache.processCache.descendantCenterLayout.localityRect.height,
93
+ width: rootCache.processCache.descendantCenterLayout.localityRect.width
94
+ };
95
+ Helper.breadthFirstWalkTree(rootNode, {
96
+ after: function after() {
97
+ // default
98
+ },
99
+ before: function before(node) {
100
+ var cache = _this.cacheMap.get(node.id);
101
+ if (!cache || Helper.judgeIfHeirAndFold(node, cache.parent, _this.root, _this.getRootHeirOrientation)) {
102
+ return false;
103
+ }
104
+
105
+ // 根节点,无父级,自身位置就是正确位置,原点位置为(0,0)
106
+ if (!cache.parent) {
107
+ cache.rect.x = cache.processCache.descendantCenterLayout.localityRect.x;
108
+ cache.rect.y = cache.processCache.descendantCenterLayout.localityRect.y;
109
+ cache.processCache.descendantCenterLayout.origin = {
110
+ x: 0,
111
+ y: 0
112
+ };
113
+ }
114
+ // 广度优先遍历,故而,节点所领导的区域位于的坐标系原点已确定
115
+ else {
116
+ var parentCache = _this.cacheMap.get(cache.parent.id);
117
+ // 坐标系原点
118
+ var origin = parentCache.processCache.descendantCenterLayout.origin;
119
+ // 自身所领导的区域容器位于父容器的矩形信息
120
+ var localityRectInParent = cache.processCache.descendantCenterLayout.localityRectInParent;
121
+ // 自身所领导的区域容器矩形信息
122
+ var localityReact = cache.processCache.descendantCenterLayout.localityRect;
123
+
124
+ // 节点所领导区域左上角坐标
125
+ // 即,领导区域的原点
126
+ var nodeOrigin = {
127
+ x: origin.x + localityRectInParent.x - localityRectInParent.width / 2,
128
+ y: origin.y + localityRectInParent.y - localityRectInParent.height / 2
129
+ };
130
+ cache.processCache.descendantCenterLayout.origin = nodeOrigin;
131
+
132
+ // 根据区域原点计算出实际坐标
133
+ cache.rect.x = localityReact.x + nodeOrigin.x;
134
+ cache.rect.y = localityReact.y + nodeOrigin.y;
135
+
136
+ // 清空无用数据
137
+ cache.processCache.descendantCenterLayout.localityRectInParent = undefined;
138
+ cache.processCache.descendantCenterLayout.localityRect = undefined;
139
+ }
140
+
141
+ // 折叠,则,子代无需继续计算
142
+ return !Helper.judgeIfAllChildFold(node, _this.root.node.id);
143
+ }
144
+ });
145
+ });
146
+ });
@@ -0,0 +1,10 @@
1
+ import { Process } from '../index';
2
+ export declare class HeirCenterLayout implements Process.Lifecycle {
3
+ private graphic;
4
+ private cacheMap;
5
+ private root;
6
+ private options;
7
+ start: (context: Process.StartContext) => void;
8
+ every: (context: Process.EveryContext) => void;
9
+ end: () => void;
10
+ }
@@ -0,0 +1,52 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ // 直系子代居中对齐布局
9
+ import * as dagre from 'dagre';
10
+ import { Mind } from "../../index";
11
+ import { generateDagreGraphic } from "./dagre";
12
+ export var HeirCenterLayout = /*#__PURE__*/_createClass(function HeirCenterLayout() {
13
+ var _this = this;
14
+ _classCallCheck(this, HeirCenterLayout);
15
+ _defineProperty(this, "graphic", void 0);
16
+ _defineProperty(this, "cacheMap", void 0);
17
+ _defineProperty(this, "root", void 0);
18
+ _defineProperty(this, "options", void 0);
19
+ _defineProperty(this, "start", function (context) {
20
+ var options = context.options,
21
+ root = context.root,
22
+ cacheMap = context.cacheMap;
23
+ _this.root = root;
24
+ _this.cacheMap = cacheMap;
25
+ _this.options = options;
26
+ _this.graphic = generateDagreGraphic(options);
27
+ });
28
+ _defineProperty(this, "every", function (context) {
29
+ var cache = context.cache;
30
+ var node = cache.node,
31
+ parent = cache.parent;
32
+ _this.graphic.setNode(node.id, cache.rect);
33
+ if (parent) {
34
+ if (cache.orientation === Mind.Orientation.positive) {
35
+ _this.graphic.setEdge(parent.id, node.id);
36
+ } else {
37
+ _this.graphic.setEdge(node.id, parent.id);
38
+ }
39
+ }
40
+ });
41
+ _defineProperty(this, "end", function () {
42
+ // 计算关系
43
+ dagre.layout(_this.graphic);
44
+ var rootCache = _this.cacheMap.get(_this.root.node.id);
45
+ // 存储整体布局尺寸
46
+ var graph = _this.graphic.graph();
47
+ rootCache.layoutSize = {
48
+ height: graph.height,
49
+ width: graph.width
50
+ };
51
+ });
52
+ });
@@ -0,0 +1,3 @@
1
+ export { DescendantCenterLayout } from './descendant-center';
2
+ export { HeirCenterLayout } from './heir-center';
3
+ export { StructuredLayout } from './structured';
@@ -0,0 +1,3 @@
1
+ export { DescendantCenterLayout } from "./descendant-center";
2
+ export { HeirCenterLayout } from "./heir-center";
3
+ export { StructuredLayout } from "./structured";
@@ -0,0 +1,2 @@
1
+ import { DraggableLayout } from '../type';
2
+ export declare const calcDragAttach: typeof DraggableLayout.calcDragAttach;
@@ -0,0 +1,172 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ import { Helper } from "../../../helper";
5
+ import { Mind } from "../../../index";
6
+ export var calcDragAttach = function calcDragAttach(context) {
7
+ var options = context.options,
8
+ cacheMap = context.cacheMap,
9
+ root = context.root,
10
+ canBeAttachedNodes = context.canBeAttachedNodes,
11
+ draggingRect = context.draggingRect,
12
+ ignoreNodes = context.ignoreNodes;
13
+ var vertical = options.direction === Mind.Direction.y;
14
+ var orientation = Mind.Orientation.root;
15
+ var rootRect = cacheMap.get(root.node.id).rect;
16
+ var targetLinkPoint = {
17
+ x: 0,
18
+ y: 0
19
+ };
20
+ if (vertical) {
21
+ targetLinkPoint.x = draggingRect.x;
22
+ // 上部/正向区域
23
+ if (draggingRect.y + draggingRect.height / 2 < rootRect.y - rootRect.height / 2) {
24
+ orientation = Mind.Orientation.positive;
25
+ targetLinkPoint.y = draggingRect.y + draggingRect.height / 2;
26
+ }
27
+ // 下部/负向区域
28
+ else if (draggingRect.y - draggingRect.height / 2 > rootRect.y + rootRect.height / 2) {
29
+ orientation = Mind.Orientation.negative;
30
+ targetLinkPoint.y = draggingRect.y - draggingRect.height / 2;
31
+ }
32
+ } else {
33
+ targetLinkPoint.y = draggingRect.y;
34
+ // 右侧/正向区域
35
+ if (draggingRect.x - draggingRect.width / 2 > rootRect.x + rootRect.width / 2) {
36
+ orientation = Mind.Orientation.positive;
37
+ targetLinkPoint.x = draggingRect.x - draggingRect.width / 2;
38
+ }
39
+ // 左侧/负向区域
40
+ else if (draggingRect.x + draggingRect.width / 2 < rootRect.x - rootRect.width / 2) {
41
+ orientation = Mind.Orientation.negative;
42
+ targetLinkPoint.x = draggingRect.x + draggingRect.width / 2;
43
+ }
44
+ }
45
+
46
+ // 没有处于有效的可链接区域,返回undefined
47
+ if (orientation === Mind.Orientation.root) {
48
+ return undefined;
49
+ }
50
+ var linkNode = undefined;
51
+ var linkPoint = undefined;
52
+ var minMainDistance = Infinity;
53
+ var _iterator = _createForOfIteratorHelper(canBeAttachedNodes),
54
+ _step;
55
+ try {
56
+ var _loop = function _loop() {
57
+ var node = _step.value;
58
+ // 过滤忽略节点
59
+ if (ignoreNodes.find(function (item) {
60
+ return item.id === node.id;
61
+ })) {
62
+ return 0; // continue
63
+ }
64
+ var cache = cacheMap.get(node.id);
65
+ if (!cache) {
66
+ return 0; // continue
67
+ }
68
+
69
+ // 只有位于同一渲染区域才需要计算
70
+ if (cache.orientation !== Mind.Orientation.root && cache.orientation !== orientation) {
71
+ return 0; // continue
72
+ }
73
+ var rect = cache.rect;
74
+ var canBeLinkPoint = {
75
+ x: 0,
76
+ y: 0
77
+ };
78
+ // 计算被链接点坐标
79
+ if (vertical) {
80
+ canBeLinkPoint.x = rect.x;
81
+
82
+ // 目标节点位于正向区域/根节点上方
83
+ if (orientation === Mind.Orientation.positive) {
84
+ canBeLinkPoint.y = rect.y - rect.height / 2;
85
+ if (canBeLinkPoint.y < targetLinkPoint.y) {
86
+ return 0; // continue
87
+ }
88
+ } else {
89
+ canBeLinkPoint.y = rect.y + rect.height / 2;
90
+ if (canBeLinkPoint.y > targetLinkPoint.y) {
91
+ return 0; // continue
92
+ }
93
+ }
94
+ } else {
95
+ canBeLinkPoint.y = rect.y;
96
+
97
+ // 目标节点位于正向区域/根节点右侧
98
+ if (orientation === Mind.Orientation.positive) {
99
+ canBeLinkPoint.x = rect.x + rect.width / 2;
100
+ if (canBeLinkPoint.x > targetLinkPoint.x) {
101
+ return 0; // continue
102
+ }
103
+ } else {
104
+ canBeLinkPoint.x = rect.x - rect.width / 2;
105
+ if (canBeLinkPoint.x < targetLinkPoint.x) {
106
+ return 0; // continue
107
+ }
108
+ }
109
+ }
110
+ var crossBoundary = cache.processCache.structuredLayout.crossBoundary[0];
111
+ // 当前节点为根节点
112
+ if (root.node.id === node.id) {
113
+ crossBoundary = orientation === Mind.Orientation.negative ? cache.processCache.structuredLayout.crossBoundary[0] : cache.processCache.structuredLayout.crossBoundary[1];
114
+ }
115
+ // 限定交叉轴范围
116
+ var targetCrossValue = vertical ? draggingRect.x : draggingRect.y;
117
+ if (targetCrossValue < crossBoundary.min - options.nodeSeparate / 2 || targetCrossValue > crossBoundary.max + options.nodeSeparate / 2) {
118
+ return 0; // continue
119
+ }
120
+
121
+ // 主轴距离最近
122
+ var mainDistance = vertical ? Math.abs(canBeLinkPoint.y - targetLinkPoint.y) : Math.abs(canBeLinkPoint.x - targetLinkPoint.x);
123
+ // 主轴距离最近
124
+ if (mainDistance < minMainDistance) {
125
+ minMainDistance = mainDistance;
126
+ linkNode = node;
127
+ linkPoint = canBeLinkPoint;
128
+ }
129
+ },
130
+ _ret;
131
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
132
+ _ret = _loop();
133
+ if (_ret === 0) continue;
134
+ }
135
+ } catch (err) {
136
+ _iterator.e(err);
137
+ } finally {
138
+ _iterator.f();
139
+ }
140
+ if (linkPoint && linkNode) {
141
+ var children = linkNode.children || [];
142
+
143
+ // 根节点折叠特殊处理
144
+ if (linkNode.id === root.node.id) {
145
+ var fold = root.node.fold || [];
146
+ // positive 没被折叠,此时镜像节点位于 positive,检查是否为视觉叶节点使用 positive 子代
147
+ if (!fold[1] && orientation === Mind.Orientation.positive) {
148
+ children = root.positive || [];
149
+ }
150
+ // negative 没被折叠,此时镜像节点位于 negative,检查是否为视觉叶节点使用 negative 子代
151
+ else if (!fold[0] && orientation === Mind.Orientation.negative) {
152
+ children = root.negative || [];
153
+ } else {
154
+ children = [];
155
+ }
156
+ }
157
+
158
+ // 视觉叶节点,主轴距离限制,超出一定比例则视作无效
159
+ if (Helper.judgeIfVisualLeaf(linkNode, children) && minMainDistance > options.rankSeparate * 2) {
160
+ return undefined;
161
+ }
162
+ return {
163
+ link: {
164
+ source: linkPoint,
165
+ target: targetLinkPoint
166
+ },
167
+ node: linkNode,
168
+ orientation: orientation
169
+ };
170
+ }
171
+ return undefined;
172
+ };
@@ -0,0 +1,2 @@
1
+ import { DraggableLayout } from '../type';
2
+ export declare const calcDropIndex: typeof DraggableLayout.calcDropIndex;
@@ -0,0 +1,38 @@
1
+ import { Mind } from "../../../index";
2
+ export var calcDropIndex = function calcDropIndex(context) {
3
+ var attachedNodeChildren = context.attachedNodeChildren,
4
+ dropPosition = context.dropPosition,
5
+ options = context.options,
6
+ cacheMap = context.cacheMap,
7
+ dragNode = context.dragNode,
8
+ attachedNode = context.attachedNode;
9
+ // 节点没有子代,则,拖拽节点自动为第一个节点
10
+ // 当子代被折叠的时候,自动作为第一个节点
11
+ if (!attachedNodeChildren || attachedNodeChildren.length === 0 || attachedNode.fold) {
12
+ return 0;
13
+ }
14
+ var vertical = options.direction === Mind.Direction.y;
15
+ var dragNodeJudgeValue = vertical ? dropPosition.x : dropPosition.y;
16
+ var getNodeJudgeValue = function getNodeJudgeValue(id) {
17
+ var cache = cacheMap.get(id);
18
+ var rect = cache.rect;
19
+ return vertical ? rect.x : rect.y;
20
+ };
21
+
22
+ // 处理边界情况
23
+ if (dragNodeJudgeValue <= getNodeJudgeValue(attachedNodeChildren[0].id)) {
24
+ return attachedNodeChildren[0].id === dragNode.id ? -1 : 0;
25
+ }
26
+ if (dragNodeJudgeValue >= getNodeJudgeValue(attachedNodeChildren[attachedNodeChildren.length - 1].id)) {
27
+ return attachedNodeChildren[attachedNodeChildren.length - 1].id === dragNode.id ? -1 : attachedNodeChildren.length;
28
+ }
29
+ for (var index = 1; index < attachedNodeChildren.length; index++) {
30
+ if (dragNodeJudgeValue >= getNodeJudgeValue(attachedNodeChildren[index - 1].id) && dragNodeJudgeValue <= getNodeJudgeValue(attachedNodeChildren[index].id)) {
31
+ if (attachedNodeChildren[index - 1].id === dragNode.id || attachedNodeChildren[index].id === dragNode.id) {
32
+ return -1;
33
+ }
34
+ return index;
35
+ }
36
+ }
37
+ return -1;
38
+ };
@@ -0,0 +1,10 @@
1
+ import { Mind } from '../../../index';
2
+ /**
3
+ * 获取节点交叉轴边界
4
+ * - 如果存在视觉子代,请保证视觉子代边界计算完成
5
+ * @param cache
6
+ * @param children
7
+ * @param vertical
8
+ * @param cacheMap
9
+ */
10
+ export declare const getNodeCrossBoundary: (cache: Mind.NodeCache, children: Mind.Node[] | undefined, vertical: boolean, cacheMap: Mind.CacheMap) => Mind.Range<number>;
@@ -0,0 +1,35 @@
1
+ import { Helper } from "../../../helper";
2
+ /**
3
+ * 获取节点交叉轴边界
4
+ * - 如果存在视觉子代,请保证视觉子代边界计算完成
5
+ * @param cache
6
+ * @param children
7
+ * @param vertical
8
+ * @param cacheMap
9
+ */
10
+ export var getNodeCrossBoundary = function getNodeCrossBoundary(cache, children, vertical, cacheMap) {
11
+ var boundary = {
12
+ max: Infinity,
13
+ min: -Infinity
14
+ };
15
+ var selfBoundary = {
16
+ max: Infinity,
17
+ min: -Infinity
18
+ };
19
+ if (vertical) {
20
+ selfBoundary.min = cache.rect.x - cache.rect.width / 2;
21
+ selfBoundary.max = cache.rect.x + cache.rect.width / 2;
22
+ } else {
23
+ selfBoundary.min = cache.rect.y - cache.rect.height / 2;
24
+ selfBoundary.max = cache.rect.y + cache.rect.height / 2;
25
+ }
26
+
27
+ // 视觉上的叶节点
28
+ if (Helper.judgeIfVisualLeaf(cache.node, children)) {
29
+ return selfBoundary;
30
+ } else {
31
+ boundary.min = Math.min(cacheMap.get(children[0].id).processCache.structuredLayout.crossBoundary[0].min, selfBoundary.min);
32
+ boundary.max = Math.max(cacheMap.get(children[children.length - 1].id).processCache.structuredLayout.crossBoundary[0].max, selfBoundary.max);
33
+ }
34
+ return boundary;
35
+ };
@@ -0,0 +1,13 @@
1
+ import { Process } from '../../index';
2
+ import { DraggableLayout } from '../type';
3
+ export declare class StructuredLayout extends DraggableLayout implements Process.Lifecycle {
4
+ private options;
5
+ private cacheMap;
6
+ private root;
7
+ private getRootHeirOrientation;
8
+ start: (context: Process.StartContext) => void;
9
+ afterEvery: (context: Process.EveryContext) => void;
10
+ end: () => void;
11
+ static calcDragAttach: typeof DraggableLayout.calcDragAttach;
12
+ static calcDropIndex: typeof DraggableLayout.calcDropIndex;
13
+ }