@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.
package/dist/index.js ADDED
@@ -0,0 +1,809 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ PlaygroundTools: () => PlaygroundTools,
34
+ defaultFixedSemiMaterials: () => defaultFixedSemiMaterials
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+
38
+ // src/components/index.tsx
39
+ var import_fixed_layout_editor7 = require("@flowgram.ai/fixed-layout-editor");
40
+
41
+ // src/assets/ellipsis.tsx
42
+ var import_react = __toESM(require("react"));
43
+ function Ellipse() {
44
+ return /* @__PURE__ */ import_react.default.createElement("svg", { width: "8", height: "8", viewBox: "0 0 8 8", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react.default.createElement("circle", { id: "Ellipse 465", cx: "4", cy: "4", r: "3", fill: "white", stroke: "#3370FF", strokeWidth: "2" }));
45
+ }
46
+
47
+ // src/assets/icons.tsx
48
+ var import_react2 = __toESM(require("react"));
49
+ function IconStyleBorder(props) {
50
+ return /* @__PURE__ */ import_react2.default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ import_react2.default.createElement(
51
+ "g",
52
+ {
53
+ fill: "none",
54
+ stroke: "currentColor",
55
+ strokeLinecap: "round",
56
+ strokeLinejoin: "round",
57
+ strokeMiterlimit: "1.5",
58
+ strokeWidth: "1.499"
59
+ },
60
+ /* @__PURE__ */ import_react2.default.createElement(
61
+ "path",
62
+ {
63
+ strokeDasharray: "2 2",
64
+ 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"
65
+ }
66
+ ),
67
+ /* @__PURE__ */ import_react2.default.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" })
68
+ ));
69
+ }
70
+ function IconParkRightBranch(props) {
71
+ return /* @__PURE__ */ import_react2.default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 48 48", ...props }, /* @__PURE__ */ import_react2.default.createElement("g", { fill: "none" }, /* @__PURE__ */ import_react2.default.createElement(
72
+ "path",
73
+ {
74
+ stroke: "currentColor",
75
+ strokeLinecap: "round",
76
+ strokeLinejoin: "round",
77
+ strokeWidth: "4",
78
+ d: "M22 8.01176C20.5 8.01193 16.0714 7.93811 15 13.0005C13.917 18.1177 9.85714 22.8477 8 24"
79
+ }
80
+ ), /* @__PURE__ */ import_react2.default.createElement(
81
+ "path",
82
+ {
83
+ stroke: "currentColor",
84
+ strokeLinecap: "round",
85
+ strokeLinejoin: "round",
86
+ strokeWidth: "4",
87
+ d: "M22 40C20.5 40.0003 16.0714 40.0628 15 35.0005C13.917 29.8833 9.85714 25.1522 8 23.9999"
88
+ }
89
+ ), /* @__PURE__ */ import_react2.default.createElement("circle", { cx: "8", cy: "24", r: "4", fill: "currentColor" }), /* @__PURE__ */ import_react2.default.createElement(
90
+ "path",
91
+ {
92
+ stroke: "currentColor",
93
+ strokeLinecap: "round",
94
+ strokeLinejoin: "round",
95
+ strokeWidth: "4",
96
+ d: "M8 24L22 24"
97
+ }
98
+ ), /* @__PURE__ */ import_react2.default.createElement(
99
+ "path",
100
+ {
101
+ stroke: "currentColor",
102
+ strokeLinecap: "round",
103
+ strokeLinejoin: "round",
104
+ strokeWidth: "4",
105
+ d: "M30 24.001H42"
106
+ }
107
+ ), /* @__PURE__ */ import_react2.default.createElement(
108
+ "path",
109
+ {
110
+ stroke: "currentColor",
111
+ strokeLinecap: "round",
112
+ strokeLinejoin: "round",
113
+ strokeWidth: "4",
114
+ d: "M30 8.00098H42"
115
+ }
116
+ ), /* @__PURE__ */ import_react2.default.createElement(
117
+ "path",
118
+ {
119
+ stroke: "currentColor",
120
+ strokeLinecap: "round",
121
+ strokeLinejoin: "round",
122
+ strokeWidth: "4",
123
+ d: "M30 40.001H42"
124
+ }
125
+ )));
126
+ }
127
+ function PhCircleBold(props) {
128
+ return /* @__PURE__ */ import_react2.default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 256 256", ...props }, /* @__PURE__ */ import_react2.default.createElement(
129
+ "path",
130
+ {
131
+ fill: "currentColor",
132
+ 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"
133
+ }
134
+ ));
135
+ }
136
+ function BiCloud(props) {
137
+ return /* @__PURE__ */ import_react2.default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 16 16", ...props }, /* @__PURE__ */ import_react2.default.createElement(
138
+ "path",
139
+ {
140
+ fill: "currentColor",
141
+ 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"
142
+ }
143
+ ));
144
+ }
145
+ function BiBootstrapReboot(props) {
146
+ return /* @__PURE__ */ import_react2.default.createElement(
147
+ "svg",
148
+ {
149
+ xmlns: "http://www.w3.org/2000/svg",
150
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
151
+ width: "1em",
152
+ height: "1em",
153
+ viewBox: "0 0 16 16",
154
+ ...props
155
+ },
156
+ /* @__PURE__ */ import_react2.default.createElement("g", { fill: "currentColor" }, /* @__PURE__ */ import_react2.default.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__ */ import_react2.default.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" }))
157
+ );
158
+ }
159
+ function FeAlignCenter(props) {
160
+ return /* @__PURE__ */ import_react2.default.createElement(
161
+ "svg",
162
+ {
163
+ xmlns: "http://www.w3.org/2000/svg",
164
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
165
+ width: "1em",
166
+ height: "1em",
167
+ viewBox: "0 0 24 24",
168
+ ...props
169
+ },
170
+ /* @__PURE__ */ import_react2.default.createElement(
171
+ "path",
172
+ {
173
+ fill: "#888888",
174
+ fillRule: "evenodd",
175
+ 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"
176
+ }
177
+ )
178
+ );
179
+ }
180
+ function Arrow({ color, circleColor }) {
181
+ return /* @__PURE__ */ import_react2.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react2.default.createElement("circle", { cx: "8", cy: "8", r: "7", fill: circleColor }), /* @__PURE__ */ import_react2.default.createElement(
182
+ "path",
183
+ {
184
+ fill: color,
185
+ 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"
186
+ }
187
+ ), /* @__PURE__ */ import_react2.default.createElement(
188
+ "path",
189
+ {
190
+ fill: color,
191
+ 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"
192
+ }
193
+ ));
194
+ }
195
+
196
+ // src/components/try-catch-collapse.tsx
197
+ var import_react3 = __toESM(require("react"));
198
+ var import_fixed_layout_editor = require("@flowgram.ai/fixed-layout-editor");
199
+ var import_semi_icons = require("@douyinfe/semi-icons");
200
+ function TryCatchCollapse(props) {
201
+ const { node } = props;
202
+ const { baseColor, baseActivatedColor } = (0, import_fixed_layout_editor.useBaseColor)();
203
+ const activateData = node.getData(import_fixed_layout_editor.FlowNodeRenderData);
204
+ const transform = node.getData(import_fixed_layout_editor.FlowNodeTransformData);
205
+ const [hoverActivated, setHoverActivated] = (0, import_react3.useState)(false);
206
+ if (!transform || !transform.parent) {
207
+ return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null);
208
+ }
209
+ const width = transform.inputPoint.x - transform.parent.inputPoint.x;
210
+ const height = 40;
211
+ const scrollToActivateNode = () => {
212
+ setTimeout(() => {
213
+ import_fixed_layout_editor.Playground.getLatest()?.scrollToView({
214
+ position: node?.getData(import_fixed_layout_editor.FlowNodeTransformData)?.inputPoint,
215
+ scrollToCenter: true
216
+ });
217
+ }, 100);
218
+ };
219
+ const collapseBlock = () => {
220
+ transform.collapsed = true;
221
+ activateData.activated = false;
222
+ scrollToActivateNode();
223
+ };
224
+ const openBlock = () => {
225
+ transform.collapsed = false;
226
+ scrollToActivateNode();
227
+ };
228
+ const handleMouseEnter = () => {
229
+ setHoverActivated(true);
230
+ activateData.activated = true;
231
+ };
232
+ const handleMouseLeave = () => {
233
+ setHoverActivated(false);
234
+ activateData.activated = false;
235
+ };
236
+ const renderCollapse = () => {
237
+ if (transform.collapsed) {
238
+ const childCount = node.allCollapsedChildren.filter(
239
+ (child) => !child.hidden && child !== node
240
+ ).length;
241
+ return /* @__PURE__ */ import_react3.default.createElement(
242
+ "div",
243
+ {
244
+ onClick: openBlock,
245
+ style: {
246
+ width: 16,
247
+ height: 16,
248
+ fontSize: 10,
249
+ borderRadius: 9,
250
+ display: "flex",
251
+ color: "#fff",
252
+ cursor: "pointer",
253
+ justifyContent: "center",
254
+ alignItems: "center",
255
+ background: hoverActivated ? baseActivatedColor : baseColor
256
+ },
257
+ "aria-hidden": "true"
258
+ },
259
+ childCount
260
+ );
261
+ }
262
+ if (hoverActivated) {
263
+ return /* @__PURE__ */ import_react3.default.createElement(
264
+ "div",
265
+ {
266
+ onClick: collapseBlock,
267
+ style: {
268
+ width: 16,
269
+ height: 16,
270
+ fontSize: 10,
271
+ borderRadius: 9,
272
+ display: "flex",
273
+ color: "#fff",
274
+ cursor: "pointer",
275
+ justifyContent: "center",
276
+ alignItems: "center",
277
+ background: baseActivatedColor
278
+ },
279
+ "aria-hidden": "true"
280
+ },
281
+ /* @__PURE__ */ import_react3.default.createElement(import_semi_icons.IconChevronLeft, null)
282
+ );
283
+ }
284
+ return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null);
285
+ };
286
+ return /* @__PURE__ */ import_react3.default.createElement(
287
+ "div",
288
+ {
289
+ onMouseEnter: handleMouseEnter,
290
+ onMouseLeave: handleMouseLeave,
291
+ style: {
292
+ width,
293
+ height,
294
+ display: "flex",
295
+ alignItems: "center",
296
+ justifyContent: "center",
297
+ gap: 6
298
+ }
299
+ },
300
+ /* @__PURE__ */ import_react3.default.createElement(
301
+ "div",
302
+ {
303
+ "data-label-id": props.labelId,
304
+ style: {
305
+ fontSize: 12,
306
+ color: hoverActivated ? baseActivatedColor : baseColor,
307
+ textAlign: "center",
308
+ whiteSpace: "nowrap",
309
+ backgroundColor: "var(--g-editor-background)",
310
+ lineHeight: "20px"
311
+ }
312
+ },
313
+ node.getService(import_fixed_layout_editor.FlowRendererRegistry).getText(import_fixed_layout_editor.FlowTextKey.CATCH_TEXT)
314
+ ),
315
+ renderCollapse()
316
+ );
317
+ }
318
+ var try_catch_collapse_default = TryCatchCollapse;
319
+
320
+ // src/components/dragging-adder/index.tsx
321
+ var import_react4 = __toESM(require("react"));
322
+ var import_fixed_layout_editor2 = require("@flowgram.ai/fixed-layout-editor");
323
+
324
+ // src/components/dragging-adder/styles.tsx
325
+ var import_styled_components = __toESM(require("styled-components"));
326
+ var UIDragNodeContainer = import_styled_components.default.div`
327
+ width: 16px;
328
+ height: 16px;
329
+ border-radius: 100px;
330
+ background-color: white;
331
+ border: 1px dashed #b8bcc1;
332
+ `;
333
+
334
+ // src/components/dragging-adder/index.tsx
335
+ function DraggingAdder(props) {
336
+ const playground = (0, import_fixed_layout_editor2.usePlayground)();
337
+ const layer = playground.getLayer(import_fixed_layout_editor2.FlowDragLayer);
338
+ if (!layer) return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null);
339
+ if (layer.options.canDrop && !layer.options.canDrop({
340
+ dragNodes: layer.dragEntities || [],
341
+ dropNode: props.from,
342
+ isBranch: false
343
+ })) {
344
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null);
345
+ }
346
+ return /* @__PURE__ */ import_react4.default.createElement(UIDragNodeContainer, null);
347
+ }
348
+
349
+ // src/components/drag-node/index.tsx
350
+ var import_react5 = __toESM(require("react"));
351
+
352
+ // src/components/drag-node/styles.tsx
353
+ var import_styled_components2 = __toESM(require("styled-components"));
354
+
355
+ // src/components/constants.tsx
356
+ var primary = "hsl(252 62% 54.9%)";
357
+ var primaryOpacity09 = "hsl(252deg 62% 55% / 9%)";
358
+
359
+ // src/components/drag-node/styles.tsx
360
+ var UIDragNodeContainer2 = import_styled_components2.default.div`
361
+ position: relative;
362
+ height: 32px;
363
+ border-radius: 5px;
364
+ display: flex;
365
+ align-items: center;
366
+ cursor: pointer;
367
+ font-size: 19px;
368
+ border: 1px solid ${primary};
369
+ padding: 0 15px;
370
+ &:hover: {
371
+ background-color: ${primaryOpacity09};
372
+ color: ${primary};
373
+ }
374
+ `;
375
+ var UIDragCounts = import_styled_components2.default.div`
376
+ position: absolute;
377
+ top: -8px;
378
+ right: -8px;
379
+ text-align: center;
380
+ line-height: 16px;
381
+ width: 16px;
382
+ height: 16px;
383
+ border-radius: 8px;
384
+ font-size: 12px;
385
+ color: #fff;
386
+ background-color: ${primary};
387
+ `;
388
+
389
+ // src/components/drag-node/index.tsx
390
+ function DragNode(props) {
391
+ const { dragStart, dragNodes } = props;
392
+ const dragLength = (dragNodes || []).map(
393
+ (_node) => _node.allCollapsedChildren.length ? _node.allCollapsedChildren.filter((_n) => !_n.hidden).length : 1
394
+ ).reduce((acm, curr) => acm + curr, 0);
395
+ return /* @__PURE__ */ import_react5.default.createElement(UIDragNodeContainer2, null, dragStart?.id, dragLength > 1 && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(UIDragCounts, null, dragLength), /* @__PURE__ */ import_react5.default.createElement(
396
+ UIDragNodeContainer2,
397
+ {
398
+ style: {
399
+ position: "absolute",
400
+ top: 5,
401
+ right: -5,
402
+ left: 5,
403
+ bottom: -5,
404
+ opacity: 0.5
405
+ }
406
+ }
407
+ )));
408
+ }
409
+
410
+ // src/components/drag-highlight-adder/index.tsx
411
+ var import_react6 = __toESM(require("react"));
412
+ var import_lodash = require("lodash");
413
+ var import_fixed_layout_editor3 = require("@flowgram.ai/fixed-layout-editor");
414
+
415
+ // src/components/drag-highlight-adder/styles.tsx
416
+ var import_styled_components3 = __toESM(require("styled-components"));
417
+ var UILineContainer = import_styled_components3.default.div`
418
+ display: flex;
419
+ align-items: center;
420
+ `;
421
+ var UILine = (width, height) => import_styled_components3.default.div`
422
+ width: ${width}px;
423
+ height: ${height}px;
424
+ background: #3370ff;
425
+ `;
426
+
427
+ // src/components/drag-highlight-adder/index.tsx
428
+ var getMinSize = (preWidth, nextWidth) => {
429
+ if (!preWidth || preWidth < 0) {
430
+ return 0;
431
+ }
432
+ if (!nextWidth || nextWidth < 0) {
433
+ return preWidth;
434
+ }
435
+ return (0, import_lodash.min)([preWidth, nextWidth]) || 0;
436
+ };
437
+ function DragHighlightAdder({ node }) {
438
+ const transformBounds = node.getData(import_fixed_layout_editor3.FlowNodeTransformData)?.bounds;
439
+ const { isVertical } = node;
440
+ if (isVertical) {
441
+ const preWidth = (transformBounds?.width || 0) - 16;
442
+ const nextNodeBounds2 = node?.next?.getData(import_fixed_layout_editor3.FlowNodeTransformData)?.bounds?.width;
443
+ const nextWidth = (nextNodeBounds2 || 0) - 16;
444
+ const LineDom2 = UILine(getMinSize(preWidth, nextWidth), 2);
445
+ return /* @__PURE__ */ import_react6.default.createElement(UILineContainer, null, /* @__PURE__ */ import_react6.default.createElement(Ellipse, null), /* @__PURE__ */ import_react6.default.createElement(LineDom2, null), /* @__PURE__ */ import_react6.default.createElement(Ellipse, null));
446
+ }
447
+ const preHeight = (transformBounds?.height || 0) - 16;
448
+ const nextNodeBounds = node?.next?.getData(import_fixed_layout_editor3.FlowNodeTransformData)?.bounds?.height;
449
+ const nextHeight = (nextNodeBounds || 0) - 16;
450
+ const LineDom = UILine(2, getMinSize(preHeight, nextHeight));
451
+ return /* @__PURE__ */ import_react6.default.createElement(UILineContainer, { style: { flexDirection: "column" } }, /* @__PURE__ */ import_react6.default.createElement(Ellipse, null), /* @__PURE__ */ import_react6.default.createElement(LineDom, null), /* @__PURE__ */ import_react6.default.createElement(Ellipse, null));
452
+ }
453
+
454
+ // src/components/collapse/index.tsx
455
+ var import_react7 = __toESM(require("react"));
456
+ var import_fixed_layout_editor4 = require("@flowgram.ai/fixed-layout-editor");
457
+
458
+ // src/components/collapse/styles.tsx
459
+ var import_styled_components4 = __toESM(require("styled-components"));
460
+ var Container = import_styled_components4.default.div`
461
+ width: 16px;
462
+ height: 16px;
463
+ font-size: 10px;
464
+ border-radius: 9px;
465
+ display: flex;
466
+ color: #fff;
467
+ cursor: pointer;
468
+ justify-content: center;
469
+ align-items: center;
470
+ background: ${(props) => props.hoverActivated ? "#82A7FC" : "#BBBFC4"};
471
+ transform: ${(props) => !props.isVertical && props.isCollapse ? "rotate(-90deg)" : ""};
472
+ `;
473
+
474
+ // src/components/collapse/index.tsx
475
+ function Collapse(props) {
476
+ const { collapseNode, activateNode, hoverActivated } = props;
477
+ const activateData = activateNode?.getData(import_fixed_layout_editor4.FlowNodeRenderData);
478
+ const transform = collapseNode.getData(import_fixed_layout_editor4.FlowNodeTransformData);
479
+ if (!transform) {
480
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null);
481
+ }
482
+ const scrollToActivateNode = () => {
483
+ setTimeout(() => {
484
+ import_fixed_layout_editor4.Playground.getLatest()?.scrollToView({
485
+ position: activateNode?.getData(import_fixed_layout_editor4.FlowNodeTransformData)?.outputPoint,
486
+ scrollToCenter: true
487
+ });
488
+ }, 100);
489
+ };
490
+ const collapseBlock = () => {
491
+ transform.collapsed = true;
492
+ activateData?.toggleMouseLeave();
493
+ scrollToActivateNode();
494
+ };
495
+ const openBlock = () => {
496
+ transform.collapsed = false;
497
+ scrollToActivateNode();
498
+ };
499
+ if (transform.collapsed) {
500
+ const childCount = collapseNode.allCollapsedChildren.filter(
501
+ (child) => !child.hidden && child !== activateNode
502
+ ).length;
503
+ return /* @__PURE__ */ import_react7.default.createElement(Container, { onClick: openBlock, hoverActivated, "aria-hidden": "true" }, childCount);
504
+ }
505
+ const circleColor = "var(--semi-color-white)";
506
+ const color = hoverActivated ? "#82A7FC" : "#BBBFC4";
507
+ return /* @__PURE__ */ import_react7.default.createElement(
508
+ Container,
509
+ {
510
+ onClick: collapseBlock,
511
+ hoverActivated,
512
+ isVertical: activateNode?.isVertical,
513
+ isCollapse: true,
514
+ "aria-hidden": "true"
515
+ },
516
+ /* @__PURE__ */ import_react7.default.createElement(Arrow, { color, circleColor })
517
+ );
518
+ }
519
+ var collapse_default = Collapse;
520
+
521
+ // src/components/branch-adder/index.tsx
522
+ var import_react8 = __toESM(require("react"));
523
+ var import_nanoid = require("nanoid");
524
+ var import_fixed_layout_editor5 = require("@flowgram.ai/fixed-layout-editor");
525
+ var import_semi_icons2 = require("@douyinfe/semi-icons");
526
+
527
+ // src/components/branch-adder/styles.tsx
528
+ var import_styled_components5 = __toESM(require("styled-components"));
529
+ var Container2 = import_styled_components5.default.div`
530
+ width: 28px;
531
+ height: 18px;
532
+ background: ${(props) => props.activated ? "#82A7FC" : "rgb(187, 191, 196)"};
533
+ display: flex;
534
+ border-radius: 9px;
535
+ justify-content: space-evenly;
536
+ align-items: center;
537
+ color: #fff;
538
+ font-size: 10px;
539
+ font-weight: bold;
540
+ transform: ${(props) => props.isVertical ? "" : "rotate(90deg)"};
541
+ div {
542
+ display: flex;
543
+ justify-content: center;
544
+ align-items: center;
545
+ svg {
546
+ width: 12px;
547
+ height: 12px;
548
+ }
549
+ }
550
+ `;
551
+
552
+ // src/components/branch-adder/index.tsx
553
+ function BranchAdder(props) {
554
+ const { activated, node } = props;
555
+ const nodeData = node.firstChild?.getData(import_fixed_layout_editor5.FlowNodeRenderData);
556
+ const playground = (0, import_fixed_layout_editor5.usePlayground)();
557
+ const flowOperationService = (0, import_fixed_layout_editor5.useService)(import_fixed_layout_editor5.FlowOperationService);
558
+ const { isVertical } = node;
559
+ function addBranch() {
560
+ const block = flowOperationService.addBlock(node, { id: (0, import_nanoid.nanoid)(5) });
561
+ setTimeout(() => {
562
+ playground.scrollToView({
563
+ bounds: block.getData(import_fixed_layout_editor5.FlowNodeTransformData).bounds,
564
+ scrollToCenter: true
565
+ });
566
+ }, 10);
567
+ }
568
+ if (playground.config.readonlyOrDisabled) return null;
569
+ return /* @__PURE__ */ import_react8.default.createElement(
570
+ Container2,
571
+ {
572
+ isVertical,
573
+ activated: activated || nodeData?.hovered,
574
+ onMouseEnter: () => nodeData?.toggleMouseEnter(),
575
+ onMouseLeave: () => nodeData?.toggleMouseLeave()
576
+ },
577
+ /* @__PURE__ */ import_react8.default.createElement(
578
+ "div",
579
+ {
580
+ onClick: () => {
581
+ addBranch();
582
+ },
583
+ "aria-hidden": "true",
584
+ style: { flexGrow: 1, textAlign: "center", cursor: "pointer" }
585
+ },
586
+ /* @__PURE__ */ import_react8.default.createElement(import_semi_icons2.IconPlus, null)
587
+ )
588
+ );
589
+ }
590
+
591
+ // src/components/adder/index.tsx
592
+ var import_react11 = __toESM(require("react"));
593
+ var import_nanoid3 = require("nanoid");
594
+ var import_fixed_layout_editor6 = require("@flowgram.ai/fixed-layout-editor");
595
+ var import_semi_ui = require("@douyinfe/semi-ui");
596
+
597
+ // src/components/nodes/index.tsx
598
+ var import_react10 = __toESM(require("react"));
599
+
600
+ // src/components/metadata.tsx
601
+ var import_react9 = __toESM(require("react"));
602
+ var import_nanoid2 = require("nanoid");
603
+ var metadata = {
604
+ nodes: [
605
+ {
606
+ type: "start",
607
+ label: "Start",
608
+ icon: /* @__PURE__ */ import_react9.default.createElement(IconStyleBorder, null)
609
+ },
610
+ {
611
+ type: "dynamicSplit",
612
+ label: "Split Branch",
613
+ icon: /* @__PURE__ */ import_react9.default.createElement(IconParkRightBranch, null),
614
+ blocks() {
615
+ return [
616
+ {
617
+ id: (0, import_nanoid2.nanoid)(5)
618
+ },
619
+ {
620
+ id: (0, import_nanoid2.nanoid)(5)
621
+ }
622
+ ];
623
+ }
624
+ },
625
+ {
626
+ type: "end",
627
+ label: "Branch End",
628
+ icon: /* @__PURE__ */ import_react9.default.createElement(FeAlignCenter, null),
629
+ branchEnd: true
630
+ },
631
+ {
632
+ type: "loop",
633
+ schemaType: "loop",
634
+ label: "Loop",
635
+ icon: /* @__PURE__ */ import_react9.default.createElement(BiBootstrapReboot, null)
636
+ },
637
+ {
638
+ type: "tryCatch",
639
+ schemaType: "tryCatch",
640
+ label: "TryCatch",
641
+ icon: /* @__PURE__ */ import_react9.default.createElement(IconParkRightBranch, null),
642
+ blocks() {
643
+ return [
644
+ {
645
+ id: `try_${(0, import_nanoid2.nanoid)(5)}`
646
+ // try branch
647
+ },
648
+ {
649
+ id: `catch_${(0, import_nanoid2.nanoid)(5)}`
650
+ // catch branch 1
651
+ },
652
+ {
653
+ id: `catch_${(0, import_nanoid2.nanoid)(5)}`
654
+ // catch branch 2
655
+ }
656
+ ];
657
+ }
658
+ },
659
+ {
660
+ type: "noop",
661
+ label: "Noop Node",
662
+ icon: /* @__PURE__ */ import_react9.default.createElement(BiCloud, null)
663
+ },
664
+ {
665
+ type: "end",
666
+ label: "End",
667
+ icon: /* @__PURE__ */ import_react9.default.createElement(PhCircleBold, null)
668
+ }
669
+ ],
670
+ find: function find(type) {
671
+ return metadata.nodes.find((m) => m.type === type);
672
+ }
673
+ };
674
+ var metadata_default = metadata;
675
+
676
+ // src/components/nodes/styles.tsx
677
+ var import_styled_components6 = __toESM(require("styled-components"));
678
+ var NodeWrap = import_styled_components6.default.div`
679
+ width: 100%;
680
+ height: 32px;
681
+ border-radius: 5px;
682
+ display: flex;
683
+ align-items: center;
684
+ cursor: pointer;
685
+ font-size: 19px;
686
+ padding: 0 15px;
687
+ &:hover: {
688
+ background-color: ${primaryOpacity09};
689
+ color: ${primary};
690
+ },
691
+ `;
692
+ var NodeLabel = import_styled_components6.default.div`
693
+ font-size: 12px;
694
+ margin-left: 10px;
695
+ `;
696
+ var NodesWrap = import_styled_components6.default.div`
697
+ max-height: 500px;
698
+ overflow: auto;
699
+ &::-webkit-scrollbar {
700
+ display: none;
701
+ }
702
+ `;
703
+
704
+ // src/components/nodes/index.tsx
705
+ function Node(props) {
706
+ return /* @__PURE__ */ import_react10.default.createElement(NodeWrap, { onClick: props.onClick }, /* @__PURE__ */ import_react10.default.createElement("div", { style: { fontSize: 14 } }, props.icon), /* @__PURE__ */ import_react10.default.createElement(NodeLabel, null, props.label));
707
+ }
708
+ var addings = metadata_default.nodes.filter((node) => node.type !== "start");
709
+ function Nodes(props) {
710
+ return /* @__PURE__ */ import_react10.default.createElement(NodesWrap, { style: { width: 80 * 2 + 20 } }, addings.map((n, i) => (
711
+ // eslint-disable-next-line react/no-array-index-key
712
+ /* @__PURE__ */ import_react10.default.createElement(Node, { key: i, icon: n.icon, label: n.label, onClick: () => props.onSelect?.(n) })
713
+ )));
714
+ }
715
+
716
+ // src/components/adder/styles.tsx
717
+ var import_styled_components7 = __toESM(require("styled-components"));
718
+ var import_semi_icons3 = require("@douyinfe/semi-icons");
719
+ var AdderWrap = import_styled_components7.default.div`
720
+ width: ${(props) => props.hovered ? 15 : 6}px;
721
+ height: ${(props) => props.hovered ? 15 : 6}px;
722
+ background-color: rgb(143, 149, 158);
723
+ color: #fff;
724
+ border-radius: 50%;
725
+ display: flex;
726
+ align-items: center;
727
+ justify-content: center;
728
+ cursor: pointer;
729
+ `;
730
+ var IconPlus2 = (0, import_styled_components7.default)(import_semi_icons3.IconPlusCircle)`
731
+ color: #3370ff;
732
+ background-color: #fff;
733
+ border-radius: 15px;
734
+ `;
735
+
736
+ // src/components/adder/index.tsx
737
+ function Adder(props) {
738
+ const { from } = props;
739
+ const [visible, setVisible] = (0, import_react11.useState)(false);
740
+ const playground = (0, import_fixed_layout_editor6.usePlayground)();
741
+ const flowOperationService = (0, import_fixed_layout_editor6.useService)(import_fixed_layout_editor6.FlowOperationService);
742
+ const add = (addProps) => {
743
+ const block = flowOperationService.addFromNode(from, {
744
+ id: addProps.type + (0, import_nanoid3.nanoid)(5),
745
+ type: addProps.type,
746
+ blocks: addProps.blocks ? addProps.blocks() : void 0
747
+ });
748
+ setTimeout(() => {
749
+ playground.scrollToView({
750
+ bounds: block.getData(import_fixed_layout_editor6.FlowNodeTransformData).bounds,
751
+ scrollToCenter: true
752
+ });
753
+ }, 10);
754
+ };
755
+ if (playground.config.readonlyOrDisabled) return null;
756
+ return /* @__PURE__ */ import_react11.default.createElement(
757
+ import_semi_ui.Popover,
758
+ {
759
+ visible,
760
+ onVisibleChange: setVisible,
761
+ content: /* @__PURE__ */ import_react11.default.createElement(Nodes, { onSelect: add }),
762
+ placement: "right",
763
+ trigger: "click",
764
+ overlayStyle: {
765
+ padding: 0
766
+ }
767
+ },
768
+ /* @__PURE__ */ import_react11.default.createElement(
769
+ AdderWrap,
770
+ {
771
+ hovered: props.hoverActivated,
772
+ onMouseDown: (e) => e.stopPropagation(),
773
+ onClick: () => {
774
+ setVisible(true);
775
+ }
776
+ },
777
+ props.hoverActivated ? /* @__PURE__ */ import_react11.default.createElement(IconPlus2, null) : null
778
+ )
779
+ );
780
+ }
781
+
782
+ // src/components/index.tsx
783
+ var defaultFixedSemiMaterials = {
784
+ [import_fixed_layout_editor7.FlowRendererKey.ADDER]: Adder,
785
+ [import_fixed_layout_editor7.FlowRendererKey.COLLAPSE]: collapse_default,
786
+ [import_fixed_layout_editor7.FlowRendererKey.TRY_CATCH_COLLAPSE]: try_catch_collapse_default,
787
+ [import_fixed_layout_editor7.FlowRendererKey.BRANCH_ADDER]: BranchAdder,
788
+ [import_fixed_layout_editor7.FlowRendererKey.DRAG_NODE]: DragNode,
789
+ [import_fixed_layout_editor7.FlowRendererKey.DRAGGABLE_ADDER]: DraggingAdder,
790
+ [import_fixed_layout_editor7.FlowRendererKey.DRAG_HIGHLIGHT_ADDER]: DragHighlightAdder,
791
+ [import_fixed_layout_editor7.FlowRendererKey.DRAG_BRANCH_HIGHLIGHT_ADDER]: Ellipse
792
+ };
793
+
794
+ // src/components/tools.tsx
795
+ var import_react12 = __toESM(require("react"));
796
+ var import_fixed_layout_editor8 = require("@flowgram.ai/fixed-layout-editor");
797
+ var import_semi_ui2 = require("@douyinfe/semi-ui");
798
+ var import_semi_icons4 = require("@douyinfe/semi-icons");
799
+ var PlaygroundTools = ({ layoutText }) => {
800
+ const tools = (0, import_fixed_layout_editor8.usePlaygroundTools)();
801
+ const { zoom } = tools;
802
+ return /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Space, null, /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Checkbox, { onChange: () => tools.changeLayout(), checked: !tools.isVertical }, layoutText || "isHorizontal"), /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Tooltip, { content: "fit view" }, /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.IconButton, { icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons4.IconGridView, null), onClick: () => tools.fitView() })), /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Tooltip, { content: "zoom out" }, /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.IconButton, { icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons4.IconShrink, null), onClick: () => tools.zoomout() })), /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Tooltip, { content: "zoom in" }, /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.IconButton, { icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons4.IconExpand, null), onClick: () => tools.zoomin() })), /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Tooltip, { content: "undo" }, /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.IconButton, { icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons4.IconUndo, null), disabled: tools.canUndo, onClick: () => tools.undo() })), /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.Tooltip, { content: "redo" }, /* @__PURE__ */ import_react12.default.createElement(import_semi_ui2.IconButton, { icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons4.IconRedo, null), disabled: tools.canRedo, onClick: () => tools.redo() })), /* @__PURE__ */ import_react12.default.createElement("span", null, Math.floor(zoom * 100), "%"));
803
+ };
804
+ // Annotate the CommonJS export names for ESM import in node:
805
+ 0 && (module.exports = {
806
+ PlaygroundTools,
807
+ defaultFixedSemiMaterials
808
+ });
809
+ //# sourceMappingURL=index.js.map