@flowgram.ai/fixed-semi-materials 0.1.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.
@@ -0,0 +1,777 @@
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
+ } from "@flowgram.ai/fixed-layout-editor";
166
+ import { IconChevronLeft } from "@douyinfe/semi-icons";
167
+ function TryCatchCollapse(props) {
168
+ const { node } = props;
169
+ const activateData = node.getData(FlowNodeRenderData);
170
+ const transform = node.getData(FlowNodeTransformData);
171
+ const [hoverActivated, setHoverActivated] = useState(false);
172
+ if (!transform || !transform.parent) {
173
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null);
174
+ }
175
+ const width = transform.inputPoint.x - transform.parent.inputPoint.x;
176
+ const height = 40;
177
+ const scrollToActivateNode = () => {
178
+ setTimeout(() => {
179
+ Playground.getLatest()?.scrollToView({
180
+ position: node?.getData(FlowNodeTransformData)?.inputPoint,
181
+ scrollToCenter: true
182
+ });
183
+ }, 100);
184
+ };
185
+ const collapseBlock = () => {
186
+ transform.collapsed = true;
187
+ activateData.activated = false;
188
+ scrollToActivateNode();
189
+ };
190
+ const openBlock = () => {
191
+ transform.collapsed = false;
192
+ scrollToActivateNode();
193
+ };
194
+ const handleMouseEnter = () => {
195
+ setHoverActivated(true);
196
+ activateData.activated = true;
197
+ };
198
+ const handleMouseLeave = () => {
199
+ setHoverActivated(false);
200
+ activateData.activated = false;
201
+ };
202
+ const renderCollapse = () => {
203
+ if (transform.collapsed) {
204
+ const childCount = node.allCollapsedChildren.filter(
205
+ (child) => !child.hidden && child !== node
206
+ ).length;
207
+ return /* @__PURE__ */ React3.createElement(
208
+ "div",
209
+ {
210
+ onClick: openBlock,
211
+ style: {
212
+ width: 16,
213
+ height: 16,
214
+ fontSize: 10,
215
+ borderRadius: 9,
216
+ display: "flex",
217
+ color: "#fff",
218
+ cursor: "pointer",
219
+ justifyContent: "center",
220
+ alignItems: "center",
221
+ background: hoverActivated ? "#82A7FC" : "#BBBFC4"
222
+ },
223
+ "aria-hidden": "true"
224
+ },
225
+ childCount
226
+ );
227
+ }
228
+ if (hoverActivated) {
229
+ return /* @__PURE__ */ React3.createElement(
230
+ "div",
231
+ {
232
+ onClick: collapseBlock,
233
+ style: {
234
+ width: 16,
235
+ height: 16,
236
+ fontSize: 10,
237
+ borderRadius: 9,
238
+ display: "flex",
239
+ color: "#fff",
240
+ cursor: "pointer",
241
+ justifyContent: "center",
242
+ alignItems: "center",
243
+ background: "#82A7FC"
244
+ },
245
+ "aria-hidden": "true"
246
+ },
247
+ /* @__PURE__ */ React3.createElement(IconChevronLeft, null)
248
+ );
249
+ }
250
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null);
251
+ };
252
+ return /* @__PURE__ */ React3.createElement(
253
+ "div",
254
+ {
255
+ onMouseEnter: handleMouseEnter,
256
+ onMouseLeave: handleMouseLeave,
257
+ style: {
258
+ width,
259
+ height,
260
+ display: "flex",
261
+ alignItems: "center",
262
+ justifyContent: "center",
263
+ gap: 6
264
+ }
265
+ },
266
+ /* @__PURE__ */ React3.createElement(
267
+ "div",
268
+ {
269
+ style: {
270
+ fontSize: 12,
271
+ color: "#8F959E",
272
+ textAlign: "center",
273
+ whiteSpace: "nowrap",
274
+ backgroundColor: "var(--g-editor-background)",
275
+ lineHeight: "20px"
276
+ }
277
+ },
278
+ "Something error"
279
+ ),
280
+ renderCollapse()
281
+ );
282
+ }
283
+ var try_catch_collapse_default = TryCatchCollapse;
284
+
285
+ // src/components/dragging-adder/index.tsx
286
+ import React4 from "react";
287
+
288
+ // src/components/dragging-adder/styles.tsx
289
+ import styled from "styled-components";
290
+ var UIDragNodeContainer = styled.div`
291
+ width: 16px;
292
+ height: 16px;
293
+ border-radius: 100px;
294
+ background-color: white;
295
+ border: 1px dashed #b8bcc1;
296
+ `;
297
+
298
+ // src/components/dragging-adder/index.tsx
299
+ function DraggingAdder() {
300
+ return /* @__PURE__ */ React4.createElement(UIDragNodeContainer, null);
301
+ }
302
+
303
+ // src/components/drag-node/index.tsx
304
+ import React5 from "react";
305
+
306
+ // src/components/drag-node/styles.tsx
307
+ import styled2 from "styled-components";
308
+
309
+ // src/components/constants.tsx
310
+ var primary = "hsl(252 62% 54.9%)";
311
+ var primaryOpacity09 = "hsl(252deg 62% 55% / 9%)";
312
+
313
+ // src/components/drag-node/styles.tsx
314
+ var UIDragNodeContainer2 = styled2.div`
315
+ position: relative;
316
+ height: 32px;
317
+ border-radius: 5px;
318
+ display: flex;
319
+ align-items: center;
320
+ cursor: pointer;
321
+ font-size: 19px;
322
+ border: 1px solid ${primary};
323
+ padding: 0 15px;
324
+ &:hover: {
325
+ background-color: ${primaryOpacity09};
326
+ color: ${primary};
327
+ }
328
+ `;
329
+ var UIDragCounts = styled2.div`
330
+ position: absolute;
331
+ top: -8px;
332
+ right: -8px;
333
+ text-align: center;
334
+ line-height: 16px;
335
+ width: 16px;
336
+ height: 16px;
337
+ border-radius: 8px;
338
+ font-size: 12px;
339
+ color: #fff;
340
+ background-color: ${primary};
341
+ `;
342
+
343
+ // src/components/drag-node/index.tsx
344
+ function DragNode(props) {
345
+ const { dragStart, dragNodes } = props;
346
+ const dragLength = (dragNodes || []).map(
347
+ (_node) => _node.allCollapsedChildren.length ? _node.allCollapsedChildren.filter((_n) => !_n.hidden).length : 1
348
+ ).reduce((acm, curr) => acm + curr, 0);
349
+ 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(
350
+ UIDragNodeContainer2,
351
+ {
352
+ style: {
353
+ position: "absolute",
354
+ top: 5,
355
+ right: -5,
356
+ left: 5,
357
+ bottom: -5,
358
+ opacity: 0.5
359
+ }
360
+ }
361
+ )));
362
+ }
363
+
364
+ // src/components/drag-highlight-adder/index.tsx
365
+ import React6 from "react";
366
+ import { min } from "lodash";
367
+ import { FlowNodeTransformData as FlowNodeTransformData2 } from "@flowgram.ai/fixed-layout-editor";
368
+
369
+ // src/components/drag-highlight-adder/styles.tsx
370
+ import styled3 from "styled-components";
371
+ var UILineContainer = styled3.div`
372
+ display: flex;
373
+ align-items: center;
374
+ `;
375
+ var UILine = (width, height) => styled3.div`
376
+ width: ${width}px;
377
+ height: ${height}px;
378
+ background: #3370ff;
379
+ `;
380
+
381
+ // src/components/drag-highlight-adder/index.tsx
382
+ var getMinSize = (preWidth, nextWidth) => {
383
+ if (!preWidth || preWidth < 0) {
384
+ return 0;
385
+ }
386
+ if (!nextWidth || nextWidth < 0) {
387
+ return preWidth;
388
+ }
389
+ return min([preWidth, nextWidth]) || 0;
390
+ };
391
+ function DragHighlightAdder({ node }) {
392
+ const transformBounds = node.getData(FlowNodeTransformData2)?.bounds;
393
+ const { isVertical } = node;
394
+ if (isVertical) {
395
+ const preWidth = (transformBounds?.width || 0) - 16;
396
+ const nextNodeBounds2 = node?.next?.getData(FlowNodeTransformData2)?.bounds?.width;
397
+ const nextWidth = (nextNodeBounds2 || 0) - 16;
398
+ const LineDom2 = UILine(getMinSize(preWidth, nextWidth), 2);
399
+ return /* @__PURE__ */ React6.createElement(UILineContainer, null, /* @__PURE__ */ React6.createElement(Ellipse, null), /* @__PURE__ */ React6.createElement(LineDom2, null), /* @__PURE__ */ React6.createElement(Ellipse, null));
400
+ }
401
+ const preHeight = (transformBounds?.height || 0) - 16;
402
+ const nextNodeBounds = node?.next?.getData(FlowNodeTransformData2)?.bounds?.height;
403
+ const nextHeight = (nextNodeBounds || 0) - 16;
404
+ const LineDom = UILine(2, getMinSize(preHeight, nextHeight));
405
+ return /* @__PURE__ */ React6.createElement(UILineContainer, { style: { flexDirection: "column" } }, /* @__PURE__ */ React6.createElement(Ellipse, null), /* @__PURE__ */ React6.createElement(LineDom, null), /* @__PURE__ */ React6.createElement(Ellipse, null));
406
+ }
407
+
408
+ // src/components/collapse/index.tsx
409
+ import React7 from "react";
410
+ import {
411
+ Playground as Playground2,
412
+ FlowNodeRenderData as FlowNodeRenderData2,
413
+ FlowNodeTransformData as FlowNodeTransformData3
414
+ } from "@flowgram.ai/fixed-layout-editor";
415
+
416
+ // src/components/collapse/styles.tsx
417
+ import styled4 from "styled-components";
418
+ var Container = styled4.div`
419
+ width: 16px;
420
+ height: 16px;
421
+ font-size: 10px;
422
+ border-radius: 9px;
423
+ display: flex;
424
+ color: #fff;
425
+ cursor: pointer;
426
+ justify-content: center;
427
+ align-items: center;
428
+ background: ${(props) => props.hoverActivated ? "#82A7FC" : "#BBBFC4"};
429
+ transform: ${(props) => !props.isVertical && props.isCollapse ? "rotate(-90deg)" : ""};
430
+ `;
431
+
432
+ // src/components/collapse/index.tsx
433
+ function Collapse(props) {
434
+ const { collapseNode, activateNode, hoverActivated } = props;
435
+ const activateData = activateNode?.getData(FlowNodeRenderData2);
436
+ const transform = collapseNode.getData(FlowNodeTransformData3);
437
+ if (!transform) {
438
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null);
439
+ }
440
+ const scrollToActivateNode = () => {
441
+ setTimeout(() => {
442
+ Playground2.getLatest()?.scrollToView({
443
+ position: activateNode?.getData(FlowNodeTransformData3)?.outputPoint,
444
+ scrollToCenter: true
445
+ });
446
+ }, 100);
447
+ };
448
+ const collapseBlock = () => {
449
+ transform.collapsed = true;
450
+ activateData?.toggleMouseLeave();
451
+ scrollToActivateNode();
452
+ };
453
+ const openBlock = () => {
454
+ transform.collapsed = false;
455
+ scrollToActivateNode();
456
+ };
457
+ if (transform.collapsed) {
458
+ const childCount = collapseNode.allCollapsedChildren.filter(
459
+ (child) => !child.hidden && child !== activateNode
460
+ ).length;
461
+ return /* @__PURE__ */ React7.createElement(Container, { onClick: openBlock, hoverActivated, "aria-hidden": "true" }, childCount);
462
+ }
463
+ const circleColor = "var(--semi-color-white)";
464
+ const color = hoverActivated ? "#82A7FC" : "#BBBFC4";
465
+ return /* @__PURE__ */ React7.createElement(
466
+ Container,
467
+ {
468
+ onClick: collapseBlock,
469
+ hoverActivated,
470
+ isVertical: activateNode?.isVertical,
471
+ isCollapse: true,
472
+ "aria-hidden": "true"
473
+ },
474
+ /* @__PURE__ */ React7.createElement(Arrow, { color, circleColor })
475
+ );
476
+ }
477
+ var collapse_default = Collapse;
478
+
479
+ // src/components/branch-adder/index.tsx
480
+ import React8 from "react";
481
+ import { nanoid } from "nanoid";
482
+ import {
483
+ FlowNodeRenderData as FlowNodeRenderData3,
484
+ FlowNodeTransformData as FlowNodeTransformData4,
485
+ usePlayground,
486
+ useService,
487
+ FlowOperationService
488
+ } from "@flowgram.ai/fixed-layout-editor";
489
+ import { IconPlus } from "@douyinfe/semi-icons";
490
+
491
+ // src/components/branch-adder/styles.tsx
492
+ import styled5 from "styled-components";
493
+ var Container2 = styled5.div`
494
+ width: 28px;
495
+ height: 18px;
496
+ background: ${(props) => props.activated ? "#82A7FC" : "rgb(187, 191, 196)"};
497
+ display: flex;
498
+ border-radius: 9px;
499
+ justify-content: space-evenly;
500
+ align-items: center;
501
+ color: #fff;
502
+ font-size: 10px;
503
+ font-weight: bold;
504
+ transform: ${(props) => props.isVertical ? "" : "rotate(90deg)"};
505
+ div {
506
+ display: flex;
507
+ justify-content: center;
508
+ align-items: center;
509
+ svg {
510
+ width: 12px;
511
+ height: 12px;
512
+ }
513
+ }
514
+ `;
515
+
516
+ // src/components/branch-adder/index.tsx
517
+ function BranchAdder(props) {
518
+ const { activated, node } = props;
519
+ const nodeData = node.firstChild?.getData(FlowNodeRenderData3);
520
+ const playground = usePlayground();
521
+ const flowOperationService = useService(FlowOperationService);
522
+ const { isVertical } = node;
523
+ function addBranch() {
524
+ const block = flowOperationService.addBlock(node, { id: nanoid(5) });
525
+ setTimeout(() => {
526
+ playground.scrollToView({
527
+ bounds: block.getData(FlowNodeTransformData4).bounds,
528
+ scrollToCenter: true
529
+ });
530
+ }, 10);
531
+ }
532
+ if (playground.config.readonlyOrDisabled) return null;
533
+ return /* @__PURE__ */ React8.createElement(
534
+ Container2,
535
+ {
536
+ isVertical,
537
+ activated,
538
+ onMouseEnter: () => nodeData?.toggleMouseEnter(),
539
+ onMouseLeave: () => nodeData?.toggleMouseLeave()
540
+ },
541
+ /* @__PURE__ */ React8.createElement(
542
+ "div",
543
+ {
544
+ onClick: () => {
545
+ addBranch();
546
+ },
547
+ "aria-hidden": "true",
548
+ style: { flexGrow: 1, textAlign: "center" }
549
+ },
550
+ /* @__PURE__ */ React8.createElement(IconPlus, null)
551
+ )
552
+ );
553
+ }
554
+
555
+ // src/components/adder/index.tsx
556
+ import React11, { useState as useState2 } from "react";
557
+ import { nanoid as nanoid3 } from "nanoid";
558
+ import {
559
+ FlowNodeTransformData as FlowNodeTransformData5,
560
+ usePlayground as usePlayground2,
561
+ useService as useService2,
562
+ FlowOperationService as FlowOperationService2
563
+ } from "@flowgram.ai/fixed-layout-editor";
564
+ import { Popover } from "@douyinfe/semi-ui";
565
+
566
+ // src/components/nodes/index.tsx
567
+ import React10 from "react";
568
+
569
+ // src/components/metadata.tsx
570
+ import React9 from "react";
571
+ import { nanoid as nanoid2 } from "nanoid";
572
+ var metadata = {
573
+ nodes: [
574
+ {
575
+ type: "start",
576
+ label: "Start",
577
+ icon: /* @__PURE__ */ React9.createElement(IconStyleBorder, null)
578
+ },
579
+ {
580
+ type: "dynamicSplit",
581
+ label: "Split Branch",
582
+ icon: /* @__PURE__ */ React9.createElement(IconParkRightBranch, null),
583
+ blocks() {
584
+ return [
585
+ {
586
+ id: nanoid2(5)
587
+ },
588
+ {
589
+ id: nanoid2(5)
590
+ }
591
+ ];
592
+ }
593
+ },
594
+ {
595
+ type: "end",
596
+ label: "Branch End",
597
+ icon: /* @__PURE__ */ React9.createElement(FeAlignCenter, null),
598
+ branchEnd: true
599
+ },
600
+ {
601
+ type: "loop",
602
+ schemaType: "loop",
603
+ label: "Loop",
604
+ icon: /* @__PURE__ */ React9.createElement(BiBootstrapReboot, null)
605
+ },
606
+ {
607
+ type: "tryCatch",
608
+ schemaType: "tryCatch",
609
+ label: "TryCatch",
610
+ icon: /* @__PURE__ */ React9.createElement(IconParkRightBranch, null),
611
+ blocks() {
612
+ return [
613
+ {
614
+ id: `try_${nanoid2(5)}`
615
+ // try branch
616
+ },
617
+ {
618
+ id: `catch_${nanoid2(5)}`
619
+ // catch branch 1
620
+ },
621
+ {
622
+ id: `catch_${nanoid2(5)}`
623
+ // catch branch 2
624
+ }
625
+ ];
626
+ }
627
+ },
628
+ {
629
+ type: "noop",
630
+ label: "Noop Node",
631
+ icon: /* @__PURE__ */ React9.createElement(BiCloud, null)
632
+ },
633
+ {
634
+ type: "end",
635
+ label: "End",
636
+ icon: /* @__PURE__ */ React9.createElement(PhCircleBold, null)
637
+ }
638
+ ],
639
+ find: function find(type) {
640
+ return metadata.nodes.find((m) => m.type === type);
641
+ }
642
+ };
643
+ var metadata_default = metadata;
644
+
645
+ // src/components/nodes/styles.tsx
646
+ import styled6 from "styled-components";
647
+ var NodeWrap = styled6.div`
648
+ width: 100%;
649
+ height: 32px;
650
+ border-radius: 5px;
651
+ display: flex;
652
+ align-items: center;
653
+ cursor: pointer;
654
+ font-size: 19px;
655
+ padding: 0 15px;
656
+ &:hover: {
657
+ background-color: ${primaryOpacity09};
658
+ color: ${primary};
659
+ },
660
+ `;
661
+ var NodeLabel = styled6.div`
662
+ font-size: 12px;
663
+ margin-left: 10px;
664
+ `;
665
+ var NodesWrap = styled6.div`
666
+ max-height: 500px;
667
+ overflow: auto;
668
+ &::-webkit-scrollbar {
669
+ display: none;
670
+ }
671
+ `;
672
+
673
+ // src/components/nodes/index.tsx
674
+ function Node(props) {
675
+ return /* @__PURE__ */ React10.createElement(NodeWrap, { onClick: props.onClick }, /* @__PURE__ */ React10.createElement("div", { style: { fontSize: 14 } }, props.icon), /* @__PURE__ */ React10.createElement(NodeLabel, null, props.label));
676
+ }
677
+ var addings = metadata_default.nodes.filter((node) => node.type !== "start");
678
+ function Nodes(props) {
679
+ return /* @__PURE__ */ React10.createElement(NodesWrap, { style: { width: 80 * 2 + 20 } }, addings.map((n, i) => (
680
+ // eslint-disable-next-line react/no-array-index-key
681
+ /* @__PURE__ */ React10.createElement(Node, { key: i, icon: n.icon, label: n.label, onClick: () => props.onSelect?.(n) })
682
+ )));
683
+ }
684
+
685
+ // src/components/adder/styles.tsx
686
+ import styled7 from "styled-components";
687
+ import { IconPlusCircle } from "@douyinfe/semi-icons";
688
+ var AdderWrap = styled7.div`
689
+ width: ${(props) => props.hovered ? 15 : 6}px;
690
+ height: ${(props) => props.hovered ? 15 : 6}px;
691
+ background-color: rgb(143, 149, 158);
692
+ color: #fff;
693
+ border-radius: 50%;
694
+ display: flex;
695
+ align-items: center;
696
+ justify-content: center;
697
+ cursor: pointer;
698
+ `;
699
+ var IconPlus2 = styled7(IconPlusCircle)`
700
+ color: #3370ff;
701
+ background-color: #fff;
702
+ border-radius: 15px;
703
+ `;
704
+
705
+ // src/components/adder/index.tsx
706
+ function Adder(props) {
707
+ const { from } = props;
708
+ const [visible, setVisible] = useState2(false);
709
+ const playground = usePlayground2();
710
+ const flowOperationService = useService2(FlowOperationService2);
711
+ const add = (addProps) => {
712
+ const block = flowOperationService.addFromNode(from, {
713
+ id: addProps.type + nanoid3(5),
714
+ type: addProps.type,
715
+ blocks: addProps.blocks ? addProps.blocks() : void 0
716
+ });
717
+ setTimeout(() => {
718
+ playground.scrollToView({
719
+ bounds: block.getData(FlowNodeTransformData5).bounds,
720
+ scrollToCenter: true
721
+ });
722
+ }, 10);
723
+ };
724
+ if (playground.config.readonlyOrDisabled) return null;
725
+ return /* @__PURE__ */ React11.createElement(
726
+ Popover,
727
+ {
728
+ visible,
729
+ onVisibleChange: setVisible,
730
+ content: /* @__PURE__ */ React11.createElement(Nodes, { onSelect: add }),
731
+ placement: "right",
732
+ trigger: "click",
733
+ overlayStyle: {
734
+ padding: 0
735
+ }
736
+ },
737
+ /* @__PURE__ */ React11.createElement(
738
+ AdderWrap,
739
+ {
740
+ hovered: props.hoverActivated,
741
+ onMouseDown: (e) => e.stopPropagation(),
742
+ onClick: () => {
743
+ setVisible(true);
744
+ }
745
+ },
746
+ props.hoverActivated ? /* @__PURE__ */ React11.createElement(IconPlus2, null) : null
747
+ )
748
+ );
749
+ }
750
+
751
+ // src/components/index.tsx
752
+ var defaultFixedSemiMaterials = {
753
+ [FlowRendererKey.ADDER]: Adder,
754
+ [FlowRendererKey.COLLAPSE]: collapse_default,
755
+ [FlowRendererKey.TRY_CATCH_COLLAPSE]: try_catch_collapse_default,
756
+ [FlowRendererKey.BRANCH_ADDER]: BranchAdder,
757
+ [FlowRendererKey.DRAG_NODE]: DragNode,
758
+ [FlowRendererKey.DRAGGABLE_ADDER]: DraggingAdder,
759
+ [FlowRendererKey.DRAG_HIGHLIGHT_ADDER]: DragHighlightAdder,
760
+ [FlowRendererKey.DRAG_BRANCH_HIGHLIGHT_ADDER]: Ellipse
761
+ };
762
+
763
+ // src/components/tools.tsx
764
+ import React12 from "react";
765
+ import { usePlaygroundTools } from "@flowgram.ai/fixed-layout-editor";
766
+ import { Checkbox, IconButton, Space, Tooltip } from "@douyinfe/semi-ui";
767
+ import { IconUndo, IconRedo, IconShrink, IconExpand, IconGridView } from "@douyinfe/semi-icons";
768
+ var PlaygroundTools = ({ layoutText }) => {
769
+ const tools = usePlaygroundTools();
770
+ const { zoom } = tools;
771
+ 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), "%"));
772
+ };
773
+ export {
774
+ PlaygroundTools,
775
+ defaultFixedSemiMaterials
776
+ };
777
+ //# sourceMappingURL=index.js.map