ebaoferc 0.0.1 → 0.0.2-beta.0
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.
- package/dist/{FlexRowCol → components/FlexRowCol}/index.js +1 -1
- package/dist/components/MindGraph/core/default.d.ts +6 -0
- package/dist/components/MindGraph/core/default.js +81 -0
- package/dist/components/MindGraph/core/graphic/drag.d.ts +42 -0
- package/dist/components/MindGraph/core/graphic/drag.js +120 -0
- package/dist/components/MindGraph/core/graphic/index.d.ts +181 -0
- package/dist/components/MindGraph/core/graphic/index.js +423 -0
- package/dist/components/MindGraph/core/graphic/node-translate-to.d.ts +11 -0
- package/dist/components/MindGraph/core/graphic/node-translate-to.js +55 -0
- package/dist/components/MindGraph/core/graphic/zoom.d.ts +17 -0
- package/dist/components/MindGraph/core/graphic/zoom.js +89 -0
- package/dist/components/MindGraph/core/helper/breadth-first-walk-tree.d.ts +5 -0
- package/dist/components/MindGraph/core/helper/breadth-first-walk-tree.js +21 -0
- package/dist/components/MindGraph/core/helper/depth-first-walk-tree.d.ts +10 -0
- package/dist/components/MindGraph/core/helper/depth-first-walk-tree.js +17 -0
- package/dist/components/MindGraph/core/helper/descendant.d.ts +6 -0
- package/dist/components/MindGraph/core/helper/descendant.js +28 -0
- package/dist/components/MindGraph/core/helper/error.d.ts +1 -0
- package/dist/components/MindGraph/core/helper/error.js +3 -0
- package/dist/components/MindGraph/core/helper/get-layout-calc-children.d.ts +10 -0
- package/dist/components/MindGraph/core/helper/get-layout-calc-children.js +37 -0
- package/dist/components/MindGraph/core/helper/get-svg-path-id.d.ts +1 -0
- package/dist/components/MindGraph/core/helper/get-svg-path-id.js +4 -0
- package/dist/components/MindGraph/core/helper/index.d.ts +23 -0
- package/dist/components/MindGraph/core/helper/index.js +26 -0
- package/dist/components/MindGraph/core/helper/judge-if-all-child-fold.d.ts +7 -0
- package/dist/components/MindGraph/core/helper/judge-if-all-child-fold.js +14 -0
- package/dist/components/MindGraph/core/helper/judge-if-heir-and-fold.d.ts +10 -0
- package/dist/components/MindGraph/core/helper/judge-if-heir-and-fold.js +26 -0
- package/dist/components/MindGraph/core/helper/judge-if-visual-leaf.d.ts +6 -0
- package/dist/components/MindGraph/core/helper/judge-if-visual-leaf.js +7 -0
- package/dist/components/MindGraph/core/helper/root-to-node-array.d.ts +2 -0
- package/dist/components/MindGraph/core/helper/root-to-node-array.js +27 -0
- package/dist/components/MindGraph/core/helper/transform-root-to-walkable.d.ts +5 -0
- package/dist/components/MindGraph/core/helper/transform-root-to-walkable.js +32 -0
- package/dist/components/MindGraph/core/helper/with-prefix.d.ts +1 -0
- package/dist/components/MindGraph/core/helper/with-prefix.js +3 -0
- package/dist/components/MindGraph/core/index.d.ts +394 -0
- package/dist/components/MindGraph/core/index.js +86 -0
- package/dist/components/MindGraph/core/process/anchor.d.ts +12 -0
- package/dist/components/MindGraph/core/process/anchor.js +63 -0
- package/dist/components/MindGraph/core/process/index.d.ts +91 -0
- package/dist/components/MindGraph/core/process/index.js +30 -0
- package/dist/components/MindGraph/core/process/layout/dagre.d.ts +2 -0
- package/dist/components/MindGraph/core/process/layout/dagre.js +20 -0
- package/dist/components/MindGraph/core/process/layout/descendant-center.d.ts +10 -0
- package/dist/components/MindGraph/core/process/layout/descendant-center.js +146 -0
- package/dist/components/MindGraph/core/process/layout/heir-center.d.ts +10 -0
- package/dist/components/MindGraph/core/process/layout/heir-center.js +52 -0
- package/dist/components/MindGraph/core/process/layout/index.d.ts +3 -0
- package/dist/components/MindGraph/core/process/layout/index.js +3 -0
- package/dist/components/MindGraph/core/process/layout/structured/calc-drag-attach.d.ts +2 -0
- package/dist/components/MindGraph/core/process/layout/structured/calc-drag-attach.js +172 -0
- package/dist/components/MindGraph/core/process/layout/structured/calc-drop-index.d.ts +2 -0
- package/dist/components/MindGraph/core/process/layout/structured/calc-drop-index.js +38 -0
- package/dist/components/MindGraph/core/process/layout/structured/get-node-cross-boundary.d.ts +10 -0
- package/dist/components/MindGraph/core/process/layout/structured/get-node-cross-boundary.js +35 -0
- package/dist/components/MindGraph/core/process/layout/structured/index.d.ts +13 -0
- package/dist/components/MindGraph/core/process/layout/structured/index.js +321 -0
- package/dist/components/MindGraph/core/process/layout/type.d.ts +44 -0
- package/dist/components/MindGraph/core/process/layout/type.js +51 -0
- package/dist/components/MindGraph/core/process/line.d.ts +9 -0
- package/dist/components/MindGraph/core/process/line.js +69 -0
- package/dist/components/MindGraph/core/process/node-valid.d.ts +6 -0
- package/dist/components/MindGraph/core/process/node-valid.js +35 -0
- package/dist/components/MindGraph/core/process/orientation.d.ts +8 -0
- package/dist/components/MindGraph/core/process/orientation.js +40 -0
- package/dist/components/MindGraph/core/process/size.d.ts +4 -0
- package/dist/components/MindGraph/core/process/size.js +16 -0
- package/dist/components/MindGraph/core/process/visible.d.ts +16 -0
- package/dist/components/MindGraph/core/process/visible.js +99 -0
- package/dist/components/MindGraph/core/render/calc-visible.d.ts +11 -0
- package/dist/components/MindGraph/core/render/calc-visible.js +25 -0
- package/dist/components/MindGraph/core/render/connect/bezier.d.ts +2 -0
- package/dist/components/MindGraph/core/render/connect/bezier.js +12 -0
- package/dist/components/MindGraph/core/render/connect/get-path-render.d.ts +2 -0
- package/dist/components/MindGraph/core/render/connect/get-path-render.js +17 -0
- package/dist/components/MindGraph/core/render/connect/index.d.ts +10 -0
- package/dist/components/MindGraph/core/render/connect/index.js +45 -0
- package/dist/components/MindGraph/core/render/connect/line.d.ts +2 -0
- package/dist/components/MindGraph/core/render/connect/line.js +71 -0
- package/dist/components/MindGraph/core/render/connect/temporary-line.d.ts +15 -0
- package/dist/components/MindGraph/core/render/connect/temporary-line.js +44 -0
- package/dist/components/MindGraph/core/render/index.d.ts +27 -0
- package/dist/components/MindGraph/core/render/index.js +8 -0
- package/dist/components/MindGraph/core/render/layout.d.ts +12 -0
- package/dist/components/MindGraph/core/render/layout.js +85 -0
- package/dist/components/MindGraph/demo.js +54 -0
- package/dist/components/MindGraph/index.d.ts +3 -0
- package/dist/components/MindGraph/index.js +3 -0
- package/dist/components/MindGraph/react/component/index.d.ts +3 -0
- package/dist/components/MindGraph/react/component/index.js +227 -0
- package/dist/components/MindGraph/react/component/index.module.less +72 -0
- package/dist/components/MindGraph/react/component/nodes.d.ts +13 -0
- package/dist/components/MindGraph/react/component/nodes.js +153 -0
- package/dist/components/MindGraph/react/hook/use-drag.d.ts +20 -0
- package/dist/components/MindGraph/react/hook/use-drag.js +191 -0
- package/dist/components/MindGraph/react/hook/use-shadow-state.d.ts +2 -0
- package/dist/components/MindGraph/react/hook/use-shadow-state.js +24 -0
- package/dist/components/MindGraph/react/index.d.ts +154 -0
- package/dist/components/MindGraph/react/index.js +9 -0
- package/dist/components/MindGraph/react/scrollbar/axis/index.d.ts +25 -0
- package/dist/components/MindGraph/react/scrollbar/axis/index.js +143 -0
- package/dist/components/MindGraph/react/scrollbar/axis/index.module.less +48 -0
- package/dist/components/MindGraph/react/scrollbar/index.d.ts +8 -0
- package/dist/components/MindGraph/react/scrollbar/index.js +134 -0
- package/dist/components/MindGraph/react/tools/class-name-wrapper.d.ts +1 -0
- package/dist/components/MindGraph/react/tools/class-name-wrapper.js +5 -0
- package/dist/{SliderVerify → components/SliderVerify}/icons/close.js +0 -1
- package/dist/{SliderVerify → components/SliderVerify}/icons/refresh.js +0 -1
- package/dist/components/SliderVerify/icons/slider.d.ts +1 -0
- package/dist/{SliderVerify → components/SliderVerify}/icons/slider.js +0 -1
- package/dist/{SliderVerify → components/SliderVerify}/style.module.less +119 -121
- package/dist/{StyledQueryFilter → components/StyledQueryFilter}/index.less +22 -22
- package/dist/{StyledTable → components/StyledTable}/index.less +11 -11
- package/dist/{TabSearchTools → components/TabSearchTools}/index.d.ts +2 -2
- package/dist/{TabSearchTools → components/TabSearchTools}/index.js +1 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +6 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +3 -5
- package/dist/utils/format/index.js +8 -8
- package/package.json +32 -20
- /package/dist/{FlexRowCol → components/FlexRowCol}/index.d.ts +0 -0
- /package/dist/{SliderVerify/icons/close.d.ts → components/MindGraph/demo.d.ts} +0 -0
- /package/dist/{SliderVerify/icons/refresh.d.ts → components/SliderVerify/icons/close.d.ts} +0 -0
- /package/dist/{SliderVerify/icons/slider.d.ts → components/SliderVerify/icons/refresh.d.ts} +0 -0
- /package/dist/{SliderVerify → components/SliderVerify}/index.d.ts +0 -0
- /package/dist/{SliderVerify → components/SliderVerify}/index.js +0 -0
- /package/dist/{StyledQueryFilter → components/StyledQueryFilter}/index.d.ts +0 -0
- /package/dist/{StyledQueryFilter → components/StyledQueryFilter}/index.js +0 -0
- /package/dist/{StyledTable → components/StyledTable}/index.d.ts +0 -0
- /package/dist/{StyledTable → components/StyledTable}/index.js +0 -0
|
@@ -0,0 +1,321 @@
|
|
|
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
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); }
|
|
15
|
+
// 规整模式布局,多用于组织结构等
|
|
16
|
+
// 边界对齐,并且布局规整,父级永远位于子代中间
|
|
17
|
+
import { Helper } from "../../../helper";
|
|
18
|
+
import { Mind } from "../../../index";
|
|
19
|
+
import { DraggableLayout } from "../type";
|
|
20
|
+
import { calcDragAttach } from "./calc-drag-attach";
|
|
21
|
+
import { calcDropIndex } from "./calc-drop-index";
|
|
22
|
+
import { getNodeCrossBoundary } from "./get-node-cross-boundary";
|
|
23
|
+
export var StructuredLayout = /*#__PURE__*/function (_DraggableLayout) {
|
|
24
|
+
_inherits(StructuredLayout, _DraggableLayout);
|
|
25
|
+
var _super = _createSuper(StructuredLayout);
|
|
26
|
+
function StructuredLayout() {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, StructuredLayout);
|
|
29
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
+
args[_key] = arguments[_key];
|
|
31
|
+
}
|
|
32
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "options", void 0);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "cacheMap", void 0);
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "root", void 0);
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "getRootHeirOrientation", void 0);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "start", function (context) {
|
|
38
|
+
var options = context.options,
|
|
39
|
+
cacheMap = context.cacheMap,
|
|
40
|
+
root = context.root,
|
|
41
|
+
getRootHeirOrientation = context.getRootHeirOrientation;
|
|
42
|
+
_this.root = root;
|
|
43
|
+
_this.options = options;
|
|
44
|
+
_this.cacheMap = cacheMap;
|
|
45
|
+
_this.getRootHeirOrientation = getRootHeirOrientation;
|
|
46
|
+
});
|
|
47
|
+
// 递归返回,子节点处理完成
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "afterEvery", function (context) {
|
|
49
|
+
var cache = context.cache;
|
|
50
|
+
var node = cache.node;
|
|
51
|
+
// 区域矩形初始化为本身尺寸,用作计算
|
|
52
|
+
var localityRect = {
|
|
53
|
+
height: cache.rect.height,
|
|
54
|
+
width: cache.rect.width,
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
};
|
|
58
|
+
cache.processCache.structuredLayout = {
|
|
59
|
+
crossBoundary: [{
|
|
60
|
+
max: Infinity,
|
|
61
|
+
min: -Infinity
|
|
62
|
+
}, {
|
|
63
|
+
max: Infinity,
|
|
64
|
+
min: -Infinity
|
|
65
|
+
}],
|
|
66
|
+
localityRect: localityRect
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// 设置子代节点
|
|
70
|
+
// 由于是深度优先遍历,并且 afterEvery 在子代遍历完成之后触发
|
|
71
|
+
// 故而,子代本身得局部矩形信息已经计算完成
|
|
72
|
+
var children = Helper.getLayoutCalcChildren(node, _this.root.node.id, _this.getRootHeirOrientation);
|
|
73
|
+
|
|
74
|
+
// 需要被计算的子代为空(被折叠或者没有子代)
|
|
75
|
+
if (children.length === 0) {
|
|
76
|
+
localityRect.x = cache.rect.width / 2;
|
|
77
|
+
localityRect.y = cache.rect.height / 2;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var main = {
|
|
81
|
+
negative: 0,
|
|
82
|
+
positive: 0
|
|
83
|
+
};
|
|
84
|
+
var cross = {
|
|
85
|
+
negative: 0,
|
|
86
|
+
positive: 0
|
|
87
|
+
};
|
|
88
|
+
var vertical = _this.options.direction === Mind.Direction.y;
|
|
89
|
+
|
|
90
|
+
// 计算子代主轴范围
|
|
91
|
+
// 计算子代副轴尺寸
|
|
92
|
+
children.forEach(function (child) {
|
|
93
|
+
var childCache = _this.cacheMap.get(child.id);
|
|
94
|
+
var childLocalityRect = childCache.processCache.structuredLayout.localityRect;
|
|
95
|
+
var inParentPosition = {
|
|
96
|
+
x: 0,
|
|
97
|
+
y: 0
|
|
98
|
+
};
|
|
99
|
+
childCache.processCache.structuredLayout.inParentPosition = inParentPosition;
|
|
100
|
+
if (vertical) {
|
|
101
|
+
if (childCache.orientation === Mind.Orientation.positive) {
|
|
102
|
+
if (childLocalityRect.height > main.positive) {
|
|
103
|
+
main.positive = childLocalityRect.height;
|
|
104
|
+
}
|
|
105
|
+
inParentPosition.x = cross.positive + childLocalityRect.width / 2;
|
|
106
|
+
cross.positive += childLocalityRect.width + _this.options.nodeSeparate;
|
|
107
|
+
}
|
|
108
|
+
if (childCache.orientation === Mind.Orientation.negative) {
|
|
109
|
+
if (childLocalityRect.height > main.negative) {
|
|
110
|
+
main.negative = childLocalityRect.height;
|
|
111
|
+
}
|
|
112
|
+
inParentPosition.x = cross.negative + childLocalityRect.width / 2;
|
|
113
|
+
cross.negative += childLocalityRect.width + _this.options.nodeSeparate;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
if (childCache.orientation === Mind.Orientation.positive) {
|
|
117
|
+
if (childLocalityRect.width > main.positive) {
|
|
118
|
+
main.positive = childLocalityRect.width;
|
|
119
|
+
}
|
|
120
|
+
inParentPosition.y = cross.positive + childLocalityRect.height / 2;
|
|
121
|
+
cross.positive += childLocalityRect.height + _this.options.nodeSeparate;
|
|
122
|
+
}
|
|
123
|
+
if (childCache.orientation === Mind.Orientation.negative) {
|
|
124
|
+
if (childLocalityRect.width > main.negative) {
|
|
125
|
+
main.negative = childLocalityRect.width;
|
|
126
|
+
}
|
|
127
|
+
inParentPosition.y = cross.negative + childLocalityRect.height / 2;
|
|
128
|
+
cross.negative += childLocalityRect.height + _this.options.nodeSeparate;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 去除多余的间距
|
|
134
|
+
if (cross.positive) {
|
|
135
|
+
cross.positive -= _this.options.nodeSeparate;
|
|
136
|
+
}
|
|
137
|
+
if (cross.negative) {
|
|
138
|
+
cross.negative -= _this.options.nodeSeparate;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 副轴尺寸
|
|
142
|
+
var crossSize = Math.max(cross.positive, cross.negative, vertical ? cache.rect.width : cache.rect.height);
|
|
143
|
+
|
|
144
|
+
// 计算节点区域坐标
|
|
145
|
+
// 主轴两侧都有节点
|
|
146
|
+
if (main.positive && main.negative) {
|
|
147
|
+
// 垂直方向渲染,y模式下 positive 渲染在上侧
|
|
148
|
+
if (vertical) {
|
|
149
|
+
localityRect.y = main.positive + _this.options.rankSeparate + cache.rect.height / 2;
|
|
150
|
+
localityRect.x = crossSize / 2;
|
|
151
|
+
localityRect.width = crossSize;
|
|
152
|
+
localityRect.height = main.positive + main.negative + cache.rect.height + 2 * _this.options.rankSeparate;
|
|
153
|
+
}
|
|
154
|
+
// 水平渲染,x模式下 positive 渲染在右侧
|
|
155
|
+
else {
|
|
156
|
+
localityRect.x = main.negative + _this.options.rankSeparate + cache.rect.width / 2;
|
|
157
|
+
localityRect.y = crossSize / 2;
|
|
158
|
+
localityRect.height = crossSize;
|
|
159
|
+
localityRect.width = main.negative + main.positive + cache.rect.width + 2 * _this.options.rankSeparate;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// 只有负向区域存在节点
|
|
163
|
+
else if (main.negative && !main.positive) {
|
|
164
|
+
// 节点位于最上方
|
|
165
|
+
if (vertical) {
|
|
166
|
+
localityRect.y = cache.rect.height / 2;
|
|
167
|
+
localityRect.x = crossSize / 2;
|
|
168
|
+
localityRect.width = crossSize;
|
|
169
|
+
localityRect.height = main.negative + cache.rect.height + _this.options.rankSeparate;
|
|
170
|
+
}
|
|
171
|
+
// 节点位于最右侧
|
|
172
|
+
else {
|
|
173
|
+
localityRect.x = main.negative + _this.options.rankSeparate + cache.rect.width / 2;
|
|
174
|
+
localityRect.y = crossSize / 2;
|
|
175
|
+
localityRect.height = crossSize;
|
|
176
|
+
localityRect.width = main.negative + cache.rect.width + _this.options.rankSeparate;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// 只有正向区域存在节点
|
|
180
|
+
else if (main.positive && !main.negative) {
|
|
181
|
+
// 节点位于最下方
|
|
182
|
+
if (vertical) {
|
|
183
|
+
localityRect.y = main.positive + _this.options.rankSeparate + cache.rect.height / 2;
|
|
184
|
+
localityRect.x = crossSize / 2;
|
|
185
|
+
localityRect.width = crossSize;
|
|
186
|
+
localityRect.height = main.positive + cache.rect.height + _this.options.rankSeparate;
|
|
187
|
+
}
|
|
188
|
+
// 节点位于最左侧
|
|
189
|
+
else {
|
|
190
|
+
localityRect.x = cache.rect.width / 2;
|
|
191
|
+
localityRect.y = crossSize / 2;
|
|
192
|
+
localityRect.height = crossSize;
|
|
193
|
+
localityRect.width = main.positive + cache.rect.width + _this.options.rankSeparate;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 子代副轴原点偏移
|
|
198
|
+
var childCrossOriginDiff = {
|
|
199
|
+
negative: 0,
|
|
200
|
+
positive: 0
|
|
201
|
+
};
|
|
202
|
+
// 垂直方向渲染,y模式下 positive 渲染在上侧
|
|
203
|
+
if (vertical) {
|
|
204
|
+
childCrossOriginDiff.positive = localityRect.x - cross.positive / 2;
|
|
205
|
+
childCrossOriginDiff.negative = localityRect.x - cross.negative / 2;
|
|
206
|
+
}
|
|
207
|
+
// 水平渲染,x模式下 positive 渲染在右侧
|
|
208
|
+
else {
|
|
209
|
+
childCrossOriginDiff.positive = localityRect.y - cross.positive / 2;
|
|
210
|
+
childCrossOriginDiff.negative = localityRect.y - cross.negative / 2;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 计算子代位于父级区域内的坐标
|
|
214
|
+
children.forEach(function (child) {
|
|
215
|
+
var childCache = _this.cacheMap.get(child.id);
|
|
216
|
+
var inParentPosition = childCache.processCache.structuredLayout.inParentPosition;
|
|
217
|
+
var childLocalityRect = childCache.processCache.structuredLayout.localityRect;
|
|
218
|
+
if (vertical) {
|
|
219
|
+
// y 轴正向,位于节点上方
|
|
220
|
+
if (childCache.orientation === Mind.Orientation.positive) {
|
|
221
|
+
inParentPosition.y = localityRect.y - cache.rect.height / 2 - _this.options.rankSeparate - childLocalityRect.height / 2;
|
|
222
|
+
inParentPosition.x += childCrossOriginDiff.positive;
|
|
223
|
+
}
|
|
224
|
+
// y 轴负向,位于节点下方
|
|
225
|
+
if (childCache.orientation === Mind.Orientation.negative) {
|
|
226
|
+
inParentPosition.y = localityRect.y + cache.rect.height / 2 + _this.options.rankSeparate + childLocalityRect.height / 2;
|
|
227
|
+
inParentPosition.x += childCrossOriginDiff.negative;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
// x 轴,节点正向,右侧
|
|
231
|
+
if (childCache.orientation === Mind.Orientation.positive) {
|
|
232
|
+
inParentPosition.x = localityRect.x + cache.rect.width / 2 + _this.options.rankSeparate + childLocalityRect.width / 2;
|
|
233
|
+
inParentPosition.y += childCrossOriginDiff.positive;
|
|
234
|
+
}
|
|
235
|
+
// x 轴,节点负向,左侧
|
|
236
|
+
if (childCache.orientation === Mind.Orientation.negative) {
|
|
237
|
+
inParentPosition.x = localityRect.x - cache.rect.width / 2 - _this.options.rankSeparate - childLocalityRect.width / 2;
|
|
238
|
+
inParentPosition.y += childCrossOriginDiff.negative;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
_defineProperty(_assertThisInitialized(_this), "end", function () {
|
|
244
|
+
var rootCache = _this.cacheMap.get(_this.root.node.id);
|
|
245
|
+
var rootNode = rootCache.node;
|
|
246
|
+
// // 保存整体布局尺寸
|
|
247
|
+
rootCache.layoutSize = {
|
|
248
|
+
height: rootCache.processCache.structuredLayout.localityRect.height,
|
|
249
|
+
width: rootCache.processCache.structuredLayout.localityRect.width
|
|
250
|
+
};
|
|
251
|
+
var vertical = _this.options.direction === Mind.Direction.y;
|
|
252
|
+
Helper.breadthFirstWalkTree(rootNode, {
|
|
253
|
+
after: function after() {
|
|
254
|
+
// default
|
|
255
|
+
},
|
|
256
|
+
before: function before(node) {
|
|
257
|
+
var cache = _this.cacheMap.get(node.id);
|
|
258
|
+
if (!cache || Helper.judgeIfHeirAndFold(node, cache.parent, _this.root, _this.getRootHeirOrientation)) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// 根节点,无父级,自身位置就是正确位置,原点位置为(0,0)
|
|
263
|
+
if (!cache.parent) {
|
|
264
|
+
cache.rect.x = cache.processCache.structuredLayout.localityRect.x;
|
|
265
|
+
cache.rect.y = cache.processCache.structuredLayout.localityRect.y;
|
|
266
|
+
cache.processCache.structuredLayout.origin = {
|
|
267
|
+
x: 0,
|
|
268
|
+
y: 0
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// 广度优先遍历,故而,节点所领导的区域位于的坐标系原点已确定
|
|
272
|
+
else {
|
|
273
|
+
var parentCache = _this.cacheMap.get(cache.parent.id);
|
|
274
|
+
// 坐标系原点
|
|
275
|
+
var origin = parentCache.processCache.structuredLayout.origin;
|
|
276
|
+
// 自身所领导区域位于父区域的位置
|
|
277
|
+
var inParentPosition = cache.processCache.structuredLayout.inParentPosition;
|
|
278
|
+
// 自身所领导的区域容器矩形信息
|
|
279
|
+
var localityReact = cache.processCache.structuredLayout.localityRect;
|
|
280
|
+
|
|
281
|
+
// 节点所领导区域左上角坐标
|
|
282
|
+
// 即,领导区域的原点
|
|
283
|
+
var nodeOrigin = {
|
|
284
|
+
x: origin.x + inParentPosition.x - localityReact.width / 2,
|
|
285
|
+
y: origin.y + inParentPosition.y - localityReact.height / 2
|
|
286
|
+
};
|
|
287
|
+
cache.processCache.structuredLayout.origin = nodeOrigin;
|
|
288
|
+
|
|
289
|
+
// 根据区域原点计算出实际坐标
|
|
290
|
+
cache.rect.x = localityReact.x + nodeOrigin.x;
|
|
291
|
+
cache.rect.y = localityReact.y + nodeOrigin.y;
|
|
292
|
+
}
|
|
293
|
+
var crossBoundary = cache.processCache.structuredLayout.crossBoundary;
|
|
294
|
+
// 计算节点交叉轴范围
|
|
295
|
+
if (vertical) {
|
|
296
|
+
crossBoundary[0].min = cache.rect.x - cache.processCache.structuredLayout.localityRect.width / 2;
|
|
297
|
+
crossBoundary[0].max = cache.rect.x + cache.processCache.structuredLayout.localityRect.width / 2;
|
|
298
|
+
} else {
|
|
299
|
+
crossBoundary[0].min = cache.rect.y - cache.processCache.structuredLayout.localityRect.height / 2;
|
|
300
|
+
crossBoundary[0].max = cache.rect.y + cache.processCache.structuredLayout.localityRect.height / 2;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// 清空无用数据
|
|
304
|
+
cache.processCache.structuredLayout.inParentPosition = undefined;
|
|
305
|
+
cache.processCache.structuredLayout.localityRect = undefined;
|
|
306
|
+
|
|
307
|
+
// 折叠,则,子代无需继续计算
|
|
308
|
+
return !Helper.judgeIfAllChildFold(node, _this.root.node.id);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// 根节点交叉轴边界特殊处理
|
|
313
|
+
// 根节点折叠特殊处理
|
|
314
|
+
rootCache.processCache.structuredLayout.crossBoundary = [getNodeCrossBoundary(rootCache, (rootNode.fold || [])[0] ? [] : _this.root.negative, vertical, _this.cacheMap), getNodeCrossBoundary(rootCache, (rootNode.fold || [])[1] ? [] : _this.root.positive, vertical, _this.cacheMap)];
|
|
315
|
+
});
|
|
316
|
+
return _this;
|
|
317
|
+
}
|
|
318
|
+
return _createClass(StructuredLayout);
|
|
319
|
+
}(DraggableLayout);
|
|
320
|
+
_defineProperty(StructuredLayout, "calcDragAttach", calcDragAttach);
|
|
321
|
+
_defineProperty(StructuredLayout, "calcDropIndex", calcDropIndex);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Mind } from '../../index';
|
|
2
|
+
export declare class DraggableLayout {
|
|
3
|
+
/**
|
|
4
|
+
* 计算拖动关联信息
|
|
5
|
+
* @param context 上下文
|
|
6
|
+
* @param context.cacheMap 缓存地图
|
|
7
|
+
* @param context.draggingRect 正在拖动节点的大小以及位置
|
|
8
|
+
* @param context.canBeAttachedNodes 可以被关联的节点
|
|
9
|
+
* @param context.ignoreNodes 需要被忽略的节点
|
|
10
|
+
* @param context.root 根节点
|
|
11
|
+
* @param context.options 选项
|
|
12
|
+
* @return 如果没有合法的节点关联,则返回`undefined`
|
|
13
|
+
*/
|
|
14
|
+
static calcDragAttach: (context: {
|
|
15
|
+
cacheMap: Mind.CacheMap;
|
|
16
|
+
draggingRect: Mind.Coordinate & Mind.Size;
|
|
17
|
+
canBeAttachedNodes: Mind.Node[];
|
|
18
|
+
ignoreNodes: Mind.Node[];
|
|
19
|
+
root: Mind.Root;
|
|
20
|
+
options: Required<Mind.Options>;
|
|
21
|
+
}) => Mind.DragAttach | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* 计算拖动结束被放置的下标
|
|
24
|
+
* @param context 上下文
|
|
25
|
+
* @param context.cacheMap 缓存地图
|
|
26
|
+
* @param context.attachedNodeChildren 关联节点子代
|
|
27
|
+
* @param context.dropPosition 拖拽结束位置
|
|
28
|
+
* @param context.root 根节点
|
|
29
|
+
*/
|
|
30
|
+
static calcDropIndex: (context: {
|
|
31
|
+
cacheMap: Mind.CacheMap;
|
|
32
|
+
attachedNodeChildren: Mind.Node[] | undefined;
|
|
33
|
+
dropPosition: Mind.Coordinate;
|
|
34
|
+
attachedNode: Mind.Node;
|
|
35
|
+
dragNode: Mind.Node;
|
|
36
|
+
root: Mind.Root;
|
|
37
|
+
options: Mind.Options;
|
|
38
|
+
}) => number;
|
|
39
|
+
/**
|
|
40
|
+
* 是否为合法的继承了这个类的类对象
|
|
41
|
+
* @param classObject
|
|
42
|
+
*/
|
|
43
|
+
static isValidExtendsClass: (classObject: any) => any;
|
|
44
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import { Helper } from "../../helper";
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
export var DraggableLayout = /*#__PURE__*/_createClass(function DraggableLayout() {
|
|
11
|
+
_classCallCheck(this, DraggableLayout);
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* 计算拖动关联信息
|
|
15
|
+
* @param context 上下文
|
|
16
|
+
* @param context.cacheMap 缓存地图
|
|
17
|
+
* @param context.draggingRect 正在拖动节点的大小以及位置
|
|
18
|
+
* @param context.canBeAttachedNodes 可以被关联的节点
|
|
19
|
+
* @param context.ignoreNodes 需要被忽略的节点
|
|
20
|
+
* @param context.root 根节点
|
|
21
|
+
* @param context.options 选项
|
|
22
|
+
* @return 如果没有合法的节点关联,则返回`undefined`
|
|
23
|
+
*/
|
|
24
|
+
_defineProperty(DraggableLayout, "calcDragAttach", function (context) {
|
|
25
|
+
// 此处是为了 ts 报错
|
|
26
|
+
context = context;
|
|
27
|
+
throw Helper.error('DraggableLayout static calcDragAttach must be implemented');
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* 计算拖动结束被放置的下标
|
|
31
|
+
* @param context 上下文
|
|
32
|
+
* @param context.cacheMap 缓存地图
|
|
33
|
+
* @param context.attachedNodeChildren 关联节点子代
|
|
34
|
+
* @param context.dropPosition 拖拽结束位置
|
|
35
|
+
* @param context.root 根节点
|
|
36
|
+
*/
|
|
37
|
+
_defineProperty(DraggableLayout, "calcDropIndex", function (context) {
|
|
38
|
+
// 此处是为了 ts 报错
|
|
39
|
+
context = context;
|
|
40
|
+
throw Helper.error('DraggableLayout static calcDropIndex must be implemented');
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* 是否为合法的继承了这个类的类对象
|
|
44
|
+
* @param classObject
|
|
45
|
+
*/
|
|
46
|
+
_defineProperty(DraggableLayout, "isValidExtendsClass", function (classObject) {
|
|
47
|
+
var shouldBeRealizedFunc = ['calcDragAttach', 'calcDropIndex'];
|
|
48
|
+
return classObject && shouldBeRealizedFunc.every(function (func) {
|
|
49
|
+
return classObject[func];
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
import { Helper } from "../helper";
|
|
9
|
+
import { Mind } from "../index";
|
|
10
|
+
export var Line = /*#__PURE__*/_createClass(function Line() {
|
|
11
|
+
var _this = this;
|
|
12
|
+
_classCallCheck(this, Line);
|
|
13
|
+
_defineProperty(this, "cacheMap", void 0);
|
|
14
|
+
_defineProperty(this, "options", void 0);
|
|
15
|
+
_defineProperty(this, "root", void 0);
|
|
16
|
+
_defineProperty(this, "getRootHeirOrientation", void 0);
|
|
17
|
+
_defineProperty(this, "start", function (context) {
|
|
18
|
+
var cacheMap = context.cacheMap,
|
|
19
|
+
options = context.options,
|
|
20
|
+
root = context.root,
|
|
21
|
+
getRootHeirOrientation = context.getRootHeirOrientation;
|
|
22
|
+
_this.cacheMap = cacheMap;
|
|
23
|
+
_this.options = options;
|
|
24
|
+
_this.root = root;
|
|
25
|
+
_this.getRootHeirOrientation = getRootHeirOrientation;
|
|
26
|
+
});
|
|
27
|
+
_defineProperty(this, "end", function () {
|
|
28
|
+
Helper.breadthFirstWalkTree(_this.cacheMap.get(_this.root.node.id).node, {
|
|
29
|
+
after: function after() {},
|
|
30
|
+
before: function before(node) {
|
|
31
|
+
var cache = _this.cacheMap.get(node.id);
|
|
32
|
+
if (!cache || Helper.judgeIfHeirAndFold(node, cache.parent, _this.root, _this.getRootHeirOrientation)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (cache.parent) {
|
|
36
|
+
var parentCache = _this.cacheMap.get(cache.parent.id);
|
|
37
|
+
if (_this.options.direction === Mind.Direction.x) {
|
|
38
|
+
cache.line.source.y = parentCache.rect.y;
|
|
39
|
+
cache.line.target.y = cache.rect.y;
|
|
40
|
+
// 节点位于父级右侧
|
|
41
|
+
if (cache.orientation === Mind.Orientation.positive) {
|
|
42
|
+
cache.line.source.x = parentCache.rect.x + parentCache.rect.width / 2;
|
|
43
|
+
cache.line.target.x = cache.rect.x - cache.rect.width / 2;
|
|
44
|
+
}
|
|
45
|
+
// 节点位于父级左侧
|
|
46
|
+
else {
|
|
47
|
+
cache.line.source.x = parentCache.rect.x - parentCache.rect.width / 2;
|
|
48
|
+
cache.line.target.x = cache.rect.x + cache.rect.width / 2;
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
cache.line.source.x = parentCache.rect.x;
|
|
52
|
+
cache.line.target.x = cache.rect.x;
|
|
53
|
+
// 节点位于上方
|
|
54
|
+
if (cache.orientation === Mind.Orientation.positive) {
|
|
55
|
+
cache.line.source.y = parentCache.rect.y - parentCache.rect.height / 2;
|
|
56
|
+
cache.line.target.y = cache.rect.y + cache.rect.height / 2;
|
|
57
|
+
}
|
|
58
|
+
// 节点位于下方
|
|
59
|
+
else {
|
|
60
|
+
cache.line.source.y = parentCache.rect.y + parentCache.rect.height / 2;
|
|
61
|
+
cache.line.target.y = cache.rect.y - cache.rect.height / 2;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return !Helper.judgeIfAllChildFold(node, _this.root.node.id);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
import { Helper } from "../helper";
|
|
9
|
+
export var NodeValid = /*#__PURE__*/_createClass(function NodeValid() {
|
|
10
|
+
var _this = this;
|
|
11
|
+
_classCallCheck(this, NodeValid);
|
|
12
|
+
_defineProperty(this, "root", void 0);
|
|
13
|
+
_defineProperty(this, "start", function (context) {
|
|
14
|
+
var root = context.root;
|
|
15
|
+
_this.root = root;
|
|
16
|
+
});
|
|
17
|
+
_defineProperty(this, "every", function (context) {
|
|
18
|
+
var node = context.cache.node;
|
|
19
|
+
if (!node.id) {
|
|
20
|
+
throw Helper.error('node id can not be empty or undefined');
|
|
21
|
+
}
|
|
22
|
+
if (!node.sizeof) {
|
|
23
|
+
throw Helper.error('node sizeof function can not be undefined');
|
|
24
|
+
}
|
|
25
|
+
if (_this.root.node.id === node.id) {
|
|
26
|
+
if (typeof node.fold !== 'undefined' && _typeof(node.fold) !== 'object') {
|
|
27
|
+
throw Helper.error('root node fold should be undefined or array');
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
if (typeof node.fold !== 'undefined' && typeof node.fold !== 'boolean') {
|
|
31
|
+
throw Helper.error('normal node fold should be undefined or boolean');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Process } from './index';
|
|
2
|
+
export declare class Orientation implements Process.Lifecycle {
|
|
3
|
+
private root;
|
|
4
|
+
private getRootHeirOrientation;
|
|
5
|
+
private cacheMap;
|
|
6
|
+
start: (context: Process.StartContext) => void;
|
|
7
|
+
every: (context: Process.EveryContext) => void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
import { Mind } from "../index";
|
|
9
|
+
export var Orientation = /*#__PURE__*/_createClass(function Orientation() {
|
|
10
|
+
var _this = this;
|
|
11
|
+
_classCallCheck(this, Orientation);
|
|
12
|
+
_defineProperty(this, "root", void 0);
|
|
13
|
+
_defineProperty(this, "getRootHeirOrientation", void 0);
|
|
14
|
+
_defineProperty(this, "cacheMap", void 0);
|
|
15
|
+
_defineProperty(this, "start", function (context) {
|
|
16
|
+
var root = context.root,
|
|
17
|
+
getRootHeirOrientation = context.getRootHeirOrientation,
|
|
18
|
+
cacheMap = context.cacheMap;
|
|
19
|
+
_this.root = root;
|
|
20
|
+
_this.getRootHeirOrientation = getRootHeirOrientation;
|
|
21
|
+
_this.cacheMap = cacheMap;
|
|
22
|
+
});
|
|
23
|
+
_defineProperty(this, "every", function (context) {
|
|
24
|
+
var cache = context.cache;
|
|
25
|
+
|
|
26
|
+
// 根节点
|
|
27
|
+
if (!cache.parent) {
|
|
28
|
+
cache.orientation = Mind.Orientation.root;
|
|
29
|
+
}
|
|
30
|
+
// 根节点直系子代
|
|
31
|
+
else if (cache.parent.id === _this.root.node.id) {
|
|
32
|
+
cache.orientation = _this.getRootHeirOrientation(cache.node.id);
|
|
33
|
+
}
|
|
34
|
+
// 非根节点直系子代,继承父级
|
|
35
|
+
// 由于是深度优先遍历,故而父节点 cache 早已设置完全
|
|
36
|
+
else {
|
|
37
|
+
cache.orientation = _this.cacheMap.get(cache.parent.id).orientation;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export var Size = /*#__PURE__*/_createClass(function Size() {
|
|
9
|
+
_classCallCheck(this, Size);
|
|
10
|
+
_defineProperty(this, "every", function (context) {
|
|
11
|
+
var cache = context.cache;
|
|
12
|
+
var size = cache.node.sizeof();
|
|
13
|
+
cache.rect.width = size.width;
|
|
14
|
+
cache.rect.height = size.height;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Mind } from '../index';
|
|
2
|
+
import { Process } from './index';
|
|
3
|
+
export declare class Visible implements Process.Lifecycle<void, void, void, Mind.Visible> {
|
|
4
|
+
private viewport;
|
|
5
|
+
private transform;
|
|
6
|
+
private root;
|
|
7
|
+
private cacheMap;
|
|
8
|
+
private options;
|
|
9
|
+
private getRootHeirOrientation;
|
|
10
|
+
start: (context: Process.StartContext) => void;
|
|
11
|
+
/**
|
|
12
|
+
* 返回可见是否改变
|
|
13
|
+
* - 使用次返回值得前提是,数据没有出现改变(也就是在viewport尺寸改变或者transform时可以使用)
|
|
14
|
+
*/
|
|
15
|
+
end: () => Mind.Visible;
|
|
16
|
+
}
|