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,423 @@
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ 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); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ 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; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ 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); }
10
+ import { merge, throttle } from 'lodash';
11
+ import { WithDefault } from "../default";
12
+ import { Render } from "../render";
13
+ import { Drag } from "./drag";
14
+ import { nodeTranslateTo } from "./node-translate-to";
15
+ import { Zoom } from "./zoom";
16
+ export var Graphic = /*#__PURE__*/_createClass(
17
+ /**
18
+ * 脑图管理器
19
+ * - `viewport`用作判断可视区域
20
+ * - svg连线将会自动注入到`container`中
21
+ * - transform 相关信息将会自动注入到`container`中
22
+ * @param viewport 视窗
23
+ * @param container 容器
24
+ * @param options 配置参数
25
+ */
26
+ function Graphic(viewport, _container, _options) {
27
+ var _this = this;
28
+ _classCallCheck(this, Graphic);
29
+ /**
30
+ * 节点相关信息缓存,树形结构拍平
31
+ */
32
+ _defineProperty(this, "cacheMap", new Map());
33
+ _defineProperty(this, "options", void 0);
34
+ _defineProperty(this, "container", void 0);
35
+ _defineProperty(this, "viewport", void 0);
36
+ _defineProperty(this, "transform", WithDefault.transform());
37
+ _defineProperty(this, "root", void 0);
38
+ _defineProperty(this, "anchor", void 0);
39
+ _defineProperty(this, "resizeObserver", void 0);
40
+ _defineProperty(this, "unbindCache", []);
41
+ _defineProperty(this, "zoom", void 0);
42
+ /**
43
+ * 同步 options 中的 zoom extent
44
+ */
45
+ _defineProperty(this, "syncZoomExtentOptions", function () {
46
+ _this.zoom.syncZoomExtentOptions({
47
+ options: _this.options
48
+ });
49
+ });
50
+ /**
51
+ * 获取当前可见的节点
52
+ */
53
+ _defineProperty(this, "getVisibleNodes", function () {
54
+ var nodes = [];
55
+ for (var _i = 0, _Array$from = Array.from(_this.cacheMap.values()); _i < _Array$from.length; _i++) {
56
+ var cache = _Array$from[_i];
57
+ if (cache.visible.node) {
58
+ // cache 中根节点 node 是源数据的 copy,故而需要特殊处理
59
+ if (_this.root && cache.node.id === _this.root.node.id) {
60
+ nodes.push(_this.root.node);
61
+ } else {
62
+ nodes.push(cache.node);
63
+ }
64
+ }
65
+ }
66
+ return nodes;
67
+ });
68
+ /**
69
+ * 获取节点定位锚点(左上角)位置,可在节点绘制的时候确定其位置
70
+ * - 推荐所有节点使用`position:absolute;left:0;top:0;`并且配合`transform`来定位,避免出现绘制异常
71
+ * @param id 节点对应id
72
+ */
73
+ _defineProperty(this, "getNodeAnchorCoordinate", function (id) {
74
+ var cache = _this.cacheMap.get(id);
75
+ if (!cache) {
76
+ return undefined;
77
+ } else {
78
+ return {
79
+ x: cache.rect.x - cache.rect.width / 2,
80
+ y: cache.rect.y - cache.rect.height / 2
81
+ };
82
+ }
83
+ });
84
+ // 绑定监听事件
85
+ _defineProperty(this, "bindEventListener", function () {
86
+ // 注销之前的事件绑定
87
+ _this.unbind();
88
+ // 上下文菜单触发事件
89
+ var onContextMenu = function onContextMenu(e) {
90
+ _this.options.event.onViewportContextMenu(e);
91
+ // 禁止弹出默认菜单
92
+ e.preventDefault();
93
+ };
94
+ // 视窗右键菜单操作
95
+ _this.viewport.addEventListener('contextmenu', onContextMenu);
96
+ _this.unbindCache.push(function () {
97
+ _this.viewport.removeEventListener('contextmenu', onContextMenu);
98
+ });
99
+
100
+ // 绑定 zoom 监听
101
+ // 此处再次封装 event 是为了在 onZoomEventTrigger 内容改变的时候,依旧可以正确触发事件
102
+ _this.zoom.bind(_this.onTransform, {
103
+ end: function end(e) {
104
+ return _this.options.event.onZoomEventTrigger.end(e);
105
+ },
106
+ start: function start(e) {
107
+ return _this.options.event.onZoomEventTrigger.start(e);
108
+ },
109
+ zoom: function zoom(e) {
110
+ return _this.options.event.onZoomEventTrigger.zoom(e);
111
+ }
112
+ });
113
+ _this.unbindCache.push(_this.zoom.destroy);
114
+
115
+ // 绑定尺寸改变监听事件
116
+ if (ResizeObserver) {
117
+ _this.resizeObserver = new ResizeObserver(_this.onViewportResize);
118
+ _this.resizeObserver.observe(_this.viewport);
119
+ _this.unbindCache.push(function () {
120
+ return _this.resizeObserver.unobserve(_this.viewport);
121
+ });
122
+ }
123
+ });
124
+ _defineProperty(this, "onTransform", function (transform) {
125
+ _this.transform = transform;
126
+ // 直接修改 dom style
127
+ _this.container.style.transform = "translateX(".concat(transform.x, "px) translateY(").concat(transform.y, "px) scale(").concat(transform.scale, ")");
128
+ _this.container.style.transformOrigin = 'left top';
129
+
130
+ // 刷新可视区域
131
+ _this.refreshVisible();
132
+ // 回调事件,通知外部 transform 改变
133
+ _this.options.callback.onTransformChange(transform);
134
+ });
135
+ /**
136
+ * - 计算节点可见是否改变,如改变,则通知外部
137
+ * - 重渲染连线,销毁不必要的连线
138
+ */
139
+ _defineProperty(this, "refreshVisible", function () {
140
+ if (_this.cacheMap.size) {
141
+ var visibleChange = _this.calcVisible();
142
+ // 节点可见性改变,通知外部重新渲染
143
+ if (visibleChange.node) {
144
+ _this.options.callback.onNodeVisibleChange(_this.getVisibleNodes());
145
+ }
146
+ // 连线可见性出现改变,则重新绘制线条
147
+ if (visibleChange.lineAttachParent) {
148
+ _this.connect();
149
+ }
150
+ }
151
+ });
152
+ _defineProperty(this, "throttleRefreshVisible", throttle(this.refreshVisible, 100));
153
+ /**
154
+ * 视窗尺寸变化
155
+ * @private
156
+ */
157
+ _defineProperty(this, "onViewportResize", function () {
158
+ _this.zoom.syncZoomExtent({
159
+ height: _this.viewport.clientHeight,
160
+ width: _this.viewport.clientWidth
161
+ });
162
+ // 避免频繁的刷新可视区域导致界面卡顿
163
+ _this.throttleRefreshVisible();
164
+ });
165
+ /**
166
+ * 注销事件绑定
167
+ * - 请在销毁组件之前调用
168
+ */
169
+ _defineProperty(this, "unbind", function () {
170
+ _this.unbindCache.forEach(function (dispose) {
171
+ return dispose();
172
+ });
173
+ _this.unbindCache = [];
174
+ });
175
+ /**
176
+ * 判断节点是否可视
177
+ * @param id 节点对应id
178
+ */
179
+ _defineProperty(this, "judgeNodeVisible", function (id) {
180
+ var cache = _this.cacheMap.get(id);
181
+ if (cache) {
182
+ return cache.visible.node;
183
+ } else {
184
+ return false;
185
+ }
186
+ });
187
+ /**
188
+ * 设定 `options`
189
+ * - 函数不会自动执行重渲染,如果改变的`options`需要重新计算布局等操作,推荐使用 `setData` 驱动数据重渲染
190
+ * @param options 设定选项
191
+ * @param isMerge 是否与之前的`options`做合并操作
192
+ */
193
+ _defineProperty(this, "setOptions", function (options) {
194
+ var isMerge = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
195
+ if (isMerge) {
196
+ _this.options = merge({}, _this.options, options || {});
197
+ } else {
198
+ _this.options = WithDefault.options(options);
199
+ }
200
+ _this.syncZoomExtentOptions();
201
+ });
202
+ /**
203
+ * 生成拖动控制器
204
+ * - 根节点不可拖拽
205
+ * - 当前暂时只有`Mind.ChildAlignMode.structured`布局算法支持拖拽功能
206
+ * @param drag 拖动节点node对象或id
207
+ * @return
208
+ * - 当root(没有调用`setData`)不存在时,或者`drag`为根节点时,返回`undefined`
209
+ * - 正常情况返回 `Drag` 类对象
210
+ */
211
+ _defineProperty(this, "dragControllerBuilder", function (drag) {
212
+ var _this$cacheMap$get;
213
+ var dragNode = typeof drag === 'string' ? (_this$cacheMap$get = _this.cacheMap.get(drag)) === null || _this$cacheMap$get === void 0 ? void 0 : _this$cacheMap$get.node : drag;
214
+ if (_this.root && dragNode && dragNode.id !== _this.root.node.id) {
215
+ return new Drag({
216
+ cacheMap: _this.cacheMap,
217
+ container: _this.container,
218
+ dragNode: dragNode,
219
+ options: _this.options,
220
+ root: _this.root
221
+ });
222
+ } else {
223
+ return undefined;
224
+ }
225
+ });
226
+ /**
227
+ * 获取渲染层尺寸
228
+ */
229
+ _defineProperty(this, "getLayoutSize", function () {
230
+ var _this$root;
231
+ var root = _this.cacheMap.get(((_this$root = _this.root) === null || _this$root === void 0 || (_this$root = _this$root.node) === null || _this$root === void 0 ? void 0 : _this$root.id) || '');
232
+ if (root) {
233
+ return root.layoutSize;
234
+ } else {
235
+ return undefined;
236
+ }
237
+ });
238
+ /**
239
+ * 获取`id`对应节点
240
+ * @param id 节点`id`
241
+ */
242
+ _defineProperty(this, "getNode", function (id) {
243
+ var _this$cacheMap$get2;
244
+ return (_this$cacheMap$get2 = _this.cacheMap.get(id)) === null || _this$cacheMap$get2 === void 0 ? void 0 : _this$cacheMap$get2.node;
245
+ });
246
+ /**
247
+ * 获取`id`对应节点父级
248
+ * @param id 节点`id`
249
+ */
250
+ _defineProperty(this, "getParent", function (id) {
251
+ var _this$cacheMap$get3;
252
+ return (_this$cacheMap$get3 = _this.cacheMap.get(id)) === null || _this$cacheMap$get3 === void 0 ? void 0 : _this$cacheMap$get3.parent;
253
+ });
254
+ /**
255
+ * 获取`id`对应节点渲染方位
256
+ * @param id 节点`id`
257
+ */
258
+ _defineProperty(this, "getNodeOrientation", function (id) {
259
+ var _this$cacheMap$get4;
260
+ return (_this$cacheMap$get4 = _this.cacheMap.get(id)) === null || _this$cacheMap$get4 === void 0 ? void 0 : _this$cacheMap$get4.orientation;
261
+ });
262
+ /**
263
+ * 主动设置位移缩放
264
+ * - 会与之前的`transform`做深度合并
265
+ * - 请注意:`setTransform` 之后 `onTransformChange` 事件依旧会触发
266
+ * - 此方法不受 `zoomExtent.translate`、`zoomExtent.scale` 限制
267
+ * @param transform 位移缩放数据
268
+ * @param duration 周期,如果配置,则执行变换会附带动画效果
269
+ */
270
+ _defineProperty(this, "setTransform", function (transform, duration) {
271
+ _this.transform = merge({}, _this.transform, transform);
272
+ _this.zoom.setTransform(_this.transform, duration);
273
+ });
274
+ /**
275
+ * 设定位移
276
+ * - 此方法受到 `zoomExtent.translate` 限制
277
+ * @param translate 位移差(屏幕尺度)
278
+ * @param duration 周期,如果配置,则执行变换会附带动画效果
279
+ */
280
+ _defineProperty(this, "translate", function (translate, duration) {
281
+ _this.zoom.translate(translate, duration);
282
+ });
283
+ /**
284
+ * 设定缩放
285
+ * - 此方法受到 `zoomExtent.translate` 限制
286
+ * - 此方法受到 `zoomExtent.scale` 限制
287
+ * @param scale 缩放比
288
+ * @param point 缩放相对点(如不配置或为`undefined`,则默认相对于`viewport`中心缩放)
289
+ * @param duration 动画周期,如配置,则位移会附带动画效果
290
+ */
291
+ _defineProperty(this, "scale", function (scale, point, duration) {
292
+ _this.zoom.scale(scale, point, duration);
293
+ });
294
+ /**
295
+ * 将某一个节点中心从某个相对位置做位移(其尺度为屏幕尺度)操作
296
+ * - 此方法不受 `zoomExtent.translate` 限制
297
+ * @param config 配置参数
298
+ * @param config.id 节点id
299
+ * @param config.diff 位移差
300
+ * @param config.relative 相对位置
301
+ * @param duration 动画周期,如配置,则位移会附带动画效果
302
+ */
303
+ _defineProperty(this, "nodeTranslateTo", function (config, duration) {
304
+ var id = config.id,
305
+ diff = config.diff,
306
+ relative = config.relative;
307
+ nodeTranslateTo({
308
+ cacheMap: _this.cacheMap,
309
+ diff: diff,
310
+ id: id,
311
+ relative: relative,
312
+ transform: _this.transform,
313
+ viewport: _this.viewport,
314
+ zoom: _this.zoom
315
+ }, duration);
316
+ });
317
+ /**
318
+ * 获取位移缩放信息
319
+ */
320
+ _defineProperty(this, "getTransform", function () {
321
+ return _objectSpread({}, _this.transform);
322
+ });
323
+ /**
324
+ * 设置锚点节点
325
+ * @param id 锚定节点id(如不设定,则清空锚点,根节点居中,缩放比归一)
326
+ */
327
+ _defineProperty(this, "setAnchor", function (id) {
328
+ _this.anchor = id;
329
+ });
330
+ /**
331
+ * 设置/更新数据,启动重渲染
332
+ * - 在重计算定位时,将保持 `anchor` 对应节点在屏幕上的相对位置不变
333
+ * - 如果 `anchor` 没有设定,或者找不到对应节点,则,根节点居中,缩放比重置为1
334
+ * @param root 根数据
335
+ */
336
+ _defineProperty(this, "setData", function (root) {
337
+ _this.root = root;
338
+ // 计算布局,定位锚点
339
+ _this.layout();
340
+ // 计算可见范围
341
+ _this.calcVisible();
342
+ // 连线
343
+ _this.connect();
344
+ // 同步层级尺寸
345
+ _this.syncLayoutSize();
346
+ // 设定数据后,通知外部可见节点
347
+ _this.options.callback.onNodeVisibleChange(_this.getVisibleNodes());
348
+ });
349
+ /**
350
+ * 刷新
351
+ */
352
+ _defineProperty(this, "refresh", function () {
353
+ if (_this.root) {
354
+ _this.setData(_this.root);
355
+ }
356
+ });
357
+ /**
358
+ * 渲染链接到某个`container`下
359
+ * @param container 容器
360
+ */
361
+ _defineProperty(this, "connectTo", function (container) {
362
+ Render.connect({
363
+ cacheMap: _this.cacheMap,
364
+ container: container,
365
+ options: _this.options,
366
+ root: _this.root
367
+ });
368
+ });
369
+ /**
370
+ * 同步渲染层尺寸到 container 中
371
+ */
372
+ _defineProperty(this, "syncLayoutSize", function () {
373
+ var _this$cacheMap$get5, _this$root2;
374
+ var layoutSize = ((_this$cacheMap$get5 = _this.cacheMap.get(((_this$root2 = _this.root) === null || _this$root2 === void 0 ? void 0 : _this$root2.node.id) || '')) === null || _this$cacheMap$get5 === void 0 ? void 0 : _this$cacheMap$get5.layoutSize) || {
375
+ height: 0,
376
+ width: 0
377
+ };
378
+ _this.container.style.width = "".concat(layoutSize.width, "px");
379
+ _this.container.style.height = "".concat(layoutSize.height, "px");
380
+ });
381
+ /**
382
+ * 链接各个节点
383
+ */
384
+ _defineProperty(this, "connect", function () {
385
+ _this.connectTo(_this.container);
386
+ });
387
+ /**
388
+ * 计算脑图布局
389
+ * - 请保证调用之前 data 已经通过 setData 设置完备
390
+ */
391
+ _defineProperty(this, "layout", function () {
392
+ Render.layout({
393
+ anchor: _this.anchor,
394
+ cacheMap: _this.cacheMap,
395
+ container: _this.container,
396
+ options: _this.options,
397
+ root: _this.root,
398
+ transform: _this.transform,
399
+ viewport: _this.viewport,
400
+ zoom: _this.zoom
401
+ });
402
+ });
403
+ /**
404
+ * 计算各节点可见性,以及链接可见性
405
+ */
406
+ _defineProperty(this, "calcVisible", function () {
407
+ return Render.calcVisible({
408
+ cacheMap: _this.cacheMap,
409
+ container: _this.container,
410
+ options: _this.options,
411
+ root: _this.root,
412
+ transform: _this.transform,
413
+ viewport: _this.viewport,
414
+ zoom: _this.zoom
415
+ });
416
+ });
417
+ this.viewport = viewport;
418
+ this.container = _container;
419
+ this.options = WithDefault.options(_options);
420
+ this.zoom = new Zoom(viewport);
421
+ this.syncZoomExtentOptions();
422
+ this.bindEventListener();
423
+ });
@@ -0,0 +1,11 @@
1
+ import { Mind } from '../index';
2
+ import { Zoom } from './zoom';
3
+ export declare const nodeTranslateTo: (context: {
4
+ id: string;
5
+ cacheMap: Mind.CacheMap;
6
+ diff: Mind.Coordinate;
7
+ relative: Mind.Relative;
8
+ viewport: HTMLElement;
9
+ transform: Mind.Transform;
10
+ zoom: Zoom;
11
+ }, duration?: number) => void;
@@ -0,0 +1,55 @@
1
+ import { Helper } from "../helper";
2
+ import { Mind } from "../index";
3
+ export var nodeTranslateTo = function nodeTranslateTo(context, duration) {
4
+ var id = context.id,
5
+ cacheMap = context.cacheMap,
6
+ diff = context.diff,
7
+ relative = context.relative,
8
+ viewport = context.viewport,
9
+ transform = context.transform,
10
+ zoom = context.zoom;
11
+ var cache = cacheMap.get(id);
12
+ if (!cache) {
13
+ throw Helper.error('id match is not exist or folded');
14
+ } else {
15
+ var viewportSize = {
16
+ height: viewport.clientHeight,
17
+ width: viewport.clientWidth
18
+ };
19
+ var relativeCoordinate = {
20
+ x: 0,
21
+ y: 0
22
+ };
23
+ var nodeToScreenCoordinate = {
24
+ x: cache.rect.x * transform.scale,
25
+ y: cache.rect.y * transform.scale
26
+ };
27
+ switch (relative.x) {
28
+ case Mind.RelativeX.left:
29
+ relativeCoordinate.x = 0;
30
+ break;
31
+ case Mind.RelativeX.middle:
32
+ relativeCoordinate.x = viewportSize.width / 2;
33
+ break;
34
+ case Mind.RelativeX.right:
35
+ relativeCoordinate.x = viewportSize.width;
36
+ break;
37
+ }
38
+ switch (relative.y) {
39
+ case Mind.RelativeY.top:
40
+ relativeCoordinate.y = 0;
41
+ break;
42
+ case Mind.RelativeY.middle:
43
+ relativeCoordinate.y = viewportSize.height / 2;
44
+ break;
45
+ case Mind.RelativeY.bottom:
46
+ relativeCoordinate.y = viewportSize.height;
47
+ break;
48
+ }
49
+ zoom.setTransform({
50
+ scale: transform.scale,
51
+ x: relativeCoordinate.x - nodeToScreenCoordinate.x + diff.x,
52
+ y: relativeCoordinate.y - nodeToScreenCoordinate.y + diff.y
53
+ }, duration);
54
+ }
55
+ };
@@ -0,0 +1,17 @@
1
+ import { Mind } from '../index';
2
+ export declare class Zoom {
3
+ private viewport;
4
+ private controller;
5
+ private callback?;
6
+ private event?;
7
+ constructor(viewport: HTMLElement);
8
+ bind: (callback: (transform: Mind.Transform) => void, event: Mind.ZoomEvent) => void;
9
+ syncZoomExtent: (size: Mind.Size) => void;
10
+ syncZoomExtentOptions: (context: {
11
+ options: Required<Mind.Options>;
12
+ }) => void;
13
+ scale: (scale: number, point?: Mind.Coordinate, duration?: number) => void;
14
+ translate: (translate: Mind.Coordinate, duration?: number) => void;
15
+ setTransform: (transform: Mind.Transform, duration?: number) => void;
16
+ destroy: () => void;
17
+ }
@@ -0,0 +1,90 @@
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
+ // @ts-nocheck
9
+
10
+ import * as D3 from 'd3';
11
+ export var Zoom = /*#__PURE__*/_createClass(function Zoom(viewport) {
12
+ var _this = this;
13
+ _classCallCheck(this, Zoom);
14
+ _defineProperty(this, "viewport", void 0);
15
+ _defineProperty(this, "controller", D3.zoom());
16
+ _defineProperty(this, "callback", void 0);
17
+ _defineProperty(this, "event", void 0);
18
+ _defineProperty(this, "bind", function (callback, event) {
19
+ var start = event.start,
20
+ zoom = event.zoom,
21
+ end = event.end;
22
+ _this.callback = callback;
23
+ _this.event = event;
24
+ D3.select(_this.viewport).call(_this.controller.on('zoom', function (e) {
25
+ var transform = {
26
+ scale: e.transform.k,
27
+ x: e.transform.x,
28
+ y: e.transform.y
29
+ };
30
+ callback(transform);
31
+ zoom && zoom(e.sourceEvent);
32
+ }).on('start', function (e) {
33
+ return start && start(e.sourceEvent);
34
+ }).on('end', function (e) {
35
+ return end && end(e.sourceEvent);
36
+ })).call(_this.controller.transform, D3.zoomIdentity);
37
+ });
38
+ _defineProperty(this, "syncZoomExtent", function (size) {
39
+ _this.controller.extent([[0, 0], [size.width, size.height]]);
40
+ });
41
+ _defineProperty(this, "syncZoomExtentOptions", function (context) {
42
+ var zoomExtent = context.options.zoomExtent;
43
+ if (zoomExtent.translate) {
44
+ _this.controller.translateExtent(zoomExtent.translate.map(function (item) {
45
+ return [item.x, item.y];
46
+ }));
47
+ } else {
48
+ _this.controller.translateExtent([[-Infinity, -Infinity], [Infinity, Infinity]]);
49
+ }
50
+ if (zoomExtent.scale) {
51
+ _this.controller.scaleExtent(zoomExtent.scale);
52
+ } else {
53
+ _this.controller.scaleExtent([0.5, 2]);
54
+ }
55
+ });
56
+ _defineProperty(this, "scale", function (scale, point) {
57
+ var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
58
+ if (duration) {
59
+ D3.select(_this.viewport).transition().duration(duration).call(_this.controller.scaleTo, scale, point && [point.x, point.y]);
60
+ } else {
61
+ D3.select(_this.viewport).call(_this.controller.scaleTo, scale, point && [point.x, point.y]);
62
+ }
63
+ });
64
+ _defineProperty(this, "translate", function (translate) {
65
+ var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
66
+ if (duration) {
67
+ D3.select(_this.viewport).transition().duration(duration).call(_this.controller.translateBy, translate.x, translate.y);
68
+ } else {
69
+ D3.select(_this.viewport).call(_this.controller.translateBy, translate.x, translate.y);
70
+ }
71
+ });
72
+ _defineProperty(this, "setTransform", function (transform) {
73
+ var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
74
+ if (duration) {
75
+ D3.select(_this.viewport).transition().duration(duration).call(_this.controller.transform, new D3.ZoomTransform(transform.scale, transform.x, transform.y));
76
+ } else {
77
+ D3.select(_this.viewport).call(_this.controller.transform, new D3.ZoomTransform(transform.scale, transform.x, transform.y));
78
+ }
79
+ });
80
+ _defineProperty(this, "destroy", function () {
81
+ D3.select(_this.viewport).on('.zoom', null).on('.start', null).on('.end', null);
82
+ });
83
+ this.viewport = viewport;
84
+ this.controller.filter(function (event) {
85
+ // 修改默认,手势
86
+ // 右键移动,ctrl+滚轮 缩放
87
+ event.preventDefault();
88
+ return event.button === 0 && event.type !== 'dblclick' || event.ctrlKey && event.type === 'wheel';
89
+ });
90
+ });
@@ -0,0 +1,5 @@
1
+ import { Mind } from '../index';
2
+ export declare const breadthFirstWalkTree: (node: Mind.Node, callback: {
3
+ before: (node: Mind.Node) => boolean;
4
+ after: (rank: Mind.Node[]) => void;
5
+ }) => void;
@@ -0,0 +1,21 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ export var breadthFirstWalkTree = function breadthFirstWalkTree(node, callback) {
8
+ var recursion = function recursion(rank) {
9
+ var nextLevel = [];
10
+ rank.forEach(function (item) {
11
+ if (callback.before(item)) {
12
+ nextLevel.push.apply(nextLevel, _toConsumableArray(item.children || []));
13
+ }
14
+ });
15
+ if (nextLevel.length) {
16
+ recursion(nextLevel);
17
+ }
18
+ callback.after(rank);
19
+ };
20
+ recursion([node]);
21
+ };
@@ -0,0 +1,10 @@
1
+ import { Mind } from '../index';
2
+ /**
3
+ * 深度优先遍历
4
+ * @param root 根节点
5
+ * @param callback before:递归之前(返回 true 代表继续搜索子代,false代表终止),after:子代递归完成返回
6
+ */
7
+ export declare const depthFirstWalkTree: (root: Mind.Node, callback: {
8
+ before: (node: Mind.Node, parent?: Mind.Node) => boolean;
9
+ after: (node: Mind.Node, parent?: Mind.Node) => void;
10
+ }) => void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 深度优先遍历
3
+ * @param root 根节点
4
+ * @param callback before:递归之前(返回 true 代表继续搜索子代,false代表终止),after:子代递归完成返回
5
+ */
6
+ export var depthFirstWalkTree = function depthFirstWalkTree(root, callback) {
7
+ var recursion = function recursion(now, parent) {
8
+ if (callback.before(now, parent)) {
9
+ ;
10
+ (now.children || []).forEach(function (n) {
11
+ return recursion(n, now);
12
+ });
13
+ }
14
+ callback.after(now, parent);
15
+ };
16
+ recursion(root, undefined);
17
+ };
@@ -0,0 +1,6 @@
1
+ import { Mind } from '../index';
2
+ /**
3
+ * 获取某个节点的所有后代
4
+ * @param node 节点
5
+ */
6
+ export declare const descendant: (node: Mind.Node) => Mind.Node[];