@flowgram.ai/fixed-semi-materials 0.1.0-alpha.10

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.
@@ -0,0 +1,793 @@
1
+ // src/components/index.tsx
2
+ import { FlowRendererKey } from "@flowgram.ai/fixed-layout-editor";
3
+
4
+ // src/assets/ellipsis.tsx
5
+ import React from "react";
6
+ function Ellipse() {
7
+ return /* @__PURE__ */ React.createElement("svg", { width: "8", height: "8", viewBox: "0 0 8 8", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React.createElement("circle", { id: "Ellipse 465", cx: "4", cy: "4", r: "3", fill: "white", stroke: "#3370FF", strokeWidth: "2" }));
8
+ }
9
+
10
+ // src/assets/icons.tsx
11
+ import React2 from "react";
12
+ function IconStyleBorder(props) {
13
+ return /* @__PURE__ */ React2.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
14
+ "g",
15
+ {
16
+ fill: "none",
17
+ stroke: "currentColor",
18
+ strokeLinecap: "round",
19
+ strokeLinejoin: "round",
20
+ strokeMiterlimit: "1.5",
21
+ strokeWidth: "1.499"
22
+ },
23
+ /* @__PURE__ */ React2.createElement(
24
+ "path",
25
+ {
26
+ strokeDasharray: "2 2",
27
+ d: "M16 2H8a6 6 0 0 0-6 6v8a6 6 0 0 0 6 6h8a6 6 0 0 0 6-6V8a6 6 0 0 0-6-6Z"
28
+ }
29
+ ),
30
+ /* @__PURE__ */ React2.createElement("path", { d: "M16 5H8a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3Z" })
31
+ ));
32
+ }
33
+ function IconParkRightBranch(props) {
34
+ return /* @__PURE__ */ React2.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 48 48", ...props }, /* @__PURE__ */ React2.createElement("g", { fill: "none" }, /* @__PURE__ */ React2.createElement(
35
+ "path",
36
+ {
37
+ stroke: "currentColor",
38
+ strokeLinecap: "round",
39
+ strokeLinejoin: "round",
40
+ strokeWidth: "4",
41
+ d: "M22 8.01176C20.5 8.01193 16.0714 7.93811 15 13.0005C13.917 18.1177 9.85714 22.8477 8 24"
42
+ }
43
+ ), /* @__PURE__ */ React2.createElement(
44
+ "path",
45
+ {
46
+ stroke: "currentColor",
47
+ strokeLinecap: "round",
48
+ strokeLinejoin: "round",
49
+ strokeWidth: "4",
50
+ d: "M22 40C20.5 40.0003 16.0714 40.0628 15 35.0005C13.917 29.8833 9.85714 25.1522 8 23.9999"
51
+ }
52
+ ), /* @__PURE__ */ React2.createElement("circle", { cx: "8", cy: "24", r: "4", fill: "currentColor" }), /* @__PURE__ */ React2.createElement(
53
+ "path",
54
+ {
55
+ stroke: "currentColor",
56
+ strokeLinecap: "round",
57
+ strokeLinejoin: "round",
58
+ strokeWidth: "4",
59
+ d: "M8 24L22 24"
60
+ }
61
+ ), /* @__PURE__ */ React2.createElement(
62
+ "path",
63
+ {
64
+ stroke: "currentColor",
65
+ strokeLinecap: "round",
66
+ strokeLinejoin: "round",
67
+ strokeWidth: "4",
68
+ d: "M30 24.001H42"
69
+ }
70
+ ), /* @__PURE__ */ React2.createElement(
71
+ "path",
72
+ {
73
+ stroke: "currentColor",
74
+ strokeLinecap: "round",
75
+ strokeLinejoin: "round",
76
+ strokeWidth: "4",
77
+ d: "M30 8.00098H42"
78
+ }
79
+ ), /* @__PURE__ */ React2.createElement(
80
+ "path",
81
+ {
82
+ stroke: "currentColor",
83
+ strokeLinecap: "round",
84
+ strokeLinejoin: "round",
85
+ strokeWidth: "4",
86
+ d: "M30 40.001H42"
87
+ }
88
+ )));
89
+ }
90
+ function PhCircleBold(props) {
91
+ return /* @__PURE__ */ React2.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 256 256", ...props }, /* @__PURE__ */ React2.createElement(
92
+ "path",
93
+ {
94
+ fill: "currentColor",
95
+ d: "M128 236a108 108 0 1 1 108-108a108.1 108.1 0 0 1-108 108Zm0-192a84 84 0 1 0 84 84a84.1 84.1 0 0 0-84-84Z"
96
+ }
97
+ ));
98
+ }
99
+ function BiCloud(props) {
100
+ return /* @__PURE__ */ React2.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 16 16", ...props }, /* @__PURE__ */ React2.createElement(
101
+ "path",
102
+ {
103
+ fill: "currentColor",
104
+ d: "M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773C16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593c.143-.863.698-1.723 1.464-2.383zm.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318C1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"
105
+ }
106
+ ));
107
+ }
108
+ function BiBootstrapReboot(props) {
109
+ return /* @__PURE__ */ React2.createElement(
110
+ "svg",
111
+ {
112
+ xmlns: "http://www.w3.org/2000/svg",
113
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
114
+ width: "1em",
115
+ height: "1em",
116
+ viewBox: "0 0 16 16",
117
+ ...props
118
+ },
119
+ /* @__PURE__ */ React2.createElement("g", { fill: "currentColor" }, /* @__PURE__ */ React2.createElement("path", { d: "M1.161 8a6.84 6.84 0 1 0 6.842-6.84a.58.58 0 1 1 0-1.16a8 8 0 1 1-6.556 3.412l-.663-.577a.58.58 0 0 1 .227-.997l2.52-.69a.58.58 0 0 1 .728.633l-.332 2.592a.58.58 0 0 1-.956.364l-.643-.56A6.812 6.812 0 0 0 1.16 8z" }), /* @__PURE__ */ React2.createElement("path", { d: "M6.641 11.671V8.843h1.57l1.498 2.828h1.314L9.377 8.665c.897-.3 1.427-1.106 1.427-2.1c0-1.37-.943-2.246-2.456-2.246H5.5v7.352h1.141zm0-3.75V5.277h1.57c.881 0 1.416.499 1.416 1.32c0 .84-.504 1.324-1.386 1.324h-1.6z" }))
120
+ );
121
+ }
122
+ function FeAlignCenter(props) {
123
+ return /* @__PURE__ */ React2.createElement(
124
+ "svg",
125
+ {
126
+ xmlns: "http://www.w3.org/2000/svg",
127
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
128
+ width: "1em",
129
+ height: "1em",
130
+ viewBox: "0 0 24 24",
131
+ ...props
132
+ },
133
+ /* @__PURE__ */ React2.createElement(
134
+ "path",
135
+ {
136
+ fill: "#888888",
137
+ fillRule: "evenodd",
138
+ d: "M11 13v-2H6.286C5.023 11 4 10.105 4 9s1.023-2 2.286-2H11V3a1 1 0 0 1 2 0v4h4.714C18.977 7 20 7.895 20 9s-1.023 2-2.286 2H13v2h3a2 2 0 1 1 0 4h-3v4a1 1 0 0 1-2 0v-4H8a2 2 0 1 1 0-4h3Z"
139
+ }
140
+ )
141
+ );
142
+ }
143
+ function Arrow({ color, circleColor }) {
144
+ return /* @__PURE__ */ React2.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React2.createElement("circle", { cx: "8", cy: "8", r: "7", fill: circleColor }), /* @__PURE__ */ React2.createElement(
145
+ "path",
146
+ {
147
+ fill: color,
148
+ d: "M10.8281 9.4715C11.0883 9.21131 11.0885 8.78909 10.8291 8.52804C10.6413 8.33892 10.4536 8.14952 10.266 7.9601C9.66706 7.35551 9.06799 6.75079 8.46068 6.15496C8.20439 5.90352 7.7947 5.90352 7.53841 6.15496C6.93103 6.75085 6.33191 7.35564 5.73291 7.96029C5.5454 8.14957 5.3579 8.33884 5.17017 8.52782C4.91075 8.78895 4.91096 9.21099 5.17124 9.47127C5.43152 9.73155 5.85355 9.73176 6.11383 9.47148L7.99955 7.58576L9.88548 9.4717C10.1457 9.73189 10.5679 9.73169 10.8281 9.4715Z"
149
+ }
150
+ ), /* @__PURE__ */ React2.createElement(
151
+ "path",
152
+ {
153
+ fill: color,
154
+ d: "M0.888672 7.99997C0.888672 4.07261 4.07242 0.888855 7.99978 0.888855C11.9271 0.888855 15.1109 4.07261 15.1109 7.99997C15.1109 11.9273 11.9271 15.1111 7.99978 15.1111C4.07242 15.1111 0.888672 11.9273 0.888672 7.99997ZM13.818 7.99997C13.818 4.78667 11.2131 2.18178 7.99978 2.18178C4.78649 2.18178 2.1816 4.78667 2.1816 7.99997C2.1816 11.2133 4.78649 13.8181 7.99978 13.8181C11.2131 13.8181 13.818 11.2133 13.818 7.99997Z"
155
+ }
156
+ ));
157
+ }
158
+
159
+ // src/components/try-catch-collapse.tsx
160
+ import React3, { useState } from "react";
161
+ import {
162
+ FlowNodeRenderData,
163
+ FlowNodeTransformData,
164
+ Playground,
165
+ useBaseColor,
166
+ FlowTextKey,
167
+ FlowRendererRegistry
168
+ } from "@flowgram.ai/fixed-layout-editor";
169
+ import { IconChevronLeft } from "@douyinfe/semi-icons";
170
+ function TryCatchCollapse(props) {
171
+ const { node } = props;
172
+ const { baseColor, baseActivatedColor } = useBaseColor();
173
+ const activateData = node.getData(FlowNodeRenderData);
174
+ const transform = node.getData(FlowNodeTransformData);
175
+ const [hoverActivated, setHoverActivated] = useState(false);
176
+ if (!transform || !transform.parent) {
177
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null);
178
+ }
179
+ const width = transform.inputPoint.x - transform.parent.inputPoint.x;
180
+ const height = 40;
181
+ const scrollToActivateNode = () => {
182
+ setTimeout(() => {
183
+ Playground.getLatest()?.scrollToView({
184
+ position: node?.getData(FlowNodeTransformData)?.inputPoint,
185
+ scrollToCenter: true
186
+ });
187
+ }, 100);
188
+ };
189
+ const collapseBlock = () => {
190
+ transform.collapsed = true;
191
+ activateData.activated = false;
192
+ scrollToActivateNode();
193
+ };
194
+ const openBlock = () => {
195
+ transform.collapsed = false;
196
+ scrollToActivateNode();
197
+ };
198
+ const handleMouseEnter = () => {
199
+ setHoverActivated(true);
200
+ activateData.activated = true;
201
+ };
202
+ const handleMouseLeave = () => {
203
+ setHoverActivated(false);
204
+ activateData.activated = false;
205
+ };
206
+ const renderCollapse = () => {
207
+ if (transform.collapsed) {
208
+ const childCount = node.allCollapsedChildren.filter(
209
+ (child) => !child.hidden && child !== node
210
+ ).length;
211
+ return /* @__PURE__ */ React3.createElement(
212
+ "div",
213
+ {
214
+ onClick: openBlock,
215
+ style: {
216
+ width: 16,
217
+ height: 16,
218
+ fontSize: 10,
219
+ borderRadius: 9,
220
+ display: "flex",
221
+ color: "#fff",
222
+ cursor: "pointer",
223
+ justifyContent: "center",
224
+ alignItems: "center",
225
+ background: hoverActivated ? baseActivatedColor : baseColor
226
+ },
227
+ "aria-hidden": "true"
228
+ },
229
+ childCount
230
+ );
231
+ }
232
+ if (hoverActivated) {
233
+ return /* @__PURE__ */ React3.createElement(
234
+ "div",
235
+ {
236
+ onClick: collapseBlock,
237
+ style: {
238
+ width: 16,
239
+ height: 16,
240
+ fontSize: 10,
241
+ borderRadius: 9,
242
+ display: "flex",
243
+ color: "#fff",
244
+ cursor: "pointer",
245
+ justifyContent: "center",
246
+ alignItems: "center",
247
+ background: baseActivatedColor
248
+ },
249
+ "aria-hidden": "true"
250
+ },
251
+ /* @__PURE__ */ React3.createElement(IconChevronLeft, null)
252
+ );
253
+ }
254
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null);
255
+ };
256
+ return /* @__PURE__ */ React3.createElement(
257
+ "div",
258
+ {
259
+ onMouseEnter: handleMouseEnter,
260
+ onMouseLeave: handleMouseLeave,
261
+ style: {
262
+ width,
263
+ height,
264
+ display: "flex",
265
+ alignItems: "center",
266
+ justifyContent: "center",
267
+ gap: 6
268
+ }
269
+ },
270
+ /* @__PURE__ */ React3.createElement(
271
+ "div",
272
+ {
273
+ "data-label-id": props.labelId,
274
+ style: {
275
+ fontSize: 12,
276
+ color: hoverActivated ? baseActivatedColor : baseColor,
277
+ textAlign: "center",
278
+ whiteSpace: "nowrap",
279
+ backgroundColor: "var(--g-editor-background)",
280
+ lineHeight: "20px"
281
+ }
282
+ },
283
+ node.getService(FlowRendererRegistry).getText(FlowTextKey.CATCH_TEXT)
284
+ ),
285
+ renderCollapse()
286
+ );
287
+ }
288
+ var try_catch_collapse_default = TryCatchCollapse;
289
+
290
+ // src/components/dragging-adder/index.tsx
291
+ import React4 from "react";
292
+ import { FlowDragLayer, usePlayground } from "@flowgram.ai/fixed-layout-editor";
293
+
294
+ // src/components/dragging-adder/styles.tsx
295
+ import styled from "styled-components";
296
+ var UIDragNodeContainer = styled.div`
297
+ width: 16px;
298
+ height: 16px;
299
+ border-radius: 100px;
300
+ background-color: white;
301
+ border: 1px dashed #b8bcc1;
302
+ `;
303
+
304
+ // src/components/dragging-adder/index.tsx
305
+ function DraggingAdder(props) {
306
+ const playground = usePlayground();
307
+ const layer = playground.getLayer(FlowDragLayer);
308
+ if (!layer) return /* @__PURE__ */ React4.createElement(React4.Fragment, null);
309
+ if (layer.options.canDrop && !layer.options.canDrop({
310
+ dragNodes: layer.dragEntities || [],
311
+ dropNode: props.from,
312
+ isBranch: false
313
+ })) {
314
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null);
315
+ }
316
+ return /* @__PURE__ */ React4.createElement(UIDragNodeContainer, null);
317
+ }
318
+
319
+ // src/components/drag-node/index.tsx
320
+ import React5 from "react";
321
+
322
+ // src/components/drag-node/styles.tsx
323
+ import styled2 from "styled-components";
324
+
325
+ // src/components/constants.tsx
326
+ var primary = "hsl(252 62% 54.9%)";
327
+ var primaryOpacity09 = "hsl(252deg 62% 55% / 9%)";
328
+
329
+ // src/components/drag-node/styles.tsx
330
+ var UIDragNodeContainer2 = styled2.div`
331
+ position: relative;
332
+ height: 32px;
333
+ border-radius: 5px;
334
+ display: flex;
335
+ align-items: center;
336
+ cursor: pointer;
337
+ font-size: 19px;
338
+ border: 1px solid ${primary};
339
+ padding: 0 15px;
340
+ &:hover: {
341
+ background-color: ${primaryOpacity09};
342
+ color: ${primary};
343
+ }
344
+ `;
345
+ var UIDragCounts = styled2.div`
346
+ position: absolute;
347
+ top: -8px;
348
+ right: -8px;
349
+ text-align: center;
350
+ line-height: 16px;
351
+ width: 16px;
352
+ height: 16px;
353
+ border-radius: 8px;
354
+ font-size: 12px;
355
+ color: #fff;
356
+ background-color: ${primary};
357
+ `;
358
+
359
+ // src/components/drag-node/index.tsx
360
+ function DragNode(props) {
361
+ const { dragStart, dragNodes } = props;
362
+ const dragLength = (dragNodes || []).map(
363
+ (_node) => _node.allCollapsedChildren.length ? _node.allCollapsedChildren.filter((_n) => !_n.hidden).length : 1
364
+ ).reduce((acm, curr) => acm + curr, 0);
365
+ return /* @__PURE__ */ React5.createElement(UIDragNodeContainer2, null, dragStart?.id, dragLength > 1 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(UIDragCounts, null, dragLength), /* @__PURE__ */ React5.createElement(
366
+ UIDragNodeContainer2,
367
+ {
368
+ style: {
369
+ position: "absolute",
370
+ top: 5,
371
+ right: -5,
372
+ left: 5,
373
+ bottom: -5,
374
+ opacity: 0.5
375
+ }
376
+ }
377
+ )));
378
+ }
379
+
380
+ // src/components/drag-highlight-adder/index.tsx
381
+ import React6 from "react";
382
+ import { min } from "lodash";
383
+ import { FlowNodeTransformData as FlowNodeTransformData2 } from "@flowgram.ai/fixed-layout-editor";
384
+
385
+ // src/components/drag-highlight-adder/styles.tsx
386
+ import styled3 from "styled-components";
387
+ var UILineContainer = styled3.div`
388
+ display: flex;
389
+ align-items: center;
390
+ `;
391
+ var UILine = (width, height) => styled3.div`
392
+ width: ${width}px;
393
+ height: ${height}px;
394
+ background: #3370ff;
395
+ `;
396
+
397
+ // src/components/drag-highlight-adder/index.tsx
398
+ var getMinSize = (preWidth, nextWidth) => {
399
+ if (!preWidth || preWidth < 0) {
400
+ return 0;
401
+ }
402
+ if (!nextWidth || nextWidth < 0) {
403
+ return preWidth;
404
+ }
405
+ return min([preWidth, nextWidth]) || 0;
406
+ };
407
+ function DragHighlightAdder({ node }) {
408
+ const transformBounds = node.getData(FlowNodeTransformData2)?.bounds;
409
+ const { isVertical } = node;
410
+ if (isVertical) {
411
+ const preWidth = (transformBounds?.width || 0) - 16;
412
+ const nextNodeBounds2 = node?.next?.getData(FlowNodeTransformData2)?.bounds?.width;
413
+ const nextWidth = (nextNodeBounds2 || 0) - 16;
414
+ const LineDom2 = UILine(getMinSize(preWidth, nextWidth), 2);
415
+ return /* @__PURE__ */ React6.createElement(UILineContainer, null, /* @__PURE__ */ React6.createElement(Ellipse, null), /* @__PURE__ */ React6.createElement(LineDom2, null), /* @__PURE__ */ React6.createElement(Ellipse, null));
416
+ }
417
+ const preHeight = (transformBounds?.height || 0) - 16;
418
+ const nextNodeBounds = node?.next?.getData(FlowNodeTransformData2)?.bounds?.height;
419
+ const nextHeight = (nextNodeBounds || 0) - 16;
420
+ const LineDom = UILine(2, getMinSize(preHeight, nextHeight));
421
+ return /* @__PURE__ */ React6.createElement(UILineContainer, { style: { flexDirection: "column" } }, /* @__PURE__ */ React6.createElement(Ellipse, null), /* @__PURE__ */ React6.createElement(LineDom, null), /* @__PURE__ */ React6.createElement(Ellipse, null));
422
+ }
423
+
424
+ // src/components/collapse/index.tsx
425
+ import React7 from "react";
426
+ import {
427
+ Playground as Playground2,
428
+ FlowNodeRenderData as FlowNodeRenderData2,
429
+ FlowNodeTransformData as FlowNodeTransformData3
430
+ } from "@flowgram.ai/fixed-layout-editor";
431
+
432
+ // src/components/collapse/styles.tsx
433
+ import styled4 from "styled-components";
434
+ var Container = styled4.div`
435
+ width: 16px;
436
+ height: 16px;
437
+ font-size: 10px;
438
+ border-radius: 9px;
439
+ display: flex;
440
+ color: #fff;
441
+ cursor: pointer;
442
+ justify-content: center;
443
+ align-items: center;
444
+ background: ${(props) => props.hoverActivated ? "#82A7FC" : "#BBBFC4"};
445
+ transform: ${(props) => !props.isVertical && props.isCollapse ? "rotate(-90deg)" : ""};
446
+ `;
447
+
448
+ // src/components/collapse/index.tsx
449
+ function Collapse(props) {
450
+ const { collapseNode, activateNode, hoverActivated } = props;
451
+ const activateData = activateNode?.getData(FlowNodeRenderData2);
452
+ const transform = collapseNode.getData(FlowNodeTransformData3);
453
+ if (!transform) {
454
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null);
455
+ }
456
+ const scrollToActivateNode = () => {
457
+ setTimeout(() => {
458
+ Playground2.getLatest()?.scrollToView({
459
+ position: activateNode?.getData(FlowNodeTransformData3)?.outputPoint,
460
+ scrollToCenter: true
461
+ });
462
+ }, 100);
463
+ };
464
+ const collapseBlock = () => {
465
+ transform.collapsed = true;
466
+ activateData?.toggleMouseLeave();
467
+ scrollToActivateNode();
468
+ };
469
+ const openBlock = () => {
470
+ transform.collapsed = false;
471
+ scrollToActivateNode();
472
+ };
473
+ if (transform.collapsed) {
474
+ const childCount = collapseNode.allCollapsedChildren.filter(
475
+ (child) => !child.hidden && child !== activateNode
476
+ ).length;
477
+ return /* @__PURE__ */ React7.createElement(Container, { onClick: openBlock, hoverActivated, "aria-hidden": "true" }, childCount);
478
+ }
479
+ const circleColor = "var(--semi-color-white)";
480
+ const color = hoverActivated ? "#82A7FC" : "#BBBFC4";
481
+ return /* @__PURE__ */ React7.createElement(
482
+ Container,
483
+ {
484
+ onClick: collapseBlock,
485
+ hoverActivated,
486
+ isVertical: activateNode?.isVertical,
487
+ isCollapse: true,
488
+ "aria-hidden": "true"
489
+ },
490
+ /* @__PURE__ */ React7.createElement(Arrow, { color, circleColor })
491
+ );
492
+ }
493
+ var collapse_default = Collapse;
494
+
495
+ // src/components/branch-adder/index.tsx
496
+ import React8 from "react";
497
+ import { nanoid } from "nanoid";
498
+ import {
499
+ FlowNodeRenderData as FlowNodeRenderData3,
500
+ FlowNodeTransformData as FlowNodeTransformData4,
501
+ FlowOperationService,
502
+ usePlayground as usePlayground2,
503
+ useService
504
+ } from "@flowgram.ai/fixed-layout-editor";
505
+ import { IconPlus } from "@douyinfe/semi-icons";
506
+
507
+ // src/components/branch-adder/styles.tsx
508
+ import styled5 from "styled-components";
509
+ var Container2 = styled5.div`
510
+ width: 28px;
511
+ height: 18px;
512
+ background: ${(props) => props.activated ? "#82A7FC" : "rgb(187, 191, 196)"};
513
+ display: flex;
514
+ border-radius: 9px;
515
+ justify-content: space-evenly;
516
+ align-items: center;
517
+ color: #fff;
518
+ font-size: 10px;
519
+ font-weight: bold;
520
+ transform: ${(props) => props.isVertical ? "" : "rotate(90deg)"};
521
+ div {
522
+ display: flex;
523
+ justify-content: center;
524
+ align-items: center;
525
+ svg {
526
+ width: 12px;
527
+ height: 12px;
528
+ }
529
+ }
530
+ `;
531
+
532
+ // src/components/branch-adder/index.tsx
533
+ function BranchAdder(props) {
534
+ const { activated, node } = props;
535
+ const nodeData = node.firstChild?.getData(FlowNodeRenderData3);
536
+ const playground = usePlayground2();
537
+ const flowOperationService = useService(FlowOperationService);
538
+ const { isVertical } = node;
539
+ function addBranch() {
540
+ const block = flowOperationService.addBlock(node, { id: nanoid(5) });
541
+ setTimeout(() => {
542
+ playground.scrollToView({
543
+ bounds: block.getData(FlowNodeTransformData4).bounds,
544
+ scrollToCenter: true
545
+ });
546
+ }, 10);
547
+ }
548
+ if (playground.config.readonlyOrDisabled) return null;
549
+ return /* @__PURE__ */ React8.createElement(
550
+ Container2,
551
+ {
552
+ isVertical,
553
+ activated: activated || nodeData?.hovered,
554
+ onMouseEnter: () => nodeData?.toggleMouseEnter(),
555
+ onMouseLeave: () => nodeData?.toggleMouseLeave()
556
+ },
557
+ /* @__PURE__ */ React8.createElement(
558
+ "div",
559
+ {
560
+ onClick: () => {
561
+ addBranch();
562
+ },
563
+ "aria-hidden": "true",
564
+ style: { flexGrow: 1, textAlign: "center", cursor: "pointer" }
565
+ },
566
+ /* @__PURE__ */ React8.createElement(IconPlus, null)
567
+ )
568
+ );
569
+ }
570
+
571
+ // src/components/adder/index.tsx
572
+ import React11, { useState as useState2 } from "react";
573
+ import { nanoid as nanoid3 } from "nanoid";
574
+ import {
575
+ FlowNodeTransformData as FlowNodeTransformData5,
576
+ usePlayground as usePlayground3,
577
+ useService as useService2,
578
+ FlowOperationService as FlowOperationService2
579
+ } from "@flowgram.ai/fixed-layout-editor";
580
+ import { Popover } from "@douyinfe/semi-ui";
581
+
582
+ // src/components/nodes/index.tsx
583
+ import React10 from "react";
584
+
585
+ // src/components/metadata.tsx
586
+ import React9 from "react";
587
+ import { nanoid as nanoid2 } from "nanoid";
588
+ var metadata = {
589
+ nodes: [
590
+ {
591
+ type: "start",
592
+ label: "Start",
593
+ icon: /* @__PURE__ */ React9.createElement(IconStyleBorder, null)
594
+ },
595
+ {
596
+ type: "dynamicSplit",
597
+ label: "Split Branch",
598
+ icon: /* @__PURE__ */ React9.createElement(IconParkRightBranch, null),
599
+ blocks() {
600
+ return [
601
+ {
602
+ id: nanoid2(5)
603
+ },
604
+ {
605
+ id: nanoid2(5)
606
+ }
607
+ ];
608
+ }
609
+ },
610
+ {
611
+ type: "end",
612
+ label: "Branch End",
613
+ icon: /* @__PURE__ */ React9.createElement(FeAlignCenter, null),
614
+ branchEnd: true
615
+ },
616
+ {
617
+ type: "loop",
618
+ schemaType: "loop",
619
+ label: "Loop",
620
+ icon: /* @__PURE__ */ React9.createElement(BiBootstrapReboot, null)
621
+ },
622
+ {
623
+ type: "tryCatch",
624
+ schemaType: "tryCatch",
625
+ label: "TryCatch",
626
+ icon: /* @__PURE__ */ React9.createElement(IconParkRightBranch, null),
627
+ blocks() {
628
+ return [
629
+ {
630
+ id: `try_${nanoid2(5)}`
631
+ // try branch
632
+ },
633
+ {
634
+ id: `catch_${nanoid2(5)}`
635
+ // catch branch 1
636
+ },
637
+ {
638
+ id: `catch_${nanoid2(5)}`
639
+ // catch branch 2
640
+ }
641
+ ];
642
+ }
643
+ },
644
+ {
645
+ type: "noop",
646
+ label: "Noop Node",
647
+ icon: /* @__PURE__ */ React9.createElement(BiCloud, null)
648
+ },
649
+ {
650
+ type: "end",
651
+ label: "End",
652
+ icon: /* @__PURE__ */ React9.createElement(PhCircleBold, null)
653
+ }
654
+ ],
655
+ find: function find(type) {
656
+ return metadata.nodes.find((m) => m.type === type);
657
+ }
658
+ };
659
+ var metadata_default = metadata;
660
+
661
+ // src/components/nodes/styles.tsx
662
+ import styled6 from "styled-components";
663
+ var NodeWrap = styled6.div`
664
+ width: 100%;
665
+ height: 32px;
666
+ border-radius: 5px;
667
+ display: flex;
668
+ align-items: center;
669
+ cursor: pointer;
670
+ font-size: 19px;
671
+ padding: 0 15px;
672
+ &:hover: {
673
+ background-color: ${primaryOpacity09};
674
+ color: ${primary};
675
+ },
676
+ `;
677
+ var NodeLabel = styled6.div`
678
+ font-size: 12px;
679
+ margin-left: 10px;
680
+ `;
681
+ var NodesWrap = styled6.div`
682
+ max-height: 500px;
683
+ overflow: auto;
684
+ &::-webkit-scrollbar {
685
+ display: none;
686
+ }
687
+ `;
688
+
689
+ // src/components/nodes/index.tsx
690
+ function Node(props) {
691
+ return /* @__PURE__ */ React10.createElement(NodeWrap, { onClick: props.onClick }, /* @__PURE__ */ React10.createElement("div", { style: { fontSize: 14 } }, props.icon), /* @__PURE__ */ React10.createElement(NodeLabel, null, props.label));
692
+ }
693
+ var addings = metadata_default.nodes.filter((node) => node.type !== "start");
694
+ function Nodes(props) {
695
+ return /* @__PURE__ */ React10.createElement(NodesWrap, { style: { width: 80 * 2 + 20 } }, addings.map((n, i) => (
696
+ // eslint-disable-next-line react/no-array-index-key
697
+ /* @__PURE__ */ React10.createElement(Node, { key: i, icon: n.icon, label: n.label, onClick: () => props.onSelect?.(n) })
698
+ )));
699
+ }
700
+
701
+ // src/components/adder/styles.tsx
702
+ import styled7 from "styled-components";
703
+ import { IconPlusCircle } from "@douyinfe/semi-icons";
704
+ var AdderWrap = styled7.div`
705
+ width: ${(props) => props.hovered ? 15 : 6}px;
706
+ height: ${(props) => props.hovered ? 15 : 6}px;
707
+ background-color: rgb(143, 149, 158);
708
+ color: #fff;
709
+ border-radius: 50%;
710
+ display: flex;
711
+ align-items: center;
712
+ justify-content: center;
713
+ cursor: pointer;
714
+ `;
715
+ var IconPlus2 = styled7(IconPlusCircle)`
716
+ color: #3370ff;
717
+ background-color: #fff;
718
+ border-radius: 15px;
719
+ `;
720
+
721
+ // src/components/adder/index.tsx
722
+ function Adder(props) {
723
+ const { from } = props;
724
+ const [visible, setVisible] = useState2(false);
725
+ const playground = usePlayground3();
726
+ const flowOperationService = useService2(FlowOperationService2);
727
+ const add = (addProps) => {
728
+ const block = flowOperationService.addFromNode(from, {
729
+ id: addProps.type + nanoid3(5),
730
+ type: addProps.type,
731
+ blocks: addProps.blocks ? addProps.blocks() : void 0
732
+ });
733
+ setTimeout(() => {
734
+ playground.scrollToView({
735
+ bounds: block.getData(FlowNodeTransformData5).bounds,
736
+ scrollToCenter: true
737
+ });
738
+ }, 10);
739
+ };
740
+ if (playground.config.readonlyOrDisabled) return null;
741
+ return /* @__PURE__ */ React11.createElement(
742
+ Popover,
743
+ {
744
+ visible,
745
+ onVisibleChange: setVisible,
746
+ content: /* @__PURE__ */ React11.createElement(Nodes, { onSelect: add }),
747
+ placement: "right",
748
+ trigger: "click",
749
+ overlayStyle: {
750
+ padding: 0
751
+ }
752
+ },
753
+ /* @__PURE__ */ React11.createElement(
754
+ AdderWrap,
755
+ {
756
+ hovered: props.hoverActivated,
757
+ onMouseDown: (e) => e.stopPropagation(),
758
+ onClick: () => {
759
+ setVisible(true);
760
+ }
761
+ },
762
+ props.hoverActivated ? /* @__PURE__ */ React11.createElement(IconPlus2, null) : null
763
+ )
764
+ );
765
+ }
766
+
767
+ // src/components/index.tsx
768
+ var defaultFixedSemiMaterials = {
769
+ [FlowRendererKey.ADDER]: Adder,
770
+ [FlowRendererKey.COLLAPSE]: collapse_default,
771
+ [FlowRendererKey.TRY_CATCH_COLLAPSE]: try_catch_collapse_default,
772
+ [FlowRendererKey.BRANCH_ADDER]: BranchAdder,
773
+ [FlowRendererKey.DRAG_NODE]: DragNode,
774
+ [FlowRendererKey.DRAGGABLE_ADDER]: DraggingAdder,
775
+ [FlowRendererKey.DRAG_HIGHLIGHT_ADDER]: DragHighlightAdder,
776
+ [FlowRendererKey.DRAG_BRANCH_HIGHLIGHT_ADDER]: Ellipse
777
+ };
778
+
779
+ // src/components/tools.tsx
780
+ import React12 from "react";
781
+ import { usePlaygroundTools } from "@flowgram.ai/fixed-layout-editor";
782
+ import { Checkbox, IconButton, Space, Tooltip } from "@douyinfe/semi-ui";
783
+ import { IconUndo, IconRedo, IconShrink, IconExpand, IconGridView } from "@douyinfe/semi-icons";
784
+ var PlaygroundTools = ({ layoutText }) => {
785
+ const tools = usePlaygroundTools();
786
+ const { zoom } = tools;
787
+ return /* @__PURE__ */ React12.createElement(Space, null, /* @__PURE__ */ React12.createElement(Checkbox, { onChange: () => tools.changeLayout(), checked: !tools.isVertical }, layoutText || "isHorizontal"), /* @__PURE__ */ React12.createElement(Tooltip, { content: "fit view" }, /* @__PURE__ */ React12.createElement(IconButton, { icon: /* @__PURE__ */ React12.createElement(IconGridView, null), onClick: () => tools.fitView() })), /* @__PURE__ */ React12.createElement(Tooltip, { content: "zoom out" }, /* @__PURE__ */ React12.createElement(IconButton, { icon: /* @__PURE__ */ React12.createElement(IconShrink, null), onClick: () => tools.zoomout() })), /* @__PURE__ */ React12.createElement(Tooltip, { content: "zoom in" }, /* @__PURE__ */ React12.createElement(IconButton, { icon: /* @__PURE__ */ React12.createElement(IconExpand, null), onClick: () => tools.zoomin() })), /* @__PURE__ */ React12.createElement(Tooltip, { content: "undo" }, /* @__PURE__ */ React12.createElement(IconButton, { icon: /* @__PURE__ */ React12.createElement(IconUndo, null), disabled: tools.canUndo, onClick: () => tools.undo() })), /* @__PURE__ */ React12.createElement(Tooltip, { content: "redo" }, /* @__PURE__ */ React12.createElement(IconButton, { icon: /* @__PURE__ */ React12.createElement(IconRedo, null), disabled: tools.canRedo, onClick: () => tools.redo() })), /* @__PURE__ */ React12.createElement("span", null, Math.floor(zoom * 100), "%"));
788
+ };
789
+ export {
790
+ PlaygroundTools,
791
+ defaultFixedSemiMaterials
792
+ };
793
+ //# sourceMappingURL=index.js.map