@logicflow/extension 2.2.3 → 2.2.4-alpha.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 (51) hide show
  1. package/dist/index.min.js +1 -1
  2. package/dist/index.min.js.map +1 -1
  3. package/es/constant/events.d.ts +9 -0
  4. package/es/constant/events.js +11 -0
  5. package/es/dynamic-group/index.d.ts +52 -3
  6. package/es/dynamic-group/index.js +294 -117
  7. package/es/dynamic-group/model.d.ts +56 -3
  8. package/es/dynamic-group/model.js +148 -25
  9. package/es/dynamic-group/node.d.ts +1 -0
  10. package/es/dynamic-group/node.js +52 -19
  11. package/es/dynamic-group/titleText.d.ts +8 -0
  12. package/es/dynamic-group/titleText.js +84 -0
  13. package/es/dynamic-group/utils.d.ts +69 -0
  14. package/es/dynamic-group/utils.js +162 -0
  15. package/es/index.css +321 -1
  16. package/es/index.d.ts +1 -0
  17. package/es/index.js +1 -0
  18. package/es/index.less +1 -0
  19. package/es/materials/group/GroupNode.js +5 -2
  20. package/es/materials/group/index.js +7 -6
  21. package/es/pool/LaneModel.d.ts +1 -1
  22. package/es/pool/PoolModel.d.ts +1 -1
  23. package/es/pool/index.d.ts +3 -2
  24. package/es/pool/index.js +44 -60
  25. package/es/style/index.css +321 -1
  26. package/es/style/index.less +381 -0
  27. package/lib/constant/events.d.ts +9 -0
  28. package/lib/constant/events.js +14 -0
  29. package/lib/dynamic-group/index.d.ts +52 -3
  30. package/lib/dynamic-group/index.js +293 -116
  31. package/lib/dynamic-group/model.d.ts +56 -3
  32. package/lib/dynamic-group/model.js +148 -25
  33. package/lib/dynamic-group/node.d.ts +1 -0
  34. package/lib/dynamic-group/node.js +53 -20
  35. package/lib/dynamic-group/titleText.d.ts +8 -0
  36. package/lib/dynamic-group/titleText.js +90 -0
  37. package/lib/dynamic-group/utils.d.ts +69 -0
  38. package/lib/dynamic-group/utils.js +172 -1
  39. package/lib/index.css +321 -1
  40. package/lib/index.d.ts +1 -0
  41. package/lib/index.js +1 -0
  42. package/lib/index.less +1 -0
  43. package/lib/materials/group/GroupNode.js +5 -2
  44. package/lib/materials/group/index.js +7 -6
  45. package/lib/pool/LaneModel.d.ts +1 -1
  46. package/lib/pool/PoolModel.d.ts +1 -1
  47. package/lib/pool/index.d.ts +3 -2
  48. package/lib/pool/index.js +44 -60
  49. package/lib/style/index.css +321 -1
  50. package/lib/style/index.less +381 -0
  51. package/package.json +8 -8
@@ -17,3 +17,72 @@ export declare function isAllowMoveTo(groupBounds: BoxBoundsPoint, node: BaseNod
17
17
  x: boolean;
18
18
  y: boolean;
19
19
  };
20
+ /**
21
+ * 计算直接子节点的 bounds 并集。
22
+ * 无有效子节点时返回 null。
23
+ */
24
+ export declare function getChildrenBounds(groupModel: {
25
+ children?: Set<string>;
26
+ }, getNodeById: (id: string) => BaseNodeModel | undefined): BoxBoundsPoint | null;
27
+ /**
28
+ * 判断 groupBounds 是否完全包含 childrenBounds。
29
+ */
30
+ export declare function isGroupBoundsContainsChildren(groupBounds: BoxBoundsPoint, childrenBounds: BoxBoundsPoint): boolean;
31
+ /** 折叠按钮距节点顶边/左边的默认 inset,与 node.getOperateIcon 一致 */
32
+ export declare const DG_OPERATE_INSET = 10;
33
+ /** @deprecated 使用 DG_OPERATE_INSET */
34
+ export declare const DG_OPERATE_INSET_TOP = 10;
35
+ export declare const DG_OPERATE_BTN_WIDTH = 14;
36
+ export declare const DG_OPERATE_BTN_HEIGHT = 12;
37
+ /** 左对齐时推荐用于避开 operator 的 wrapPadding.left(inset + btn + inset) */
38
+ export declare const DG_TITLE_LEFT_CLEARANCE: number;
39
+ export declare const DEFAULT_TITLE_WRAP_PADDING = "0,0,0,0";
40
+ export declare const DEFAULT_TITLE_TEXT_ALIGN = "center";
41
+ export type TitleBand = {
42
+ bandLeft: number;
43
+ bandTop: number;
44
+ bandWidth: number;
45
+ bandHeight: number;
46
+ };
47
+ export type TitleForeignObjectRect = {
48
+ foX: number;
49
+ foY: number;
50
+ foWidth: number;
51
+ foHeight: number;
52
+ };
53
+ export declare function getTitleBand(options: {
54
+ x: number;
55
+ y: number;
56
+ width: number;
57
+ height: number;
58
+ }): TitleBand;
59
+ export declare function resolveTitleTextPosition(options: {
60
+ x: number;
61
+ y: number;
62
+ width: number;
63
+ height: number;
64
+ textAlign: string;
65
+ pad: ReturnType<typeof parseWrapPadding>;
66
+ }): {
67
+ x: number;
68
+ y: number;
69
+ };
70
+ export declare function getTitleForeignObjectRect(options: {
71
+ x: number;
72
+ y: number;
73
+ width: number;
74
+ height: number;
75
+ overflowMode: 'autoWrap' | 'ellipsis';
76
+ fontSize: number;
77
+ pad: ReturnType<typeof parseWrapPadding>;
78
+ }): TitleForeignObjectRect;
79
+ export declare function parseWrapPadding(padding?: string | number | null): {
80
+ top: number;
81
+ right: number;
82
+ bottom: number;
83
+ left: number;
84
+ };
85
+ export declare function textAlignToAnchor(textAlign?: string): 'start' | 'middle' | 'end';
86
+ export declare function isHtmlTextOverflow(overflowMode?: string): boolean;
87
+ /** LogicFlow 存储格式 `15,8,4,8` → CSS padding `15px 8px 4px 8px` */
88
+ export declare function formatWrapPaddingCss(padding?: string | number | null): string;
@@ -1,3 +1,14 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
1
12
  /**
2
13
  *
3
14
  * @param bounds
@@ -31,3 +42,154 @@ export function isAllowMoveTo(groupBounds, node, deltaX, deltaY) {
31
42
  y: y + deltaY >= allowMoveMinY && y + deltaY <= allowMoveMaxY,
32
43
  };
33
44
  }
45
+ /**
46
+ * 计算直接子节点的 bounds 并集。
47
+ * 无有效子节点时返回 null。
48
+ */
49
+ export function getChildrenBounds(groupModel, getNodeById) {
50
+ var e_1, _a;
51
+ if (!groupModel.children || groupModel.children.size === 0) {
52
+ return null;
53
+ }
54
+ var minX = Infinity;
55
+ var minY = Infinity;
56
+ var maxX = -Infinity;
57
+ var maxY = -Infinity;
58
+ var hasChild = false;
59
+ try {
60
+ for (var _b = __values(Array.from(groupModel.children)), _c = _b.next(); !_c.done; _c = _b.next()) {
61
+ var childId = _c.value;
62
+ var child = getNodeById(childId);
63
+ if (!child) {
64
+ continue;
65
+ }
66
+ hasChild = true;
67
+ var childBounds = child.getBounds();
68
+ minX = Math.min(minX, childBounds.minX);
69
+ minY = Math.min(minY, childBounds.minY);
70
+ maxX = Math.max(maxX, childBounds.maxX);
71
+ maxY = Math.max(maxY, childBounds.maxY);
72
+ }
73
+ }
74
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
75
+ finally {
76
+ try {
77
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
78
+ }
79
+ finally { if (e_1) throw e_1.error; }
80
+ }
81
+ if (!hasChild) {
82
+ return null;
83
+ }
84
+ return { minX: minX, minY: minY, maxX: maxX, maxY: maxY };
85
+ }
86
+ /**
87
+ * 判断 groupBounds 是否完全包含 childrenBounds。
88
+ */
89
+ export function isGroupBoundsContainsChildren(groupBounds, childrenBounds) {
90
+ return (groupBounds.minX <= childrenBounds.minX &&
91
+ groupBounds.minY <= childrenBounds.minY &&
92
+ groupBounds.maxX >= childrenBounds.maxX &&
93
+ groupBounds.maxY >= childrenBounds.maxY);
94
+ }
95
+ /** 折叠按钮距节点顶边/左边的默认 inset,与 node.getOperateIcon 一致 */
96
+ export var DG_OPERATE_INSET = 10;
97
+ /** @deprecated 使用 DG_OPERATE_INSET */
98
+ export var DG_OPERATE_INSET_TOP = DG_OPERATE_INSET;
99
+ export var DG_OPERATE_BTN_WIDTH = 14;
100
+ export var DG_OPERATE_BTN_HEIGHT = 12;
101
+ /** 左对齐时推荐用于避开 operator 的 wrapPadding.left(inset + btn + inset) */
102
+ export var DG_TITLE_LEFT_CLEARANCE = DG_OPERATE_INSET + DG_OPERATE_BTN_WIDTH + DG_OPERATE_INSET;
103
+ export var DEFAULT_TITLE_WRAP_PADDING = '0,0,0,0';
104
+ export var DEFAULT_TITLE_TEXT_ALIGN = 'center';
105
+ export function getTitleBand(options) {
106
+ var x = options.x, y = options.y, width = options.width, height = options.height;
107
+ var left = x - width / 2;
108
+ var top = y - height / 2;
109
+ return {
110
+ bandLeft: left,
111
+ bandTop: top + DG_OPERATE_INSET,
112
+ bandWidth: width,
113
+ bandHeight: height - DG_OPERATE_INSET,
114
+ };
115
+ }
116
+ export function resolveTitleTextPosition(options) {
117
+ var x = options.x, width = options.width, height = options.height, textAlign = options.textAlign, pad = options.pad;
118
+ var _a = getTitleBand({
119
+ x: x,
120
+ y: options.y,
121
+ width: width,
122
+ height: height,
123
+ }), bandLeft = _a.bandLeft, bandTop = _a.bandTop, bandWidth = _a.bandWidth;
124
+ var contentLeft = bandLeft + pad.left;
125
+ var contentRight = bandLeft + bandWidth - pad.right;
126
+ var contentTop = bandTop + pad.top;
127
+ var contentCenterX = contentLeft + Math.max(0, contentRight - contentLeft) / 2;
128
+ if (textAlign === 'left') {
129
+ return { x: contentLeft, y: contentTop };
130
+ }
131
+ if (textAlign === 'right') {
132
+ return { x: contentRight, y: contentTop };
133
+ }
134
+ return { x: contentCenterX, y: contentTop };
135
+ }
136
+ export function getTitleForeignObjectRect(options) {
137
+ var _a = getTitleBand(options), bandLeft = _a.bandLeft, bandTop = _a.bandTop, bandWidth = _a.bandWidth, bandHeight = _a.bandHeight;
138
+ var overflowMode = options.overflowMode, fontSize = options.fontSize, pad = options.pad;
139
+ var foX = bandLeft;
140
+ var foY = bandTop;
141
+ var foWidth = bandWidth;
142
+ var foHeight = overflowMode === 'ellipsis'
143
+ ? pad.top + fontSize + 2 + pad.bottom
144
+ : bandHeight;
145
+ return { foX: foX, foY: foY, foWidth: foWidth, foHeight: foHeight };
146
+ }
147
+ export function parseWrapPadding(padding) {
148
+ if (padding === undefined || padding === null || padding === '') {
149
+ return { top: 0, right: 0, bottom: 0, left: 0 };
150
+ }
151
+ if (typeof padding === 'number') {
152
+ var n = Math.max(0, padding);
153
+ return { top: n, right: n, bottom: n, left: n };
154
+ }
155
+ var parts = String(padding)
156
+ .split(/[\s,]+/)
157
+ .filter(Boolean)
158
+ .map(function (s) { return parseFloat(s.replace(/px$/i, '')) || 0; });
159
+ if (parts.length === 1) {
160
+ var n = parts[0];
161
+ return { top: n, right: n, bottom: n, left: n };
162
+ }
163
+ if (parts.length === 2) {
164
+ return { top: parts[0], right: parts[1], bottom: parts[0], left: parts[1] };
165
+ }
166
+ if (parts.length === 3) {
167
+ return {
168
+ top: parts[0],
169
+ right: parts[1],
170
+ bottom: parts[2],
171
+ left: parts[1],
172
+ };
173
+ }
174
+ return {
175
+ top: parts[0],
176
+ right: parts[1],
177
+ bottom: parts[2],
178
+ left: parts[3],
179
+ };
180
+ }
181
+ export function textAlignToAnchor(textAlign) {
182
+ if (textAlign === 'left')
183
+ return 'start';
184
+ if (textAlign === 'right')
185
+ return 'end';
186
+ return 'middle';
187
+ }
188
+ export function isHtmlTextOverflow(overflowMode) {
189
+ return overflowMode === 'autoWrap' || overflowMode === 'ellipsis';
190
+ }
191
+ /** LogicFlow 存储格式 `15,8,4,8` → CSS padding `15px 8px 4px 8px` */
192
+ export function formatWrapPaddingCss(padding) {
193
+ var p = parseWrapPadding(padding);
194
+ return "".concat(p.top, "px ").concat(p.right, "px ").concat(p.bottom, "px ").concat(p.left, "px");
195
+ }