@yh-ui/flow 1.0.26 → 1.0.30

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 (142) hide show
  1. package/package.json +4 -4
  2. package/dist/__tests__/ai-workflow.ssr.test.cjs +0 -352
  3. package/dist/__tests__/ai-workflow.ssr.test.d.ts +0 -1
  4. package/dist/__tests__/ai-workflow.ssr.test.mjs +0 -283
  5. package/dist/__tests__/ai-workflow.test.cjs +0 -109
  6. package/dist/__tests__/ai-workflow.test.d.ts +0 -1
  7. package/dist/__tests__/ai-workflow.test.mjs +0 -112
  8. package/dist/__tests__/bpmn-engine.test.cjs +0 -357
  9. package/dist/__tests__/bpmn-engine.test.d.ts +0 -1
  10. package/dist/__tests__/bpmn-engine.test.mjs +0 -406
  11. package/dist/__tests__/bpmn-utils.test.cjs +0 -268
  12. package/dist/__tests__/bpmn-utils.test.d.ts +0 -1
  13. package/dist/__tests__/bpmn-utils.test.mjs +0 -227
  14. package/dist/__tests__/bpmn-xml.test.cjs +0 -150
  15. package/dist/__tests__/bpmn-xml.test.d.ts +0 -1
  16. package/dist/__tests__/bpmn-xml.test.mjs +0 -112
  17. package/dist/__tests__/bpmn.ssr.test.cjs +0 -278
  18. package/dist/__tests__/bpmn.ssr.test.d.ts +0 -1
  19. package/dist/__tests__/bpmn.ssr.test.mjs +0 -237
  20. package/dist/__tests__/bpmn.test.cjs +0 -103
  21. package/dist/__tests__/bpmn.test.d.ts +0 -1
  22. package/dist/__tests__/bpmn.test.mjs +0 -106
  23. package/dist/__tests__/collaboration.test.cjs +0 -487
  24. package/dist/__tests__/collaboration.test.d.ts +0 -1
  25. package/dist/__tests__/collaboration.test.mjs +0 -424
  26. package/dist/__tests__/custom-types.test.cjs +0 -300
  27. package/dist/__tests__/custom-types.test.d.ts +0 -1
  28. package/dist/__tests__/custom-types.test.mjs +0 -248
  29. package/dist/__tests__/edge-types.test.cjs +0 -275
  30. package/dist/__tests__/edge-types.test.d.ts +0 -1
  31. package/dist/__tests__/edge-types.test.mjs +0 -234
  32. package/dist/__tests__/edge-utils.test.cjs +0 -375
  33. package/dist/__tests__/edge-utils.test.d.ts +0 -1
  34. package/dist/__tests__/edge-utils.test.mjs +0 -376
  35. package/dist/__tests__/edge.test.cjs +0 -56
  36. package/dist/__tests__/edge.test.d.ts +0 -1
  37. package/dist/__tests__/edge.test.mjs +0 -69
  38. package/dist/__tests__/event-bus.test.cjs +0 -80
  39. package/dist/__tests__/event-bus.test.d.ts +0 -1
  40. package/dist/__tests__/event-bus.test.mjs +0 -51
  41. package/dist/__tests__/events-types.test.cjs +0 -184
  42. package/dist/__tests__/events-types.test.d.ts +0 -1
  43. package/dist/__tests__/events-types.test.mjs +0 -184
  44. package/dist/__tests__/export-image-plugin.test.cjs +0 -142
  45. package/dist/__tests__/export-image-plugin.test.d.ts +0 -1
  46. package/dist/__tests__/export-image-plugin.test.mjs +0 -118
  47. package/dist/__tests__/export.test.cjs +0 -237
  48. package/dist/__tests__/export.test.d.ts +0 -1
  49. package/dist/__tests__/export.test.mjs +0 -171
  50. package/dist/__tests__/flow-context.test.cjs +0 -16
  51. package/dist/__tests__/flow-context.test.d.ts +0 -1
  52. package/dist/__tests__/flow-context.test.mjs +0 -16
  53. package/dist/__tests__/flow-props.test.cjs +0 -94
  54. package/dist/__tests__/flow-props.test.d.ts +0 -1
  55. package/dist/__tests__/flow-props.test.mjs +0 -92
  56. package/dist/__tests__/flow.ssr.test.cjs +0 -156
  57. package/dist/__tests__/flow.ssr.test.d.ts +0 -1
  58. package/dist/__tests__/flow.ssr.test.mjs +0 -112
  59. package/dist/__tests__/geometry.test.cjs +0 -191
  60. package/dist/__tests__/geometry.test.d.ts +0 -1
  61. package/dist/__tests__/geometry.test.mjs +0 -105
  62. package/dist/__tests__/graph.test.cjs +0 -115
  63. package/dist/__tests__/graph.test.d.ts +0 -1
  64. package/dist/__tests__/graph.test.mjs +0 -85
  65. package/dist/__tests__/history-plugin.test.cjs +0 -191
  66. package/dist/__tests__/history-plugin.test.d.ts +0 -1
  67. package/dist/__tests__/history-plugin.test.mjs +0 -161
  68. package/dist/__tests__/history.test.cjs +0 -81
  69. package/dist/__tests__/history.test.d.ts +0 -1
  70. package/dist/__tests__/history.test.mjs +0 -43
  71. package/dist/__tests__/layout-plugin.test.cjs +0 -233
  72. package/dist/__tests__/layout-plugin.test.d.ts +0 -1
  73. package/dist/__tests__/layout-plugin.test.mjs +0 -215
  74. package/dist/__tests__/layout.test.cjs +0 -213
  75. package/dist/__tests__/layout.test.d.ts +0 -1
  76. package/dist/__tests__/layout.test.mjs +0 -170
  77. package/dist/__tests__/node-edit-panel.ssr.test.cjs +0 -168
  78. package/dist/__tests__/node-edit-panel.ssr.test.d.ts +0 -1
  79. package/dist/__tests__/node-edit-panel.ssr.test.mjs +0 -118
  80. package/dist/__tests__/node-group-plugin.test.cjs +0 -235
  81. package/dist/__tests__/node-group-plugin.test.d.ts +0 -1
  82. package/dist/__tests__/node-group-plugin.test.mjs +0 -187
  83. package/dist/__tests__/node-handles.test.cjs +0 -340
  84. package/dist/__tests__/node-handles.test.d.ts +0 -1
  85. package/dist/__tests__/node-handles.test.mjs +0 -230
  86. package/dist/__tests__/node-types.test.cjs +0 -368
  87. package/dist/__tests__/node-types.test.d.ts +0 -1
  88. package/dist/__tests__/node-types.test.mjs +0 -292
  89. package/dist/__tests__/performance.test.cjs +0 -313
  90. package/dist/__tests__/performance.test.d.ts +0 -1
  91. package/dist/__tests__/performance.test.mjs +0 -218
  92. package/dist/__tests__/plugin-advanced.test.cjs +0 -301
  93. package/dist/__tests__/plugin-advanced.test.d.ts +0 -1
  94. package/dist/__tests__/plugin-advanced.test.mjs +0 -225
  95. package/dist/__tests__/plugin.test.cjs +0 -151
  96. package/dist/__tests__/plugin.test.d.ts +0 -1
  97. package/dist/__tests__/plugin.test.mjs +0 -116
  98. package/dist/__tests__/plugins.test.cjs +0 -412
  99. package/dist/__tests__/plugins.test.d.ts +0 -1
  100. package/dist/__tests__/plugins.test.mjs +0 -402
  101. package/dist/__tests__/screenshot-capture.test.cjs +0 -183
  102. package/dist/__tests__/screenshot-capture.test.d.ts +0 -1
  103. package/dist/__tests__/screenshot-capture.test.mjs +0 -124
  104. package/dist/__tests__/screenshot.test.cjs +0 -74
  105. package/dist/__tests__/screenshot.test.d.ts +0 -1
  106. package/dist/__tests__/screenshot.test.mjs +0 -69
  107. package/dist/__tests__/theme.test.cjs +0 -185
  108. package/dist/__tests__/theme.test.d.ts +0 -1
  109. package/dist/__tests__/theme.test.mjs +0 -191
  110. package/dist/__tests__/transform.test.cjs +0 -384
  111. package/dist/__tests__/transform.test.d.ts +0 -1
  112. package/dist/__tests__/transform.test.mjs +0 -239
  113. package/dist/__tests__/useAlignment.test.cjs +0 -128
  114. package/dist/__tests__/useAlignment.test.d.ts +0 -1
  115. package/dist/__tests__/useAlignment.test.mjs +0 -72
  116. package/dist/__tests__/useEdges.test.cjs +0 -117
  117. package/dist/__tests__/useEdges.test.d.ts +0 -1
  118. package/dist/__tests__/useEdges.test.mjs +0 -80
  119. package/dist/__tests__/useKeyboard.test.cjs +0 -88
  120. package/dist/__tests__/useKeyboard.test.d.ts +0 -1
  121. package/dist/__tests__/useKeyboard.test.mjs +0 -56
  122. package/dist/__tests__/useNodeDistribution.test.cjs +0 -643
  123. package/dist/__tests__/useNodeDistribution.test.d.ts +0 -1
  124. package/dist/__tests__/useNodeDistribution.test.mjs +0 -297
  125. package/dist/__tests__/useNodes.test.cjs +0 -150
  126. package/dist/__tests__/useNodes.test.d.ts +0 -1
  127. package/dist/__tests__/useNodes.test.mjs +0 -80
  128. package/dist/__tests__/useSelection.test.cjs +0 -112
  129. package/dist/__tests__/useSelection.test.d.ts +0 -1
  130. package/dist/__tests__/useSelection.test.mjs +0 -76
  131. package/dist/__tests__/useViewport.test.cjs +0 -171
  132. package/dist/__tests__/useViewport.test.d.ts +0 -1
  133. package/dist/__tests__/useViewport.test.mjs +0 -82
  134. package/dist/__tests__/utils/ssr.cjs +0 -124
  135. package/dist/__tests__/utils/ssr.d.ts +0 -33
  136. package/dist/__tests__/utils/ssr.mjs +0 -129
  137. package/dist/__tests__/validation.test.cjs +0 -95
  138. package/dist/__tests__/validation.test.d.ts +0 -1
  139. package/dist/__tests__/validation.test.mjs +0 -36
  140. package/dist/__tests__/viewport-types.test.cjs +0 -324
  141. package/dist/__tests__/viewport-types.test.d.ts +0 -1
  142. package/dist/__tests__/viewport-types.test.mjs +0 -207
@@ -1,643 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _vue = require("vue");
5
- var _useNodeDistribution = require("../core/useNodeDistribution.cjs");
6
- function createMockFlowInstance() {
7
- const nodes = (0, _vue.ref)([]);
8
- const edges = (0, _vue.ref)([]);
9
- const viewport = (0, _vue.ref)({
10
- x: 0,
11
- y: 0,
12
- zoom: 1
13
- });
14
- const draggingNodeId = (0, _vue.ref)(null);
15
- return {
16
- nodes,
17
- edges,
18
- viewport,
19
- draggingNodeId,
20
- addNode: _vitest.vi.fn(),
21
- removeNode: _vitest.vi.fn(),
22
- updateNode: _vitest.vi.fn(),
23
- getNode: _vitest.vi.fn(),
24
- addEdge: _vitest.vi.fn(),
25
- removeEdge: _vitest.vi.fn(),
26
- updateEdge: _vitest.vi.fn(),
27
- getEdge: _vitest.vi.fn(),
28
- setViewport: _vitest.vi.fn(),
29
- fitView: _vitest.vi.fn(),
30
- zoomIn: _vitest.vi.fn(),
31
- zoomOut: _vitest.vi.fn(),
32
- centerView: _vitest.vi.fn(),
33
- selectNode: _vitest.vi.fn(),
34
- selectEdge: _vitest.vi.fn(),
35
- clearSelection: _vitest.vi.fn(),
36
- getNodes: _vitest.vi.fn(() => nodes.value),
37
- getEdges: _vitest.vi.fn(() => edges.value),
38
- getViewport: _vitest.vi.fn(() => viewport.value),
39
- screenToCanvas: _vitest.vi.fn(),
40
- canvasToScreen: _vitest.vi.fn(),
41
- on: _vitest.vi.fn(),
42
- off: _vitest.vi.fn(),
43
- emit: _vitest.vi.fn(),
44
- isValidConnection: _vitest.vi.fn(() => true),
45
- $el: void 0,
46
- usePlugin: _vitest.vi.fn(),
47
- removePlugin: _vitest.vi.fn()
48
- };
49
- }
50
- (0, _vitest.describe)("flow/core/useNodeDistribution", () => {
51
- (0, _vitest.it)("should return all distribution functions", () => {
52
- const flow = createMockFlowInstance();
53
- const {
54
- distributeHorizontally,
55
- distributeVertically,
56
- alignNodesHorizontal,
57
- alignNodesVertical
58
- } = (0, _useNodeDistribution.useNodeDistribution)({
59
- nodes: flow.nodes
60
- });
61
- (0, _vitest.expect)(typeof distributeHorizontally).toBe("function");
62
- (0, _vitest.expect)(typeof distributeVertically).toBe("function");
63
- (0, _vitest.expect)(typeof alignNodesHorizontal).toBe("function");
64
- (0, _vitest.expect)(typeof alignNodesVertical).toBe("function");
65
- });
66
- (0, _vitest.describe)("distributeHorizontally", () => {
67
- (0, _vitest.it)("should not distribute when fewer than 3 nodes", () => {
68
- const flow = createMockFlowInstance();
69
- flow.nodes.value = [{
70
- id: "1",
71
- type: "default",
72
- position: {
73
- x: 0,
74
- y: 0
75
- },
76
- data: {}
77
- }, {
78
- id: "2",
79
- type: "default",
80
- position: {
81
- x: 100,
82
- y: 0
83
- },
84
- data: {}
85
- }];
86
- const {
87
- distributeHorizontally
88
- } = (0, _useNodeDistribution.useNodeDistribution)({
89
- nodes: flow.nodes
90
- });
91
- distributeHorizontally(["1", "2"]);
92
- (0, _vitest.expect)(flow.nodes.value[0].position.x).toBe(0);
93
- (0, _vitest.expect)(flow.nodes.value[1].position.x).toBe(100);
94
- });
95
- (0, _vitest.it)("should distribute 3 nodes horizontally with custom gap", () => {
96
- const flow = createMockFlowInstance();
97
- flow.nodes.value = [{
98
- id: "1",
99
- type: "default",
100
- position: {
101
- x: 0,
102
- y: 0
103
- },
104
- data: {},
105
- width: 50,
106
- height: 50
107
- }, {
108
- id: "2",
109
- type: "default",
110
- position: {
111
- x: 50,
112
- y: 0
113
- },
114
- data: {},
115
- width: 50,
116
- height: 50
117
- }, {
118
- id: "3",
119
- type: "default",
120
- position: {
121
- x: 100,
122
- y: 0
123
- },
124
- data: {},
125
- width: 50,
126
- height: 50
127
- }];
128
- const {
129
- distributeHorizontally
130
- } = (0, _useNodeDistribution.useNodeDistribution)({
131
- nodes: flow.nodes
132
- });
133
- distributeHorizontally(["1", "2", "3"], 100);
134
- const positions = flow.nodes.value.map(n => n.position.x);
135
- (0, _vitest.expect)(positions[0]).toBe(0);
136
- (0, _vitest.expect)(positions[1]).toBe(150);
137
- (0, _vitest.expect)(positions[2]).toBe(300);
138
- });
139
- (0, _vitest.it)("should distribute nodes that are too close", () => {
140
- const flow = createMockFlowInstance();
141
- flow.nodes.value = [{
142
- id: "1",
143
- type: "default",
144
- position: {
145
- x: 0,
146
- y: 0
147
- },
148
- data: {},
149
- width: 50,
150
- height: 50
151
- }, {
152
- id: "2",
153
- type: "default",
154
- position: {
155
- x: 10,
156
- y: 0
157
- },
158
- data: {},
159
- width: 50,
160
- height: 50
161
- }, {
162
- id: "3",
163
- type: "default",
164
- position: {
165
- x: 20,
166
- y: 0
167
- },
168
- data: {},
169
- width: 50,
170
- height: 50
171
- }];
172
- const {
173
- distributeHorizontally
174
- } = (0, _useNodeDistribution.useNodeDistribution)({
175
- nodes: flow.nodes
176
- });
177
- distributeHorizontally(["1", "2", "3"], 50);
178
- const positions = flow.nodes.value.map(n => n.position.x);
179
- (0, _vitest.expect)(positions[0]).toBe(0);
180
- (0, _vitest.expect)(positions[1]).toBeGreaterThan(positions[0]);
181
- (0, _vitest.expect)(positions[2]).toBeGreaterThan(positions[1]);
182
- });
183
- (0, _vitest.it)("should use selected nodes when no nodeIds provided", () => {
184
- const flow = createMockFlowInstance();
185
- flow.nodes.value = [{
186
- id: "1",
187
- type: "default",
188
- position: {
189
- x: 0,
190
- y: 0
191
- },
192
- data: {},
193
- width: 50,
194
- height: 50,
195
- selected: true
196
- }, {
197
- id: "2",
198
- type: "default",
199
- position: {
200
- x: 50,
201
- y: 0
202
- },
203
- data: {},
204
- width: 50,
205
- height: 50,
206
- selected: true
207
- }, {
208
- id: "3",
209
- type: "default",
210
- position: {
211
- x: 100,
212
- y: 0
213
- },
214
- data: {},
215
- width: 50,
216
- height: 50,
217
- selected: true
218
- }];
219
- const {
220
- distributeHorizontally
221
- } = (0, _useNodeDistribution.useNodeDistribution)({
222
- nodes: flow.nodes
223
- });
224
- distributeHorizontally(void 0, 50);
225
- const positions = flow.nodes.value.map(n => n.position.x);
226
- (0, _vitest.expect)(positions[0]).toBe(0);
227
- (0, _vitest.expect)(positions[1]).toBe(100);
228
- (0, _vitest.expect)(positions[2]).toBe(200);
229
- });
230
- });
231
- (0, _vitest.describe)("distributeVertically", () => {
232
- (0, _vitest.it)("should not distribute when fewer than 3 nodes", () => {
233
- const flow = createMockFlowInstance();
234
- flow.nodes.value = [{
235
- id: "1",
236
- type: "default",
237
- position: {
238
- x: 0,
239
- y: 0
240
- },
241
- data: {}
242
- }, {
243
- id: "2",
244
- type: "default",
245
- position: {
246
- x: 0,
247
- y: 100
248
- },
249
- data: {}
250
- }];
251
- const {
252
- distributeVertically
253
- } = (0, _useNodeDistribution.useNodeDistribution)({
254
- nodes: flow.nodes
255
- });
256
- distributeVertically(["1", "2"]);
257
- (0, _vitest.expect)(flow.nodes.value[0].position.y).toBe(0);
258
- (0, _vitest.expect)(flow.nodes.value[1].position.y).toBe(100);
259
- });
260
- (0, _vitest.it)("should distribute 3 nodes vertically", () => {
261
- const flow = createMockFlowInstance();
262
- flow.nodes.value = [{
263
- id: "1",
264
- type: "default",
265
- position: {
266
- x: 0,
267
- y: 0
268
- },
269
- data: {},
270
- width: 50,
271
- height: 50
272
- }, {
273
- id: "2",
274
- type: "default",
275
- position: {
276
- x: 0,
277
- y: 50
278
- },
279
- data: {},
280
- width: 50,
281
- height: 50
282
- }, {
283
- id: "3",
284
- type: "default",
285
- position: {
286
- x: 0,
287
- y: 100
288
- },
289
- data: {},
290
- width: 50,
291
- height: 50
292
- }];
293
- const {
294
- distributeVertically
295
- } = (0, _useNodeDistribution.useNodeDistribution)({
296
- nodes: flow.nodes
297
- });
298
- distributeVertically(["1", "2", "3"], 100);
299
- const positions = flow.nodes.value.map(n => n.position.y);
300
- (0, _vitest.expect)(positions[0]).toBe(0);
301
- (0, _vitest.expect)(positions[1]).toBe(150);
302
- (0, _vitest.expect)(positions[2]).toBe(300);
303
- });
304
- (0, _vitest.it)("should distribute nodes that are too close vertically", () => {
305
- const flow = createMockFlowInstance();
306
- flow.nodes.value = [{
307
- id: "1",
308
- type: "default",
309
- position: {
310
- x: 0,
311
- y: 0
312
- },
313
- data: {},
314
- width: 50,
315
- height: 50
316
- }, {
317
- id: "2",
318
- type: "default",
319
- position: {
320
- x: 0,
321
- y: 10
322
- },
323
- data: {},
324
- width: 50,
325
- height: 50
326
- }, {
327
- id: "3",
328
- type: "default",
329
- position: {
330
- x: 0,
331
- y: 20
332
- },
333
- data: {},
334
- width: 50,
335
- height: 50
336
- }];
337
- const {
338
- distributeVertically
339
- } = (0, _useNodeDistribution.useNodeDistribution)({
340
- nodes: flow.nodes
341
- });
342
- distributeVertically(["1", "2", "3"], 50);
343
- const positions = flow.nodes.value.map(n => n.position.y);
344
- (0, _vitest.expect)(positions[0]).toBe(0);
345
- (0, _vitest.expect)(positions[1]).toBeGreaterThan(positions[0]);
346
- (0, _vitest.expect)(positions[2]).toBeGreaterThan(positions[1]);
347
- });
348
- });
349
- (0, _vitest.describe)("alignNodesHorizontal", () => {
350
- (0, _vitest.it)("should not align when fewer than 2 nodes", () => {
351
- const flow = createMockFlowInstance();
352
- flow.nodes.value = [{
353
- id: "1",
354
- type: "default",
355
- position: {
356
- x: 0,
357
- y: 0
358
- },
359
- data: {},
360
- width: 100,
361
- height: 50
362
- }];
363
- const {
364
- alignNodesHorizontal
365
- } = (0, _useNodeDistribution.useNodeDistribution)({
366
- nodes: flow.nodes
367
- });
368
- alignNodesHorizontal(["1"]);
369
- (0, _vitest.expect)(flow.nodes.value[0].position.x).toBe(0);
370
- });
371
- (0, _vitest.it)("should align to left edge", () => {
372
- const flow = createMockFlowInstance();
373
- flow.nodes.value = [{
374
- id: "1",
375
- type: "default",
376
- position: {
377
- x: 0,
378
- y: 0
379
- },
380
- data: {},
381
- width: 100,
382
- height: 50
383
- }, {
384
- id: "2",
385
- type: "default",
386
- position: {
387
- x: 50,
388
- y: 50
389
- },
390
- data: {},
391
- width: 100,
392
- height: 50
393
- }, {
394
- id: "3",
395
- type: "default",
396
- position: {
397
- x: 100,
398
- y: 100
399
- },
400
- data: {},
401
- width: 100,
402
- height: 50
403
- }];
404
- const {
405
- alignNodesHorizontal
406
- } = (0, _useNodeDistribution.useNodeDistribution)({
407
- nodes: flow.nodes
408
- });
409
- alignNodesHorizontal(["1", "2", "3"], "left");
410
- (0, _vitest.expect)(flow.nodes.value[0].position.x).toBe(0);
411
- (0, _vitest.expect)(flow.nodes.value[1].position.x).toBe(0);
412
- (0, _vitest.expect)(flow.nodes.value[2].position.x).toBe(0);
413
- });
414
- (0, _vitest.it)("should align to right edge", () => {
415
- const flow = createMockFlowInstance();
416
- flow.nodes.value = [{
417
- id: "1",
418
- type: "default",
419
- position: {
420
- x: 0,
421
- y: 0
422
- },
423
- data: {},
424
- width: 100,
425
- height: 50
426
- }, {
427
- id: "2",
428
- type: "default",
429
- position: {
430
- x: 50,
431
- y: 50
432
- },
433
- data: {},
434
- width: 100,
435
- height: 50
436
- }];
437
- const {
438
- alignNodesHorizontal
439
- } = (0, _useNodeDistribution.useNodeDistribution)({
440
- nodes: flow.nodes
441
- });
442
- alignNodesHorizontal(["1", "2"], "right");
443
- (0, _vitest.expect)(flow.nodes.value[0].position.x).toBe(50);
444
- (0, _vitest.expect)(flow.nodes.value[1].position.x).toBe(50);
445
- });
446
- (0, _vitest.it)("should align to center", () => {
447
- const flow = createMockFlowInstance();
448
- flow.nodes.value = [{
449
- id: "1",
450
- type: "default",
451
- position: {
452
- x: 0,
453
- y: 0
454
- },
455
- data: {},
456
- width: 100,
457
- height: 50
458
- }, {
459
- id: "2",
460
- type: "default",
461
- position: {
462
- x: 50,
463
- y: 50
464
- },
465
- data: {},
466
- width: 200,
467
- height: 50
468
- }];
469
- const {
470
- alignNodesHorizontal
471
- } = (0, _useNodeDistribution.useNodeDistribution)({
472
- nodes: flow.nodes
473
- });
474
- alignNodesHorizontal(["1", "2"], "center");
475
- (0, _vitest.expect)(flow.nodes.value[0].position.x).toBe(50);
476
- (0, _vitest.expect)(flow.nodes.value[1].position.x).toBe(0);
477
- });
478
- (0, _vitest.it)("should use selected nodes when no nodeIds provided", () => {
479
- const flow = createMockFlowInstance();
480
- flow.nodes.value = [{
481
- id: "1",
482
- type: "default",
483
- position: {
484
- x: 0,
485
- y: 0
486
- },
487
- data: {},
488
- width: 100,
489
- height: 50,
490
- selected: true
491
- }, {
492
- id: "2",
493
- type: "default",
494
- position: {
495
- x: 50,
496
- y: 0
497
- },
498
- data: {},
499
- width: 100,
500
- height: 50,
501
- selected: true
502
- }];
503
- const {
504
- alignNodesHorizontal
505
- } = (0, _useNodeDistribution.useNodeDistribution)({
506
- nodes: flow.nodes
507
- });
508
- alignNodesHorizontal(void 0, "left");
509
- (0, _vitest.expect)(flow.nodes.value[0].position.x).toBe(0);
510
- (0, _vitest.expect)(flow.nodes.value[1].position.x).toBe(0);
511
- });
512
- });
513
- (0, _vitest.describe)("alignNodesVertical", () => {
514
- (0, _vitest.it)("should not align when fewer than 2 nodes", () => {
515
- const flow = createMockFlowInstance();
516
- flow.nodes.value = [{
517
- id: "1",
518
- type: "default",
519
- position: {
520
- x: 0,
521
- y: 0
522
- },
523
- data: {},
524
- width: 100,
525
- height: 50
526
- }];
527
- const {
528
- alignNodesVertical
529
- } = (0, _useNodeDistribution.useNodeDistribution)({
530
- nodes: flow.nodes
531
- });
532
- alignNodesVertical(["1"]);
533
- (0, _vitest.expect)(flow.nodes.value[0].position.y).toBe(0);
534
- });
535
- (0, _vitest.it)("should align to top edge", () => {
536
- const flow = createMockFlowInstance();
537
- flow.nodes.value = [{
538
- id: "1",
539
- type: "default",
540
- position: {
541
- x: 0,
542
- y: 0
543
- },
544
- data: {},
545
- width: 100,
546
- height: 50
547
- }, {
548
- id: "2",
549
- type: "default",
550
- position: {
551
- x: 0,
552
- y: 50
553
- },
554
- data: {},
555
- width: 100,
556
- height: 50
557
- }, {
558
- id: "3",
559
- type: "default",
560
- position: {
561
- x: 0,
562
- y: 100
563
- },
564
- data: {},
565
- width: 100,
566
- height: 50
567
- }];
568
- const {
569
- alignNodesVertical
570
- } = (0, _useNodeDistribution.useNodeDistribution)({
571
- nodes: flow.nodes
572
- });
573
- alignNodesVertical(["1", "2", "3"], "top");
574
- (0, _vitest.expect)(flow.nodes.value[0].position.y).toBe(0);
575
- (0, _vitest.expect)(flow.nodes.value[1].position.y).toBe(0);
576
- (0, _vitest.expect)(flow.nodes.value[2].position.y).toBe(0);
577
- });
578
- (0, _vitest.it)("should align to bottom edge", () => {
579
- const flow = createMockFlowInstance();
580
- flow.nodes.value = [{
581
- id: "1",
582
- type: "default",
583
- position: {
584
- x: 0,
585
- y: 0
586
- },
587
- data: {},
588
- width: 100,
589
- height: 50
590
- }, {
591
- id: "2",
592
- type: "default",
593
- position: {
594
- x: 0,
595
- y: 50
596
- },
597
- data: {},
598
- width: 100,
599
- height: 50
600
- }];
601
- const {
602
- alignNodesVertical
603
- } = (0, _useNodeDistribution.useNodeDistribution)({
604
- nodes: flow.nodes
605
- });
606
- alignNodesVertical(["1", "2"], "bottom");
607
- (0, _vitest.expect)(flow.nodes.value[0].position.y).toBe(50);
608
- (0, _vitest.expect)(flow.nodes.value[1].position.y).toBe(50);
609
- });
610
- (0, _vitest.it)("should align to middle", () => {
611
- const flow = createMockFlowInstance();
612
- flow.nodes.value = [{
613
- id: "1",
614
- type: "default",
615
- position: {
616
- x: 0,
617
- y: 0
618
- },
619
- data: {},
620
- width: 100,
621
- height: 50
622
- }, {
623
- id: "2",
624
- type: "default",
625
- position: {
626
- x: 0,
627
- y: 50
628
- },
629
- data: {},
630
- width: 100,
631
- height: 100
632
- }];
633
- const {
634
- alignNodesVertical
635
- } = (0, _useNodeDistribution.useNodeDistribution)({
636
- nodes: flow.nodes
637
- });
638
- alignNodesVertical(["1", "2"], "middle");
639
- (0, _vitest.expect)(flow.nodes.value[0].position.y).toBe(37.5);
640
- (0, _vitest.expect)(flow.nodes.value[1].position.y).toBe(12.5);
641
- });
642
- });
643
- });
@@ -1 +0,0 @@
1
- export {};