@flowgram.ai/form-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/bin/index.ts +99 -0
- package/bin/materials.ts +156 -0
- package/bin/project.ts +91 -0
- package/dist/esm/index.js +3303 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +495 -0
- package/dist/index.d.ts +495 -0
- package/dist/index.js +3299 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
- package/src/components/batch-outputs/config.json +12 -0
- package/src/components/batch-outputs/index.tsx +61 -0
- package/src/components/batch-outputs/styles.tsx +19 -0
- package/src/components/batch-outputs/types.ts +22 -0
- package/src/components/batch-outputs/use-list.ts +86 -0
- package/src/components/batch-variable-selector/config.json +5 -0
- package/src/components/batch-variable-selector/index.tsx +24 -0
- package/src/components/code-editor/config.json +9 -0
- package/src/components/code-editor/index.tsx +74 -0
- package/src/components/code-editor/language-features.ts +24 -0
- package/src/components/code-editor/theme/dark.ts +119 -0
- package/src/components/code-editor/theme/index.ts +12 -0
- package/src/components/code-editor/theme/light.ts +119 -0
- package/src/components/code-editor/utils.ts +20 -0
- package/src/components/condition-row/config.json +5 -0
- package/src/components/condition-row/constants.ts +128 -0
- package/src/components/condition-row/hooks/useOp.tsx +50 -0
- package/src/components/condition-row/hooks/useRule.ts +31 -0
- package/src/components/condition-row/index.tsx +81 -0
- package/src/components/condition-row/styles.tsx +30 -0
- package/src/components/condition-row/types.ts +42 -0
- package/src/components/constant-input/config.json +6 -0
- package/src/components/constant-input/index.tsx +86 -0
- package/src/components/constant-input/types.ts +23 -0
- package/src/components/dynamic-value-input/config.json +5 -0
- package/src/components/dynamic-value-input/index.tsx +92 -0
- package/src/components/dynamic-value-input/styles.tsx +26 -0
- package/src/components/index.ts +18 -0
- package/src/components/json-editor-with-variables/config.json +13 -0
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +173 -0
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +83 -0
- package/src/components/json-editor-with-variables/index.tsx +19 -0
- package/src/components/json-editor-with-variables/styles.tsx +44 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +27 -0
- package/src/components/json-schema-editor/config.json +13 -0
- package/src/components/json-schema-editor/default-value.tsx +135 -0
- package/src/components/json-schema-editor/hooks.tsx +166 -0
- package/src/components/json-schema-editor/index.tsx +267 -0
- package/src/components/json-schema-editor/styles.tsx +240 -0
- package/src/components/json-schema-editor/types.ts +26 -0
- package/src/components/json-schema-editor/utils.ts +29 -0
- package/src/components/prompt-editor/config.json +9 -0
- package/src/components/prompt-editor/extensions/jinja.tsx +58 -0
- package/src/components/prompt-editor/extensions/language-support.tsx +19 -0
- package/src/components/prompt-editor/extensions/markdown.tsx +75 -0
- package/src/components/prompt-editor/index.tsx +68 -0
- package/src/components/prompt-editor/styles.tsx +18 -0
- package/src/components/prompt-editor/types.tsx +18 -0
- package/src/components/prompt-editor-with-inputs/config.json +13 -0
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +82 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +22 -0
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +100 -0
- package/src/components/prompt-editor-with-variables/config.json +13 -0
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +179 -0
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +83 -0
- package/src/components/prompt-editor-with-variables/index.tsx +19 -0
- package/src/components/prompt-editor-with-variables/styles.tsx +44 -0
- package/src/components/type-selector/config.json +5 -0
- package/src/components/type-selector/constants.tsx +364 -0
- package/src/components/type-selector/index.tsx +62 -0
- package/src/components/variable-selector/config.json +5 -0
- package/src/components/variable-selector/index.tsx +116 -0
- package/src/components/variable-selector/styles.tsx +59 -0
- package/src/components/variable-selector/use-variable-tree.tsx +103 -0
- package/src/effects/auto-rename-ref/config.json +5 -0
- package/src/effects/auto-rename-ref/index.ts +109 -0
- package/src/effects/index.ts +10 -0
- package/src/effects/provide-batch-input/config.json +5 -0
- package/src/effects/provide-batch-input/index.ts +43 -0
- package/src/effects/provide-batch-outputs/config.json +5 -0
- package/src/effects/provide-batch-outputs/index.ts +38 -0
- package/src/effects/provide-json-schema-outputs/config.json +8 -0
- package/src/effects/provide-json-schema-outputs/index.ts +28 -0
- package/src/effects/sync-variable-title/config.json +5 -0
- package/src/effects/sync-variable-title/index.ts +28 -0
- package/src/form-plugins/batch-outputs-plugin/config.json +7 -0
- package/src/form-plugins/batch-outputs-plugin/index.ts +104 -0
- package/src/form-plugins/index.ts +6 -0
- package/src/index.ts +10 -0
- package/src/typings/flow-value/config.json +5 -0
- package/src/typings/flow-value/index.ts +32 -0
- package/src/typings/index.ts +7 -0
- package/src/typings/json-schema/config.json +5 -0
- package/src/typings/json-schema/index.ts +36 -0
- package/src/utils/format-legacy-refs/config.json +5 -0
- package/src/utils/format-legacy-refs/index.ts +158 -0
- package/src/utils/format-legacy-refs/readme.md +38 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/json-schema/config.json +5 -0
- package/src/utils/json-schema/index.ts +180 -0
|
@@ -0,0 +1,3303 @@
|
|
|
1
|
+
// src/components/variable-selector/index.tsx
|
|
2
|
+
import React3, { useMemo } from "react";
|
|
3
|
+
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
4
|
+
|
|
5
|
+
// src/components/variable-selector/use-variable-tree.tsx
|
|
6
|
+
import React2, { useCallback } from "react";
|
|
7
|
+
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
8
|
+
import { Icon as Icon2 } from "@douyinfe/semi-ui";
|
|
9
|
+
|
|
10
|
+
// src/components/type-selector/constants.tsx
|
|
11
|
+
import React from "react";
|
|
12
|
+
import Icon from "@douyinfe/semi-icons";
|
|
13
|
+
var VariableTypeIcons = {
|
|
14
|
+
custom: /* @__PURE__ */ React.createElement(
|
|
15
|
+
"svg",
|
|
16
|
+
{
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
fill: "none",
|
|
19
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
20
|
+
width: "1em",
|
|
21
|
+
height: "1em",
|
|
22
|
+
focusable: "false",
|
|
23
|
+
"aria-hidden": "true"
|
|
24
|
+
},
|
|
25
|
+
/* @__PURE__ */ React.createElement(
|
|
26
|
+
"path",
|
|
27
|
+
{
|
|
28
|
+
fillRule: "evenodd",
|
|
29
|
+
clipRule: "evenodd",
|
|
30
|
+
d: "M5.1 18L4.5032 20.1702C4.24999 21.0909 4.94281 22 5.89773 22C6.54881 22 7.11964 21.565 7.29227 20.9372L8.1 18H12.1L11.5032 20.1702C11.25 21.0909 11.9428 22 12.8977 22C13.5488 22 14.1196 21.565 14.2923 20.9372L15.1 18H19.5C20.3284 18 21 17.3284 21 16.5C21 15.6716 20.3284 15 19.5 15H15.925L17.575 9H20.5C21.3284 9 22 8.32843 22 7.5C22 6.67157 21.3284 6 20.5 6H18.4L18.9968 3.8298C19.25 2.90906 18.5572 2 17.6023 2C16.9512 2 16.3804 2.43504 16.2077 3.06281L15.4 6H11.4L11.9968 3.8298C12.25 2.90906 11.5572 2 10.6023 2C9.95119 2 9.38036 2.43504 9.20773 3.06281L8.4 6H4.5C3.67157 6 3 6.67157 3 7.5C3 8.32843 3.67157 9 4.5 9H7.575L5.925 15H3.5C2.67157 15 2 15.6716 2 16.5C2 17.3284 2.67157 18 3.5 18H5.1ZM8.925 15L10.575 9H14.575L12.925 15H8.925Z",
|
|
31
|
+
fill: "currentColor"
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
),
|
|
35
|
+
object: /* @__PURE__ */ React.createElement(
|
|
36
|
+
"svg",
|
|
37
|
+
{
|
|
38
|
+
width: "1em",
|
|
39
|
+
height: "1em",
|
|
40
|
+
viewBox: "0 0 16 16",
|
|
41
|
+
fill: "none",
|
|
42
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
43
|
+
},
|
|
44
|
+
/* @__PURE__ */ React.createElement(
|
|
45
|
+
"path",
|
|
46
|
+
{
|
|
47
|
+
d: "M5.33893 1.5835C5.66613 1.5835 5.93137 1.88142 5.93137 2.20862C5.93137 2.53582 5.66613 2.76838 5.33893 2.76838H4.9099C4.34717 2.76838 4.08062 3.07557 4.08062 3.71921V6.58633C4.08062 7.30996 3.80723 7.84734 3.26798 8.19105C3.11426 8.28902 3.10884 8.55273 3.26068 8.65359C3.80476 9.01503 4.08062 9.53994 4.08062 10.2434V13.1251C4.08062 13.7395 4.34717 14.0613 4.9099 14.0613H5.33893C5.66613 14.0613 5.93137 14.3435 5.93137 14.6707C5.93137 14.9979 5.66613 15.2462 5.33893 15.2462H4.64335C3.99177 15.2462 3.48828 15.0268 3.13287 14.6172C2.80708 14.2369 2.64419 13.7103 2.64419 13.0666V10.3165C2.64419 9.8923 2.55534 9.58511 2.37764 9.39494C2.26816 9.27135 1.80618 9.17938 1.38154 9.11602C1.02726 9.06315 0.759057 8.76744 0.765747 8.4093C0.772379 8.0543 1.03439 7.7566 1.38545 7.70346C1.80778 7.63952 2.26906 7.54968 2.37764 7.43477C2.55534 7.22997 2.64419 6.92278 2.64419 6.51319V3.77772C2.64419 3.11945 2.80708 2.59284 3.13287 2.21251C3.48828 1.78829 3.99177 1.5835 4.64335 1.5835H5.33893Z",
|
|
48
|
+
fill: "currentColor"
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ React.createElement(
|
|
52
|
+
"path",
|
|
53
|
+
{
|
|
54
|
+
d: "M10.962 15.2463C10.6348 15.2463 10.3696 14.9483 10.3696 14.6211C10.3696 14.2939 10.6348 14.0614 10.962 14.0614H11.391C11.9538 14.0614 12.2203 13.7542 12.2203 13.1105V10.2434C12.2203 9.51979 12.4937 8.98241 13.033 8.6387C13.1867 8.54073 13.1921 8.27703 13.0403 8.17616C12.4962 7.81472 12.2203 7.28982 12.2203 6.58638V3.70463C12.2203 3.09024 11.9538 2.76842 11.391 2.76842L10.962 2.76842C10.6348 2.76842 10.3696 2.48627 10.3696 2.15907C10.3696 1.83188 10.6348 1.58354 10.962 1.58354L11.6576 1.58354C12.3092 1.58354 12.8127 1.80296 13.1681 2.21255C13.4939 2.59289 13.6568 3.1195 13.6568 3.76314V6.51324C13.6568 6.93745 13.7456 7.24464 13.9233 7.43481C14.03 7.5553 14.4328 7.64858 14.8186 7.71393C15.1718 7.77376 15.4401 8.06977 15.4334 8.42791C15.4268 8.78291 15.1646 9.08018 14.814 9.13633C14.4306 9.19774 14.0291 9.28303 13.9233 9.39499C13.7456 9.59978 13.6568 9.90697 13.6568 10.3166V13.052C13.6568 13.7103 13.4939 14.2369 13.1681 14.6172C12.8127 15.0415 12.3092 15.2463 11.6576 15.2463H10.962Z",
|
|
55
|
+
fill: "currentColor"
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
),
|
|
59
|
+
boolean: /* @__PURE__ */ React.createElement(
|
|
60
|
+
"svg",
|
|
61
|
+
{
|
|
62
|
+
width: "1em",
|
|
63
|
+
height: "1em",
|
|
64
|
+
viewBox: "0 0 16 16",
|
|
65
|
+
fill: "none",
|
|
66
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
67
|
+
},
|
|
68
|
+
/* @__PURE__ */ React.createElement(
|
|
69
|
+
"path",
|
|
70
|
+
{
|
|
71
|
+
fillRule: "evenodd",
|
|
72
|
+
clipRule: "evenodd",
|
|
73
|
+
d: "M10.668 4.66683H5.33463C3.49369 4.66683 2.0013 6.15921 2.0013 8.00016C2.0013 9.84111 3.49369 11.3335 5.33463 11.3335H10.668C12.5089 11.3335 14.0013 9.84111 14.0013 8.00016C14.0013 6.15921 12.5089 4.66683 10.668 4.66683ZM5.33463 3.3335C2.75731 3.3335 0.667969 5.42283 0.667969 8.00016C0.667969 10.5775 2.75731 12.6668 5.33463 12.6668H10.668C13.2453 12.6668 15.3346 10.5775 15.3346 8.00016C15.3346 5.42283 13.2453 3.3335 10.668 3.3335H5.33463Z",
|
|
74
|
+
fill: "currentColor"
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ React.createElement(
|
|
78
|
+
"path",
|
|
79
|
+
{
|
|
80
|
+
fillRule: "evenodd",
|
|
81
|
+
clipRule: "evenodd",
|
|
82
|
+
d: "M8.66797 8.00016C8.66797 6.89559 9.5634 6.00016 10.668 6.00016C11.7725 6.00016 12.668 6.89559 12.668 8.00016C12.668 9.10473 11.7725 10.0002 10.668 10.0002C9.5634 10.0002 8.66797 9.10473 8.66797 8.00016ZM10.668 7.3335C10.2998 7.3335 10.0013 7.63197 10.0013 8.00016C10.0013 8.36835 10.2998 8.66683 10.668 8.66683C11.0362 8.66683 11.3346 8.36835 11.3346 8.00016C11.3346 7.63197 11.0362 7.3335 10.668 7.3335Z",
|
|
83
|
+
fill: "currentColor"
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
),
|
|
87
|
+
string: /* @__PURE__ */ React.createElement(
|
|
88
|
+
"svg",
|
|
89
|
+
{
|
|
90
|
+
width: "1em",
|
|
91
|
+
height: "1em",
|
|
92
|
+
viewBox: "0 0 16 16",
|
|
93
|
+
fill: "none",
|
|
94
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
95
|
+
},
|
|
96
|
+
/* @__PURE__ */ React.createElement(
|
|
97
|
+
"path",
|
|
98
|
+
{
|
|
99
|
+
d: "M9.3342 3.33321C8.96601 3.33321 8.66753 3.63169 8.66753 3.99988C8.66753 4.36807 8.96601 4.66655 9.3342 4.66655H14.6675C15.0357 4.66655 15.3342 4.36807 15.3342 3.99988C15.3342 3.63169 15.0357 3.33321 14.6675 3.33321H9.3342Z",
|
|
100
|
+
fill: "currentColor"
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ React.createElement(
|
|
104
|
+
"path",
|
|
105
|
+
{
|
|
106
|
+
d: "M10.0009 7.99988C10.0009 7.63169 10.2993 7.33321 10.6675 7.33321H14.6675C15.0357 7.33321 15.3342 7.63169 15.3342 7.99988C15.3342 8.36807 15.0357 8.66655 14.6675 8.66655H10.6675C10.2993 8.66655 10.0009 8.36807 10.0009 7.99988Z",
|
|
107
|
+
fill: "currentColor"
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ React.createElement(
|
|
111
|
+
"path",
|
|
112
|
+
{
|
|
113
|
+
d: "M12.0009 11.3332C11.6327 11.3332 11.3342 11.6317 11.3342 11.9999C11.3342 12.3681 11.6327 12.6665 12.0009 12.6665H14.6675C15.0357 12.6665 15.3342 12.3681 15.3342 11.9999C15.3342 11.6317 15.0357 11.3332 14.6675 11.3332H12.0009Z",
|
|
114
|
+
fill: "currentColor"
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ React.createElement(
|
|
118
|
+
"path",
|
|
119
|
+
{
|
|
120
|
+
d: "M9.86659 14.1482L8.23444 10.1844H3.18136C3.13868 10.1844 3.09685 10.1808 3.05616 10.1738L1.66589 14.1129C1.53049 14.4965 1.10971 14.6978 0.726058 14.5624C0.342408 14.427 0.141166 14.0062 0.276572 13.6225L4.37566 2.00848C4.71323 1.05202 6.05321 1.01763 6.4394 1.95552L11.2289 13.5872C11.3838 13.9634 11.2044 14.394 10.8282 14.5489C10.452 14.7038 10.0215 14.5244 9.86659 14.1482ZM5.44412 3.40791L3.57241 8.71109H7.62778L5.44412 3.40791Z",
|
|
121
|
+
fill: "currentColor"
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
),
|
|
125
|
+
integer: /* @__PURE__ */ React.createElement(
|
|
126
|
+
"svg",
|
|
127
|
+
{
|
|
128
|
+
width: "1em",
|
|
129
|
+
height: "1em",
|
|
130
|
+
viewBox: "0 0 16 16",
|
|
131
|
+
fill: "none",
|
|
132
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
133
|
+
},
|
|
134
|
+
/* @__PURE__ */ React.createElement(
|
|
135
|
+
"path",
|
|
136
|
+
{
|
|
137
|
+
d: "M15.132 11.4601C15.644 11.0121 15.9 10.3921 15.9 9.60007C15.9 8.60807 15.5 7.93607 14.7 7.58407C15.412 7.23207 15.768 6.62407 15.768 5.76007C15.768 5.05607 15.536 4.48007 15.072 4.03207C14.608 3.59207 14.012 3.37207 13.284 3.37207C12.588 3.37207 12.008 3.58007 11.544 3.99607C11.064 4.42007 10.808 4.98807 10.776 5.70007H12C12.064 4.88407 12.492 4.47607 13.284 4.47607C14.124 4.47607 14.544 4.91607 14.544 5.79607C14.544 6.66007 14.112 7.09207 13.248 7.09207H13.044V8.16007H13.248C14.2 8.16007 14.676 8.62807 14.676 9.56407C14.676 10.5081 14.212 10.9801 13.284 10.9801C12.9 10.9801 12.584 10.8761 12.336 10.6681C12.064 10.4441 11.916 10.1161 11.892 9.68407H10.668C10.692 10.4761 10.964 11.0841 11.484 11.5081C11.948 11.8921 12.548 12.0841 13.284 12.0841C14.036 12.0841 14.652 11.8761 15.132 11.4601Z",
|
|
138
|
+
fill: "currentColor"
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ React.createElement(
|
|
142
|
+
"path",
|
|
143
|
+
{
|
|
144
|
+
d: "M4.46875 12.0003V10.9083L7.75675 6.91228C8.06075 6.54428 8.21275 6.16428 8.21275 5.77228C8.21275 4.90828 7.79675 4.47628 6.96475 4.47628C6.60475 4.47628 6.31275 4.57628 6.08875 4.77628C5.83275 5.00828 5.70475 5.34828 5.70475 5.79628H4.48075C4.48075 5.07628 4.71275 4.49228 5.17675 4.04428C5.64075 3.60428 6.23675 3.38428 6.96475 3.38428C7.70075 3.38428 8.29675 3.60028 8.75275 4.03228C9.20875 4.47228 9.43675 5.05628 9.43675 5.78428C9.43675 6.13628 9.36875 6.45628 9.23275 6.74428C9.12075 6.97628 8.92075 7.27228 8.63275 7.63228L5.95675 10.9083H9.43675V12.0003H4.46875Z",
|
|
145
|
+
fill: "currentColor"
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ React.createElement(
|
|
149
|
+
"path",
|
|
150
|
+
{
|
|
151
|
+
d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
|
|
152
|
+
fill: "currentColor"
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
),
|
|
156
|
+
number: /* @__PURE__ */ React.createElement(
|
|
157
|
+
"svg",
|
|
158
|
+
{
|
|
159
|
+
width: "1em",
|
|
160
|
+
height: "1em",
|
|
161
|
+
viewBox: "0 0 16 16",
|
|
162
|
+
fill: "none",
|
|
163
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
164
|
+
},
|
|
165
|
+
/* @__PURE__ */ React.createElement(
|
|
166
|
+
"path",
|
|
167
|
+
{
|
|
168
|
+
d: "M3.44151 5.3068C3.44151 3.83404 4.71542 2.64014 6.18818 2.64014C7.66094 2.64014 8.93484 3.83404 8.93484 5.3068V10.6135C8.93484 12.0862 7.66094 13.2801 6.18818 13.2801C4.71542 13.2801 3.44151 12.0862 3.44151 10.6135V5.3068ZM7.60151 5.3068C7.60151 4.57042 6.92456 3.97347 6.18818 3.97347C5.4518 3.97347 4.77484 4.57042 4.77484 5.3068V10.6135C4.77484 11.3498 5.4518 11.9468 6.18818 11.9468C6.92456 11.9468 7.60151 11.3498 7.60151 10.6135V5.3068Z",
|
|
169
|
+
fill: "currentColor"
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
/* @__PURE__ */ React.createElement(
|
|
173
|
+
"path",
|
|
174
|
+
{
|
|
175
|
+
d: "M12.9882 2.64014C11.5154 2.64014 10.2415 3.83404 10.2415 5.3068V10.6135C10.2415 12.0862 11.5154 13.2801 12.9882 13.2801C14.4609 13.2801 15.7348 12.0862 15.7348 10.6135V5.3068C15.7348 3.83404 14.4609 2.64014 12.9882 2.64014ZM14.4015 10.6135C14.4015 11.3498 13.7246 11.9468 12.9882 11.9468C12.2518 11.9468 11.5748 11.3498 11.5748 10.6135V5.3068C11.5748 4.57042 12.2518 3.97347 12.9882 3.97347C13.7246 3.97347 14.4015 4.57042 14.4015 5.3068V10.6135Z",
|
|
176
|
+
fill: "currentColor"
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ React.createElement(
|
|
180
|
+
"path",
|
|
181
|
+
{
|
|
182
|
+
d: "M1.21484 13.2001C1.76713 13.2001 2.21484 12.7524 2.21484 12.2001C2.21484 11.6479 1.76713 11.2001 1.21484 11.2001C0.662559 11.2001 0.214844 11.6479 0.214844 12.2001C0.214844 12.7524 0.662559 13.2001 1.21484 13.2001Z",
|
|
183
|
+
fill: "currentColor"
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
),
|
|
187
|
+
array: /* @__PURE__ */ React.createElement(
|
|
188
|
+
"svg",
|
|
189
|
+
{
|
|
190
|
+
width: "1em",
|
|
191
|
+
height: "1em",
|
|
192
|
+
viewBox: "0 0 16 16",
|
|
193
|
+
fill: "none",
|
|
194
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
195
|
+
},
|
|
196
|
+
/* @__PURE__ */ React.createElement(
|
|
197
|
+
"path",
|
|
198
|
+
{
|
|
199
|
+
d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
|
|
200
|
+
fill: "currentColor"
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
/* @__PURE__ */ React.createElement(
|
|
204
|
+
"path",
|
|
205
|
+
{
|
|
206
|
+
d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
|
|
207
|
+
fill: "currentColor"
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
),
|
|
211
|
+
stream: /* @__PURE__ */ React.createElement(
|
|
212
|
+
"svg",
|
|
213
|
+
{
|
|
214
|
+
viewBox: "0 0 1024 1024",
|
|
215
|
+
version: "1.1",
|
|
216
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
217
|
+
width: "1em",
|
|
218
|
+
height: "1em"
|
|
219
|
+
},
|
|
220
|
+
/* @__PURE__ */ React.createElement(
|
|
221
|
+
"path",
|
|
222
|
+
{
|
|
223
|
+
d: "M879.674 544.51l-158.254-0.221c-8.534 2.287-17.305-2.776-19.588-11.307l-23.862-75.877-74.742 350.891c0 0-1.523 18.507-11.518 18.507s-26.9 0.281-26.9 0.281c-8.259 2.213-16.748-2.687-18.961-10.949l-92.741-457.648-70.305 330.634c-2.261 8.291-11.94 15.206-20.385 12.986l-24.876 0.339c-8.723 2.293-17.685-2.789-20.023-11.349L270.629 544.51 143.993 544.51c-8.831 0-15.993-7.159-15.993-15.993l0-31.986c0-8.831 7.162-15.993 15.993-15.993l157.429-0.516c9.565-0.304 17.685 0.788 20.023 9.351l24.386 76.092 68.642-358.907c0 0 3.4-10.894 14.397-10.894 10.994 0 34.107-0.448 34.107-0.448 8.262-2.213 16.751 2.687 18.965 10.949l91.912 454.126 67.948-326.182c2.213-8.262 8.707-15.161 16.965-12.948l27.316-0.333c8.531-2.287 17.301 2.776 19.588 11.31l46.665 148.4 127.337 0c8.835 0 15.993 7.162 15.993 15.993l0 31.986C895.667 537.352 888.508 544.51 879.674 544.51z",
|
|
224
|
+
fill: "currentColor"
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
),
|
|
228
|
+
map: /* @__PURE__ */ React.createElement(
|
|
229
|
+
"svg",
|
|
230
|
+
{
|
|
231
|
+
viewBox: "0 0 1024 1024",
|
|
232
|
+
version: "1.1",
|
|
233
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
234
|
+
width: "1em",
|
|
235
|
+
height: "1em"
|
|
236
|
+
},
|
|
237
|
+
/* @__PURE__ */ React.createElement(
|
|
238
|
+
"path",
|
|
239
|
+
{
|
|
240
|
+
d: "M877.860571 938.642286h-645.851428c-27.574857 0-54.052571-11.337143-73.508572-31.744a110.957714 110.957714 0 0 1-30.500571-76.8V193.828571c0-28.745143 10.971429-56.32 30.500571-76.726857a101.888 101.888 0 0 1 73.508572-31.817143h574.171428c27.501714 0 53.979429 11.337143 73.508572 31.744 19.529143 20.333714 30.500571 48.054857 30.500571 76.8v522.020572a34.157714 34.157714 0 0 1-6.948571 22.820571c-37.156571 19.382857-57.636571 39.350857-57.636572 72.630857 0 39.716571 19.894857 50.029714 57.636572 72.777143a34.816 34.816 0 0 1-8.045714 49.298286 32.256 32.256 0 0 1-17.334858 5.193143z m-32.256-254.537143V193.828571a40.228571 40.228571 0 0 0-39.497142-41.179428H232.009143a40.301714 40.301714 0 0 0-39.497143 41.252571V699.245714c17.773714-9.874286 37.449143-14.994286 57.417143-14.921143h595.675428v-0.073142z m-595.675428 187.245714h566.198857c-22.893714-11.190857-27.940571-39.497143-28.013714-59.977143 0-20.260571 3.218286-43.885714 28.013714-59.904h-566.125714c-31.670857 0-57.417143 26.843429-57.417143 59.977143 0 33.060571 25.746286 59.904 57.344 59.904z",
|
|
241
|
+
fill: "currentColor"
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
/* @__PURE__ */ React.createElement(
|
|
245
|
+
"path",
|
|
246
|
+
{
|
|
247
|
+
d: "M320 128m32.036571 0l-0.073142 0q32.036571 0 32.036571 32.036571l0 511.926858q0 32.036571-32.036571 32.036571l0.073142 0q-32.036571 0-32.036571-32.036571l0-511.926858q0-32.036571 32.036571-32.036571Z",
|
|
248
|
+
fill: "currentColor"
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
)
|
|
252
|
+
};
|
|
253
|
+
var ArrayIcons = {
|
|
254
|
+
object: /* @__PURE__ */ React.createElement(
|
|
255
|
+
"svg",
|
|
256
|
+
{
|
|
257
|
+
width: "1em",
|
|
258
|
+
height: "1em",
|
|
259
|
+
viewBox: "0 0 16 16",
|
|
260
|
+
fill: "none",
|
|
261
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
262
|
+
},
|
|
263
|
+
/* @__PURE__ */ React.createElement(
|
|
264
|
+
"path",
|
|
265
|
+
{
|
|
266
|
+
fillRule: "evenodd",
|
|
267
|
+
clipRule: "evenodd",
|
|
268
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM3.82031 5.9091C3.82031 5.18535 4.40703 4.59863 5.13078 4.59863C5.85453 4.59863 6.44124 5.18535 6.44124 5.9091C6.44124 6.56485 5.9596 7.1081 5.33078 7.2044V8.70018H5.32877C5.32982 8.75093 5.33078 8.80912 5.33078 8.87034V9.72111C5.33078 10.0195 5.57268 10.2614 5.87109 10.2614H6.24124C6.55613 10.2614 6.8114 10.5167 6.8114 10.8316C6.8114 11.1465 6.55613 11.4017 6.24124 11.4017H5.87109C4.94291 11.4017 4.19047 10.6493 4.19047 9.72111V6.82186C3.96158 6.58607 3.82031 6.26397 3.82031 5.9091ZM7.33679 5.9091C7.33679 5.59421 7.59205 5.33894 7.90694 5.33894H11.6085C11.9234 5.33894 12.1786 5.59421 12.1786 5.9091C12.1786 6.22399 11.9234 6.47925 11.6085 6.47925H7.90694C7.59205 6.47925 7.33679 6.22399 7.33679 5.9091ZM7.33679 9.86846C7.33679 9.55357 7.59205 9.2983 7.90694 9.2983H11.6085C11.9234 9.2983 12.1786 9.55357 12.1786 9.86846C12.1786 10.1833 11.9234 10.4386 11.6085 10.4386H7.90694C7.59205 10.4386 7.33679 10.1833 7.33679 9.86846Z",
|
|
269
|
+
fill: "currentColor"
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
),
|
|
273
|
+
boolean: /* @__PURE__ */ React.createElement(
|
|
274
|
+
"svg",
|
|
275
|
+
{
|
|
276
|
+
width: "1em",
|
|
277
|
+
height: "1em",
|
|
278
|
+
viewBox: "0 0 16 16",
|
|
279
|
+
fill: "none",
|
|
280
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
281
|
+
},
|
|
282
|
+
/* @__PURE__ */ React.createElement(
|
|
283
|
+
"path",
|
|
284
|
+
{
|
|
285
|
+
fillRule: "evenodd",
|
|
286
|
+
clipRule: "evenodd",
|
|
287
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM2.75 7.99993C2.75 6.14518 4.25358 4.6416 6.10833 4.6416H9.775C11.6298 4.6416 13.1333 6.14518 13.1333 7.99993C13.1333 9.85469 11.6298 11.3583 9.775 11.3583H6.10833C4.25358 11.3583 2.75 9.85469 2.75 7.99993ZM6.10833 5.85827C4.92552 5.85827 3.96667 6.81713 3.96667 7.99993C3.96667 9.18274 4.92552 10.1416 6.10833 10.1416H9.775C10.9578 10.1416 11.9167 9.18274 11.9167 7.99993C11.9167 6.81713 10.9578 5.85827 9.775 5.85827H6.10833ZM8.25 7.99993C8.25 7.1577 8.93277 6.47493 9.775 6.47493C10.6172 6.47493 11.3 7.1577 11.3 7.99993C11.3 8.84217 10.6172 9.52493 9.775 9.52493C8.93277 9.52493 8.25 8.84217 8.25 7.99993ZM9.775 7.6916C9.60471 7.6916 9.46667 7.82965 9.46667 7.99993C9.46667 8.17022 9.60471 8.30827 9.775 8.30827C9.94529 8.30827 10.0833 8.17022 10.0833 7.99993C10.0833 7.82965 9.94529 7.6916 9.775 7.6916Z",
|
|
288
|
+
fill: "currentColor"
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
),
|
|
292
|
+
string: /* @__PURE__ */ React.createElement(
|
|
293
|
+
"svg",
|
|
294
|
+
{
|
|
295
|
+
width: "1em",
|
|
296
|
+
height: "1em",
|
|
297
|
+
viewBox: "0 0 16 16",
|
|
298
|
+
fill: "none",
|
|
299
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
300
|
+
},
|
|
301
|
+
/* @__PURE__ */ React.createElement(
|
|
302
|
+
"path",
|
|
303
|
+
{
|
|
304
|
+
fillRule: "evenodd",
|
|
305
|
+
clipRule: "evenodd",
|
|
306
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM5.23701 4.07158C5.50364 3.3161 6.56205 3.28894 6.86709 4.02974L10 11.6383C10.1329 11.9609 9.979 12.3302 9.65631 12.4631C9.33363 12.596 8.96434 12.4421 8.83147 12.1194L7.8021 9.61951H4.61903L3.7474 12.0891C3.63126 12.4182 3.27034 12.5908 2.94127 12.4747C2.6122 12.3585 2.43958 11.9976 2.55573 11.6685L5.23701 4.07158ZM6.08814 5.45704L5.06505 8.35579H7.28174L6.08814 5.45704ZM8.81938 6.07534C8.81938 5.75166 9.08177 5.48926 9.40545 5.48926H12.8941C13.2178 5.48926 13.4802 5.75166 13.4802 6.07534C13.4802 6.39902 13.2178 6.66142 12.8941 6.66142H9.40545C9.08177 6.66142 8.81938 6.39902 8.81938 6.07534ZM10.2668 9.69181C10.2668 9.36812 10.5292 9.10573 10.8529 9.10573H12.8941C13.2178 9.10573 13.4802 9.36812 13.4802 9.69181C13.4802 10.0155 13.2178 10.2779 12.8941 10.2779H10.8529C10.5292 10.2779 10.2668 10.0155 10.2668 9.69181Z",
|
|
307
|
+
fill: "currentColor"
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
),
|
|
311
|
+
integer: /* @__PURE__ */ React.createElement(
|
|
312
|
+
"svg",
|
|
313
|
+
{
|
|
314
|
+
width: "1em",
|
|
315
|
+
height: "1em",
|
|
316
|
+
viewBox: "0 0 16 16",
|
|
317
|
+
fill: "none",
|
|
318
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
319
|
+
},
|
|
320
|
+
/* @__PURE__ */ React.createElement(
|
|
321
|
+
"path",
|
|
322
|
+
{
|
|
323
|
+
fillRule: "evenodd",
|
|
324
|
+
clipRule: "evenodd",
|
|
325
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM10.3614 5.22374C10.7161 4.90585 11.1581 4.75 11.6762 4.75C12.2173 4.75 12.6723 4.91467 13.0281 5.25207L13.0291 5.253C13.3852 5.59688 13.561 6.03946 13.561 6.56767C13.561 6.89 13.4945 7.17448 13.3539 7.41445C13.2572 7.57972 13.1279 7.71948 12.9685 7.83428C13.1575 7.95643 13.3099 8.11182 13.4225 8.30109C13.5793 8.5644 13.6531 8.88311 13.6531 9.24936C13.6531 9.83787 13.4612 10.3151 13.0656 10.6612C12.6982 10.9795 12.2305 11.1341 11.6762 11.1341C11.1356 11.1341 10.6805 10.9925 10.324 10.6977C9.92124 10.3691 9.71723 9.90026 9.69942 9.31256L9.69473 9.15802H10.846L10.8539 9.2997C10.8689 9.5698 10.9591 9.75553 11.1096 9.87941L11.1106 9.88027C11.2519 9.99882 11.4365 10.0631 11.6762 10.0631C11.9765 10.0631 12.1743 9.98692 12.2984 9.86071C12.4229 9.73404 12.4984 9.53136 12.4984 9.22422C12.4984 8.92116 12.4215 8.72127 12.2939 8.59581C12.1658 8.46989 11.961 8.39373 11.6511 8.39373H11.3586V7.34788H11.6511C11.9297 7.34788 12.111 7.27834 12.2238 7.16555C12.3366 7.05276 12.4062 6.87138 12.4062 6.59281C12.4062 6.30696 12.3378 6.12041 12.2277 6.00501C12.1188 5.89092 11.9446 5.82098 11.6762 5.82098C11.4248 5.82098 11.2539 5.88537 11.1407 5.99325C11.0268 6.10185 10.9497 6.27522 10.9291 6.5375L10.9183 6.67577H9.76788L9.77492 6.51904C9.79886 5.98644 9.99237 5.54989 10.3614 5.22374ZM5.91032 5.26037C6.26612 4.92297 6.72112 4.7583 7.26219 4.7583C7.80751 4.7583 8.26297 4.91938 8.61401 5.25194L8.61501 5.25289C8.96719 5.59272 9.13852 6.04185 9.13852 6.58435C9.13852 6.84997 9.08709 7.09565 8.9817 7.31883L8.98114 7.31999C8.89563 7.49712 8.74775 7.71415 8.54418 7.96862L8.54322 7.96981L6.87446 10.0127H9.13852V11.0753H5.36909V10.1089L7.69946 7.27679C7.89456 7.04062 7.98374 6.80773 7.98374 6.57597C7.98374 6.29602 7.91626 6.11385 7.8078 6.00122C7.70036 5.88964 7.52811 5.8209 7.26219 5.8209C7.04017 5.8209 6.87439 5.88173 6.75075 5.99193C6.61227 6.11766 6.53226 6.30918 6.53226 6.59273V6.74273H5.37747V6.59273C5.37747 6.05443 5.55248 5.60586 5.90934 5.2613L5.91032 5.26037ZM3.50907 4.80865H4.56964V11.0754H3.41486V6.2201L2.25 7.24249V5.89561L3.50907 4.80865Z",
|
|
326
|
+
fill: "currentColor"
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
),
|
|
330
|
+
number: /* @__PURE__ */ React.createElement(
|
|
331
|
+
"svg",
|
|
332
|
+
{
|
|
333
|
+
width: "1em",
|
|
334
|
+
height: "1em",
|
|
335
|
+
viewBox: "0 0 16 16",
|
|
336
|
+
fill: "none",
|
|
337
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
338
|
+
},
|
|
339
|
+
/* @__PURE__ */ React.createElement(
|
|
340
|
+
"path",
|
|
341
|
+
{
|
|
342
|
+
fillRule: "evenodd",
|
|
343
|
+
clipRule: "evenodd",
|
|
344
|
+
d: "M3.6139 1.58154H0V14.4191H3.6139V13.1269H1.36702V2.87375H3.6139V1.58154ZM3.41656 13.3271V13.3269H1.17155V13.3271H3.41656ZM0.199219 14.2191H0.197344V1.78154H3.41656V1.78174H0.199219V14.2191ZM16 1.58154H12.3861V2.87375H14.633V13.1269H12.3861V14.4191H16V1.58154ZM12.5834 1.78154V2.67375H12.5853V1.78174H15.8027V1.78154H12.5834ZM12.5853 14.2191V13.3271H14.8322V2.67394H14.8303V13.3269H12.5834V14.2191H12.5853ZM6.86771 4.5C5.87019 4.5 5.00104 5.30767 5.00104 6.31667V9.63333C5.00104 10.6423 5.87019 11.45 6.86771 11.45C7.86523 11.45 8.73438 10.6423 8.73438 9.63333V6.31667C8.73438 5.30767 7.86523 4.5 6.86771 4.5ZM11.1177 4.5C10.1202 4.5 9.25104 5.30767 9.25104 6.31667V9.63333C9.25104 10.6423 10.1202 11.45 11.1177 11.45C12.1152 11.45 12.9844 10.6423 12.9844 9.63333V6.31667C12.9844 5.30767 12.1152 4.5 11.1177 4.5ZM6.13438 6.31667C6.13438 5.9503 6.47884 5.63333 6.86771 5.63333C7.25657 5.63333 7.60104 5.9503 7.60104 6.31667V9.63333C7.60104 9.9997 7.25657 10.3167 6.86771 10.3167C6.47884 10.3167 6.13438 9.9997 6.13438 9.63333V6.31667ZM10.3844 6.31667C10.3844 5.9503 10.7288 5.63333 11.1177 5.63333C11.5066 5.63333 11.851 5.9503 11.851 6.31667V9.63333C11.851 9.9997 11.5066 10.3167 11.1177 10.3167C10.7288 10.3167 10.3844 9.9997 10.3844 9.63333V6.31667ZM3.75938 9.85C3.33135 9.85 2.98438 10.197 2.98438 10.625C2.98438 11.053 3.33135 11.4 3.75938 11.4C4.1874 11.4 4.53438 11.053 4.53438 10.625C4.53438 10.197 4.1874 9.85 3.75938 9.85Z",
|
|
345
|
+
fill: "currentColor"
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
)
|
|
349
|
+
};
|
|
350
|
+
var getSchemaIcon = (value) => {
|
|
351
|
+
if (value?.type === "array") {
|
|
352
|
+
return ArrayIcons[value.items?.type || "object"];
|
|
353
|
+
}
|
|
354
|
+
return VariableTypeIcons[value?.type || "object"];
|
|
355
|
+
};
|
|
356
|
+
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
357
|
+
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
358
|
+
var baseOptions = [
|
|
359
|
+
{
|
|
360
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "string" }) }), firstUppercase("string")),
|
|
361
|
+
value: "string"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
|
|
365
|
+
value: "integer"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
|
|
369
|
+
value: "number"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
|
|
373
|
+
value: "boolean"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
|
|
377
|
+
value: "object"
|
|
378
|
+
}
|
|
379
|
+
];
|
|
380
|
+
var options = [
|
|
381
|
+
...baseOptions,
|
|
382
|
+
{
|
|
383
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
|
|
384
|
+
value: "array",
|
|
385
|
+
children: baseOptions.map((_opt) => ({
|
|
386
|
+
..._opt,
|
|
387
|
+
value: `${_opt.value}`,
|
|
388
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(
|
|
389
|
+
Icon,
|
|
390
|
+
{
|
|
391
|
+
size: "small",
|
|
392
|
+
svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
|
|
393
|
+
}
|
|
394
|
+
), firstUppercase(_opt.value))
|
|
395
|
+
}))
|
|
396
|
+
}
|
|
397
|
+
];
|
|
398
|
+
|
|
399
|
+
// src/utils/json-schema/index.ts
|
|
400
|
+
import { get } from "lodash";
|
|
401
|
+
import { ASTFactory, ASTKind, ASTMatch } from "@flowgram.ai/editor";
|
|
402
|
+
var JsonSchemaUtils;
|
|
403
|
+
((JsonSchemaUtils2) => {
|
|
404
|
+
function schemaToAST(jsonSchema) {
|
|
405
|
+
const { type, extra } = jsonSchema || {};
|
|
406
|
+
const { weak = false } = extra || {};
|
|
407
|
+
if (!type) {
|
|
408
|
+
return void 0;
|
|
409
|
+
}
|
|
410
|
+
switch (type) {
|
|
411
|
+
case "object":
|
|
412
|
+
if (weak) {
|
|
413
|
+
return { kind: ASTKind.Object, weak: true };
|
|
414
|
+
}
|
|
415
|
+
return ASTFactory.createObject({
|
|
416
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a?.[1], "extra.index") || 0) - (get(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
417
|
+
key,
|
|
418
|
+
type: schemaToAST(_property),
|
|
419
|
+
meta: {
|
|
420
|
+
title: _property.title,
|
|
421
|
+
description: _property.description
|
|
422
|
+
}
|
|
423
|
+
}))
|
|
424
|
+
});
|
|
425
|
+
case "array":
|
|
426
|
+
if (weak) {
|
|
427
|
+
return { kind: ASTKind.Array, weak: true };
|
|
428
|
+
}
|
|
429
|
+
return ASTFactory.createArray({
|
|
430
|
+
items: schemaToAST(jsonSchema.items)
|
|
431
|
+
});
|
|
432
|
+
case "map":
|
|
433
|
+
if (weak) {
|
|
434
|
+
return { kind: ASTKind.Map, weak: true };
|
|
435
|
+
}
|
|
436
|
+
return ASTFactory.createMap({
|
|
437
|
+
valueType: schemaToAST(jsonSchema.additionalProperties)
|
|
438
|
+
});
|
|
439
|
+
case "string":
|
|
440
|
+
return ASTFactory.createString();
|
|
441
|
+
case "number":
|
|
442
|
+
return ASTFactory.createNumber();
|
|
443
|
+
case "boolean":
|
|
444
|
+
return ASTFactory.createBoolean();
|
|
445
|
+
case "integer":
|
|
446
|
+
return ASTFactory.createInteger();
|
|
447
|
+
default:
|
|
448
|
+
return ASTFactory.createCustomType({ typeName: type });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
JsonSchemaUtils2.schemaToAST = schemaToAST;
|
|
452
|
+
function astToSchema(typeAST, options2) {
|
|
453
|
+
const { drilldown = true } = options2 || {};
|
|
454
|
+
if (ASTMatch.isString(typeAST)) {
|
|
455
|
+
return {
|
|
456
|
+
type: "string"
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
if (ASTMatch.isBoolean(typeAST)) {
|
|
460
|
+
return {
|
|
461
|
+
type: "boolean"
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
if (ASTMatch.isNumber(typeAST)) {
|
|
465
|
+
return {
|
|
466
|
+
type: "number"
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
if (ASTMatch.isInteger(typeAST)) {
|
|
470
|
+
return {
|
|
471
|
+
type: "integer"
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
if (ASTMatch.isObject(typeAST)) {
|
|
475
|
+
return {
|
|
476
|
+
type: "object",
|
|
477
|
+
properties: drilldown ? Object.fromEntries(
|
|
478
|
+
typeAST.properties.map((property) => {
|
|
479
|
+
const schema = astToSchema(property.type);
|
|
480
|
+
if (property.meta?.title && schema) {
|
|
481
|
+
schema.title = property.meta.title;
|
|
482
|
+
}
|
|
483
|
+
if (property.meta?.description && schema) {
|
|
484
|
+
schema.description = property.meta.description;
|
|
485
|
+
}
|
|
486
|
+
return [property.key, schema];
|
|
487
|
+
})
|
|
488
|
+
) : {}
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (ASTMatch.isArray(typeAST)) {
|
|
492
|
+
return {
|
|
493
|
+
type: "array",
|
|
494
|
+
items: drilldown ? astToSchema(typeAST.items) : void 0
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
if (ASTMatch.isMap(typeAST)) {
|
|
498
|
+
return {
|
|
499
|
+
type: "map",
|
|
500
|
+
items: drilldown ? astToSchema(typeAST.valueType) : void 0
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
if (ASTMatch.isCustomType(typeAST)) {
|
|
504
|
+
return {
|
|
505
|
+
type: typeAST.typeName
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
return void 0;
|
|
509
|
+
}
|
|
510
|
+
JsonSchemaUtils2.astToSchema = astToSchema;
|
|
511
|
+
function isASTMatchSchema(typeAST, schema) {
|
|
512
|
+
if (Array.isArray(schema)) {
|
|
513
|
+
return typeAST.isTypeEqual(
|
|
514
|
+
ASTFactory.createUnion({
|
|
515
|
+
types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
|
|
516
|
+
})
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
return typeAST.isTypeEqual(schemaToAST(schema));
|
|
520
|
+
}
|
|
521
|
+
JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
|
|
522
|
+
})(JsonSchemaUtils || (JsonSchemaUtils = {}));
|
|
523
|
+
|
|
524
|
+
// src/components/variable-selector/use-variable-tree.tsx
|
|
525
|
+
function useVariableTree(params) {
|
|
526
|
+
const { includeSchema, excludeSchema } = params;
|
|
527
|
+
const variables = useAvailableVariables();
|
|
528
|
+
const getVariableTypeIcon = useCallback((variable) => {
|
|
529
|
+
if (variable.meta?.icon) {
|
|
530
|
+
if (typeof variable.meta.icon === "string") {
|
|
531
|
+
return /* @__PURE__ */ React2.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
532
|
+
}
|
|
533
|
+
return variable.meta.icon;
|
|
534
|
+
}
|
|
535
|
+
const _type = variable.type;
|
|
536
|
+
if (ASTMatch2.isArray(_type)) {
|
|
537
|
+
return /* @__PURE__ */ React2.createElement(
|
|
538
|
+
Icon2,
|
|
539
|
+
{
|
|
540
|
+
size: "small",
|
|
541
|
+
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
542
|
+
}
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
if (ASTMatch2.isCustomType(_type)) {
|
|
546
|
+
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
547
|
+
}
|
|
548
|
+
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
549
|
+
}, []);
|
|
550
|
+
const renderVariable = (variable, parentFields = []) => {
|
|
551
|
+
let type = variable?.type;
|
|
552
|
+
if (!type) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
let children;
|
|
556
|
+
if (ASTMatch2.isObject(type)) {
|
|
557
|
+
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
558
|
+
}
|
|
559
|
+
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
560
|
+
const key = keyPath.join(".");
|
|
561
|
+
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
562
|
+
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
563
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
|
|
564
|
+
if (!isSchemaMatch && !children?.length) {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
return {
|
|
568
|
+
key,
|
|
569
|
+
label: variable.meta?.title || variable.key,
|
|
570
|
+
value: key,
|
|
571
|
+
keyPath,
|
|
572
|
+
icon: getVariableTypeIcon(variable),
|
|
573
|
+
children,
|
|
574
|
+
disabled: !isSchemaMatch,
|
|
575
|
+
rootMeta: parentFields[0]?.meta
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// src/components/variable-selector/styles.tsx
|
|
582
|
+
import styled from "styled-components";
|
|
583
|
+
import { Tag, TreeSelect } from "@douyinfe/semi-ui";
|
|
584
|
+
var UIRootTitle = styled.div`
|
|
585
|
+
margin-right: 4px;
|
|
586
|
+
min-width: 20px;
|
|
587
|
+
overflow: hidden;
|
|
588
|
+
text-overflow: ellipsis;
|
|
589
|
+
white-space: nowrap;
|
|
590
|
+
color: var(--semi-color-text-2);
|
|
591
|
+
`;
|
|
592
|
+
var UIVarName = styled.div`
|
|
593
|
+
overflow: hidden;
|
|
594
|
+
text-overflow: ellipsis;
|
|
595
|
+
white-space: nowrap;
|
|
596
|
+
min-width: 50%;
|
|
597
|
+
`;
|
|
598
|
+
var UITag = styled(Tag)`
|
|
599
|
+
width: 100%;
|
|
600
|
+
display: flex;
|
|
601
|
+
align-items: center;
|
|
602
|
+
justify-content: flex-start;
|
|
603
|
+
|
|
604
|
+
& .semi-tag-content-center {
|
|
605
|
+
justify-content: flex-start;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
&.semi-tag {
|
|
609
|
+
margin: 0;
|
|
610
|
+
}
|
|
611
|
+
`;
|
|
612
|
+
var UITreeSelect = styled(TreeSelect)`
|
|
613
|
+
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
614
|
+
|
|
615
|
+
height: 22px;
|
|
616
|
+
min-height: 22px;
|
|
617
|
+
line-height: 22px;
|
|
618
|
+
|
|
619
|
+
& .semi-tree-select-selection {
|
|
620
|
+
padding: 0 2px;
|
|
621
|
+
height: 22px;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
& .semi-tree-select-selection-content {
|
|
625
|
+
width: 100%;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
& .semi-tree-select-selection-placeholder {
|
|
629
|
+
padding-left: 10px;
|
|
630
|
+
}
|
|
631
|
+
`;
|
|
632
|
+
|
|
633
|
+
// src/components/variable-selector/index.tsx
|
|
634
|
+
var VariableSelector = ({
|
|
635
|
+
value,
|
|
636
|
+
config = {},
|
|
637
|
+
onChange,
|
|
638
|
+
style,
|
|
639
|
+
readonly = false,
|
|
640
|
+
includeSchema,
|
|
641
|
+
excludeSchema,
|
|
642
|
+
hasError,
|
|
643
|
+
triggerRender
|
|
644
|
+
}) => {
|
|
645
|
+
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
646
|
+
const treeValue = useMemo(() => {
|
|
647
|
+
if (typeof value === "string") {
|
|
648
|
+
console.warn(
|
|
649
|
+
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
650
|
+
"Please check the value of VariableSelector \n"
|
|
651
|
+
);
|
|
652
|
+
return value;
|
|
653
|
+
}
|
|
654
|
+
return value?.join(".");
|
|
655
|
+
}, [value]);
|
|
656
|
+
const renderIcon = (icon) => {
|
|
657
|
+
if (typeof icon === "string") {
|
|
658
|
+
return /* @__PURE__ */ React3.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
659
|
+
}
|
|
660
|
+
return icon;
|
|
661
|
+
};
|
|
662
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
663
|
+
UITreeSelect,
|
|
664
|
+
{
|
|
665
|
+
dropdownMatchSelectWidth: false,
|
|
666
|
+
disabled: readonly,
|
|
667
|
+
treeData,
|
|
668
|
+
size: "small",
|
|
669
|
+
value: treeValue,
|
|
670
|
+
clearIcon: null,
|
|
671
|
+
$error: hasError,
|
|
672
|
+
style,
|
|
673
|
+
validateStatus: hasError ? "error" : void 0,
|
|
674
|
+
onChange: (_, _config) => {
|
|
675
|
+
onChange(_config.keyPath);
|
|
676
|
+
},
|
|
677
|
+
renderSelectedItem: (_option) => {
|
|
678
|
+
if (!_option?.keyPath) {
|
|
679
|
+
return /* @__PURE__ */ React3.createElement(
|
|
680
|
+
UITag,
|
|
681
|
+
{
|
|
682
|
+
prefixIcon: /* @__PURE__ */ React3.createElement(IconIssueStroked, null),
|
|
683
|
+
color: "amber",
|
|
684
|
+
closable: !readonly,
|
|
685
|
+
onClose: () => onChange(void 0)
|
|
686
|
+
},
|
|
687
|
+
config?.notFoundContent ?? "Undefined"
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
return /* @__PURE__ */ React3.createElement(
|
|
691
|
+
UITag,
|
|
692
|
+
{
|
|
693
|
+
prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
|
|
694
|
+
closable: !readonly,
|
|
695
|
+
onClose: () => onChange(void 0)
|
|
696
|
+
},
|
|
697
|
+
/* @__PURE__ */ React3.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
|
|
698
|
+
/* @__PURE__ */ React3.createElement(UIVarName, null, _option.label)
|
|
699
|
+
);
|
|
700
|
+
},
|
|
701
|
+
showClear: false,
|
|
702
|
+
arrowIcon: /* @__PURE__ */ React3.createElement(IconChevronDownStroked, { size: "small" }),
|
|
703
|
+
triggerRender,
|
|
704
|
+
placeholder: config?.placeholder ?? "Select Variable..."
|
|
705
|
+
}
|
|
706
|
+
));
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// src/components/type-selector/index.tsx
|
|
710
|
+
import React4, { useMemo as useMemo2 } from "react";
|
|
711
|
+
import { Button, Cascader } from "@douyinfe/semi-ui";
|
|
712
|
+
var getTypeSelectValue = (value) => {
|
|
713
|
+
if (value?.type === "array" && value?.items) {
|
|
714
|
+
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
715
|
+
}
|
|
716
|
+
return value?.type ? [value.type] : void 0;
|
|
717
|
+
};
|
|
718
|
+
var parseTypeSelectValue = (value) => {
|
|
719
|
+
const [type, ...subTypes] = value || [];
|
|
720
|
+
if (type === "array") {
|
|
721
|
+
return { type: "array", items: parseTypeSelectValue(subTypes) };
|
|
722
|
+
}
|
|
723
|
+
return { type };
|
|
724
|
+
};
|
|
725
|
+
function TypeSelector(props) {
|
|
726
|
+
const { value, onChange, disabled, style } = props;
|
|
727
|
+
const selectValue = useMemo2(() => getTypeSelectValue(value), [value]);
|
|
728
|
+
return /* @__PURE__ */ React4.createElement(
|
|
729
|
+
Cascader,
|
|
730
|
+
{
|
|
731
|
+
disabled,
|
|
732
|
+
size: "small",
|
|
733
|
+
triggerRender: () => /* @__PURE__ */ React4.createElement(Button, { size: "small", style }, getSchemaIcon(value)),
|
|
734
|
+
treeData: options,
|
|
735
|
+
value: selectValue,
|
|
736
|
+
leafOnly: true,
|
|
737
|
+
onChange: (value2) => {
|
|
738
|
+
onChange(parseTypeSelectValue(value2));
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/components/json-schema-editor/index.tsx
|
|
745
|
+
import React9, { useMemo as useMemo5, useState as useState4 } from "react";
|
|
746
|
+
import { Button as Button2, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
|
|
747
|
+
import {
|
|
748
|
+
IconExpand,
|
|
749
|
+
IconShrink,
|
|
750
|
+
IconPlus,
|
|
751
|
+
IconChevronDown,
|
|
752
|
+
IconChevronRight,
|
|
753
|
+
IconMinus
|
|
754
|
+
} from "@douyinfe/semi-icons";
|
|
755
|
+
|
|
756
|
+
// src/components/json-schema-editor/styles.tsx
|
|
757
|
+
import React5 from "react";
|
|
758
|
+
import styled2, { css } from "styled-components";
|
|
759
|
+
import Icon3 from "@douyinfe/semi-icons";
|
|
760
|
+
var UIContainer = styled2.div`
|
|
761
|
+
/* & .semi-input {
|
|
762
|
+
background-color: #fff;
|
|
763
|
+
border-radius: 6px;
|
|
764
|
+
height: 24px;
|
|
765
|
+
} */
|
|
766
|
+
`;
|
|
767
|
+
var UIRow = styled2.div`
|
|
768
|
+
display: flex;
|
|
769
|
+
align-items: center;
|
|
770
|
+
gap: 6px;
|
|
771
|
+
`;
|
|
772
|
+
var UICollapseTrigger = styled2.div`
|
|
773
|
+
cursor: pointer;
|
|
774
|
+
margin-right: 5px;
|
|
775
|
+
`;
|
|
776
|
+
var UIExpandDetail = styled2.div`
|
|
777
|
+
display: flex;
|
|
778
|
+
flex-direction: column;
|
|
779
|
+
`;
|
|
780
|
+
var UILabel = styled2.div`
|
|
781
|
+
font-size: 12px;
|
|
782
|
+
color: #999;
|
|
783
|
+
font-weight: 400;
|
|
784
|
+
margin-bottom: 2px;
|
|
785
|
+
`;
|
|
786
|
+
var UIProperties = styled2.div`
|
|
787
|
+
display: grid;
|
|
788
|
+
grid-template-columns: auto 1fr;
|
|
789
|
+
|
|
790
|
+
${({ $shrink }) => $shrink && css`
|
|
791
|
+
padding-left: 10px;
|
|
792
|
+
margin-top: 10px;
|
|
793
|
+
`}
|
|
794
|
+
`;
|
|
795
|
+
var UIPropertyLeft = styled2.div`
|
|
796
|
+
grid-column: 1;
|
|
797
|
+
position: relative;
|
|
798
|
+
width: 16px;
|
|
799
|
+
|
|
800
|
+
${({ $showLine, $isLast, $parentType }) => {
|
|
801
|
+
let height = "100%";
|
|
802
|
+
if ($parentType && $isLast) {
|
|
803
|
+
height = "24px";
|
|
804
|
+
}
|
|
805
|
+
return $showLine && css`
|
|
806
|
+
&::before {
|
|
807
|
+
/* 竖线 */
|
|
808
|
+
content: '';
|
|
809
|
+
height: ${height};
|
|
810
|
+
position: absolute;
|
|
811
|
+
left: -22px;
|
|
812
|
+
top: -16px;
|
|
813
|
+
width: 1px;
|
|
814
|
+
background: #d9d9d9;
|
|
815
|
+
display: block;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
&::after {
|
|
819
|
+
/* 横线 */
|
|
820
|
+
content: '';
|
|
821
|
+
position: absolute;
|
|
822
|
+
left: -22px; // 横线起点和竖线对齐
|
|
823
|
+
top: 8px; // 跟随你的行高调整
|
|
824
|
+
width: 18px; // 横线长度
|
|
825
|
+
height: 1px;
|
|
826
|
+
background: #d9d9d9;
|
|
827
|
+
display: block;
|
|
828
|
+
}
|
|
829
|
+
`;
|
|
830
|
+
}}
|
|
831
|
+
`;
|
|
832
|
+
var UIPropertyRight = styled2.div`
|
|
833
|
+
grid-column: 2;
|
|
834
|
+
margin-bottom: 10px;
|
|
835
|
+
|
|
836
|
+
&:last-child {
|
|
837
|
+
margin-bottom: 0px;
|
|
838
|
+
}
|
|
839
|
+
`;
|
|
840
|
+
var UIPropertyMain = styled2.div`
|
|
841
|
+
display: flex;
|
|
842
|
+
flex-direction: column;
|
|
843
|
+
gap: 10px;
|
|
844
|
+
position: relative;
|
|
845
|
+
|
|
846
|
+
${({ $expand, type, $collapse, $showCollapse }) => {
|
|
847
|
+
const beforeElement = `
|
|
848
|
+
&::before {
|
|
849
|
+
/* \u7AD6\u7EBF */
|
|
850
|
+
content: '';
|
|
851
|
+
height: 100%;
|
|
852
|
+
position: absolute;
|
|
853
|
+
left: -12px;
|
|
854
|
+
top: 18px;
|
|
855
|
+
width: 1px;
|
|
856
|
+
background: #d9d9d9;
|
|
857
|
+
display: block;
|
|
858
|
+
}`;
|
|
859
|
+
return $expand && css`
|
|
860
|
+
background-color: #f5f5f5;
|
|
861
|
+
padding: 10px;
|
|
862
|
+
border-radius: 4px;
|
|
863
|
+
|
|
864
|
+
${$showCollapse && $collapse && (type === "array" || type === "object") && css`
|
|
865
|
+
${beforeElement}
|
|
866
|
+
`}
|
|
867
|
+
`;
|
|
868
|
+
}}
|
|
869
|
+
`;
|
|
870
|
+
var UICollapsible = styled2.div`
|
|
871
|
+
display: none;
|
|
872
|
+
|
|
873
|
+
${({ $collapse }) => $collapse && css`
|
|
874
|
+
display: block;
|
|
875
|
+
`}
|
|
876
|
+
`;
|
|
877
|
+
var UIName = styled2.div`
|
|
878
|
+
flex-grow: 1;
|
|
879
|
+
`;
|
|
880
|
+
var UIType = styled2.div``;
|
|
881
|
+
var UIRequired = styled2.div``;
|
|
882
|
+
var UIActions = styled2.div`
|
|
883
|
+
white-space: nowrap;
|
|
884
|
+
`;
|
|
885
|
+
var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
|
|
886
|
+
"svg",
|
|
887
|
+
{
|
|
888
|
+
className: "icon-icon icon-icon-coz_add_node ",
|
|
889
|
+
width: "1em",
|
|
890
|
+
height: "1em",
|
|
891
|
+
viewBox: "0 0 24 24",
|
|
892
|
+
fill: "currentColor",
|
|
893
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
894
|
+
},
|
|
895
|
+
/* @__PURE__ */ React5.createElement(
|
|
896
|
+
"path",
|
|
897
|
+
{
|
|
898
|
+
fillRule: "evenodd",
|
|
899
|
+
clipRule: "evenodd",
|
|
900
|
+
d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
|
|
901
|
+
}
|
|
902
|
+
),
|
|
903
|
+
/* @__PURE__ */ React5.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
|
|
904
|
+
);
|
|
905
|
+
var IconAddChildren = () => /* @__PURE__ */ React5.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
|
|
906
|
+
var DefaultValueWrapper = styled2.div`
|
|
907
|
+
margin: 0;
|
|
908
|
+
`;
|
|
909
|
+
var JSONViewerWrapper = styled2.div`
|
|
910
|
+
padding: 0 0 24px;
|
|
911
|
+
&:first-child {
|
|
912
|
+
margin-top: 0px;
|
|
913
|
+
}
|
|
914
|
+
`;
|
|
915
|
+
var JSONHeader = styled2.div`
|
|
916
|
+
display: flex;
|
|
917
|
+
justify-content: space-between;
|
|
918
|
+
align-items: center;
|
|
919
|
+
background-color: var(--semi-color-fill-0);
|
|
920
|
+
border-radius: 6px 6px 0 0;
|
|
921
|
+
height: 36px;
|
|
922
|
+
padding: 0 8px 0 12px;
|
|
923
|
+
`;
|
|
924
|
+
var JSONHeaderLeft = styled2.div`
|
|
925
|
+
display: flex;
|
|
926
|
+
align-items: center;
|
|
927
|
+
gap: 10px;
|
|
928
|
+
`;
|
|
929
|
+
var JSONHeaderRight = styled2.div`
|
|
930
|
+
display: flex;
|
|
931
|
+
align-items: center;
|
|
932
|
+
gap: 10px;
|
|
933
|
+
`;
|
|
934
|
+
var ConstantInputWrapper = styled2.div`
|
|
935
|
+
flex-grow: 1;
|
|
936
|
+
|
|
937
|
+
& .semi-tree-select,
|
|
938
|
+
& .semi-input-number,
|
|
939
|
+
& .semi-select {
|
|
940
|
+
width: 100%;
|
|
941
|
+
}
|
|
942
|
+
`;
|
|
943
|
+
|
|
944
|
+
// src/components/json-schema-editor/hooks.tsx
|
|
945
|
+
import { useEffect, useMemo as useMemo3, useRef, useState } from "react";
|
|
946
|
+
var _id = 0;
|
|
947
|
+
function genId() {
|
|
948
|
+
return _id++;
|
|
949
|
+
}
|
|
950
|
+
function getDrilldownSchema(value, path) {
|
|
951
|
+
if (!value) {
|
|
952
|
+
return {};
|
|
953
|
+
}
|
|
954
|
+
if (value.type === "array" && value.items) {
|
|
955
|
+
return getDrilldownSchema(value.items, [...path || [], "items"]);
|
|
956
|
+
}
|
|
957
|
+
return { schema: value, path };
|
|
958
|
+
}
|
|
959
|
+
function usePropertiesEdit(value, onChange) {
|
|
960
|
+
const drilldown = useMemo3(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
961
|
+
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
962
|
+
const initPropertyList = useMemo3(
|
|
963
|
+
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
964
|
+
([name, _value], index) => ({
|
|
965
|
+
key: genId(),
|
|
966
|
+
name,
|
|
967
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
968
|
+
..._value,
|
|
969
|
+
extra: {
|
|
970
|
+
..._value.extra || {},
|
|
971
|
+
index
|
|
972
|
+
}
|
|
973
|
+
})
|
|
974
|
+
) : [],
|
|
975
|
+
[isDrilldownObject]
|
|
976
|
+
);
|
|
977
|
+
const [propertyList, setPropertyList] = useState(initPropertyList);
|
|
978
|
+
const mountRef = useRef(false);
|
|
979
|
+
useEffect(() => {
|
|
980
|
+
if (mountRef.current) {
|
|
981
|
+
setPropertyList((_list) => {
|
|
982
|
+
const nameMap = /* @__PURE__ */ new Map();
|
|
983
|
+
for (const _property of _list) {
|
|
984
|
+
if (_property.name) {
|
|
985
|
+
nameMap.set(_property.name, _property);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
989
|
+
const _property = nameMap.get(name);
|
|
990
|
+
if (_property) {
|
|
991
|
+
return {
|
|
992
|
+
key: _property.key,
|
|
993
|
+
name,
|
|
994
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
995
|
+
..._value
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
key: genId(),
|
|
1000
|
+
name,
|
|
1001
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1002
|
+
..._value
|
|
1003
|
+
};
|
|
1004
|
+
});
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
mountRef.current = true;
|
|
1008
|
+
}, [drilldown.schema]);
|
|
1009
|
+
const updatePropertyList = (updater) => {
|
|
1010
|
+
setPropertyList((_list) => {
|
|
1011
|
+
const next = updater(_list);
|
|
1012
|
+
const nextProperties = {};
|
|
1013
|
+
const nextRequired = [];
|
|
1014
|
+
for (const _property of next) {
|
|
1015
|
+
if (!_property.name) {
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
nextProperties[_property.name] = _property;
|
|
1019
|
+
if (_property.isPropertyRequired) {
|
|
1020
|
+
nextRequired.push(_property.name);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
let drilldownSchema = value || {};
|
|
1024
|
+
if (drilldown.path) {
|
|
1025
|
+
drilldownSchema = drilldown.path.reduce((acc, key) => acc[key], value || {});
|
|
1026
|
+
}
|
|
1027
|
+
drilldownSchema.properties = nextProperties;
|
|
1028
|
+
drilldownSchema.required = nextRequired;
|
|
1029
|
+
onChange?.(value || {});
|
|
1030
|
+
return next;
|
|
1031
|
+
});
|
|
1032
|
+
};
|
|
1033
|
+
const onAddProperty = () => {
|
|
1034
|
+
updatePropertyList((_list) => [
|
|
1035
|
+
..._list,
|
|
1036
|
+
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
1037
|
+
]);
|
|
1038
|
+
};
|
|
1039
|
+
const onRemoveProperty = (key) => {
|
|
1040
|
+
updatePropertyList((_list) => _list.filter((_property) => _property.key !== key));
|
|
1041
|
+
};
|
|
1042
|
+
const onEditProperty = (key, nextValue) => {
|
|
1043
|
+
updatePropertyList(
|
|
1044
|
+
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1045
|
+
);
|
|
1046
|
+
};
|
|
1047
|
+
useEffect(() => {
|
|
1048
|
+
if (!isDrilldownObject) {
|
|
1049
|
+
setPropertyList([]);
|
|
1050
|
+
}
|
|
1051
|
+
}, [isDrilldownObject]);
|
|
1052
|
+
return {
|
|
1053
|
+
propertyList,
|
|
1054
|
+
isDrilldownObject,
|
|
1055
|
+
onAddProperty,
|
|
1056
|
+
onRemoveProperty,
|
|
1057
|
+
onEditProperty
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// src/components/json-schema-editor/default-value.tsx
|
|
1062
|
+
import React7, { useRef as useRef2, useState as useState2, useCallback as useCallback2 } from "react";
|
|
1063
|
+
import { IconButton, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
|
|
1064
|
+
import { IconBrackets } from "@douyinfe/semi-icons";
|
|
1065
|
+
|
|
1066
|
+
// src/components/json-schema-editor/utils.ts
|
|
1067
|
+
function getValueType(value) {
|
|
1068
|
+
const type = typeof value;
|
|
1069
|
+
if (type === "string") {
|
|
1070
|
+
return "string";
|
|
1071
|
+
} else if (type === "number") {
|
|
1072
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
1073
|
+
} else if (type === "boolean") {
|
|
1074
|
+
return "boolean";
|
|
1075
|
+
} else if (type === "object") {
|
|
1076
|
+
if (value === null) {
|
|
1077
|
+
return "other";
|
|
1078
|
+
}
|
|
1079
|
+
return Array.isArray(value) ? "array" : "object";
|
|
1080
|
+
} else {
|
|
1081
|
+
return "other";
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// src/components/constant-input/index.tsx
|
|
1086
|
+
import React6, { useMemo as useMemo4 } from "react";
|
|
1087
|
+
import { Input, InputNumber, Select } from "@douyinfe/semi-ui";
|
|
1088
|
+
var defaultStrategies = [
|
|
1089
|
+
{
|
|
1090
|
+
hit: (schema) => schema?.type === "string",
|
|
1091
|
+
Renderer: (props) => /* @__PURE__ */ React6.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
hit: (schema) => schema?.type === "number",
|
|
1095
|
+
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1096
|
+
InputNumber,
|
|
1097
|
+
{
|
|
1098
|
+
placeholder: "Please Input Number",
|
|
1099
|
+
size: "small",
|
|
1100
|
+
disabled: props.readonly,
|
|
1101
|
+
hideButtons: true,
|
|
1102
|
+
...props
|
|
1103
|
+
}
|
|
1104
|
+
)
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
hit: (schema) => schema?.type === "integer",
|
|
1108
|
+
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1109
|
+
InputNumber,
|
|
1110
|
+
{
|
|
1111
|
+
placeholder: "Please Input Integer",
|
|
1112
|
+
size: "small",
|
|
1113
|
+
disabled: props.readonly,
|
|
1114
|
+
hideButtons: true,
|
|
1115
|
+
precision: 0,
|
|
1116
|
+
...props
|
|
1117
|
+
}
|
|
1118
|
+
)
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
hit: (schema) => schema?.type === "boolean",
|
|
1122
|
+
Renderer: (props) => {
|
|
1123
|
+
const { value, onChange, ...rest } = props;
|
|
1124
|
+
return /* @__PURE__ */ React6.createElement(
|
|
1125
|
+
Select,
|
|
1126
|
+
{
|
|
1127
|
+
placeholder: "Please Select Boolean",
|
|
1128
|
+
size: "small",
|
|
1129
|
+
disabled: props.readonly,
|
|
1130
|
+
optionList: [
|
|
1131
|
+
{ label: "True", value: 1 },
|
|
1132
|
+
{ label: "False", value: 0 }
|
|
1133
|
+
],
|
|
1134
|
+
value: value ? 1 : 0,
|
|
1135
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
1136
|
+
...rest
|
|
1137
|
+
}
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
];
|
|
1142
|
+
function ConstantInput(props) {
|
|
1143
|
+
const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
|
|
1144
|
+
const strategies = useMemo4(
|
|
1145
|
+
() => [...defaultStrategies, ...extraStrategies || []],
|
|
1146
|
+
[extraStrategies]
|
|
1147
|
+
);
|
|
1148
|
+
const Renderer2 = useMemo4(() => {
|
|
1149
|
+
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1150
|
+
return strategy?.Renderer;
|
|
1151
|
+
}, [strategies, schema]);
|
|
1152
|
+
if (!Renderer2) {
|
|
1153
|
+
return /* @__PURE__ */ React6.createElement(Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1154
|
+
}
|
|
1155
|
+
return /* @__PURE__ */ React6.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// src/components/json-schema-editor/default-value.tsx
|
|
1159
|
+
function DefaultValue(props) {
|
|
1160
|
+
const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
|
|
1161
|
+
const wrapperRef = useRef2(null);
|
|
1162
|
+
const JsonViewerRef = useRef2(null);
|
|
1163
|
+
const [internalJsonValue, setInternalJsonValue] = useState2(
|
|
1164
|
+
getValueType(value) === "string" ? value : ""
|
|
1165
|
+
);
|
|
1166
|
+
const handleJsonChange = useCallback2((val) => {
|
|
1167
|
+
if (val !== internalJsonValue) {
|
|
1168
|
+
setInternalJsonValue(val);
|
|
1169
|
+
}
|
|
1170
|
+
}, []);
|
|
1171
|
+
const handleEditComplete = useCallback2(() => {
|
|
1172
|
+
onChange(internalJsonValue);
|
|
1173
|
+
requestAnimationFrame(() => {
|
|
1174
|
+
wrapperRef.current?.blur();
|
|
1175
|
+
});
|
|
1176
|
+
setJsonReadOnly(true);
|
|
1177
|
+
}, [internalJsonValue, onChange]);
|
|
1178
|
+
const [jsonReadOnly, setJsonReadOnly] = useState2(true);
|
|
1179
|
+
const handleFormatJson = useCallback2(() => {
|
|
1180
|
+
try {
|
|
1181
|
+
const parsed = JSON.parse(internalJsonValue);
|
|
1182
|
+
const formatted = JSON.stringify(parsed, null, 4);
|
|
1183
|
+
setInternalJsonValue(formatted);
|
|
1184
|
+
onChange(formatted);
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
console.error("Invalid JSON:", error);
|
|
1187
|
+
}
|
|
1188
|
+
}, [internalJsonValue, onChange]);
|
|
1189
|
+
return type === "object" ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(JSONHeader, null, /* @__PURE__ */ React7.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React7.createElement(JSONHeaderRight, null, /* @__PURE__ */ React7.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React7.createElement(
|
|
1190
|
+
IconButton,
|
|
1191
|
+
{
|
|
1192
|
+
icon: /* @__PURE__ */ React7.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1193
|
+
size: "small",
|
|
1194
|
+
type: "tertiary",
|
|
1195
|
+
theme: "borderless",
|
|
1196
|
+
onClick: handleFormatJson
|
|
1197
|
+
}
|
|
1198
|
+
)))), /* @__PURE__ */ React7.createElement(
|
|
1199
|
+
JSONViewerWrapper,
|
|
1200
|
+
{
|
|
1201
|
+
ref: wrapperRef,
|
|
1202
|
+
tabIndex: -1,
|
|
1203
|
+
onBlur: (e) => {
|
|
1204
|
+
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1205
|
+
handleEditComplete();
|
|
1206
|
+
}
|
|
1207
|
+
},
|
|
1208
|
+
onClick: (e) => {
|
|
1209
|
+
setJsonReadOnly(false);
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
1212
|
+
/* @__PURE__ */ React7.createElement(
|
|
1213
|
+
JsonViewer,
|
|
1214
|
+
{
|
|
1215
|
+
ref: JsonViewerRef,
|
|
1216
|
+
value: getValueType(value) === "string" ? value : "",
|
|
1217
|
+
height: 120,
|
|
1218
|
+
width: "100%",
|
|
1219
|
+
showSearch: false,
|
|
1220
|
+
options: {
|
|
1221
|
+
readOnly: jsonReadOnly,
|
|
1222
|
+
formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
|
|
1223
|
+
},
|
|
1224
|
+
style: {
|
|
1225
|
+
padding: 0
|
|
1226
|
+
},
|
|
1227
|
+
onChange: handleJsonChange
|
|
1228
|
+
}
|
|
1229
|
+
)
|
|
1230
|
+
)) : /* @__PURE__ */ React7.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React7.createElement(
|
|
1231
|
+
ConstantInput,
|
|
1232
|
+
{
|
|
1233
|
+
value,
|
|
1234
|
+
onChange: (_v) => onChange(_v),
|
|
1235
|
+
schema: schema || { type: "string" },
|
|
1236
|
+
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1237
|
+
}
|
|
1238
|
+
));
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1242
|
+
import React8, { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1243
|
+
import Input2 from "@douyinfe/semi-ui/lib/es/input";
|
|
1244
|
+
function BlurInput(props) {
|
|
1245
|
+
const [value, setValue] = useState3("");
|
|
1246
|
+
useEffect2(() => {
|
|
1247
|
+
setValue(props.value);
|
|
1248
|
+
}, [props.value]);
|
|
1249
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1250
|
+
Input2,
|
|
1251
|
+
{
|
|
1252
|
+
...props,
|
|
1253
|
+
value,
|
|
1254
|
+
onChange: (value2) => {
|
|
1255
|
+
setValue(value2);
|
|
1256
|
+
},
|
|
1257
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1258
|
+
}
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// src/components/json-schema-editor/index.tsx
|
|
1263
|
+
function JsonSchemaEditor(props) {
|
|
1264
|
+
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
1265
|
+
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1266
|
+
value,
|
|
1267
|
+
onChangeProps
|
|
1268
|
+
);
|
|
1269
|
+
return /* @__PURE__ */ React9.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React9.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
|
|
1270
|
+
PropertyEdit,
|
|
1271
|
+
{
|
|
1272
|
+
key: _property.key,
|
|
1273
|
+
value: _property,
|
|
1274
|
+
config,
|
|
1275
|
+
$index: index,
|
|
1276
|
+
onChange: (_v) => {
|
|
1277
|
+
onEditProperty(_property.key, _v);
|
|
1278
|
+
},
|
|
1279
|
+
onRemove: () => {
|
|
1280
|
+
onRemoveProperty(_property.key);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
))), /* @__PURE__ */ React9.createElement(
|
|
1284
|
+
Button2,
|
|
1285
|
+
{
|
|
1286
|
+
size: "small",
|
|
1287
|
+
style: { marginTop: 10, marginLeft: 16 },
|
|
1288
|
+
icon: /* @__PURE__ */ React9.createElement(IconPlus, null),
|
|
1289
|
+
onClick: onAddProperty
|
|
1290
|
+
},
|
|
1291
|
+
config?.addButtonText ?? "Add"
|
|
1292
|
+
));
|
|
1293
|
+
}
|
|
1294
|
+
function PropertyEdit(props) {
|
|
1295
|
+
const {
|
|
1296
|
+
value,
|
|
1297
|
+
config,
|
|
1298
|
+
$level = 0,
|
|
1299
|
+
onChange: onChangeProps,
|
|
1300
|
+
onRemove,
|
|
1301
|
+
$index,
|
|
1302
|
+
$isFirst,
|
|
1303
|
+
$isLast,
|
|
1304
|
+
$parentExpand = false,
|
|
1305
|
+
$parentType = "",
|
|
1306
|
+
$showLine
|
|
1307
|
+
} = props;
|
|
1308
|
+
const [expand, setExpand] = useState4(false);
|
|
1309
|
+
const [collapse, setCollapse] = useState4(false);
|
|
1310
|
+
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1311
|
+
const typeSelectorValue = useMemo5(() => ({ type, items }), [type, items]);
|
|
1312
|
+
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1313
|
+
const onChange = (key, _value) => {
|
|
1314
|
+
onChangeProps?.({
|
|
1315
|
+
...value || {},
|
|
1316
|
+
[key]: _value
|
|
1317
|
+
});
|
|
1318
|
+
};
|
|
1319
|
+
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
1320
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
1321
|
+
UIPropertyLeft,
|
|
1322
|
+
{
|
|
1323
|
+
type,
|
|
1324
|
+
$index,
|
|
1325
|
+
$isFirst,
|
|
1326
|
+
$isLast,
|
|
1327
|
+
$showLine,
|
|
1328
|
+
$isExpand: expand,
|
|
1329
|
+
$parentExpand,
|
|
1330
|
+
$parentType
|
|
1331
|
+
},
|
|
1332
|
+
showCollapse && /* @__PURE__ */ React9.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React9.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconChevronRight, { size: "small" }))
|
|
1333
|
+
), /* @__PURE__ */ React9.createElement(UIPropertyRight, null, /* @__PURE__ */ React9.createElement(
|
|
1334
|
+
UIPropertyMain,
|
|
1335
|
+
{
|
|
1336
|
+
$showCollapse: showCollapse,
|
|
1337
|
+
$collapse: collapse,
|
|
1338
|
+
$expand: expand,
|
|
1339
|
+
type
|
|
1340
|
+
},
|
|
1341
|
+
/* @__PURE__ */ React9.createElement(UIRow, null, /* @__PURE__ */ React9.createElement(UIName, null, /* @__PURE__ */ React9.createElement(
|
|
1342
|
+
BlurInput,
|
|
1343
|
+
{
|
|
1344
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1345
|
+
size: "small",
|
|
1346
|
+
value: name,
|
|
1347
|
+
onChange: (value2) => onChange("name", value2)
|
|
1348
|
+
}
|
|
1349
|
+
)), /* @__PURE__ */ React9.createElement(UIType, null, /* @__PURE__ */ React9.createElement(
|
|
1350
|
+
TypeSelector,
|
|
1351
|
+
{
|
|
1352
|
+
value: typeSelectorValue,
|
|
1353
|
+
onChange: (_value) => {
|
|
1354
|
+
onChangeProps?.({
|
|
1355
|
+
...value || {},
|
|
1356
|
+
..._value
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
)), /* @__PURE__ */ React9.createElement(UIRequired, null, /* @__PURE__ */ React9.createElement(
|
|
1361
|
+
Checkbox,
|
|
1362
|
+
{
|
|
1363
|
+
checked: isPropertyRequired,
|
|
1364
|
+
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1365
|
+
}
|
|
1366
|
+
)), /* @__PURE__ */ React9.createElement(UIActions, null, /* @__PURE__ */ React9.createElement(
|
|
1367
|
+
IconButton2,
|
|
1368
|
+
{
|
|
1369
|
+
size: "small",
|
|
1370
|
+
theme: "borderless",
|
|
1371
|
+
icon: expand ? /* @__PURE__ */ React9.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconExpand, { size: "small" }),
|
|
1372
|
+
onClick: () => {
|
|
1373
|
+
setExpand((_expand) => !_expand);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
), isDrilldownObject && /* @__PURE__ */ React9.createElement(
|
|
1377
|
+
IconButton2,
|
|
1378
|
+
{
|
|
1379
|
+
size: "small",
|
|
1380
|
+
theme: "borderless",
|
|
1381
|
+
icon: /* @__PURE__ */ React9.createElement(IconAddChildren, null),
|
|
1382
|
+
onClick: () => {
|
|
1383
|
+
onAddProperty();
|
|
1384
|
+
setCollapse(true);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
), /* @__PURE__ */ React9.createElement(
|
|
1388
|
+
IconButton2,
|
|
1389
|
+
{
|
|
1390
|
+
size: "small",
|
|
1391
|
+
theme: "borderless",
|
|
1392
|
+
icon: /* @__PURE__ */ React9.createElement(IconMinus, { size: "small" }),
|
|
1393
|
+
onClick: onRemove
|
|
1394
|
+
}
|
|
1395
|
+
))),
|
|
1396
|
+
expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React9.createElement(
|
|
1397
|
+
BlurInput,
|
|
1398
|
+
{
|
|
1399
|
+
size: "small",
|
|
1400
|
+
value: description,
|
|
1401
|
+
onChange: (value2) => onChange("description", value2),
|
|
1402
|
+
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1403
|
+
}
|
|
1404
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React9.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React9.createElement(
|
|
1405
|
+
DefaultValue,
|
|
1406
|
+
{
|
|
1407
|
+
value: defaultValue,
|
|
1408
|
+
schema: value,
|
|
1409
|
+
type,
|
|
1410
|
+
placeholder: config?.defaultValuePlaceholder,
|
|
1411
|
+
jsonFormatText: config?.jsonFormatText,
|
|
1412
|
+
onChange: (value2) => onChange("default", value2)
|
|
1413
|
+
}
|
|
1414
|
+
))))
|
|
1415
|
+
), showCollapse && /* @__PURE__ */ React9.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React9.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
|
|
1416
|
+
PropertyEdit,
|
|
1417
|
+
{
|
|
1418
|
+
key: _property.key,
|
|
1419
|
+
value: _property,
|
|
1420
|
+
config,
|
|
1421
|
+
$level: $level + 1,
|
|
1422
|
+
$parentExpand: expand,
|
|
1423
|
+
$parentType: type,
|
|
1424
|
+
onChange: (_v) => {
|
|
1425
|
+
onEditProperty(_property.key, _v);
|
|
1426
|
+
},
|
|
1427
|
+
onRemove: () => {
|
|
1428
|
+
onRemoveProperty(_property.key);
|
|
1429
|
+
},
|
|
1430
|
+
$isLast: index === propertyList.length - 1,
|
|
1431
|
+
$isFirst: index === 0,
|
|
1432
|
+
$index: index,
|
|
1433
|
+
$showLine: true
|
|
1434
|
+
}
|
|
1435
|
+
))))));
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// src/components/batch-variable-selector/index.tsx
|
|
1439
|
+
import React10 from "react";
|
|
1440
|
+
import { PrivateScopeProvider } from "@flowgram.ai/editor";
|
|
1441
|
+
var batchVariableSchema = {
|
|
1442
|
+
type: "array",
|
|
1443
|
+
extra: { weak: true }
|
|
1444
|
+
};
|
|
1445
|
+
function BatchVariableSelector(props) {
|
|
1446
|
+
return /* @__PURE__ */ React10.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React10.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
// src/components/dynamic-value-input/index.tsx
|
|
1450
|
+
import React11, { useMemo as useMemo6 } from "react";
|
|
1451
|
+
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1452
|
+
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1453
|
+
|
|
1454
|
+
// src/components/dynamic-value-input/styles.tsx
|
|
1455
|
+
import styled3 from "styled-components";
|
|
1456
|
+
var UIContainer2 = styled3.div`
|
|
1457
|
+
display: flex;
|
|
1458
|
+
align-items: center;
|
|
1459
|
+
gap: 5px;
|
|
1460
|
+
`;
|
|
1461
|
+
var UIMain = styled3.div`
|
|
1462
|
+
flex-grow: 1;
|
|
1463
|
+
overflow: hidden;
|
|
1464
|
+
min-width: 0;
|
|
1465
|
+
|
|
1466
|
+
& .semi-tree-select,
|
|
1467
|
+
& .semi-input-number,
|
|
1468
|
+
& .semi-select {
|
|
1469
|
+
width: 100%;
|
|
1470
|
+
}
|
|
1471
|
+
`;
|
|
1472
|
+
var UITrigger = styled3.div``;
|
|
1473
|
+
|
|
1474
|
+
// src/components/dynamic-value-input/index.tsx
|
|
1475
|
+
function DynamicValueInput({
|
|
1476
|
+
value,
|
|
1477
|
+
onChange,
|
|
1478
|
+
readonly,
|
|
1479
|
+
style,
|
|
1480
|
+
schema,
|
|
1481
|
+
constantProps
|
|
1482
|
+
}) {
|
|
1483
|
+
const includeSchema = useMemo6(() => {
|
|
1484
|
+
if (schema?.type === "number") {
|
|
1485
|
+
return [schema, { type: "integer" }];
|
|
1486
|
+
}
|
|
1487
|
+
return schema;
|
|
1488
|
+
}, [schema]);
|
|
1489
|
+
const renderMain = () => {
|
|
1490
|
+
if (value?.type === "ref") {
|
|
1491
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1492
|
+
VariableSelector,
|
|
1493
|
+
{
|
|
1494
|
+
style: { width: "100%" },
|
|
1495
|
+
value: value?.content,
|
|
1496
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1497
|
+
includeSchema,
|
|
1498
|
+
readonly
|
|
1499
|
+
}
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1503
|
+
ConstantInput,
|
|
1504
|
+
{
|
|
1505
|
+
value: value?.content,
|
|
1506
|
+
onChange: (_v) => onChange({ type: "constant", content: _v }),
|
|
1507
|
+
schema: schema || { type: "string" },
|
|
1508
|
+
readonly,
|
|
1509
|
+
...constantProps
|
|
1510
|
+
}
|
|
1511
|
+
);
|
|
1512
|
+
};
|
|
1513
|
+
const renderTrigger = () => /* @__PURE__ */ React11.createElement(
|
|
1514
|
+
VariableSelector,
|
|
1515
|
+
{
|
|
1516
|
+
style: { width: "100%" },
|
|
1517
|
+
value: value?.type === "ref" ? value?.content : void 0,
|
|
1518
|
+
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1519
|
+
includeSchema,
|
|
1520
|
+
readonly,
|
|
1521
|
+
triggerRender: () => /* @__PURE__ */ React11.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React11.createElement(IconSetting, { size: "small" }) })
|
|
1522
|
+
}
|
|
1523
|
+
);
|
|
1524
|
+
return /* @__PURE__ */ React11.createElement(UIContainer2, { style }, /* @__PURE__ */ React11.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React11.createElement(UITrigger, null, renderTrigger()));
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// src/components/condition-row/index.tsx
|
|
1528
|
+
import React13, { useMemo as useMemo9 } from "react";
|
|
1529
|
+
import { Input as Input3 } from "@douyinfe/semi-ui";
|
|
1530
|
+
|
|
1531
|
+
// src/components/condition-row/styles.tsx
|
|
1532
|
+
import styled4 from "styled-components";
|
|
1533
|
+
var UIContainer3 = styled4.div`
|
|
1534
|
+
display: flex;
|
|
1535
|
+
align-items: center;
|
|
1536
|
+
gap: 4px;
|
|
1537
|
+
`;
|
|
1538
|
+
var UIOperator = styled4.div``;
|
|
1539
|
+
var UILeft = styled4.div`
|
|
1540
|
+
width: 100%;
|
|
1541
|
+
`;
|
|
1542
|
+
var UIRight = styled4.div`
|
|
1543
|
+
width: 100%;
|
|
1544
|
+
`;
|
|
1545
|
+
var UIValues = styled4.div`
|
|
1546
|
+
flex-grow: 1;
|
|
1547
|
+
display: flex;
|
|
1548
|
+
flex-direction: column;
|
|
1549
|
+
align-items: center;
|
|
1550
|
+
gap: 4px;
|
|
1551
|
+
`;
|
|
1552
|
+
|
|
1553
|
+
// src/components/condition-row/hooks/useRule.ts
|
|
1554
|
+
import { useMemo as useMemo7 } from "react";
|
|
1555
|
+
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
1556
|
+
|
|
1557
|
+
// src/components/condition-row/constants.ts
|
|
1558
|
+
var rules = {
|
|
1559
|
+
string: {
|
|
1560
|
+
["eq" /* EQ */]: "string",
|
|
1561
|
+
["neq" /* NEQ */]: "string",
|
|
1562
|
+
["contains" /* CONTAINS */]: "string",
|
|
1563
|
+
["not_contains" /* NOT_CONTAINS */]: "string",
|
|
1564
|
+
["in" /* IN */]: "array",
|
|
1565
|
+
["nin" /* NIN */]: "array",
|
|
1566
|
+
["is_empty" /* IS_EMPTY */]: "string",
|
|
1567
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: "string"
|
|
1568
|
+
},
|
|
1569
|
+
number: {
|
|
1570
|
+
["eq" /* EQ */]: "number",
|
|
1571
|
+
["neq" /* NEQ */]: "number",
|
|
1572
|
+
["gt" /* GT */]: "number",
|
|
1573
|
+
["gte" /* GTE */]: "number",
|
|
1574
|
+
["lt" /* LT */]: "number",
|
|
1575
|
+
["lte" /* LTE */]: "number",
|
|
1576
|
+
["in" /* IN */]: "array",
|
|
1577
|
+
["nin" /* NIN */]: "array",
|
|
1578
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1579
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1580
|
+
},
|
|
1581
|
+
integer: {
|
|
1582
|
+
["eq" /* EQ */]: "number",
|
|
1583
|
+
["neq" /* NEQ */]: "number",
|
|
1584
|
+
["gt" /* GT */]: "number",
|
|
1585
|
+
["gte" /* GTE */]: "number",
|
|
1586
|
+
["lt" /* LT */]: "number",
|
|
1587
|
+
["lte" /* LTE */]: "number",
|
|
1588
|
+
["in" /* IN */]: "array",
|
|
1589
|
+
["nin" /* NIN */]: "array",
|
|
1590
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1591
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1592
|
+
},
|
|
1593
|
+
boolean: {
|
|
1594
|
+
["eq" /* EQ */]: "boolean",
|
|
1595
|
+
["neq" /* NEQ */]: "boolean",
|
|
1596
|
+
["is_true" /* IS_TRUE */]: null,
|
|
1597
|
+
["is_false" /* IS_FALSE */]: null,
|
|
1598
|
+
["in" /* IN */]: "array",
|
|
1599
|
+
["nin" /* NIN */]: "array",
|
|
1600
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1601
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1602
|
+
},
|
|
1603
|
+
object: {
|
|
1604
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1605
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1606
|
+
},
|
|
1607
|
+
array: {
|
|
1608
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1609
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1610
|
+
},
|
|
1611
|
+
map: {
|
|
1612
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1613
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
var opConfigs = {
|
|
1617
|
+
["eq" /* EQ */]: {
|
|
1618
|
+
label: "Equal",
|
|
1619
|
+
abbreviation: "="
|
|
1620
|
+
},
|
|
1621
|
+
["neq" /* NEQ */]: {
|
|
1622
|
+
label: "Not Equal",
|
|
1623
|
+
abbreviation: "\u2260"
|
|
1624
|
+
},
|
|
1625
|
+
["gt" /* GT */]: {
|
|
1626
|
+
label: "Greater Than",
|
|
1627
|
+
abbreviation: ">"
|
|
1628
|
+
},
|
|
1629
|
+
["gte" /* GTE */]: {
|
|
1630
|
+
label: "Greater Than or Equal",
|
|
1631
|
+
abbreviation: ">="
|
|
1632
|
+
},
|
|
1633
|
+
["lt" /* LT */]: {
|
|
1634
|
+
label: "Less Than",
|
|
1635
|
+
abbreviation: "<"
|
|
1636
|
+
},
|
|
1637
|
+
["lte" /* LTE */]: {
|
|
1638
|
+
label: "Less Than or Equal",
|
|
1639
|
+
abbreviation: "<="
|
|
1640
|
+
},
|
|
1641
|
+
["in" /* IN */]: {
|
|
1642
|
+
label: "In",
|
|
1643
|
+
abbreviation: "\u2208"
|
|
1644
|
+
},
|
|
1645
|
+
["nin" /* NIN */]: {
|
|
1646
|
+
label: "Not In",
|
|
1647
|
+
abbreviation: "\u2209"
|
|
1648
|
+
},
|
|
1649
|
+
["contains" /* CONTAINS */]: {
|
|
1650
|
+
label: "Contains",
|
|
1651
|
+
abbreviation: "\u2287"
|
|
1652
|
+
},
|
|
1653
|
+
["not_contains" /* NOT_CONTAINS */]: {
|
|
1654
|
+
label: "Not Contains",
|
|
1655
|
+
abbreviation: "\u2289"
|
|
1656
|
+
},
|
|
1657
|
+
["is_empty" /* IS_EMPTY */]: {
|
|
1658
|
+
label: "Is Empty",
|
|
1659
|
+
abbreviation: "=",
|
|
1660
|
+
rightDisplay: "Empty"
|
|
1661
|
+
},
|
|
1662
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: {
|
|
1663
|
+
label: "Is Not Empty",
|
|
1664
|
+
abbreviation: "\u2260",
|
|
1665
|
+
rightDisplay: "Empty"
|
|
1666
|
+
},
|
|
1667
|
+
["is_true" /* IS_TRUE */]: {
|
|
1668
|
+
label: "Is True",
|
|
1669
|
+
abbreviation: "=",
|
|
1670
|
+
rightDisplay: "True"
|
|
1671
|
+
},
|
|
1672
|
+
["is_false" /* IS_FALSE */]: {
|
|
1673
|
+
label: "Is False",
|
|
1674
|
+
abbreviation: "=",
|
|
1675
|
+
rightDisplay: "False"
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1679
|
+
// src/utils/format-legacy-refs/index.ts
|
|
1680
|
+
import { isObject } from "lodash";
|
|
1681
|
+
function formatLegacyRefOnSubmit(value) {
|
|
1682
|
+
if (isObject(value)) {
|
|
1683
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
1684
|
+
return formatLegacyRefToNewRef(value);
|
|
1685
|
+
}
|
|
1686
|
+
return Object.fromEntries(
|
|
1687
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1688
|
+
key,
|
|
1689
|
+
formatLegacyRefOnSubmit(value2)
|
|
1690
|
+
])
|
|
1691
|
+
);
|
|
1692
|
+
}
|
|
1693
|
+
if (Array.isArray(value)) {
|
|
1694
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
1695
|
+
}
|
|
1696
|
+
return value;
|
|
1697
|
+
}
|
|
1698
|
+
function formatLegacyRefOnInit(value) {
|
|
1699
|
+
if (isObject(value)) {
|
|
1700
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
1701
|
+
return formatNewRefToLegacyRef(value);
|
|
1702
|
+
}
|
|
1703
|
+
return Object.fromEntries(
|
|
1704
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1705
|
+
key,
|
|
1706
|
+
formatLegacyRefOnInit(value2)
|
|
1707
|
+
])
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
if (Array.isArray(value)) {
|
|
1711
|
+
return value.map(formatLegacyRefOnInit);
|
|
1712
|
+
}
|
|
1713
|
+
return value;
|
|
1714
|
+
}
|
|
1715
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
1716
|
+
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1717
|
+
}
|
|
1718
|
+
function isNewFlowRefValueSchema(value) {
|
|
1719
|
+
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1720
|
+
}
|
|
1721
|
+
function formatLegacyRefToNewRef(value) {
|
|
1722
|
+
const keyPath = value.content.split(".");
|
|
1723
|
+
if (keyPath[1] === "outputs") {
|
|
1724
|
+
return {
|
|
1725
|
+
type: "ref",
|
|
1726
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
return {
|
|
1730
|
+
type: "ref",
|
|
1731
|
+
content: keyPath
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
function formatNewRefToLegacyRef(value) {
|
|
1735
|
+
return {
|
|
1736
|
+
type: "ref",
|
|
1737
|
+
content: value.content.join(".")
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
// src/components/condition-row/hooks/useRule.ts
|
|
1742
|
+
function useRule(left) {
|
|
1743
|
+
const available = useScopeAvailable();
|
|
1744
|
+
const variable = useMemo7(() => {
|
|
1745
|
+
if (!left) return void 0;
|
|
1746
|
+
return available.getByKeyPath(left.content);
|
|
1747
|
+
}, [available, left]);
|
|
1748
|
+
const rule = useMemo7(() => {
|
|
1749
|
+
if (!variable) return void 0;
|
|
1750
|
+
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1751
|
+
return rules[schema?.type];
|
|
1752
|
+
}, [variable?.type]);
|
|
1753
|
+
return { rule };
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
// src/components/condition-row/hooks/useOp.tsx
|
|
1757
|
+
import React12, { useMemo as useMemo8 } from "react";
|
|
1758
|
+
import { Button as Button3, Select as Select2 } from "@douyinfe/semi-ui";
|
|
1759
|
+
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1760
|
+
function useOp({ rule, op, onChange }) {
|
|
1761
|
+
const options2 = useMemo8(
|
|
1762
|
+
() => Object.keys(rule || {}).map((_op) => ({
|
|
1763
|
+
...opConfigs[_op] || {},
|
|
1764
|
+
value: _op
|
|
1765
|
+
})),
|
|
1766
|
+
[rule]
|
|
1767
|
+
);
|
|
1768
|
+
const opConfig = useMemo8(() => opConfigs[op], [op]);
|
|
1769
|
+
const renderOpSelect = () => /* @__PURE__ */ React12.createElement(
|
|
1770
|
+
Select2,
|
|
1771
|
+
{
|
|
1772
|
+
style: { height: 22 },
|
|
1773
|
+
size: "small",
|
|
1774
|
+
value: op,
|
|
1775
|
+
optionList: options2,
|
|
1776
|
+
onChange: (v) => {
|
|
1777
|
+
onChange(v);
|
|
1778
|
+
},
|
|
1779
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1782
|
+
return { renderOpSelect, opConfig };
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
// src/components/condition-row/index.tsx
|
|
1786
|
+
function ConditionRow({ style, value, onChange, readonly }) {
|
|
1787
|
+
const { left, operator, right } = value || {};
|
|
1788
|
+
const { rule } = useRule(left);
|
|
1789
|
+
const { renderOpSelect, opConfig } = useOp({
|
|
1790
|
+
rule,
|
|
1791
|
+
op: operator,
|
|
1792
|
+
onChange: (v) => onChange({ ...value, operator: v })
|
|
1793
|
+
});
|
|
1794
|
+
const targetSchema = useMemo9(() => {
|
|
1795
|
+
const targetType = rule?.[operator] || null;
|
|
1796
|
+
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1797
|
+
}, [rule, opConfig]);
|
|
1798
|
+
return /* @__PURE__ */ React13.createElement(UIContainer3, { style }, /* @__PURE__ */ React13.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React13.createElement(UIValues, null, /* @__PURE__ */ React13.createElement(UILeft, null, /* @__PURE__ */ React13.createElement(
|
|
1799
|
+
VariableSelector,
|
|
1800
|
+
{
|
|
1801
|
+
readonly,
|
|
1802
|
+
style: { width: "100%" },
|
|
1803
|
+
value: left?.content,
|
|
1804
|
+
onChange: (v) => onChange({
|
|
1805
|
+
...value,
|
|
1806
|
+
left: {
|
|
1807
|
+
type: "ref",
|
|
1808
|
+
content: v
|
|
1809
|
+
}
|
|
1810
|
+
})
|
|
1811
|
+
}
|
|
1812
|
+
)), /* @__PURE__ */ React13.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React13.createElement(
|
|
1813
|
+
DynamicValueInput,
|
|
1814
|
+
{
|
|
1815
|
+
readonly: readonly || !rule,
|
|
1816
|
+
value: right,
|
|
1817
|
+
schema: targetSchema,
|
|
1818
|
+
onChange: (v) => onChange({ ...value, right: v })
|
|
1819
|
+
}
|
|
1820
|
+
) : /* @__PURE__ */ React13.createElement(
|
|
1821
|
+
Input3,
|
|
1822
|
+
{
|
|
1823
|
+
size: "small",
|
|
1824
|
+
disabled: true,
|
|
1825
|
+
style: { pointerEvents: "none" },
|
|
1826
|
+
value: opConfig?.rightDisplay || "Empty"
|
|
1827
|
+
}
|
|
1828
|
+
))));
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
// src/components/batch-outputs/index.tsx
|
|
1832
|
+
import React14 from "react";
|
|
1833
|
+
import { Button as Button4, Input as Input4 } from "@douyinfe/semi-ui";
|
|
1834
|
+
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1835
|
+
|
|
1836
|
+
// src/components/batch-outputs/use-list.ts
|
|
1837
|
+
import { useEffect as useEffect3, useState as useState5 } from "react";
|
|
1838
|
+
import { difference } from "lodash";
|
|
1839
|
+
var _id2 = 0;
|
|
1840
|
+
function genId2() {
|
|
1841
|
+
return _id2++;
|
|
1842
|
+
}
|
|
1843
|
+
function useList({ value, onChange }) {
|
|
1844
|
+
const [list, setList] = useState5([]);
|
|
1845
|
+
useEffect3(() => {
|
|
1846
|
+
setList((_prevList) => {
|
|
1847
|
+
const newKeys = Object.keys(value || {});
|
|
1848
|
+
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1849
|
+
const addKeys = difference(newKeys, oldKeys);
|
|
1850
|
+
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1851
|
+
id: item.id,
|
|
1852
|
+
key: item.key,
|
|
1853
|
+
value: item.key ? value?.[item.key] : void 0
|
|
1854
|
+
})).concat(
|
|
1855
|
+
addKeys.map((_key) => ({
|
|
1856
|
+
id: genId2(),
|
|
1857
|
+
key: _key,
|
|
1858
|
+
value: value?.[_key]
|
|
1859
|
+
}))
|
|
1860
|
+
);
|
|
1861
|
+
});
|
|
1862
|
+
}, [value]);
|
|
1863
|
+
const add = () => {
|
|
1864
|
+
setList((prevList) => [
|
|
1865
|
+
...prevList,
|
|
1866
|
+
{
|
|
1867
|
+
id: genId2()
|
|
1868
|
+
}
|
|
1869
|
+
]);
|
|
1870
|
+
};
|
|
1871
|
+
const update = (item) => {
|
|
1872
|
+
setList((prevList) => {
|
|
1873
|
+
const nextList = prevList.map((_item) => {
|
|
1874
|
+
if (_item.id === item.id) {
|
|
1875
|
+
return item;
|
|
1876
|
+
}
|
|
1877
|
+
return _item;
|
|
1878
|
+
});
|
|
1879
|
+
onChange(
|
|
1880
|
+
Object.fromEntries(
|
|
1881
|
+
nextList.filter((item2) => item2.key).map((item2) => [item2.key, item2.value])
|
|
1882
|
+
)
|
|
1883
|
+
);
|
|
1884
|
+
return nextList;
|
|
1885
|
+
});
|
|
1886
|
+
};
|
|
1887
|
+
const remove = (itemId) => {
|
|
1888
|
+
setList((prevList) => {
|
|
1889
|
+
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
1890
|
+
onChange(
|
|
1891
|
+
Object.fromEntries(
|
|
1892
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1893
|
+
)
|
|
1894
|
+
);
|
|
1895
|
+
return nextList;
|
|
1896
|
+
});
|
|
1897
|
+
};
|
|
1898
|
+
return { list, add, update, remove };
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
// src/components/batch-outputs/styles.tsx
|
|
1902
|
+
import styled5 from "styled-components";
|
|
1903
|
+
var UIRows = styled5.div`
|
|
1904
|
+
display: flex;
|
|
1905
|
+
flex-direction: column;
|
|
1906
|
+
gap: 10px;
|
|
1907
|
+
margin-bottom: 10px;
|
|
1908
|
+
`;
|
|
1909
|
+
var UIRow2 = styled5.div`
|
|
1910
|
+
display: flex;
|
|
1911
|
+
align-items: center;
|
|
1912
|
+
gap: 5px;
|
|
1913
|
+
`;
|
|
1914
|
+
|
|
1915
|
+
// src/components/batch-outputs/index.tsx
|
|
1916
|
+
function BatchOutputs(props) {
|
|
1917
|
+
const { readonly, style } = props;
|
|
1918
|
+
const { list, add, update, remove } = useList(props);
|
|
1919
|
+
return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React14.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React14.createElement(
|
|
1920
|
+
Input4,
|
|
1921
|
+
{
|
|
1922
|
+
style: { width: 100 },
|
|
1923
|
+
disabled: readonly,
|
|
1924
|
+
size: "small",
|
|
1925
|
+
value: item.key,
|
|
1926
|
+
onChange: (v) => update({ ...item, key: v })
|
|
1927
|
+
}
|
|
1928
|
+
), /* @__PURE__ */ React14.createElement(
|
|
1929
|
+
VariableSelector,
|
|
1930
|
+
{
|
|
1931
|
+
style: { flexGrow: 1 },
|
|
1932
|
+
readonly,
|
|
1933
|
+
value: item.value?.content,
|
|
1934
|
+
onChange: (v) => update({
|
|
1935
|
+
...item,
|
|
1936
|
+
value: {
|
|
1937
|
+
type: "ref",
|
|
1938
|
+
content: v
|
|
1939
|
+
}
|
|
1940
|
+
})
|
|
1941
|
+
}
|
|
1942
|
+
), /* @__PURE__ */ React14.createElement(
|
|
1943
|
+
Button4,
|
|
1944
|
+
{
|
|
1945
|
+
disabled: readonly,
|
|
1946
|
+
icon: /* @__PURE__ */ React14.createElement(IconDelete, null),
|
|
1947
|
+
size: "small",
|
|
1948
|
+
onClick: () => remove(item.id)
|
|
1949
|
+
}
|
|
1950
|
+
)))), /* @__PURE__ */ React14.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
// src/components/prompt-editor/index.tsx
|
|
1954
|
+
import React15, { useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
1955
|
+
import { Renderer, EditorProvider, ActiveLinePlaceholder } from "@coze-editor/editor/react";
|
|
1956
|
+
import preset from "@coze-editor/editor/preset-prompt";
|
|
1957
|
+
|
|
1958
|
+
// src/components/prompt-editor/styles.tsx
|
|
1959
|
+
import styled6, { css as css2 } from "styled-components";
|
|
1960
|
+
var UIContainer4 = styled6.div`
|
|
1961
|
+
background-color: var(--semi-color-fill-0);
|
|
1962
|
+
padding-left: 10px;
|
|
1963
|
+
padding-right: 6px;
|
|
1964
|
+
|
|
1965
|
+
${({ $hasError }) => $hasError && css2`
|
|
1966
|
+
border: 1px solid var(--semi-color-danger-6);
|
|
1967
|
+
`}
|
|
1968
|
+
`;
|
|
1969
|
+
|
|
1970
|
+
// src/components/prompt-editor/extensions/markdown.tsx
|
|
1971
|
+
import { useLayoutEffect } from "react";
|
|
1972
|
+
import { useInjector } from "@coze-editor/editor/react";
|
|
1973
|
+
import { astDecorator } from "@coze-editor/editor";
|
|
1974
|
+
import { EditorView } from "@codemirror/view";
|
|
1975
|
+
function MarkdownHighlight() {
|
|
1976
|
+
const injector = useInjector();
|
|
1977
|
+
useLayoutEffect(
|
|
1978
|
+
() => injector.inject([
|
|
1979
|
+
astDecorator.whole.of((cursor) => {
|
|
1980
|
+
if (cursor.name.startsWith("ATXHeading")) {
|
|
1981
|
+
return {
|
|
1982
|
+
type: "className",
|
|
1983
|
+
className: "heading"
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
if (cursor.name === "Emphasis") {
|
|
1987
|
+
return {
|
|
1988
|
+
type: "className",
|
|
1989
|
+
className: "emphasis"
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
if (cursor.name === "StrongEmphasis") {
|
|
1993
|
+
return {
|
|
1994
|
+
type: "className",
|
|
1995
|
+
className: "strong-emphasis"
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
|
|
1999
|
+
return {
|
|
2000
|
+
type: "className",
|
|
2001
|
+
className: "mark"
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
}),
|
|
2005
|
+
EditorView.theme({
|
|
2006
|
+
".heading": {
|
|
2007
|
+
color: "#00818C",
|
|
2008
|
+
fontWeight: "bold"
|
|
2009
|
+
},
|
|
2010
|
+
".emphasis": {
|
|
2011
|
+
fontStyle: "italic"
|
|
2012
|
+
},
|
|
2013
|
+
".strong-emphasis": {
|
|
2014
|
+
fontWeight: "bold"
|
|
2015
|
+
},
|
|
2016
|
+
".mark": {
|
|
2017
|
+
color: "#4E40E5"
|
|
2018
|
+
}
|
|
2019
|
+
})
|
|
2020
|
+
]),
|
|
2021
|
+
[injector]
|
|
2022
|
+
);
|
|
2023
|
+
return null;
|
|
2024
|
+
}
|
|
2025
|
+
var markdown_default = MarkdownHighlight;
|
|
2026
|
+
|
|
2027
|
+
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2028
|
+
import { useLayoutEffect as useLayoutEffect2 } from "react";
|
|
2029
|
+
import { useInjector as useInjector2 } from "@coze-editor/editor/react";
|
|
2030
|
+
import { languageSupport } from "@coze-editor/editor/preset-prompt";
|
|
2031
|
+
function LanguageSupport() {
|
|
2032
|
+
const injector = useInjector2();
|
|
2033
|
+
useLayoutEffect2(() => injector.inject([languageSupport]), [injector]);
|
|
2034
|
+
return null;
|
|
2035
|
+
}
|
|
2036
|
+
var language_support_default = LanguageSupport;
|
|
2037
|
+
|
|
2038
|
+
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2039
|
+
import { useLayoutEffect as useLayoutEffect3 } from "react";
|
|
2040
|
+
import { useInjector as useInjector3 } from "@coze-editor/editor/react";
|
|
2041
|
+
import { astDecorator as astDecorator2 } from "@coze-editor/editor";
|
|
2042
|
+
import { EditorView as EditorView2 } from "@codemirror/view";
|
|
2043
|
+
function JinjaHighlight() {
|
|
2044
|
+
const injector = useInjector3();
|
|
2045
|
+
useLayoutEffect3(
|
|
2046
|
+
() => injector.inject([
|
|
2047
|
+
astDecorator2.whole.of((cursor) => {
|
|
2048
|
+
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2049
|
+
return {
|
|
2050
|
+
type: "className",
|
|
2051
|
+
className: "jinja-statement-bracket"
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
if (cursor.name === "JinjaComment") {
|
|
2055
|
+
return {
|
|
2056
|
+
type: "className",
|
|
2057
|
+
className: "jinja-comment"
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
if (cursor.name === "JinjaExpression") {
|
|
2061
|
+
return {
|
|
2062
|
+
type: "className",
|
|
2063
|
+
className: "jinja-expression"
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
}),
|
|
2067
|
+
EditorView2.theme({
|
|
2068
|
+
".jinja-statement-bracket": {
|
|
2069
|
+
color: "#D1009D"
|
|
2070
|
+
},
|
|
2071
|
+
".jinja-comment": {
|
|
2072
|
+
color: "#0607094D"
|
|
2073
|
+
},
|
|
2074
|
+
".jinja-expression": {
|
|
2075
|
+
color: "#4E40E5"
|
|
2076
|
+
}
|
|
2077
|
+
})
|
|
2078
|
+
]),
|
|
2079
|
+
[injector]
|
|
2080
|
+
);
|
|
2081
|
+
return null;
|
|
2082
|
+
}
|
|
2083
|
+
var jinja_default = JinjaHighlight;
|
|
2084
|
+
|
|
2085
|
+
// src/components/prompt-editor/index.tsx
|
|
2086
|
+
function PromptEditor(props) {
|
|
2087
|
+
const {
|
|
2088
|
+
value,
|
|
2089
|
+
onChange,
|
|
2090
|
+
readonly,
|
|
2091
|
+
placeholder,
|
|
2092
|
+
activeLinePlaceholder,
|
|
2093
|
+
style,
|
|
2094
|
+
hasError,
|
|
2095
|
+
children
|
|
2096
|
+
} = props || {};
|
|
2097
|
+
const editorRef = useRef3(null);
|
|
2098
|
+
useEffect4(() => {
|
|
2099
|
+
if (editorRef.current?.getValue() !== value?.content) {
|
|
2100
|
+
editorRef.current?.setValue(String(value?.content || ""));
|
|
2101
|
+
}
|
|
2102
|
+
}, [value]);
|
|
2103
|
+
return /* @__PURE__ */ React15.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React15.createElement(EditorProvider, null, /* @__PURE__ */ React15.createElement(
|
|
2104
|
+
Renderer,
|
|
2105
|
+
{
|
|
2106
|
+
didMount: (editor) => {
|
|
2107
|
+
editorRef.current = editor;
|
|
2108
|
+
},
|
|
2109
|
+
plugins: preset,
|
|
2110
|
+
defaultValue: String(value?.content),
|
|
2111
|
+
options: {
|
|
2112
|
+
readOnly: readonly,
|
|
2113
|
+
editable: !readonly,
|
|
2114
|
+
placeholder
|
|
2115
|
+
},
|
|
2116
|
+
onChange: (e) => {
|
|
2117
|
+
onChange({ type: "template", content: e.value });
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
), activeLinePlaceholder && /* @__PURE__ */ React15.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder), /* @__PURE__ */ React15.createElement(markdown_default, null), /* @__PURE__ */ React15.createElement(language_support_default, null), /* @__PURE__ */ React15.createElement(jinja_default, null), children));
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2124
|
+
import React18 from "react";
|
|
2125
|
+
|
|
2126
|
+
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2127
|
+
import React16, { useEffect as useEffect5, useState as useState6 } from "react";
|
|
2128
|
+
import { Popover, Tree } from "@douyinfe/semi-ui";
|
|
2129
|
+
import {
|
|
2130
|
+
Mention,
|
|
2131
|
+
getCurrentMentionReplaceRange,
|
|
2132
|
+
useEditor,
|
|
2133
|
+
PositionMirror
|
|
2134
|
+
} from "@coze-editor/editor/react";
|
|
2135
|
+
function VariableTree() {
|
|
2136
|
+
const [posKey, setPosKey] = useState6("");
|
|
2137
|
+
const [visible, setVisible] = useState6(false);
|
|
2138
|
+
const [position, setPosition] = useState6(-1);
|
|
2139
|
+
const editor = useEditor();
|
|
2140
|
+
function insert(variablePath) {
|
|
2141
|
+
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
2142
|
+
if (!range) {
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
editor.replaceText({
|
|
2146
|
+
...range,
|
|
2147
|
+
text: "{{" + variablePath + "}}"
|
|
2148
|
+
});
|
|
2149
|
+
setVisible(false);
|
|
2150
|
+
}
|
|
2151
|
+
function handleOpenChange(e) {
|
|
2152
|
+
setPosition(e.state.selection.main.head);
|
|
2153
|
+
setVisible(e.value);
|
|
2154
|
+
}
|
|
2155
|
+
useEffect5(() => {
|
|
2156
|
+
if (!editor) {
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
}, [editor, visible]);
|
|
2160
|
+
const treeData = useVariableTree({});
|
|
2161
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React16.createElement(
|
|
2162
|
+
Popover,
|
|
2163
|
+
{
|
|
2164
|
+
visible,
|
|
2165
|
+
trigger: "custom",
|
|
2166
|
+
position: "topLeft",
|
|
2167
|
+
rePosKey: posKey,
|
|
2168
|
+
content: /* @__PURE__ */ React16.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React16.createElement(
|
|
2169
|
+
Tree,
|
|
2170
|
+
{
|
|
2171
|
+
treeData,
|
|
2172
|
+
onSelect: (v) => {
|
|
2173
|
+
insert(v);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
))
|
|
2177
|
+
},
|
|
2178
|
+
/* @__PURE__ */ React16.createElement(
|
|
2179
|
+
PositionMirror,
|
|
2180
|
+
{
|
|
2181
|
+
position,
|
|
2182
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2183
|
+
}
|
|
2184
|
+
)
|
|
2185
|
+
));
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2189
|
+
import ReactDOM from "react-dom";
|
|
2190
|
+
import React17, { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
2191
|
+
import { isEqual, last } from "lodash";
|
|
2192
|
+
import {
|
|
2193
|
+
Disposable,
|
|
2194
|
+
DisposableCollection,
|
|
2195
|
+
useCurrentScope
|
|
2196
|
+
} from "@flowgram.ai/editor";
|
|
2197
|
+
import { Popover as Popover2 } from "@douyinfe/semi-ui";
|
|
2198
|
+
import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
|
|
2199
|
+
import { useInjector as useInjector4 } from "@coze-editor/editor/react";
|
|
2200
|
+
import {
|
|
2201
|
+
Decoration,
|
|
2202
|
+
EditorView as EditorView3,
|
|
2203
|
+
MatchDecorator,
|
|
2204
|
+
ViewPlugin,
|
|
2205
|
+
WidgetType
|
|
2206
|
+
} from "@codemirror/view";
|
|
2207
|
+
|
|
2208
|
+
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2209
|
+
import styled7 from "styled-components";
|
|
2210
|
+
import { Tag as Tag2 } from "@douyinfe/semi-ui";
|
|
2211
|
+
var UIRootTitle2 = styled7.div`
|
|
2212
|
+
margin-right: 4px;
|
|
2213
|
+
min-width: 20px;
|
|
2214
|
+
overflow: hidden;
|
|
2215
|
+
text-overflow: ellipsis;
|
|
2216
|
+
white-space: nowrap;
|
|
2217
|
+
color: var(--semi-color-text-2);
|
|
2218
|
+
`;
|
|
2219
|
+
var UIVarName2 = styled7.div`
|
|
2220
|
+
overflow: hidden;
|
|
2221
|
+
text-overflow: ellipsis;
|
|
2222
|
+
white-space: nowrap;
|
|
2223
|
+
`;
|
|
2224
|
+
var UITag2 = styled7(Tag2)`
|
|
2225
|
+
display: inline-flex;
|
|
2226
|
+
align-items: center;
|
|
2227
|
+
justify-content: flex-start;
|
|
2228
|
+
max-width: 300px;
|
|
2229
|
+
|
|
2230
|
+
& .semi-tag-content-center {
|
|
2231
|
+
justify-content: flex-start;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
&.semi-tag {
|
|
2235
|
+
margin: 0 5px;
|
|
2236
|
+
}
|
|
2237
|
+
`;
|
|
2238
|
+
var UIPopoverContent = styled7.div`
|
|
2239
|
+
padding: 10px;
|
|
2240
|
+
display: inline-flex;
|
|
2241
|
+
align-items: center;
|
|
2242
|
+
justify-content: flex-start;
|
|
2243
|
+
`;
|
|
2244
|
+
|
|
2245
|
+
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2246
|
+
var VariableTagWidget = class extends WidgetType {
|
|
2247
|
+
constructor({ keyPath, scope }) {
|
|
2248
|
+
super();
|
|
2249
|
+
this.toDispose = new DisposableCollection();
|
|
2250
|
+
this.renderIcon = (icon) => {
|
|
2251
|
+
if (typeof icon === "string") {
|
|
2252
|
+
return /* @__PURE__ */ React17.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2253
|
+
}
|
|
2254
|
+
return icon;
|
|
2255
|
+
};
|
|
2256
|
+
this.keyPath = keyPath;
|
|
2257
|
+
this.scope = scope;
|
|
2258
|
+
}
|
|
2259
|
+
renderReact(jsx) {
|
|
2260
|
+
ReactDOM.render(jsx, this.rootDOM);
|
|
2261
|
+
}
|
|
2262
|
+
renderVariable(v) {
|
|
2263
|
+
if (!v) {
|
|
2264
|
+
this.renderReact(
|
|
2265
|
+
/* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React17.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
|
|
2266
|
+
);
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
const rootField = last(v.parentFields);
|
|
2270
|
+
const rootTitle = /* @__PURE__ */ React17.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2271
|
+
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2272
|
+
this.renderReact(
|
|
2273
|
+
/* @__PURE__ */ React17.createElement(
|
|
2274
|
+
Popover2,
|
|
2275
|
+
{
|
|
2276
|
+
content: /* @__PURE__ */ React17.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2277
|
+
},
|
|
2278
|
+
/* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.key))
|
|
2279
|
+
)
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
toDOM(view) {
|
|
2283
|
+
const dom = document.createElement("span");
|
|
2284
|
+
this.rootDOM = dom;
|
|
2285
|
+
this.toDispose.push(
|
|
2286
|
+
Disposable.create(() => {
|
|
2287
|
+
ReactDOM.unmountComponentAtNode(this.rootDOM);
|
|
2288
|
+
})
|
|
2289
|
+
);
|
|
2290
|
+
this.toDispose.push(
|
|
2291
|
+
this.scope.available.trackByKeyPath(
|
|
2292
|
+
this.keyPath,
|
|
2293
|
+
(v) => {
|
|
2294
|
+
this.renderVariable(v);
|
|
2295
|
+
},
|
|
2296
|
+
{ triggerOnInit: false }
|
|
2297
|
+
)
|
|
2298
|
+
);
|
|
2299
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
2300
|
+
return dom;
|
|
2301
|
+
}
|
|
2302
|
+
eq(other) {
|
|
2303
|
+
return isEqual(this.keyPath, other.keyPath);
|
|
2304
|
+
}
|
|
2305
|
+
ignoreEvent() {
|
|
2306
|
+
return false;
|
|
2307
|
+
}
|
|
2308
|
+
destroy(dom) {
|
|
2309
|
+
this.toDispose.dispose();
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
function VariableTagInject() {
|
|
2313
|
+
const injector = useInjector4();
|
|
2314
|
+
const scope = useCurrentScope();
|
|
2315
|
+
useLayoutEffect4(() => {
|
|
2316
|
+
const atMatcher = new MatchDecorator({
|
|
2317
|
+
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2318
|
+
decoration: (match) => Decoration.replace({
|
|
2319
|
+
widget: new VariableTagWidget({
|
|
2320
|
+
keyPath: match[1]?.split(".") ?? [],
|
|
2321
|
+
scope
|
|
2322
|
+
})
|
|
2323
|
+
})
|
|
2324
|
+
});
|
|
2325
|
+
return injector.inject([
|
|
2326
|
+
ViewPlugin.fromClass(
|
|
2327
|
+
class {
|
|
2328
|
+
constructor(view) {
|
|
2329
|
+
this.view = view;
|
|
2330
|
+
this.decorations = atMatcher.createDeco(view);
|
|
2331
|
+
}
|
|
2332
|
+
update() {
|
|
2333
|
+
this.decorations = atMatcher.createDeco(this.view);
|
|
2334
|
+
}
|
|
2335
|
+
},
|
|
2336
|
+
{
|
|
2337
|
+
decorations: (p) => p.decorations,
|
|
2338
|
+
provide(p) {
|
|
2339
|
+
return EditorView3.atomicRanges.of(
|
|
2340
|
+
(view) => view.plugin(p)?.decorations ?? Decoration.none
|
|
2341
|
+
);
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
)
|
|
2345
|
+
]);
|
|
2346
|
+
}, [injector]);
|
|
2347
|
+
return null;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2351
|
+
function PromptEditorWithVariables(props) {
|
|
2352
|
+
return /* @__PURE__ */ React18.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React18.createElement(VariableTree, null), /* @__PURE__ */ React18.createElement(VariableTagInject, null));
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2356
|
+
import React21 from "react";
|
|
2357
|
+
|
|
2358
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2359
|
+
import React20, { useEffect as useEffect6, useState as useState7 } from "react";
|
|
2360
|
+
import { Popover as Popover3 } from "@douyinfe/semi-ui";
|
|
2361
|
+
import {
|
|
2362
|
+
Mention as Mention2,
|
|
2363
|
+
getCurrentMentionReplaceRange as getCurrentMentionReplaceRange2,
|
|
2364
|
+
useEditor as useEditor2,
|
|
2365
|
+
PositionMirror as PositionMirror2
|
|
2366
|
+
} from "@coze-editor/editor/react";
|
|
2367
|
+
|
|
2368
|
+
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2369
|
+
import React19, { useMemo as useMemo10 } from "react";
|
|
2370
|
+
import { last as last2 } from "lodash";
|
|
2371
|
+
import {
|
|
2372
|
+
ASTMatch as ASTMatch3,
|
|
2373
|
+
useScopeAvailable as useScopeAvailable2
|
|
2374
|
+
} from "@flowgram.ai/editor";
|
|
2375
|
+
import { Tree as Tree2 } from "@douyinfe/semi-ui";
|
|
2376
|
+
function InputsPicker({
|
|
2377
|
+
inputsValues,
|
|
2378
|
+
onSelect
|
|
2379
|
+
}) {
|
|
2380
|
+
const available = useScopeAvailable2();
|
|
2381
|
+
const getArrayDrilldown = (type, depth = 1) => {
|
|
2382
|
+
if (ASTMatch3.isArray(type.items)) {
|
|
2383
|
+
return getArrayDrilldown(type.items, depth + 1);
|
|
2384
|
+
}
|
|
2385
|
+
return { type: type.items, depth };
|
|
2386
|
+
};
|
|
2387
|
+
const renderVariable = (variable, keyPath) => {
|
|
2388
|
+
let type = variable?.type;
|
|
2389
|
+
let children;
|
|
2390
|
+
if (ASTMatch3.isObject(type)) {
|
|
2391
|
+
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2392
|
+
}
|
|
2393
|
+
if (ASTMatch3.isArray(type)) {
|
|
2394
|
+
const drilldown = getArrayDrilldown(type);
|
|
2395
|
+
if (ASTMatch3.isObject(drilldown.type)) {
|
|
2396
|
+
children = (drilldown.type.properties || []).map(
|
|
2397
|
+
(_property) => renderVariable(_property, [
|
|
2398
|
+
...keyPath,
|
|
2399
|
+
...new Array(drilldown.depth).fill("[0]"),
|
|
2400
|
+
_property.key
|
|
2401
|
+
])
|
|
2402
|
+
).filter(Boolean);
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2406
|
+
return {
|
|
2407
|
+
key,
|
|
2408
|
+
label: last2(keyPath),
|
|
2409
|
+
value: key,
|
|
2410
|
+
children
|
|
2411
|
+
};
|
|
2412
|
+
};
|
|
2413
|
+
const treeData = useMemo10(
|
|
2414
|
+
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2415
|
+
if (value.type === "ref") {
|
|
2416
|
+
const variable = available.getByKeyPath(value.content || []);
|
|
2417
|
+
if (variable) {
|
|
2418
|
+
return renderVariable(variable, [key]);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
return {
|
|
2422
|
+
key,
|
|
2423
|
+
value: key,
|
|
2424
|
+
label: key
|
|
2425
|
+
};
|
|
2426
|
+
}),
|
|
2427
|
+
[]
|
|
2428
|
+
);
|
|
2429
|
+
return /* @__PURE__ */ React19.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2433
|
+
function InputsTree({ inputsValues }) {
|
|
2434
|
+
const [posKey, setPosKey] = useState7("");
|
|
2435
|
+
const [visible, setVisible] = useState7(false);
|
|
2436
|
+
const [position, setPosition] = useState7(-1);
|
|
2437
|
+
const editor = useEditor2();
|
|
2438
|
+
function insert(variablePath) {
|
|
2439
|
+
const range = getCurrentMentionReplaceRange2(editor.$view.state);
|
|
2440
|
+
if (!range) {
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
editor.replaceText({
|
|
2444
|
+
...range,
|
|
2445
|
+
text: "{{" + variablePath + "}}"
|
|
2446
|
+
});
|
|
2447
|
+
setVisible(false);
|
|
2448
|
+
}
|
|
2449
|
+
function handleOpenChange(e) {
|
|
2450
|
+
setPosition(e.state.selection.main.head);
|
|
2451
|
+
setVisible(e.value);
|
|
2452
|
+
}
|
|
2453
|
+
useEffect6(() => {
|
|
2454
|
+
if (!editor) {
|
|
2455
|
+
return;
|
|
2456
|
+
}
|
|
2457
|
+
}, [editor, visible]);
|
|
2458
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React20.createElement(
|
|
2459
|
+
Popover3,
|
|
2460
|
+
{
|
|
2461
|
+
visible,
|
|
2462
|
+
trigger: "custom",
|
|
2463
|
+
position: "topLeft",
|
|
2464
|
+
rePosKey: posKey,
|
|
2465
|
+
content: /* @__PURE__ */ React20.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React20.createElement(
|
|
2466
|
+
InputsPicker,
|
|
2467
|
+
{
|
|
2468
|
+
inputsValues,
|
|
2469
|
+
onSelect: (v) => {
|
|
2470
|
+
insert(v);
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
))
|
|
2474
|
+
},
|
|
2475
|
+
/* @__PURE__ */ React20.createElement(
|
|
2476
|
+
PositionMirror2,
|
|
2477
|
+
{
|
|
2478
|
+
position,
|
|
2479
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2480
|
+
}
|
|
2481
|
+
)
|
|
2482
|
+
));
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2486
|
+
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2487
|
+
return /* @__PURE__ */ React21.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React21.createElement(InputsTree, { inputsValues }));
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
// src/components/code-editor/index.tsx
|
|
2491
|
+
import React22, { useEffect as useEffect7, useRef as useRef4 } from "react";
|
|
2492
|
+
import { ActiveLinePlaceholder as ActiveLinePlaceholder2, createRenderer, EditorProvider as EditorProvider2 } from "@coze-editor/editor/react";
|
|
2493
|
+
import preset2 from "@coze-editor/editor/preset-code";
|
|
2494
|
+
import { EditorView as EditorView4 } from "@codemirror/view";
|
|
2495
|
+
|
|
2496
|
+
// src/components/code-editor/utils.ts
|
|
2497
|
+
function getSuffixByLanguageId(languageId) {
|
|
2498
|
+
if (languageId === "python") {
|
|
2499
|
+
return ".py";
|
|
2500
|
+
}
|
|
2501
|
+
if (languageId === "typescript") {
|
|
2502
|
+
return ".ts";
|
|
2503
|
+
}
|
|
2504
|
+
if (languageId === "shell") {
|
|
2505
|
+
return ".sh";
|
|
2506
|
+
}
|
|
2507
|
+
if (languageId === "json") {
|
|
2508
|
+
return ".json";
|
|
2509
|
+
}
|
|
2510
|
+
return "";
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
// src/components/code-editor/theme/index.ts
|
|
2514
|
+
import { themes } from "@coze-editor/editor/preset-code";
|
|
2515
|
+
|
|
2516
|
+
// src/components/code-editor/theme/light.ts
|
|
2517
|
+
import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
|
|
2518
|
+
var colors = {
|
|
2519
|
+
background: "#F7F7FC",
|
|
2520
|
+
// syntax
|
|
2521
|
+
comment: "#000A298A",
|
|
2522
|
+
key: "#00818C",
|
|
2523
|
+
string: "#D1009D",
|
|
2524
|
+
number: "#C74200",
|
|
2525
|
+
boolean: "#2B57D9",
|
|
2526
|
+
null: "#2B57D9",
|
|
2527
|
+
separator: "#0F1529D1"
|
|
2528
|
+
};
|
|
2529
|
+
var lightTheme = createTheme({
|
|
2530
|
+
variant: "light",
|
|
2531
|
+
settings: {
|
|
2532
|
+
background: "#fff",
|
|
2533
|
+
foreground: "#000",
|
|
2534
|
+
caret: "#000",
|
|
2535
|
+
selection: "#d9d9d9",
|
|
2536
|
+
gutterBackground: "#f0f0f0",
|
|
2537
|
+
gutterForeground: "#666",
|
|
2538
|
+
gutterBorderColor: "transparent",
|
|
2539
|
+
gutterBorderWidth: 0,
|
|
2540
|
+
lineHighlight: "#f0f0f0",
|
|
2541
|
+
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2542
|
+
tooltip: {
|
|
2543
|
+
backgroundColor: "#f0f0f0",
|
|
2544
|
+
color: "#000",
|
|
2545
|
+
border: "1px solid #ccc"
|
|
2546
|
+
},
|
|
2547
|
+
link: {
|
|
2548
|
+
color: "#007bff"
|
|
2549
|
+
},
|
|
2550
|
+
completionItemHover: {
|
|
2551
|
+
backgroundColor: "#f0f0f0"
|
|
2552
|
+
},
|
|
2553
|
+
completionItemSelected: {
|
|
2554
|
+
backgroundColor: "#e0e0e0"
|
|
2555
|
+
},
|
|
2556
|
+
completionItemIcon: {
|
|
2557
|
+
color: "#333"
|
|
2558
|
+
},
|
|
2559
|
+
completionItemLabel: {
|
|
2560
|
+
color: "#333"
|
|
2561
|
+
},
|
|
2562
|
+
completionItemInfo: {
|
|
2563
|
+
color: "#333"
|
|
2564
|
+
},
|
|
2565
|
+
completionItemDetail: {
|
|
2566
|
+
color: "#666"
|
|
2567
|
+
}
|
|
2568
|
+
},
|
|
2569
|
+
styles: [
|
|
2570
|
+
// JSON
|
|
2571
|
+
{
|
|
2572
|
+
tag: t.comment,
|
|
2573
|
+
color: colors.comment
|
|
2574
|
+
},
|
|
2575
|
+
{
|
|
2576
|
+
tag: [t.propertyName],
|
|
2577
|
+
color: colors.key
|
|
2578
|
+
},
|
|
2579
|
+
{
|
|
2580
|
+
tag: [t.string],
|
|
2581
|
+
color: colors.string
|
|
2582
|
+
},
|
|
2583
|
+
{
|
|
2584
|
+
tag: [t.number],
|
|
2585
|
+
color: colors.number
|
|
2586
|
+
},
|
|
2587
|
+
{
|
|
2588
|
+
tag: [t.bool],
|
|
2589
|
+
color: colors.boolean
|
|
2590
|
+
},
|
|
2591
|
+
{
|
|
2592
|
+
tag: [t.null],
|
|
2593
|
+
color: colors.null
|
|
2594
|
+
},
|
|
2595
|
+
{
|
|
2596
|
+
tag: [t.separator],
|
|
2597
|
+
color: colors.separator
|
|
2598
|
+
},
|
|
2599
|
+
// markdown
|
|
2600
|
+
{
|
|
2601
|
+
tag: [t.heading],
|
|
2602
|
+
color: "#3e76ef"
|
|
2603
|
+
},
|
|
2604
|
+
{
|
|
2605
|
+
tag: [t.processingInstruction],
|
|
2606
|
+
color: "#3e76ef"
|
|
2607
|
+
},
|
|
2608
|
+
// shell
|
|
2609
|
+
// curl
|
|
2610
|
+
{
|
|
2611
|
+
tag: [t.standard(t.variableName)],
|
|
2612
|
+
color: "#00804A"
|
|
2613
|
+
},
|
|
2614
|
+
// -X
|
|
2615
|
+
{
|
|
2616
|
+
tag: [t.attributeName],
|
|
2617
|
+
color: "#C74200"
|
|
2618
|
+
},
|
|
2619
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
2620
|
+
{
|
|
2621
|
+
tag: [t.special(t.string)],
|
|
2622
|
+
color: "#2B57D9"
|
|
2623
|
+
}
|
|
2624
|
+
]
|
|
2625
|
+
});
|
|
2626
|
+
|
|
2627
|
+
// src/components/code-editor/theme/dark.ts
|
|
2628
|
+
import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
|
|
2629
|
+
var colors2 = {
|
|
2630
|
+
background: "#151B27",
|
|
2631
|
+
// syntax
|
|
2632
|
+
comment: "#FFFFFF63",
|
|
2633
|
+
key: "#39E5D7",
|
|
2634
|
+
string: "#FF94D2",
|
|
2635
|
+
number: "#FF9933",
|
|
2636
|
+
boolean: "#78B0FF",
|
|
2637
|
+
null: "#78B0FF",
|
|
2638
|
+
separator: "#FFFFFFC9"
|
|
2639
|
+
};
|
|
2640
|
+
var darkTheme = createTheme2({
|
|
2641
|
+
variant: "dark",
|
|
2642
|
+
settings: {
|
|
2643
|
+
background: colors2.background,
|
|
2644
|
+
foreground: "#fff",
|
|
2645
|
+
caret: "#AEAFAD",
|
|
2646
|
+
selection: "#d9d9d942",
|
|
2647
|
+
gutterBackground: colors2.background,
|
|
2648
|
+
gutterForeground: "#FFFFFF63",
|
|
2649
|
+
gutterBorderColor: "transparent",
|
|
2650
|
+
gutterBorderWidth: 0,
|
|
2651
|
+
lineHighlight: "#272e3d36",
|
|
2652
|
+
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2653
|
+
tooltip: {
|
|
2654
|
+
backgroundColor: "#363D4D",
|
|
2655
|
+
color: "#fff",
|
|
2656
|
+
border: "none"
|
|
2657
|
+
},
|
|
2658
|
+
link: {
|
|
2659
|
+
color: "#4daafc"
|
|
2660
|
+
},
|
|
2661
|
+
completionItemHover: {
|
|
2662
|
+
backgroundColor: "#FFFFFF0F"
|
|
2663
|
+
},
|
|
2664
|
+
completionItemSelected: {
|
|
2665
|
+
backgroundColor: "#FFFFFF17"
|
|
2666
|
+
},
|
|
2667
|
+
completionItemIcon: {
|
|
2668
|
+
color: "#FFFFFFC9"
|
|
2669
|
+
},
|
|
2670
|
+
completionItemLabel: {
|
|
2671
|
+
color: "#FFFFFFC9"
|
|
2672
|
+
},
|
|
2673
|
+
completionItemInfo: {
|
|
2674
|
+
color: "#FFFFFFC9"
|
|
2675
|
+
},
|
|
2676
|
+
completionItemDetail: {
|
|
2677
|
+
color: "#FFFFFF63"
|
|
2678
|
+
}
|
|
2679
|
+
},
|
|
2680
|
+
styles: [
|
|
2681
|
+
// json
|
|
2682
|
+
{
|
|
2683
|
+
tag: t2.comment,
|
|
2684
|
+
color: colors2.comment
|
|
2685
|
+
},
|
|
2686
|
+
{
|
|
2687
|
+
tag: [t2.propertyName],
|
|
2688
|
+
color: colors2.key
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
tag: [t2.string],
|
|
2692
|
+
color: colors2.string
|
|
2693
|
+
},
|
|
2694
|
+
{
|
|
2695
|
+
tag: [t2.number],
|
|
2696
|
+
color: colors2.number
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
tag: [t2.bool],
|
|
2700
|
+
color: colors2.boolean
|
|
2701
|
+
},
|
|
2702
|
+
{
|
|
2703
|
+
tag: [t2.null],
|
|
2704
|
+
color: colors2.null
|
|
2705
|
+
},
|
|
2706
|
+
{
|
|
2707
|
+
tag: [t2.separator],
|
|
2708
|
+
color: colors2.separator
|
|
2709
|
+
},
|
|
2710
|
+
// markdown
|
|
2711
|
+
{
|
|
2712
|
+
tag: [t2.heading],
|
|
2713
|
+
color: "#6b6bff"
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
tag: [t2.processingInstruction],
|
|
2717
|
+
color: "#6b6bff"
|
|
2718
|
+
},
|
|
2719
|
+
// shell
|
|
2720
|
+
// curl
|
|
2721
|
+
{
|
|
2722
|
+
tag: [t2.standard(t2.variableName)],
|
|
2723
|
+
color: "#3BEB84"
|
|
2724
|
+
},
|
|
2725
|
+
// -X
|
|
2726
|
+
{
|
|
2727
|
+
tag: [t2.attributeName],
|
|
2728
|
+
color: "#FF9933"
|
|
2729
|
+
},
|
|
2730
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
2731
|
+
{
|
|
2732
|
+
tag: [t2.special(t2.string)],
|
|
2733
|
+
color: "#78B0FF"
|
|
2734
|
+
}
|
|
2735
|
+
]
|
|
2736
|
+
});
|
|
2737
|
+
|
|
2738
|
+
// src/components/code-editor/theme/index.ts
|
|
2739
|
+
themes.register("dark", darkTheme);
|
|
2740
|
+
themes.register("light", lightTheme);
|
|
2741
|
+
|
|
2742
|
+
// src/components/code-editor/language-features.ts
|
|
2743
|
+
import { languages } from "@coze-editor/editor/preset-code";
|
|
2744
|
+
import { shell } from "@coze-editor/editor/language-shell";
|
|
2745
|
+
import { python } from "@coze-editor/editor/language-python";
|
|
2746
|
+
import { json } from "@coze-editor/editor/language-json";
|
|
2747
|
+
import { mixLanguages } from "@coze-editor/editor";
|
|
2748
|
+
languages.register("python", python);
|
|
2749
|
+
languages.register("json", {
|
|
2750
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2751
|
+
language: mixLanguages({
|
|
2752
|
+
outerLanguage: json.language
|
|
2753
|
+
}),
|
|
2754
|
+
languageService: json.languageService
|
|
2755
|
+
});
|
|
2756
|
+
languages.register("shell", shell);
|
|
2757
|
+
|
|
2758
|
+
// src/components/code-editor/index.tsx
|
|
2759
|
+
var OriginCodeEditor = createRenderer(preset2, [
|
|
2760
|
+
EditorView4.theme({
|
|
2761
|
+
"&.cm-focused": {
|
|
2762
|
+
outline: "none"
|
|
2763
|
+
}
|
|
2764
|
+
})
|
|
2765
|
+
]);
|
|
2766
|
+
function CodeEditor({
|
|
2767
|
+
value,
|
|
2768
|
+
onChange,
|
|
2769
|
+
languageId = "python",
|
|
2770
|
+
theme = "light",
|
|
2771
|
+
children,
|
|
2772
|
+
placeholder,
|
|
2773
|
+
activeLinePlaceholder
|
|
2774
|
+
}) {
|
|
2775
|
+
const editorRef = useRef4(null);
|
|
2776
|
+
useEffect7(() => {
|
|
2777
|
+
if (editorRef.current?.getValue() !== value) {
|
|
2778
|
+
editorRef.current?.setValue(String(value || ""));
|
|
2779
|
+
}
|
|
2780
|
+
}, [value]);
|
|
2781
|
+
return /* @__PURE__ */ React22.createElement(EditorProvider2, null, /* @__PURE__ */ React22.createElement(
|
|
2782
|
+
OriginCodeEditor,
|
|
2783
|
+
{
|
|
2784
|
+
defaultValue: value,
|
|
2785
|
+
options: {
|
|
2786
|
+
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
2787
|
+
languageId,
|
|
2788
|
+
theme,
|
|
2789
|
+
placeholder
|
|
2790
|
+
},
|
|
2791
|
+
didMount: (editor) => {
|
|
2792
|
+
editorRef.current = editor;
|
|
2793
|
+
},
|
|
2794
|
+
onChange: (e) => onChange?.(e.value)
|
|
2795
|
+
},
|
|
2796
|
+
activeLinePlaceholder && /* @__PURE__ */ React22.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder),
|
|
2797
|
+
children
|
|
2798
|
+
));
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
// src/components/json-editor-with-variables/index.tsx
|
|
2802
|
+
import React25 from "react";
|
|
2803
|
+
|
|
2804
|
+
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2805
|
+
import React23, { useEffect as useEffect8, useState as useState8 } from "react";
|
|
2806
|
+
import { Popover as Popover4, Tree as Tree3 } from "@douyinfe/semi-ui";
|
|
2807
|
+
import {
|
|
2808
|
+
Mention as Mention3,
|
|
2809
|
+
getCurrentMentionReplaceRange as getCurrentMentionReplaceRange3,
|
|
2810
|
+
useEditor as useEditor3,
|
|
2811
|
+
PositionMirror as PositionMirror3
|
|
2812
|
+
} from "@coze-editor/editor/react";
|
|
2813
|
+
function VariableTree2() {
|
|
2814
|
+
const [posKey, setPosKey] = useState8("");
|
|
2815
|
+
const [visible, setVisible] = useState8(false);
|
|
2816
|
+
const [position, setPosition] = useState8(-1);
|
|
2817
|
+
const editor = useEditor3();
|
|
2818
|
+
function insert(variablePath) {
|
|
2819
|
+
const range = getCurrentMentionReplaceRange3(editor.$view.state);
|
|
2820
|
+
if (!range) {
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
editor.replaceText({
|
|
2824
|
+
...range,
|
|
2825
|
+
text: "{{" + variablePath + "}}"
|
|
2826
|
+
});
|
|
2827
|
+
setVisible(false);
|
|
2828
|
+
}
|
|
2829
|
+
function handleOpenChange(e) {
|
|
2830
|
+
setPosition(e.state.selection.main.head);
|
|
2831
|
+
setVisible(e.value);
|
|
2832
|
+
}
|
|
2833
|
+
useEffect8(() => {
|
|
2834
|
+
if (!editor) {
|
|
2835
|
+
return;
|
|
2836
|
+
}
|
|
2837
|
+
}, [editor, visible]);
|
|
2838
|
+
const treeData = useVariableTree({});
|
|
2839
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React23.createElement(
|
|
2840
|
+
Popover4,
|
|
2841
|
+
{
|
|
2842
|
+
visible,
|
|
2843
|
+
trigger: "custom",
|
|
2844
|
+
position: "topLeft",
|
|
2845
|
+
rePosKey: posKey,
|
|
2846
|
+
content: /* @__PURE__ */ React23.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React23.createElement(
|
|
2847
|
+
Tree3,
|
|
2848
|
+
{
|
|
2849
|
+
treeData,
|
|
2850
|
+
onSelect: (v) => {
|
|
2851
|
+
insert(v);
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
))
|
|
2855
|
+
},
|
|
2856
|
+
/* @__PURE__ */ React23.createElement(
|
|
2857
|
+
PositionMirror3,
|
|
2858
|
+
{
|
|
2859
|
+
position,
|
|
2860
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2861
|
+
}
|
|
2862
|
+
)
|
|
2863
|
+
));
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2867
|
+
import React24, { useLayoutEffect as useLayoutEffect5 } from "react";
|
|
2868
|
+
import { createRoot } from "react-dom/client";
|
|
2869
|
+
import { isEqual as isEqual2, last as last3 } from "lodash";
|
|
2870
|
+
import {
|
|
2871
|
+
Disposable as Disposable2,
|
|
2872
|
+
DisposableCollection as DisposableCollection2,
|
|
2873
|
+
useCurrentScope as useCurrentScope2
|
|
2874
|
+
} from "@flowgram.ai/editor";
|
|
2875
|
+
import { Popover as Popover5 } from "@douyinfe/semi-ui";
|
|
2876
|
+
import { IconIssueStroked as IconIssueStroked3 } from "@douyinfe/semi-icons";
|
|
2877
|
+
import { useInjector as useInjector5 } from "@coze-editor/editor/react";
|
|
2878
|
+
import {
|
|
2879
|
+
Decoration as Decoration2,
|
|
2880
|
+
EditorView as EditorView5,
|
|
2881
|
+
MatchDecorator as MatchDecorator2,
|
|
2882
|
+
ViewPlugin as ViewPlugin2,
|
|
2883
|
+
WidgetType as WidgetType2
|
|
2884
|
+
} from "@codemirror/view";
|
|
2885
|
+
|
|
2886
|
+
// src/components/json-editor-with-variables/styles.tsx
|
|
2887
|
+
import styled8 from "styled-components";
|
|
2888
|
+
import { Tag as Tag3 } from "@douyinfe/semi-ui";
|
|
2889
|
+
var UIRootTitle3 = styled8.div`
|
|
2890
|
+
margin-right: 4px;
|
|
2891
|
+
min-width: 20px;
|
|
2892
|
+
overflow: hidden;
|
|
2893
|
+
text-overflow: ellipsis;
|
|
2894
|
+
white-space: nowrap;
|
|
2895
|
+
color: var(--semi-color-text-2);
|
|
2896
|
+
`;
|
|
2897
|
+
var UIVarName3 = styled8.div`
|
|
2898
|
+
overflow: hidden;
|
|
2899
|
+
text-overflow: ellipsis;
|
|
2900
|
+
white-space: nowrap;
|
|
2901
|
+
`;
|
|
2902
|
+
var UITag3 = styled8(Tag3)`
|
|
2903
|
+
display: inline-flex;
|
|
2904
|
+
align-items: center;
|
|
2905
|
+
justify-content: flex-start;
|
|
2906
|
+
max-width: 300px;
|
|
2907
|
+
|
|
2908
|
+
& .semi-tag-content-center {
|
|
2909
|
+
justify-content: flex-start;
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
&.semi-tag {
|
|
2913
|
+
margin: 0 5px;
|
|
2914
|
+
}
|
|
2915
|
+
`;
|
|
2916
|
+
var UIPopoverContent2 = styled8.div`
|
|
2917
|
+
padding: 10px;
|
|
2918
|
+
display: inline-flex;
|
|
2919
|
+
align-items: center;
|
|
2920
|
+
justify-content: flex-start;
|
|
2921
|
+
`;
|
|
2922
|
+
|
|
2923
|
+
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2924
|
+
var VariableTagWidget2 = class extends WidgetType2 {
|
|
2925
|
+
constructor({ keyPath, scope }) {
|
|
2926
|
+
super();
|
|
2927
|
+
this.toDispose = new DisposableCollection2();
|
|
2928
|
+
this.renderIcon = (icon) => {
|
|
2929
|
+
if (typeof icon === "string") {
|
|
2930
|
+
return /* @__PURE__ */ React24.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2931
|
+
}
|
|
2932
|
+
return icon;
|
|
2933
|
+
};
|
|
2934
|
+
this.keyPath = keyPath;
|
|
2935
|
+
this.scope = scope;
|
|
2936
|
+
}
|
|
2937
|
+
renderVariable(v) {
|
|
2938
|
+
if (!v) {
|
|
2939
|
+
this.root.render(
|
|
2940
|
+
/* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React24.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
|
|
2941
|
+
);
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2944
|
+
const rootField = last3(v.parentFields);
|
|
2945
|
+
const rootTitle = /* @__PURE__ */ React24.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2946
|
+
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2947
|
+
this.root.render(
|
|
2948
|
+
/* @__PURE__ */ React24.createElement(
|
|
2949
|
+
Popover5,
|
|
2950
|
+
{
|
|
2951
|
+
content: /* @__PURE__ */ React24.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
2952
|
+
},
|
|
2953
|
+
/* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.key))
|
|
2954
|
+
)
|
|
2955
|
+
);
|
|
2956
|
+
}
|
|
2957
|
+
toDOM(view) {
|
|
2958
|
+
const dom = document.createElement("span");
|
|
2959
|
+
this.root = createRoot(dom);
|
|
2960
|
+
this.toDispose.push(
|
|
2961
|
+
Disposable2.create(() => {
|
|
2962
|
+
this.root.unmount();
|
|
2963
|
+
})
|
|
2964
|
+
);
|
|
2965
|
+
this.toDispose.push(
|
|
2966
|
+
this.scope.available.trackByKeyPath(
|
|
2967
|
+
this.keyPath,
|
|
2968
|
+
(v) => {
|
|
2969
|
+
this.renderVariable(v);
|
|
2970
|
+
},
|
|
2971
|
+
{ triggerOnInit: false }
|
|
2972
|
+
)
|
|
2973
|
+
);
|
|
2974
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
2975
|
+
return dom;
|
|
2976
|
+
}
|
|
2977
|
+
eq(other) {
|
|
2978
|
+
return isEqual2(this.keyPath, other.keyPath);
|
|
2979
|
+
}
|
|
2980
|
+
ignoreEvent() {
|
|
2981
|
+
return false;
|
|
2982
|
+
}
|
|
2983
|
+
destroy(dom) {
|
|
2984
|
+
this.toDispose.dispose();
|
|
2985
|
+
}
|
|
2986
|
+
};
|
|
2987
|
+
function VariableTagInject2() {
|
|
2988
|
+
const injector = useInjector5();
|
|
2989
|
+
const scope = useCurrentScope2();
|
|
2990
|
+
useLayoutEffect5(() => {
|
|
2991
|
+
const atMatcher = new MatchDecorator2({
|
|
2992
|
+
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2993
|
+
decoration: (match) => Decoration2.replace({
|
|
2994
|
+
widget: new VariableTagWidget2({
|
|
2995
|
+
keyPath: match[1]?.split(".") ?? [],
|
|
2996
|
+
scope
|
|
2997
|
+
})
|
|
2998
|
+
})
|
|
2999
|
+
});
|
|
3000
|
+
return injector.inject([
|
|
3001
|
+
ViewPlugin2.fromClass(
|
|
3002
|
+
class {
|
|
3003
|
+
constructor(view) {
|
|
3004
|
+
this.view = view;
|
|
3005
|
+
this.decorations = atMatcher.createDeco(view);
|
|
3006
|
+
}
|
|
3007
|
+
update() {
|
|
3008
|
+
this.decorations = atMatcher.createDeco(this.view);
|
|
3009
|
+
}
|
|
3010
|
+
},
|
|
3011
|
+
{
|
|
3012
|
+
decorations: (p) => p.decorations,
|
|
3013
|
+
provide(p) {
|
|
3014
|
+
return EditorView5.atomicRanges.of(
|
|
3015
|
+
(view) => view.plugin(p)?.decorations ?? Decoration2.none
|
|
3016
|
+
);
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
)
|
|
3020
|
+
]);
|
|
3021
|
+
}, [injector]);
|
|
3022
|
+
return null;
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
// src/components/json-editor-with-variables/index.tsx
|
|
3026
|
+
function JsonEditorWithVariables(props) {
|
|
3027
|
+
return /* @__PURE__ */ React25.createElement(CodeEditor, { languageId: "json", activeLinePlaceholder: "Press '@' to Select variable", ...props }, /* @__PURE__ */ React25.createElement(VariableTree2, null), /* @__PURE__ */ React25.createElement(VariableTagInject2, null));
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
// src/effects/provide-batch-input/index.ts
|
|
3031
|
+
import {
|
|
3032
|
+
ASTFactory as ASTFactory2,
|
|
3033
|
+
createEffectFromVariableProvider,
|
|
3034
|
+
getNodeForm
|
|
3035
|
+
} from "@flowgram.ai/editor";
|
|
3036
|
+
var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
3037
|
+
private: true,
|
|
3038
|
+
parse: (value, ctx) => [
|
|
3039
|
+
ASTFactory2.createVariableDeclaration({
|
|
3040
|
+
key: `${ctx.node.id}_locals`,
|
|
3041
|
+
meta: {
|
|
3042
|
+
title: getNodeForm(ctx.node)?.getValueIn("title"),
|
|
3043
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3044
|
+
},
|
|
3045
|
+
type: ASTFactory2.createObject({
|
|
3046
|
+
properties: [
|
|
3047
|
+
ASTFactory2.createProperty({
|
|
3048
|
+
key: "item",
|
|
3049
|
+
initializer: ASTFactory2.createEnumerateExpression({
|
|
3050
|
+
enumerateFor: ASTFactory2.createKeyPathExpression({
|
|
3051
|
+
keyPath: value.content || []
|
|
3052
|
+
})
|
|
3053
|
+
})
|
|
3054
|
+
}),
|
|
3055
|
+
ASTFactory2.createProperty({
|
|
3056
|
+
key: "index",
|
|
3057
|
+
type: ASTFactory2.createNumber()
|
|
3058
|
+
})
|
|
3059
|
+
]
|
|
3060
|
+
})
|
|
3061
|
+
})
|
|
3062
|
+
]
|
|
3063
|
+
});
|
|
3064
|
+
|
|
3065
|
+
// src/effects/provide-batch-outputs/index.ts
|
|
3066
|
+
import {
|
|
3067
|
+
ASTFactory as ASTFactory3,
|
|
3068
|
+
createEffectFromVariableProvider as createEffectFromVariableProvider2,
|
|
3069
|
+
getNodeForm as getNodeForm2
|
|
3070
|
+
} from "@flowgram.ai/editor";
|
|
3071
|
+
var provideBatchOutputsEffect = createEffectFromVariableProvider2({
|
|
3072
|
+
parse: (value, ctx) => [
|
|
3073
|
+
ASTFactory3.createVariableDeclaration({
|
|
3074
|
+
key: `${ctx.node.id}`,
|
|
3075
|
+
meta: {
|
|
3076
|
+
title: getNodeForm2(ctx.node)?.getValueIn("title"),
|
|
3077
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3078
|
+
},
|
|
3079
|
+
type: ASTFactory3.createObject({
|
|
3080
|
+
properties: Object.entries(value).map(
|
|
3081
|
+
([_key, value2]) => ASTFactory3.createProperty({
|
|
3082
|
+
key: _key,
|
|
3083
|
+
initializer: ASTFactory3.createWrapArrayExpression({
|
|
3084
|
+
wrapFor: ASTFactory3.createKeyPathExpression({
|
|
3085
|
+
keyPath: value2.content || []
|
|
3086
|
+
})
|
|
3087
|
+
})
|
|
3088
|
+
})
|
|
3089
|
+
)
|
|
3090
|
+
})
|
|
3091
|
+
})
|
|
3092
|
+
]
|
|
3093
|
+
});
|
|
3094
|
+
|
|
3095
|
+
// src/effects/auto-rename-ref/index.ts
|
|
3096
|
+
import { isArray, isObject as isObject2 } from "lodash";
|
|
3097
|
+
import {
|
|
3098
|
+
DataEvent,
|
|
3099
|
+
VariableFieldKeyRenameService
|
|
3100
|
+
} from "@flowgram.ai/editor";
|
|
3101
|
+
var autoRenameRefEffect = [
|
|
3102
|
+
{
|
|
3103
|
+
event: DataEvent.onValueInit,
|
|
3104
|
+
effect: (params) => {
|
|
3105
|
+
const { context, form, name } = params;
|
|
3106
|
+
const renameService = context.node.getService(VariableFieldKeyRenameService);
|
|
3107
|
+
const disposable = renameService.onRename(({ before, after }) => {
|
|
3108
|
+
const beforeKeyPath = [
|
|
3109
|
+
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
3110
|
+
before.key
|
|
3111
|
+
];
|
|
3112
|
+
const afterKeyPath = [
|
|
3113
|
+
...after.parentFields.map((_field) => _field.key).reverse(),
|
|
3114
|
+
after.key
|
|
3115
|
+
];
|
|
3116
|
+
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
3117
|
+
if (isRefMatch(_v, beforeKeyPath)) {
|
|
3118
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
3119
|
+
form.setValueIn(_drilldownName, _v);
|
|
3120
|
+
}
|
|
3121
|
+
});
|
|
3122
|
+
});
|
|
3123
|
+
return () => {
|
|
3124
|
+
disposable.dispose();
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
];
|
|
3129
|
+
function isRefMatch(value, targetKeyPath) {
|
|
3130
|
+
return targetKeyPath.every((_key, index) => _key === value.content?.[index]);
|
|
3131
|
+
}
|
|
3132
|
+
function isRef(value) {
|
|
3133
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3134
|
+
}
|
|
3135
|
+
function traverseRef(name, value, cb) {
|
|
3136
|
+
if (isObject2(value)) {
|
|
3137
|
+
if (isRef(value)) {
|
|
3138
|
+
cb(name, value);
|
|
3139
|
+
return;
|
|
3140
|
+
}
|
|
3141
|
+
Object.entries(value).forEach(([_key, _value]) => {
|
|
3142
|
+
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3143
|
+
});
|
|
3144
|
+
return;
|
|
3145
|
+
}
|
|
3146
|
+
if (isArray(value)) {
|
|
3147
|
+
value.forEach((_value, idx) => {
|
|
3148
|
+
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3149
|
+
});
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
// src/effects/provide-json-schema-outputs/index.ts
|
|
3156
|
+
import {
|
|
3157
|
+
ASTFactory as ASTFactory4,
|
|
3158
|
+
createEffectFromVariableProvider as createEffectFromVariableProvider3,
|
|
3159
|
+
getNodeForm as getNodeForm3
|
|
3160
|
+
} from "@flowgram.ai/editor";
|
|
3161
|
+
var provideJsonSchemaOutputs = createEffectFromVariableProvider3({
|
|
3162
|
+
parse: (value, ctx) => [
|
|
3163
|
+
ASTFactory4.createVariableDeclaration({
|
|
3164
|
+
key: `${ctx.node.id}`,
|
|
3165
|
+
meta: {
|
|
3166
|
+
title: getNodeForm3(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3167
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3168
|
+
},
|
|
3169
|
+
type: JsonSchemaUtils.schemaToAST(value)
|
|
3170
|
+
})
|
|
3171
|
+
]
|
|
3172
|
+
});
|
|
3173
|
+
|
|
3174
|
+
// src/effects/sync-variable-title/index.ts
|
|
3175
|
+
import {
|
|
3176
|
+
DataEvent as DataEvent2,
|
|
3177
|
+
FlowNodeVariableData
|
|
3178
|
+
} from "@flowgram.ai/editor";
|
|
3179
|
+
var syncVariableTitle = [
|
|
3180
|
+
{
|
|
3181
|
+
event: DataEvent2.onValueChange,
|
|
3182
|
+
effect: ({ value, context }) => {
|
|
3183
|
+
context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3184
|
+
_scope.output.variables.forEach((_var) => {
|
|
3185
|
+
_var.updateMeta({
|
|
3186
|
+
title: value || context.node.id,
|
|
3187
|
+
icon: context.node.getNodeRegistry().info?.icon
|
|
3188
|
+
});
|
|
3189
|
+
});
|
|
3190
|
+
});
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
];
|
|
3194
|
+
|
|
3195
|
+
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3196
|
+
import {
|
|
3197
|
+
ASTFactory as ASTFactory5,
|
|
3198
|
+
createEffectFromVariableProvider as createEffectFromVariableProvider4,
|
|
3199
|
+
defineFormPluginCreator,
|
|
3200
|
+
getNodeForm as getNodeForm4,
|
|
3201
|
+
getNodePrivateScope,
|
|
3202
|
+
getNodeScope,
|
|
3203
|
+
ScopeChainTransformService,
|
|
3204
|
+
FlowNodeScopeType
|
|
3205
|
+
} from "@flowgram.ai/editor";
|
|
3206
|
+
var provideBatchOutputsEffect2 = createEffectFromVariableProvider4({
|
|
3207
|
+
parse: (value, ctx) => [
|
|
3208
|
+
ASTFactory5.createVariableDeclaration({
|
|
3209
|
+
key: `${ctx.node.id}`,
|
|
3210
|
+
meta: {
|
|
3211
|
+
title: getNodeForm4(ctx.node)?.getValueIn("title"),
|
|
3212
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3213
|
+
},
|
|
3214
|
+
type: ASTFactory5.createObject({
|
|
3215
|
+
properties: Object.entries(value).map(
|
|
3216
|
+
([_key, value2]) => ASTFactory5.createProperty({
|
|
3217
|
+
key: _key,
|
|
3218
|
+
initializer: ASTFactory5.createWrapArrayExpression({
|
|
3219
|
+
wrapFor: ASTFactory5.createKeyPathExpression({
|
|
3220
|
+
keyPath: value2?.content || []
|
|
3221
|
+
})
|
|
3222
|
+
})
|
|
3223
|
+
})
|
|
3224
|
+
)
|
|
3225
|
+
})
|
|
3226
|
+
})
|
|
3227
|
+
]
|
|
3228
|
+
});
|
|
3229
|
+
var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
3230
|
+
name: "batch-outputs-plugin",
|
|
3231
|
+
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3232
|
+
mergeEffect({
|
|
3233
|
+
[outputKey]: provideBatchOutputsEffect2
|
|
3234
|
+
});
|
|
3235
|
+
},
|
|
3236
|
+
onInit(ctx, { outputKey }) {
|
|
3237
|
+
const chainTransformService = ctx.node.getService(ScopeChainTransformService);
|
|
3238
|
+
const batchNodeType = ctx.node.flowNodeType;
|
|
3239
|
+
const transformerId = `${batchNodeType}-outputs`;
|
|
3240
|
+
if (chainTransformService.hasTransformer(transformerId)) {
|
|
3241
|
+
return;
|
|
3242
|
+
}
|
|
3243
|
+
chainTransformService.registerTransformer(transformerId, {
|
|
3244
|
+
transformCovers: (covers, ctx2) => {
|
|
3245
|
+
const node = ctx2.scope.meta?.node;
|
|
3246
|
+
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3247
|
+
return [...covers, getNodeScope(node.parent)];
|
|
3248
|
+
}
|
|
3249
|
+
return covers;
|
|
3250
|
+
},
|
|
3251
|
+
transformDeps(scopes, ctx2) {
|
|
3252
|
+
const scopeMeta = ctx2.scope.meta;
|
|
3253
|
+
if (scopeMeta?.type === FlowNodeScopeType.private) {
|
|
3254
|
+
return scopes;
|
|
3255
|
+
}
|
|
3256
|
+
const node = scopeMeta?.node;
|
|
3257
|
+
if (node?.flowNodeType === batchNodeType) {
|
|
3258
|
+
const childBlocks = node.blocks;
|
|
3259
|
+
return [
|
|
3260
|
+
getNodePrivateScope(node),
|
|
3261
|
+
...childBlocks.map((_childBlock) => getNodeScope(_childBlock))
|
|
3262
|
+
];
|
|
3263
|
+
}
|
|
3264
|
+
return scopes;
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
});
|
|
3269
|
+
export {
|
|
3270
|
+
ArrayIcons,
|
|
3271
|
+
BatchOutputs,
|
|
3272
|
+
BatchVariableSelector,
|
|
3273
|
+
CodeEditor,
|
|
3274
|
+
ConditionRow,
|
|
3275
|
+
ConstantInput,
|
|
3276
|
+
DynamicValueInput,
|
|
3277
|
+
JsonEditorWithVariables,
|
|
3278
|
+
JsonSchemaEditor,
|
|
3279
|
+
JsonSchemaUtils,
|
|
3280
|
+
PromptEditor,
|
|
3281
|
+
PromptEditorWithInputs,
|
|
3282
|
+
PromptEditorWithVariables,
|
|
3283
|
+
TypeSelector,
|
|
3284
|
+
VariableSelector,
|
|
3285
|
+
VariableTypeIcons,
|
|
3286
|
+
autoRenameRefEffect,
|
|
3287
|
+
createBatchOutputsFormPlugin,
|
|
3288
|
+
formatLegacyRefOnInit,
|
|
3289
|
+
formatLegacyRefOnSubmit,
|
|
3290
|
+
formatLegacyRefToNewRef,
|
|
3291
|
+
formatNewRefToLegacyRef,
|
|
3292
|
+
getSchemaIcon,
|
|
3293
|
+
getTypeSelectValue,
|
|
3294
|
+
isLegacyFlowRefValueSchema,
|
|
3295
|
+
isNewFlowRefValueSchema,
|
|
3296
|
+
parseTypeSelectValue,
|
|
3297
|
+
provideBatchInputEffect,
|
|
3298
|
+
provideBatchOutputsEffect,
|
|
3299
|
+
provideJsonSchemaOutputs,
|
|
3300
|
+
syncVariableTitle,
|
|
3301
|
+
useVariableTree
|
|
3302
|
+
};
|
|
3303
|
+
//# sourceMappingURL=index.js.map
|